Migrate to experimental TxOut in createCompatibleTx#1376
Closed
Jimbo4350 wants to merge 2 commits into
Closed
Conversation
| pure $ TxOut addr val datum refScript | ||
| let legacyTxOut = TxOut addr val datum refScript | ||
| pure $ | ||
| shelleyBasedEraConstraints sbe $ |
Adapt to cardano-api PR #1209, which removes the legacy 'TxOut CtxTx era' from the Compatible and Experimental APIs: * 'createCompatibleTx' now takes '[Exp.TxOut (ShelleyLedgerEra era)]' plus a new 'Map L.DataHash (L.Data ...)' argument carrying any supplemental datum bodies. The legacy 'TxOut CtxTx era' bundled supplemental datums inside outputs; 'Exp.TxOut' only carries the datum hash, so callers thread the full datum bodies in explicitly. * The bridge helpers 'fromLegacyTxOut', 'legacyDatumToDatum', 'supplementalDatumFromLegacy', 'toLedgerDatum', and the 'DatumDecodingError' type are deleted from 'Cardano.Api.Experimental.Tx'. Migration: * 'mkTxOut' and 'toTxOutInAnyEra' now return '(Exp.TxOut (ShelleyLedgerEra era), Map DataHash (L.Data ...))' directly, building the legacy 'TxOut CtxTx era' internally only as a stepping stone for 'toShelleyTxOutAny'. * 'createCompatibleTx' call site in 'Compatible/Transaction/Run.hs' folds the per-output supplemental datums via 'Map.unions' and passes them as the new argument. * 'toTxOutInEra' and 'toTxOutInShelleyBasedEra' in 'EraBased/Transaction/Run.hs' delegate directly to 'mkTxOut' (the deleted 'fromLegacyTxOut' is gone). * 'TxCmdDatumDecodingError' is removed since the underlying 'Exp.DatumDecodingError' is gone and the new conversion is total. Temporary 'cabal.project' additions (to be removed once #1209 is merged and the next cardano-api is published to CHaP): * 'source-repository-package' pointing at the PR branch so CI can build against the unpublished API. * Per-package '-Wwarn=deprecations -Wwarn=unused-imports' for cardano-cli. The PR branch is several commits ahead of cardano-api-11.1.0.0 and surfaces unrelated TxBody/TxBodyContent deprecations (cardano-api PR #1200) plus a redundant 'Cardano.Ledger.Core' import in 'Cardano.CLI.Read' that became visible after upstream re-exports widened. Both are separate cleanups out of scope for this PR.
Eliminate the legacy 'TxOut CtxTx era' and 'TxOut CtxUTxO era' type
signatures and pattern matches from cardano-cli's non-Byron code paths.
Byron-era code uses a separate pre-Shelley tx output model and is left
alone — 'Exp.TxOut' is not applicable there.
* 'friendlyTxOut' in 'Compatible/Json/Friendly.hs' now takes
'Exp.TxOut (LedgerEra era)' and reads address, value, datum, and
reference script directly via the ledger lenses ('addrTxOutL',
'valueTxOutL', 'datumTxOutL', 'referenceScriptTxOutL'). The two
call sites ('basePairs', 'friendlyReturnCollateral') wrap the
body's ledger outputs with 'Exp.TxOut' instead of going through
'fromShelleyTxOut → fromCtxUTxOTxOut'. The dead 'friendlyTxOutValue'
helper is dropped.
* 'filteredUTxOsToText' in 'EraBased/Query/Run.hs' now takes a
'ShelleyBasedEra era' witness, converts the api 'UTxO era' to the
ledger UTxO once via 'toLedgerUTxO', then renders each entry from
'(TxIn, Exp.TxOut (ShelleyLedgerEra era))' using ledger lenses.
The pre-Babbage datum slot has no uniform ledger representation,
so the renderer emits an empty placeholder there and shows the
babbage+ ledger datum elsewhere — debug-style output, no golden
tests touched.
* Removed 'validateTxReturnCollateral' from
'Type/Error/TxValidationError.hs'. It was exported but never
called outside its own module; the actual return-collateral
construction in 'EraBased/Transaction/Run' builds
'Exp.TxReturnCollateral' directly.
Remaining uses of legacy ctx-typed tx outputs in cardano-cli are
confined to Byron-only modules.
cf0ba30 to
3d32b5a
Compare
5 tasks
This was referenced May 18, 2026
Contributor
Author
|
Superseded by #1379, which folds in this PR's work (cardano-api #1209 companion — migration of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Context
Depends on cardano-api #1209 — Remove legacy TxOut from Compatible and Experimental APIs.
That PR makes two breaking changes in the cardano-api experimental namespace:
createCompatibleTxnow takes[Exp.TxOut (ShelleyLedgerEra era)]plus a newMap L.DataHash (L.Data ...)of supplemental datum bodies. The legacyTxOut CtxTx erabundled supplemental datums inside outputs;Exp.TxOutonly carries the datum hash, so callers thread the full datum bodies in explicitly.fromLegacyTxOut,legacyDatumToDatum,supplementalDatumFromLegacy,toLedgerDatum, and theDatumDecodingErrortype are removed fromCardano.Api.Experimental.Tx.This PR adapts cardano-cli's three affected call sites and removes the now-unreachable error constructor.
How the migration works
A new helper
convertLegacyTxOut :: ShelleyBasedEra era -> TxOut CtxTx era -> (Exp.TxOut (ShelleyLedgerEra era), Map DataHash (L.Data ...))lives inCardano.CLI.Compatible.Transaction.TxOut. It builds on the existingtoShelleyTxOutAny(which already strips supplemental datums to their hash in the ledger TxOut) and pulls the supplemental datum bodies into the map. Total conversion — no error case, so the previousEither DatumDecodingError ...plumbing is gone.Call sites:
Cardano.CLI.Compatible.Transaction.Run: converts outs at the boundary and folds supplemental datums viaMap.unionsbefore callingcreateCompatibleTx.Cardano.CLI.EraBased.Transaction.Run:toTxOutInEraandtoTxOutInShelleyBasedErauseconvertLegacyTxOutinstead of the deletedExp.fromLegacyTxOut.obtainCommonConstraintsbridgesShelleyLedgerEra ~ LedgerErafor the experimental-era return type.Temporary
cabal.projectadditionsTo let CI validate against the unpublished API:
source-repository-packagepointing at the cardano-api PR Refactor and moderniseDRepgolden tests for thread-safety #1209 branch.-Wwarn=deprecations -Wwarn=unused-importsfor cardano-cli.The PR branch is several commits ahead of
cardano-api-11.1.0.0and surfaces unrelatedTxBody/TxBodyContentdeprecations (cardano-api #1200) plus a redundantCardano.Ledger.Coreimport inCardano.CLI.Readthat became visible after upstream re-exports widened. Both are separate cardano-cli cleanups; this PR keeps them out of scope by downgrading the warnings. All four lines should be removed in a follow-up once #1209 is merged and the next cardano-api is published to CHaP.How to trust this PR
convertLegacyTxOutreusestoShelleyTxOutAnyrather than re-implementing the datum-to-ledger mapping, so semantics on theExp.TxOutside are identical to what cardano-api itself does for non-experimental tx body construction.createCompatibleTxargument is passed through toconvScriptData'inside cardano-api.-Werrorstill in effect for everything except the two pre-existing classes of warnings above.Checklist