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

Use protobuf de helpers #515

Merged
merged 3 commits into from
Oct 27, 2021
Merged

Use protobuf de helpers #515

merged 3 commits into from
Oct 27, 2021

Conversation

maurolacy
Copy link
Contributor

@maurolacy maurolacy commented Oct 27, 2021

Use protobuf helpers to deserialize response in wasm executor instantiate_contract.

Also, add a couple extra useful methods, and publish structs so that they can be used directly.

Also, add deserialization / serialization traits to them.

Add serialiation / deserialization traits to them
Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

Looks like nice cleanup

@@ -7,13 +9,13 @@ const WIRE_TYPE_LENGTH_DELIMITED: u8 = 2;
// Up to 9 bytes of varints as a practical limit (https://github.com/multiformats/unsigned-varint#practical-maximum-of-9-bytes-for-security)
const VARINT_MAX_BYTES: usize = 9;

#[derive(Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
Copy link
Member

Choose a reason for hiding this comment

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

Why do we serialize? (As JSON)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it would be useful.

We need to "binarize" these messages, not serialise them.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. I prefer no json methods.

We can add method to protobuf serialise in the future. (which could be used in multitest for example).

Copy link
Member

Choose a reason for hiding this comment

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

merging now, so I can start linking. feel free to clean up later.

@@ -856,11 +857,11 @@ pub fn parse_contract_addr(data: &Option<Binary>) -> AnyResult<Addr> {
.ok_or_else(|| anyhow!("No data response"))?
.to_vec();
// parse the protobuf struct
let init_data = InstantiateData::decode(bin.as_slice())?;
Copy link
Member

Choose a reason for hiding this comment

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

Ah, this is the example I can link to. I guess it works.

@ethanfrey ethanfrey merged commit f149596 into main Oct 27, 2021
@ethanfrey ethanfrey deleted the use-protobuf-de-helpers branch October 27, 2021 16:34
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.

2 participants