Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix datum conversion in 'fromLedgerTxOuts' when using 'fromAlonzoTxOut' #620

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading