Documentation
¶
Index ¶
- Constants
- Variables
- func MustMarshalDenomTrace(denomTrace DenomTrace, cdc codec.Codec) []byte
- func ParseHexHash(hexHash string) (tmbytes.HexBytes, error)
- func ValidateIBCDenom(denom string) error
- func ValidatePrefixedDenom(denom string) error
- type DenomTrace
- func (*DenomTrace) Descriptor() ([]byte, []int)
- func (m *DenomTrace) GetBaseDenom() string
- func (dt DenomTrace) GetFullDenomPath() string
- func (m *DenomTrace) GetPath() string
- func (dt DenomTrace) GetPrefix() string
- func (dt DenomTrace) Hash() tmbytes.HexBytes
- func (dt DenomTrace) IBCDenom() string
- func (dt DenomTrace) IsNativeDenom() bool
- func (m *DenomTrace) Marshal() (dAtA []byte, err error)
- func (m *DenomTrace) MarshalTo(dAtA []byte) (int, error)
- func (m *DenomTrace) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*DenomTrace) ProtoMessage()
- func (m *DenomTrace) Reset()
- func (m *DenomTrace) Size() (n int)
- func (m *DenomTrace) String() string
- func (m *DenomTrace) Unmarshal(dAtA []byte) error
- func (dt DenomTrace) Validate() error
- func (m *DenomTrace) XXX_DiscardUnknown()
- func (m *DenomTrace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *DenomTrace) XXX_Merge(src proto.Message)
- func (m *DenomTrace) XXX_Size() int
- func (m *DenomTrace) XXX_Unmarshal(b []byte) error
- type Migrator
- type Traces
Constants ¶
const DenomPrefix = "ibc"
Variables ¶
Functions ¶
func MustMarshalDenomTrace ¶
func MustMarshalDenomTrace(denomTrace DenomTrace, cdc codec.Codec) []byte
MustMarshalDenomTrace attempts to encode an DenomTrace object and returns the raw encoded bytes. It panics on error.
func ParseHexHash ¶
ParseHexHash parses a hex hash in string format to bytes and validates its correctness.
func ValidateIBCDenom ¶
ValidateIBCDenom validates that the given denomination is either:
- A valid base denomination (eg: 'uatom' or 'gamm/pool/1' as in https://github.com/cosmos/ibc-go/issues/894)
- A valid fungible token representation (i.e 'ibc/{hash}') per ADR 001 https://github.com/cosmos/ibc-go/blob/main/docs/architecture/adr-001-coin-source-tracing.md
func ValidatePrefixedDenom ¶
ValidatePrefixedDenom checks that the denomination for an IBC fungible token packet denom is correctly prefixed. The function will return no error if the given string follows one of the two formats:
- Prefixed denomination: '{portIDN}/{channelIDN}/.../{portID0}/{channelID0}/baseDenom'
- Unprefixed denomination: 'baseDenom'
'baseDenom' may or may not contain '/'s
Types ¶
type DenomTrace ¶
type DenomTrace struct {
// path defines the chain of port/channel identifiers used for tracing the
// source of the fungible token.
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
// base denomination of the relayed fungible token.
BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"`
}
DenomTrace contains the base denomination for ICS20 fungible tokens and the source tracing information path.
func MustUnmarshalDenomTrace ¶
func MustUnmarshalDenomTrace(bz []byte, cdc codec.Codec) DenomTrace
MustUnmarshalDenomTrace attempts to decode and return an DenomTrace object from raw encoded bytes. It panics on error.
func ParseDenomTrace ¶
func ParseDenomTrace(rawDenom string) DenomTrace
ParseDenomTrace parses a string with the ibc prefix (denom trace) and the base denomination into a DenomTrace type.
Examples:
- "portidone/channel-0/uatom" => DenomTrace{Path: "portidone/channel-0", BaseDenom: "uatom"} - "portidone/channel-0/portidtwo/channel-1/uatom" => DenomTrace{Path: "portidone/channel-0/portidtwo/channel-1", BaseDenom: "uatom"} - "portidone/channel-0/gamm/pool/1" => DenomTrace{Path: "portidone/channel-0", BaseDenom: "gamm/pool/1"} - "gamm/pool/1" => DenomTrace{Path: "", BaseDenom: "gamm/pool/1"} - "uatom" => DenomTrace{Path: "", BaseDenom: "uatom"}
func (*DenomTrace) Descriptor ¶
func (*DenomTrace) Descriptor() ([]byte, []int)
func (*DenomTrace) GetBaseDenom ¶
func (m *DenomTrace) GetBaseDenom() string
func (DenomTrace) GetFullDenomPath ¶
func (dt DenomTrace) GetFullDenomPath() string
GetFullDenomPath returns the full denomination according to the ICS20 specification: tracePath + "/" + baseDenom If there exists no trace then the base denomination is returned.
func (*DenomTrace) GetPath ¶
func (m *DenomTrace) GetPath() string
func (DenomTrace) GetPrefix ¶
func (dt DenomTrace) GetPrefix() string
GetPrefix returns the receiving denomination prefix composed by the trace info and a separator.
func (DenomTrace) Hash ¶
func (dt DenomTrace) Hash() tmbytes.HexBytes
Hash returns the hex bytes of the SHA256 hash of the DenomTrace fields using the following formula:
hash = sha256(tracePath + "/" + baseDenom)
func (DenomTrace) IBCDenom ¶
func (dt DenomTrace) IBCDenom() string
IBCDenom a coin denomination for an ICS20 fungible token in the format 'ibc/{hash(tracePath + baseDenom)}'. If the trace is empty, it will return the base denomination.
func (DenomTrace) IsNativeDenom ¶
func (dt DenomTrace) IsNativeDenom() bool
IsNativeDenom returns true if the denomination is native, thus containing no trace history.
func (*DenomTrace) Marshal ¶
func (m *DenomTrace) Marshal() (dAtA []byte, err error)
func (*DenomTrace) MarshalToSizedBuffer ¶
func (m *DenomTrace) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*DenomTrace) ProtoMessage ¶
func (*DenomTrace) ProtoMessage()
func (*DenomTrace) Reset ¶
func (m *DenomTrace) Reset()
func (*DenomTrace) Size ¶
func (m *DenomTrace) Size() (n int)
func (*DenomTrace) String ¶
func (m *DenomTrace) String() string
func (*DenomTrace) Unmarshal ¶
func (m *DenomTrace) Unmarshal(dAtA []byte) error
func (DenomTrace) Validate ¶
func (dt DenomTrace) Validate() error
Validate performs a basic validation of the DenomTrace fields.
func (*DenomTrace) XXX_DiscardUnknown ¶
func (m *DenomTrace) XXX_DiscardUnknown()
func (*DenomTrace) XXX_Marshal ¶
func (m *DenomTrace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DenomTrace) XXX_Merge ¶
func (m *DenomTrace) XXX_Merge(src proto.Message)
func (*DenomTrace) XXX_Size ¶
func (m *DenomTrace) XXX_Size() int
func (*DenomTrace) XXX_Unmarshal ¶
func (m *DenomTrace) XXX_Unmarshal(b []byte) error
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
DenomTraces is a struct for handling in-place store migrations.
func NewDenomTracesMigrator ¶
func NewDenomTracesMigrator(ibcStore storetypes.KVStore) Migrator
func (Migrator) IterateDenomTraces ¶
func (m Migrator) IterateDenomTraces(ctx sdk.Context, cdc codec.Codec, cb func(denomTrace DenomTrace) bool)
IterateDenomTraces iterates over the denomination traces in the store and performs a callback function.
func (Migrator) MigrateTraces ¶
MigrateTraces migrates the DenomTraces to the correct format, accounting for slashes in the BaseDenom.
func (Migrator) SetDenomTrace ¶
SetDenomTrace sets a new {trace hash -> denom trace} pair to the store.
type Traces ¶
type Traces []DenomTrace
Traces defines a wrapper type for a slice of DenomTrace.