Documentation ¶
Index ¶
- func ComposeMiddlewares(txHandler tx.Handler, middlewares ...tx.Middleware) tx.Handler
- func ConsumeBlockGasMiddleware(txh tx.Handler) tx.Handler
- func ConsumeMultisignatureVerificationGas(meter sdk.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey, ...) error
- func ConsumeTxSizeGasMiddleware(ak AccountKeeper) tx.Middleware
- func CountSubKeys(pub cryptotypes.PubKey) int
- func DeductFeeMiddleware(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper) tx.Middleware
- func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, ...) errordeprecated
- func DefaultSigVerificationGasConsumer(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error
- func GasTxMiddleware(txh tx.Handler) tx.Handler
- func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (types.AccountI, error)
- func GetTxPriority(fee sdk.Coins) int64
- func IncrementSequenceMiddleware(ak AccountKeeper) tx.Middleware
- func MempoolFeeMiddleware(txh tx.Handler) tx.Handler
- func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error)
- func NewIndexEventsTxMiddleware(indexEvents map[string]struct{}) tx.Middleware
- func NewRunMsgsTxHandler(msr *MsgServiceRouter, legacyRouter sdk.Router) tx.Handler
- func NewTipMiddleware(bankKeeper types.BankKeeper) tx.Middleware
- func NewTxDecoderMiddleware(txDecoder sdk.TxDecoder) tx.Middleware
- func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool
- func RecoveryTxMiddleware(txh tx.Handler) tx.Handler
- func RejectExtensionOptionsMiddleware(txh tx.Handler) tx.Handler
- func SetPubKeyMiddleware(ak AccountKeeper) tx.Middleware
- func SigGasConsumeMiddleware(ak AccountKeeper, sigGasConsumer SignatureVerificationGasConsumer) tx.Middleware
- func SigVerificationMiddleware(ak AccountKeeper, signModeHandler authsigning.SignModeHandler) tx.Middleware
- func TxPriorityMiddleware(txh tx.Handler) tx.Handler
- func TxTimeoutHeightMiddleware(txh tx.Handler) tx.Handler
- func ValidateBasicMiddleware(txh tx.Handler) tx.Handler
- func ValidateMemoMiddleware(ak AccountKeeper) tx.Middleware
- func ValidateSigCountMiddleware(ak AccountKeeper) tx.Middleware
- func WithBranchedStore(txh tx.Handler) tx.Handler
- type AccountKeeper
- type FeegrantKeeper
- type GasTx
- type HasExtensionOptionsTx
- type LegacyRouter
- type MsgServiceHandler
- type MsgServiceRouter
- type SignatureVerificationGasConsumer
- type TxHandlerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComposeMiddlewares ¶
ComposeMiddlewares compose multiple middlewares on top of a tx.Handler. The middleware order in the variadic arguments is from outer to inner.
Example: Given a base tx.Handler H, and two middlewares A and B, the middleware stack: ``` A.pre
B.pre H B.post
A.post ``` is created by calling `ComposeMiddlewares(H, A, B)`.
func ConsumeBlockGasMiddleware ¶
ConsumeBlockGasMiddleware check and consume block gas meter.
func ConsumeMultisignatureVerificationGas ¶
func ConsumeMultisignatureVerificationGas( meter sdk.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey, params types.Params, accSeq uint64, ) error
ConsumeMultisignatureVerificationGas consumes gas from a GasMeter for verifying a multisig pubkey signature
func ConsumeTxSizeGasMiddleware ¶
func ConsumeTxSizeGasMiddleware(ak AccountKeeper) tx.Middleware
ConsumeTxSizeGasMiddleware will take in parameters and consume gas proportional to the size of tx before calling next middleware. Note, the gas costs will be slightly over estimated due to the fact that any given signing account may need to be retrieved from state.
CONTRACT: If simulate=true, then signatures must either be completely filled in or empty. CONTRACT: To use this middleware, signatures of transaction must be represented as legacytx.StdSignature otherwise simulate mode will incorrectly estimate gas cost.
func CountSubKeys ¶
func CountSubKeys(pub cryptotypes.PubKey) int
CountSubKeys counts the total number of keys for a multi-sig public key.
func DeductFeeMiddleware ¶
func DeductFeeMiddleware(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper) tx.Middleware
DeductFeeMiddleware deducts fees from the first signer of the tx If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error Call next middleware if fees successfully deducted CONTRACT: Tx must implement FeeTx interface to use deductFeeTxHandler
func DeductFees
deprecated
func DefaultSigVerificationGasConsumer ¶
func DefaultSigVerificationGasConsumer( meter sdk.GasMeter, sig signing.SignatureV2, params types.Params, ) error
DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas for signature verification based upon the public key type. The cost is fetched from the given params and is matched by the concrete type.
func GasTxMiddleware ¶
GasTxMiddleware defines a simple middleware that sets a new GasMeter on the sdk.Context, and sets the GasInfo on the result. It reads the tx.GetGas() by default, or sets to infinity in simulate mode.
func GetSignerAcc ¶
func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (types.AccountI, error)
GetSignerAcc returns an account for a given address that is expected to sign a transaction.
func GetTxPriority ¶
GetTxPriority returns a naive tx priority based on the amount of the smallest denomination of the fee provided in a transaction.
func IncrementSequenceMiddleware ¶
func IncrementSequenceMiddleware(ak AccountKeeper) tx.Middleware
IncrementSequenceMiddleware handles incrementing sequences of all signers. Use the incrementSequenceTxHandler middleware to prevent replay attacks. Note, there is no need to execute incrementSequenceTxHandler on RecheckTX since CheckTx would already bump the sequence number.
NOTE: Since CheckTx and DeliverTx state are managed separately, subsequent and sequential txs orginating from the same account cannot be handled correctly in a reliable way unless sequence numbers are managed and tracked manually by a client. It is recommended to instead use multiple messages in a tx.
func MempoolFeeMiddleware ¶
MempoolFeeMiddleware will check if the transaction's fee is at least as large as the local validator's minimum gasFee (defined in validator config). If fee is too low, middleware returns error and tx is rejected from mempool. Note this only applies when ctx.CheckTx = true If fee is high enough or not CheckTx, then call next middleware CONTRACT: Tx must implement FeeTx to use MempoolFeeMiddleware
func NewDefaultTxHandler ¶
func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error)
NewDefaultTxHandler defines a TxHandler middleware stacks that should work for most applications.
func NewIndexEventsTxMiddleware ¶
func NewIndexEventsTxMiddleware(indexEvents map[string]struct{}) tx.Middleware
NewIndexEventsTxMiddleware defines a middleware to optionally only index a subset of the emitted events inside the Tendermint events indexer.
func NewRunMsgsTxHandler ¶
func NewRunMsgsTxHandler(msr *MsgServiceRouter, legacyRouter sdk.Router) tx.Handler
func NewTipMiddleware ¶
func NewTipMiddleware(bankKeeper types.BankKeeper) tx.Middleware
NewTipMiddleware returns a new middleware for handling transactions with tips.
func NewTxDecoderMiddleware ¶
func NewTxDecoderMiddleware(txDecoder sdk.TxDecoder) tx.Middleware
NewTxDecoderMiddleware creates a new middleware that will decode tx bytes into a sdk.Tx. As input request, at least one of Tx or TxBytes must be set. If only TxBytes is set, then TxDecoderMiddleware will populate the Tx field. If only Tx is set, then TxBytes will be left empty, but some middlewares such as signature verification might fail.
func OnlyLegacyAminoSigners ¶
func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool
OnlyLegacyAminoSigners checks SignatureData to see if all signers are using SIGN_MODE_LEGACY_AMINO_JSON. If this is the case then the corresponding SignatureV2 struct will not have account sequence explicitly set, and we should skip the explicit verification of sig.Sequence in the SigVerificationMiddleware's middleware function.
func RecoveryTxMiddleware ¶
RecoveryTxMiddleware defines a middleware that catches all panics that happen in inner middlewares.
Be careful, it won't catch any panics happening outside!
func RejectExtensionOptionsMiddleware ¶
RejectExtensionOptionsMiddleware creates a new rejectExtensionOptionsMiddleware. rejectExtensionOptionsMiddleware is a middleware that rejects all extension options which can optionally be included in protobuf transactions. Users that need extension options should create a custom middleware chain that handles needed extension options properly and rejects unknown ones.
func SetPubKeyMiddleware ¶
func SetPubKeyMiddleware(ak AccountKeeper) tx.Middleware
SetPubKeyMiddleware sets PubKeys in context for any signer which does not already have pubkey set PubKeys must be set in context for all signers before any other sigverify middlewares run CONTRACT: Tx must implement SigVerifiableTx interface
func SigGasConsumeMiddleware ¶
func SigGasConsumeMiddleware(ak AccountKeeper, sigGasConsumer SignatureVerificationGasConsumer) tx.Middleware
SigGasConsumeMiddleware consumes parameter-defined amount of gas for each signature according to the passed-in SignatureVerificationGasConsumer function before calling the next middleware CONTRACT: Pubkeys are set in context for all signers before this middleware runs CONTRACT: Tx must implement SigVerifiableTx interface
func SigVerificationMiddleware ¶
func SigVerificationMiddleware(ak AccountKeeper, signModeHandler authsigning.SignModeHandler) tx.Middleware
SigVerificationMiddleware verifies all signatures for a tx and return an error if any are invalid. Note, the sigVerificationTxHandler middleware will not get executed on ReCheck.
CONTRACT: Pubkeys are set in context for all signers before this middleware runs CONTRACT: Tx must implement SigVerifiableTx interface
func TxPriorityMiddleware ¶
TxPriorityMiddleware implements tx handling middleware that determines a transaction's priority via a naive mechanism -- the total sum of fees provided. It sets the Priority in ResponseCheckTx only.
func TxTimeoutHeightMiddleware ¶
TxTimeoutHeightMiddleware defines a middleware that checks for a tx height timeout.
func ValidateBasicMiddleware ¶
ValidateBasicMiddleware will call tx.ValidateBasic, msg.ValidateBasic(for each msg inside tx) and return any non-nil error. If ValidateBasic passes, middleware calls next middleware in chain. Note, validateBasicTxHandler will not get executed on ReCheckTx since it is not dependent on application state.
func ValidateMemoMiddleware ¶
func ValidateMemoMiddleware(ak AccountKeeper) tx.Middleware
ValidateMemoMiddleware will validate memo given the parameters passed in If memo is too large middleware returns with error, otherwise call next middleware CONTRACT: Tx must implement TxWithMemo interface
func ValidateSigCountMiddleware ¶
func ValidateSigCountMiddleware(ak AccountKeeper) tx.Middleware
ValidateSigCountMiddleware takes in Params and returns errors if there are too many signatures in the tx for the given params otherwise it calls next middleware Use this middleware to set parameterized limit on number of signatures in tx CONTRACT: Tx must implement SigVerifiableTx interface
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { GetParams(ctx sdk.Context) (params types.Params) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI SetAccount(ctx sdk.Context, acc types.AccountI) GetModuleAddress(moduleName string) sdk.AccAddress }
AccountKeeper defines the contract needed for AccountKeeper related APIs. Interface provides support to use non-sdk AccountKeeper for TxHandler's middlewares.
type FeegrantKeeper ¶
type FeegrantKeeper interface {
UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error
}
FeegrantKeeper defines the expected feegrant keeper.
type HasExtensionOptionsTx ¶
type HasExtensionOptionsTx interface { GetExtensionOptions() []*codectypes.Any GetNonCriticalExtensionOptions() []*codectypes.Any }
type LegacyRouter ¶
type LegacyRouter struct {
// contains filtered or unexported fields
}
func NewLegacyRouter ¶
func NewLegacyRouter() *LegacyRouter
NewRouter returns a reference to a new router.
type MsgServiceHandler ¶
MsgServiceHandler defines a function type which handles Msg service message.
type MsgServiceRouter ¶
type MsgServiceRouter struct {
// contains filtered or unexported fields
}
MsgServiceRouter routes fully-qualified Msg service methods to their handler.
func NewMsgServiceRouter ¶
func NewMsgServiceRouter(registry codectypes.InterfaceRegistry) *MsgServiceRouter
NewMsgServiceRouter creates a new MsgServiceRouter.
func (*MsgServiceRouter) Handler ¶
func (msr *MsgServiceRouter) Handler(msg sdk.Msg) MsgServiceHandler
Handler returns the MsgServiceHandler for a given msg or nil if not found.
func (*MsgServiceRouter) HandlerByTypeURL ¶
func (msr *MsgServiceRouter) HandlerByTypeURL(typeURL string) MsgServiceHandler
HandlerByTypeURL returns the MsgServiceHandler for a given query route path or nil if not found.
func (*MsgServiceRouter) RegisterService ¶
func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler interface{})
RegisterService implements the gRPC Server.RegisterService method. sd is a gRPC service description, handler is an object which implements that gRPC service.
This function PANICs:
- if it is called before the service `Msg`s have been registered using RegisterInterfaces,
- or if a service is being registered twice.
type SignatureVerificationGasConsumer ¶
type SignatureVerificationGasConsumer = func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error
SignatureVerificationGasConsumer is the type of function that is used to both consume gas when verifying signatures and also to accept or reject different types of pubkeys This is where apps can define their own PubKey
type TxHandlerOptions ¶
type TxHandlerOptions struct { Debug bool // TxDecoder is used to decode the raw tx bytes into a sdk.Tx. TxDecoder sdk.TxDecoder // IndexEvents defines the set of events in the form {eventType}.{attributeKey}, // which informs Tendermint what to index. If empty, all events will be indexed. IndexEvents map[string]struct{} LegacyRouter sdk.Router MsgServiceRouter *MsgServiceRouter AccountKeeper AccountKeeper BankKeeper types.BankKeeper FeegrantKeeper FeegrantKeeper SignModeHandler authsigning.SignModeHandler SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error }