diff --git a/tests/sims/feegrant/operations_test.go b/tests/sims/feegrant/operations_test.go index d280cd6c40..5477287d1c 100644 --- a/tests/sims/feegrant/operations_test.go +++ b/tests/sims/feegrant/operations_test.go @@ -28,7 +28,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codecaddress "github.com/cosmos/cosmos-sdk/codec/address" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" @@ -101,9 +100,8 @@ func (suite *SimTestSuite) TestWeightedOperations() { appParams := make(simtypes.AppParams) weightedOps := simulation.WeightedOperations( - suite.interfaceRegistry, - appParams, suite.cdc, suite.txConfig, suite.accountKeeper, - suite.bankKeeper, suite.feegrantKeeper, codecaddress.NewBech32Codec("cosmos"), + appParams, suite.txConfig, suite.accountKeeper, + suite.bankKeeper, suite.feegrantKeeper, ) s := rand.NewSource(1) @@ -153,7 +151,7 @@ func (suite *SimTestSuite) TestSimulateMsgGrantAllowance() { require.NoError(err) // execute operation - op := simulation.SimulateMsgGrantAllowance(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper) + op := simulation.SimulateMsgGrantAllowance(suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper) operationMsg, futureOperations, err := op(r, app.BaseApp, ctx.WithHeaderInfo(header.Info{Time: time.Now()}), accounts, "") require.NoError(err) @@ -197,7 +195,7 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeAllowance() { require.NoError(err) // execute operation - op := simulation.SimulateMsgRevokeAllowance(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper) + op := simulation.SimulateMsgRevokeAllowance(suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper) operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(err) diff --git a/x/feegrant/CHANGELOG.md b/x/feegrant/CHANGELOG.md index 13d29accbc..9f565f739c 100644 --- a/x/feegrant/CHANGELOG.md +++ b/x/feegrant/CHANGELOG.md @@ -31,12 +31,15 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* [#21377](https://github.com/cosmos/cosmos-sdk/pull/21377) Simulation API breaking changes: + * `SimulateMsgGrantAllowance` and `SimulateMsgRevokeAllowance` no longer require a `ProtoCodec` parameter. + * `WeightedOperations` functions no longer require `ProtoCodec`, `JSONCodec`, or `address.Codec` parameters. * [#20529](https://github.com/cosmos/cosmos-sdk/pull/20529) `Accept` on the `FeeAllowanceI` interface now expects the feegrant environment in the `context.Context`. * [#19450](https://github.com/cosmos/cosmos-sdk/pull/19450) Migrate module to use `appmodule.Environment` instead of passing individual services. ### Consensus Breaking Changes -* [#19188](https://github.com/cosmos/cosmos-sdk/pull/19188) Remove creation of `BaseAccount` when sending a message to an account that does not exist +* [#19188](https://github.com/cosmos/cosmos-sdk/pull/19188) Remove creation of `BaseAccount` when sending a message to an account that does not exist. ## [v0.1.1](https://github.com/cosmos/cosmos-sdk/releases/tag/x/feegrant/v0.1.1) - 2024-04-22 diff --git a/x/feegrant/basic_fee.go b/x/feegrant/basic_fee.go index 2100cd5be3..a495d8c3d5 100644 --- a/x/feegrant/basic_fee.go +++ b/x/feegrant/basic_fee.go @@ -72,4 +72,4 @@ func (a BasicAllowance) ExpiresAt() (*time.Time, error) { } // UpdatePeriodReset BasicAllowance does not update "PeriodReset" -func (a BasicAllowance) UpdatePeriodReset(validTime time.Time) error { return nil } +func (a BasicAllowance) UpdatePeriodReset(_ time.Time) error { return nil } diff --git a/x/feegrant/basic_fee_test.go b/x/feegrant/basic_fee_test.go index 2ea7ad3008..5f086ebc43 100644 --- a/x/feegrant/basic_fee_test.go +++ b/x/feegrant/basic_fee_test.go @@ -130,8 +130,7 @@ func TestBasicFeeValidAllow(t *testing.T) { }, } - for name, stc := range cases { - tc := stc // to make scopelint happy + for name, tc := range cases { t.Run(name, func(t *testing.T) { err := tc.allowance.UpdatePeriodReset(tc.blockTime) require.NoError(t, err) diff --git a/x/feegrant/client/cli/tx_test.go b/x/feegrant/client/cli/tx_test.go index 61c32ea34e..4d8c07e4b5 100644 --- a/x/feegrant/client/cli/tx_test.go +++ b/x/feegrant/client/cli/tx_test.go @@ -446,7 +446,7 @@ func (s *CLITestSuite) TestTxWithFeeGrant() { granterAddr, err := s.baseCtx.AddressCodec.BytesToString(granter) s.Require().NoError(err) - // creating an account manually (This account won't be exist in state) + // creating an account manually (This account won't exist in state) k, _, err := s.baseCtx.Keyring.NewMnemonic("grantee", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) s.Require().NoError(err) pub, err := k.GetPubKey() diff --git a/x/feegrant/fees.go b/x/feegrant/fees.go index d229512f93..4675b0449e 100644 --- a/x/feegrant/fees.go +++ b/x/feegrant/fees.go @@ -19,7 +19,7 @@ type FeeAllowanceI interface { // and will be saved again after an acceptance. // // If remove is true (regardless of the error), the FeeAllowance will be deleted from storage - // (eg. when it is used up). (See call to RevokeAllowance in Keeper.UseGrantedFees) + // (e.g. when it is used up). (See call to RevokeAllowance in Keeper.UseGrantedFees) Accept(ctx context.Context, fee sdk.Coins, msgs []sdk.Msg) (remove bool, err error) // ValidateBasic should evaluate this FeeAllowance for internal consistency. diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index 68e2fa681c..3005ec9646 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -63,12 +63,13 @@ func (a *AllowedMsgAllowance) GetAllowance() (FeeAllowanceI, error) { // SetAllowance sets allowed fee allowance. func (a *AllowedMsgAllowance) SetAllowance(allowance FeeAllowanceI) error { - var err error - a.Allowance, err = types.NewAnyWithValue(allowance.(proto.Message)) + newAllowance, err := types.NewAnyWithValue(allowance.(proto.Message)) if err != nil { return errorsmod.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", allowance) } + a.Allowance = newAllowance + return nil } @@ -96,8 +97,8 @@ func (a *AllowedMsgAllowance) Accept(ctx context.Context, fee sdk.Coins, msgs [] return remove, err } -func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx context.Context) (map[string]bool, error) { - msgsMap := make(map[string]bool, len(a.AllowedMessages)) +func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx context.Context) (map[string]struct{}, error) { + msgsMap := make(map[string]struct{}, len(a.AllowedMessages)) environment, ok := ctx.Value(corecontext.EnvironmentContextKey).(appmodule.Environment) if !ok { return nil, errors.New("environment not set") @@ -107,7 +108,7 @@ func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx context.Context) (map[string] if err := gasMeter.Consume(gasCostPerIteration, "check msg"); err != nil { return nil, err } - msgsMap[msg] = true + msgsMap[msg] = struct{}{} } return msgsMap, nil @@ -127,7 +128,7 @@ func (a *AllowedMsgAllowance) allMsgTypesAllowed(ctx context.Context, msgs []sdk if err := gasMeter.Consume(gasCostPerIteration, "check msg"); err != nil { return false, err } - if !msgsMap[sdk.MsgTypeURL(msg)] { + if _, allowed := msgsMap[sdk.MsgTypeURL(msg)]; !allowed { return false, nil } } diff --git a/x/feegrant/filtered_fee_test.go b/x/feegrant/filtered_fee_test.go index f4ecf2dc15..9ca967bc0d 100644 --- a/x/feegrant/filtered_fee_test.go +++ b/x/feegrant/filtered_fee_test.go @@ -141,8 +141,7 @@ func TestFilteredFeeValidAllow(t *testing.T) { }, } - for name, stc := range cases { - tc := stc // to make scopelint happy + for name, tc := range cases { t.Run(name, func(t *testing.T) { err := tc.allowance.ValidateBasic() require.NoError(t, err) @@ -150,7 +149,7 @@ func TestFilteredFeeValidAllow(t *testing.T) { ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: tc.blockTime}) // create grant - var granter, grantee sdk.AccAddress + granter, grantee := sdk.AccAddress("granter"), sdk.AccAddress("grantee") allowance, err := feegrant.NewAllowedMsgAllowance(tc.allowance, tc.msgs) require.NoError(t, err) granterStr, err := ac.BytesToString(granter) diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index ad3f5d59c6..b59fd7caa0 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -190,7 +190,7 @@ func (k Keeper) revokeAllowance(ctx context.Context, granter, grantee sdk.AccAdd } // GetAllowance returns the allowance between the granter and grantee. -// If there is none, it returns nil, nil. +// If there is none, it returns nil, collections.ErrNotFound. // Returns an error on parsing issues func (k Keeper) GetAllowance(ctx context.Context, granter, grantee sdk.AccAddress) (feegrant.FeeAllowanceI, error) { grant, err := k.FeeAllowance.Get(ctx, collections.Join(grantee, granter)) diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index 04c11eda9d..1a682e73a5 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -167,7 +167,6 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { } for name, tc := range cases { - tc := tc suite.Run(name, func() { allow, _ := suite.feegrantKeeper.GetAllowance(suite.ctx, tc.granter, tc.grantee) @@ -261,7 +260,6 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { } for name, tc := range cases { - tc := tc suite.Run(name, func() { err := suite.feegrantKeeper.GrantAllowance(suite.ctx, tc.granter, tc.grantee, future) suite.Require().NoError(err) @@ -298,9 +296,9 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { suite.Contains(err.Error(), "fee allowance expired") // verify: feegrant is not revoked - // Because using the past feegrant will return err, data will be rolled back in actual scenarios. - // Only when the feegrant allowance used up in a certain transaction feegrant will revoked success due to err is nil - // abci's EndBlocker will remove the expired feegrant. + // The expired feegrant is not automatically revoked when attempting to use it. + // This is because the transaction using an expired feegrant would fail and be rolled back. + // Expired feegrants are typically cleaned up by the ABCI EndBlocker, not by failed usage attempts. _, err = suite.feegrantKeeper.GetAllowance(ctx, suite.addrs[0], suite.addrs[2]) suite.Require().NoError(err) } @@ -344,8 +342,6 @@ func (suite *KeeperTestSuite) TestPruneGrants() { grantee sdk.AccAddress allowance feegrant.FeeAllowanceI expErrMsg string - preRun func() - postRun func() }{ { name: "grant pruned from state after a block: error", @@ -412,11 +408,7 @@ func (suite *KeeperTestSuite) TestPruneGrants() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { - if tc.preRun != nil { - tc.preRun() - } err := suite.feegrantKeeper.GrantAllowance(suite.ctx, tc.granter, tc.grantee, tc.allowance) suite.NoError(err) err = suite.feegrantKeeper.RemoveExpiredAllowances(tc.ctx, 5) @@ -430,10 +422,6 @@ func (suite *KeeperTestSuite) TestPruneGrants() { suite.NoError(err) suite.NotNil(grant) } - - if tc.postRun != nil { - tc.postRun() - } }) } } diff --git a/x/feegrant/keeper/msg_server_test.go b/x/feegrant/keeper/msg_server_test.go index 46bde3e93e..50f21da5bd 100644 --- a/x/feegrant/keeper/msg_server_test.go +++ b/x/feegrant/keeper/msg_server_test.go @@ -29,8 +29,8 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { errMsg string }{ { - "invalid granter address", - func() *feegrant.MsgGrantAllowance { + name: "invalid granter address", + req: func() *feegrant.MsgGrantAllowance { any, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{}) suite.Require().NoError(err) invalid := "invalid-granter" @@ -40,12 +40,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - true, - "decoding bech32 failed", + expectErr: true, + errMsg: "decoding bech32 failed", }, { - "invalid grantee address", - func() *feegrant.MsgGrantAllowance { + name: "invalid grantee address", + req: func() *feegrant.MsgGrantAllowance { any, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{}) suite.Require().NoError(err) invalid := "invalid-grantee" @@ -55,12 +55,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - true, - "decoding bech32 failed", + expectErr: true, + errMsg: "decoding bech32 failed", }, { - "valid: grantee account doesn't exist", - func() *feegrant.MsgGrantAllowance { + name: "valid: grantee account doesn't exist", + req: func() *feegrant.MsgGrantAllowance { grantee := "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5" granteeAccAddr, err := addressCodec.StringToBytes(grantee) suite.Require().NoError(err) @@ -85,12 +85,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - false, - "", + expectErr: false, + errMsg: "", }, { - "invalid: past expiry", - func() *feegrant.MsgGrantAllowance { + name: "invalid: past expiry", + req: func() *feegrant.MsgGrantAllowance { any, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{ SpendLimit: suite.atom, Expiration: &yesterday, @@ -102,12 +102,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - true, - "expiration is before current block time", + expectErr: true, + errMsg: "expiration is before current block time", }, { - "valid: basic fee allowance", - func() *feegrant.MsgGrantAllowance { + name: "valid: basic fee allowance", + req: func() *feegrant.MsgGrantAllowance { any, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{ SpendLimit: suite.atom, Expiration: &oneYear, @@ -119,12 +119,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - false, - "", + expectErr: false, + errMsg: "", }, { - "fail: fee allowance exists", - func() *feegrant.MsgGrantAllowance { + name: "fail: fee allowance exists", + req: func() *feegrant.MsgGrantAllowance { any, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{ SpendLimit: suite.atom, Expiration: &oneYear, @@ -136,12 +136,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - true, - "fee allowance already exists", + expectErr: true, + errMsg: "fee allowance already exists", }, { - "valid: periodic fee allowance", - func() *feegrant.MsgGrantAllowance { + name: "valid: periodic fee allowance", + req: func() *feegrant.MsgGrantAllowance { any, err := codectypes.NewAnyWithValue(&feegrant.PeriodicAllowance{ Basic: feegrant.BasicAllowance{ SpendLimit: suite.atom, @@ -156,12 +156,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - false, - "", + expectErr: false, + errMsg: "", }, { - "valid: with period reset", - func() *feegrant.MsgGrantAllowance { + name: "valid: with period reset", + req: func() *feegrant.MsgGrantAllowance { any, err := codectypes.NewAnyWithValue(&feegrant.PeriodicAllowance{ Basic: feegrant.BasicAllowance{ SpendLimit: suite.atom, @@ -178,12 +178,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - false, - "", + expectErr: false, + errMsg: "", }, { - "error: fee allowance exists", - func() *feegrant.MsgGrantAllowance { + name: "error: fee allowance exists", + req: func() *feegrant.MsgGrantAllowance { any, err := codectypes.NewAnyWithValue(&feegrant.PeriodicAllowance{ Basic: feegrant.BasicAllowance{ SpendLimit: suite.atom, @@ -198,8 +198,8 @@ func (suite *KeeperTestSuite) TestGrantAllowance() { Allowance: any, } }, - true, - "fee allowance already exists", + expectErr: true, + errMsg: "fee allowance already exists", }, } for _, tc := range testCases { @@ -225,42 +225,42 @@ func (suite *KeeperTestSuite) TestRevokeAllowance() { errMsg string }{ { - "error: invalid granter", - &feegrant.MsgRevokeAllowance{ + name: "error: invalid granter", + request: &feegrant.MsgRevokeAllowance{ Granter: invalidGranter, Grantee: suite.encodedAddrs[1], }, - func() {}, - true, - "decoding bech32 failed", + preRun: func() {}, + expectErr: true, + errMsg: "decoding bech32 failed", }, { - "error: invalid grantee", - &feegrant.MsgRevokeAllowance{ + name: "error: invalid grantee", + request: &feegrant.MsgRevokeAllowance{ Granter: suite.encodedAddrs[0], Grantee: invalidGrantee, }, - func() {}, - true, - "decoding bech32 failed", + preRun: func() {}, + expectErr: true, + errMsg: "decoding bech32 failed", }, { - "error: fee allowance not found", - &feegrant.MsgRevokeAllowance{ + name: "error: fee allowance not found", + request: &feegrant.MsgRevokeAllowance{ Granter: suite.encodedAddrs[0], Grantee: suite.encodedAddrs[1], }, - func() {}, - true, - "not found", + preRun: func() {}, + expectErr: true, + errMsg: "not found", }, { - "success: revoke fee allowance", - &feegrant.MsgRevokeAllowance{ + name: "success: revoke fee allowance", + request: &feegrant.MsgRevokeAllowance{ Granter: suite.encodedAddrs[0], Grantee: suite.encodedAddrs[1], }, - func() { + preRun: func() { // removing fee allowance from previous tests if exists _, err := suite.msgSrvr.RevokeAllowance(suite.ctx, &feegrant.MsgRevokeAllowance{ Granter: suite.encodedAddrs[0], @@ -283,18 +283,18 @@ func (suite *KeeperTestSuite) TestRevokeAllowance() { _, err = suite.msgSrvr.GrantAllowance(suite.ctx, req) suite.Require().NoError(err) }, - false, - "", + expectErr: false, + errMsg: "", }, { - "error: check fee allowance revoked", - &feegrant.MsgRevokeAllowance{ + name: "error: check fee allowance revoked", + request: &feegrant.MsgRevokeAllowance{ Granter: suite.encodedAddrs[0], Grantee: suite.encodedAddrs[1], }, - func() {}, - true, - "not found", + preRun: func() {}, + expectErr: true, + errMsg: "not found", }, } diff --git a/x/feegrant/migrations/v2/store.go b/x/feegrant/migrations/v2/store.go index 82a76eacfe..93551a4ed9 100644 --- a/x/feegrant/migrations/v2/store.go +++ b/x/feegrant/migrations/v2/store.go @@ -19,8 +19,7 @@ func addAllowancesByExpTimeQueue(ctx context.Context, env appmodule.Environment, for ; iterator.Valid(); iterator.Next() { var grant feegrant.Grant - bz := iterator.Value() - if err := cdc.Unmarshal(bz, &grant); err != nil { + if err := cdc.Unmarshal(iterator.Value(), &grant); err != nil { return err } @@ -41,8 +40,7 @@ func addAllowancesByExpTimeQueue(ctx context.Context, env appmodule.Environment, prefixStore.Delete(key) } else { grantByExpTimeQueueKey := FeeAllowancePrefixQueue(exp, key) - err = store.Set(grantByExpTimeQueueKey, []byte{}) - if err != nil { + if err := store.Set(grantByExpTimeQueueKey, []byte{}); err != nil { return err } } diff --git a/x/feegrant/mock_test.go b/x/feegrant/mock_test.go index ae2f1f13b4..a999149b04 100644 --- a/x/feegrant/mock_test.go +++ b/x/feegrant/mock_test.go @@ -19,7 +19,7 @@ type mockGasService struct { coregas.Service } -func (m mockGasService) GasMeter(ctx context.Context) coregas.Meter { +func (m mockGasService) GasMeter(_ context.Context) coregas.Meter { return mockGasMeter{} } @@ -27,6 +27,6 @@ type mockGasMeter struct { coregas.Meter } -func (m mockGasMeter) Consume(amount coregas.Gas, descriptor string) error { +func (m mockGasMeter) Consume(_ coregas.Gas, _ string) error { return nil } diff --git a/x/feegrant/module/abci_test.go b/x/feegrant/module/abci_test.go index feeead80a5..20c74ebf37 100644 --- a/x/feegrant/module/abci_test.go +++ b/x/feegrant/module/abci_test.go @@ -87,13 +87,20 @@ func TestFeegrantPruning(t *testing.T) { feegrant.RegisterQueryServer(queryHelper, feegrantKeeper) queryClient := feegrant.NewQueryClient(queryHelper) - require.NoError(t, module.EndBlocker(testCtx.Ctx, feegrantKeeper)) - granteeStr, err := ac.BytesToString(grantee) require.NoError(t, err) - res, err := queryClient.Allowances(testCtx.Ctx.Context(), &feegrant.QueryAllowancesRequest{ + queryRequest := &feegrant.QueryAllowancesRequest{ Grantee: granteeStr, - }) + } + + res, err := queryClient.Allowances(testCtx.Ctx.Context(), queryRequest) + require.NoError(t, err) + require.NotNil(t, res) + require.Len(t, res.Allowances, 3) + + require.NoError(t, module.EndBlocker(testCtx.Ctx, feegrantKeeper)) + + res, err = queryClient.Allowances(testCtx.Ctx.Context(), queryRequest) require.NoError(t, err) require.NotNil(t, res) require.Len(t, res.Allowances, 2) @@ -101,9 +108,7 @@ func TestFeegrantPruning(t *testing.T) { testCtx.Ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: now.AddDate(0, 0, 2)}) require.NoError(t, module.EndBlocker(testCtx.Ctx, feegrantKeeper)) - res, err = queryClient.Allowances(testCtx.Ctx.Context(), &feegrant.QueryAllowancesRequest{ - Grantee: granteeStr, - }) + res, err = queryClient.Allowances(testCtx.Ctx.Context(), queryRequest) require.NoError(t, err) require.NotNil(t, res) require.Len(t, res.Allowances, 1) diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 163c91cef1..5fde472bdb 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -170,7 +170,7 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { // WeightedOperations returns all the feegrant module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - am.registry, simState.AppParams, simState.Cdc, simState.TxConfig, - am.accountKeeper, am.bankKeeper, am.keeper, am.accountKeeper.AddressCodec(), + simState.AppParams, simState.TxConfig, + am.accountKeeper, am.bankKeeper, am.keeper, ) } diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index 59c3d0d7df..65bd53d528 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -3,13 +3,10 @@ package simulation import ( "math/rand" - "cosmossdk.io/core/address" "cosmossdk.io/x/feegrant" "cosmossdk.io/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -29,14 +26,11 @@ var ( ) func WeightedOperations( - registry codectypes.InterfaceRegistry, appParams simtypes.AppParams, - cdc codec.JSONCodec, txConfig client.TxConfig, ak feegrant.AccountKeeper, bk feegrant.BankKeeper, k keeper.Keeper, - ac address.Codec, ) simulation.WeightedOperations { var ( weightMsgGrantAllowance int @@ -55,23 +49,20 @@ func WeightedOperations( }, ) - pCdc := codec.NewProtoCodec(registry) - return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgGrantAllowance, - SimulateMsgGrantAllowance(pCdc, txConfig, ak, bk, k), + SimulateMsgGrantAllowance(txConfig, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgRevokeAllowance, - SimulateMsgRevokeAllowance(pCdc, txConfig, ak, bk, k), + SimulateMsgRevokeAllowance(txConfig, ak, bk, k), ), } } // SimulateMsgGrantAllowance generates MsgGrantAllowance with random values. func SimulateMsgGrantAllowance( - cdc *codec.ProtoCodec, txConfig client.TxConfig, ak feegrant.AccountKeeper, bk feegrant.BankKeeper, @@ -135,7 +126,6 @@ func SimulateMsgGrantAllowance( // SimulateMsgRevokeAllowance generates a MsgRevokeAllowance with random values. func SimulateMsgRevokeAllowance( - cdc *codec.ProtoCodec, txConfig client.TxConfig, ak feegrant.AccountKeeper, bk feegrant.BankKeeper,