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 26, 2024
1 parent fe2ae13 commit 0fb1ac4
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 @@ -1986,8 +1986,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 @@ -2015,18 +2017,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 0fb1ac4

Please sign in to comment.