Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON schema checking functionality for validating gov action metadata #713

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

palas
Copy link
Contributor

@palas palas commented Dec 20, 2024

Changelog

- description: |
    Added schema checking functionality for DRep registration, DRep update, and GovAction metadata, based on CIP-0100, CIP-0108, and CIP-0119. Also add functionality to check whether a certificate is for DRep registration or updating.
  type:
  - feature
  - compatible
  - test

Context

The objective is addressing this issue: IntersectMBO/cardano-cli#906

This PR adds 3 functions to the API that should be the only ones needed by the cardano-cli in order to implement this functionality:

  • isDRepRegOrUpdateCert - Checks whether a certificate is for DRep registration or DRep update.
  • validateDRepAnchorData - Checks whether a ByteString is valid JSON and conforms to CIP-0119.
  • validateGovActionAnchorData - Checks whether a ByteString is valid JSON and conforms to CIP-0108

This PR is a requirement from PR #995 that implements the checking in cardano-cli and is based of the version of cardano-api in this PR.

Related PRs in CIPs repo:

  • PR #950 - Adds @ before type field name
  • PR #951 - Ensures CIP-0008 is in capital letters

How to trust this PR

Tests should give some assurance. They are taken from the CIPs repo, with some adaptations that I have already created PRs in CIPs repo for (see above).

The main thing to check here is the accuracy of the checks (are they enough, are they too much, are they right).

Could be useful to check the cardano-cli PR together with this one.

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

@carbolymer
Copy link
Contributor

But the CIPs 0119 and 0108 are in proposed state. Shouldn't we wait till they get accepted?

@palas palas force-pushed the gov-action-schema-checking branch 4 times, most recently from a447f80 to 504575e Compare January 13, 2025 14:36
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

LGTM! Can you clean up the commit history and add links to the CIPs at the top of the modules?

cardano-api/cardano-api.cabal Outdated Show resolved Hide resolved
cardano-api/src/Cardano/Api.hs Outdated Show resolved Hide resolved
@palas palas force-pushed the gov-action-schema-checking branch 2 times, most recently from 9ddff13 to dade8b3 Compare January 14, 2025 15:40
@palas palas changed the title Add JSON schema checking functionality for DRep and Gov action metadata Add JSON schema checking functionality for validating gov action metadata Jan 14, 2025
@palas palas force-pushed the gov-action-schema-checking branch from dade8b3 to 2922689 Compare January 14, 2025 15:46
@palas palas enabled auto-merge January 14, 2025 15:48
@palas palas added this pull request to the merge queue Jan 14, 2025
@carbolymer carbolymer removed this pull request from the merge queue due to a manual request Jan 14, 2025
@carbolymer carbolymer merged commit bbe5077 into master Jan 14, 2025
29 of 31 checks passed
@carbolymer carbolymer deleted the gov-action-schema-checking branch January 14, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Governance metadata is not validated
3 participants