Improve JSON Output for Upload and Remove Commands#1389
Merged
xermicus merged 3 commits intouse-ink:masterfrom Nov 24, 2023
Merged
Improve JSON Output for Upload and Remove Commands#1389xermicus merged 3 commits intouse-ink:masterfrom
xermicus merged 3 commits intouse-ink:masterfrom
Conversation
tareknaser
added a commit
to tareknaser/cargo-contract
that referenced
this pull request
Nov 1, 2023
Signed-off-by: Tarek <[email protected]>
smiasojed
reviewed
Nov 2, 2023
smiasojed
reviewed
Nov 13, 2023
| // Create a JSON object with the events and the removed code hash. | ||
| let json_object = serde_json::json!({ | ||
| "events": serde_json::from_str::<serde_json::Value>(&output_events)?, | ||
| "removed_code_hash": remove_result, |
Contributor
There was a problem hiding this comment.
Here, we have removed_code_hash in JSON format, and in standard printing, we have Code hash. I think it makes sense to align it.
In the upload command, we have code hash in both cases; in JSON: code_hash, and in standard print: Code hash.
Contributor
Author
There was a problem hiding this comment.
Yes I think I missed this one.
Which one do you prefer to be used in both cases?
Contributor
There was a problem hiding this comment.
it could be just code hash for me, but I am not owner of this repo.
@ascjones do you have any preferences?
Contributor
Author
There was a problem hiding this comment.
I've now renamed it to code_hash for consistency.
Thanks for your input
This commit addresses an issue where the JSON output for both the upload and remove commands in cargo contract was in an invalid format. This commit refactors the JSON structure for these commands, resulting in valid JSON objects. Signed-off-by: Tarek <[email protected]>
Signed-off-by: Tarek <[email protected]>
This commit renames the field removed_code_hash to just code_hash in the remove command output to keep it consistent with between json output and human readable output Signed-off-by: Tarek <[email protected]>
fd70f32 to
b156b08
Compare
smiasojed
approved these changes
Nov 24, 2023
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses an issue where the JSON output for both the
uploadandremovecommands in cargo contract was in an invalid format.inkorpallet-contracts?Description
This pull request enhances the JSON output for both the
uploadandremovecommands in cargo contract.Previously, the JSON output was in an invalid format, making it challenging to parse and extract information. The modified format now produces valid JSON objects for easier parsing.
Example: JSON Output Before:
// Invalid JSON Format (Before) [ { "pallet": "Balances", "name": "Withdraw", // ... Other fields }, // ... Additional events ] { "code_hash": "0xe62b681614e6b7dbe892796b..." }Example: JSON Output After:
// Valid JSON Format (After) { "code_hash": "0xe62b681614e6b7dbe892796b...", "events": [ { "name": "Withdraw", "pallet": "Balances", // ... Other fields }, // ... Additional events ] }Checklist before requesting a review
CHANGELOG.md