Documentation ¶
Index ¶
- func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error
- func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error)
- func BuildUnsignedTx(txf Factory, msgs ...sdk.Msg) (client.TxBuilder, error)
- func CalculateGas(queryFunc func(string, []byte) ([]byte, int64, error), txf Factory, ...) (tx.SimulateResponse, uint64, error)
- func ConvertAndEncodeStdTx(txConfig client.TxConfig, stdTx legacytx.StdTx) ([]byte, error)
- func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (legacytx.StdTx, error)
- func CopyTx(tx signing.Tx, builder client.TxBuilder, ignoreSignatureError bool) error
- func GenerateOrBroadcastTxCLI(clientCtx client.Context, flagSet *pflag.FlagSet, msgs ...sdk.Msg) error
- func GenerateOrBroadcastTxWithFactory(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error
- func GenerateTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error
- func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig bool) error
- func SignWithPrivKey(signMode signing.SignMode, signerData authsigning.SignerData, ...) (signing.SignatureV2, error)
- func WriteGeneratedTxResponse(ctx client.Context, w http.ResponseWriter, br rest.BaseReq, msgs ...sdk.Msg)
- type Factory
- func (f Factory) AccountRetriever() client.AccountRetriever
- func (f Factory) ChainID() string
- func (f Factory) Fees() sdk.Coins
- func (f Factory) Gas() uint64
- func (f Factory) GasAdjustment() float64
- func (f Factory) GasPrices() sdk.DecCoins
- func (f Factory) Keybase() keyring.Keyring
- func (f Factory) Memo() string
- func (f Factory) Sequence() uint64
- func (f Factory) SigBlockHeight() uint64
- func (f Factory) SignMode() signing.SignMode
- func (f Factory) SimulateAndExecute() bool
- func (f Factory) TimeoutHeight() uint64
- func (f Factory) WithAccountRetriever(ar client.AccountRetriever) Factory
- func (f Factory) WithChainID(chainID string) Factory
- func (f Factory) WithFees(fees string) Factory
- func (f Factory) WithGas(gas uint64) Factory
- func (f Factory) WithGasAdjustment(gasAdj float64) Factory
- func (f Factory) WithGasPrices(gasPrices string) Factory
- func (f Factory) WithKeybase(keybase keyring.Keyring) Factory
- func (f Factory) WithMemo(memo string) Factory
- func (f Factory) WithSequence(sequence uint64) Factory
- func (f Factory) WithSigBlockHeight(sigBlockHeight uint64) Factory
- func (f Factory) WithSignMode(mode signing.SignMode) Factory
- func (f Factory) WithSimulateAndExecute(sim bool) Factory
- func (f Factory) WithTimeoutHeight(height uint64) Factory
- func (f Factory) WithTxConfig(g client.TxConfig) Factory
- type GasEstimateResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastTx ¶ added in v0.43.0
BroadcastTx attempts to generate, sign and broadcast a transaction with the given set of messages. It will also simulate gas requirements if necessary. It will return an error upon failure.
func BuildSimTx ¶ added in v0.43.0
BuildSimTx creates an unsigned tx with an empty single signature and returns the encoded transaction or an error if the unsigned transaction cannot be built.
func BuildUnsignedTx ¶ added in v0.43.0
BuildUnsignedTx builds a transaction to be signed given a set of messages. The transaction is initially created via the provided factory's generator. Once created, the fee, memo, and messages are set.
func CalculateGas ¶ added in v0.43.0
func CalculateGas( queryFunc func(string, []byte) ([]byte, int64, error), txf Factory, msgs ...sdk.Msg, ) (tx.SimulateResponse, uint64, error)
CalculateGas simulates the execution of a transaction and returns the simulation response obtained by the query and the adjusted gas amount.
func ConvertAndEncodeStdTx ¶ added in v0.43.0
ConvertAndEncodeStdTx encodes the stdTx as a transaction in the format specified by txConfig
func ConvertTxToStdTx ¶ added in v0.43.0
ConvertTxToStdTx converts a transaction to the legacy StdTx format
func CopyTx ¶ added in v0.43.0
CopyTx copies a Tx to a new TxBuilder, allowing conversion between different transaction formats. If ignoreSignatureError is true, copying will continue tx even if the signature cannot be set in the target builder resulting in an unsigned tx.
func GenerateOrBroadcastTxCLI ¶ added in v0.43.0
func GenerateOrBroadcastTxCLI(clientCtx client.Context, flagSet *pflag.FlagSet, msgs ...sdk.Msg) error
GenerateOrBroadcastTxCLI will either generate and print and unsigned transaction or sign it and broadcast it returning an error upon failure.
func GenerateOrBroadcastTxWithFactory ¶ added in v0.43.0
GenerateOrBroadcastTxWithFactory will either generate and print and unsigned transaction or sign it and broadcast it returning an error upon failure.
func GenerateTx ¶ added in v0.43.0
GenerateTx will generate an unsigned transaction and print it to the writer specified by ctx.Output. If simulation was requested, the gas will be simulated and also printed to the same writer before the transaction is printed.
func Sign ¶ added in v0.43.0
Sign signs a given tx with a named key. The bytes signed over are canconical. The resulting signature will be added to the transaction builder overwriting the previous ones if overwrite=true (otherwise, the signature will be appended). Signing a transaction with mutltiple signers in the DIRECT mode is not supprted and will return an error. An error is returned upon failure.
func SignWithPrivKey ¶ added in v0.43.0
func SignWithPrivKey( signMode signing.SignMode, signerData authsigning.SignerData, txBuilder client.TxBuilder, priv cryptotypes.PrivKey, txConfig client.TxConfig, accSeq uint64, ) (signing.SignatureV2, error)
SignWithPrivKey signs a given tx with the given private key, and returns the corresponding SignatureV2 if the signing is successful.
func WriteGeneratedTxResponse ¶ added in v0.43.0
func WriteGeneratedTxResponse( ctx client.Context, w http.ResponseWriter, br rest.BaseReq, msgs ...sdk.Msg, )
WriteGeneratedTxResponse writes a generated unsigned transaction to the provided http.ResponseWriter. It will simulate gas costs if requested by the BaseReq. Upon any error, the error will be written to the http.ResponseWriter. Note that this function returns the legacy StdTx Amino JSON format for compatibility with legacy clients.
Types ¶
type Factory ¶ added in v0.43.0
type Factory struct {
// contains filtered or unexported fields
}
Factory defines a client transaction factory that facilitates generating and signing an application-specific transaction.
func NewFactoryCLI ¶ added in v0.43.0
NewFactoryCLI creates a new Factory.
func PrepareFactory ¶ added in v0.43.0
PrepareFactory set sig block height and account sequence to the tx factory. It doesn't require that the account should exist. If the account does not exist, then it use the zero sequence number.
func (Factory) AccountRetriever ¶ added in v0.43.0
func (f Factory) AccountRetriever() client.AccountRetriever
func (Factory) GasAdjustment ¶ added in v0.43.0
func (Factory) SigBlockHeight ¶ added in v0.43.0
func (Factory) SimulateAndExecute ¶ added in v0.43.0
SimulateAndExecute returns the option to simulate and then execute the transaction using the gas from the simulation results
func (Factory) TimeoutHeight ¶ added in v0.43.0
func (Factory) WithAccountRetriever ¶ added in v0.43.0
func (f Factory) WithAccountRetriever(ar client.AccountRetriever) Factory
WithAccountRetriever returns a copy of the Factory with an updated AccountRetriever.
func (Factory) WithChainID ¶ added in v0.43.0
WithChainID returns a copy of the Factory with an updated chainID.
func (Factory) WithFees ¶ added in v0.43.0
WithFees returns a copy of the Factory with an updated fee.
func (Factory) WithGas ¶ added in v0.43.0
WithGas returns a copy of the Factory with an updated gas value.
func (Factory) WithGasAdjustment ¶ added in v0.43.0
WithGasAdjustment returns a copy of the Factory with an updated gas adjustment.
func (Factory) WithGasPrices ¶ added in v0.43.0
WithGasPrices returns a copy of the Factory with updated gas prices.
func (Factory) WithKeybase ¶ added in v0.43.0
WithKeybase returns a copy of the Factory with updated Keybase.
func (Factory) WithMemo ¶ added in v0.43.0
WithMemo returns a copy of the Factory with an updated memo.
func (Factory) WithSequence ¶ added in v0.43.0
WithSequence returns a copy of the Factory with an updated sequence number.
func (Factory) WithSigBlockHeight ¶ added in v0.43.0
WithSigBlockHeight returns a copy of the Factory with an updated sig block height.
func (Factory) WithSignMode ¶ added in v0.43.0
WithSignMode returns a copy of the Factory with an updated sign mode value.
func (Factory) WithSimulateAndExecute ¶ added in v0.43.0
WithSimulateAndExecute returns a copy of the Factory with an updated gas simulation value.
func (Factory) WithTimeoutHeight ¶ added in v0.43.0
WithTimeoutHeight returns a copy of the Factory with an updated timeout height.
type GasEstimateResponse ¶ added in v0.43.0
type GasEstimateResponse struct {
GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"`
}
GasEstimateResponse defines a response definition for tx gas estimation.
func (GasEstimateResponse) String ¶ added in v0.43.0
func (gr GasEstimateResponse) String() string