Skip to content

Commit

Permalink
refactor: explicit parameters for the Wallet.constructTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Unisay committed Nov 15, 2022
1 parent 4aeea50 commit ab4539e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2447,8 +2447,8 @@ constructTransaction
, extraCoinSink = fromMaybe (Coin 0) deposit
}
unbalancedTx <- liftHandler $
W.constructTransaction @_ @_ @_ @n @'CredFromKeyK
wrk wid era txCtx' preSel
W.constructTransaction @n @'CredFromKeyK
txLayer netLayer db wid era txCtx' preSel

let balancedPostData = ApiBalanceTransactionPostData
{ transaction = ApiT unbalancedTx
Expand Down
30 changes: 10 additions & 20 deletions lib/wallet/src/Cardano/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2513,31 +2513,21 @@ buildAndSignTransaction ctx wid era mkRwdAcct pwd txCtx sel = db & \DBLayer{..}

-- | Construct an unsigned transaction from a given selection.
constructTransaction
:: forall ctx s k (n :: NetworkDiscriminant) ktype.
( HasTransactionLayer k ktype ctx
, HasDBLayer IO s k ctx
, HasNetworkLayer IO ctx
, Typeable s
, Typeable n
, Typeable k
)
=> ctx
:: forall (n :: NetworkDiscriminant) ktype
. TransactionLayer ShelleyKey ktype SealedTx
-> NetworkLayer IO Block
-> DBLayer IO (SeqState n ShelleyKey) ShelleyKey
-> WalletId
-> Cardano.AnyCardanoEra
-> TransactionCtx
-> PreSelection
-> ExceptT ErrConstructTx IO SealedTx
constructTransaction ctx wid era txCtx preSel = db & \DBLayer{..} -> do
(_, xpub, _) <- withExceptT ErrConstructTxReadRewardAccount $
shelleyOnlyReadRewardAccount @s @k @n db wid
mapExceptT atomically $ do
pp <- liftIO $ currentProtocolParameters nl
withExceptT ErrConstructTxBody $ ExceptT $ pure $
mkUnsignedTransaction tl era xpub pp txCtx (Left preSel)
where
db = ctx ^. dbLayer @IO @s @k
tl = ctx ^. transactionLayer @k @ktype
nl = ctx ^. networkLayer
constructTransaction txLayer netLayer db wid era txCtx preSel = do
(_, xpub, _) <- readRewardAccount db wid
& withExceptT ErrConstructTxReadRewardAccount
pp <- liftIO $ currentProtocolParameters netLayer
mkUnsignedTransaction txLayer era xpub pp txCtx (Left preSel)
& withExceptT ErrConstructTxBody . except

-- | Construct an unsigned transaction from a given selection
-- for a shared wallet.
Expand Down

0 comments on commit ab4539e

Please sign in to comment.