Skip to content

Commit

Permalink
add ApiNetworkClock and endpoint skeloton
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Feb 27, 2020
1 parent c1ab33d commit b5ab398
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/core/cardano-wallet-core.cabal
Expand Up @@ -67,6 +67,7 @@ library
, memory
, monad-logger
, network
, ntp-client
, OddWord
, path-pieces
, persistent
Expand Down
7 changes: 7 additions & 0 deletions lib/core/src/Cardano/Wallet/Api.hs
Expand Up @@ -65,6 +65,7 @@ module Cardano.Wallet.Api
, Network
, GetNetworkInformation
, GetNetworkParameters
, GetNetworkClock

, Proxy_
, PostExternalTransaction
Expand All @@ -88,6 +89,7 @@ import Cardano.Wallet.Api.Types
, ApiCoinSelection
, ApiEpochNumber
, ApiFee
, ApiNetworkClock
, ApiNetworkInformation
, ApiNetworkParameters
, ApiNetworkTip
Expand Down Expand Up @@ -439,6 +441,7 @@ type GetByronWalletMigrationInfo = "byron-wallets"
type Network =
GetNetworkInformation
:<|> GetNetworkParameters
:<|> GetNetworkClock

type GetNetworkInformation = "network"
:> "information"
Expand All @@ -449,6 +452,10 @@ type GetNetworkParameters = "network"
:> Capture "epochId" ApiEpochNumber
:> Get '[JSON] ApiNetworkParameters

type GetNetworkClock = "network"
:> "clock"
:> Get '[JSON] ApiNetworkClock

{-------------------------------------------------------------------------------
Proxy_
Expand Down
7 changes: 7 additions & 0 deletions lib/core/src/Cardano/Wallet/Api/Types.hs
Expand Up @@ -65,6 +65,7 @@ module Cardano.Wallet.Api.Types
, AddressAmount (..)
, ApiErrorCode (..)
, ApiNetworkInformation (..)
, ApiNetworkClock (..)
, ApiBlockReference (..)
, ApiNetworkTip (..)
, Iso8601Time (..)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Expand Up @@ -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
Expand Down

0 comments on commit b5ab398

Please sign in to comment.