Skip to content

Commit

Permalink
Add datum info to friendlyTxImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Nov 25, 2024
1 parent 6a2b94c commit 80db7b6
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-api
subdir: cardano-api
tag: 955aefdcbdedb2959f176e03da80e82ce27fc879
--sha256: sha256-Eph4eFuS4+Y8JqrJ/JfI9r6CT0Ec4H9hQFPcilebEQc=
tag: 07cfd58f4ffabc96391bba53d2f464b859be0a6a
--sha256: sha256-3Hdp3g/F1py8Lnev2Dk+eMBukPmmjsz1bnupkuYMgjA=

program-options
ghc-options: -Werror
Expand Down
13 changes: 13 additions & 0 deletions cardano-cli/src/Cardano/CLI/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ getAlonzoSpecificDetails aeo tb =
let ShelleyTx _ ledgerTx = makeSignedTransaction [] tb
in [ "redeemers" .= friendlyRedeemers ledgerTx
, "scripts" .= friendlyScriptData ledgerTx
, "datums" .= friendlyDats ledgerTx
]
where
friendlyRedeemers
Expand Down Expand Up @@ -398,6 +399,18 @@ getAlonzoSpecificDetails aeo tb =
]
| (scriptHash, scriptData) <- Map.toList $ tx ^. Ledger.witsTxL . Ledger.scriptTxWitsL]

friendlyDats :: Ledger.Tx (ShelleyLedgerEra era) -> Aeson.Value
friendlyDats tx =
alonzoEraOnwardsConstraints aeo $
let Ledger.TxDats dats = tx ^. Ledger.witsTxL . Ledger.datsTxWitsL in
Aeson.Array $ Vector.fromList $
[ Aeson.Object $ KeyMap.fromList [
"datum hash" .= datHash,
"datum" .= Api.friendlyDatum dat
]
| (datHash, dat) <- Map.toList dats
]

friendlyTotalCollateral :: TxTotalCollateral era -> Aeson.Value
friendlyTotalCollateral TxTotalCollateralNone = Aeson.Null
friendlyTotalCollateral (TxTotalCollateral _ coll) = toJSON coll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ auxiliary scripts: null
certificates: null
collateral inputs:
- c9765d7d0e3955be8920e6d7a38e1f3f2032eac48c7c59b0b9193caa87727e7e#256
datums: []
era: Alonzo
fee: 213 Lovelace
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ auxiliary scripts: null
certificates: null
collateral inputs:
- c9765d7d0e3955be8920e6d7a38e1f3f2032eac48c7c59b0b9193caa87727e7e#256
datums: []
era: Alonzo
fee: 213 Lovelace
inputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
auxiliary scripts: null
certificates: null
collateral inputs: []
datums: []
era: Babbage
fee: 21300 Lovelace
inputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
auxiliary scripts: null
certificates: null
collateral inputs: []
datums: []
era: Babbage
fee: 21300 Lovelace
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ auxiliary scripts: null
certificates: null
collateral inputs:
- c9765d7d0e3955be8920e6d7a38e1f3f2032eac48c7c59b0b9193caa87727e7e#256
datums:
- datum: I 6666
datum hash: 9e478573ab81ea7a8e31891ce0648b81229f408d596a3483e6f4f9b92d3cf710
era: Babbage
fee: 213 Lovelace
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"certificates": null,
"collateral inputs": [],
"currentTreasuryValue": null,
"datums": [],
"era": "Conway",
"fee": "181517 Lovelace",
"governance actions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"certificates": null,
"collateral inputs": [],
"currentTreasuryValue": null,
"datums": [],
"era": "Conway",
"fee": "185433 Lovelace",
"governance actions": [],
Expand Down

0 comments on commit 80db7b6

Please sign in to comment.