/
ante.go
44 lines (42 loc) · 2.21 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 ante
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"
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
beaconante "github.com/unification-com/mainchain/x/beacon/ante"
entante "github.com/unification-com/mainchain/x/enterprise/ante"
wrkante "github.com/unification-com/mainchain/x/wrkchain/ante"
)
func NewAnteHandler(
ak authante.AccountKeeper,
fgk authante.FeegrantKeeper,
bankKeeper BankKeeper,
wrkchainKeeper wrkante.WrkchainKeeper,
beaconKeeper beaconante.BeaconKeeper,
enterpriseKeeper entante.EnterpriseKeeper,
ibcKeeper *ibckeeper.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.NewTxTimeoutHeightDecorator(),
authante.NewValidateMemoDecorator(ak),
authante.NewConsumeGasForTxSizeDecorator(ak),
wrkante.NewCorrectWrkChainFeeDecorator(bankKeeper, ak, wrkchainKeeper, enterpriseKeeper), // WRKChain check Tx fees. Specifically check after MemPool, but before consuming fees/gas and undelegating locked FUND
beaconante.NewCorrectBeaconFeeDecorator(bankKeeper, ak, beaconKeeper, enterpriseKeeper), // BEACON check Tx fees. Specifically check after MemPool, but before consuming fees/gas and undelegating locked FUND
entante.NewCheckLockedUndDecorator(enterpriseKeeper), // check for and unlock any locked FUND for valid WRKChain/BEACON Txs
authante.NewDeductFeeDecorator(ak, bankKeeper, fgk),
authante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators
authante.NewValidateSigCountDecorator(ak),
authante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
authante.NewSigVerificationDecorator(ak, signModeHandler),
authante.NewIncrementSequenceDecorator(ak),
ibcante.NewAnteDecorator(ibcKeeper),
)
}