types

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModuleName defines the module name
	ModuleName = "ibc-callbacks"
)

Variables

View Source
var (
	ErrInvalidReceiverAddress       = errorsmod.Register(ModuleName, 1, "invalid receiver address")
	ErrCallbackFailed               = errorsmod.Register(ModuleName, 2, "callback failed")
	ErrInvalidCalldata              = errorsmod.Register(ModuleName, 3, "invalid calldata in callback data")
	ErrContractHasNoCode            = errorsmod.Register(ModuleName, 4, "contract has no code")
	ErrTokenPairNotFound            = errorsmod.Register(ModuleName, 5, "token not registered")
	ErrNumberOverflow               = errorsmod.Register(ModuleName, 6, "number overflow")
	ErrAllowanceFailed              = errorsmod.Register(ModuleName, 7, "allowance failed")
	ErrEVMCallFailed                = errorsmod.Register(ModuleName, 8, "evm call failed")
	ErrOutOfGas                     = errorsmod.Register(ModuleName, 9, "out of gas")
	ErrNestedSourceCallbackTransfer = errorsmod.Register(ModuleName, 10, "ics20 transfer is not allowed during source callback execution")
)

EVM sentinel callback errors

Functions

func GenerateIsolatedAddress

func GenerateIsolatedAddress(channelID string, sender string) sdk.AccAddress

GenerateIsolatedAddress generates an isolated address for the given channel ID and sender address. This provides a safe address to call the receiver contract address with custom calldata

func IsSourceCallbackExecution added in v0.7.0

func IsSourceCallbackExecution(ctx sdk.Context) bool

IsSourceCallbackExecution returns true when executing inside a source callback.

func WithSourceCallbackExecution added in v0.7.0

func WithSourceCallbackExecution(ctx sdk.Context) sdk.Context

WithSourceCallbackExecution marks a context as executing a source callback.

Types

type AccountKeeper

type AccountKeeper interface {
	NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
	SetAccount(ctx context.Context, acc sdk.AccountI)
	HasAccount(ctx context.Context, addr sdk.AccAddress) bool
}

AccountKeeper defines the contract required for account APIs.

type ERC20Keeper

type ERC20Keeper interface {
	GetTokenPairID(ctx sdk.Context, token string) []byte
	GetTokenPair(ctx sdk.Context, id []byte) (types.TokenPair, bool)
	SetAllowance(ctx sdk.Context, erc20 common.Address, owner common.Address, spender common.Address, value *big.Int) error
	BalanceOf(ctx sdk.Context, abi abi.ABI, contract, account common.Address) *big.Int
}

type EVMKeeper

type EVMKeeper interface {
	CallEVM(ctx sdk.Context, stateDB *statedb.StateDB, abi abi.ABI, from, contract common.Address, commit bool, callFromPrecompile bool, gasCap *big.Int, method string, args ...interface{}) (*evmtypes.MsgEthereumTxResponse, error)
	CallEVMWithData(ctx sdk.Context, stateDB *statedb.StateDB, from common.Address, contract *common.Address, data []byte, commit bool, callFromPrecompile bool, gasCap *big.Int) (*evmtypes.MsgEthereumTxResponse, error)
	GetAccountOrEmpty(ctx sdk.Context, addr common.Address) statedb.Account
	GetAccount(ctx sdk.Context, addr common.Address) *statedb.Account
	IsContract(ctx sdk.Context, addr common.Address) bool
	GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash
	GetCode(ctx sdk.Context, codeHash common.Hash) []byte
	GetCodeHash(ctx sdk.Context, addr common.Address) common.Hash
	ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key common.Hash, value common.Hash) bool)
	SetAccount(ctx sdk.Context, addr common.Address, account statedb.Account) error
	DeleteState(ctx sdk.Context, addr common.Address, key common.Hash)
	SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte)
	DeleteCode(ctx sdk.Context, codeHash []byte)
	SetCode(ctx sdk.Context, codeHash []byte, code []byte)
	DeleteAccount(ctx sdk.Context, addr common.Address) error
	KVStoreKeys() map[string]storetypes.StoreKey
}

EVMKeeper defines the expected EVM keeper interface used on erc20

type Unmarshaler

type Unmarshaler struct{}

func (Unmarshaler) UnmarshalPacketData

func (u Unmarshaler) UnmarshalPacketData(ctx sdk.Context, portID, channelID string, data []byte) (any, string, error)

UnmarshalPacketData will unmarshal the packet data for the IBC transfer callback. It expects the data to be in the format of transfertypes.FungibleTokenPacketData. If the data is not in the expected format, it returns an error.

Jump to

Keyboard shortcuts

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