tx

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientFee

type ClientFee interface {
	sdk.Fee
	SetGas(uint64)
	SetAmount(sdk.Coins)
}

type ClientSignature

type ClientSignature interface {
	sdk.Signature
	SetPubKey(crypto.PubKey) error
	SetSignature([]byte)
}

type ClientTx

type ClientTx interface {
	sdk.Tx
	codec.ProtoMarshaler

	SetMsgs(...sdk.Msg) error
	GetSignatures() []sdk.Signature
	SetSignatures(...ClientSignature) error
	GetFee() sdk.Fee
	SetFee(ClientFee) error
	GetMemo() string
	SetMemo(string)

	// CanonicalSignBytes returns the canonical JSON bytes to sign over, given a
	// chain ID, along with an account and sequence number. The JSON encoding
	// ensures all field names adhere to their proto definition, default values
	// are omitted, and follows the JSON Canonical Form.
	CanonicalSignBytes(cid string, num, seq uint64) ([]byte, error)
}

ClientTx defines an interface which an application-defined concrete transaction type must implement. Namely, it must be able to set messages, generate signatures, and provide canonical bytes to sign over. The transaction must also know how to encode itself.

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 (Factory) AccountNumber

func (f Factory) AccountNumber() uint64

func (Factory) BuildAndSignedTx

func (f Factory) BuildAndSignedTx(msgs ...sdk.Msg) ([]byte, error)

func (Factory) BuildSimTx

func (f Factory) BuildSimTx(msgs ...sdk.Msg) ([]byte, error)

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 (Factory) BuildUnsignedTx

func (f Factory) BuildUnsignedTx(msgs ...sdk.Msg) (ClientTx, error)

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 (Factory) ChainID

func (f Factory) ChainID() string

func (Factory) Fees

func (f Factory) Fees() sdk.Coins

func (Factory) Gas

func (f Factory) Gas() uint64

func (Factory) GasAdjustment

func (f Factory) GasAdjustment() float64

func (Factory) GasPrices

func (f Factory) GasPrices() sdk.DecCoins

func (Factory) Memo

func (f Factory) Memo() string

func (Factory) Sequence

func (f Factory) Sequence() uint64

func (Factory) Sign

func (f Factory) Sign(tx ClientTx) ([]byte, error)

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 (Factory) SimulateAndExecute

func (f Factory) SimulateAndExecute() bool

SimulateAndExecute returns the option to simulate and then execute the transaction using the gas from the simulation results

func (Factory) WithAccountNumber

func (f Factory) WithAccountNumber(accnum uint64) Factory

WithAccountNumber returns a copy of the Factory with an updated account number.

func (Factory) WithChainID

func (f Factory) WithChainID(chainID string) Factory

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

func (Factory) WithFees

func (f Factory) WithFees(fees string) Factory

WithFees returns a copy of the Factory with an updated fee.

func (Factory) WithGas

func (f Factory) WithGas(gas uint64) Factory

WithGas returns a copy of the Factory with an updated gas value.

func (Factory) WithGasAdjustment

func (f Factory) WithGasAdjustment(gasAdj float64) Factory

WithGasAdjustment returns a copy of the Factory with an updated gas adjustment.

func (Factory) WithGasPrices

func (f Factory) WithGasPrices(gasPrices string) Factory

WithGasPrices returns a copy of the Factory with updated gas prices.

func (Factory) WithMemo

func (f Factory) WithMemo(memo string) Factory

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

func (Factory) WithSequence

func (f Factory) WithSequence(sequence uint64) Factory

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

func (Factory) WithSimulateAndExecute

func (f Factory) WithSimulateAndExecute(sim bool) Factory

WithSimulateAndExecute returns a copy of the Factory with an updated gas simulation value.

func (Factory) WithTxGenerator

func (f Factory) WithTxGenerator(g Generator) Factory

WithTxGenerator returns a copy of the Factory with an updated Generator.

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

type Generator

type Generator interface {
	NewTx() ClientTx
	NewFee() ClientFee
	NewSignature() ClientSignature
}

Generator defines an interface a client can utilize to generate an application-defined concrete transaction type. The type returned must implement ClientTx.

Jump to

Keyboard shortcuts

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