Skip to content

Commit

Permalink
Make sure getDatum returns corect type. Rename isAdaOly
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Feb 25, 2022
1 parent 47d8a35 commit 379c286
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ feesOK pp tx (UTxO utxo) = do
failureUnless
(all vKeyLocked collat)
(inject (ScriptsNotPaidUTxO (UTxO (SplitMap.filter (not . vKeyLocked) collat)))),
-- Part 4 (adaOnly balance)
failureUnless (Val.adaOnly valbalance) (inject (CollateralContainsNonADA @era valbalance)),
-- Part 4 (isAdaOnly balance)
failureUnless (Val.isAdaOnly valbalance) (inject (CollateralContainsNonADA @era valbalance)),
-- Part 5 (balance ≥ minCollateral tx pp)
failureUnless
(coinbalance >= minCollateral txb pp)
Expand Down
25 changes: 11 additions & 14 deletions eras/babbage/impl/src/Cardano/Ledger/Babbage/Scripts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ getTxIn (Minting _policyid) = Nothing
getTxIn (Rewarding _rewaccnt) = Nothing
getTxIn (Certifying _dcert) = Nothing

-- | Extract binary data either directly from the `Core.Tx` as an "inline datum"
-- or it up in the witnesses by the hash.
getDatum ::
( Era era,
Core.TxOut era ~ TxOut era,
Expand All @@ -51,20 +53,15 @@ getDatum ::
Core.Tx era ->
UTxO era ->
ScriptPurpose (Crypto era) ->
[BinaryData era]
getDatum tx (UTxO m) sp = case getTxIn sp of
Nothing -> []
Just txin ->
case SplitMap.lookup txin m of
Nothing -> []
Just (TxOut _ _ datum _refScript) ->
case datum of
NoDatum -> []
Datum d -> [d]
DatumHash hash ->
case Map.lookup hash (unTxDats $ txdats' (getField @"wits" tx)) of
Nothing -> []
Just dat -> [dataToBinaryData dat]
Maybe (BinaryData era)
getDatum tx (UTxO m) sp = do
txin <- getTxIn sp
TxOut _ _ datum _refScript <- SplitMap.lookup txin m
case datum of
NoDatum -> Nothing
Datum d -> Just d
DatumHash hash ->
dataToBinaryData <$> Map.lookup hash (unTxDats $ txdats' (getField @"wits" tx))

txscripts ::
forall era.
Expand Down

0 comments on commit 379c286

Please sign in to comment.