Skip to content

Commit

Permalink
[ADP-3272] Remove cardano-api conversions from restrictResolution. (
Browse files Browse the repository at this point in the history
#4557)

This PR removes conversions to and from `cardano-api` types from the
`restrictResolution` function.

## Issue

ADP-3272
  • Loading branch information
jonathanknowles authored Apr 22, 2024
2 parents 0e03af3 + 081595c commit cb21a8e
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/BalanceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ import Internal.Cardano.Write.Tx
, recentEra
, serializeTx
, toCardanoApiTx
, toCardanoApiUTxO
, unsafeUtxoFromTxOutsInRecentEra
)
import Internal.Cardano.Write.Tx.Balance
Expand Down Expand Up @@ -2302,21 +2301,11 @@ paymentPartialTx txouts =
-- shrinking the CBOR.
--
-- NOTE: Perhaps ideally 'PartialTx' would handle this automatically.
restrictResolution
:: forall era. IsRecentEra era
=> PartialTx era
-> PartialTx era
restrictResolution partialTx@PartialTx {tx, extraUTxO} =
partialTx
{ extraUTxO
= fromCardanoApiUTxO
$ CardanoApi.UTxO
$ extraUTxOMap `Map.restrictKeys` inputsInTx (toCardanoApiTx tx)
}
restrictResolution :: IsRecentEra era => PartialTx era -> PartialTx era
restrictResolution partialTx@PartialTx {tx, extraUTxO} = partialTx
{extraUTxO = UTxO $ unUTxO extraUTxO `Map.restrictKeys` txIns}
where
CardanoApi.UTxO extraUTxOMap = toCardanoApiUTxO extraUTxO
inputsInTx (CardanoApi.Tx (CardanoApi.TxBody bod) _) =
Set.fromList $ map fst $ CardanoApi.txIns bod
txIns = tx ^. bodyTxL . inputsTxBodyL

serializedSize
:: forall era. IsRecentEra era
Expand Down

0 comments on commit cb21a8e

Please sign in to comment.