ibchooks

package
v1.19.0-rc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

README

x/ibchooks

Notice

**This module was forked from https://github.com/osmosis-labs/osmosis/tree/main/x/ibchooks **

Unfortunately the original version could not be directly used due to extensive osmosis references, an incompatible Cosmos SDK version, and lack of support for IBC v6.x.

Wasm Hooks

The wasm hook is an IBC middleware which is used to allow ICS-20 token transfers to initiate contract calls. This allows cross-chain contract calls, that involve token movement. This is useful for a variety of usecases. One of primary importance is cross-chain swaps, which is an extremely powerful primitive.

The mechanism enabling this is a memo field on every ICS20 transfer packet as of IBC v3.4.0. Wasm hooks is an IBC middleware that parses an ICS20 transfer, and if the memo field is of a particular form, executes a wasm contract call. We now detail the memo format for wasm contract calls, and the execution guarantees provided.

Cosmwasm Contract Execution Format

Before we dive into the IBC metadata format, we show the cosmwasm execute message format, so the reader has a sense of what are the fields we need to be setting in. The cosmwasm MsgExecuteContract is defined here as the following type:

type MsgExecuteContract struct {
	// Sender is the actor that committed the message in the sender chain
	Sender string
	// Contract is the address of the smart contract
	Contract string
	// Msg json encoded message to be passed to the contract
	Msg RawContractMessage
	// Funds coins that are transferred to the contract on execution
	Funds sdk.Coins
}

So we detail where we want to get each of these fields from:

  • Sender: We cannot trust the sender of an IBC packet, the counterparty chain has full ability to lie about it. We cannot risk this sender being confused for a particular user or module address on Osmosis. So we replace the sender with an account to represent the sender prefixed by the channel and a wasm module prefix. This is done by setting the sender to Bech32(Hash("ibc-wasm-hook-intermediary" || channelID || sender)), where the channelId is the channel id on the local chain.
  • Contract: This field should be directly obtained from the ICS-20 packet metadata
  • Msg: This field should be directly obtained from the ICS-20 packet metadata.
  • Funds: This field is set to the amount of funds being sent over in the ICS 20 packet. One detail is that the denom in the packet is the counterparty chains representation of the denom, so we have to translate it to Osmosis' representation.

WARNING: Due to a bug in the packet forward middleware, we cannot trust the sender from chains that use PFM. Until that is fixed, we recommend chains to not trust the sender on contracts executed via IBC hooks.

So our constructed cosmwasm message that we execute will look like:

msg := MsgExecuteContract{
	// Sender is the that actor that signed the messages
	Sender: "osmo1-hash-of-channel-and-sender",
	// Contract is the address of the smart contract
	Contract: packet.data.memo["wasm"]["ContractAddress"],
	// Msg json encoded message to be passed to the contract
	Msg: packet.data.memo["wasm"]["Msg"],
	// Funds coins that are transferred to the contract on execution
	Funds: sdk.NewCoin{Denom: ibc.ConvertSenderDenomToLocalDenom(packet.data.Denom), Amount: packet.data.Amount}
ICS20 packet structure

So given the details above, we propogate the implied ICS20 packet data structure. ICS20 is JSON native, so we use JSON for the memo format.

{
    //... other ibc fields that we don't care about
    "data":{
    	"denom": "denom on counterparty chain (e.g. uatom)",  // will be transformed to the local denom (ibc/...)
        "amount": "1000",
        "sender": "addr on counterparty chain", // will be transformed
        "receiver": "contract addr or blank",
    	"memo": {
           "wasm": {
              "contract": "osmo1contractAddr",
              "msg": {
                "raw_message_fields": "raw_message_data",
              }
            }
        }
    }
}

An ICS20 packet is formatted correctly for wasmhooks iff the following all hold:

  • memo is not blank
  • memo is valid JSON
  • memo has at least one key, with value "wasm"
  • memo["wasm"] has exactly two entries, "contract" and "msg"
  • memo["wasm"]["msg"] is a valid JSON object
  • receiver == "" || receiver == memo["wasm"]["contract"]

We consider an ICS20 packet as directed towards wasmhooks iff all of the following hold:

  • memo is not blank
  • memo is valid JSON
  • memo has at least one key, with name "wasm"

If an ICS20 packet is not directed towards wasmhooks, wasmhooks doesn't do anything. If an ICS20 packet is directed towards wasmhooks, and is formated incorrectly, then wasmhooks returns an error.

Execution flow

Pre wasm hooks:

  • Ensure the incoming IBC packet is cryptogaphically valid
  • Ensure the incoming IBC packet is not timed out.

In Wasm hooks, pre packet execution:

  • Ensure the packet is correctly formatted (as defined above)
  • Edit the receiver to be the hardcoded IBC module account

In wasm hooks, post packet execution:

  • Construct wasm message as defined before
  • Execute wasm message
  • if wasm message has error, return ErrAck
  • otherwise continue through middleware

Ack callbacks

A contract that sends an IBC transfer, may need to listen for the ACK from that packet. To allow contracts to listen on the ack of specific packets, we provide Ack callbacks.

Design

The sender of an IBC transfer packet may specify a callback for when the ack of that packet is received in the memo field of the transfer packet.

Crucially, only the IBC packet sender can set the callback.

Use case

The crosschain swaps implementation sends an IBC transfer. If the transfer were to fail, we want to allow the sender to be able to retrieve their funds (which would otherwise be stuck in the contract). To do this, we allow users to retrieve the funds after the timeout has passed, but without the ack information, we cannot guarantee that the send hasn't failed (i.e.: returned an error ack notifying that the receiving change didn't accept it)

Implementation
Callback information in memo

For the callback to be processed, the transfer packet's memo should contain the following in its JSON:

{"ibc_callback": "osmo1contractAddr"}

The wasm hooks will keep the mapping from the packet's channel and sequence to the contract in storage. When an ack is received, it will notify the specified contract via a sudo message.

Interface for receiving the Acks and Timeouts

The contract that awaits the callback should implement the following interface for a sudo message:

#[cw_serde]
pub enum IBCLifecycleComplete {
    #[serde(rename = "ibc_ack")]
    IBCAck {
        /// The source channel (osmosis side) of the IBC packet
        channel: String,
        /// The sequence number that the packet was sent with
        sequence: u64,
        /// String encoded version of the ack as seen by OnAcknowledgementPacket(..)
        ack: String,
        /// Weather an ack is a success of failure according to the transfer spec
        success: bool,
    },
    #[serde(rename = "ibc_timeout")]
    IBCTimeout {
        /// The source channel (osmosis side) of the IBC packet
        channel: String,
        /// The sequence number that the packet was sent with
        sequence: u64,
    },
}

/// Message type for `sudo` entry_point
#[cw_serde]
pub enum SudoMsg {
    #[serde(rename = "ibc_lifecycle_complete")]
    IBCLifecycleComplete(IBCLifecycleComplete),
}
Async Acks

IBC supports the ability to send an ack back to the sender of the packet asynchronously. This is useful for cases where the packet is received, but the ack is not immediately known. For example, if the packet is being forwarded to another chain, the ack may not be known until the packet is received on the other chain.

Note this ACK does not imply full revertability. It is possible that unrevertable actions have occurred even if there is an Ack Error. (This is distinct from the behavior of ICS-20 transfers). If you want to ensure revertability, your contract should be implemented in a way that actions are not finalized until a success ack is received.

Use case

Async acks are useful in cases where the contract needs to wait for a response from another chain before returning a result to the caller.

For example, if you want to send tokens to another chain after the contract is executed you need to add a new ibc packet and wait for its ack.

In the synchronous acks case, the caller will receive an ack from the contract before the second packet has been processed. This means that the caller will have to wait (and potentially track) if the second packet has been processed successfully or not.

With async acks, you contract can take this responsibility and only send an ack to the caller once the second packet has been processed

Making contract Acks async

To support this, we allow contracts to return an IBCAsync response from the function being executed when the packet is received. That response specifies that the ack should be handled asynchronously.

Concretely the contract should return:

#[cw_serde]
pub struct OnRecvPacketAsyncResponse {
    pub is_async_ack: bool,
}

if is_async_ack is set to true, OnRecvPacket will return nil and the ack will not be written. Instead, the contract wil be stored as the "ack actor" for the packet so that only that contract is allowed to send an ack for it.

It is up to the contract developers to decide which conditions will trigger the ack to be sent.

Sending an async ack

To send the async ack, the contract needs to send the MsgEmitIBCAck message to the chain. This message will then make a sudo call to the contract requesting the ack and write the ack to state.

That message can be specified in the contract as:

#[derive(
    Clone,
    PartialEq,
    Eq,
    ::prost::Message,
    serde::Serialize,
    serde::Deserialize,
    schemars::JsonSchema,
    CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.ibchooks.MsgEmitIBCAck")]
pub struct MsgEmitIBCAck {
    #[prost(string, tag = "1")]
    pub sender: ::prost::alloc::string::String,
    #[prost(uint64, tag = "2")]
    pub packet_sequence: u64,
    #[prost(string, tag = "3")]
    pub channel: ::prost::alloc::string::String,
}

The contract is expected to implement the following sudo message handler:

#[cw_serde]
pub enum IBCAsyncOptions {
    #[serde(rename = "request_ack")]
    RequestAck {
        /// The source channel (osmosis side) of the IBC packet
        source_channel: String,
        /// The sequence number that the packet was sent with
        packet_sequence: u64,
    },
}

#[cw_serde]
pub enum SudoMsg {
    #[serde(rename = "ibc_async")]
    IBCAsync(IBCAsyncOptions),
}

and that sudo call should return an IBCAckResponse:

#[cw_serde]
#[serde(tag = "type", content = "content")]
pub enum IBCAck {
    AckResponse{
        packet: Packet,
        contract_ack: ContractAck,
    },
    AckError {
        packet: Packet,
        error_description: String,
        error_response: String,
    }
}

Note: the sudo call is required to potentially allow anyone to send the MsgEmitIBCAck message. For now, however, this is artificially limited so that the message can only be send by the same contract. This could be expanded in the future if needed.

Testing strategy

See go tests.`

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMarkerMemo

func CreateMarkerMemo(marker markertypes.MarkerAccountI) (interface{}, error)

CreateMarkerMemo returns a json memo for marker

func IsJSONAckError

func IsJSONAckError(acknowledgement []byte) bool

IsJSONAckError checks an IBC acknowledgement to see if it's an error. This is a replacement for ack.Success() which is currently not working on some circumstances

func MustExtractDenomFromPacketOnRecv

func MustExtractDenomFromPacketOnRecv(packet ibcexported.PacketI) string

MustExtractDenomFromPacketOnRecv takes a packet with a valid ICS20 token data in the Data field and returns the denom as represented in the local chain. If the data cannot be unmarshalled this function will panic

func NewEmitErrorAcknowledgement

func NewEmitErrorAcknowledgement(ctx sdktypes.Context, err error, errorContexts ...string) channeltypes.Acknowledgement

NewEmitErrorAcknowledgement creates a new error acknowledgement after having emitted an event with the details of the error.

func ProcessMarkerMemo

func ProcessMarkerMemo(memo string) ([]sdktypes.AccAddress, markertypes.MarkerType, bool, error)

ProcessMarkerMemo extracts the list of transfer auth address from marker part of packet memo

func ResetMarkerAccessGrants

func ResetMarkerAccessGrants(transferAuths []sdktypes.AccAddress, marker markertypes.MarkerAccountI) error

ResetMarkerAccessGrants removes all current access grants from marker and adds new transfer grants for transferAuths

func SanitizeMemo

func SanitizeMemo(memo string) map[string]interface{}

SanitizeMemo returns a keyed json object for memo

func ValidateAndParseMemo

func ValidateAndParseMemo(memo string, receiver string) (isWasmRouted bool, contractAddr sdktypes.AccAddress, msgBytes []byte, err error)

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements an application module for the ibchooks module.

func NewAppModule

func NewAppModule(ak authkeeper.AccountKeeper, keeper keeper.Keeper) AppModule

NewAppModule creates a new AppModule object.

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements AppModule/ConsensusVersion.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

func (AppModule) GenerateGenesisState

func (AppModule) GenerateGenesisState(simState *module.SimulationState)

GenerateGenesisState creates a randomized GenState of the name module.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs genesis initialization for the ibchooks module. It returns no validator updates.

func (AppModule) IsAppModule added in v1.19.0

func (AppModule) IsAppModule()

IsAppModule is a dummy function that satisfies the AppModule interface.

func (AppModule) IsOnePerModuleType added in v1.19.0

func (AppModule) IsOnePerModuleType()

IsOnePerModuleType is a dummy function that satisfies the OnePerModuleType interface (needed by AppModule).

func (AppModule) Name

func (AppModule) Name() string

Name returns the ibchooks module's name.

func (AppModule) RandomizedParams

func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange

RandomizedParams creates randomized name param changes for the simulator.

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry)

RegisterInvariants registers the ibchooks module invariants.

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(cfg module.Configurator)

RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries.

func (AppModule) RegisterStoreDecoder

func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder for name module's types

func (AppModule) WeightedOperations

func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation

WeightedOperations returns the all the gov module operations with their respective weights.

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic defines the basic application module used by the ibchooks module.

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

DefaultGenesis returns default genesis state as raw bytes for the module.

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd() *cobra.Command

GetQueryCmd returns the root query command for the ibchooks module.

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd() *cobra.Command

GetTxCmd returns no root tx command for the ibchooks module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the ibchooks module's name.

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibchooks module.

func (AppModuleBasic) RegisterInterfaces

func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry)

RegisterInterfaces registers the module's interface types

func (AppModuleBasic) RegisterLegacyAminoCodec

func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the ibchooks module's types on the given LegacyAmino codec.

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router)

RegisterRESTRoutes registers the REST routes for the ibchooks module.

func (AppModuleBasic) ValidateGenesis

ValidateGenesis performs genesis state validation for the ibchooks module.

type GetAppVersionAfterHooks

type GetAppVersionAfterHooks interface {
	GetAppVersionAfterHook(ctx sdk.Context, portID, channelID string, result string, success bool)
}

type GetAppVersionBeforeHooks

type GetAppVersionBeforeHooks interface {
	GetAppVersionBeforeHook(ctx sdk.Context, portID, channelID string)
}

type GetAppVersionOverrideHooks

type GetAppVersionOverrideHooks interface {
	GetAppVersionOverride(i ICS4Middleware, ctx sdk.Context, portID, channelID string) (string, bool)
}

GetAppVersion Hooks

type Hooks

type Hooks interface{}

type IBCMiddleware

type IBCMiddleware struct {
	App            porttypes.IBCModule
	ICS4Middleware *ICS4Middleware
}

func NewIBCMiddleware

func NewIBCMiddleware(app porttypes.IBCModule, ics4 *ICS4Middleware) IBCMiddleware

func (IBCMiddleware) GetAppVersion

func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool)

func (IBCMiddleware) OnAcknowledgementPacket

func (im IBCMiddleware) OnAcknowledgementPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	acknowledgement []byte,
	relayer sdk.AccAddress,
) error

OnAcknowledgementPacket implements the IBCMiddleware interface

func (IBCMiddleware) OnChanCloseConfirm

func (im IBCMiddleware) OnChanCloseConfirm(
	ctx sdk.Context,
	portID,
	channelID string,
) error

OnChanCloseConfirm implements the IBCMiddleware interface

func (IBCMiddleware) OnChanCloseInit

func (im IBCMiddleware) OnChanCloseInit(
	ctx sdk.Context,
	portID,
	channelID string,
) error

OnChanCloseInit implements the IBCMiddleware interface

func (IBCMiddleware) OnChanOpenAck

func (im IBCMiddleware) OnChanOpenAck(
	ctx sdk.Context,
	portID,
	channelID string,
	counterpartyChannelID string,
	counterpartyVersion string,
) error

OnChanOpenAck implements the IBCMiddleware interface

func (IBCMiddleware) OnChanOpenConfirm

func (im IBCMiddleware) OnChanOpenConfirm(
	ctx sdk.Context,
	portID,
	channelID string,
) error

OnChanOpenConfirm implements the IBCMiddleware interface

func (IBCMiddleware) OnChanOpenInit

func (im IBCMiddleware) OnChanOpenInit(
	ctx sdk.Context,
	order channeltypes.Order,
	connectionHops []string,
	portID string,
	channelID string,
	channelCap *capabilitytypes.Capability,
	counterparty channeltypes.Counterparty,
	version string,
) (string, error)

OnChanOpenInit implements the IBCMiddleware interface

func (IBCMiddleware) OnChanOpenTry

func (im IBCMiddleware) OnChanOpenTry(
	ctx sdk.Context,
	order channeltypes.Order,
	connectionHops []string,
	portID,
	channelID string,
	channelCap *capabilitytypes.Capability,
	counterparty channeltypes.Counterparty,
	counterpartyVersion string,
) (string, error)

OnChanOpenTry implements the IBCMiddleware interface

func (IBCMiddleware) OnRecvPacket

func (im IBCMiddleware) OnRecvPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	relayer sdk.AccAddress,
) ibcexported.Acknowledgement

OnRecvPacket implements the IBCMiddleware interface

func (IBCMiddleware) OnTimeoutPacket

func (im IBCMiddleware) OnTimeoutPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	relayer sdk.AccAddress,
) error

OnTimeoutPacket implements the IBCMiddleware interface

func (IBCMiddleware) SendPacket

func (im IBCMiddleware) SendPacket(
	ctx sdk.Context,
	chanCap *capabilitytypes.Capability,
	sourcePort string,
	sourceChannel string,
	timeoutHeight clienttypes.Height,
	timeoutTimestamp uint64,
	data []byte,
) (sequence uint64, err error)

SendPacket implements the ICS4 Wrapper interface

func (IBCMiddleware) WriteAcknowledgement

func (im IBCMiddleware) WriteAcknowledgement(
	ctx sdk.Context,
	chanCap *capabilitytypes.Capability,
	packet ibcexported.PacketI,
	ack ibcexported.Acknowledgement,
) error

WriteAcknowledgement implements the ICS4 Wrapper interface

type ICS4Middleware

type ICS4Middleware struct {

	// Hooks
	Hooks Hooks
	// contains filtered or unexported fields
}

func NewICS4Middleware

func NewICS4Middleware(channel porttypes.ICS4Wrapper, hooks Hooks) ICS4Middleware

func (ICS4Middleware) GetAppVersion

func (i ICS4Middleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool)

func (ICS4Middleware) SendPacket

func (i ICS4Middleware) SendPacket(
	ctx sdk.Context,
	chanCap *capabilitytypes.Capability,
	sourcePort string,
	sourceChannel string,
	timeoutHeight clienttypes.Height,
	timeoutTimestamp uint64,
	data []byte,
) (sequence uint64, err error)

func (ICS4Middleware) WriteAcknowledgement

func (i ICS4Middleware) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) error

type IbcHooks

type IbcHooks struct {
	SendPacketPreProcessors []types.PreSendPacketDataProcessingFn
	// contains filtered or unexported fields
}

func NewIbcHooks

func NewIbcHooks(cdc codec.BinaryCodec, ibcHooksKeeper *keeper.Keeper, ibcKeeper *ibckeeper.Keeper, wasmHooks *WasmHooks, markerHooks *MarkerHooks, preSendPacketDataProcessingFns []types.PreSendPacketDataProcessingFn) IbcHooks

func (IbcHooks) GetSendPacketPreProcessors

func (h IbcHooks) GetSendPacketPreProcessors() []types.PreSendPacketDataProcessingFn

GetSendPacketPreProcessors returns a list of ordered functions to be executed before ibc's SendPacket function in middleware

func (IbcHooks) OnAcknowledgementPacketOverride

func (h IbcHooks) OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdktypes.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdktypes.AccAddress) error

OnAcknowledgementPacketOverride returns impl of wasm OnAcknowledgementPacketOverride

func (IbcHooks) OnRecvPacketOverride

func (h IbcHooks) OnRecvPacketOverride(im IBCMiddleware, ctx sdktypes.Context, packet channeltypes.Packet, relayer sdktypes.AccAddress) ibcexported.Acknowledgement

OnRecvPacketOverride executes wasm or marker hooks for Ics20 packets, if not ics20 packet it will continue to process packet with no override

func (IbcHooks) OnTimeoutPacketOverride

func (h IbcHooks) OnTimeoutPacketOverride(im IBCMiddleware, ctx sdktypes.Context, packet channeltypes.Packet, relayer sdktypes.AccAddress) error

OnTimeoutPacketOverride returns impl of wasm hook for OnTimeoutPacketOverride

func (IbcHooks) ProperlyConfigured

func (h IbcHooks) ProperlyConfigured() bool

ProperlyConfigured returns false if either wasm or marker hooks are configured incorrectly

func (IbcHooks) SendPacketAfterHook

func (h IbcHooks) SendPacketAfterHook(ctx sdktypes.Context,
	chanCap *capabilitytypes.Capability,
	sourcePort string,
	sourceChannel string,
	timeoutHeight clienttypes.Height,
	timeoutTimestamp uint64,
	data []byte,
	sequence uint64,
	err error,
	processData map[string]interface{},
)

SendPacketAfterHook function is executed after ibc's SendPacket Note: processData is a JSON object of state data from the PreSendPacketDataProcessingFns

type MarkerHooks

type MarkerHooks struct {
	MarkerKeeper *markerkeeper.Keeper
}

func NewMarkerHooks

func NewMarkerHooks(markerkeeper *markerkeeper.Keeper) MarkerHooks

func (MarkerHooks) AddUpdateMarker

func (h MarkerHooks) AddUpdateMarker(ctx sdktypes.Context, packet exported.PacketI, ibcKeeper *ibckeeper.Keeper) error

AddUpdateMarker will add or update ibc Marker with transfer authorities

func (MarkerHooks) GetChainID

func (h MarkerHooks) GetChainID(ctx sdktypes.Context, ibcPort, ibcChannel string, ibcKeeper *ibckeeper.Keeper) string

GetChainID returns the source chain id from packet for a `07-tendermint` client connection or returns `unknown`

func (MarkerHooks) ProperlyConfigured

func (h MarkerHooks) ProperlyConfigured() bool

ProperlyConfigured returns false when marker hooks are configured incorrectly

func (MarkerHooks) SetupMarkerMemoFn

func (h MarkerHooks) SetupMarkerMemoFn(
	ctx sdktypes.Context,
	data []byte,
	_ map[string]interface{},
) ([]byte, error)

SetupMarkerMemoFn processes a ics20 packets memo part to have `marker` setup information for receiving chain

type OnAcknowledgementPacketAfterHooks

type OnAcknowledgementPacketAfterHooks interface {
	OnAcknowledgementPacketAfterHook(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, err error)
}

type OnAcknowledgementPacketBeforeHooks

type OnAcknowledgementPacketBeforeHooks interface {
	OnAcknowledgementPacketBeforeHook(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress)
}

type OnAcknowledgementPacketOverrideHooks

type OnAcknowledgementPacketOverrideHooks interface {
	OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error
}

OnAcknowledgementPacket Hooks

type OnChanCloseConfirmAfterHooks

type OnChanCloseConfirmAfterHooks interface {
	OnChanCloseConfirmAfterHook(ctx sdk.Context, portID, channelID string, err error)
}

type OnChanCloseConfirmBeforeHooks

type OnChanCloseConfirmBeforeHooks interface {
	OnChanCloseConfirmBeforeHook(ctx sdk.Context, portID, channelID string)
}

type OnChanCloseConfirmOverrideHooks

type OnChanCloseConfirmOverrideHooks interface {
	OnChanCloseConfirmOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string) error
}

OnChanCloseConfirm Hooks

type OnChanCloseInitAfterHooks

type OnChanCloseInitAfterHooks interface {
	OnChanCloseInitAfterHook(ctx sdk.Context, portID, channelID string, err error)
}

type OnChanCloseInitBeforeHooks

type OnChanCloseInitBeforeHooks interface {
	OnChanCloseInitBeforeHook(ctx sdk.Context, portID, channelID string)
}

type OnChanCloseInitOverrideHooks

type OnChanCloseInitOverrideHooks interface {
	OnChanCloseInitOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string) error
}

OnChanCloseInit Hooks

type OnChanOpenAckAfterHooks

type OnChanOpenAckAfterHooks interface {
	OnChanOpenAckAfterHook(ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string, err error)
}

type OnChanOpenAckBeforeHooks

type OnChanOpenAckBeforeHooks interface {
	OnChanOpenAckBeforeHook(ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string)
}

type OnChanOpenAckOverrideHooks

type OnChanOpenAckOverrideHooks interface {
	OnChanOpenAckOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string) error
}

OnChanOpenAck Hooks

type OnChanOpenConfirmAfterHooks

type OnChanOpenConfirmAfterHooks interface {
	OnChanOpenConfirmAfterHook(ctx sdk.Context, portID, channelID string, err error)
}

type OnChanOpenConfirmBeforeHooks

type OnChanOpenConfirmBeforeHooks interface {
	OnChanOpenConfirmBeforeHook(ctx sdk.Context, portID, channelID string)
}

type OnChanOpenConfirmOverrideHooks

type OnChanOpenConfirmOverrideHooks interface {
	OnChanOpenConfirmOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string) error
}

OnChanOpenConfirm Hooks

type OnChanOpenInitAfterHooks

type OnChanOpenInitAfterHooks interface {
	OnChanOpenInitAfterHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string, finalVersion string, err error)
}

type OnChanOpenInitBeforeHooks

type OnChanOpenInitBeforeHooks interface {
	OnChanOpenInitBeforeHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string)
}

type OnChanOpenInitOverrideHooks

type OnChanOpenInitOverrideHooks interface {
	OnChanOpenInitOverride(im IBCMiddleware, ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) (string, error)
}

type OnChanOpenTryAfterHooks

type OnChanOpenTryAfterHooks interface {
	OnChanOpenTryAfterHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string, version string, err error)
}

type OnChanOpenTryBeforeHooks

type OnChanOpenTryBeforeHooks interface {
	OnChanOpenTryBeforeHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string)
}

type OnChanOpenTryOverrideHooks

type OnChanOpenTryOverrideHooks interface {
	OnChanOpenTryOverride(im IBCMiddleware, ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string) (string, error)
}

OnChanOpenTry Hooks

type OnRecvPacketAfterHooks

type OnRecvPacketAfterHooks interface {
	OnRecvPacketAfterHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ack ibcexported.Acknowledgement)
}

type OnRecvPacketBeforeHooks

type OnRecvPacketBeforeHooks interface {
	OnRecvPacketBeforeHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress)
}

type OnRecvPacketOverrideHooks

type OnRecvPacketOverrideHooks interface {
	OnRecvPacketOverride(im IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) ibcexported.Acknowledgement
}

OnRecvPacket Hooks

type OnTimeoutPacketAfterHooks

type OnTimeoutPacketAfterHooks interface {
	OnTimeoutPacketAfterHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, err error)
}

type OnTimeoutPacketBeforeHooks

type OnTimeoutPacketBeforeHooks interface {
	OnTimeoutPacketBeforeHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress)
}

type OnTimeoutPacketOverrideHooks

type OnTimeoutPacketOverrideHooks interface {
	OnTimeoutPacketOverride(im IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error
}

OnTimeoutPacket Hooks

type SendPacketAfterHooks

type SendPacketAfterHooks interface {
	SendPacketAfterHook(ctx sdk.Context,
		chanCap *capabilitytypes.Capability,
		sourcePort string,
		sourceChannel string,
		timeoutHeight clienttypes.Height,
		timeoutTimestamp uint64,
		data []byte,
		sequence uint64,
		err error,
		processData map[string]interface{},
	)
}

type SendPacketBeforeHooks

type SendPacketBeforeHooks interface {
	SendPacketBeforeHook(ctx sdk.Context,
		chanCap *capabilitytypes.Capability,
		sourcePort string,
		sourceChannel string,
		timeoutHeight clienttypes.Height,
		timeoutTimestamp uint64,
		data []byte,
	)
}

type SendPacketOverrideHooks

type SendPacketOverrideHooks interface {
	SendPacketOverride(
		i ICS4Middleware,
		ctx sdk.Context,
		chanCap *capabilitytypes.Capability,
		sourcePort string,
		sourceChannel string,
		timeoutHeight clienttypes.Height,
		timeoutTimestamp uint64,
		data []byte,
	) (sequence uint64, err error)
}

SendPacket Hooks

type SendPacketPreProcessors

type SendPacketPreProcessors interface {
	GetSendPacketPreProcessors() []types.PreSendPacketDataProcessingFn
}

SendPacketPreProcessors returns a list of ordered functions to be executed before ibc's SendPacket function in middleware

type WasmHooks

type WasmHooks struct {
	ContractKeeper *wasmkeeper.Keeper
	// contains filtered or unexported fields
}

func NewWasmHooks

func NewWasmHooks(ibcHooksKeeper *keeper.Keeper, contractKeeper *wasmkeeper.Keeper, bech32PrefixAccAddr string) WasmHooks

func (WasmHooks) GetWasmSendPacketPreProcessor

func (h WasmHooks) GetWasmSendPacketPreProcessor(
	_ sdktypes.Context,
	data []byte,
	processData map[string]interface{},
) ([]byte, error)

func (WasmHooks) OnAcknowledgementPacketOverride

func (h WasmHooks) OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdktypes.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdktypes.AccAddress) error

func (WasmHooks) OnRecvPacketOverride

func (h WasmHooks) OnRecvPacketOverride(im IBCMiddleware, ctx sdktypes.Context, packet channeltypes.Packet, relayer sdktypes.AccAddress) ibcexported.Acknowledgement

func (WasmHooks) OnTimeoutPacketOverride

func (h WasmHooks) OnTimeoutPacketOverride(im IBCMiddleware, ctx sdktypes.Context, packet channeltypes.Packet, relayer sdktypes.AccAddress) error

func (WasmHooks) ProperlyConfigured

func (h WasmHooks) ProperlyConfigured() bool

ProperlyConfigured returns false when wasm hooks are configured incorrectly

func (WasmHooks) SendPacketAfterHook

func (h WasmHooks) SendPacketAfterHook(ctx sdktypes.Context,
	_ *capabilitytypes.Capability,
	_ string,
	sourceChannel string,
	_ clienttypes.Height,
	_ uint64,
	_ []byte,
	sequence uint64,
	err error,
	processData map[string]interface{},
)

func (WasmHooks) SendPacketOverride

func (h WasmHooks) SendPacketOverride(
	i ICS4Middleware,
	ctx sdktypes.Context,
	chanCap *capabilitytypes.Capability,
	sourcePort string,
	sourceChannel string,
	timeoutHeight clienttypes.Height,
	timeoutTimestamp uint64,
	data []byte,
) (uint64, error)

type WriteAcknowledgementAfterHooks

type WriteAcknowledgementAfterHooks interface {
	WriteAcknowledgementAfterHook(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, err error)
}

type WriteAcknowledgementBeforeHooks

type WriteAcknowledgementBeforeHooks interface {
	WriteAcknowledgementBeforeHook(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement)
}

type WriteAcknowledgementOverrideHooks

type WriteAcknowledgementOverrideHooks interface {
	WriteAcknowledgementOverride(i ICS4Middleware, ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) error
}

WriteAcknowledgement Hooks

Directories

Path Synopsis
client
cli
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL