github.com/cosmos/cosmos-sdk@v0.50.10/client/tx_config.go (about)

     1  package client
     2  
     3  import (
     4  	txsigning "cosmossdk.io/x/tx/signing"
     5  
     6  	codectypes "github.com/cosmos/cosmos-sdk/codec/types"
     7  	sdk "github.com/cosmos/cosmos-sdk/types"
     8  	"github.com/cosmos/cosmos-sdk/types/tx"
     9  	signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
    10  	"github.com/cosmos/cosmos-sdk/x/auth/signing"
    11  )
    12  
    13  type (
    14  	// TxEncodingConfig defines an interface that contains transaction
    15  	// encoders and decoders
    16  	TxEncodingConfig interface {
    17  		TxEncoder() sdk.TxEncoder
    18  		TxDecoder() sdk.TxDecoder
    19  		TxJSONEncoder() sdk.TxEncoder
    20  		TxJSONDecoder() sdk.TxDecoder
    21  		MarshalSignatureJSON([]signingtypes.SignatureV2) ([]byte, error)
    22  		UnmarshalSignatureJSON([]byte) ([]signingtypes.SignatureV2, error)
    23  	}
    24  
    25  	// TxConfig defines an interface a client can utilize to generate an
    26  	// application-defined concrete transaction type. The type returned must
    27  	// implement TxBuilder.
    28  	TxConfig interface {
    29  		TxEncodingConfig
    30  
    31  		NewTxBuilder() TxBuilder
    32  		WrapTxBuilder(sdk.Tx) (TxBuilder, error)
    33  		SignModeHandler() *txsigning.HandlerMap
    34  		SigningContext() *txsigning.Context
    35  	}
    36  
    37  	// TxBuilder defines an interface which an application-defined concrete transaction
    38  	// type must implement. Namely, it must be able to set messages, generate
    39  	// signatures, and provide canonical bytes to sign over. The transaction must
    40  	// also know how to encode itself.
    41  	TxBuilder interface {
    42  		GetTx() signing.Tx
    43  
    44  		SetMsgs(msgs ...sdk.Msg) error
    45  		SetSignatures(signatures ...signingtypes.SignatureV2) error
    46  		SetMemo(memo string)
    47  		SetFeeAmount(amount sdk.Coins)
    48  		SetFeePayer(feePayer sdk.AccAddress)
    49  		SetGasLimit(limit uint64)
    50  		SetTimeoutHeight(height uint64)
    51  		SetFeeGranter(feeGranter sdk.AccAddress)
    52  		AddAuxSignerData(tx.AuxSignerData) error
    53  	}
    54  
    55  	// ExtendedTxBuilder extends the TxBuilder interface,
    56  	// which is used to set extension options to be included in a transaction.
    57  	ExtendedTxBuilder interface {
    58  		SetExtensionOptions(extOpts ...*codectypes.Any)
    59  	}
    60  )