Skip to content

Commit

Permalink
Fix datum conversion in 'fromLedgerTxOuts' when using 'fromAlonzoTxOut'
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhvh2205 committed Aug 30, 2024
1 parent 00bb673 commit 026cc1a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cardano-api/internal/Cardano/Api/Tx/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2010,8 +2010,10 @@ fromLedgerTxOuts sbe body scriptdata =
ShelleyBasedEraAlonzo ->
[ fromAlonzoTxOut
AlonzoEraOnwardsAlonzo
txdatums
txout
| txout <- toList (body ^. L.outputsTxBodyL)
| let txdatums = selectTxDatums scriptdata
, txout <- toList (body ^. L.outputsTxBodyL)
]
ShelleyBasedEraBabbage ->
[ fromBabbageTxOut
Expand Down Expand Up @@ -2039,18 +2041,31 @@ selectTxDatums (TxBodyScriptData _ (Alonzo.TxDats' datums) _) = datums
fromAlonzoTxOut
:: ()
=> AlonzoEraOnwards era
-> Map (L.DataHash StandardCrypto) (L.Data ledgerera)
-> L.TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
fromAlonzoTxOut w txOut =
fromAlonzoTxOut w txdatums txOut =
alonzoEraOnwardsConstraints w $
TxOut
(fromShelleyAddr shelleyBasedEra (txOut ^. L.addrTxOutL))
(TxOutValueShelleyBased sbe (txOut ^. L.valueTxOutL))
(fromAlonzoTxOutDatumHash w (txOut ^. L.dataHashTxOutL))
(fromAlonzoTxOutDatum w txdatums (txOut ^. L.dataHashTxOutL))
ReferenceScriptNone
where
sbe = alonzoEraOnwardsToShelleyBasedEra w

fromAlonzoTxOutDatum
:: ()
=> AlonzoEraOnwards era
-> Map (L.DataHash StandardCrypto) (L.Data ledgerera)
-> StrictMaybe (L.DataHash StandardCrypto)
-> TxOutDatum CtxTx era
fromAlonzoTxOutDatum w txdatums = \case
SNothing -> TxOutDatumNone
SJust dh
| Just d <- Map.lookup dh txdatums -> TxOutDatumInTx' w (ScriptDataHash dh) (fromAlonzoData d)
| otherwise -> TxOutDatumHash w (ScriptDataHash dh)

fromBabbageTxOut
:: forall era
. ()
Expand Down

0 comments on commit 026cc1a

Please sign in to comment.