types

package
v0.0.0-...-ac1e388 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// AddrLen defines a valid address length
	AddrLen = 20
	// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
	Bech32MainPrefix = "cosmos"

	// Atom in https://github.com/satoshilabs/slips/blob/master/slip-0044.md
	CoinType = 118

	// BIP44Prefix is the parts of the BIP44 HD path that are fixed by
	// what we used during the fundraiser.
	FullFundraiserPath = "44'/118'/0'/0/0"

	// PrefixAccount is the prefix for account keys
	PrefixAccount = "acc"
	// PrefixValidator is the prefix for validator keys
	PrefixValidator = "val"
	// PrefixConsensus is the prefix for consensus keys
	PrefixConsensus = "cons"
	// PrefixPublic is the prefix for public keys
	PrefixPublic = "pub"
	// PrefixOperator is the prefix for operator keys
	PrefixOperator = "oper"

	// PrefixAddress is the prefix for addresses
	PrefixAddress = "addr"

	// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
	Bech32PrefixAccAddr = Bech32MainPrefix
	// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
	Bech32PrefixAccPub = Bech32MainPrefix + PrefixPublic
	// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
	Bech32PrefixValAddr = Bech32MainPrefix + PrefixValidator + PrefixOperator
	// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
	Bech32PrefixValPub = Bech32MainPrefix + PrefixValidator + PrefixOperator + PrefixPublic
	// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
	Bech32PrefixConsAddr = Bech32MainPrefix + PrefixValidator + PrefixConsensus
	// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
	Bech32PrefixConsPub = Bech32MainPrefix + PrefixValidator + PrefixConsensus + PrefixPublic
)
View Source
const (
	// Base error codes
	CodeOK                CodeType = 0
	CodeInternal          CodeType = 1
	CodeTxDecode          CodeType = 2
	CodeInvalidSequence   CodeType = 3
	CodeUnauthorized      CodeType = 4
	CodeInsufficientFunds CodeType = 5
	CodeUnknownRequest    CodeType = 6
	CodeInvalidAddress    CodeType = 7
	CodeInvalidPubKey     CodeType = 8
	CodeUnknownAddress    CodeType = 9
	CodeInsufficientCoins CodeType = 10
	CodeInvalidCoins      CodeType = 11
	CodeOutOfGas          CodeType = 12
	CodeMemoTooLarge      CodeType = 13
	CodeInsufficientFee   CodeType = 14
	CodeTooManySignatures CodeType = 15
	CodeGasOverflow       CodeType = 16
	CodeNoSignatures      CodeType = 17

	// CodespaceRoot is a codespace for error codes in this file only.
	// Notice that 0 is an "unset" codespace, which can be overridden with
	// Error.WithDefaultCodespace().
	CodespaceUndefined CodespaceType = ""
	CodespaceRoot      CodespaceType = "sdk"
)

SDK error codes

View Source
const SortableTimeFormat = "2006-01-02T15:04:05.000000000"

Slight modification of the RFC3339Nano but it right pads all zeros and drops the time zone info

Variables

View Source
var (
	EventTypeMessage = "message"

	AttributeKeyAction = "action"
	AttributeKeyModule = "module"
	AttributeKeySender = "sender"
	AttributeKeyAmount = "amount"
)

Common event types and attribute keys

View Source
var (
	// This is set at compile time. Could be cleveldb, defaults is goleveldb.
	DBBackend = ""
)

Functions

func AppendMsgToErr

func AppendMsgToErr(msg string, err string) string

appends a message to the head of the given error

func Bech32ifyAccPub

func Bech32ifyAccPub(pub crypto.PubKey) (string, error)

Bech32ifyAccPub returns a Bech32 encoded string containing the Bech32PrefixAccPub prefix for a given account PubKey.

func Bech32ifyConsPub

func Bech32ifyConsPub(pub crypto.PubKey) (string, error)

Bech32ifyConsPub returns a Bech32 encoded string containing the Bech32PrefixConsPub prefixfor a given consensus node's PubKey.

func Bech32ifyValPub

func Bech32ifyValPub(pub crypto.PubKey) (string, error)

Bech32ifyValPub returns a Bech32 encoded string containing the Bech32PrefixValPub prefix for a given validator operator's PubKey.

func CodeToDefaultMsg

func CodeToDefaultMsg(code CodeType) string

NOTE: Don't stringer this, we'll put better messages in later.

func FormatTimeBytes

func FormatTimeBytes(t time.Time) []byte

Formats a time.Time into a []byte that can be sorted

func GetAccPubKeyBech32

func GetAccPubKeyBech32(pubkey string) (pk crypto.PubKey, err error)

GetAccPubKeyBech32 creates a PubKey for an account with a given public key string using the Bech32 Bech32PrefixAccPub prefix.

func GetConsPubKeyBech32

func GetConsPubKeyBech32(pubkey string) (pk crypto.PubKey, err error)

GetConsPubKeyBech32 creates a PubKey for a consensus node with a given public key string using the Bech32 Bech32PrefixConsPub prefix.

func GetFromBech32

func GetFromBech32(bech32str, prefix string) ([]byte, error)

GetFromBech32 decodes a bytestring from a Bech32 encoded string.

func GetValPubKeyBech32

func GetValPubKeyBech32(pubkey string) (pk crypto.PubKey, err error)

GetValPubKeyBech32 creates a PubKey for a validator's operator with a given public key string using the Bech32 Bech32PrefixValPub prefix.

func MustBech32ifyAccPub

func MustBech32ifyAccPub(pub crypto.PubKey) string

MustBech32ifyAccPub returns the result of Bech32ifyAccPub panicing on failure.

func MustBech32ifyConsPub

func MustBech32ifyConsPub(pub crypto.PubKey) string

MustBech32ifyConsPub returns the result of Bech32ifyConsPub panicing on failure.

func MustBech32ifyValPub

func MustBech32ifyValPub(pub crypto.PubKey) string

MustBech32ifyValPub returns the result of Bech32ifyValPub panicing on failure.

func MustGetAccPubKeyBech32

func MustGetAccPubKeyBech32(pubkey string) (pk crypto.PubKey)

MustGetAccPubKeyBech32 returns the result of GetAccPubKeyBech32 panicing on failure.

func MustGetConsPubKeyBech32

func MustGetConsPubKeyBech32(pubkey string) (pk crypto.PubKey)

MustGetConsPubKeyBech32 returns the result of GetConsPubKeyBech32 panicing on failure.

func MustGetValPubKeyBech32

func MustGetValPubKeyBech32(pubkey string) (pk crypto.PubKey)

MustGetValPubKeyBech32 returns the result of GetValPubKeyBech32 panicing on failure.

func MustSortJSON

func MustSortJSON(toSortJSON []byte) []byte

MustSortJSON is like SortJSON but panic if an error occurs, e.g., if the passed JSON isn't valid.

func NewLevelDB

func NewLevelDB(name, dir string) (db dbm.DB, err error)

NewLevelDB instantiate a new LevelDB instance according to DBBackend.

func ParseTimeBytes

func ParseTimeBytes(bz []byte) (time.Time, error)

Parses a []byte encoded using FormatTimeKey back into a time.Time

func SortJSON

func SortJSON(toSortJSON []byte) ([]byte, error)

SortedJSON takes any JSON and returns it sorted by keys. Also, all white-spaces are removed. This method can be used to canonicalize JSON to be returned by GetSignBytes, e.g. for the ledger integration. If the passed JSON isn't valid it will return an error.

func Uint64ToBigEndian

func Uint64ToBigEndian(i uint64) []byte

Uint64ToBigEndian - marshals uint64 to a bigendian byte slice so it can be sorted

func VerifyAddressFormat

func VerifyAddressFormat(bz []byte) error

VerifyAddressFormat verifies that the provided bytes form a valid address according to the default address rules or a custom address verifier set by GetConfig().SetAddressVerifier()

Types

type ABCIMessageLog

type ABCIMessageLog struct {
	MsgIndex uint16 `json:"msg_index"`
	Success  bool   `json:"success"`
	Log      string `json:"log"`

	// Events contains a slice of Event objects that were emitted during some
	// execution.
	Events StringEvents `json:"events"`
}

ABCIMessageLog defines a structure containing an indexed tx ABCI message log.

func NewABCIMessageLog

func NewABCIMessageLog(i uint16, success bool, log string, events Events) ABCIMessageLog

type ABCIMessageLogs

type ABCIMessageLogs []ABCIMessageLog

ABCIMessageLogs represents a slice of ABCIMessageLog.

func ParseABCILogs

func ParseABCILogs(logs string) (res ABCIMessageLogs, err error)

ParseABCILogs attempts to parse a stringified ABCI tx log into a slice of ABCIMessageLog types. It returns an error upon JSON decoding failure.

func (ABCIMessageLogs) String

func (logs ABCIMessageLogs) String() (str string)

String implements the fmt.Stringer interface for the ABCIMessageLogs type.

type AccAddress

type AccAddress []byte

AccAddress a wrapper around bytes meant to represent an account address. When marshaled to a string or JSON, it uses Bech32.

func AccAddressFromBech32

func AccAddressFromBech32(address string) (addr AccAddress, err error)

AccAddressFromBech32 creates an AccAddress from a Bech32 string.

func AccAddressFromHex

func AccAddressFromHex(address string) (addr AccAddress, err error)

AccAddressFromHex creates an AccAddress from a hex string.

func (AccAddress) Bytes

func (aa AccAddress) Bytes() []byte

Bytes returns the raw address bytes.

func (AccAddress) Empty

func (aa AccAddress) Empty() bool

Returns boolean for whether an AccAddress is empty

func (AccAddress) Equals

func (aa AccAddress) Equals(aa2 Address) bool

Returns boolean for whether two AccAddresses are Equal

func (AccAddress) Format

func (aa AccAddress) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface. nolint: errcheck

func (AccAddress) Marshal

func (aa AccAddress) Marshal() ([]byte, error)

Marshal returns the raw address bytes. It is needed for protobuf compatibility.

func (AccAddress) MarshalJSON

func (aa AccAddress) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON using Bech32.

func (AccAddress) MarshalYAML

func (aa AccAddress) MarshalYAML() (interface{}, error)

MarshalYAML marshals to YAML using Bech32.

func (AccAddress) String

func (aa AccAddress) String() string

String implements the Stringer interface.

func (*AccAddress) Unmarshal

func (aa *AccAddress) Unmarshal(data []byte) error

Unmarshal sets the address to the given data. It is needed for protobuf compatibility.

func (*AccAddress) UnmarshalJSON

func (aa *AccAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.

func (*AccAddress) UnmarshalYAML

func (aa *AccAddress) UnmarshalYAML(data []byte) error

UnmarshalYAML unmarshals from JSON assuming Bech32 encoding.

type Address

type Address interface {
	Equals(Address) bool
	Empty() bool
	Marshal() ([]byte, error)
	MarshalJSON() ([]byte, error)
	Bytes() []byte
	String() string
	Format(s fmt.State, verb rune)
}

Address is a common interface for different types of addresses used by the SDK

type Attribute

type Attribute struct {
	Key   string `json:"key"`
	Value string `json:"value,omitempty"`
}

Attribute defines an attribute wrapper where the key and value are strings instead of raw bytes.

func NewAttribute

func NewAttribute(k, v string) Attribute

NewAttribute returns a new key/value Attribute object.

func (Attribute) String

func (a Attribute) String() string

func (Attribute) ToKVPair

func (a Attribute) ToKVPair() cmn.KVPair

ToKVPair converts an Attribute object into a Tendermint key/value pair.

type CodeType

type CodeType uint32

CodeType - ABCI code identifier within codespace

func (CodeType) IsOK

func (code CodeType) IsOK() bool

IsOK - is everything okay?

type CodespaceType

type CodespaceType string

CodespaceType - codespace identifier

type Config

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

Config is the structure that holds the SDK configuration parameters. This could be used to initialize certain configuration parameters for the SDK.

func GetConfig

func GetConfig() *Config

GetConfig returns the config instance for the SDK.

func (*Config) GetAddressVerifier

func (config *Config) GetAddressVerifier() func([]byte) error

GetAddressVerifier returns the function to verify that addresses have the correct format

func (*Config) GetBech32AccountAddrPrefix

func (config *Config) GetBech32AccountAddrPrefix() string

GetBech32AccountAddrPrefix returns the Bech32 prefix for account address

func (*Config) GetBech32AccountPubPrefix

func (config *Config) GetBech32AccountPubPrefix() string

GetBech32AccountPubPrefix returns the Bech32 prefix for account public key

func (*Config) GetBech32ConsensusAddrPrefix

func (config *Config) GetBech32ConsensusAddrPrefix() string

GetBech32ConsensusAddrPrefix returns the Bech32 prefix for consensus node address

func (*Config) GetBech32ConsensusPubPrefix

func (config *Config) GetBech32ConsensusPubPrefix() string

GetBech32ConsensusPubPrefix returns the Bech32 prefix for consensus node public key

func (*Config) GetBech32ValidatorAddrPrefix

func (config *Config) GetBech32ValidatorAddrPrefix() string

GetBech32ValidatorAddrPrefix returns the Bech32 prefix for validator address

func (*Config) GetBech32ValidatorPubPrefix

func (config *Config) GetBech32ValidatorPubPrefix() string

GetBech32ValidatorPubPrefix returns the Bech32 prefix for validator public key

func (*Config) GetCoinType

func (config *Config) GetCoinType() uint32

Get the BIP-0044 CoinType code on the config

func (*Config) GetFullFundraiserPath

func (config *Config) GetFullFundraiserPath() string

Get the FullFundraiserPath (BIP44Prefix) on the config

func (*Config) GetTxEncoder

func (config *Config) GetTxEncoder() TxEncoder

GetTxEncoder return function to encode transactions

func (*Config) Seal

func (config *Config) Seal() *Config

Seal seals the config such that the config state could not be modified further

func (*Config) SetAddressVerifier

func (config *Config) SetAddressVerifier(addressVerifier func([]byte) error)

SetAddressVerifier builds the Config with the provided function for verifying that addresses have the correct format

func (*Config) SetBech32PrefixForAccount

func (config *Config) SetBech32PrefixForAccount(addressPrefix, pubKeyPrefix string)

SetBech32PrefixForAccount builds the Config with Bech32 addressPrefix and publKeyPrefix for accounts and returns the config instance

func (*Config) SetBech32PrefixForConsensusNode

func (config *Config) SetBech32PrefixForConsensusNode(addressPrefix, pubKeyPrefix string)

SetBech32PrefixForConsensusNode builds the Config with Bech32 addressPrefix and publKeyPrefix for consensus nodes and returns the config instance

func (*Config) SetBech32PrefixForValidator

func (config *Config) SetBech32PrefixForValidator(addressPrefix, pubKeyPrefix string)

SetBech32PrefixForValidator builds the Config with Bech32 addressPrefix and publKeyPrefix for validators

and returns the config instance

func (*Config) SetCoinType

func (config *Config) SetCoinType(coinType uint32)

Set the BIP-0044 CoinType code on the config

func (*Config) SetFullFundraiserPath

func (config *Config) SetFullFundraiserPath(fullFundraiserPath string)

Set the FullFundraiserPath (BIP44Prefix) on the config

func (*Config) SetTxEncoder

func (config *Config) SetTxEncoder(encoder TxEncoder)

SetTxEncoder builds the Config with TxEncoder used to marshal StdTx to bytes

type ConsAddress

type ConsAddress []byte

ConsAddress defines a wrapper around bytes meant to present a consensus node. When marshaled to a string or JSON, it uses Bech32.

func ConsAddressFromBech32

func ConsAddressFromBech32(address string) (addr ConsAddress, err error)

ConsAddressFromBech32 creates a ConsAddress from a Bech32 string.

func ConsAddressFromHex

func ConsAddressFromHex(address string) (addr ConsAddress, err error)

ConsAddressFromHex creates a ConsAddress from a hex string.

func GetConsAddress

func GetConsAddress(pubkey crypto.PubKey) ConsAddress

get ConsAddress from pubkey

func (ConsAddress) Bytes

func (ca ConsAddress) Bytes() []byte

Bytes returns the raw address bytes.

func (ConsAddress) Empty

func (ca ConsAddress) Empty() bool

Returns boolean for whether an ConsAddress is empty

func (ConsAddress) Equals

func (ca ConsAddress) Equals(ca2 Address) bool

Returns boolean for whether two ConsAddress are Equal

func (ConsAddress) Format

func (ca ConsAddress) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface. nolint: errcheck

func (ConsAddress) Marshal

func (ca ConsAddress) Marshal() ([]byte, error)

Marshal returns the raw address bytes. It is needed for protobuf compatibility.

func (ConsAddress) MarshalJSON

func (ca ConsAddress) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON using Bech32.

func (ConsAddress) MarshalYAML

func (ca ConsAddress) MarshalYAML() (interface{}, error)

MarshalYAML marshals to YAML using Bech32.

func (ConsAddress) String

func (ca ConsAddress) String() string

String implements the Stringer interface.

func (*ConsAddress) Unmarshal

func (ca *ConsAddress) Unmarshal(data []byte) error

Unmarshal sets the address to the given data. It is needed for protobuf compatibility.

func (*ConsAddress) UnmarshalJSON

func (ca *ConsAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.

func (*ConsAddress) UnmarshalYAML

func (ca *ConsAddress) UnmarshalYAML(data []byte) error

UnmarshalYAML unmarshals from YAML assuming Bech32 encoding.

type Error

type Error interface {

	// convenience
	TraceSDK(format string, args ...interface{}) Error

	// set codespace
	WithDefaultCodespace(CodespaceType) Error

	Code() CodeType
	Codespace() CodespaceType
	ABCILog() string
	Result() Result
	QueryResult() abci.ResponseQuery
	// contains filtered or unexported methods
}

sdk Error type

func ErrGasOverflow

func ErrGasOverflow(msg string) Error

func ErrInsufficientCoins

func ErrInsufficientCoins(msg string) Error

func ErrInsufficientFee

func ErrInsufficientFee(msg string) Error

func ErrInsufficientFunds

func ErrInsufficientFunds(msg string) Error

func ErrInternal

func ErrInternal(msg string) Error

nolint

func ErrInvalidAddress

func ErrInvalidAddress(msg string) Error

func ErrInvalidCoins

func ErrInvalidCoins(msg string) Error

func ErrInvalidPubKey

func ErrInvalidPubKey(msg string) Error

func ErrInvalidSequence

func ErrInvalidSequence(msg string) Error

func ErrMemoTooLarge

func ErrMemoTooLarge(msg string) Error

func ErrNoSignatures

func ErrNoSignatures(msg string) Error

func ErrOutOfGas

func ErrOutOfGas(msg string) Error

func ErrTooManySignatures

func ErrTooManySignatures(msg string) Error

func ErrTxDecode

func ErrTxDecode(msg string) Error

func ErrUnauthorized

func ErrUnauthorized(msg string) Error

func ErrUnknownAddress

func ErrUnknownAddress(msg string) Error

func ErrUnknownRequest

func ErrUnknownRequest(msg string) Error

func NewError

func NewError(codespace CodespaceType, code CodeType, format string, args ...interface{}) Error

NewError - create an error.

type Event

type Event abci.Event

Event is a type alias for an ABCI Event

func NewEvent

func NewEvent(ty string, attrs ...Attribute) Event

NewEvent creates a new Event object with a given type and slice of one or more attributes.

func (Event) AppendAttributes

func (e Event) AppendAttributes(attrs ...Attribute) Event

AppendAttributes adds one or more attributes to an Event.

type EventManager

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

EventManager implements a simple wrapper around a slice of Event objects that can be emitted from.

func NewEventManager

func NewEventManager() *EventManager

func (EventManager) ABCIEvents

func (em EventManager) ABCIEvents() []abci.Event

ABCIEvents returns all stored Event objects as abci.Event objects.

func (*EventManager) EmitEvent

func (em *EventManager) EmitEvent(event Event)

EmitEvent stores a single Event object.

func (*EventManager) EmitEvents

func (em *EventManager) EmitEvents(events Events)

EmitEvents stores a series of Event objects.

func (*EventManager) Events

func (em *EventManager) Events() Events

type Events

type Events []Event

Events defines a slice of Event objects

func EmptyEvents

func EmptyEvents() Events

EmptyEvents returns an empty slice of events.

func (Events) AppendEvent

func (e Events) AppendEvent(event Event) Events

AppendEvent adds an Event to a slice of events.

func (Events) AppendEvents

func (e Events) AppendEvents(events Events) Events

AppendEvents adds a slice of Event objects to an exist slice of Event objects.

func (Events) ToABCIEvents

func (e Events) ToABCIEvents() []abci.Event

ToABCIEvents converts a slice of Event objects to a slice of abci.Event objects.

type Msg

type Msg interface {

	// Return the message type.
	// Must be alphanumeric or empty.
	Route() string

	// Returns a human-readable string for the message, intended for utilization
	// within tags
	Type() string

	// ValidateBasic does a simple validation check that
	// doesn't require access to any other information.
	ValidateBasic() Error

	// Get the canonical byte representation of the Msg.
	GetSignBytes() []byte

	// Signers returns the addrs of signers that must sign.
	// CONTRACT: All signatures must be present to be valid.
	// CONTRACT: Returns addrs in some deterministic order.
	GetSigners() []AccAddress
}

Transactions messages must fulfill the Msg

type Result

type Result struct {
	// Code is the response code, is stored back on the chain.
	Code CodeType

	// Codespace is the string referring to the domain of an error
	Codespace CodespaceType

	// Data is any data returned from the app.
	// Data has to be length prefixed in order to separate
	// results from multiple msgs executions
	Data []byte

	// Log contains the txs log information. NOTE: nondeterministic.
	Log string

	// GasWanted is the maximum units of work we allow this tx to perform.
	GasWanted uint64

	// GasUsed is the amount of gas actually consumed. NOTE: unimplemented
	GasUsed uint64

	// Events contains a slice of Event objects that were emitted during some
	// execution.
	Events Events
}

Result is the union of ResponseFormat and ResponseCheckTx.

func (Result) IsOK

func (res Result) IsOK() bool

TODO: In the future, more codes may be OK.

type SearchTxsResult

type SearchTxsResult struct {
	TotalCount int          `json:"total_count"` // Count of all txs
	Count      int          `json:"count"`       // Count of txs in current page
	PageNumber int          `json:"page_number"` // Index of current page, start from 1
	PageTotal  int          `json:"page_total"`  // Count of total pages
	Limit      int          `json:"limit"`       // Max count txs per page
	Txs        []TxResponse `json:"txs"`         // List of txs in current page
}

SearchTxsResult defines a structure for querying txs pageable

func NewSearchTxsResult

func NewSearchTxsResult(totalCount, count, page, limit int, txs []TxResponse) SearchTxsResult

type StringEvent

type StringEvent struct {
	Type       string      `json:"type,omitempty"`
	Attributes []Attribute `json:"attributes,omitempty"`
}

StringAttribute defines en Event object wrapper where all the attributes contain key/value pairs that are strings instead of raw bytes.

func StringifyEvent

func StringifyEvent(e abci.Event) StringEvent

StringifyEvent converts an Event object to a StringEvent object.

type StringEvents

type StringEvents []StringEvent

StringAttributes defines a slice of StringEvents objects.

func StringifyEvents

func StringifyEvents(events []abci.Event) StringEvents

StringifyEvents converts a slice of Event objects into a slice of StringEvent objects.

func (StringEvents) Flatten

func (se StringEvents) Flatten() StringEvents

Flatten returns a flattened version of StringEvents by grouping all attributes per unique event type.

func (StringEvents) String

func (se StringEvents) String() string

type TestMsg

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

msg type for testing

func NewTestMsg

func NewTestMsg(addrs ...AccAddress) *TestMsg

func (*TestMsg) GetSignBytes

func (msg *TestMsg) GetSignBytes() []byte

func (*TestMsg) GetSigners

func (msg *TestMsg) GetSigners() []AccAddress

func (*TestMsg) Route

func (msg *TestMsg) Route() string

nolint

func (*TestMsg) Type

func (msg *TestMsg) Type() string

func (*TestMsg) ValidateBasic

func (msg *TestMsg) ValidateBasic() Error

type Tx

type Tx interface {
	// Gets the all the transaction's messages.
	GetMsgs() []Msg

	// ValidateBasic does a simple and lightweight validation check that doesn't
	// require access to any other information.
	ValidateBasic() Error
}

Transactions objects must fulfill the Tx

type TxDecoder

type TxDecoder func(txBytes []byte) (Tx, Error)

TxDecoder unmarshals transaction bytes

type TxEncoder

type TxEncoder func(tx Tx) ([]byte, error)

TxEncoder marshals transaction to bytes

type TxResponse

type TxResponse struct {
	Height    int64           `json:"height"`
	TxHash    string          `json:"txhash"`
	Code      uint32          `json:"code,omitempty"`
	Data      string          `json:"data,omitempty"`
	RawLog    string          `json:"raw_log,omitempty"`
	Logs      ABCIMessageLogs `json:"logs,omitempty"`
	Info      string          `json:"info,omitempty"`
	GasWanted int64           `json:"gas_wanted,omitempty"`
	GasUsed   int64           `json:"gas_used,omitempty"`
	Codespace string          `json:"codespace,omitempty"`
	Tx        Tx              `json:"tx,omitempty"`
	Timestamp string          `json:"timestamp,omitempty"`

	// DEPRECATED: Remove in the next next major release in favor of using the
	// ABCIMessageLog.Events field.
	Events StringEvents `json:"events,omitempty"`
}

TxResponse defines a structure containing relevant tx data and metadata. The tags are stringified and the log is JSON decoded.

func NewResponseFormatBroadcastTx

func NewResponseFormatBroadcastTx(res *ctypes.ResultBroadcastTx) TxResponse

NewResponseFormatBroadcastTx returns a TxResponse given a ResultBroadcastTx from tendermint

func NewResponseFormatBroadcastTxCommit

func NewResponseFormatBroadcastTxCommit(res *ctypes.ResultBroadcastTxCommit) TxResponse

NewResponseFormatBroadcastTxCommit returns a TxResponse given a ResultBroadcastTxCommit from tendermint.

func NewResponseResultTx

func NewResponseResultTx(res *ctypes.ResultTx, tx Tx, timestamp string) TxResponse

NewResponseResultTx returns a TxResponse given a ResultTx from tendermint

func (TxResponse) Empty

func (r TxResponse) Empty() bool

Empty returns true if the response is empty

func (TxResponse) String

func (r TxResponse) String() string

type ValAddress

type ValAddress []byte

ValAddress defines a wrapper around bytes meant to present a validator's operator. When marshaled to a string or JSON, it uses Bech32.

func ValAddressFromBech32

func ValAddressFromBech32(address string) (addr ValAddress, err error)

ValAddressFromBech32 creates a ValAddress from a Bech32 string.

func ValAddressFromHex

func ValAddressFromHex(address string) (addr ValAddress, err error)

ValAddressFromHex creates a ValAddress from a hex string.

func (ValAddress) Bytes

func (va ValAddress) Bytes() []byte

Bytes returns the raw address bytes.

func (ValAddress) Empty

func (va ValAddress) Empty() bool

Returns boolean for whether an AccAddress is empty

func (ValAddress) Equals

func (va ValAddress) Equals(va2 Address) bool

Returns boolean for whether two ValAddresses are Equal

func (ValAddress) Format

func (va ValAddress) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface. nolint: errcheck

func (ValAddress) Marshal

func (va ValAddress) Marshal() ([]byte, error)

Marshal returns the raw address bytes. It is needed for protobuf compatibility.

func (ValAddress) MarshalJSON

func (va ValAddress) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON using Bech32.

func (ValAddress) MarshalYAML

func (va ValAddress) MarshalYAML() (interface{}, error)

MarshalYAML marshals to YAML using Bech32.

func (ValAddress) String

func (va ValAddress) String() string

String implements the Stringer interface.

func (*ValAddress) Unmarshal

func (va *ValAddress) Unmarshal(data []byte) error

Unmarshal sets the address to the given data. It is needed for protobuf compatibility.

func (*ValAddress) UnmarshalJSON

func (va *ValAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.

func (*ValAddress) UnmarshalYAML

func (va *ValAddress) UnmarshalYAML(data []byte) error

UnmarshalYAML unmarshals from YAML assuming Bech32 encoding.

Jump to

Keyboard shortcuts

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