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 for metadata #1290

Merged
merged 3 commits into from
Jun 16, 2022
Merged

Add JSON schema for metadata #1290

merged 3 commits into from
Jun 16, 2022

Conversation

HCastano
Copy link
Contributor

This PR introduces a JSON schema which describes the contract
metadata. There are two schemas, the outer metadata (generated by cargo-contract) and
the versioned ink! metadata.

(This distinction only exists because cargo-contract is technically agnostic to the
language metadata, although in practice it's really only using the ink! metadata. In the
future we should be able to merge these into a single schema.)

The schemas provide a source of truth about what key-value pairs are supported and what
types they expect. This is useful for developers as well as external tooling. One use
case here is tooling which needs to verify that a given piece of metadata is valid.

Note that the generated process for the schemas is currently using some hacked branches
across scale-info, ink, and cargo-contract (the generation process is described in
the metadata crate's README). My goal is that in the future we'll be able to properly
upstream these changes across our repos and have an easy way to generate the schemas from
cargo-contract. At that point we'll be able to get rid of these hardcoded schema files.

Related issue: #940

Copy link
Collaborator

@cmichi cmichi left a comment

Choose a reason for hiding this comment

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

For some whatever reason I cannot add suggestions to the readme. I'm approving it hence now and might create a follow-up PR.

For the Metadata Schema Generation, do you plan on upstreaming those changes?

@HCastano
Copy link
Contributor Author

For the Metadata Schema Generation, do you plan on upstreaming those changes?

Yeah. I think the ideal workflow would be to have an option in cargo-contract to generate the schema. Will take a bit to upstream though since it cuts through a few repos

Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

LGTM

@HCastano
Copy link
Contributor Author

CI failures are unrelated to this PR

@HCastano HCastano merged commit 8566c14 into master Jun 16, 2022
@HCastano HCastano deleted the hc-metadata-schema branch June 16, 2022 17:42
@HCastano HCastano mentioned this pull request Jun 16, 2022
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