context

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: Apache-2.0 Imports: 22 Imported by: 3

Documentation

Index

Constants

View Source
const (
	BroadcastSync   = "sync"
	BroadcastAsync  = "async"
	BroadcastBlock  = "block"
	AccountStoreKey = "acc"
)

Variables

View Source
var (
	ErrInvalidSigner = errors.New("Invalid signer")
)

Functions

func ErrInvalidAccount

func ErrInvalidAccount(addr sdk.AccAddress) error

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

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 GetFromFields

func GetFromFields(from string, home string) (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.

Types

type Context

type Context struct {
	Codec         *codec.Codec
	Client        rpcclient.Client
	Keybase       cryptokeys.Keybase
	Output        io.Writer
	OutputFormat  string
	Height        int64
	NodeURI       string
	From          string
	AccountStore  string
	TrustNode     bool
	UseLedger     bool
	BroadcastMode string
	PrintResponse bool

	VerifierHome string
	Simulate     bool
	GenerateOnly bool
	FromAddress  sdk.AccAddress
	FromName     string
	Indent       bool
	SkipConfirm  bool
	Home         string
	Passphrase   string
	PrivKey      crypto.PrivKey
	// contains filtered or unexported fields
}

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

func NewContext

func NewContext(chainID string, nodeURI string, home string) (*Context, error)

NewContext returns a new initialized Context

func NewContextWithDelay

func NewContextWithDelay(chainID string, nodeURI string, home string) (*Context, error)

func (Context) BroadcastTx

func (ctx Context) 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 (Context) BroadcastTxAsync

func (ctx Context) BroadcastTxAsync(txBytes []byte) (sdk.TxResponse, error)

BroadcastTxAsync broadcasts transaction bytes to a Tendermint node asynchronously (i.e. returns immediately).

func (Context) BroadcastTxCommit

func (ctx Context) BroadcastTxCommit(txBytes []byte) (sdk.TxResponse, error)

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

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 (Context) BroadcastTxSync

func (ctx Context) BroadcastTxSync(txBytes []byte) (sdk.TxResponse, error)

BroadcastTxSync broadcasts transaction bytes to a Tendermint node synchronously (i.e. returns after CheckTx execution).

func (Context) EnsureAccountExists

func (ctx Context) EnsureAccountExists() error

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

func (Context) EnsureAccountExistsFromAddr

func (ctx Context) 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 (Context) GetFromAddress

func (ctx Context) GetFromAddress() sdk.AccAddress

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

func (Context) GetFromName

func (ctx Context) GetFromName() string

GetFromName returns the key name for the current context.

func (Context) GetNode

func (ctx Context) GetNode() (rpcclient.Client, error)

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

func (*Context) GetVerifier

func (ctx *Context) GetVerifier() tmlite.Verifier

func (*Context) PrintOutput

func (ctx *Context) 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 (Context) Query

func (ctx Context) Query(path string, data cmn.HexBytes) ([]byte, int64, error)

Query performs a query for information about the connected node.

func (Context) QueryStore

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

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

func (Context) QuerySubspace

func (ctx Context) 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 (Context) QueryWithData

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

Query information about the connected node with a data payload

func (*Context) Verify

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

Verify verifies the consensus proof at given height.

func (*Context) WithAccountStore

func (ctx *Context) WithAccountStore(accountStore string) *Context

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

func (*Context) WithBroadcastMode

func (ctx *Context) WithBroadcastMode(mode string) *Context

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

func (*Context) WithClient

func (ctx *Context) WithClient(client rpcclient.Client) *Context

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

func (*Context) WithCodec

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

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

func (*Context) WithFrom

func (ctx *Context) WithFrom(from string) *Context

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

func (*Context) WithFromAddress

func (ctx *Context) WithFromAddress(addr sdk.AccAddress) *Context

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

func (*Context) WithFromName

func (ctx *Context) WithFromName(name string) *Context

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

func (*Context) WithGenerateOnly

func (ctx *Context) WithGenerateOnly(generateOnly bool) *Context

WithGenerateOnly returns a copy of the context with updated GenerateOnly value

func (*Context) WithHeight

func (ctx *Context) WithHeight(height int64) *Context

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

func (*Context) WithHome

func (ctx *Context) WithHome(home string) *Context

WithHome returns a copy of the context with an updated home.

func (*Context) WithNodeURI

func (ctx *Context) WithNodeURI(nodeURI string) *Context

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

func (*Context) WithOutput

func (ctx *Context) WithOutput(w io.Writer) *Context

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

func (*Context) WithPassphrase

func (ctx *Context) WithPassphrase(passphrase string) *Context

WithPassphrase returns a copy of the context with an passphrase for signing tx.

func (*Context) WithPrivKey

func (ctx *Context) WithPrivKey(privKey crypto.PrivKey) *Context

WithPassphrase returns a copy of the context with an private key for signing tx.

func (*Context) WithSimulation

func (ctx *Context) WithSimulation(simulate bool) *Context

WithSimulation returns a copy of the context with updated Simulate value

func (*Context) WithTrustNode

func (ctx *Context) WithTrustNode(trustNode bool) *Context

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

func (*Context) WithUseLedger

func (ctx *Context) WithUseLedger(useLedger bool) *Context

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

func (*Context) WithVerifier

func (ctx *Context) WithVerifier(verifier tmlite.Verifier) *Context

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

type QueryAccountParams

type QueryAccountParams struct {
	Address sdk.AccAddress
}

Jump to

Keyboard shortcuts

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