Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Conversation

@ethanfrey
Copy link
Contributor

This is not meant to merge, but as a demo for discussion on CosmWasm/wasmd#1220

Copy link
Contributor Author

@ethanfrey ethanfrey left a 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
Copy link
Contributor Author

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

env: Env,
msg: IbcPacketReceiveMsg,
) -> Result<IbcReceiveResponse, ContractError> {
// Any error in this initial checks should abort the whole IBC transaction
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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

}

/// This takes the submessage and encodes the proper ack field
pub fn reply_process_ibc(_deps: DepsMut, reply: Reply) -> Result<Response, ContractError> {
Copy link
Contributor Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants