CosmWasm / CosmWasm/wasmd

Investigate / document how WasmExecute message replies look

Open
#623 3 comments 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Go
Stars
416
Forks
538
PR merge metrics
No merged PRs in 30d

Description

We got the following support issue. No need to change behaviour, but let's check how things are encoded when calling between wasm contracts (but using REAL contracts, not Go mocks). eg. a reflect contract executes another one and gets the sub message reply. Check the content of the data field in the reply.

If we have the same issue in wasmd, let's update cosmwasm docs and maybe provide a helper function there.

> hi everybody, after the upgrade to cosmwasm 0.16 the binary structures that arrive to reply entry point are prepended with 2 bytes which is 10 and {size_of_msg} and the only option i found to decode it back to the original struct is using an obfuscated protobuf thing which involves code-gen tooling and msgs declaration (like in terraswap). Isnt there any simple way to accomplish a proper from_binary process between the submsgs?

> one contract sends to another a submsg
```rust
Ok(Response::new()
.add_attribute("action", "redeem_rewards")
.add_attribute("amount", to_pay.to_string())
.set_data(to_binary(&RedeemRewardsResponse {
amount: to_pay,
address: sender,
})?))
```

> and the other one should be able to destruct it back from_binary

```rust
from_binary::(&response.data.ok_or_else(|| {
StdError::generic_err("Expected response data from RedeemRewards msg")
})?)?,
```

> the problem is that the response.data has additional two bytes prepended 10 and the length
> i sent: Binary([123, 34, 97, 109, 111, 117, 110,...
> but get in response.data this: [10, 83, 123, 34, 97, 109, 111, 117, 110, 116...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.