This repository was archived by the owner on May 20, 2025. It is now read-only.
DO NOT MERGE: Demo new approach to error handling in ibc receive#20
Draft
ethanfrey wants to merge 1 commit into
Draft
DO NOT MERGE: Demo new approach to error handling in ibc receive#20ethanfrey wants to merge 1 commit into
ethanfrey wants to merge 1 commit into
Conversation
ethanfrey
commented
Mar 22, 2023
ethanfrey
left a comment
Contributor
Author
There was a problem hiding this comment.
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 |
Contributor
Author
There was a problem hiding this comment.
Start here reading the general flow we are modelling
| env: Env, | ||
| msg: IbcPacketReceiveMsg, | ||
| ) -> Result<IbcReceiveResponse, ContractError> { | ||
| // Any error in this initial checks should abort the whole IBC transaction |
Contributor
Author
There was a problem hiding this comment.
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 { |
Contributor
Author
There was a problem hiding this comment.
Call self to actually do the logic
| ContractError::OnlySelfCall | ||
| ); | ||
|
|
||
| match packet { |
Contributor
Author
There was a problem hiding this comment.
These lines moved from old ibc_packet_receive
| } | ||
|
|
||
| /// This takes the submessage and encodes the proper ack field | ||
| pub fn reply_process_ibc(_deps: DepsMut, reply: Reply) -> Result<Response, ContractError> { |
Contributor
Author
There was a problem hiding this comment.
And this is where we handle the self-dispatch, both error and success cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is not meant to merge, but as a demo for discussion on CosmWasm/wasmd#1220