From 5efb8432391aaa2cd39d3885066fc6ec92f36670 Mon Sep 17 00:00:00 2001 From: Girish Ramnani Date: Sun, 26 Apr 2020 20:09:38 +0530 Subject: [PATCH] extracted the standard ante handler --- app/app.go | 3 ++- x/pylons/handlers/custom_ante_handler.go | 26 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 606f3052a3..8abfdb1b18 100644 --- a/app/app.go +++ b/app/app.go @@ -21,6 +21,7 @@ import ( tmtypes "github.com/tendermint/tendermint/types" "github.com/Pylons-tech/pylons/x/pylons" + "github.com/Pylons-tech/pylons/x/pylons/handlers" "github.com/Pylons-tech/pylons/x/pylons/keep" bam "github.com/cosmos/cosmos-sdk/baseapp" @@ -233,7 +234,7 @@ func NewPylonsApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Base // The AnteHandler handles signature verification and transaction pre-processing app.SetAnteHandler( - auth.NewAnteHandler( + handlers.NewAnteHandler( app.accountKeeper, app.supplyKeeper, auth.DefaultSigVerificationGasConsumer, diff --git a/x/pylons/handlers/custom_ante_handler.go b/x/pylons/handlers/custom_ante_handler.go index 5ac8282f4b..6ab8bda888 100644 --- a/x/pylons/handlers/custom_ante_handler.go +++ b/x/pylons/handlers/custom_ante_handler.go @@ -1 +1,27 @@ package handlers + +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 checks and increments sequence +// numbers, checks signatures & account numbers, and deducts fees from the first +// signer. +func NewAnteHandler(ak keeper.AccountKeeper, supplyKeeper types.SupplyKeeper, sigGasConsumer ante.SignatureVerificationGasConsumer) sdk.AnteHandler { + return sdk.ChainAnteDecorators( + ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + 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 + ) +}