mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
9c69ee2fbf
* use kava antehandler * add authenticated mempool decorator * add get authorised address methods * hook antehandler into app * refactor address fetcher interface * tidy up args to NewApp * remove unused function * tidy up after removing address fetcher interface * read authorized addresses from config * fix error message, and minor tidy * update cosmos-sdk and tendermint * clarify function name * add flags for mempool options
33 lines
1.4 KiB
Go
33 lines
1.4 KiB
Go
package ante
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/x/auth/ante"
|
|
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
|
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
)
|
|
|
|
// NewAnteHandler returns an 'AnteHandler' that will run actions before a tx is sent to a module's handler.
|
|
func NewAnteHandler(ak keeper.AccountKeeper, supplyKeeper types.SupplyKeeper, sigGasConsumer ante.SignatureVerificationGasConsumer, addressFetchers ...AddressFetcher) sdk.AnteHandler {
|
|
decorators := []sdk.AnteDecorator{}
|
|
|
|
decorators = append(decorators, ante.NewSetUpContextDecorator()) // outermost AnteDecorator. SetUpContext must be called first
|
|
|
|
if len(addressFetchers) > 0 {
|
|
decorators = append(decorators, NewAuthenticatedMempoolDecorator(addressFetchers...))
|
|
}
|
|
decorators = append(decorators,
|
|
ante.NewMempoolFeeDecorator(),
|
|
ante.NewValidateBasicDecorator(),
|
|
ante.NewValidateMemoDecorator(ak),
|
|
ante.NewConsumeGasForTxSizeDecorator(ak),
|
|
ante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators
|
|
ante.NewValidateSigCountDecorator(ak),
|
|
ante.NewDeductFeeDecorator(ak, supplyKeeper),
|
|
ante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
|
|
ante.NewSigVerificationDecorator(ak),
|
|
ante.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator
|
|
)
|
|
return sdk.ChainAnteDecorators(decorators...)
|
|
}
|