Documentation
¶
Index ¶
- func CompleteAndBroadcastTxCLI(txBldr auth.TxBuilder, cliCtx CLIContext, msgs []sdk.Msg) (*sdk.TxResponse, error)
- func Paginate(numObjs, page, limit, defLimit int) (start, end int)
- func PrepareTxBuilder(txBldr auth.TxBuilder, cliCtx CLIContext) (auth.TxBuilder, error)
- type BroadcastType
- type CLIContext
- func (ctx CLIContext) BroadcastTx(txBytes []byte) (res sdk.TxResponse, err error)
- func (ctx CLIContext) BroadcastTxAsync(txBytes []byte) (sdk.TxResponse, error)
- func (ctx CLIContext) BroadcastTxCommit(txBytes []byte) (sdk.TxResponse, error)
- func (ctx CLIContext) BroadcastTxSync(txBytes []byte) (sdk.TxResponse, error)
- func (ctx CLIContext) GetFromAddress() sdk.Address
- func (ctx CLIContext) GetNode() (rpcclient.Client, error)
- func (ctx CLIContext) Query(path string) ([]byte, int64, error)
- func (ctx CLIContext) QueryStore(key cmn.HexBytes, storeName string) ([]byte, int64, error)
- func (ctx CLIContext) QuerySubspace(subspace []byte, storeName string) (res []sdk.KVPair, height int64, err error)
- func (ctx CLIContext) QueryWithData(path string, data []byte) ([]byte, int64, error)
- func (ctx CLIContext) WithClient(client rpcclient.Client) CLIContext
- func (ctx CLIContext) WithCodec(cdc *codec.Codec) CLIContext
- func (ctx CLIContext) WithFromAddress(addr sdk.Address) CLIContext
- func (ctx CLIContext) WithHeight(height int64) CLIContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompleteAndBroadcastTxCLI ¶
func CompleteAndBroadcastTxCLI(txBldr auth.TxBuilder, cliCtx CLIContext, msgs []sdk.Msg) (*sdk.TxResponse, error)
CompleteAndBroadcastTxCLI implements a utility function that facilitates sending a series of messages in a signed transaction given a TxBuilder and a QueryContext. It ensures that the account exists, has a proper number and sequence set. In addition, it builds and signs a transaction with the supplied messages. Finally, it broadcasts the signed transaction to a node.
func Paginate ¶
Paginate returns the correct starting and ending index for a paginated query, given that client provides a desired page and limit of objects and the handler provides the total number of objects. If the start page is invalid, non-positive values are returned signaling the request is invalid.
NOTE: The start page is assumed to be 1-indexed.
func PrepareTxBuilder ¶
PrepareTxBuilder populates a TxBuilder in preparation for the build of a Tx.
Types ¶
type BroadcastType ¶
type BroadcastType int
const ( BroadcastSync BroadcastType = iota + 1 BroadcastAsync BroadcastBlock )
type CLIContext ¶
type CLIContext struct { Codec *codec.Codec Client rpcclient.Client FromAddress sdk.Address Passphrase string Height int64 BroadcastMode BroadcastType PrivateKey crypto.PrivateKey }
CLIContext implements a typical CLI context created in SDK modules for transaction handling and queries.
func NewCLIContext ¶
NewCLIContext returns a new initialized CLIContext with parameters from the command line using Viper. It takes a key name or address and populates the FromName and FromAddress field accordingly.
func (CLIContext) BroadcastTx ¶
func (ctx CLIContext) BroadcastTx(txBytes []byte) (res sdk.TxResponse, err error)
--------------------------------------------------------------------------------------------------------------------- BroadcastTx broadcasts a transactions either synchronously or asynchronously based on the context parameters. The result of the broadcast is parsed into an intermediate structure which is logged if the context has a logger defined.
func (CLIContext) BroadcastTxAsync ¶
func (ctx CLIContext) BroadcastTxAsync(txBytes []byte) (sdk.TxResponse, error)
BroadcastTxAsync broadcasts transaction bytes to a Tendermint node asynchronously (i.e. returns immediately).
func (CLIContext) BroadcastTxCommit ¶
func (ctx CLIContext) BroadcastTxCommit(txBytes []byte) (sdk.TxResponse, error)
BroadcastTxCommit broadcasts transaction bytes to a Tendermint node and waits for a commit. An error is only returned if there is no RPC node connection or if broadcasting fails.
NOTE: This should ideally not be used as the request may timeout but the tx may still be included in a block. Use BroadcastTxAsync or BroadcastTxSync instead.
func (CLIContext) BroadcastTxSync ¶
func (ctx CLIContext) BroadcastTxSync(txBytes []byte) (sdk.TxResponse, error)
BroadcastTxSync broadcasts transaction bytes to a Tendermint node synchronously (i.e. returns after CheckTx execution).
func (CLIContext) GetFromAddress ¶
func (ctx CLIContext) GetFromAddress() sdk.Address
GetFromAddress returns the from address from the context's name.
func (CLIContext) GetNode ¶
func (ctx CLIContext) GetNode() (rpcclient.Client, error)
GetNode returns an RPC client. If the context's client is not defined, an error is returned.
func (CLIContext) Query ¶
func (ctx CLIContext) Query(path string) ([]byte, int64, error)
--------------------------------------------------------------------------------------------------------------------- Query performs a query to a Tendermint node with the provided path. It returns the result and height of the query upon success or an error if the query fails.
func (CLIContext) QueryStore ¶
QueryStore performs a query to a Tendermint node with the provided key and store name. It returns the result and height of the query upon success or an error if the query fails.
func (CLIContext) QuerySubspace ¶
func (ctx CLIContext) QuerySubspace(subspace []byte, storeName string) (res []sdk.KVPair, height int64, err error)
QuerySubspace performs a query to a Tendermint node with the provided store name and subspace. It returns key value pair and height of the query upon success or an error if the query fails.
func (CLIContext) QueryWithData ¶
QueryWithData performs a query to a Tendermint node with the provided path and a data payload. It returns the result and height of the query upon success or an error if the query fails.
func (CLIContext) WithClient ¶
func (ctx CLIContext) WithClient(client rpcclient.Client) CLIContext
WithClient returns a copy of the context with an updated RPC client instance.
func (CLIContext) WithCodec ¶
func (ctx CLIContext) WithCodec(cdc *codec.Codec) CLIContext
WithCodec returns a copy of the context with an updated codec.
func (CLIContext) WithFromAddress ¶
func (ctx CLIContext) WithFromAddress(addr sdk.Address) CLIContext
WithFromAddress returns a copy of the context with an updated from account address.
func (CLIContext) WithHeight ¶
func (ctx CLIContext) WithHeight(height int64) CLIContext
WithHeight returns a copy of the context with an updated height.