decoder

package
v0.0.0-...-7d4c4c8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

package decoder provides a decoder for Cosmos SDK messages The code has been added from https://github.com/calvinlauyh/cosmosutils which hasn't been updated in many years

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthExtensions        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowExtensions          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupExtensions = fmt.Errorf("proto: unexpected end of group")
)
View Source
var DefaultDecoder = NewDecoder().RegisterInterfaces(RegisterDefaultInterfaces)

DefaultDecoder is a decoder with all Cosmos builtin modules interfaces registered

Functions

func RegisterDefaultInterfaces

func RegisterDefaultInterfaces(interfaceRegistry types.InterfaceRegistry)

func RegisterInterfaces

func RegisterInterfaces(registry types.InterfaceRegistry)

Types

type Amount

type Amount struct {
	Denom  string `json:"denom"`
	Amount string `json:"amount"`
}

type AuthInfo

type AuthInfo struct {
	SignerInfos []SignerInfo `json:"signer_infos"`
	Fee         Fee          `json:"fee"`
}

type Bitarray

type Bitarray struct {
	ExtraBitsStored int64  `json:"extra_bits_stored"`
	Elems           string `json:"elems"`
}

type Body

type Body struct {
	Messages                    []map[string]interface{} `json:"messages"`
	Memo                        string                   `json:"memo"`
	TimeoutHeight               string                   `json:"timeout_height"`
	ExtensionOptions            []interface{}            `json:"extension_options"`
	NonCriticalExtensionOptions []interface{}            `json:"non_critical_extension_options"`
}

type CosmosTx

type CosmosTx struct {
	Body       Body     `json:"body"`
	AuthInfo   AuthInfo `json:"auth_info"`
	Signatures []string `json:"signatures"`
}

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder() *Decoder

NewDecoder creates a new decoder

func (*Decoder) Decode

func (decoder *Decoder) Decode(txBytes []byte) (Tx, error)

Decode decodes the transaction bytes to Tx

func (*Decoder) DecodeBase64

func (decoder *Decoder) DecodeBase64(base64Tx string) (Tx, error)

Decode decodes the base64-encoded transaction bytes to Tx

func (*Decoder) RegisterInterfaces

func (decoder *Decoder) RegisterInterfaces(registry func(registry codectypes.InterfaceRegistry)) *Decoder

RegisterInterfaces register decoding interface to the decoder by using the provided interface registry.

type ExtensionData

type ExtensionData struct {
	// protocol_id is the identifier of the protocol
	// the field is not used internally but it is validated for correctness
	ProtocolId string `protobuf:"bytes,1,opt,name=protocol_id,json=protocolId,proto3" json:"protocol_id,omitempty"`
	// protocol_version is the identifier of the protocol version
	// the field is not used internally but it is validated for correctness
	ProtocolVersion string `protobuf:"bytes,2,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
	// arbitrary bytes data that can be used to store any data
	// the field is not used internally but it is validated and must be provided
	Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
}

ExtensionData is a data structure that can be used in transaction extensions.

func (*ExtensionData) Descriptor

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

func (*ExtensionData) GetData

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

func (*ExtensionData) GetProtocolId

func (m *ExtensionData) GetProtocolId() string

func (*ExtensionData) GetProtocolVersion

func (m *ExtensionData) GetProtocolVersion() string

func (*ExtensionData) Marshal

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

func (*ExtensionData) MarshalTo

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

func (*ExtensionData) MarshalToSizedBuffer

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

func (*ExtensionData) ProtoMessage

func (*ExtensionData) ProtoMessage()

func (*ExtensionData) Reset

func (m *ExtensionData) Reset()

func (*ExtensionData) Size

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

func (*ExtensionData) String

func (m *ExtensionData) String() string

func (*ExtensionData) Unmarshal

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

func (*ExtensionData) XXX_DiscardUnknown

func (m *ExtensionData) XXX_DiscardUnknown()

func (*ExtensionData) XXX_Marshal

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

func (*ExtensionData) XXX_Merge

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

func (*ExtensionData) XXX_MessageName

func (m *ExtensionData) XXX_MessageName() string

func (*ExtensionData) XXX_Size

func (m *ExtensionData) XXX_Size() int

func (*ExtensionData) XXX_Unmarshal

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

type Fee

type Fee struct {
	Amount   []Amount `json:"amount"`
	GasLimit string   `json:"gas_limit"`
	Payer    string   `json:"payer"`
	Granter  string   `json:"granter"`
}

type Message

type Message struct {
	Type string `json:"@type"`
}

type ModeInfo

type ModeInfo struct {
	MaybeSingle *Single `json:"single,omitempty"`
	MaybeMulti  *Multi  `json:"multi,omitempty"`
}

type Multi

type Multi struct {
	Bitarray  Bitarray         `json:"bitarray"`
	ModeInfos []SingleModeInfo `json:"mode_infos"`
}

type PublicKey

type PublicKey struct {
	Type string `json:"@type"`
	Key  string `json:"key"`
}

type SignerInfo

type SignerInfo struct {
	PublicKey SignerInfoPublicKey `json:"public_key"`
	ModeInfo  ModeInfo            `json:"mode_info"`
	Sequence  string              `json:"sequence"`
}

type SignerInfoPublicKey

type SignerInfoPublicKey struct {
	Type            string      `json:"@type"`
	MaybeThreshold  *int64      `json:"threshold,omitempty"`
	MaybePublicKeys []PublicKey `json:"public_keys,omitempty"`
	MaybeKey        *string     `json:"key,omitempty"`
}

type Single

type Single struct {
	Mode string `json:"mode"`
}

type SingleModeInfo

type SingleModeInfo struct {
	Single Single `json:"single"`
}

type Tx

type Tx struct {
	cosmostypes.Tx
	// contains filtered or unexported fields
}

func (*Tx) MarshalToJSON

func (tx *Tx) MarshalToJSON() ([]byte, error)

type TxExtensionOptionI

type TxExtensionOptionI interface{}

Jump to

Keyboard shortcuts

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