Remove legacy TxOut from Compatible and Experimental APIs#1209
Merged
Jimbo4350 merged 2 commits intoMay 15, 2026
Conversation
Jimbo4350
added a commit
that referenced
this pull request
May 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Removes the legacy TxOut ctx era surface from the Compatible and Experimental exposed APIs, shifting createCompatibleTx to consume the experimental ledger-TxOut wrapper plus an explicit supplemental-datums map, and deleting now-obsolete legacy conversion helpers from the experimental namespace.
Changes:
- Updated
Cardano.Api.Compatible.Tx.createCompatibleTxto accept[Exp.TxOut (ShelleyLedgerEra era)]and an explicitMap L.DataHash (L.Data (ShelleyLedgerEra era))for supplemental datums (instead of extracting them from legacy outputs). - Removed legacy TxOut/datum bridge helpers from
Cardano.Api.Experimental.TxandCardano.Api.Experimental.Tx.Internal.BodyContent.New. - Adjusted the property test to pass
memptyfor the new supplemental-datums parameter, and added a Herald changelog fragment classifying this asbreaking.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs |
Updates createCompatibleTx test call site for the new supplemental-datums argument. |
cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs |
Removes legacy TxOut/datum conversion helpers and related exports/imports. |
cardano-api/src/Cardano/Api/Experimental/Tx.hs |
Stops re-exporting the removed legacy conversion helpers from the exposed Experimental API. |
cardano-api/src/Cardano/Api/Compatible/Tx.hs |
Changes createCompatibleTx/createCommonTxBody to use experimental TxOut and threads supplemental datums explicitly into script data. |
.changes/20260514_cardano_api_remove_legacy_txout_from_compat_and_experimental.yml |
Adds a breaking-change changelog fragment describing the API removals/signature change. |
3 tasks
palas
approved these changes
May 14, 2026
Contributor
palas
left a comment
There was a problem hiding this comment.
It all looks good, and I can see you already have IntersectMBO/cardano-cli#1376 ready to adapt to the changes and it also compiles
carbolymer
approved these changes
May 15, 2026
createCompatibleTx now takes [Exp.TxOut (ShelleyLedgerEra era)] plus an explicit Map L.DataHash (L.Data ...) for supplemental datums, mirroring how it already takes Exp.TxCertificates / Exp.TxVotingProcedures / Exp.TxProposalProcedures. Supplemental datums were previously rescued out of the legacy TxOut constructor inside convScriptData' and folded into TxBodyScriptData; Exp.TxOut intentionally does not carry them (only the hash; the full datum lives in the witness set), so callers now thread them in explicitly. Deletes the legacy bridge helpers from Experimental.Tx (fromLegacyTxOut, legacyDatumToDatum, supplementalDatumFromLegacy, toLedgerDatum, DatumDecodingError). They existed only to migrate callers from legacy TxOut CtxTx era; with the Compatible API no longer accepting that type, the bridges have no remaining callers inside cardano-api. They were re-exported only via the experimental namespace, whose stability contract permits breaking changes. After this change, neither Cardano.Api.Compatible.* nor Cardano.Api.Experimental.* references OldApi.TxOut / TxOut CtxTx era. The legacy TxOut ctx era type itself stays in place — UTxO, Tx body construction, fee/balancing, LedgerState, and Byron all still depend on it.
d18a07c to
e90405b
Compare
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
data TxOut ctx era(fromCardano.Api.Tx.Internal.Output) is still load-bearing acrossCardano.Api.UTxO,Cardano.Api.Tx.Internal.Body, fee/balancing helpers,LedgerState, and Byron — roughly 230 references incardano-api/srcafter filtering — so deprecating it wholesale is not currently practical. The entireUTxO era = Map TxIn (TxOut CtxUTxO era)abstraction depends on it.The Experimental API has already introduced its own GADT wrapper at
Cardano.Api.Experimental.Tx.Internal.BodyContent.New:— a thin wrapper over the ledger's
L.TxOut. The Experimental code was internally consistent and only referenced legacyTxOutin a handful of migration bridge helpers. The Compatible API (Cardano.Api.Compatible.Tx) still threaded[TxOut CtxTx era]throughcreateCompatibleTx,createCommonTxBody, andconvScriptData'.This PR removes legacy
TxOutfrom both Compatible and Experimental:createCompatibleTxnow takes[Exp.TxOut (ShelleyLedgerEra era)]+Map L.DataHash (L.Data (ShelleyLedgerEra era))for supplemental datums. The legacyTxOut CtxTx erabundled supplemental datums inside outputs, whichconvScriptData'extracted via[d | TxOut _ _ (TxOutSupplementalDatum _ d) _ <- txOuts']and folded intoTxBodyScriptData.Exp.TxOutintentionally does not carry supplemental datums (only the datum hash; the full datum lives in the witness set), so callers now thread them in explicitly — matching how ledgerTxDatsactually work.Deletes the legacy bridge helpers from
Cardano.Api.Experimental.Tx:fromLegacyTxOutlegacyDatumToDatumsupplementalDatumFromLegacytoLedgerDatumDatumDecodingErrorThese existed solely to convert legacy
TxOut CtxTx era/TxOutDatum CtxTx eravalues into the new world. With the Compatible API no longer accepting the legacy type, no in-repo caller remains. They were re-exported only viaCardano.Api.Experimental.Tx— they are not part of top-levelCardano.Api, and the experimental namespace explicitly permits breaking changes.After this PR, neither
Cardano.Api.Compatible.*norCardano.Api.Experimental.*referencesOldApi.TxOut/TxOut CtxTx era.How to trust this PR
Checklist
prop_createCompatibleTx_preserves_all_certsHedgehog property still passes 100 cases)fourmolu-Werror