Skip to content

Commit

Permalink
Add error to FailedProposalExecution response
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ismellike committed Sep 13, 2023
1 parent bf3ef9c commit a43b46d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion contracts/proposal/dao-proposal-condorcet/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE
let mut proposal = PROPOSAL.load(deps.storage, proposal_id as u32)?;
proposal.set_execution_failed();
PROPOSAL.save(deps.storage, proposal_id as u32, &proposal)?;

Ok(Response::default()
.add_attribute("proposal_execution_failed", proposal_id.to_string()))
.add_attribute("proposal_execution_failed", proposal_id.to_string())
.add_attribute("error", msg.result.unwrap_err()))
}
_ => unimplemented!("pre-propose and hooks not yet supported"),
}
Expand Down
5 changes: 4 additions & 1 deletion contracts/proposal/dao-proposal-multiple/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE
}
None => 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)?;
Expand Down
4 changes: 3 additions & 1 deletion contracts/proposal/dao-proposal-single/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,9 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE
None => 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)?;
Expand Down

0 comments on commit a43b46d

Please sign in to comment.