Skip to content

Remove legacy Certificate type and Cardano.Api.Certificate module#1210

Merged
Jimbo4350 merged 6 commits into
masterfrom
jordan/remove-legacy-certificate-type
May 18, 2026
Merged

Remove legacy Certificate type and Cardano.Api.Certificate module#1210
Jimbo4350 merged 6 commits into
masterfrom
jordan/remove-legacy-certificate-type

Conversation

@Jimbo4350
Copy link
Copy Markdown
Contributor

Context

cardano-api has carried two parallel certificate APIs for some time:

  • Legacydata Certificate era in Cardano.Api.Certificate.Internal, a GADT with ShelleyRelatedCertificate/ConwayCertificate constructors, surrounded by ~13 deprecated make*Certificate functions and ~11 *Requirements GADTs. Re-exported via the public Cardano.Api.Certificate module.
  • Replacementdata Certificate era where Certificate :: L.EraTxCert era => L.TxCert era -> Certificate era in Cardano.Api.Experimental.Tx.Internal.Certificate.Type. Era-polymorphic wrapper over the ledger's TxCert. Exposed via Cardano.Api.Experimental.Certificate (Era-parameterized, Conway onwards) and Cardano.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 -j4 is green.
  • cabal test cardano-api -j4 passes all 221 tests; cardano-api-golden passes all 125 tests.
  • The legacy Certificate GADT, its constructors, every deprecated make*Certificate, every *Requirements GADT, and the helpers selectStakeCredentialWitness/toShelleyCertificate/fromShelleyCertificate/isDRepRegOrUpdateCert are gone. Cardano.Api.Certificate.Internal now contains only pool params and conversion helpers.
  • The public Cardano.Api.Certificate module is deleted; the cabal exposed-modules and Cardano.Api re-export are updated.
  • filterUnRegCreds and filterUnRegDRepCreds were moved to Cardano.Api.Experimental.Tx.Internal.Certificate (where they belong — they operate on Exp.Certificate already) and re-exported via Cardano.Api.Experimental.Certificate.
  • genCertificate in gen/Test/Gen/Cardano/Api/Typed.hs now produces Exp.Certificate (ShelleyLedgerEra era) directly using ledger constructors gated by era evidence. extractCertificate and all gen*Requirements helpers are deleted.
  • Consumers updated: Sign.hs imports AsTxId directly from Tx.Internal.TxIn; Body.hs and OperationalCertificate.hs drop unused imports; Query/Internal/Convenience.hs uses the experimental path for the filter functions; wasm/StakeCertificate.hs gets PoolId from the experimental module; test modules pick up OperationalCertIssueError/StakePoolMetadataValidationError/DRepMetadata/op-cert AsType constructors from Cardano.Api.Experimental.Certificate.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

🤖 Generated with Claude Code

Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
Comment thread cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Fixed
@Jimbo4350 Jimbo4350 force-pushed the jordan/remove-legacy-certificate-type branch from 888bdef to 867573a Compare May 15, 2026 13:45
…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.
@Jimbo4350 Jimbo4350 force-pushed the jordan/remove-legacy-certificate-type branch from 867573a to 7c6ab9f Compare May 15, 2026 14:12
@Jimbo4350 Jimbo4350 marked this pull request as ready for review May 15, 2026 14:13
Copilot AI review requested due to automatic review settings May 15, 2026 14:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Certificate GADT, all make*Certificate functions, all *Requirements GADTs, helpers (selectStakeCredentialWitness, toShelleyCertificate, fromShelleyCertificate, isDRepRegOrUpdateCert), getAnchorDataFromCertificate, the Cardano.Api.Certificate module, and its re-export from Cardano.Api.
  • Move filterUnRegCreds / filterUnRegDRepCreds to Cardano.Api.Experimental.Tx.Internal.Certificate and re-export through Cardano.Api.Experimental.Certificate; expose AsType constructors for op-cert types there.
  • Rewrite genCertificate and friends in Test.Gen.Cardano.Api.Typed to construct Exp.Certificate (ShelleyLedgerEra era) directly via ledger constructors; update consumer imports (Sign.hs, Body.hs, OperationalCertificate.hs, Query.Convenience, wasm StakeCertificate, 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
@Jimbo4350 Jimbo4350 force-pushed the jordan/remove-legacy-certificate-type branch 2 times, most recently from e6519b9 to 79272ed Compare May 15, 2026 15:33
Comment thread .changes/20260515_cardano_api_remove_legacy_certificate_type.yml Outdated
Comment thread .changes/20260515_cardano_wasm_remove_legacy_certificate_type.yml Outdated
Jimbo4350 added 4 commits May 15, 2026 14:19
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.
@Jimbo4350 Jimbo4350 force-pushed the jordan/remove-legacy-certificate-type branch from 79272ed to 1aee072 Compare May 15, 2026 18:19
@Jimbo4350 Jimbo4350 force-pushed the jordan/remove-legacy-certificate-type branch from 1aee072 to 089edd7 Compare May 15, 2026 20:41
@Jimbo4350 Jimbo4350 added this pull request to the merge queue May 18, 2026
Merged via the queue into master with commit f2469e3 May 18, 2026
31 checks passed
@Jimbo4350 Jimbo4350 deleted the jordan/remove-legacy-certificate-type branch May 18, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants