Skip to content

Commit

Permalink
Co-locate UTxO-related arguments of balanceTransaction. (#4281)
Browse files Browse the repository at this point in the history
## Issue

None, noticed while reviewing code.

## Description

This PR adjusts the type signature of `balanceTransaction` so that the
following UTxO-related arguments occur together:
- `UTxOAssumptions`
- `UTxOIndex`
  • Loading branch information
jonathanknowles authored Nov 30, 2023
2 parents 9c6ef91 + 375a002 commit 6a7bfdf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,7 @@ balanceTransaction
( MonadRandom m
, IsRecentEra era
)
=> UTxOAssumptions
-> PParams era
=> PParams era
-- Protocol parameters. Can be retrieved via Local State Query to a
-- local node.
--
Expand All @@ -535,15 +534,16 @@ balanceTransaction
-- forfeited. We should ideally investigate and clarify as part of ADP-1544
-- or similar ticket. Relevant ledger code:
-- https://github.com/input-output-hk/cardano-ledger/blob/fdec04e8c071060a003263cdcb37e7319fb4dbf3/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxInfo.hs#L428-L440
-> UTxOAssumptions
-> UTxOIndex era
-> ChangeAddressGen changeState
-> changeState
-> PartialTx era
-> ExceptT (ErrBalanceTx era) m (Tx era, changeState)
balanceTransaction
utxoAssumptions
pp
timeTranslation
utxoAssumptions
utxo
genChange
s
Expand All @@ -554,9 +554,9 @@ balanceTransaction
balanceWith strategy =
balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment
@era @m @changeState
utxoAssumptions
pp
timeTranslation
utxoAssumptions
utxo
genChange
s
Expand Down Expand Up @@ -641,19 +641,19 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment
( MonadRandom m
, IsRecentEra era
)
=> UTxOAssumptions
-> PParams era
=> PParams era
-> TimeTranslation
-> UTxOAssumptions
-> UTxOIndex era
-> ChangeAddressGen changeState
-> changeState
-> SelectionStrategy
-> PartialTx era
-> ExceptT (ErrBalanceTx era) m (Tx era, changeState)
balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment
utxoAssumptions
pp
timeTranslation
utxoAssumptions
(UTxOIndex walletUTxO internalUtxoAvailable walletLedgerUTxO)
genChange
s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3464,9 +3464,9 @@ balanceTransaction
. fst
)
$ Write.balanceTransaction
utxoAssumptions
pp
timeTranslation
utxoAssumptions
utxoIndex
(W.defaultChangeAddressGen argGenChange)
(getState wallet)
Expand Down
4 changes: 2 additions & 2 deletions lib/wallet/src/Cardano/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2353,9 +2353,9 @@ buildTransactionPure
withExceptT Left $
first Write.toCardanoApiTx <$>
balanceTransaction @_ @_ @s
(utxoAssumptionsForWallet (walletFlavor @s))
pparams
timeTranslation
(utxoAssumptionsForWallet (walletFlavor @s))
utxoIndex
changeAddrGen
(getState wallet)
Expand Down Expand Up @@ -3006,9 +3006,9 @@ transactionFee DBLayer{atomically, walletState} protocolParams
res <- runExceptT $
first (Write.toCardanoApiTx @era) <$>
balanceTransaction @_ @_ @s
(utxoAssumptionsForWallet (walletFlavor @s))
protocolParams
timeTranslation
(utxoAssumptionsForWallet (walletFlavor @s))
utxoIndex
changeAddressGen
(getState wallet)
Expand Down
4 changes: 2 additions & 2 deletions lib/wallet/test/unit/Internal/Cardano/Write/Tx/BalanceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1981,9 +1981,9 @@ balanceTx
= (`evalRand` stdGenFromSeed seed) $ runExceptT $ do
(transactionInEra, _nextChangeState) <-
balanceTransaction
utxoAssumptions
protocolParameters
timeTranslation
utxoAssumptions
utxoIndex
genChange
s
Expand All @@ -2005,9 +2005,9 @@ balanceTransactionWithDummyChangeState
balanceTransactionWithDummyChangeState utxoAssumptions utxo seed partialTx =
(`evalRand` stdGenFromSeed seed) $ runExceptT $
balanceTransaction
utxoAssumptions
mockPParamsForBalancing
dummyTimeTranslation
utxoAssumptions
utxoIndex
dummyChangeAddrGen
(DummyChangeState 0)
Expand Down

0 comments on commit 6a7bfdf

Please sign in to comment.