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

Json schema validation error #1506

Open
tmcgroul opened this issue Nov 17, 2022 · 3 comments
Open

Json schema validation error #1506

tmcgroul opened this issue Nov 17, 2022 · 3 comments
Assignees
Labels
A-ink_metadata [ink_metadata] Work item

Comments

@tmcgroul
Copy link

I've already reported this issue here: https://substrate.stackexchange.com/questions/4449/validation-error-during-ink-contract-metadata-validation

Link to the contract - https://github.com/Supercolony-net/openbrush-contracts/tree/e366f6ff1e5892c6a624833dd337a6da16a06baa/examples/psp22_extensions/metadata
Version of cargo-contract: cargo-contract 1.5.0-unknown-x86_64-unknown-linux-gnu

@HCastano

@HCastano HCastano self-assigned this Nov 17, 2022
@HCastano HCastano added the A-ink_metadata [ink_metadata] Work item label Nov 23, 2022
@vikiival
Copy link

Hello,

any updates on this?

We got the same error with this PSP-34 contract
https://github.com/swanky-dapps/nft

@HCastano
Copy link
Contributor

Thanks for the report. No updates yet since this is on the backburner while some remaining ink! 4.0 issues get sorted.

@XY-Wang
Copy link

XY-Wang commented Dec 23, 2022

Hey guys,

Since I was working on #1564 I decided to check out this related issue and I believe I have found the cause of the problem.

Firstly, I see from your linked schema validator errors that you are trying to validate your complete contract metadata file. There's a schema called outer-schema.json found here to validate that (and your file is valid!). If you want to validate against ink-v3-schema.json, you will need to remove the source and contract objects in the metadata and only leave the V3 object.

That leads us to the next problem 😄

The ink-v3-schema.json is expecting an object for LayoutKey in the storage layout even though the metadata output is a string. I published an updated version of the V3 schema here with the updated LayoutKey schema. Using this schema your contract metadata is valid 🎉

On why the LayoutKey was expecting an object but metadata output is a string:

In this file we can see that LayoutKey is indeed defined as a struct. If we read on further we see that there is a custom serde::Serialize that serailizes the key to a hex string. However in the generation of the schema this was not taken into account so the schema expected the same struct layout.

Hope this explanation helps 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ink_metadata [ink_metadata] Work item
Projects
None yet
Development

No branches or pull requests

4 participants