Skip to content

Commit

Permalink
Merge branch 'feature/proposal_msg_forwarding' into fork/v2.5.0-callb…
Browse files Browse the repository at this point in the history
…acks
  • Loading branch information
ismellike committed Sep 9, 2024
2 parents e1b675a + 8e38fd1 commit 4e8088f
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions contracts/dao-dao-core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const PROPOSAL_MODULE_INSTANTIATE_REPLY_ID: u64 = 0;
const VOTE_MODULE_INSTANTIATE_REPLY_ID: u64 = 1;
const VOTE_MODULE_UPDATE_REPLY_ID: u64 = 2;
const PROPOSAL_MODULE_EXECUTE_REPLY_ID: u64 = 3;
const CALLBACK_MESSAGES_ERROR_REPLY_ID: u64 = 4;

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
Expand Down Expand Up @@ -1005,16 +1004,13 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE
let callback_msgs = match res.data {
Some(data) => from_json::<CallbackMessages>(&data)
.map(|m| m.msgs)
.unwrap_or_else(|_| vec![])
.into_iter()
.map(|msg| SubMsg::reply_on_error(msg, CALLBACK_MESSAGES_ERROR_REPLY_ID))
.collect(),
.unwrap_or_else(|_| vec![]),
None => vec![],
};

Ok(Response::default()
.add_attribute("voting_module", vote_module_addr)
.add_submessages(callback_msgs))
.add_messages(callback_msgs))
}
VOTE_MODULE_UPDATE_REPLY_ID => {
let res = parse_reply_instantiate_data(msg)?;
Expand All @@ -1029,23 +1025,14 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE
let callback_msgs = match res.data {
Some(data) => from_json::<CallbackMessages>(&data)
.map(|m| m.msgs)
.unwrap_or_else(|_| vec![])
.into_iter()
.map(|msg| SubMsg::reply_on_error(msg, CALLBACK_MESSAGES_ERROR_REPLY_ID))
.collect(),
.unwrap_or_else(|_| vec![]),
None => vec![],
};

Ok(Response::default().add_submessages(callback_msgs))
Ok(Response::default().add_messages(callback_msgs))
}
Err(_) => Ok(Response::default()),
},
CALLBACK_MESSAGES_ERROR_REPLY_ID => Ok(Response::default()
.add_attribute("callback_message_failed", msg.id.to_string())
.add_attribute(
"error",
msg.result.into_result().err().unwrap_or("None".to_string()),
)),
_ => Err(ContractError::UnknownReplyID {}),
}
}
Expand Down

0 comments on commit 4e8088f

Please sign in to comment.