Skip to content

Commit

Permalink
renderTxWithUTxO: add collateralInputLines
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Nov 26, 2024
1 parent 8582200 commit f7fadff
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions hydra-cardano-api/src/Hydra/Cardano/Api/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ renderTxWithUTxO utxo (Tx body _wits) =
<> [""]
<> inputLines
<> [""]
<> collateralInputLines
<> [""]
<> referenceInputLines
<> [""]
<> outputLines
<> [""]
<> totalCollateralLines
<> [""]
<> returnCollateralLines
<> [""]
<> feeLines
<> [""]
<> validityLines
<> [""]
<> mintLines
Expand Down Expand Up @@ -69,6 +77,15 @@ renderTxWithUTxO utxo (Tx body _wits) =
Api.TxInsReferenceNone -> []
Api.TxInsReference refInputs -> refInputs

collateralInputLines =
"== COLLATERAL INPUTS (" <> show (length collateralInputs) <> ")"
: (("- " <>) . prettyTxIn <$> sort collateralInputs)

collateralInputs =
case txInsCollateral content of
Api.TxInsCollateralNone -> []
Api.TxInsCollateral refInputs -> refInputs

prettyTxIn i =
case UTxO.resolve i utxo of
Nothing -> T.unpack $ renderTxIn i
Expand All @@ -79,6 +96,7 @@ renderTxWithUTxO utxo (Tx body _wits) =
<> ("\n " <> prettyDatumUtxo (Api.txOutDatum o))
<> ("\n " <> prettyReferenceScript (Api.txOutReferenceScript o))

outputLines :: [String]
outputLines =
[ "== OUTPUTS (" <> show (length outs) <> ")"
, "Total number of assets: " <> show totalNumberOfAssets
Expand All @@ -100,6 +118,25 @@ renderTxWithUTxO utxo (Tx body _wits) =
let totalValue = foldMap Api.txOutValue outs
in length $ toList totalValue

totalCollateralLines :: [String]
totalCollateralLines =
[ "== TOTAL COLLATERAL"
, show $ txTotalCollateral content
]

returnCollateralLines :: [String]
returnCollateralLines =
[ "== RETURN COLLATERAL"
, show $ txReturnCollateral content
]

feeLines :: [String]
feeLines =
[ "== FEE"
, show $ txFee content
]

validityLines :: [String]
validityLines =
[ "== VALIDITY"
, show (txValidityLowerBound content)
Expand Down

0 comments on commit f7fadff

Please sign in to comment.