ics20

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 24 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// ErrInvalidSourcePort is raised when the source port is invalid.
	ErrInvalidSourcePort = "invalid source port"
	// ErrInvalidSourceChannel is raised when the source channel is invalid.
	ErrInvalidSourceChannel = "invalid source port"
	// ErrInvalidSender is raised when the sender is invalid.
	ErrInvalidSender = "invalid sender: %s"
	// ErrInvalidReceiver is raised when the receiver is invalid.
	ErrInvalidReceiver = "invalid receiver: %s"
	// ErrInvalidTimeoutTimestamp is raised when the timeout timestamp is invalid.
	ErrInvalidTimeoutTimestamp = "invalid timeout timestamp: %d"
	// ErrInvalidMemo is raised when the memo is invalid.
	ErrInvalidMemo = "invalid memo: %s"
	// ErrInvalidHash is raised when the hash is invalid.
	ErrInvalidHash = "invalid hash: %s"
	// ErrNoMatchingAllocation is raised when no matching allocation is found.
	ErrNoMatchingAllocation = "no matching allocation found for source port: %s, source channel: %s, and denom: %s"
	// ErrDifferentOriginFromSender is raised when the origin address is not the same as the sender address.
	ErrDifferentOriginFromSender = "origin address %s is not the same as sender address %s"
	// ErrDenomNotFound is raised when the denom for the specified request does not exist.
	ErrDenomNotFound = "denomination not found"
)
View Source
const (
	// DenomMethod defines the ABI method name for the ICS20 Denom
	// query.
	DenomMethod = "denom"
	// DenomsMethod defines the ABI method name for the ICS20 Denoms
	// query.
	DenomsMethod = "denoms"
	// DenomHashMethod defines the ABI method name for the ICS20 DenomHash
	// query.
	DenomHashMethod = "denomHash"
)
View Source
const (
	// DefaultRevisionNumber is the default value used to not set a timeout revision number
	DefaultRevisionNumber = 0

	// DefaultRevisionHeight is the default value used to not set a timeout revision height
	DefaultRevisionHeight = 0

	// DefaultTimeoutMinutes is the default value in minutes used to set a timeout timestamp
	DefaultTimeoutMinutes = 10
)
View Source
const (
	// EventTypeIBCTransfer defines the event type for the ICS20 Transfer transaction.
	EventTypeIBCTransfer = "IBCTransfer"
)
View Source
const PrecompileAddress = "0x0000000000000000000000000000000000000802"

PrecompileAddress of the ICS-20 EVM extension in hex format.

View Source
const (
	// TransferMethod defines the ABI method name for the ICS20 Transfer
	// transaction.
	TransferMethod = "transfer"
)

Variables

DefaultTimeoutHeight is the default value used to set a timeout height

Functions

func CheckOriginAndSender

func CheckOriginAndSender(contract *vm.Contract, origin common.Address, sender common.Address) (common.Address, error)

CheckOriginAndSender ensures the correct sender is being used.

func CreateAndValidateMsgTransfer

func CreateAndValidateMsgTransfer(
	sourcePort, sourceChannel string,
	coin sdk.Coin, senderAddress, receiverAddress string,
	timeoutHeight clienttypes.Height,
	timeoutTimestamp uint64,
	memo string,
) (*transfertypes.MsgTransfer, error)

CreateAndValidateMsgTransfer creates a new MsgTransfer message and run validate basic.

func EmitIBCTransferEvent

func EmitIBCTransferEvent(
	ctx sdk.Context,
	stateDB vm.StateDB,
	event abi.Event,
	precompileAddr, senderAddr common.Address,
	receiver string,
	sourcePort, sourceChannel string,
	token sdk.Coin,
	memo string,
) error

EmitIBCTransferEvent creates a new IBC transfer event emitted on a Transfer transaction.

func NewDenomHashRequest

func NewDenomHashRequest(args []interface{}) (*transfertypes.QueryDenomHashRequest, error)

NewDenomHashRequest returns a new denom hash request from the given arguments.

func NewDenomRequest added in v0.2.0

func NewDenomRequest(args []interface{}) (*transfertypes.QueryDenomRequest, error)

NewDenomRequest returns a new denom request from the given arguments.

func NewDenomsRequest added in v0.2.0

func NewDenomsRequest(method *abi.Method, args []interface{}) (*transfertypes.QueryDenomsRequest, error)

NewDenomsRequest returns a new denoms request from the given arguments.

func NewMsgTransfer

func NewMsgTransfer(method *abi.Method, args []interface{}) (*transfertypes.MsgTransfer, common.Address, error)

NewMsgTransfer returns a new transfer message from the given arguments.

Types

type DenomResponse added in v0.2.0

type DenomResponse struct {
	Denom transfertypes.Denom
}

DenomResponse defines the data for the denom response.

type DenomsResponse added in v0.2.0

type DenomsResponse struct {
	Denoms       []transfertypes.Denom
	PageResponse query.PageResponse
}

DenomsResponse defines the data for the denoms response.

type EventIBCTransfer

type EventIBCTransfer struct {
	Sender        common.Address
	Receiver      common.Hash
	SourcePort    string
	SourceChannel string
	Denom         string
	Amount        *big.Int
	Memo          string
}

EventIBCTransfer is the event type emitted when a transfer is executed.

type EventTransferAuthorization

type EventTransferAuthorization struct {
	Grantee     common.Address
	Granter     common.Address
	Allocations []cmn.ICS20Allocation
}

EventTransferAuthorization is the event type emitted when a transfer authorization is created.

type PageRequest

type PageRequest struct {
	PageRequest query.PageRequest
}

PageRequest defines the data for the page request.

type Precompile

type Precompile struct {
	cmn.Precompile
	// contains filtered or unexported fields
}

func NewPrecompile

func NewPrecompile(
	stakingKeeper stakingkeeper.Keeper,
	transferKeeper transferkeeper.Keeper,
	channelKeeper *channelkeeper.Keeper,
	evmKeeper *evmkeeper.Keeper,
) (*Precompile, error)

NewPrecompile creates a new ICS-20 Precompile instance as a PrecompiledContract interface.

func (Precompile) Denom added in v0.2.0

func (p Precompile) Denom(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Denom returns the requested denomination information.

func (Precompile) DenomHash

func (p Precompile) DenomHash(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

DenomHash returns the denom hash (in hex format) of the denomination information.

func (Precompile) Denoms added in v0.2.0

func (p Precompile) Denoms(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Denoms returns the requested denomination information.

func (Precompile) IsTransaction

func (Precompile) IsTransaction(method *abi.Method) bool

IsTransaction checks if the given method name corresponds to a transaction or query.

Available ics20 transactions are:

  • Transfer

func (Precompile) RequiredGas

func (p Precompile) RequiredGas(input []byte) uint64

RequiredGas calculates the precompiled contract's base gas rate.

func (Precompile) Run

func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error)

Run executes the precompiled contract IBC transfer methods defined in the ABI.

func (*Precompile) Transfer

func (p *Precompile) Transfer(
	ctx sdk.Context,
	origin common.Address,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Transfer implements the ICS20 transfer transactions.

Jump to

Keyboard shortcuts

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