From a43b46d31ae2ecd33d55e81256bf6e0da9934cf1 Mon Sep 17 00:00:00 2001 From: Gabriel Lopez Date: Wed, 13 Sep 2023 15:43:46 -0500 Subject: [PATCH] Add error to FailedProposalExecution response Minimal information is shown when a proposal execution fails, and this could give users a better clue of what went wrong. It should probably be used in all reply_on_error handles. --- contracts/proposal/dao-proposal-condorcet/src/contract.rs | 4 +++- contracts/proposal/dao-proposal-multiple/src/contract.rs | 5 ++++- contracts/proposal/dao-proposal-single/src/contract.rs | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/contracts/proposal/dao-proposal-condorcet/src/contract.rs b/contracts/proposal/dao-proposal-condorcet/src/contract.rs index b436b76e4..b741bd1d7 100644 --- a/contracts/proposal/dao-proposal-condorcet/src/contract.rs +++ b/contracts/proposal/dao-proposal-condorcet/src/contract.rs @@ -271,8 +271,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result unimplemented!("pre-propose and hooks not yet supported"), } diff --git a/contracts/proposal/dao-proposal-multiple/src/contract.rs b/contracts/proposal/dao-proposal-multiple/src/contract.rs index 35465ab50..a9cf7b8b7 100644 --- a/contracts/proposal/dao-proposal-multiple/src/contract.rs +++ b/contracts/proposal/dao-proposal-multiple/src/contract.rs @@ -878,7 +878,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result Err(ContractError::NoSuchProposal { id: proposal_id }), })?; - Ok(Response::new().add_attribute("proposal execution failed", proposal_id.to_string())) + + Ok(Response::new() + .add_attribute("proposal execution failed", proposal_id.to_string()) + .add_attribute("error", msg.result.unwrap_err())) } TaggedReplyId::FailedProposalHook(idx) => { let addr = PROPOSAL_HOOKS.remove_hook_by_index(deps.storage, idx)?; diff --git a/contracts/proposal/dao-proposal-single/src/contract.rs b/contracts/proposal/dao-proposal-single/src/contract.rs index 5f30030f5..eb85dd9ba 100644 --- a/contracts/proposal/dao-proposal-single/src/contract.rs +++ b/contracts/proposal/dao-proposal-single/src/contract.rs @@ -957,7 +957,9 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result Err(ContractError::NoSuchProposal { id: proposal_id }), })?; - Ok(Response::new().add_attribute("proposal_execution_failed", proposal_id.to_string())) + Ok(Response::new() + .add_attribute("proposal_execution_failed", proposal_id.to_string()) + .add_attribute("error", msg.result.unwrap_err())) } TaggedReplyId::FailedProposalHook(idx) => { let addr = PROPOSAL_HOOKS.remove_hook_by_index(deps.storage, idx)?;