Skip to content

Commit

Permalink
data in reflect response
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Feb 8, 2024
1 parent 95f6788 commit e5dbcfd
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions contracts/reflect/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::query::{ChainResponse, InterchainQueries, QueryMsg};
use cosmwasm_std::{
entry_point, to_json_binary, to_json_vec, Binary, ContractResult, CosmosMsg, Deps, DepsMut,
Env, MessageInfo, QueryRequest, Response, StdError, StdResult, SystemResult,
Env, MessageInfo, QueryRequest, Reply, Response, StdError, StdResult, SubMsg, SystemResult,
};
use cw2::set_contract_version;
use neutron_sdk::bindings::msg::NeutronMsg;
Expand All @@ -12,6 +12,8 @@ use serde::{Deserialize, Serialize};
pub struct InstantiateMsg {}
use neutron_sdk::sudo::msg::SudoMsg;

const REFLECT_REPLY_ID: u64 = 0;

const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME"));
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

Expand Down Expand Up @@ -50,7 +52,13 @@ pub fn execute(
ExecuteMsg::Send { .. } => {
unimplemented!()
}
ExecuteMsg::ReflectMsg { msgs } => Ok(Response::default().add_messages(msgs)),
ExecuteMsg::ReflectMsg { msgs } => {
let submsgs = msgs
.into_iter()
.map(|m| SubMsg::reply_on_success(m, REFLECT_REPLY_ID));

Ok(Response::default().add_submessages(submsgs))
}
}
}

Expand All @@ -61,6 +69,18 @@ pub fn query(deps: Deps<InterchainQueries>, env: Env, msg: QueryMsg) -> StdResul
}
}

#[entry_point]
pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> StdResult<Response> {
match msg.id {
REFLECT_REPLY_ID => {
Ok(Response::default().set_data(msg.result.unwrap().data.unwrap_or_default()))
}
_ => {
unimplemented!()
}
}
}

fn query_with_payload(
deps: Deps<InterchainQueries>,
_env: Env,
Expand Down

0 comments on commit e5dbcfd

Please sign in to comment.