cosmos-sdk: Index | Files | Directories

package client

import ""


Package Files

query.go rest.go tx.go


var Codec codec.Marshaler

Codec defines the x/auth account codec to be used for use with the AccountRetriever. The application must be sure to set this to their respective codec that implements the Codec interface and must be the same codec that passed to the x/auth module.

TODO:/XXX: Using a package-level global isn't ideal and we should consider refactoring the module manager to allow passing in the correct module codec.

func CalculateGas Uses

func CalculateGas(
    queryFunc func(string, []byte) ([]byte, int64, error), cdc *codec.Codec,
    txBytes []byte, adjustment float64,
) (sdk.SimulationResponse, uint64, error)

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

func CompleteAndBroadcastTxCLI Uses

func CompleteAndBroadcastTxCLI(txBldr authtypes.TxBuilder, clientCtx client.Context, msgs []sdk.Msg) 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 EnrichWithGas Uses

func EnrichWithGas(txBldr authtypes.TxBuilder, clientCtx client.Context, msgs []sdk.Msg) (authtypes.TxBuilder, error)

EnrichWithGas calculates the gas estimate that would be consumed by the transaction and set the transaction's respective value accordingly.

func GenerateOrBroadcastMsgs Uses

func GenerateOrBroadcastMsgs(clientCtx client.Context, txBldr authtypes.TxBuilder, msgs []sdk.Msg) error

GenerateOrBroadcastMsgs creates a StdTx given a series of messages. If the provided context has generate-only enabled, the tx will only be printed to STDOUT in a fully offline manner. Otherwise, the tx will be signed and broadcasted.

func GetTxEncoder Uses

func GetTxEncoder(cdc *codec.Codec) (encoder sdk.TxEncoder)

GetTxEncoder return tx encoder from global sdk configuration if ones is defined. Otherwise returns encoder with default logic.

func PrepareTxBuilder Uses

func PrepareTxBuilder(txBldr authtypes.TxBuilder, clientCtx client.Context) (authtypes.TxBuilder, error)

PrepareTxBuilder populates a TxBuilder in preparation for the build of a Tx.

func PrintUnsignedStdTx Uses

func PrintUnsignedStdTx(txBldr authtypes.TxBuilder, clientCtx client.Context, msgs []sdk.Msg) error

PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout.

func QueryTx Uses

func QueryTx(clientCtx client.Context, hashHexStr string) (sdk.TxResponse, error)

QueryTx queries for a single transaction by a hash string in hex format. An error is returned if the transaction does not exist or cannot be queried.

func QueryTxsByEvents Uses

func QueryTxsByEvents(clientCtx client.Context, events []string, page, limit int, orderBy string) (*sdk.SearchTxsResult, error)

QueryTxsByEvents performs a search for transactions for a given set of events via the Tendermint RPC. An event takes the form of: "{eventAttribute}.{attributeKey} = '{attributeValue}'". Each event is concatenated with an 'AND' operand. It returns a slice of Info object containing txs and metadata. An error is returned if the query fails. If an empty string is provided it will order txs by asc

func ReadTxFromFile Uses

func ReadTxFromFile(ctx client.Context, filename string) (tx sdk.Tx, err error)

Read and decode a StdTx from the given filename. Can pass "-" to read from stdin.

func SignStdTx Uses

func SignStdTx(
    txBldr authtypes.TxBuilder, clientCtx client.Context, name string,
    stdTx authtypes.StdTx, appendSig bool, offline bool,
) (authtypes.StdTx, error)

SignStdTx appends a signature to a StdTx and returns a copy of it. If appendSig is false, it replaces the signatures already attached with the new signature. Don't perform online validation or lookups if offline is true.

func SignStdTxWithSignerAddress Uses

func SignStdTxWithSignerAddress(
    txBldr authtypes.TxBuilder, clientCtx client.Context,
    addr sdk.AccAddress, name string, stdTx authtypes.StdTx, offline bool,
) (signedStdTx authtypes.StdTx, err error)

SignStdTxWithSignerAddress attaches a signature to a StdTx and returns a copy of a it. Don't perform online validation or lookups if offline is true, else populate account and sequence numbers from a foreign account.

func ValidateTxResult Uses

func ValidateTxResult(clientCtx client.Context, resTx *ctypes.ResultTx) error

ValidateTxResult performs transaction verification.

func WriteGenerateStdTxResponse Uses

func WriteGenerateStdTxResponse(w http.ResponseWriter, clientCtx client.Context, br rest.BaseReq, msgs []sdk.Msg)

WriteGenerateStdTxResponse writes response for the generate only mode.

type BatchScanner Uses

type BatchScanner struct {
    // contains filtered or unexported fields

BatchScanner provides a convenient interface for reading batch data such as a file of newline-delimited JSON encoded StdTx.

func NewBatchScanner Uses

func NewBatchScanner(cdc *codec.Codec, r io.Reader) *BatchScanner

NewBatchScanner returns a new BatchScanner to read newline-delimited StdTx transactions from r.

func (*BatchScanner) Scan Uses

func (bs *BatchScanner) Scan() bool

Scan advances the Scanner to the next line.

func (BatchScanner) StdTx Uses

func (bs BatchScanner) StdTx() authtypes.StdTx

StdTx returns the most recent StdTx unmarshalled by a call to Scan.

func (BatchScanner) UnmarshalErr Uses

func (bs BatchScanner) UnmarshalErr() error

UnmarshalErr returns the first unmarshalling error that was encountered by the scanner.

type GasEstimateResponse Uses

type GasEstimateResponse struct {
    GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"`

GasEstimateResponse defines a response definition for tx gas estimation.

func (GasEstimateResponse) String Uses

func (gr GasEstimateResponse) String() string



Package client imports 23 packages (graph) and is imported by 21 packages. Updated 2020-07-10. Refresh now. Tools for package owners.