Skip to content

Commit

Permalink
extracted the standard ante handler
Browse files Browse the repository at this point in the history
  • Loading branch information
girishramnani authored and antstalepresh committed May 27, 2020
1 parent 106d2cc commit 5efb843
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions x/pylons/handlers/custom_ante_handler.go
Original file line number Diff line number Diff line change
@@ -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
)
}

0 comments on commit 5efb843

Please sign in to comment.