Skip to content

Commit

Permalink
implement the server handler
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed Aug 10, 2022
1 parent 153df3c commit fe28866
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -98,6 +98,7 @@ module Cardano.Wallet.Api.Server
, postPolicyId
, constructSharedTransaction
, decodeSharedTransaction
, getBlocksLatestHeader

-- * Server error responses
, IsServerError(..)
Expand All @@ -119,7 +120,8 @@ module Cardano.Wallet.Api.Server

-- * Logging
, WalletEngineLog (..)
) where
)
where

import Prelude

Expand Down Expand Up @@ -338,6 +340,8 @@ import Cardano.Wallet.Api.Types
, toApiNetworkParameters
, toApiUtxoStatistics
)
import Cardano.Wallet.Api.Types.BlockHeader
( ApiBlockHeader, mkApiBlockHeader )
import Cardano.Wallet.Api.Types.SchemaMetadata
( TxMetadataSchema (..), TxMetadataWithSchema (TxMetadataWithSchema) )
import Cardano.Wallet.CoinSelection
Expand Down Expand Up @@ -678,7 +682,8 @@ import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TokenBundle
import qualified Cardano.Wallet.Primitive.Types.TokenMap as TokenMap
import qualified Cardano.Wallet.Primitive.Types.Tx as W
import qualified Cardano.Wallet.Primitive.Types.UTxO as UTxO
import qualified Cardano.Wallet.Primitive.Types.UTxOIndex as UTxOIndex
import qualified Cardano.Wallet.Primitive.Types.UTxOIndex.Internal as UTxOIndex
( toMap )
import qualified Cardano.Wallet.Primitive.Types.UTxOSelection as UTxOSelection
import qualified Cardano.Wallet.Registry as Registry
import qualified Control.Concurrent.Concierge as Concierge
Expand Down Expand Up @@ -3769,6 +3774,8 @@ getNetworkParameters (_block0, genesisNp) nl tl = do
getNetworkClock :: NtpClient -> Bool -> Handler ApiNetworkClock
getNetworkClock client = liftIO . getNtpStatus client

getBlocksLatestHeader :: NetworkLayer IO Block -> Handler ApiBlockHeader
getBlocksLatestHeader nl = liftIO $ mkApiBlockHeader <$> NW.currentNodeTip nl
{-------------------------------------------------------------------------------
Miscellaneous
-------------------------------------------------------------------------------}
Expand Down
8 changes: 7 additions & 1 deletion lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs
Expand Up @@ -75,6 +75,7 @@ import Cardano.Wallet.Api.Server
, getAccountPublicKey
, getAsset
, getAssetDefault
, getBlocksLatestHeader
, getCurrentEpoch
, getNetworkClock
, getNetworkInformation
Expand Down Expand Up @@ -158,6 +159,8 @@ import Cardano.Wallet.Api.Types
, SettingsPutData (..)
, SomeByronWalletPostData (..)
)
import Cardano.Wallet.Api.Types.BlockHeader
( ApiBlockHeader )
import Cardano.Wallet.Api.Types.SchemaMetadata
( TxMetadataSchema (..), parseSimpleMetadataFlag )
import Cardano.Wallet.Primitive.AddressDerivation
Expand Down Expand Up @@ -266,7 +269,7 @@ server byron icarus shelley multisig spl ntp blockchainSource =
:<|> sharedWalletKeys multisig
:<|> sharedAddresses multisig
:<|> sharedTransactions multisig
:<|> error "not implemented"
:<|> blocks
where
wallets :: Server Wallets
wallets = deleteWallet shelley
Expand Down Expand Up @@ -619,6 +622,9 @@ server byron icarus shelley multisig spl ntp blockchainSource =
(knownPools spl) (getPoolLifeCycleStatus spl)
:<|> decodeSharedTransaction apilayer

blocks :: Handler ApiBlockHeader
blocks = getBlocksLatestHeader (shelley ^. networkLayer)

postAnyAddress
:: NetworkId
-> ApiAddressData
Expand Down

0 comments on commit fe28866

Please sign in to comment.