Skip to content

Commit

Permalink
Do not throw exception when looking for policy public key
Browse files Browse the repository at this point in the history
Delegate that task to callers
  • Loading branch information
abailly committed Dec 17, 2024
1 parent eab1d67 commit ca7546a
Show file tree
Hide file tree
Showing 3 changed files with 3,912 additions and 3,115 deletions.
35 changes: 16 additions & 19 deletions lib/api/src/Cardano/Wallet/Api/Http/Server/Handlers/MintBurn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
-- |
-- Copyright: © 2020 IOHK
-- License: Apache-2.0
--

module Cardano.Wallet.Api.Http.Server.Handlers.MintBurn
( convertApiAssetMintBurn
, getTxApiAssetMintBurn
)
where
( convertApiAssetMintBurn
, getTxApiAssetMintBurn
)
where

import Prelude hiding
( (.)
Expand Down Expand Up @@ -44,9 +42,6 @@ import Control.Category
import Control.Monad.IO.Class
( MonadIO (liftIO)
)
import Control.Monad.Trans.Except
( runExceptT
)
import Data.Either.Extra
( eitherToMaybe
)
Expand All @@ -61,16 +56,18 @@ convertApiAssetMintBurn
-> (TokenMapWithScripts, TokenMapWithScripts)
-> Handler (ApiAssetMintBurn, ApiAssetMintBurn)
convertApiAssetMintBurn ctx (mint, burn) = do
xpubM <- fmap (fmap fst . eitherToMaybe)
<$> liftIO . runExceptT $ readPolicyPublicKey ctx
let convert tokenWithScripts = ApiAssetMintBurn
{ tokens = toApiTokens tokenWithScripts
, walletPolicyKeyHash =
uncurry ApiPolicyKey . computeKeyPayload (Just True) <$>
includePolicyKeyInfo tokenWithScripts xpubM
, walletPolicyKeyIndex =
policyIx <$ includePolicyKeyInfo tokenWithScripts xpubM
}
xpubM <-
fmap fst . eitherToMaybe
<$> liftIO (readPolicyPublicKey ctx)
let convert tokenWithScripts =
ApiAssetMintBurn
{ tokens = toApiTokens tokenWithScripts
, walletPolicyKeyHash =
uncurry ApiPolicyKey . computeKeyPayload (Just True)
<$> includePolicyKeyInfo tokenWithScripts xpubM
, walletPolicyKeyIndex =
policyIx <$ includePolicyKeyInfo tokenWithScripts xpubM
}
pure (convert mint, convert burn)

getTxApiAssetMintBurn
Expand Down
Loading

0 comments on commit ca7546a

Please sign in to comment.