NewAnteHandler returns an AnteHandler that checks and increments sequence numbers, checks signatures & account numbers, and deducts fees from the first signer.
(options HandlerOptions)
| 19 | // numbers, checks signatures & account numbers, and deducts fees from the first |
| 20 | // signer. |
| 21 | func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { |
| 22 | if options.AccountKeeper == nil { |
| 23 | return nil, sdkerrors.ErrLogic.Wrap("account keeper is required for ante builder") |
| 24 | } |
| 25 | |
| 26 | if options.BankKeeper == nil { |
| 27 | return nil, sdkerrors.ErrLogic.Wrap("bank keeper is required for ante builder") |
| 28 | } |
| 29 | |
| 30 | if options.SignModeHandler == nil { |
| 31 | return nil, sdkerrors.ErrLogic.Wrap("sign mode handler is required for ante builder") |
| 32 | } |
| 33 | |
| 34 | if options.SigGasConsumer == nil { |
| 35 | return nil, sdkerrors.ErrLogic.Wrap("sig gas consumer handler is required for ante builder") |
| 36 | } |
| 37 | |
| 38 | if options.GovKeeper == nil { |
| 39 | return nil, sdkerrors.ErrLogic.Wrap("akash governance keeper is required for ante builder") |
| 40 | } |
| 41 | |
| 42 | if options.FeegrantKeeper == nil { |
| 43 | return nil, sdkerrors.ErrLogic.Wrap("akash feegrant keeper is required for ante builder") |
| 44 | } |
| 45 | |
| 46 | anteDecorators := []sdk.AnteDecorator{ |
| 47 | ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first |
| 48 | ante.NewValidateBasicDecorator(), |
| 49 | ante.NewTxTimeoutHeightDecorator(), |
| 50 | ante.NewValidateMemoDecorator(options.AccountKeeper), |
| 51 | ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), |
| 52 | ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, nil), |
| 53 | ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators |
| 54 | ante.NewValidateSigCountDecorator(options.AccountKeeper), |
| 55 | ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), |
| 56 | ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler, options.SigVerifyOptions...), |
| 57 | ante.NewIncrementSequenceDecorator(options.AccountKeeper), |
| 58 | } |
| 59 | |
| 60 | return sdk.ChainAnteDecorators(anteDecorators...), nil |
| 61 | } |