From b5ab39877663fb8154cf7b630a2b8ab592efdfce Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 27 Feb 2020 13:05:14 +0100 Subject: [PATCH] add ApiNetworkClock and endpoint skeloton --- lib/core/cardano-wallet-core.cabal | 1 + lib/core/src/Cardano/Wallet/Api.hs | 7 +++++++ lib/core/src/Cardano/Wallet/Api/Types.hs | 7 +++++++ stack.yaml | 1 + 4 files changed, 16 insertions(+) diff --git a/lib/core/cardano-wallet-core.cabal b/lib/core/cardano-wallet-core.cabal index 3ea03d58e14..b7bfcd8933d 100644 --- a/lib/core/cardano-wallet-core.cabal +++ b/lib/core/cardano-wallet-core.cabal @@ -67,6 +67,7 @@ library , memory , monad-logger , network + , ntp-client , OddWord , path-pieces , persistent diff --git a/lib/core/src/Cardano/Wallet/Api.hs b/lib/core/src/Cardano/Wallet/Api.hs index 79c8de09d8a..513e2cd53f8 100644 --- a/lib/core/src/Cardano/Wallet/Api.hs +++ b/lib/core/src/Cardano/Wallet/Api.hs @@ -65,6 +65,7 @@ module Cardano.Wallet.Api , Network , GetNetworkInformation , GetNetworkParameters + , GetNetworkClock , Proxy_ , PostExternalTransaction @@ -88,6 +89,7 @@ import Cardano.Wallet.Api.Types , ApiCoinSelection , ApiEpochNumber , ApiFee + , ApiNetworkClock , ApiNetworkInformation , ApiNetworkParameters , ApiNetworkTip @@ -439,6 +441,7 @@ type GetByronWalletMigrationInfo = "byron-wallets" type Network = GetNetworkInformation :<|> GetNetworkParameters + :<|> GetNetworkClock type GetNetworkInformation = "network" :> "information" @@ -449,6 +452,10 @@ type GetNetworkParameters = "network" :> Capture "epochId" ApiEpochNumber :> Get '[JSON] ApiNetworkParameters +type GetNetworkClock = "network" + :> "clock" + :> Get '[JSON] ApiNetworkClock + {------------------------------------------------------------------------------- Proxy_ diff --git a/lib/core/src/Cardano/Wallet/Api/Types.hs b/lib/core/src/Cardano/Wallet/Api/Types.hs index 90569c7bf81..51f82fbc491 100644 --- a/lib/core/src/Cardano/Wallet/Api/Types.hs +++ b/lib/core/src/Cardano/Wallet/Api/Types.hs @@ -65,6 +65,7 @@ module Cardano.Wallet.Api.Types , AddressAmount (..) , ApiErrorCode (..) , ApiNetworkInformation (..) + , ApiNetworkClock (..) , ApiBlockReference (..) , ApiNetworkTip (..) , Iso8601Time (..) @@ -217,6 +218,8 @@ import GHC.Generics ( Generic ) import GHC.TypeLits ( Nat, Symbol ) +import Network.NTP.Query + ( NtpStatus ) import Numeric.Natural ( Natural ) import Servant.API @@ -479,6 +482,10 @@ data ApiNetworkInformation = ApiNetworkInformation , networkTip :: !ApiNetworkTip } deriving (Eq, Generic, Show) +newtype ApiNetworkClock = ApiNetworkClock + { ntpStatus :: !(ApiT NtpStatus) + } deriving (Eq, Generic, Show) + -- | Error codes returned by the API, in the form of snake_cased strings data ApiErrorCode = NoSuchWallet diff --git a/stack.yaml b/stack.yaml index 0ce44eeaa32..31d8ac8d5b6 100644 --- a/stack.yaml +++ b/stack.yaml @@ -117,6 +117,7 @@ extra-deps: - ouroboros-consensus - typed-protocols - typed-protocols-cbor + - ntp-client flags: # Avoid a system library which causes difficulty with cross-compilation