types

package
v7.2.0-mocks-mechain.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypePacket = "ics27_packet"

	AttributeKeyAckError            = "error"
	AttributeKeyHostChannelID       = "host_channel_id"
	AttributeKeyControllerChannelID = "controller_channel_id"
	AttributeKeyAckSuccess          = "success"
)

ICS27 Interchain Accounts events

View Source
const (
	// ModuleName defines the interchain accounts module name
	ModuleName = "interchainaccounts"

	// HostPortID is the default port id that the interchain accounts host submodule binds to
	HostPortID = "icahost"

	// ControllerPortPrefix is the default port prefix that the interchain accounts controller submodule binds to
	ControllerPortPrefix = "icacontroller-"

	// Version defines the current version for interchain accounts
	Version = "ics27-1"

	// StoreKey is the store key string for interchain accounts
	StoreKey = ModuleName

	// RouterKey is the message route for interchain accounts
	RouterKey = ModuleName

	// QuerierRoute is the querier route for interchain accounts
	QuerierRoute = ModuleName
)
View Source
const (
	// EncodingProtobuf defines the protocol buffers proto3 encoding format
	EncodingProtobuf = "proto3"

	// TxTypeSDKMultiMsg defines the multi message transaction type supported by the Cosmos SDK
	TxTypeSDKMultiMsg = "sdk_multi_msg"
)
View Source
const MaxMemoCharLength = 256

MaxMemoCharLength defines the maximum length for the InterchainAccountPacketData memo field

Variables

View Source
var (
	ErrInvalidLengthAccount        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowAccount          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupAccount = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrUnknownDataType             = sdkerrors.Register(ModuleName, 2, "unknown data type")
	ErrAccountAlreadyExist         = sdkerrors.Register(ModuleName, 3, "account already exist")
	ErrPortAlreadyBound            = sdkerrors.Register(ModuleName, 4, "port is already bound")
	ErrInvalidChannelFlow          = sdkerrors.Register(ModuleName, 5, "invalid message sent to channel end")
	ErrInvalidOutgoingData         = sdkerrors.Register(ModuleName, 6, "invalid outgoing data")
	ErrInvalidRoute                = sdkerrors.Register(ModuleName, 7, "invalid route")
	ErrInterchainAccountNotFound   = sdkerrors.Register(ModuleName, 8, "interchain account not found")
	ErrInterchainAccountAlreadySet = sdkerrors.Register(ModuleName, 9, "interchain account is already set")
	ErrActiveChannelAlreadySet     = sdkerrors.Register(ModuleName, 10, "active channel already set for this owner")
	ErrActiveChannelNotFound       = sdkerrors.Register(ModuleName, 11, "no active channel for this owner")
	ErrInvalidVersion              = sdkerrors.Register(ModuleName, 12, "invalid interchain accounts version")
	ErrInvalidAccountAddress       = sdkerrors.Register(ModuleName, 13, "invalid account address")
	ErrUnsupported                 = sdkerrors.Register(ModuleName, 14, "interchain account does not support this action")
	ErrInvalidControllerPort       = sdkerrors.Register(ModuleName, 15, "invalid controller port")
	ErrInvalidHostPort             = sdkerrors.Register(ModuleName, 16, "invalid host port")
	ErrInvalidTimeoutTimestamp     = sdkerrors.Register(ModuleName, 17, "timeout timestamp must be in the future")
	ErrInvalidCodec                = sdkerrors.Register(ModuleName, 18, "codec is not supported")
	ErrInvalidAccountReopening     = sdkerrors.Register(ModuleName, 19, "invalid account reopening")
)
View Source
var (
	// ActiveChannelKeyPrefix defines the key prefix used to store active channels
	ActiveChannelKeyPrefix = "activeChannel"

	// OwnerKeyPrefix defines the key prefix used to store interchain accounts
	OwnerKeyPrefix = "owner"

	// PortKeyPrefix defines the key prefix used to store ports
	PortKeyPrefix = "port"

	// IsMiddlewareEnabledPrefix defines the key prefix used to store a flag for legacy API callback routing via ibc middleware
	IsMiddlewareEnabledPrefix = "isMiddlewareEnabled"

	// MiddlewareEnabled is the value used to signal that controller middleware is enabled
	MiddlewareEnabled = []byte{0x01}

	// MiddlewareDisabled is the value used to signal that controller midleware is disabled
	MiddlewareDisabled = []byte{0x02}
)
View Source
var (
	ErrInvalidLengthMetadata        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowMetadata          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupMetadata = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	// DefaultRelativePacketTimeoutHeight is the default packet timeout height (in blocks) relative
	// to the current block height of the counterparty chain provided by the client state. The
	// timeout is disabled when set to 0.
	DefaultRelativePacketTimeoutHeight = "0-1000"

	// DefaultRelativePacketTimeoutTimestamp is the default packet timeout timestamp (in nanoseconds)
	// relative to the current block timestamp of the counterparty chain provided by the client
	// state. The timeout is disabled when set to 0. The default is currently set to a 10 minute
	// timeout.
	DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds())
)
View Source
var (
	ErrInvalidLengthPacket        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPacket          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupPacket = fmt.Errorf("proto: unexpected end of group")
)
View Source
var DefaultMaxAddrLength = 128

DefaultMaxAddrLength defines the default maximum character length used in validation of addresses

ModuleCdc references the global interchain accounts module codec. Note, the codec should ONLY be used in certain instances of tests and for JSON encoding.

The actual codec used for serialization should be provided to interchain accounts and defined at the application level.

View Source
var Type_name = map[int32]string{
	0: "TYPE_UNSPECIFIED",
	1: "TYPE_EXECUTE_TX",
}
View Source
var Type_value = map[string]int32{
	"TYPE_UNSPECIFIED": 0,
	"TYPE_EXECUTE_TX":  1,
}

Functions

func DeserializeCosmosTx

func DeserializeCosmosTx(cdc codec.BinaryCodec, data []byte) ([]sdk.Msg, error)

DeserializeCosmosTx unmarshals and unpacks a slice of transaction bytes into a slice of sdk.Msg's. Only the ProtoCodec is supported for message deserialization.

func GenerateAddress

func GenerateAddress(ctx sdk.Context, connectionID, portID string) sdk.AccAddress

GenerateAddress returns an sdk.AccAddress derived using a host module account address, host connection ID, the controller portID, the current block app hash, and the current block data hash. The sdk.AccAddress returned is a sub-address of the host module account.

func IsPreviousMetadataEqual

func IsPreviousMetadataEqual(previousVersion string, metadata Metadata) bool

IsPreviousMetadataEqual compares a metadata to a previous version string set in a channel struct. It ensures all fields are equal except the Address string

func KeyActiveChannel

func KeyActiveChannel(portID, connectionID string) []byte

KeyActiveChannel creates and returns a new key used for active channels store operations

func KeyIsMiddlewareEnabled

func KeyIsMiddlewareEnabled(portID, connectionID string) []byte

KeyIsMiddlewareEnabled creates and returns a new key used for signaling legacy API callback routing via ibc middleware

func KeyOwnerAccount

func KeyOwnerAccount(portID, connectionID string) []byte

KeyOwnerAccount creates and returns a new key used for interchain account store operations

func KeyPort

func KeyPort(portID string) []byte

KeyPort creates and returns a new key used for port store operations

func NewControllerPortID

func NewControllerPortID(owner string) (string, error)

NewControllerPortID creates and returns a new prefixed controller port identifier using the provided owner string

func NewDefaultMetadataString

func NewDefaultMetadataString(controllerConnectionID, hostConnectionID string) string

NewDefaultMetadataString creates and returns a new JSON encoded version string containing the default ICS27 Metadata values with the provided controller and host connection identifiers

func RegisterInterfaces

func RegisterInterfaces(registry codectypes.InterfaceRegistry)

RegisterInterfaces registers the interchain accounts controller types and the concrete InterchainAccount implementation against the associated x/auth AccountI and GenesisAccount interfaces.

func SerializeCosmosTx

func SerializeCosmosTx(cdc codec.BinaryCodec, msgs []proto.Message) (bz []byte, err error)

SerializeCosmosTx serializes a slice of sdk.Msg's using the CosmosTx type. The sdk.Msg's are packed into Any's and inserted into the Messages field of a CosmosTx. The proto marshaled CosmosTx bytes are returned. Only the ProtoCodec is supported for serializing messages.

func ValidateAccountAddress

func ValidateAccountAddress(addr string) error

ValidateAccountAddress performs basic validation of interchain account addresses, enforcing constraints on address length and character set

func ValidateControllerMetadata

func ValidateControllerMetadata(ctx sdk.Context, channelKeeper ChannelKeeper, connectionHops []string, metadata Metadata) error

ValidateControllerMetadata performs validation of the provided ICS27 controller metadata parameters

func ValidateHostMetadata

func ValidateHostMetadata(ctx sdk.Context, channelKeeper ChannelKeeper, connectionHops []string, metadata Metadata) error

ValidateHostMetadata performs validation of the provided ICS27 host metadata parameters

Types

type AccountKeeper

type AccountKeeper interface {
	NewAccount(ctx sdk.Context, acc authtypes.AccountI) authtypes.AccountI
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
	SetAccount(ctx sdk.Context, acc authtypes.AccountI)
	GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI
	GetModuleAddress(name string) sdk.AccAddress
}

AccountKeeper defines the expected account keeper

type ChannelKeeper

type ChannelKeeper interface {
	GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool)
	GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
	GetConnection(ctx sdk.Context, connectionID string) (ibcexported.ConnectionI, error)
	GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) []channeltypes.IdentifiedChannel
}

ChannelKeeper defines the expected IBC channel keeper

type CosmosTx

type CosmosTx struct {
	Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
}

CosmosTx contains a list of sdk.Msg's. It should be used when sending transactions to an SDK host chain.

func (*CosmosTx) Descriptor

func (*CosmosTx) Descriptor() ([]byte, []int)

func (CosmosTx) GetBytes

func (ct CosmosTx) GetBytes() []byte

GetBytes returns the JSON marshalled interchain account CosmosTx.

func (*CosmosTx) GetMessages

func (m *CosmosTx) GetMessages() []*types.Any

func (*CosmosTx) Marshal

func (m *CosmosTx) Marshal() (dAtA []byte, err error)

func (*CosmosTx) MarshalTo

func (m *CosmosTx) MarshalTo(dAtA []byte) (int, error)

func (*CosmosTx) MarshalToSizedBuffer

func (m *CosmosTx) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CosmosTx) ProtoMessage

func (*CosmosTx) ProtoMessage()

func (*CosmosTx) Reset

func (m *CosmosTx) Reset()

func (*CosmosTx) Size

func (m *CosmosTx) Size() (n int)

func (*CosmosTx) String

func (m *CosmosTx) String() string

func (*CosmosTx) Unmarshal

func (m *CosmosTx) Unmarshal(dAtA []byte) error

func (CosmosTx) UnpackInterfaces

func (ct CosmosTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error

UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces

func (*CosmosTx) XXX_DiscardUnknown

func (m *CosmosTx) XXX_DiscardUnknown()

func (*CosmosTx) XXX_Marshal

func (m *CosmosTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CosmosTx) XXX_Merge

func (m *CosmosTx) XXX_Merge(src proto.Message)

func (*CosmosTx) XXX_Size

func (m *CosmosTx) XXX_Size() int

func (*CosmosTx) XXX_Unmarshal

func (m *CosmosTx) XXX_Unmarshal(b []byte) error

type InterchainAccount

type InterchainAccount struct {
	*types.BaseAccount ``     /* 136-byte string literal not displayed */
	AccountOwner       string `protobuf:"bytes,2,opt,name=account_owner,json=accountOwner,proto3" json:"account_owner,omitempty" yaml:"account_owner"`
}

An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain

func NewInterchainAccount

func NewInterchainAccount(ba *authtypes.BaseAccount, accountOwner string) *InterchainAccount

NewInterchainAccount creates and returns a new InterchainAccount type

func (*InterchainAccount) Descriptor

func (*InterchainAccount) Descriptor() ([]byte, []int)

func (*InterchainAccount) Marshal

func (m *InterchainAccount) Marshal() (dAtA []byte, err error)

func (InterchainAccount) MarshalJSON

func (ia InterchainAccount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of the InterchainAccount

func (*InterchainAccount) MarshalTo

func (m *InterchainAccount) MarshalTo(dAtA []byte) (int, error)

func (*InterchainAccount) MarshalToSizedBuffer

func (m *InterchainAccount) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (InterchainAccount) MarshalYAML

func (ia InterchainAccount) MarshalYAML() ([]byte, error)

MarshalYAML returns the YAML representation of the InterchainAccount

func (*InterchainAccount) ProtoMessage

func (*InterchainAccount) ProtoMessage()

func (*InterchainAccount) Reset

func (m *InterchainAccount) Reset()

func (InterchainAccount) SetPubKey

func (ia InterchainAccount) SetPubKey(pubKey crypto.PubKey) error

SetPubKey implements the authtypes.AccountI interface

func (InterchainAccount) SetSequence

func (ia InterchainAccount) SetSequence(seq uint64) error

SetSequence implements the authtypes.AccountI interface

func (*InterchainAccount) Size

func (m *InterchainAccount) Size() (n int)

func (InterchainAccount) String

func (ia InterchainAccount) String() string

String returns a string representation of the InterchainAccount

func (*InterchainAccount) Unmarshal

func (m *InterchainAccount) Unmarshal(dAtA []byte) error

func (*InterchainAccount) UnmarshalJSON

func (ia *InterchainAccount) UnmarshalJSON(bz []byte) error

UnmarshalJSON unmarshals raw JSON bytes into the InterchainAccount

func (InterchainAccount) Validate

func (ia InterchainAccount) Validate() error

Validate implements basic validation of the InterchainAccount

func (*InterchainAccount) XXX_DiscardUnknown

func (m *InterchainAccount) XXX_DiscardUnknown()

func (*InterchainAccount) XXX_Marshal

func (m *InterchainAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InterchainAccount) XXX_Merge

func (m *InterchainAccount) XXX_Merge(src proto.Message)

func (*InterchainAccount) XXX_Size

func (m *InterchainAccount) XXX_Size() int

func (*InterchainAccount) XXX_Unmarshal

func (m *InterchainAccount) XXX_Unmarshal(b []byte) error

type InterchainAccountI

type InterchainAccountI interface {
	authtypes.AccountI
}

InterchainAccountI wraps the authtypes.AccountI interface

type InterchainAccountPacketData

type InterchainAccountPacketData struct {
	Type Type   `protobuf:"varint,1,opt,name=type,proto3,enum=ibc.applications.interchain_accounts.v1.Type" json:"type,omitempty"`
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	Memo string `protobuf:"bytes,3,opt,name=memo,proto3" json:"memo,omitempty"`
}

InterchainAccountPacketData is comprised of a raw transaction, type of transaction and optional memo field.

func (*InterchainAccountPacketData) Descriptor

func (*InterchainAccountPacketData) Descriptor() ([]byte, []int)

func (InterchainAccountPacketData) GetBytes

func (iapd InterchainAccountPacketData) GetBytes() []byte

GetBytes returns the JSON marshalled interchain account packet data.

func (*InterchainAccountPacketData) GetData

func (m *InterchainAccountPacketData) GetData() []byte

func (*InterchainAccountPacketData) GetMemo

func (m *InterchainAccountPacketData) GetMemo() string

func (*InterchainAccountPacketData) GetType

func (m *InterchainAccountPacketData) GetType() Type

func (*InterchainAccountPacketData) Marshal

func (m *InterchainAccountPacketData) Marshal() (dAtA []byte, err error)

func (*InterchainAccountPacketData) MarshalTo

func (m *InterchainAccountPacketData) MarshalTo(dAtA []byte) (int, error)

func (*InterchainAccountPacketData) MarshalToSizedBuffer

func (m *InterchainAccountPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*InterchainAccountPacketData) ProtoMessage

func (*InterchainAccountPacketData) ProtoMessage()

func (*InterchainAccountPacketData) Reset

func (m *InterchainAccountPacketData) Reset()

func (*InterchainAccountPacketData) Size

func (m *InterchainAccountPacketData) Size() (n int)

func (*InterchainAccountPacketData) String

func (m *InterchainAccountPacketData) String() string

func (*InterchainAccountPacketData) Unmarshal

func (m *InterchainAccountPacketData) Unmarshal(dAtA []byte) error

func (InterchainAccountPacketData) ValidateBasic

func (iapd InterchainAccountPacketData) ValidateBasic() error

ValidateBasic performs basic validation of the interchain account packet data. The memo may be empty.

func (*InterchainAccountPacketData) XXX_DiscardUnknown

func (m *InterchainAccountPacketData) XXX_DiscardUnknown()

func (*InterchainAccountPacketData) XXX_Marshal

func (m *InterchainAccountPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InterchainAccountPacketData) XXX_Merge

func (m *InterchainAccountPacketData) XXX_Merge(src proto.Message)

func (*InterchainAccountPacketData) XXX_Size

func (m *InterchainAccountPacketData) XXX_Size() int

func (*InterchainAccountPacketData) XXX_Unmarshal

func (m *InterchainAccountPacketData) XXX_Unmarshal(b []byte) error

type MessageRouter

type MessageRouter interface {
	Handler(msg sdk.Msg) baseapp.MsgServiceHandler
}

MessageRouter ADR 031 request type routing https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-031-msg-service.md

type Metadata

type Metadata struct {
	// version defines the ICS27 protocol version
	Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	// controller_connection_id is the connection identifier associated with the controller chain
	ControllerConnectionId string `` /* 161-byte string literal not displayed */
	// host_connection_id is the connection identifier associated with the host chain
	HostConnectionId string `` /* 137-byte string literal not displayed */
	// address defines the interchain account address to be fulfilled upon the OnChanOpenTry handshake step
	// NOTE: the address field is empty on the OnChanOpenInit handshake step
	Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
	// encoding defines the supported codec format
	Encoding string `protobuf:"bytes,5,opt,name=encoding,proto3" json:"encoding,omitempty"`
	// tx_type defines the type of transactions the interchain account can execute
	TxType string `protobuf:"bytes,6,opt,name=tx_type,json=txType,proto3" json:"tx_type,omitempty"`
}

Metadata defines a set of protocol specific data encoded into the ICS27 channel version bytestring See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning

func NewDefaultMetadata

func NewDefaultMetadata(controllerConnectionID, hostConnectionID string) Metadata

NewDefaultMetadata creates and returns a new ICS27 Metadata instance containing the default ICS27 Metadata values with the provided controller and host connection identifiers

func NewMetadata

func NewMetadata(version, controllerConnectionID, hostConnectionID, accAddress, encoding, txType string) Metadata

NewMetadata creates and returns a new ICS27 Metadata instance

func (*Metadata) Descriptor

func (*Metadata) Descriptor() ([]byte, []int)

func (*Metadata) GetAddress

func (m *Metadata) GetAddress() string

func (*Metadata) GetControllerConnectionId

func (m *Metadata) GetControllerConnectionId() string

func (*Metadata) GetEncoding

func (m *Metadata) GetEncoding() string

func (*Metadata) GetHostConnectionId

func (m *Metadata) GetHostConnectionId() string

func (*Metadata) GetTxType

func (m *Metadata) GetTxType() string

func (*Metadata) GetVersion

func (m *Metadata) GetVersion() string

func (*Metadata) Marshal

func (m *Metadata) Marshal() (dAtA []byte, err error)

func (*Metadata) MarshalTo

func (m *Metadata) MarshalTo(dAtA []byte) (int, error)

func (*Metadata) MarshalToSizedBuffer

func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) Reset

func (m *Metadata) Reset()

func (*Metadata) Size

func (m *Metadata) Size() (n int)

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) Unmarshal

func (m *Metadata) Unmarshal(dAtA []byte) error

func (*Metadata) XXX_DiscardUnknown

func (m *Metadata) XXX_DiscardUnknown()

func (*Metadata) XXX_Marshal

func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Metadata) XXX_Merge

func (m *Metadata) XXX_Merge(src proto.Message)

func (*Metadata) XXX_Size

func (m *Metadata) XXX_Size() int

func (*Metadata) XXX_Unmarshal

func (m *Metadata) XXX_Unmarshal(b []byte) error

type PortKeeper

type PortKeeper interface {
	BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability
	IsBound(ctx sdk.Context, portID string) bool
}

PortKeeper defines the expected IBC port keeper

type Type

type Type int32

Type defines a classification of message issued from a controller chain to its associated interchain accounts host

const (
	// Default zero value enumeration
	UNSPECIFIED Type = 0
	// Execute a transaction on an interchain accounts host chain
	EXECUTE_TX Type = 1
)

func (Type) EnumDescriptor

func (Type) EnumDescriptor() ([]byte, []int)

func (Type) String

func (x Type) String() string

Jump to

Keyboard shortcuts

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