context

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrInvalidAccount

func ErrInvalidAccount(addr sdk.AccAddress) error

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

func ErrInvalidBaseTx

func ErrInvalidBaseTx(errMsg string) error

ErrInvalidBaseTx returns a common error reflecting the failed BaseTx verification result

func ErrVerifyCommit

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 MakeSignature added in v0.7.0

func MakeSignature(name, passphrase string, msg authtxb.StdSignMsg) (sig auth.StdSignature, err error)

MakeSignature builds a StdSignature given key name, passphrase, and a StdSignMsg.

Types

type BaseTx

type BaseTx struct {
	Name          string `json:"name"`
	Password      string `json:"password"`
	ChainID       string `json:"chain_id"`
	AccountNumber int64  `json:"account_number"`
	Sequence      int64  `json:"sequence"`
	Gas           string `json:"gas"`
	GasAdjustment string `json:"gas_adjustment"`
	Fee           string `json:"fee"`
}

BaseReq defines a structure that can be embedded in other request structures that all share common "base" fields.

func (BaseTx) Sanitize added in v0.7.0

func (br BaseTx) Sanitize() BaseTx

Sanitize performs basic sanitization on a BaseReq object.

func (BaseTx) ValidateBasic added in v0.7.0

func (br BaseTx) ValidateBasic(w http.ResponseWriter, cliCtx CLIContext) bool

ValidateBasic performs basic validation of a BaseReq. If custom validation logic is needed, the implementing request handler should perform those checks manually.

type CLIContext

type CLIContext struct {
	Codec         *codec.Codec
	AccDecoder    auth.AccountDecoder
	Client        rpcclient.Client
	Logger        io.Writer
	Height        int64
	NodeURI       string
	AccountStore  string
	TrustNode     bool
	UseLedger     bool
	Async         bool
	JSON          bool
	PrintResponse bool
	Verifier      tmlite.Verifier
	GenerateOnly  bool

	Indent bool
	DryRun bool
	// contains filtered or unexported fields
}

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

func NewCLIContext

func NewCLIContext() CLIContext

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

func (CLIContext) BroadcastTx

func (cliCtx CLIContext) BroadcastTx(txBytes []byte) (*ctypes.ResultBroadcastTxCommit, 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) BroadcastTxAndAwaitCommit added in v0.7.0

func (cliCtx CLIContext) BroadcastTxAndAwaitCommit(tx []byte) (*ctypes.ResultBroadcastTxCommit, error)

BroadcastTxAndAwaitCommit broadcasts transaction bytes to a Tendermint node and waits for a commit.

func (CLIContext) BroadcastTxAsync

func (cliCtx CLIContext) BroadcastTxAsync(tx []byte) (*ctypes.ResultBroadcastTx, error)

BroadcastTxAsync broadcasts transaction bytes to a Tendermint node asynchronously.

func (CLIContext) BroadcastTxSync added in v0.7.0

func (cliCtx CLIContext) BroadcastTxSync(tx []byte) (*ctypes.ResultBroadcastTx, error)

BroadcastTxSync broadcasts transaction bytes to a Tendermint node synchronously.

func (CLIContext) ConvertCoinToMainUnit

func (cliCtx CLIContext) ConvertCoinToMainUnit(coinsStr string) (coins []string, err error)

func (CLIContext) EnsureAccountExists

func (cliCtx CLIContext) EnsureAccountExists() error

EnsureAccountExists ensures that an account exists for a given context. An error is returned if it does not.

func (CLIContext) EnsureAccountExistsFromAddr

func (cliCtx CLIContext) EnsureAccountExistsFromAddr(addr sdk.AccAddress) error

EnsureAccountExistsFromAddr ensures that an account exists for a given address. Instead of using the context's from name, a direct address is given. An error is returned if it does not.

func (CLIContext) GetAccount

func (cliCtx CLIContext) GetAccount(address []byte) (auth.Account, error)

GetAccount queries for an account given an address and a block height. An error is returned if the query or decoding fails.

func (CLIContext) GetAccountNumber

func (cliCtx CLIContext) GetAccountNumber(address []byte) (int64, error)

GetAccountNumber returns the next account number for the given account address.

func (CLIContext) GetAccountSequence

func (cliCtx CLIContext) GetAccountSequence(address []byte) (int64, error)

GetAccountSequence returns the sequence number for the given account address.

func (CLIContext) GetCoinType

func (cliCtx CLIContext) GetCoinType(coinName string) (types.CoinType, error)

func (CLIContext) GetFromAddress

func (cliCtx CLIContext) GetFromAddress() (sdk.AccAddress, error)

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

func (CLIContext) GetFromName added in v0.7.0

func (cliCtx CLIContext) GetFromName() (string, error)

GetFromName returns the key name for the current context.

func (CLIContext) GetNode

func (cliCtx CLIContext) GetNode() (rpcclient.Client, error)

GetNode returns an RPC client. If the context's client is not defined, an error is returned.

func (CLIContext) NetInfo

func (cliCtx CLIContext) NetInfo() (*ctypes.ResultNetInfo, error)

func (CLIContext) NumUnconfirmedTxs

func (cliCtx CLIContext) NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error)

func (CLIContext) ParseCoin

func (cliCtx CLIContext) ParseCoin(coinStr string) (sdk.Coin, error)

func (CLIContext) ParseCoins

func (cliCtx CLIContext) ParseCoins(coinsStr string) (coins sdk.Coins, err error)

func (CLIContext) Query

func (cliCtx CLIContext) Query(path string, data cmn.HexBytes) (res []byte, err error)

Query performs a query for information about the connected node.

func (CLIContext) QueryStore

func (cliCtx CLIContext) QueryStore(key cmn.HexBytes, storeName string) (res []byte, err error)

QueryStore performs a query from a Tendermint node with the provided key and store name.

func (CLIContext) QuerySubspace

func (cliCtx CLIContext) QuerySubspace(subspace []byte, storeName string) (res []sdk.KVPair, err error)

QuerySubspace performs a query from a Tendermint node with the provided store name and subspace.

func (CLIContext) QueryWithData added in v0.7.0

func (cliCtx CLIContext) QueryWithData(path string, data []byte) (res []byte, err error)

Query information about the connected node with a data payload

func (CLIContext) Verify added in v0.7.0

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

Verify verifies the consensus proof at given height.

func (CLIContext) WithAccountDecoder

func (ctx CLIContext) WithAccountDecoder(decoder auth.AccountDecoder) CLIContext

WithAccountDecoder returns a copy of the context with an updated account decoder.

func (CLIContext) WithAccountStore

func (ctx CLIContext) WithAccountStore(accountStore string) CLIContext

WithAccountStore returns a copy of the context with an updated AccountStore.

func (CLIContext) WithCertifier

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

WithCertifier - return a copy of the context with an updated Certifier

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) WithLogger

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

WithLogger returns a copy of the context with an updated logger.

func (CLIContext) WithNodeURI

func (ctx CLIContext) WithNodeURI(nodeURI string) CLIContext

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

func (CLIContext) WithTrustNode

func (ctx CLIContext) WithTrustNode(trustNode bool) CLIContext

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

func (CLIContext) WithUseLedger

func (ctx CLIContext) WithUseLedger(useLedger bool) CLIContext

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

type TxContext

type TxContext struct {
	Codec *codec.Codec

	AccountNumber int64
	Sequence      int64
	Gas           int64 // TODO: should this turn into uint64? requires further discussion - see #2173
	GasAdjustment float64
	SimulateGas   bool
	ChainID       string
	Memo          string
	Fee           string
	// contains filtered or unexported fields
}

TxContext implements a transaction context created in SDK modules.

func NewTxContextFromCLI

func NewTxContextFromCLI() TxContext

NewTxBuilderFromCLI returns a new initialized TxContext with parameters from the command line using Viper.

func (TxContext) Build

func (txCtx TxContext) Build(msgs []sdk.Msg) (authtxb.StdSignMsg, error)

Build builds a single message to be signed from a TxContext given a set of messages. It returns an error if a fee is supplied but cannot be parsed.

func (TxContext) BuildAndSign

func (txCtx TxContext) BuildAndSign(name, passphrase string, msgs []sdk.Msg) ([]byte, error)

BuildAndSign builds a single message to be signed, and signs a transaction with the built message given a name, passphrase, and a set of messages.

func (TxContext) BuildWithPubKey added in v0.7.0

func (txCtx TxContext) BuildWithPubKey(name string, msgs []sdk.Msg) ([]byte, error)

BuildWithPubKey builds a single message to be signed from a TxContext given a set of messages and attach the public key associated to the given name. It returns an error if a fee is supplied but cannot be parsed or the key cannot be retrieved.

func (TxContext) Sign

func (txCtx TxContext) Sign(name, passphrase string, msg authtxb.StdSignMsg) ([]byte, error)

Sign signs a transaction given a name, passphrase, and a single message to signed. An error is returned if signing fails.

func (TxContext) SignStdTx added in v0.7.0

func (txCtx TxContext) SignStdTx(name, passphrase string, stdTx auth.StdTx, appendSig bool) (signedStdTx auth.StdTx, err error)

SignStdTx appends a signature to a StdTx and returns a copy of a it. If append is false, it replaces the signatures already attached with the new signature.

func (TxContext) WithAccountNumber

func (txCtx TxContext) WithAccountNumber(accnum int64) TxContext

WithAccountNumber returns a copy of the context with an account number.

func (TxContext) WithChainID

func (txCtx TxContext) WithChainID(chainID string) TxContext

WithChainID returns a copy of the context with an updated chainID.

func (TxContext) WithCliCtx

func (txCtx TxContext) WithCliCtx(ctx CLIContext) TxContext

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

func (TxContext) WithCodec

func (txCtx TxContext) WithCodec(cdc *codec.Codec) TxContext

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

func (TxContext) WithFee

func (txCtx TxContext) WithFee(fee string) TxContext

WithFee returns a copy of the context with an updated fee.

func (TxContext) WithGas

func (txCtx TxContext) WithGas(gas int64) TxContext

WithGas returns a copy of the context with an updated gas.

func (TxContext) WithMemo

func (txCtx TxContext) WithMemo(memo string) TxContext

WithMemo returns a copy of the context with an updated memo.

func (TxContext) WithSequence

func (txCtx TxContext) WithSequence(sequence int64) TxContext

WithSequence returns a copy of the context with an updated sequence number.

Jump to

Keyboard shortcuts

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