Documentation ¶
Index ¶
- func BroadcastTx(ctx context.CLIContext, txf Factory, msgs ...sdk.Msg) error
- func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error)
- func BuildUnsignedTx(txf Factory, msgs ...sdk.Msg) (context.TxBuilder, error)
- func CalculateGas(queryFunc func(string, []byte) ([]byte, int64, error), txf Factory, ...) (sdk.SimulationResponse, uint64, error)
- func GenerateOrBroadcastTx(ctx context.CLIContext, msgs ...sdk.Msg) error
- func GenerateOrBroadcastTxWithFactory(ctx context.CLIContext, txf Factory, msgs ...sdk.Msg) error
- func GenerateTx(ctx context.CLIContext, txf Factory, msgs ...sdk.Msg) error
- func Sign(txf Factory, name, passphrase string, tx context.TxBuilder) ([]byte, error)
- func WriteGeneratedTxResponse(ctx context.CLIContext, w http.ResponseWriter, br rest.BaseReq, ...)
- type Factory
- func (f Factory) AccountNumber() uint64
- func (f Factory) AccountRetriever() context.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) SimulateAndExecute() bool
- func (f Factory) WithAccountNumber(accnum uint64) Factory
- func (f Factory) WithAccountRetriever(ar context.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) WithSimulateAndExecute(sim bool) Factory
- func (f Factory) WithTxGenerator(g context.TxGenerator) Factory
- type GasEstimateResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastTx ¶
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 ¶
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 ¶
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 ¶
func CalculateGas( queryFunc func(string, []byte) ([]byte, int64, error), txf Factory, msgs ...sdk.Msg, ) (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 GenerateOrBroadcastTx ¶
func GenerateOrBroadcastTx(ctx context.CLIContext, msgs ...sdk.Msg) error
GenerateOrBroadcastTx will either generate and print and unsigned transaction or sign it and broadcast it returning an error upon failure.
func GenerateOrBroadcastTxWithFactory ¶
GenerateOrBroadcastTxWithFactory will either generate and print and unsigned transaction or sign it and broadcast it returning an error upon failure.
func GenerateTx ¶
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 ¶
Sign signs a given tx with the provided name and passphrase. If the Factory's Keybase is not set, a new one will be created based on the client's backend. The bytes signed over are canconical. The resulting signature will be set on the transaction. Finally, the marshaled transaction is returned. An error is returned upon failure.
Note, It is assumed the Factory has the necessary fields set that are required by the CanonicalSignBytes call.
func WriteGeneratedTxResponse ¶
func WriteGeneratedTxResponse( ctx context.CLIContext, 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.
Types ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory defines a client transaction factory that facilitates generating and signing an application-specific transaction.
func NewFactoryFromCLI ¶
func PrepareFactory ¶
func PrepareFactory(ctx context.CLIContext, txf Factory) (Factory, error)
PrepareFactory ensures the account defined by ctx.GetFromAddress() exists and if the account number and/or the account sequence number are zero (not set), they will be queried for and set on the provided Factory. A new Factory with the updated fields will be returned.
func (Factory) AccountNumber ¶
func (Factory) AccountRetriever ¶
func (f Factory) AccountRetriever() context.AccountRetriever
func (Factory) GasAdjustment ¶
func (Factory) SimulateAndExecute ¶
SimulateAndExecute returns the option to simulate and then execute the transaction using the gas from the simulation results
func (Factory) WithAccountNumber ¶
WithAccountNumber returns a copy of the Factory with an updated account number.
func (Factory) WithAccountRetriever ¶
func (f Factory) WithAccountRetriever(ar context.AccountRetriever) Factory
WithAccountRetriever returns a copy of the Factory with an updated AccountRetriever.
func (Factory) WithChainID ¶
WithChainID returns a copy of the Factory with an updated chainID.
func (Factory) WithGasAdjustment ¶
WithGasAdjustment returns a copy of the Factory with an updated gas adjustment.
func (Factory) WithGasPrices ¶
WithGasPrices returns a copy of the Factory with updated gas prices.
func (Factory) WithKeybase ¶
WithKeybase returns a copy of the Factory with updated Keybase.
func (Factory) WithSequence ¶
WithSequence returns a copy of the Factory with an updated sequence number.
func (Factory) WithSimulateAndExecute ¶
WithSimulateAndExecute returns a copy of the Factory with an updated gas simulation value.
func (Factory) WithTxGenerator ¶
func (f Factory) WithTxGenerator(g context.TxGenerator) Factory
WithTxGenerator returns a copy of the Factory with an updated TxGenerator.
type GasEstimateResponse ¶
type GasEstimateResponse struct {
GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"`
}
GasEstimateResponse defines a response definition for tx gas estimation.
func (GasEstimateResponse) String ¶
func (gr GasEstimateResponse) String() string