Remove old-API TxBody uses from cardano-cli (companion to cardano-api #1200)#1375
Remove old-API TxBody uses from cardano-cli (companion to cardano-api #1200)#1375Jimbo4350 wants to merge 3 commits into
Conversation
Pins cardano-api to the master commit containing PR #1200, which deprecates `TxBody`, `TxBodyContent`, `getTxBody`, `getTxBodyContent`, `createTransactionBody`, `defaultTxBodyContent`, and `BalancedTxBody`. Lets this PR verify -Wdeprecations is clean against the deprecated surface. Remove this stanza once cardano-api releases a version containing #1200.
`TxBodyFile` was a `File (TxBody ())` whose phantom payload was only ever used as a file-tag for option/parser plumbing; the bytes on disk do not depend on it. Replace `TxBody ()` with a fresh empty `TxBodyTag` data type so the alias no longer references the deprecated `TxBody` from cardano-api PR #1200. No on-disk format change. No call-site change beyond the alias itself.
Drops the last remaining uses of the deprecated old-API transaction body surface (`TxBody`, `getTxBody`, `getTxBodyAndWitnesses`, `makeShelleyKeyWitness`, `makeSignedTransaction`, `evaluateTransactionExecutionUnits` on a deprecated `TxBody`, `getTxId . getTxBody`) from cardano-cli's source tree. `IncompleteTxBody` is reworked from a `newtype` wrapping `InAnyShelleyBasedEra TxBody` into a GADT existential carrying `Exp.UnsignedTx (ShelleyLedgerEra era)` plus `IsShelleyBasedEra` evidence. `readFileTxBody` pattern-matches `ShelleyTx _ ledgerTx` directly and wraps as `Exp.UnsignedTx ledgerTx` — no `getTxBody`. Consumers in `Transaction.Run` are migrated to: - `makeShelleyKeyWitness'` (ledger-level body) and `addWitnesses` for signing — both non-deprecated and work for all Shelley-based eras, preserving pre-Conway support. - `getTxIdShelley` for transaction IDs. - `evaluateTransactionExecutionUnitsShelley` (operates on the ledger `Tx` directly) for `transaction calculate-plutus-script-cost`, preserving Alonzo+ era support. - `Exp.evaluateTransactionFee` on `Exp.UnsignedTx` for `transaction calculate-min-fee` (already Conway+ via `sbeToEra`). `TransactionView.Run` no longer needs the `makeSignedTransaction []`-then-extract-ledger boundary that PR #1374 added — the new `readFileTxBody` returns `Exp.UnsignedTx` directly. The TextEnvelope I/O boundary still uses `Tx era` and `ShelleyTx _` (both non-deprecated), since `Exp.UnsignedTx`/`Exp.SignedTx` have no `HasTextEnvelope` instance. The on-disk `.tx`/`.txbody` formats are unchanged. The compatible command path (`Cardano.CLI.Compatible.Transaction.Run`) was already using non-deprecated symbols (`makeShelleyKeyWitness'`, `addWitnesses`) and is unchanged by this commit.
There was a problem hiding this comment.
Pull request overview
Migrates cardano-cli away from the deprecated legacy transaction-body API (TxBody, TxBodyContent, getTxBody, etc.) to keep builds clean under -Wdeprecations -Werror, aligning with the experimental API direction in cardano-api#1200.
Changes:
- Replace
TxBodyFile = File (TxBody ())with a tag-basedTxBodyFile = File TxBodyTag. - Rework
readFileTxBody/IncompleteTxBodyto carry anExp.UnsignedTx(ledger tx) plus era evidence, and update transaction/debug commands to use ledger-level signing/witness attachment. - Temporarily pin
cardano-apiviasource-repository-packageincabal.projectto validate against the deprecated surface.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cardano-cli/src/Cardano/CLI/Type/Common.hs | Switch TxBodyFile to a tag type to avoid deprecated TxBody in the phantom. |
| cardano-cli/src/Cardano/CLI/Read.hs | Redefine IncompleteTxBody and update readFileTxBody to produce Exp.UnsignedTx with era evidence. |
| cardano-cli/src/Cardano/CLI/EraIndependent/Debug/TransactionView/Run.hs | Update tx-body viewing path to consume IncompleteTxBody/Exp.UnsignedTx. |
| cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs | Replace deprecated tx-body operations with ledger-level tx-body extraction, witness creation, and addWitnesses. |
| cabal.project | Add a temporary cardano-api git pin to build against the deprecation changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| deriving Show | ||
|
|
||
| type TxBodyFile = File (TxBody ()) | ||
| data TxBodyTag |
| -- TEMPORARY: pin cardano-api to a master commit containing PR #1200 | ||
| -- (deprecation of TxBody / TxBodyContent) so this PR can verify -Wdeprecations | ||
| -- is clean against the deprecated surface. Remove once cardano-api releases a | ||
| -- version containing PR #1200. | ||
| source-repository-package | ||
| type: git | ||
| location: https://github.com/IntersectMBO/cardano-api | ||
| tag: 1272b84342425dcbc653abe9b8eb11447a34ec01 | ||
| subdir: cardano-api | ||
|
|
| -- Why are we differentiating between a transaction body and a transaction? | ||
| -- In the case of a transaction body, we /could/ simply call @makeSignedTransaction []@ | ||
| -- In the case of a transaction body, we /could/ simply call @addWitnesses []@ | ||
| -- to get a transaction which would allow us to reuse friendlyTxBS. However, |
|
Superseded by #1379, which folds in this PR's work (cardano-api #1200 companion — migration off the deprecated |
Summary
Companion to cardano-api #1200, which deprecates the old transaction-body API surface. This PR strips the remaining old-API uses from cardano-cli so
-Werrorstays clean once cardano-cli bumps to a cardano-api containing #1200.PR #1374 already migrated the friendly-tx renderer; this PR handles the rest:
Cardano.CLI.Read,Cardano.CLI.EraBased.Transaction.Run,Cardano.CLI.EraIndependent.Debug.TransactionView.Run, and theTxBodyFilephantom alias inCardano.CLI.Type.Common.Deprecated symbols replaced:
TxBody eraExp.UnsignedTx (ShelleyLedgerEra era)getTxBodyShelleyTx _ ledgerTxgetTxBodyAndWitnessesgetTxWitnesses+ ledger body via lensmakeShelleyKeyWitnessmakeShelleyKeyWitness'(ledger body)makeSignedTransactionaddWitnessesgetTxId . getTxBodygetTxIdShelley sbe (ledgerTx ^. L.bodyTxL)evaluateTransactionExecutionUnits(on oldTxBody)evaluateTransactionExecutionUnitsShelley(ledgerTx)evaluateTransactionFee(on oldTxBody)Exp.evaluateTransactionFee(onExp.UnsignedTx)Pre-Conway era support is preserved everywhere it currently works. The migration uses ledger-level signing (
makeShelleyKeyWitness'/addWitnesses) rather thanExp.makeKeyWitness/Exp.signTx, which are Conway+ only. The TextEnvelope I/O boundary still usesTx era/ShelleyTx _(both non-deprecated);.tx/.txbodyon-disk formats are unchanged.The compatible command path (
Cardano.CLI.Compatible.Transaction.Run) already used non-deprecated symbols and is unchanged.Commits
Reviewable in order:
cabal.project: temporarily pin cardano-api to PR #1200— temporarysource-repository-packagestanza so CI builds against the deprecated surface. Drop this commit before merging once cardano-api ships a release containing Experimental api propagation 2025-05-23 #1200.Drop deprecated TxBody from TxBodyFile phantom— tiny, isolated.File (TxBody ())→File TxBodyTag(a new empty tag type). No on-disk format change.Migrate IncompleteTxBody and transaction commands to Exp.UnsignedTx— the substantive change. ReworksIncompleteTxBodyfrom a newtype aroundInAnyShelleyBasedEra TxBodyinto a GADT carryingExp.UnsignedTx (ShelleyLedgerEra era)withIsShelleyBasedEraevidence;readFileTxBodydestructuresShelleyTx _ ledgerTxdirectly. Updatestransaction sign / sign-witness / witness / txid / submit / calculate-min-fee / calculate-plutus-script-costanddebug transaction view.How to trust this PR
cabal build cardano-cli -j4clean against the pinned cardano-api — zero-Wdeprecations, zero warnings.cabal test cardano-cli-test -j4— 69 / 69 pass.cabal test cardano-cli-golden -j4— 686 / 686 pass..tx/.txbodyfiles continue to round-trip viaHasTextEnvelope (Tx era).Changelog
Checklist