-
Notifications
You must be signed in to change notification settings - Fork 121
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
Rename metadata.json
to {contract_name}.json
#952
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changelog entry plz.
Oh, this is a breaking change. We have tools reading the contract name from the |
@kvinwang makes a good point. We should think carefully before introducing breaking changes. |
On balance, I think this is reasonable to introduce as a breaking change into the The main thing is for consistency with other artefact file names. Downstream tools which depend on the static name will instead have to handle any |
Breaking is always acceptable to me. However, as I said in #950, the real problem here is not the breaking itself. We can read the metadata from the |
The guarantee now is that the |
We can guarantee there will exist a |
The way to determine the contract name is to take the first part of the The edge case with this is that if you rename your contract, then there will be multiple
We have recently changed it so the contract name is always the package name #929. But anyway it should not be required in this case because of the above heuristic (all contract artifacts have the same root name, different extensions) |
I don't think this is a good design. This is like asking the tools to guess |
The tool doesn't need to guess what the name is, the name is now the name of the |
Given there is |
I'm not exactly sure what you mean here, but if you are asking how to identify the file when it is not inside |
@kvinwang I reckon the obvious benefit of matching the metadata file with the contract's name is that sometimes you only have metadata file and meaningful name helps to understand which contract it belongs to. We already encountered an instance of such problem: we have a workshop https://github.com/paritytech/ink-workshop where game.contract is deployed by someone else and the player had to upload metadata in polkadot.js ui to be able to read the game's contracts. |
I mean there is no guarantee that Let me show a piece of pseudocode code here. Suppose we have a downstream build script like this: cargo contract build --release
CONTRACT_NAME=`jq -r .contract.name target/ink/metadata.json` Now, we might need to be changed to: cargo contract build --release
CONTRACT_NAME=`cat target/ink/*.json | jq -r .contract.name` Do you think the command I think a better solution might be adding an optional argument to assign the metadata file name by the caller. So the script would be like: cargo contract build --release --metadata target/ink/metadata.json
CONTRACT_NAME=`jq -r .contract.name target/ink/metadata.json` |
Downstream tools can easily rename the I think a better solution might be adding an option to assign the metadata file name by the caller. Like: |
Why? :) |
I explained it in this comment above. |
To make such a script more robust and agnostic of the file path of the metadata, you can read the path of the metadata from the build result e.g.:
|
Cool! Didn't know there is so much useful info in the JSON output. |
A few follow-ups here: There's going to be a bunch of tutorials and examples that need to be updated across We should also update our docs on |
In fact, the only used subcommand in our script is |
Closes #950