Skip to content

Commit

Permalink
Unwrap envelope in echo contract reply
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey authored and maurolacy committed Oct 28, 2021
1 parent 0a4f3f3 commit 87f9b12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/multi-test/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2393,7 +2393,7 @@ mod test {

mod protobuf_wrapped_data {
use super::*;
use cw0::{parse_execute_response_data, parse_instantiate_response_data};
use cw0::parse_instantiate_response_data;

#[test]
fn instantiate_wrapped_properly() {
Expand Down
13 changes: 12 additions & 1 deletion packages/multi-test/src/test_helpers/contracts/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{test_helpers::EmptyMsg, Contract, ContractWrapper};
use schemars::JsonSchema;
use std::fmt::Debug;

use cw0::parse_execute_response_data;
use derivative::Derivative;

#[derive(Debug, Clone, Serialize, Deserialize, Derivative)]
Expand Down Expand Up @@ -97,7 +98,17 @@ where
..
} = msg
{
Ok(Response::new().set_data(data))
// we parse out the WasmMsg::Execute wrapper...
// TODO: this is not fully correct... we need to handle execute, instantiate, and bankmsg differently
// that will require using the Reply id somehow to signal what type
let parsed = parse_execute_response_data(data.as_slice())
.map_err(|e| StdError::generic_err(e.to_string()))?
.data;
if let Some(d) = parsed {
Ok(Response::new().set_data(d))
} else {
Ok(Response::new())
}
} else {
Ok(Response::new())
}
Expand Down

0 comments on commit 87f9b12

Please sign in to comment.