-
Notifications
You must be signed in to change notification settings - Fork 100
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 metadata information to generated .abi.json file (master-2.x) #148
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.
Changes are fine and you add UT.
Let's wait for the testing team before approving it.
@superboyiii Can you take a quick look at this PR from a testing perspective? |
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.
agree
Sure, @nicolegys will give a quick response of test result. |
Test: I added the attributes in my contract and the metadata infomation could be seen in the generated .abi.json file. Now I could not make further test, because this part in neo-cli hasn't been changed. In addtion, could you also add paramTypes and returnTypeHexString? Or they can be calculated automaticly from the smart contract code. |
Thanks for verifying my PR @nicolegys! I didn't include the hex string for parameter/return types because it's trivial to parse that information from existing data in the in the .abi.json file. |
@@ -80,6 +81,18 @@ public static MyJson.JsonNode_Object Export(NeoModule module, byte[] script) | |||
} | |||
outjson.SetDictValue("hash", sb.ToString()); | |||
|
|||
//metadata | |||
var metadataJson = new MyJson.JsonNode_Object(); |
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.
What's happend if there the value it's null? maybe we should avoid the entry
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.
The metadata properties being inserted into .abi.json file here all have default values if not specified via custom attributes.
Fixes #144
This PR adds a new "metadata" property to the .abi.json file generated by NEON (2.x branch). It contains the metadata needed by Neo.Contract.Create to deploy contracts that can't be obtained from the AVM or existing .abi.json file.
Having this information included in the abi.json file enables tools like neo-express and neo-visual-devtracker to deploy contracts w/o collecting this information from the developer at contract deployment time. Additionally, by specifying these values in source (as per below), we also reduce the potential for errors at contract deployment time.
The contract metadata can be included in the contract C# source code via a set of new custom attributes that this PR adds to the Neo.SmartContract.Framework package.
The resulting metadata node looks in the contract.abi.json file looks like this:
NEON uses the following defaults if metadata is not specified via custom attributes:
The .NET library already has
AssemblyTitleAttribute
andAssemblyDescriptionAttribute
custom attributes. If these attributes are specified, NEON will use them for contract title and description respectively. However, if both standard and Neo contract attributes are used to specify the same metadata, NEON will use the value from the Neo contract attribute.