types

package
v6.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: CC0-1.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindFlagsLoadViper

func BindFlagsLoadViper(cmd *cobra.Command, _ []string) error

BindFlagsLoadViper binds all flags and read the config into viper

func ConvertValidatorAddressToBech32String

func ConvertValidatorAddressToBech32String(address types.Address) string

ConvertValidatorAddressToBech32String converts the given validator address to its Bech32 string representation

func ConvertValidatorPubKeyToBech32String

func ConvertValidatorPubKeyToBech32String(pubKey tmcrypto.PubKey) (string, error)

ConvertValidatorPubKeyToBech32String converts the given pubKey to a Bech32 string

func FindAttributeByKey

func FindAttributeByKey(event abci.Event, attrKey string) (abci.EventAttribute, error)

func FindEventByType

func FindEventByType(events []abci.Event, eventType string) (abci.Event, error)

func FindEventsByType

func FindEventsByType(events []abci.Event, eventType string) []abci.Event

Types

type AuthInfo

type AuthInfo struct {
	*tx.AuthInfo
	SignerInfos []*SignerInfo `json:"signer_infos,omitempty"`
	Fee         *Fee          `json:"fee"`
}

AuthInfo represents the data of a single transaction auth info. It embeds the Cosmos AuthInfo type, but it overrides the SignerInfos and Fee fields with a custom type.

type Block

type Block struct {
	Height          int64
	Hash            string
	TxNum           int
	TotalGas        uint64
	ProposerAddress string
	Timestamp       time.Time
}

Block contains the data of a single chain block

func NewBlock

func NewBlock(
	height int64, hash string, txNum int, totalGas uint64, proposerAddress string, timestamp time.Time,
) *Block

NewBlock allows to build a new Block instance

func NewBlockFromTmBlock

func NewBlockFromTmBlock(blk *tmctypes.ResultBlock, totalGas uint64) *Block

NewBlockFromTmBlock builds a new Block instance from a given ResultBlock object

type CobraCmdFunc

type CobraCmdFunc func(cmd *cobra.Command, args []string) error

CobraCmdFunc represents a cobra command function

func ConcatCobraCmdFuncs

func ConcatCobraCmdFuncs(fs ...CobraCmdFunc) CobraCmdFunc

ConcatCobraCmdFuncs returns a single function that calls each argument function in sequence RunE, PreRunE, PersistentPreRunE, etc. all have this same signature

type CommitSig

type CommitSig struct {
	Height           int64
	ValidatorAddress string
	VotingPower      int64
	ProposerPriority int64
	Timestamp        time.Time
}

CommitSig contains the data of a single validator commit signature

func NewCommitSig

func NewCommitSig(validatorAddress string, votingPower, proposerPriority, height int64, timestamp time.Time) *CommitSig

NewCommitSig allows to build a new CommitSign object

type Fee

type Fee struct {
	*tx.Fee
	GasLimit uint64 `json:"gas_limit,string,omitempty"`
}

Fee represents the data of a single transaction fee. It embeds the Cosmos Fee type, but it overrides the GasLimit field with a custom type.

type HeightQueue

type HeightQueue chan int64

HeightQueue is a simple type alias for a (buffered) channel of block heights.

func NewQueue

func NewQueue(size int) HeightQueue

type Message

type Message interface {
	GetType() string
	GetIndex() int
	GetBytes() json.RawMessage
}

func UnmarshalMessage

func UnmarshalMessage(index int, rawMsg json.RawMessage) (Message, error)

UnmarshalMessage can be used to unmarshal a Message instance from a JSON representation.

type SignerInfo

type SignerInfo struct {
	PublicKey json.RawMessage `json:"public_key,omitempty"`
	ModeInfo  json.RawMessage `json:"mode_info,omitempty"`
	Sequence  uint64          `json:"sequence,string,omitempty"`
}

SignerInfo represents the data of a single transaction signer info. It embeds the Cosmos SignerInfo type, but it overrides the PublicKey and Sequence fields with a custom type.

type StandardMessage

type StandardMessage struct {
	Index int
	Type  string `json:"@type"`
	Bytes json.RawMessage
}

StandardMessage represents the data of a single transaction message. It contains the raw bytes of the message, plus the type of the message. This is done in order to be able to support any kind of message agnosticly while still being able to decode the message bytes into a concrete type.

func NewStandardMessage

func NewStandardMessage(index int, msgType string, bytes json.RawMessage) *StandardMessage

NewStandardMessage allows to build a new StandardMessage instance

func (*StandardMessage) GetBytes

func (msg *StandardMessage) GetBytes() json.RawMessage

func (*StandardMessage) GetIndex

func (msg *StandardMessage) GetIndex() int

func (*StandardMessage) GetType

func (msg *StandardMessage) GetType() string

func (*StandardMessage) MarshalJSON

func (msg *StandardMessage) MarshalJSON() ([]byte, error)

MarshalJSON allows to marshal a Message into a JSON representation.

func (*StandardMessage) UnmarshalJSON

func (msg *StandardMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON allows to unmarshal a Message from a JSON representation.

type Transaction

type Transaction struct {
	// Override the TxResponse field to apply the custom type
	*TxResponse `json:"tx_response,omitempty"`
	// Override the Tx field to apply the custom type
	*Tx `json:"tx,omitempty"`
}

Transaction represents an already existing blockchain transaction.

func NewTransaction

func NewTransaction(txResponse *TxResponse, tx *Tx) (*Transaction, error)

NewTransaction allows to create a new Transaction instance from the given txResponse

func (Transaction) FindAttributeByKey

func (tx Transaction) FindAttributeByKey(event sdk.StringEvent, attrKey string) (string, error)

FindAttributeByKey searches inside the specified event of the given tx to find the attribute having the given key. If the specified event does not contain a such attribute, returns an error instead.

func (Transaction) FindEventByType

func (tx Transaction) FindEventByType(index int, eventType string) (sdk.StringEvent, error)

FindEventByType searches inside the given tx events for the message having the specified index, in order to find the event having the given type, and returns it. If no such event is found, returns an error instead.

func (Transaction) Successful

func (tx Transaction) Successful() bool

Successful tells whether this tx is successful or not

type Tx

type Tx struct {
	*tx.Tx
	Body     *TxBody   `json:"body,omitempty"`
	AuthInfo *AuthInfo `json:"auth_info,omitempty"`
}

Tx represents the data of a single transaction. It embeds the Cosmos Tx type, but it overrides the Body field with a custom type.

type TxBody

type TxBody struct {
	*tx.TxBody
	TimeoutHeight uint64    `json:"timeout_height,string,omitempty"`
	Messages      []Message `json:"messages,omitempty"`
}

TxBody represents the data of a single transaction body. It embeds the Cosmos TxBody type, but it overrides the Messages field with a custom type.

func (*TxBody) UnmarshalJSON

func (tb *TxBody) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. This is done to properly unmarshal the Messages field by setting the Index field to the proper value.

type TxResponse

type TxResponse struct {
	*sdk.TxResponse

	// Override these fields to apply the proper type since the Cosmos SDK encodes uint64 as strings
	Tx        *Tx    `json:"tx,omitempty"`
	Height    uint64 `json:"height,string,omitempty"`
	GasWanted uint64 `json:"gas_wanted,string,omitempty"`
	GasUsed   uint64 `json:"gas_used,string,omitempty"`
}

TxResponse represents the data of a single transaction response.

type Validator

type Validator struct {
	ConsAddr   string
	ConsPubKey string
}

Validator contains the data of a single validator

func NewValidator

func NewValidator(consAddr string, consPubKey string) *Validator

NewValidator allows to build a new Validator instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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