Skip to content

Commit

Permalink
Use Set instead of list for extraCollateral.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Apr 30, 2024
1 parent 1d1bbd3 commit 9a88ac7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ balanceTxInner
minfee = Convert.toWalletCoin $ evaluateMinimumFee pp tx witCount
update = TxUpdate
{ extraInputs = mempty
, extraCollateral = []
, extraCollateral = mempty
, extraOutputs = []
, extraInputScripts = []
, feeUpdate = UseNewTxFee minfee
Expand All @@ -885,7 +885,7 @@ balanceTxInner

data SelectAssetsResult = SelectAssetsResult
{ extraInputs :: Set W.TxIn
, extraCollateral :: [W.TxIn]
, extraCollateral :: Set W.TxIn
, extraOutputs :: [W.TxOut]
, extraInputScripts :: [CA.Script CA.KeyHash]
} deriving (Eq, Show)
Expand Down Expand Up @@ -1077,7 +1077,7 @@ selectAssets pp utxoAssumptions outs' redeemers
-- The correctness of balanceTx is currently not affected, but
-- it is misleading.
-- https://cardanofoundation.atlassian.net/browse/ADP-3355
, extraCollateral = map fst collateral
, extraCollateral = Set.fromList (map fst collateral)
, extraOutputs = change
, extraInputScripts = inputScripts
}
Expand Down Expand Up @@ -1158,7 +1158,7 @@ splitSignedValue v = (bNegative, bPositive)
-- | Describes modifications that can be made to a `Tx` using `updateTx`.
data TxUpdate = TxUpdate
{ extraInputs :: Set W.TxIn
, extraCollateral :: [W.TxIn]
, extraCollateral :: Set W.TxIn
-- ^ Only used in the Alonzo era and later. Will be silently ignored in
-- previous eras.
, extraOutputs :: [W.TxOut]
Expand All @@ -1175,7 +1175,7 @@ data TxUpdate = TxUpdate
noTxUpdate :: TxUpdate
noTxUpdate = TxUpdate
{ extraInputs = mempty
, extraCollateral = []
, extraCollateral = mempty
, extraOutputs = []
, extraInputScripts = []
, feeUpdate = UseOldTxFee
Expand Down Expand Up @@ -1264,7 +1264,7 @@ modifyShelleyTxBody txUpdate =
TxUpdate {extraInputs, extraCollateral, extraOutputs, feeUpdate} = txUpdate
extraOutputs' = StrictSeq.fromList $ map (toLedgerTxOut era) extraOutputs
extraInputs' = Set.map Convert.toLedger extraInputs
extraCollateral' = Set.fromList $ Convert.toLedger <$> extraCollateral
extraCollateral' = Set.map Convert.toLedger extraCollateral

modifyFee old = case feeUpdate of
UseNewTxFee c -> Convert.toLedger c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ prop_updateTx
:: forall era. era ~ Write.BabbageEra
=> Tx era
-> Set W.TxIn
-> [W.TxIn]
-> Set W.TxIn
-> [W.TxOut]
-> W.Coin
-> Property
Expand All @@ -1558,7 +1558,7 @@ prop_updateTx tx extraInputs extraCollateral extraOutputs newFee = do
<> StrictSeq.fromList (fromWalletTxOut <$> extraOutputs)
, fee tx' === Convert.toLedger newFee
, collateralIns tx' === collateralIns tx
<> Set.fromList (fromWalletTxIn <$> extraCollateral)
<> Set.map fromWalletTxIn extraCollateral
]
where
inputs = view (bodyTxL . inputsTxBodyL)
Expand Down

0 comments on commit 9a88ac7

Please sign in to comment.