-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DO NOT MERGE: Demo new approach to error handling in ibc receive #20
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few annotations to understand the approach
/// we look for a the proper reflect contract to relay to and send the message | ||
/// We cannot return any meaningful response value as we do not know the response value | ||
/// of execution. We just return ok if we dispatched, error if we failed to dispatch | ||
/// This is a demo of a new way to handle both error ack and abort in a CosmWasm contract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start here reading the general flow we are modelling
msg: IbcPacketReceiveMsg, | ||
) -> Result<IbcReceiveResponse, ContractError> { | ||
// Any error in this initial checks should abort the whole IBC transaction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do inline only actions that can abort the tx (don't capture in x/wasm)
let sub = SubMsg::reply_always( | ||
WasmMsg::Execute { | ||
contract_addr: env.contract.address.into_string(), | ||
msg: to_binary(&ExecuteMsg::ProcessIbc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call self to actually do the logic
ContractError::OnlySelfCall | ||
); | ||
|
||
match packet { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines moved from old ibc_packet_receive
@@ -199,20 +216,79 @@ pub fn reply_init_callback(deps: DepsMut, reply: Reply) -> Result<Response, Cont | |||
Ok(Response::new()) | |||
} | |||
|
|||
/// This takes the submessage and encodes the proper ack field | |||
pub fn reply_process_ibc(_deps: DepsMut, reply: Reply) -> Result<Response, ContractError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is where we handle the self-dispatch, both error and success cases.
This is not meant to merge, but as a demo for discussion on CosmWasm/wasmd#1220