cosmos-sdk: github.com/cosmos/cosmos-sdk/client/context Index | Files

package context

import "github.com/cosmos/cosmos-sdk/client/context"

Index

Package Files

broadcast.go context.go errors.go query.go

func ErrInvalidAccount Uses

func ErrInvalidAccount(addr sdk.AccAddress) error

ErrInvalidAccount returns a standardized error reflecting that a given account address does not exist.

func ErrVerifyCommit Uses

func ErrVerifyCommit(height int64) error

ErrVerifyCommit returns a common error reflecting that the blockchain commit at a given height can't be verified. The reason is that the base checkpoint of the certifier is newer than the given height

func GetFromFields Uses

func GetFromFields(from string, genOnly bool) (sdk.AccAddress, string, error)

GetFromFields returns a from account address and Keybase name given either an address or key name. If genOnly is true, only a valid Bech32 cosmos address is returned.

type CLIContext Uses

type CLIContext struct {
    Codec         *codec.Codec
    Client        rpcclient.Client
    Keybase       cryptokeys.Keybase
    Output        io.Writer
    OutputFormat  string
    Height        int64
    NodeURI       string
    From          string
    TrustNode     bool
    UseLedger     bool
    BroadcastMode string
    Verifier      tmlite.Verifier
    VerifierHome  string
    Simulate      bool
    GenerateOnly  bool
    FromAddress   sdk.AccAddress
    FromName      string
    Indent        bool
    SkipConfirm   bool
}

CLIContext implements a typical CLI context created in SDK modules for transaction handling and queries.

func NewCLIContext Uses

func NewCLIContext() CLIContext

NewCLIContext returns a new initialized CLIContext with parameters from the command line using Viper.

func NewCLIContextWithFrom Uses

func NewCLIContextWithFrom(from string) CLIContext

NewCLIContextWithFrom 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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (ctx CLIContext) GetFromAddress() sdk.AccAddress

GetFromAddress returns the from address from the context's name.

func (CLIContext) GetFromName Uses

func (ctx CLIContext) GetFromName() string

GetFromName returns the key name for the current context.

func (CLIContext) GetNode Uses

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) PrintOutput Uses

func (ctx CLIContext) PrintOutput(toPrint fmt.Stringer) (err error)

PrintOutput prints output while respecting output and indent flags NOTE: pass in marshalled structs that have been unmarshaled because this function will panic on marshaling errors

func (CLIContext) Query Uses

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 Uses

func (ctx CLIContext) QueryStore(key cmn.HexBytes, storeName string) ([]byte, int64, error)

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 Uses

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 Uses

func (ctx CLIContext) QueryWithData(path string, data []byte) ([]byte, int64, error)

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) Verify Uses

func (ctx CLIContext) Verify(height int64) (tmtypes.SignedHeader, error)

Verify verifies the consensus proof at given height.

func (CLIContext) WithBroadcastMode Uses

func (ctx CLIContext) WithBroadcastMode(mode string) CLIContext

WithBroadcastMode returns a copy of the context with an updated broadcast mode.

func (CLIContext) WithClient Uses

func (ctx CLIContext) WithClient(client rpcclient.Client) CLIContext

WithClient returns a copy of the context with an updated RPC client instance.

func (CLIContext) WithCodec Uses

func (ctx CLIContext) WithCodec(cdc *codec.Codec) CLIContext

WithCodec returns a copy of the context with an updated codec.

func (CLIContext) WithFrom Uses

func (ctx CLIContext) WithFrom(from string) CLIContext

WithFrom returns a copy of the context with an updated from address or name.

func (CLIContext) WithFromAddress Uses

func (ctx CLIContext) WithFromAddress(addr sdk.AccAddress) CLIContext

WithFromAddress returns a copy of the context with an updated from account address.

func (CLIContext) WithFromName Uses

func (ctx CLIContext) WithFromName(name string) CLIContext

WithFromName returns a copy of the context with an updated from account name.

func (CLIContext) WithGenerateOnly Uses

func (ctx CLIContext) WithGenerateOnly(generateOnly bool) CLIContext

WithGenerateOnly returns a copy of the context with updated GenerateOnly value

func (CLIContext) WithHeight Uses

func (ctx CLIContext) WithHeight(height int64) CLIContext

WithHeight returns a copy of the context with an updated height.

func (CLIContext) WithNodeURI Uses

func (ctx CLIContext) WithNodeURI(nodeURI string) CLIContext

WithNodeURI returns a copy of the context with an updated node URI.

func (CLIContext) WithOutput Uses

func (ctx CLIContext) WithOutput(w io.Writer) CLIContext

WithOutput returns a copy of the context with an updated output writer (e.g. stdout).

func (CLIContext) WithSimulation Uses

func (ctx CLIContext) WithSimulation(simulate bool) CLIContext

WithSimulation returns a copy of the context with updated Simulate value

func (CLIContext) WithTrustNode Uses

func (ctx CLIContext) WithTrustNode(trustNode bool) CLIContext

WithTrustNode returns a copy of the context with an updated TrustNode flag.

func (CLIContext) WithUseLedger Uses

func (ctx CLIContext) WithUseLedger(useLedger bool) CLIContext

WithUseLedger returns a copy of the context with an updated UseLedger flag.

func (CLIContext) WithVerifier Uses

func (ctx CLIContext) WithVerifier(verifier tmlite.Verifier) CLIContext

WithVerifier - return a copy of the context with an updated Verifier

Package context imports 25 packages (graph) and is imported by 80 packages. Updated 2019-08-15. Refresh now. Tools for package owners.