Skip to content

Commit

Permalink
Simplify type of Cardano.Wallet.constructTransaction.
Browse files Browse the repository at this point in the history
The function `Cardano.Wallet.constructTransaction` is only ever called
with a `Left PreSelection`, and never called with a `Right Selection`.

Therefore, we can simplify the selection argument type from
`Either PreSelection Selection` to just `PreSelection`.
  • Loading branch information
jonathanknowles authored and Unisay committed Nov 10, 2022
1 parent c568aa0 commit d23c432
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2439,7 +2439,7 @@ constructTransaction
, extraCoinSink = fromMaybe (Coin 0) deposit
}
unbalancedTx <- liftHandler $
W.constructTransaction @_ @s @k @n wrk wid era txCtx' (Left preSel)
W.constructTransaction @_ @s @k @n wrk wid era txCtx' preSel

let balancedPostData = ApiBalanceTransactionPostData
{ transaction = ApiT unbalancedTx
Expand Down
6 changes: 3 additions & 3 deletions lib/wallet/src/Cardano/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2532,15 +2532,15 @@ constructTransaction
-> WalletId
-> Cardano.AnyCardanoEra
-> TransactionCtx
-> Either PreSelection (SelectionOf TxOut)
-> PreSelection
-> ExceptT ErrConstructTx IO SealedTx
constructTransaction ctx wid era txCtx sel = db & \DBLayer{..} -> do
constructTransaction ctx wid era txCtx preSel = db & \DBLayer{..} -> do
(_, xpub, _) <- withExceptT ErrConstructTxReadRewardAccount $
readRewardAccount @ctx @s @k @n ctx wid
mapExceptT atomically $ do
pp <- liftIO $ currentProtocolParameters nl
withExceptT ErrConstructTxBody $ ExceptT $ pure $
mkUnsignedTransaction tl era xpub pp txCtx sel
mkUnsignedTransaction tl era xpub pp txCtx (Left preSel)
where
db = ctx ^. dbLayer @IO @s @k
tl = ctx ^. transactionLayer @k @'CredFromKeyK
Expand Down

0 comments on commit d23c432

Please sign in to comment.