Bump to cardano-api 11.2.0.0 + migrate to Certificate API#1379
Bump to cardano-api 11.2.0.0 + migrate to Certificate API#1379Jimbo4350 wants to merge 6 commits into
Conversation
| pure $ TxOut addr val datum refScript | ||
| let legacyTxOut = TxOut addr val datum refScript | ||
| pure $ | ||
| shelleyBasedEraConstraints sbe $ |
There was a problem hiding this comment.
Pull request overview
Updates cardano-cli to build against cardano-api-11.2.0.0 and migrates CLI code to the new Experimental/Compatible Certificate and TxOut APIs introduced by upstream breaking changes. This keeps the CLI warning-clean under -Werror while preserving existing command behavior and on-disk formats.
Changes:
- Bump dependency bounds and Nix/CHaP pins to consume
cardano-api ^>= 11.2from CHaP. - Migrate transaction-body handling and several transaction commands from legacy
TxBodyusage toExp.UnsignedTx/ ledger-body based helpers. - Migrate certificate-related imports/types to
Cardano.Api.Experimental.Certificate/Cardano.Api.Compatible.Certificateand adapt TxOut construction to produce(Exp.TxOut, supplemental-datum map).
Reviewed changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| flake.lock | Bumps CHaP flake input revision/hash to a version containing cardano-api-11.2.0.0. |
| cabal.project | Advances cardano-haskell-packages index-state past the 11.2.0.0 publish timestamp. |
| cardano-cli/cardano-cli.cabal | Updates cardano-api bound to ^>=11.2. |
| cardano-cli/src/Cardano/CLI/Type/Common.hs | Replaces TxBodyFile phantom type with a dedicated tag type to avoid deprecated/removed TxBody usage. |
| cardano-cli/src/Cardano/CLI/Read.hs | Refactors IncompleteTxBody to carry Exp.UnsignedTx and updates txbody reading accordingly. |
| cardano-cli/src/Cardano/CLI/EraIndependent/Debug/TransactionView/Run.hs | Updates txbody viewing to consume the new IncompleteTxBody representation. |
| cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs | Migrates signing/witnessing/txid/submit/min-fee/script-cost paths to ledger-body + experimental helpers and new TxOut return types. |
| cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs | Changes TxOut building to produce experimental outputs plus a supplemental datum map. |
| cardano-cli/src/Cardano/CLI/Compatible/Transaction/Run.hs | Threads supplemental datum map into createCompatibleTx call. |
| cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs | Switches friendly JSON rendering to use experimental TxOut wrapper and ledger datum rendering. |
| cardano-cli/src/Cardano/CLI/Type/Error/TxCmdError.hs | Removes now-unreachable datum decoding error constructor/rendering after upstream type removal. |
| cardano-cli/src/Cardano/CLI/Type/Error/TxValidationError.hs | Removes validateTxReturnCollateral helper (now unused after migration). |
| cardano-cli/src/Cardano/CLI/Type/Key.hs | Moves stake pool metadata/relay types to Experimental Certificate API imports. |
| cardano-cli/src/Cardano/CLI/Type/Error/StakePoolCmdError.hs | Migrates stake pool metadata error types/hashes to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/Type/Error/GovernanceCmdError.hs | Migrates DRep metadata hash types to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraIndependent/Node/Command.hs | Imports KESPeriod from Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraIndependent/Node/Run.hs | Migrates operational certificate issuance to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/Genesis/Run.hs | Migrates operational certificate issuance/types to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/Genesis/CreateTestnetData/Run.hs | Migrates KES period / op cert counter types to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/Common/Option.hs | Migrates KES/stake pool metadata/relay option types to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs | Updates UTxO text rendering to use experimental TxOut wrapper + ledger-based value/datum rendering. |
| cardano-cli/src/Cardano/CLI/EraBased/StakePool/Run.hs | Migrates stake pool metadata validation/hashing/params conversion to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/StakePool/Option.hs | Migrates stake pool metadata hash type imports to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/StakePool/Internal/Metadata.hs | Migrates stake pool metadata reference + hashing to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/StakePool/Command.hs | Migrates stake pool command types (metadata/relay) to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/Compatible/StakePool/Run.hs | Migrates compatible stake pool params conversion to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/Compatible/StakePool/Command.hs | Migrates stake pool metadata reference/relay types to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs | Drops legacy hiding clause; aligns with updated certificate APIs. |
| cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs | Drops legacy hiding clause; aligns with updated certificate APIs. |
| cardano-cli/src/Cardano/CLI/EraBased/Governance/Run.hs | Drops legacy hiding clause; aligns with updated certificate APIs. |
| cardano-cli/src/Cardano/CLI/EraBased/Governance/GenesisKeyDelegationCertificate/Run.hs | Drops legacy hiding clause; aligns with updated certificate APIs. |
| cardano-cli/src/Cardano/CLI/EraBased/Governance/Committee/Run.hs | Drops legacy hiding clause; aligns with updated certificate APIs. |
| cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Run.hs | Migrates DRep metadata hashing/types to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Option.hs | Migrates DRep metadata hash type imports to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Command.hs | Migrates DRep metadata type import to Experimental Certificate API. |
| cardano-cli/src/Cardano/CLI/Compatible/Governance/Command.hs | Imports MIRPot from Compatible Certificate API. |
| cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs | Updates AsType import for op cert issue counter to Experimental Certificate API. |
| cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/Operational.hs | Updates AsType import for operational certificate to Experimental Certificate API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1,3 +1,5 @@ | |||
| {-# LANGUAGE FlexibleContexts #-} | |||
| {-# LANGUAGE GADTs #-} | |||
| IncompleteTxBody era (Exp.UnsignedTx ledgerTx) <- | ||
| lift (readFileTxBody txbodyFile) & onLeft (left . TxCmdTextEnvError) | ||
| witnesses <- |
6fb148a to
d200dd2
Compare
cardano-api 11.2.0.0 is published to CHaP. Bump the cardano-haskell-packages index-state past the publish (2026-05-18T18:23:40Z), bump the cardano-cli cabal dep from ^>=11.1 to ^>=11.2, and bump the CHaP flake input accordingly. 11.2.0.0 introduces breaking changes that subsequent commits in this PR migrate cardano-cli to: legacy TxOut removed (cardano-api #1209), legacy Certificate type removed (#1210), and TxBody/TxBodyContent deprecated (#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.
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, and
reference script directly via the ledger lenses ('addrTxOutL',
'valueTxOutL', '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.
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.
cardano-api #1210 removed the legacy 'Cardano.Api.Certificate' module and stopped re-exporting Certificate-construction helpers from 'Cardano.Api'. Migrate cardano-cli to import the relevant types ('StakePoolRelay', 'StakePoolMetadataReference', 'StakePoolMetadata', 'DRepMetadata', 'KESPeriod', 'OperationalCertificate', 'OperationalCertificateIssueCounter', 'PoolId', 'StakePoolParameters', helpers like 'issueOperationalCertificate', 'validateAndHashStakePoolMetadata', 'toShelleyPoolParams', 'hashDRepMetadata', 'getKesPeriod', 'getOpCertCount', data instances 'Hash StakePoolMetadataHash' / 'Hash DRepMetadataHash', 'AsType AsOperationalCertificate' / 'AsType AsOperationalCertificateIssueCounter', 'MIRPot') from 'Cardano.Api.Experimental.Certificate' or 'Cardano.Api.Compatible.Certificate' as appropriate. Drops vacuous 'hiding (make*Certificate)' / 'hiding (Certificate)' clauses that referenced names no longer re-exported from 'Cardano.Api', which had become '-Wdodgy-imports' errors under '-Werror'. Removes the redundant 'Cardano.Ledger.Core' qualified import from 'Cardano.CLI.Read' that became unused after the cardano-api re-export narrowing.
d200dd2 to
db5a030
Compare
| type TxBodyFile = File (TxBody ()) | ||
| data TxBodyTag | ||
|
|
||
| type TxBodyFile = File TxBodyTag |
There was a problem hiding this comment.
I'm not so certain how TxBodyTag is useful here. Usually the phantom type here is used to represent what's in the file. So it's kind of detached from the actual content. Maybe L.TxBody could be used? but it has kind TxLevel -> Type -> Type, so we'd have to assume a Tx level or thread it in.
| , "amount" .= friendlyLedgerValue era ledgerValue | ||
| , "stake reference" | ||
| .= friendlyStakeReference (fromShelleyStakeReference stake) | ||
| , "reference script" .= refScript |
There was a problem hiding this comment.
| , "reference script" .= refScript | |
| , "datum" .= case ledgerTxOut ^. L.datumTxOutL of | |
| L.NoDatum -> Aeson.Null | |
| L.DatumHash h -> toJSON h | |
| L.Datum bd -> friendlyDatum (L.binaryDataToData bd) | |
| , "reference script" .= refScript |
It seems the datum here got removed. It seems originally it was only shown when present but, since this is Babbage onwards, I am guessing it is more consistent to show it as null if absent
| let ledgerTxBody = shelleyBasedEraConstraints sbe $ ledgerTx ^. L.bodyTxL | ||
| unsignedTxAsTx = shelleyBasedEraConstraints sbe $ ShelleyTx sbe ledgerTx |
There was a problem hiding this comment.
| let ledgerTxBody = shelleyBasedEraConstraints sbe $ ledgerTx ^. L.bodyTxL | |
| unsignedTxAsTx = shelleyBasedEraConstraints sbe $ ShelleyTx sbe ledgerTx | |
| let ledgerTxBody = ledgerTx ^. L.bodyTxL | |
| unsignedTxAsTx = ShelleyTx sbe ledgerTx |
shelleyBasedEraConstraints is not necessary here
| mkShelleyBootstrapWitness sbe mNetworkId ledgerTxBody bootstrapWitData | ||
| AShelleyKeyWitness skShelley -> | ||
| pure $ makeShelleyKeyWitness sbe txbody skShelley | ||
| let ledgerTxBody = shelleyBasedEraConstraints sbe $ ledgerTx ^. L.bodyTxL |
There was a problem hiding this comment.
| let ledgerTxBody = shelleyBasedEraConstraints sbe $ ledgerTx ^. L.bodyTxL | |
| let ledgerTxBody = ledgerTx ^. L.bodyTxL |
Same here
| :: IsShelleyBasedEra era | ||
| => ShelleyBasedEra era |
There was a problem hiding this comment.
| :: IsShelleyBasedEra era | |
| => ShelleyBasedEra era | |
| :: ShelleyBasedEra era |
IsShelleyBasedEra era can be deduced from ShelleyBasedEra era by using shelleyBasedEraConstraints. But maybe we want it for convenience
| outsAndDatums <- mapM (toTxOutInAnyEra sbe) outs | ||
| let allOuts = map fst outsAndDatums | ||
| extraDatums = Map.unions (map snd outsAndDatums) |
There was a problem hiding this comment.
| outsAndDatums <- mapM (toTxOutInAnyEra sbe) outs | |
| let allOuts = map fst outsAndDatums | |
| extraDatums = Map.unions (map snd outsAndDatums) | |
| (allOuts, extraDatumsMapList) <- mapAndUnzipM (toTxOutInAnyEra sbe) outs | |
| let extraDatums = Map.unions extraDatumsMapList |
Just showing off, but it is a bit simpler and eagerer
| TxSubmitSuccess -> do | ||
| liftIO $ Text.hPutStrLn IO.stderr "Transaction successfully submitted. Transaction hash is:" | ||
| liftIO $ LBS.putStrLn $ Aeson.encode $ TxSubmissionResult $ getTxId $ getTxBody tx | ||
| liftIO $ |
There was a problem hiding this comment.
This is outside of the PR, but, since we are at it, we could liftIO only once outside of the do instead
| let unsignedTx :: Exp.UnsignedTx (Exp.LedgerEra era) | ||
| unsignedTx = obtainCommonConstraints era $ Exp.UnsignedTx ledgerTx | ||
| shelleyfee :: Lovelace | ||
| shelleyfee = | ||
| obtainCommonConstraints era $ | ||
| Exp.evaluateTransactionFee lpparams unsignedTx nShelleyKeyWitW32 0 sReferenceScript | ||
| txFeePerByte :: L.CoinPerByte | ||
| txFeePerByte = obtainCommonConstraints era $ lpparams ^. L.ppTxFeePerByteL | ||
| byronfee :: Lovelace | ||
| byronfee = calculateByronWitnessFees txFeePerByte nByronKeyWitnesses | ||
| fee :: Lovelace | ||
| fee = shelleyfee + byronfee |
There was a problem hiding this comment.
Since these definitions have types declarations, I would add an empty line between them, otherwise it is a bit hard to parse them
Changelog
Context
Test run: https://github.com/IntersectMBO/cardano-node-tests/actions/runs/26061932453
Supersedes #1375 and #1376. cardano-api 11.2.0.0 ships these breaking changes:
DRepgolden tests for thread-safety #1209 — legacy TxOut removed from Compatible / Experimental APIsPlus two non-breaking notable changes (#1205 evaluateTransaction, #1200 TxBody/TxBodyContent deprecation, #1193 export of evaluateTransactionExecutionUnits).
cardano-api 11.2.0.0 is now published to CHaP (timestamp
2026-05-18T18:23:40Z). This branch consumes it via the standard CHaP repository — the previoussource-repository-packagepin has been removed and thecardano-haskell-packagesindex-stateplus theCHaPflake input have been bumped past the publish.How to trust this PR
cabal build cardano-cli -j4is green against cardano-api 11.2.0.0 from CHaP.cabal test all -j4:cardano-cli-test69/69 pass;cardano-cli-golden686/686 pass.fourmoluclean on all touched modules.Checklist
source-repository-packagepin dropped; consuming cardano-api 11.2.0.0 from CHaP