v1beta3

package
v0.0.2-rc3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 47 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// BroadcastSync defines a tx broadcasting mode where the client waits for
	// a CheckTx execution response only.
	BroadcastSync = "sync"
	// BroadcastAsync defines a tx broadcasting mode where the client returns
	// immediately.
	BroadcastAsync = "async"

	BroadcastBlock = "block"

	BroadcastDefaultTimeout    = 30 * time.Second
	BroadcastBlockRetryTimeout = 300 * time.Second
)

Variables

View Source
var (
	// ErrClientNotFound is a new error with message "Client not found"
	ErrClientNotFound = errors.New("client not found")
	ErrNodeNotSynced  = errors.New("rpc node is not catching up")
)
View Source
var (
	ErrNotRunning       = errors.New("tx client: not running")
	ErrSyncTimedOut     = errors.New("tx client: timed-out waiting for sequence sync")
	ErrNodeCatchingUp   = errors.New("tx client: cannot sync from catching up node")
	ErrSimulateOffline  = errors.New("tx client: cannot simulate tx in offline mode")
	ErrBroadcastOffline = errors.New("tx client: cannot broadcast tx in offline mode")
	ErrTxCanceledByUser = errors.New("tx client: transaction declined by user input")
)

Functions

func CalculateGas

func CalculateGas(
	ctx context.Context,
	clientCtx gogogrpc.ClientConn,
	txf clienttx.Factory,
	msgs ...sdk.Msg,
) (*ttx.SimulateResponse, uint64, error)

CalculateGas simulates the execution of a transaction and returns the simulation response obtained by the query and the adjusted gas amount.

func CheckTendermintError

func CheckTendermintError(err error, tx cbtypes.Tx) *sdk.TxResponse

CheckTendermintError checks if the error returned from BroadcastTx is a Tendermint error that is returned before the tx is submitted due to precondition checks that failed. If an Tendermint error is detected, this function returns the correct code back in TxResponse.

TODO: Avoid brittle string matching in favor of error matching. This requires a change to Tendermint's RPCError type to allow retrieval or matching against a concrete error type.

func NewResponseFormatBroadcastTxCommit

func NewResponseFormatBroadcastTxCommit(res *cbcoretypes.ResultBroadcastTxCommit) *sdk.TxResponse

NewResponseFormatBroadcastTxCommit returns a TxResponse given a ResultBroadcastTxCommit from tendermint.

func ParseABCILogs

func ParseABCILogs(logs string) (res sdk.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.

Types

type BroadcastOption

type BroadcastOption func(*BroadcastOptions) error

BroadcastOption is a function that takes as first argument a pointer to BroadcastOptions and returns an error if the option cannot be configured. A number of BroadcastOption functions are available in this package.

func WithBroadcastMode

func WithBroadcastMode(val string) BroadcastOption

WithBroadcastMode returns a BroadcastOption that sets the broadcast for particular tx

func WithBroadcastTimeout

func WithBroadcastTimeout(val time.Duration) BroadcastOption

WithBroadcastTimeout returns a BroadcastOption that sets the timeout configuration for the transaction.

func WithConfirmFn

func WithConfirmFn(val ConfirmFn) BroadcastOption

WithConfirmFn returns a BroadcastOption that sets the ConfirmFn function configuration for the transaction.

func WithFees

func WithFees(val string) BroadcastOption

WithFees returns a BroadcastOption that sets the fees configuration for the transaction.

func WithGas

func WithGas(val cltypes.GasSetting) BroadcastOption

WithGas returns a BroadcastOption that sets the gas setting configuration for the transaction.

func WithGasAdjustment

func WithGasAdjustment(val float64) BroadcastOption

WithGasAdjustment returns a BroadcastOption that sets the gas adjustment configuration for the transaction.

func WithGasPrices

func WithGasPrices(val string) BroadcastOption

WithGasPrices returns a BroadcastOption that sets the gas price configuration for the transaction. Gas price is a string of the amount. E.g. "0.25uakt".

func WithNote

func WithNote(val string) BroadcastOption

WithNote returns a BroadcastOption that sets the note configuration for the transaction.

func WithResultCodeAsError

func WithResultCodeAsError() BroadcastOption

WithResultCodeAsError returns a BroadcastOption that enables the result code as error configuration for the transaction.

func WithSkipConfirm

func WithSkipConfirm(val bool) BroadcastOption

WithSkipConfirm returns a BroadcastOption that sets whether to skip or not the confirmation for the transaction.

func WithTimeoutHeight

func WithTimeoutHeight(val uint64) BroadcastOption

WithTimeoutHeight returns a BroadcastOption that sets the timeout height configuration for the transaction.

type BroadcastOptions

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

BroadcastOptions defines the options allowed to configure a transaction broadcast.

type Client

type Client interface {
	LightClient
	Tx() TxClient
}

Client is the umbrella interface that exposes every other client's modules.

func NewClient

func NewClient(ctx context.Context, cctx sdkclient.Context, opts ...cltypes.ClientOption) (Client, error)

NewClient creates a new client.

type ClientOption

type ClientOption func(*ClientOptions) *ClientOptions

type ClientOptions

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

type ConfirmFn

type ConfirmFn func(string) (bool, error)

type LightClient

type LightClient interface {
	Query() QueryClient
	Node() NodeClient
	ClientContext() sdkclient.Context
	PrintMessage(interface{}) error
}

LightClient is the umbrella interface that exposes every other client's modules.

func NewLightClient

func NewLightClient(cctx sdkclient.Context) (LightClient, error)

NewLightClient creates a new client.

type NodeClient

type NodeClient interface {
	SyncInfo(context.Context) (*tmrpc.SyncInfo, error)
	CurrentBlockHeight(context.Context) (int64, error)
}

type QueryClient

type QueryClient interface {
	Deployment() dtypes.QueryClient
	Market() mtypes.QueryClient
	Provider() ptypes.QueryClient
	Audit() atypes.QueryClient
	Certs() ctypes.QueryClient
	Auth() authtypes.QueryClient
	Authz() authz.QueryClient
	Bank() banktypes.QueryClient
	Distribution() disttypes.QueryClient
	Evidence() evdtypes.QueryClient
	Feegrant() feegranttypes.QueryClient
	GovLegacy() govtypes.QueryClient
	Gov() v1.QueryClient
	Mint() minttypes.QueryClient
	Slashing() slashtypes.QueryClient
	Staking() staketypes.QueryClient
	Upgrade() upgradetypes.QueryClient
	Params() paramstypes.QueryClient

	ClientContext() sdkclient.Context
}

QueryClient is the interface that exposes query modules.

func NewQueryClient

func NewQueryClient(cctx sdkclient.Context) QueryClient

NewQueryClient creates new query client instance based on a Cosmos SDK client context.

type TxClient

type TxClient interface {
	BroadcastMsgs(context.Context, []sdk.Msg, ...BroadcastOption) (interface{}, error)
	BroadcastTx(context.Context, sdk.Tx, ...BroadcastOption) (interface{}, error)
}

TxClient is the interface that wraps the Broadcast method. Broadcast broadcasts a transaction. A transaction is composed of 1 or many messages. This allows several operations to be performed in a single transaction. A transaction broadcast can be configured with an arbitrary number of BroadcastOption.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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