diff --git a/docs/architecture/adr-045-check-delivertx-middlewares.md b/docs/architecture/adr-045-check-delivertx-middlewares.md index bb108d401ea4..dfb03d705ebe 100644 --- a/docs/architecture/adr-045-check-delivertx-middlewares.md +++ b/docs/architecture/adr-045-check-delivertx-middlewares.md @@ -4,6 +4,7 @@ * 20.08.2021: Initial draft. * 07.12.2021: Update `tx.Handler` interface ([\#10693](https://github.com/cosmos/cosmos-sdk/pull/10693)). +* 22.03.2022: Update code snippets. ## Status diff --git a/simapp/app.go b/simapp/app.go index c4cd700401d7..8e9b94075df8 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -471,7 +471,6 @@ func (app *SimApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []strin SignModeHandler: txConfig.SignModeHandler(), SigGasConsumer: authmiddleware.DefaultSigVerificationGasConsumer, TxDecoder: txConfig.TxDecoder(), - FeeMarket: authmiddleware.ValidatorTxFee{}, }) if err != nil { panic(err) diff --git a/x/auth/middleware/middleware.go b/x/auth/middleware/middleware.go index 46374c11e93d..54de03760070 100644 --- a/x/auth/middleware/middleware.go +++ b/x/auth/middleware/middleware.go @@ -75,6 +75,11 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { sigGasConsumer = DefaultSigVerificationGasConsumer } + var feeMarket = options.FeeMarket + if feeMarket == nil { + feeMarket = ValidatorTxFee{} + } + return ComposeMiddlewares( NewRunMsgsTxHandler(options.MsgServiceRouter, options.LegacyRouter), NewTxDecoderMiddleware(options.TxDecoder), @@ -94,7 +99,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // tx. RejectExtensionOptionsMiddleware, // Reject auth_info extension options that don't pass the criteria. - NewAuthExtensionOptionsMiddleware(options.FeeMarket.AllowAuthExtensionOption), + NewAuthExtensionOptionsMiddleware(feeMarket.AllowAuthExtensionOption), ValidateBasicMiddleware, TxTimeoutHeightMiddleware, ValidateMemoMiddleware(options.AccountKeeper), @@ -103,7 +108,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // ComposeMiddlewares godoc for details. // `DeductFeeMiddleware` and `IncrementSequenceMiddleware` should be put outside of `WithBranchedStore` middleware, // so their storage writes are not discarded when tx fails. - DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.FeeMarket), + DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, feeMarket), SetPubKeyMiddleware(options.AccountKeeper), ValidateSigCountMiddleware(options.AccountKeeper), SigGasConsumeMiddleware(options.AccountKeeper, sigGasConsumer), diff --git a/x/auth/middleware/middleware_test.go b/x/auth/middleware/middleware_test.go index 058b44ea890a..d923b84b2c3d 100644 --- a/x/auth/middleware/middleware_test.go +++ b/x/auth/middleware/middleware_test.go @@ -1026,7 +1026,6 @@ func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() { } }, TxDecoder: s.clientCtx.TxConfig.TxDecoder(), - FeeMarket: middleware.ValidatorTxFee{}, }, ) s.Require().NoError(err) diff --git a/x/auth/middleware/testutil_test.go b/x/auth/middleware/testutil_test.go index 78d49fd9dbd7..f493a463fa2a 100644 --- a/x/auth/middleware/testutil_test.go +++ b/x/auth/middleware/testutil_test.go @@ -90,7 +90,6 @@ func (s *MWTestSuite) SetupTest(isCheckTx bool) sdk.Context { SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: middleware.DefaultSigVerificationGasConsumer, TxDecoder: s.clientCtx.TxConfig.TxDecoder(), - FeeMarket: middleware.ValidatorTxFee{}, }) s.Require().NoError(err) s.txHandler = txHandler