Skip to content

Add schema generation and verification#1404

Merged
SkymanOne merged 3 commits intomasterfrom
gn/schema-ops
Nov 17, 2023
Merged

Add schema generation and verification#1404
SkymanOne merged 3 commits intomasterfrom
gn/schema-ops

Conversation

@SkymanOne
Copy link
Copy Markdown
Contributor

@SkymanOne SkymanOne commented Nov 16, 2023

Summary

Closes #1090 and use-ink/ink#1564

  • [n] y/n | Does it introduce breaking changes?
  • [y] y/n | Is it dependent on the specific version of ink or pallet-contracts? - 5.0.0-alpha

Introudeces schema generation and verfication commands.

Description

This PR automated proces for metadata schema generation.

Whenever there are changes to the schema, if cargo-contract targets the latest version of ink_metadata the scheme can be generated with cargo contract schema-generate inner/outer. This will print json to STDOUT.

And here is the sample of how to verify the metadata against specified schema file:

Bundle:

cargo contract verify-schema --schema /Users/skymanone/Projects/ink/crates/metadata/contract_schema.json --bundle target/ink/flipper.contract

Successfully verified metadata in `target/ink/flipper.contract` against schema `/Users/skymanone/Projects/ink/crates/metadata/contract_schema.json`!

Metadata file:

cargo contract verify-schema --schema /Users/skymanone/Projects/ink/crates/metadata/contract_schema.json --metadata target/ink/flipper.json

Successfully verified metadata in `target/ink/flipper.json` against schema `/Users/skymanone/Projects/ink/crates/metadata/contract_schema.json`!

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have added an entry to CHANGELOG.md
  • I have commented my code, particularly in hard-to-understand aras
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@SkymanOne SkymanOne changed the title add schema generation and verification Add schema generation and verification Nov 16, 2023
#[clap(name = "verify")]
Verify(VerifyCommand),
/// Generates schema from the current metadata specification.
#[clap(name = "generate-schema")]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be better to have a 'schema' command and use '-generate' and '-verify' as its arguments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Too many subcommands IMO: cargo contract schema ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think info and call have more arguments, but it's up to you whether to leave them as they are or make changes.

@SkymanOne SkymanOne requested a review from smiasojed November 17, 2023 11:32
Copy link
Copy Markdown
Contributor

@smiasojed smiasojed left a comment

Choose a reason for hiding this comment

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

LGTM

@SkymanOne SkymanOne merged commit e1f7ae2 into master Nov 17, 2023
@SkymanOne SkymanOne deleted the gn/schema-ops branch November 17, 2023 16:05
@smiasojed smiasojed mentioned this pull request Nov 30, 2023
@smiasojed smiasojed mentioned this pull request Mar 4, 2024
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.

Schema generation/validation

2 participants