Add a dedicated transaction viewing type to the experimental API

Open
#1,416 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@palas is already working on this.

Since Nov 13, 2026.

Assessment

This issue has not been assessed yet.

Description

type: enhancement

Summary

cardano-api should give the CLI a ready-made view of a decoded tx. The CLI should only format it.

API = what is in the tx. CLI = how it is shown.

Why

  • Today transaction view (Cardano.CLI.Compatible.Json.Friendly) reads the ledger tx directly. It keeps its own split of shared vs top-level-only fields (sharedTxPairs, dijkstraTopLevelPairs).
  • The experimental API knows the same split (TxBodyContent / SubTxBodyContent). Two copies, so they drift.
  • We can't reuse TxBodyContent. It is for building txs and needs info a decoded tx doesn't have, e.g. txIns :: [(TxIn, AnyWitness era)].

Plan

cardano-api (experimental)
  • Add a type for viewing a decoded tx, separate from the building type (TxBodyContent). Use experimental API types as much as possible, not the ledger's.
  • Cover top-level txs and sub-txs. The types say which fields are shared and which are top-level only.
  • Spending inputs: a plain list, no AnyWitness.
  • Scripts, datums, redeemers and key witnesses: kept separate, as decoded.
  • Redeemer pointers: resolved to their purposes from the tx body, as the renderer does today.
  • Add conversions for top-level txs and sub-txs. Embedded sub-txs keep their order and their own witnesses.
cardano-cli
  • The renderer takes the new type. Only friendly labels and JSON/YAML formatting stay in the CLI.
  • Take the shared / top-level-only split from the API types. Don't keep a second one in the CLI.
  • friendly* functions throw (CIO) instead of returning Either (FileError e) () (review comment).
    • Which: friendly, friendlyTx, friendlyTxBody, friendlySubTx, friendlyProposal, friendlyCertificate.
    • Why: callers throw right away with fromEitherIOCli. governance action view even drops the error with void.
  • transaction view output stays the same. Golden tests pass as they are.

Don't

  • Don't assume an input is key-controlled because it has no redeemer (it could be a simple script).
  • Don't look up the UTxO. transaction view doesn't get it.
  • Don't invent info that isn't in the tx.

Notes

  • Moving the current code to cardano-api as it is can be a first step. It does not close this issue.
  • read* functions moving to CIO is tracked in IntersectMBO/cardano-cli#1503.
Dominant language
Haskell
Stars
41
Forks
33
Avg merge
3d 3h
Merged PRs (30d)
15

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntersectMBO/cardano-api

All issues in IntersectMBO/cardano-api

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.