Remove legacy Certificate type and Cardano.Api.Certificate module#1210
Merged
Conversation
888bdef to
867573a
Compare
…e module Both functions already operate on the experimental `Exp.Certificate` wrapper; they only lived in `Cardano.Api.Certificate.Internal` for historical reasons. Move them next to the type they operate on and re-export them from `Cardano.Api.Experimental.Certificate`. Update the sole caller in Query/Internal/Convenience.hs to import directly from the new location.
867573a to
7c6ab9f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Removes the legacy Certificate era GADT API and the public Cardano.Api.Certificate module entirely, consolidating on the experimental ledger-backed Certificate wrapper. Pool params and metadata helpers remain in Cardano.Api.Certificate.Internal; filterUnRegCreds / filterUnRegDRepCreds move to the experimental certificate module. This is a breaking change to a foundational, widely re-exported API surface.
Changes:
- Delete the legacy
CertificateGADT, allmake*Certificatefunctions, all*RequirementsGADTs, helpers (selectStakeCredentialWitness,toShelleyCertificate,fromShelleyCertificate,isDRepRegOrUpdateCert),getAnchorDataFromCertificate, theCardano.Api.Certificatemodule, and its re-export fromCardano.Api. - Move
filterUnRegCreds/filterUnRegDRepCredstoCardano.Api.Experimental.Tx.Internal.Certificateand re-export throughCardano.Api.Experimental.Certificate; exposeAsTypeconstructors for op-cert types there. - Rewrite
genCertificateand friends inTest.Gen.Cardano.Api.Typedto constructExp.Certificate (ShelleyLedgerEra era)directly via ledger constructors; update consumer imports (Sign.hs,Body.hs,OperationalCertificate.hs,Query.Convenience, wasmStakeCertificate, test modules).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cardano-api/src/Cardano/Api/Certificate.hs | Deleted public umbrella module for legacy certificate API. |
| cardano-api/src/Cardano/Api/Certificate/Internal.hs | Reduced to pool params + conversion helpers; legacy GADT and helpers removed. |
| cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs | Added filterUnRegCreds / filterUnRegDRepCreds. |
| cardano-api/src/Cardano/Api/Experimental/Certificate.hs | Re-export filtering helpers and op-cert AsType constructors. |
| cardano-api/src/Cardano/Api.hs | Drop re-export of removed Cardano.Api.Certificate. |
| cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs | Drop legacy import; bring AsTxId from Tx.Internal.TxIn; remove -Wno-deprecations. |
| cardano-api/src/Cardano/Api/Tx/Internal/Body.hs | Drop legacy Cardano.Api.Certificate import. |
| cardano-api/src/Cardano/Api/Certificate/Internal/OperationalCertificate.hs | Drop unused Cardano.Api.Certificate.Internal import. |
| cardano-api/src/Cardano/Api/Query/Internal/Convenience.hs | Use experimental module for filter functions. |
| cardano-api/cardano-api.cabal | Remove Cardano.Api.Certificate from exposed-modules. |
| cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs | Rewrite generators to produce experimental Certificate values directly. |
| cardano-api/test/cardano-api-test/Test/Cardano/Api/CBOR.hs | Import op-cert AsType constructors from experimental. |
| cardano-api/test/cardano-api-test/Test/Cardano/Api/GovAnchorValidation.hs | Switch DRepMetadata import to experimental. |
| cardano-api/test/cardano-api-golden/Test/Golden/ErrorsSpec.hs | Switch op-cert/stake-pool error imports to experimental. |
| cardano-wasm/src-lib/Cardano/Wasm/Api/Certificate/StakeCertificate.hs | Source PoolId from experimental certificate module. |
| .changes/20260515_cardano_api_remove_legacy_certificate_type.yml | Add breaking Herald changelog fragment. |
| @@ -0,0 +1,16 @@ | |||
| project: cardano-api | |||
|
|
|||
| pr: 0 | |||
e6519b9 to
79272ed
Compare
carbolymer
reviewed
May 15, 2026
carbolymer
reviewed
May 15, 2026
Replace the legacy `genCertificate :: ShelleyBasedEra era -> Gen (Certificate era)` generator with one that produces `Exp.Certificate (ShelleyLedgerEra era)` directly using ledger constructors gated by ShelleyToBabbageEra/ConwayEraOnwards evidence. Delete `extractCertificate` (no longer needed, since there is no legacy-to-experimental conversion to perform) and the 11 obsolete `gen*Requirements` helpers. Update `genTxCertificates` and `genScriptWitnessedTxCertificates` to consume the new generator directly. Drop now-redundant `Typeable era` constraints that were only required by the legacy GADT's `Typeable era =>` constructor signatures (`genTxCertificates`, `genScriptWitnessedTxCertificates`, `genTxBodyContent`, `genValidTxBody`, `genTxBody`, `genTx`, `genWitnesses`, `genShelleyBootstrapWitness`, `genShelleyKeyWitness`, `genShelleyWitness`, `genCardanoKeyWitness`) and the `Data.Typeable` import that became unused as a result.
Add `AsOperationalCertificate` and `AsOperationalCertificateIssueCounter` to the `AsType` re-export list of `Cardano.Api.Experimental.Certificate` so consumers that drop the public `Cardano.Api.Certificate` import have a single place to pick up the op-cert data-family constructors.
The public `Cardano.Api.Certificate` module exists only to re-export deprecated names. Delete it (and the cabal `exposed-modules` entry, and the `Cardano.Api` re-export) and migrate every remaining consumer to `Cardano.Api.Experimental.Certificate`. Test modules pick up `KESPeriod`, `OperationalCertificate`, `OperationalCertificateIssueCounter`, `issueOperationalCertificate`, `AsOperationalCertificate`, `AsOperationalCertificateIssueCounter`, `DRepMetadata`, `OperationalCertIssueError`, and `StakePoolMetadataValidationError` from the experimental module directly. `cardano-wasm` switches its `PoolId` import to the experimental module. `Cardano.Api.Tx.Internal.Body` swaps its `Cardano.Api.Certificate` import for the internal module (where the re-exports still live for now). `Cardano.Api.Certificate.Internal` itself is unchanged in this commit — the slim-down happens next.
Strip the deprecated legacy `Certificate era` GADT, its `ShelleyRelatedCertificate`/`ConwayCertificate` constructors, every `make*Certificate` constructor function, every `*Requirements` GADT, `selectStakeCredentialWitness`, `toShelleyCertificate`, `fromShelleyCertificate`, `isDRepRegOrUpdateCert`, and the legacy `AnchorDataFromCertificateError` + `getAnchorDataFromCertificate`. The module is now responsible only for the (non-deprecated) pool parameter types and their conversion helpers. Update consumers: - `Sign.hs` re-exports `AsTxId` by importing it directly from `Cardano.Api.Tx.Internal.TxIn` (the previous re-export chain went through the legacy `AsType (AsCertificate, AsTxId)` in Internal). The `-Wno-deprecations` pragma is dropped because no deprecated symbol remains. - `Body.hs` and `Certificate/Internal/OperationalCertificate.hs` drop their `Cardano.Api.Certificate.Internal` imports, which became unused once the legacy surface was removed.
79272ed to
1aee072
Compare
1aee072 to
089edd7
Compare
carbolymer
approved these changes
May 18, 2026
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.
Context
cardano-apihas carried two parallel certificate APIs for some time:data Certificate erainCardano.Api.Certificate.Internal, a GADT withShelleyRelatedCertificate/ConwayCertificateconstructors, surrounded by ~13 deprecatedmake*Certificatefunctions and ~11*RequirementsGADTs. Re-exported via the publicCardano.Api.Certificatemodule.data Certificate era where Certificate :: L.EraTxCert era => L.TxCert era -> Certificate erainCardano.Api.Experimental.Tx.Internal.Certificate.Type. Era-polymorphic wrapper over the ledger'sTxCert. Exposed viaCardano.Api.Experimental.Certificate(Era-parameterized, Conway onwards) andCardano.Api.Compatible.Certificate(covers all Shelley-based eras).Internal call sites already use the new
Exp.Certificate. This PR removes the legacy surface entirely.How to trust this PR
cabal build all -j4is green.cabal test cardano-api -j4passes all 221 tests;cardano-api-goldenpasses all 125 tests.CertificateGADT, its constructors, every deprecatedmake*Certificate, every*RequirementsGADT, and the helpersselectStakeCredentialWitness/toShelleyCertificate/fromShelleyCertificate/isDRepRegOrUpdateCertare gone.Cardano.Api.Certificate.Internalnow contains only pool params and conversion helpers.Cardano.Api.Certificatemodule is deleted; the cabalexposed-modulesandCardano.Apire-export are updated.filterUnRegCredsandfilterUnRegDRepCredswere moved toCardano.Api.Experimental.Tx.Internal.Certificate(where they belong — they operate onExp.Certificatealready) and re-exported viaCardano.Api.Experimental.Certificate.genCertificateingen/Test/Gen/Cardano/Api/Typed.hsnow producesExp.Certificate (ShelleyLedgerEra era)directly using ledger constructors gated by era evidence.extractCertificateand allgen*Requirementshelpers are deleted.Sign.hsimportsAsTxIddirectly fromTx.Internal.TxIn;Body.hsandOperationalCertificate.hsdrop unused imports;Query/Internal/Convenience.hsuses the experimental path for the filter functions;wasm/StakeCertificate.hsgetsPoolIdfrom the experimental module; test modules pick upOperationalCertIssueError/StakePoolMetadataValidationError/DRepMetadata/op-certAsTypeconstructors fromCardano.Api.Experimental.Certificate.Checklist
.changes/🤖 Generated with Claude Code