tx

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastTx

func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error

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 CalculateGas

func CalculateGas(
	clientCtx gogogrpc.ClientConn, 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 ConvertTxToStdTx

func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (legacytx.StdTx, error)

ConvertTxToStdTx converts a transaction to the legacy StdTx format

func CopyTx

func CopyTx(tx signing.Tx, builder client.TxBuilder, ignoreSignatureError bool) error

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

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

func GenerateOrBroadcastTxWithFactory(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error

GenerateOrBroadcastTxWithFactory will either generate and print and unsigned transaction or sign it and broadcast it returning an error upon failure.

func Sign

func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig bool) error

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

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.

Types

type AuxTxBuilder

type AuxTxBuilder struct {
	// contains filtered or unexported fields
}

AuxTxBuilder is a client-side builder for creating an AuxSignerData.

func NewAuxTxBuilder

func NewAuxTxBuilder() AuxTxBuilder

NewAuxTxBuilder creates a new client-side builder for constructing an AuxSignerData.

func (*AuxTxBuilder) GetAuxSignerData

func (b *AuxTxBuilder) GetAuxSignerData() (tx.AuxSignerData, error)

GetAuxSignerData returns the builder's AuxSignerData.

func (*AuxTxBuilder) GetSignBytes

func (b *AuxTxBuilder) GetSignBytes() ([]byte, error)

GetSignBytes returns the builder's sign bytes.

func (*AuxTxBuilder) SetAccountNumber

func (b *AuxTxBuilder) SetAccountNumber(accNum uint64)

SetAccountNumber sets the aux signer's account number in the AuxSignerData.

func (*AuxTxBuilder) SetAddress

func (b *AuxTxBuilder) SetAddress(addr string)

SetAddress sets the aux signer's bech32 address.

func (*AuxTxBuilder) SetChainID

func (b *AuxTxBuilder) SetChainID(chainID string)

SetChainID sets the chain id in the AuxSignerData.

func (*AuxTxBuilder) SetExtensionOptions

func (b *AuxTxBuilder) SetExtensionOptions(extOpts ...*codectypes.Any)

SetExtensionOptions sets the aux signer's extension options.

func (*AuxTxBuilder) SetMemo

func (b *AuxTxBuilder) SetMemo(memo string)

SetMemo sets a memo in the tx.

func (*AuxTxBuilder) SetMsgs

func (b *AuxTxBuilder) SetMsgs(msgs ...sdk.Msg) error

SetMsgs sets an array of Msgs in the tx.

func (*AuxTxBuilder) SetNonCriticalExtensionOptions

func (b *AuxTxBuilder) SetNonCriticalExtensionOptions(extOpts ...*codectypes.Any)

SetSignature sets the aux signer's signature.

func (*AuxTxBuilder) SetPubKey

func (b *AuxTxBuilder) SetPubKey(pk cryptotypes.PubKey) error

SetPubKey sets the aux signer's pubkey in the AuxSignerData.

func (*AuxTxBuilder) SetSequence

func (b *AuxTxBuilder) SetSequence(accSeq uint64)

SetSequence sets the aux signer's sequence in the AuxSignerData.

func (*AuxTxBuilder) SetSignMode

func (b *AuxTxBuilder) SetSignMode(mode signing.SignMode) error

SetSignMode sets the aux signer's sign mode. Allowed sign modes are DIRECT_AUX and LEGACY_AMINO_JSON.

func (*AuxTxBuilder) SetSignature

func (b *AuxTxBuilder) SetSignature(sig []byte)

SetSignature sets the aux signer's signature in the AuxSignerData.

func (*AuxTxBuilder) SetTimeoutHeight

func (b *AuxTxBuilder) SetTimeoutHeight(height uint64)

SetTimeoutHeight sets a timeout height in the tx.

func (*AuxTxBuilder) SetTip

func (b *AuxTxBuilder) SetTip(tip *tx.Tip)

SetTip sets an optional tip in the AuxSignerData.

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 NewFactoryCLI

func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory

NewFactoryCLI creates a new Factory.

func (Factory) AccountNumber

func (f Factory) AccountNumber() uint64

func (Factory) AccountRetriever

func (f Factory) AccountRetriever() client.AccountRetriever

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) (client.TxBuilder, error)

BuildUnsignedTx builds a transaction to be signed given a set of messages. 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) Keybase

func (f Factory) Keybase() keyring.Keyring

func (Factory) Memo

func (f Factory) Memo() string

func (Factory) Prepare

func (f Factory) Prepare(clientCtx client.Context) (Factory, error)

Prepare 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) PrintUnsignedTx

func (f Factory) PrintUnsignedTx(clientCtx client.Context, msgs ...sdk.Msg) error

PrintUnsignedTx 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 (Factory) Sequence

func (f Factory) Sequence() uint64

func (Factory) SignMode

func (f Factory) SignMode() signing.SignMode

SignMode returns the sign mode configured in the Factory

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

func (f Factory) TimeoutHeight() uint64

func (Factory) WithAccountNumber

func (f Factory) WithAccountNumber(accnum uint64) Factory

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

func (Factory) WithAccountRetriever

func (f Factory) WithAccountRetriever(ar client.AccountRetriever) Factory

WithAccountRetriever returns a copy of the Factory with an updated AccountRetriever.

func (Factory) WithChainID

func (f Factory) WithChainID(chainID string) Factory

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

func (Factory) WithFeeGranter

func (f Factory) WithFeeGranter(fg sdk.AccAddress) Factory

WithFeeGranter returns a copy of the Factory with an updated fee granter.

func (Factory) WithFeePayer

func (f Factory) WithFeePayer(fp sdk.AccAddress) Factory

WithFeePayer returns a copy of the Factory with an updated fee granter.

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

func (f Factory) WithKeybase(keybase keyring.Keyring) Factory

WithKeybase returns a copy of the Factory with updated Keybase.

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

func (f Factory) WithSignMode(mode signing.SignMode) Factory

WithSignMode returns a copy of the Factory with an updated sign mode value.

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

func (f Factory) WithTimeoutHeight(height uint64) Factory

WithTimeoutHeight returns a copy of the Factory with an updated timeout height.

func (Factory) WithTips

func (f Factory) WithTips(tip string, tipper string) Factory

WithTips returns a copy of the Factory with an updated tip.

func (Factory) WithTxConfig

func (f Factory) WithTxConfig(g client.TxConfig) Factory

WithTxConfig returns a copy of the Factory with an updated TxConfig.

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

Jump to

Keyboard shortcuts

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