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

Add --binary flag for info command #1311

Merged
merged 65 commits into from
Sep 4, 2023
Merged

Add --binary flag for info command #1311

merged 65 commits into from
Sep 4, 2023

Conversation

smiasojed
Copy link
Collaborator

@smiasojed smiasojed commented Sep 4, 2023

Closes #800

The combination --binary and --output-json returns JSON:

{ 
  "wasm": "0x..."
}

I assumed that binary flag is a behaviour switch, and output-json just formatter.
The another option is to combine wasm hex code with the rest of info command default content:

{
  "trie_id": "f8ac805216a9318ab898d0777e24ac52583ca690a218556cfeb6b05744d191cf",
  "code_hash": "0x1a56980585ad4097aaea9daf1bee2332e2a9cf579d0c1a3b91a81900cb399a53",
  "storage_items": 1,
  "storage_item_deposit": 100000000000
  "wasm": "0x..."
}

I think that cleaner approach is the first one, where --binary is treated as behaviour switch

Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

Looks good, just the small nitpick about the return type and a question.

Also please update the description with "Closes #800", so we know which issue is being dealt with and it closes automatically when this is merged.

pub async fn fetch_wasm_code(
hash: CodeHash,
client: &Client,
) -> Result<Option<BoundedVec<u8>>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should convert the BoundedVec to a Vec for the return type: better not to expose types generated by subxt in the public api of this crate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

crates/cargo-contract/src/cmd/info.rs Show resolved Hide resolved
Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

LGTM!

@ascjones ascjones merged commit 497cb88 into master Sep 4, 2023
10 checks passed
@ascjones ascjones deleted the ln-info-prinstine-code branch September 4, 2023 19:34
@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.

Output pristine Wasm code for cargo contract info
3 participants