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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: |
`transaction view` now renders Dijkstra-era certificates instead of failing with an internal TODO error.
kind:
- feature
pr: 1430
project: cardano-cli
91 changes: 90 additions & 1 deletion cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ renderCertificate
renderCertificate era (Exp.Certificate c) =
case era of
Exp.ConwayEra -> renderConwayCertificate c
Exp.DijkstraEra -> error "renderCertificate: TODO Dijkstra era not supported"
Exp.DijkstraEra -> renderDijkstraCertificate c

renderDrepCredential
:: ()
Expand Down Expand Up @@ -681,6 +681,95 @@ renderConwayCertificate cert =
]
_ -> "unsupported certificate" .= String (T.pack $ show cert)

renderDijkstraCertificate
:: Ledger.DijkstraTxCert (Exp.LedgerEra DijkstraEra) -> (Aeson.Key, Aeson.Value)
renderDijkstraCertificate cert =
case cert of
L.RegDRepTxCert credential coin mAnchor ->
"Drep registration certificate"
.= object
[ "deposit" .= coin
, "certificate" .= renderDrepCredential credential
, "anchor" .= mAnchor
]
L.UnRegDRepTxCert credential coin ->
"Drep unregistration certificate"
.= object
[ "refund" .= coin
, "certificate" .= renderDrepCredential credential
]
L.AuthCommitteeHotKeyTxCert coldCred hotCred
| L.ScriptHashObj sh <- coldCred ->
"Cold committee authorization"
.= object
["script hash" .= sh]
| L.ScriptHashObj sh <- hotCred ->
"Hot committee authorization"
.= object
["script hash" .= sh]
| L.KeyHashObj ck@L.KeyHash{} <- coldCred
, L.KeyHashObj hk@L.KeyHash{} <- hotCred ->
"Constitutional committee member hot key registration"
.= object
[ "cold key hash" .= ck
, "hot key hash" .= hk
]
L.ResignCommitteeColdTxCert cred anchor -> case cred of
L.ScriptHashObj sh ->
"Cold committee resignation"
.= object
[ "script hash" .= sh
, "anchor" .= anchor
]
L.KeyHashObj ck@L.KeyHash{} ->
"Constitutional committee cold key resignation"
.= object
[ "cold key hash" .= ck
]
L.RegDepositTxCert stakeCredential deposit ->
"Stake address registration"
.= object
[ "stake credential" .= stakeCredential
, "deposit" .= deposit
]
L.UnRegDepositTxCert stakeCredential refund ->
"Stake address deregistration"
.= object
[ "stake credential" .= stakeCredential
, "refund" .= refund
]
L.DelegTxCert stakeCredential delegatee ->
"Stake address delegation"
.= object
[ "stake credential" .= stakeCredential
, "delegatee" .= delegateeJson delegatee
]
L.RegDepositDelegTxCert stakeCredential delegatee deposit ->
"Stake address registration and delegation"
.= object
[ "stake credential" .= stakeCredential
, "delegatee" .= delegateeJson delegatee
, "deposit" .= deposit
]
L.RegPoolTxCert poolParams ->
"Pool registration"
.= object
[ "pool params" .= poolParams
]
L.RetirePoolTxCert kh@L.KeyHash{} epoch ->
"Pool retirement"
.= object
[ "stake pool key hash" .= kh
, "epoch" .= epoch
]
L.UpdateDRepTxCert drepCredential mbAnchor ->
"Drep certificate update"
.= object
[ "Drep credential" .= drepCredential
, "anchor" .= mbAnchor
]
_ -> "unsupported certificate" .= String (T.pack $ show cert)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's hidden in _? Shouldn't that be an error? at least a non-zero error code. This applies to conway as well.
I don't remember why COMPLETE pragma doesn't work here.

@palas palas Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a COMPLETE pragma here: https://github.com/IntersectMBO/cardano-ledger/blob/f3104f00f9819ba94de119c38bc3e0109982821f/eras/conway/impl/src/Cardano/Ledger/Conway/TxCert.hs#L358-L371

In the first place, it doesn't work because it is done over DijkstraEra instead of DijkstraTxCert, but that also doesn't seem to work, may be a compiler issue.

So the only way to get it to work would be to recursively pattern match on DijkstraTxCert, but we are not supposed to do that, and is not wat we did for Conway.

And about it being an error instead: I think it is best to just print it uglily than failing if for some reason we miss a certificate


friendlyStakeCredential
:: L.Credential L.Staking -> Aeson.Pair
friendlyStakeCredential = \case
Expand Down
Loading