Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reuse getTransaction in shared context
- Loading branch information
1 parent
349e6b1
commit b7ce49e
Showing
5 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Handlers/Certificates.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
-- | | ||
-- Copyright: © 2020 IOHK | ||
-- License: Apache-2.0 | ||
-- | ||
|
||
module Cardano.Wallet.Api.Http.Server.Handlers.Certificates | ||
( getApiAnyCertificates | ||
) | ||
where | ||
|
||
import Cardano.Wallet.Api | ||
( ApiLayer ) | ||
import Cardano.Wallet.Api.Http.Server.Error | ||
( liftHandler ) | ||
import Cardano.Wallet.Api.Http.Server.Handlers.TxCBOR | ||
( ParsedTxCBOR (..) ) | ||
import Cardano.Wallet.Api.Types.Certificate | ||
( ApiAnyCertificate, mkApiAnyCertificate ) | ||
import Cardano.Wallet.Primitive.Types | ||
( WalletId ) | ||
import Cardano.Wallet.Registry | ||
( WorkerCtx ) | ||
import Data.Typeable | ||
( Typeable ) | ||
import Prelude hiding | ||
( (.) ) | ||
import Servant.Server | ||
( Handler ) | ||
|
||
import qualified Cardano.Wallet as W | ||
|
||
-- | Promote certificates of a transaction to API type, | ||
-- using additional context from the 'WorkerCtx'. | ||
getApiAnyCertificates | ||
:: forall ctx s k ktype n. | ||
( ctx ~ ApiLayer s k ktype | ||
, Typeable s | ||
, Typeable n | ||
) | ||
=> WorkerCtx ctx | ||
-> WalletId | ||
-> ParsedTxCBOR | ||
-> Handler [ApiAnyCertificate n] | ||
getApiAnyCertificates wrk wid ParsedTxCBOR{certificates} = do | ||
(acct, _, acctPath) <- | ||
liftHandler $ W.readRewardAccount @_ @s @k @n wrk wid | ||
pure $ mkApiAnyCertificate acct acctPath <$> certificates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters