Skip to content

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Sep 22, 2025

Changelog

- description: |
    Replace `Certificate` in `TxCertificates` with new api's `Certificate` type.
# uncomment types applicable to the change:
  type:
  - breaking       # the API has changed in a breaking way
  projects:
   - cardano-api

Context

Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.

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

@Jimbo4350 Jimbo4350 force-pushed the jordan/deprecate-certificate-in-tx-certificates branch from d0ae67a to d165125 Compare September 22, 2025 13:22
@Jimbo4350 Jimbo4350 force-pushed the jordan/deprecate-certificate-in-tx-certificates branch 3 times, most recently from 34eb78c to 6bf3263 Compare September 24, 2025 11:16
@Jimbo4350 Jimbo4350 force-pushed the jordan/deprecate-certificate-in-tx-certificates branch from 6bf3263 to 62b27ed Compare September 24, 2025 11:57
@Jimbo4350 Jimbo4350 force-pushed the jordan/deprecate-certificate-in-tx-certificates branch from 62b27ed to 457550a Compare September 24, 2025 12:03
@Jimbo4350 Jimbo4350 changed the title WIP: Deprecate certificate in tx certificates Deprecate certificate in tx certificates Sep 24, 2025
@Jimbo4350 Jimbo4350 force-pushed the jordan/deprecate-certificate-in-tx-certificates branch from 457550a to ebdf22b Compare September 24, 2025 12:06
@Jimbo4350 Jimbo4350 marked this pull request as ready for review September 24, 2025 12:06

let stakeCreds = fromList $ mapMaybe filterUnRegCreds certs
drepCreds = fromList $ mapMaybe filterUnRegDRepCreds certs
-- TODO: Left off here fix filterUnRegCreds
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove comment

filterUnRegCreds sbe (Exp.Certificate cert) =
fmap fromShelleyStakeCredential $
shelleyBasedEraConstraints sbe $
Ledger.lookupUnRegStakeTxCert cert
Copy link
Contributor

@carbolymer carbolymer Sep 24, 2025

Choose a reason for hiding this comment

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

That's cool, so many hours were wasted here on figuring out the correct implementation here.

instance Error AnchorDataFromCertificateError where
prettyError :: AnchorDataFromCertificateError -> Doc ann
prettyError (InvalidPoolMetadataHashError url hash) =
"Invalid pool metadata hash for URL " <> fromString (show url) <> ": " <> fromString (show hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

afair show will quote the argument, so if you don't want quotes, this should be easier

Suggested change
"Invalid pool metadata hash for URL " <> fromString (show url) <> ": " <> fromString (show hash)
"Invalid pool metadata hash for URL " <> pretty url <> ": " <> pretty hash

or this seems more idiomatic:

Suggested change
"Invalid pool metadata hash for URL " <> fromString (show url) <> ": " <> fromString (show hash)
"Invalid pool metadata hash for URL " <> dquotes (pretty url) <> ": " <> dquotes (pretty hash)

Copy link
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

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

LGTM

@Jimbo4350 Jimbo4350 force-pushed the jordan/deprecate-certificate-in-tx-certificates branch from ebdf22b to 45eae26 Compare September 25, 2025 09:13
Copy link
Contributor

@palas palas left a comment

Choose a reason for hiding this comment

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

It all looks good 👍. I wonder why we had a property around Ord. And we could probably preserve it somehow, but not sure why that was important

@carbolymer
Copy link
Contributor

@palas partially because of this definition:

  TxCertificates
    :: ShelleyBasedEra era
    -> OMap
         (Certificate era)
         ( BuildTxWith
             build
             (Maybe (StakeCredential, Witness WitCtxStake era))
         )
    -> TxCertificates build era

Because the certificate is just wrapper over ledger's TxCert, we can trust ledger to provide a legal Ord instance I think.

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.

3 participants