Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changes/20261015_cip159_deposit_view.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project: cardano-cli
pr: 1470
kind:
- bugfix
description: Show direct-deposit recipients and amounts in Dijkstra transaction JSON and YAML views.
3 changes: 3 additions & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ jobs:
uses: input-output-hk/actions/base@latest
with:
use-sodium-vrf: true # default is true
# Work around macOS foreign-library configure failures with iohk-nix v3.2.
# https://github.com/IntersectMBO/cardano-cli/actions/runs/39825029792/job/119985950591
url-prefix: ${{ runner.os == 'macOS' && 'https://github.com/input-output-hk/iohk-nix/releases/download/v3.1' || 'https://github.com/input-output-hk/iohk-nix/releases/latest/download' }}

- uses: actions/checkout@v6

Expand Down
16 changes: 15 additions & 1 deletion cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import Cardano.CLI.Orphan ()
import Cardano.CLI.Type.Common (FormatJson (..), FormatYaml (..))
import Cardano.CLI.Type.MonadWarning (MonadWarning, runWarningIO)
import Cardano.Crypto.Hash (hashToTextAsHex)
import Cardano.Ledger.Address qualified as L
import Cardano.Ledger.Api.Tx qualified as L
import Cardano.Ledger.Core qualified as C
import Cardano.Ledger.Credential (credKeyHash, credScriptHash)
Expand Down Expand Up @@ -188,6 +189,16 @@ friendlyTxBodyImpl era (Exp.UnsignedTx ledgerTx) =
]
<> alonzoScriptWitnessPairs era ledgerTx
<> conwayBodyPairs body
<> dijkstraBodyPairs era body

dijkstraBodyPairs
:: Exp.Era era
-> L.TxBody C.TopTx (Exp.LedgerEra era)
-> [Aeson.Pair]
dijkstraBodyPairs era body = case era of
Exp.ConwayEra -> []
Exp.DijkstraEra ->
["direct deposits" .= friendlyAccountAmounts (L.unDirectDeposits $ body ^. L.directDepositsTxBodyL)]

renderCollateralInputs
:: L.AlonzoEraTxBody (Exp.LedgerEra era)
Expand Down Expand Up @@ -480,7 +491,10 @@ friendlyExtraKeyWits keyhashes
| otherwise = toJSON [PaymentKeyHash (coerceKeyRole kh) | kh <- Set.toList keyhashes]

friendlyWithdrawals :: L.Withdrawals -> Aeson.Value
friendlyWithdrawals (L.Withdrawals ws)
friendlyWithdrawals (L.Withdrawals ws) = friendlyAccountAmounts ws

friendlyAccountAmounts :: Map.Map L.AccountAddress Lovelace -> Aeson.Value
friendlyAccountAmounts ws
| Map.null ws = Null
| otherwise =
array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Test.Golden.Debug.TransactionView where

import Control.Monad (void)
import System.FilePath ((</>))

import Test.Cardano.CLI.Util (execCardanoCLI, watchdogProp)
Expand Down Expand Up @@ -49,3 +50,45 @@ hprop_golden_debug_transaction_view_conway_yaml =
, "--output-yaml"
]
H.diffVsGoldenFile result $ goldenDir </> "conway/transaction-view.yaml"

-- | Deposits must be visible when inspecting a transaction before signing.
hprop_golden_debug_transaction_view_dijkstra_direct_deposits_json :: Property
hprop_golden_debug_transaction_view_dijkstra_direct_deposits_json =
goldenDijkstraDirectDeposits "json"

hprop_golden_debug_transaction_view_dijkstra_direct_deposits_yaml :: Property
hprop_golden_debug_transaction_view_dijkstra_direct_deposits_yaml =
goldenDijkstraDirectDeposits "yaml"

goldenDijkstraDirectDeposits :: String -> Property
goldenDijkstraDirectDeposits format =
watchdogProp . propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
bodyFile <- H.noteTempFile tempDir "tx.body"
void $
execCardanoCLI
[ "dijkstra"
, "transaction"
, "build-raw"
, "--tx-in"
, "63e6a9a8e58e48cc025cae04daaed9d36fc7b70bc292721d9f5057ae37b24981#0"
, "--tx-out"
, "addr_test1vp0t4dfa9ktc2uvv7sg9leafuhtwyu0xcj4q4kf5pqkpjwqhklklg+5000000"
, "--fee"
, "200000"
, "--direct-deposit"
, "stake_test17qvxuvh64q9zdqgrjt76d42eclk5wgdxtnsun4808cwg0dqxv5r99+20000000"
, "--direct-deposit"
, "stake_test1uz855drx5szvz845zqcnq9dc3ez8mqdkqzy7yhmpzcqwvpg59zzfl+30000000"
, "--out-file"
, bodyFile
]
result <-
execCardanoCLI
[ "debug"
, "transaction"
, "view"
, "--tx-body-file"
, bodyFile
, "--output-" ++ format
]
H.diffVsGoldenFile result $ goldenDir </> "dijkstra/transaction-view-direct-deposits." ++ format
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"auxiliary scripts": null,
"certificates": null,
"collateral inputs": [],
"currentTreasuryValue": null,
"datums": [],
"direct deposits": [
{
"address": "stake_test17qvxuvh64q9zdqgrjt76d42eclk5wgdxtnsun4808cwg0dqxv5r99",
"amount": "20000000 Lovelace",
"network": "Testnet",
"stake credential script hash": "186e32faa80a26810392fda6d559c7ed4721a65ce1c9d4ef3e1c87b4"
},
{
"address": "stake_test1uz855drx5szvz845zqcnq9dc3ez8mqdkqzy7yhmpzcqwvpg59zzfl",
"amount": "30000000 Lovelace",
"network": "Testnet",
"stake credential key hash": "8f4a3466a404c11eb410313015b88e447d81b60089e25f611600e605"
}
],
"era": "Dijkstra",
"fee": "200000 Lovelace",
"governance actions": [],
"inputs": [
"63e6a9a8e58e48cc025cae04daaed9d36fc7b70bc292721d9f5057ae37b24981#0"
],
"metadata": null,
"mint": null,
"outputs": [
{
"address": "addr_test1vp0t4dfa9ktc2uvv7sg9leafuhtwyu0xcj4q4kf5pqkpjwqhklklg",
"address era": "Shelley",
"amount": {
"lovelace": 5000000
},
"datum": null,
"network": "Testnet",
"payment credential key hash": "5ebab53d2d9785718cf4105fe7a9e5d6e271e6c4aa0ad934082c1938",
"reference script": null,
"stake reference": null
}
],
"redeemers": [],
"reference inputs": [],
"required signers (payment key hashes needed for scripts)": null,
"return collateral": null,
"scripts": [],
"total collateral": null,
"treasuryDonation": 0,
"validity range": {
"lower bound": null,
"upper bound": null
},
"voters": {},
"withdrawals": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
auxiliary scripts: null
certificates: null
collateral inputs: []
currentTreasuryValue: null
datums: []
direct deposits:
- address: stake_test17qvxuvh64q9zdqgrjt76d42eclk5wgdxtnsun4808cwg0dqxv5r99
amount: 20000000 Lovelace
network: Testnet
stake credential script hash: 186e32faa80a26810392fda6d559c7ed4721a65ce1c9d4ef3e1c87b4
- address: stake_test1uz855drx5szvz845zqcnq9dc3ez8mqdkqzy7yhmpzcqwvpg59zzfl
amount: 30000000 Lovelace
network: Testnet
stake credential key hash: 8f4a3466a404c11eb410313015b88e447d81b60089e25f611600e605
era: Dijkstra
fee: 200000 Lovelace
governance actions: []
inputs:
- 63e6a9a8e58e48cc025cae04daaed9d36fc7b70bc292721d9f5057ae37b24981#0
metadata: null
mint: null
outputs:
- address: addr_test1vp0t4dfa9ktc2uvv7sg9leafuhtwyu0xcj4q4kf5pqkpjwqhklklg
address era: Shelley
amount:
lovelace: 5000000
datum: null
network: Testnet
payment credential key hash: 5ebab53d2d9785718cf4105fe7a9e5d6e271e6c4aa0ad934082c1938
reference script: null
stake reference: null
redeemers: []
reference inputs: []
required signers (payment key hashes needed for scripts): null
return collateral: null
scripts: []
total collateral: null
treasuryDonation: 0
validity range:
lower bound: null
upper bound: null
voters: {}
withdrawals: null
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ currentTreasuryValue: null
datums:
- datum: I 24
datum hash: df5078aee07dd171a343fb99d5fc1b5462fb3c94d82bf72dc1b77d9c0aceec29
direct deposits: null
era: Dijkstra
fee: 200000 Lovelace
governance actions:
Expand Down
Loading