-
Notifications
You must be signed in to change notification settings - Fork 12
/
ante.go
44 lines (41 loc) · 1.79 KB
/
ante.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package app
import (
sdk "github.com/cosmos/cosmos-sdk/types"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
didkeeper "github.com/allinbits/cosmos-cash/v2/x/did/keeper"
issuerante "github.com/allinbits/cosmos-cash/v2/x/issuer/ante"
issuerkeeper "github.com/allinbits/cosmos-cash/v2/x/issuer/keeper"
vcskeeper "github.com/allinbits/cosmos-cash/v2/x/verifiable-credential/keeper"
)
// NewAnteHandler returns an AnteHandler that checks and increments sequence
// numbers, checks signatures & account numbers, and deducts fees from the first
// signer.
func NewAnteHandler(
ak authante.AccountKeeper,
bankKeeper authtypes.BankKeeper,
feeGrantKeeper authante.FeegrantKeeper,
ik issuerkeeper.Keeper,
dk didkeeper.Keeper,
vcsk vcskeeper.Keeper,
sigGasConsumer authante.SignatureVerificationGasConsumer,
signModeHandler signing.SignModeHandler,
) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
authante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
authante.NewRejectExtensionOptionsDecorator(),
authante.NewMempoolFeeDecorator(),
authante.NewValidateBasicDecorator(),
authante.TxTimeoutHeightDecorator{},
authante.NewValidateMemoDecorator(ak),
authante.NewConsumeGasForTxSizeDecorator(ak),
authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators
authante.NewValidateSigCountDecorator(ak),
authante.NewDeductFeeDecorator(ak, bankKeeper, feeGrantKeeper),
authante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
authante.NewSigVerificationDecorator(ak, signModeHandler),
authante.NewIncrementSequenceDecorator(ak),
issuerante.NewCheckUserCredentialsDecorator(ak, ik, dk, vcsk),
)
}