forked from sentinel-official/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathante.go
56 lines (50 loc) · 2.12 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
45
46
47
48
49
50
51
52
53
54
55
56
package hub
import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
)
type HandlerOptions struct {
authante.HandlerOptions
IBCKeeper *ibckeeper.Keeper
TxCounterStoreKey sdk.StoreKey
WasmConfig wasmtypes.WasmConfig
}
func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
if opts.AccountKeeper == nil {
return nil, errors.Wrap(errors.ErrLogic, "account keeper is required for ante handler")
}
if opts.BankKeeper == nil {
return nil, errors.Wrap(errors.ErrLogic, "bank keeper is required for ante handler")
}
if opts.SignModeHandler == nil {
return nil, errors.Wrap(errors.ErrLogic, "sign mode handler is required for ante handler")
}
var sigGasConsumer = opts.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = authante.DefaultSigVerificationGasConsumer
}
anteDecorators := []sdk.AnteDecorator{
authante.NewSetUpContextDecorator(),
wasmkeeper.NewLimitSimulationGasDecorator(opts.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(opts.TxCounterStoreKey),
authante.NewRejectExtensionOptionsDecorator(),
authante.NewMempoolFeeDecorator(),
authante.NewValidateBasicDecorator(),
authante.NewTxTimeoutHeightDecorator(),
authante.NewValidateMemoDecorator(opts.AccountKeeper),
authante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper),
authante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper),
authante.NewSetPubKeyDecorator(opts.AccountKeeper),
authante.NewValidateSigCountDecorator(opts.AccountKeeper),
authante.NewSigGasConsumeDecorator(opts.AccountKeeper, sigGasConsumer),
authante.NewSigVerificationDecorator(opts.AccountKeeper, opts.SignModeHandler),
authante.NewIncrementSequenceDecorator(opts.AccountKeeper),
ibcante.NewAnteDecorator(opts.IBCKeeper),
}
return sdk.ChainAnteDecorators(anteDecorators...), nil
}