traces

package
v0.15.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DenomPrefix = "ibc"

Variables

View Source
var (
	ErrInvalidLengthTransfer        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTransfer          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTransfer = fmt.Errorf("proto: unexpected end of group")
)

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

func ParseHexHash(hexHash string) (tmbytes.HexBytes, error)

ParseHexHash parses a hex hash in string format to bytes and validates its correctness.

func ValidateIBCDenom

func ValidateIBCDenom(denom string) error

ValidateIBCDenom validates that the given denomination is either:

func ValidatePrefixedDenom

func ValidatePrefixedDenom(denom string) error

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) MarshalTo

func (m *DenomTrace) MarshalTo(dAtA []byte) (int, 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

func (m Migrator) MigrateTraces(ctx sdk.Context) error

MigrateTraces migrates the DenomTraces to the correct format, accounting for slashes in the BaseDenom.

func (Migrator) SetDenomTrace

func (m Migrator) SetDenomTrace(ctx sdk.Context, cdc codec.Codec, denomTrace DenomTrace)

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.

func (Traces) Len

func (t Traces) Len() int

Len implements sort.Interface for Traces

func (Traces) Less

func (t Traces) Less(i, j int) bool

Less implements sort.Interface for Traces

func (Traces) Sort

func (t Traces) Sort() Traces

Sort is a helper function to sort the set of denomination traces in-place

func (Traces) Swap

func (t Traces) Swap(i, j int)

Swap implements sort.Interface for Traces

func (Traces) Validate

func (t Traces) Validate() error

Validate performs a basic validation of each denomination trace info.

Jump to

Keyboard shortcuts

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