From d29e8eb4f6ac9c26de7b6f275eb5552f7c862f20 Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Mon, 27 Mar 2023 15:57:02 -0300 Subject: [PATCH] refactor!: use KVStoreService in x/auth (#15520) Co-authored-by: Aleksandr Bezobchuk --- CHANGELOG.md | 1 + UPGRADING.md | 32 +++++--- runtime/store.go | 72 ++++++++++++++++++ simapp/app.go | 2 +- tests/integration/bank/keeper/keeper_test.go | 11 ++- x/auth/ante/expected_keepers.go | 8 +- .../ante/testutil/expected_keepers_mocks.go | 7 +- x/auth/ante/testutil_test.go | 4 +- x/auth/keeper/account.go | 76 +++++++++++++------ x/auth/keeper/deterministic_test.go | 14 +++- x/auth/keeper/grpc_query.go | 8 +- x/auth/keeper/keeper.go | 67 ++++++++-------- x/auth/keeper/keeper_test.go | 5 +- x/auth/keeper/migrations.go | 9 +-- x/auth/keeper/params.go | 21 ++--- x/auth/migrations/v2/store_test.go | 5 +- x/auth/migrations/v3/store.go | 14 ++-- x/auth/migrations/v3/store_test.go | 5 +- x/auth/migrations/v4/migrate.go | 5 +- x/auth/migrations/v4/migrate_test.go | 8 +- x/auth/module.go | 10 +-- x/auth/vesting/msg_server_test.go | 4 +- x/auth/vesting/types/vesting_account_test.go | 4 +- x/authz/expected_keepers.go | 8 +- x/authz/testutil/expected_keepers_mocks.go | 7 +- x/bank/testutil/expected_keepers_mocks.go | 21 ++--- x/bank/types/expected_keepers.go | 22 +++--- .../testutil/expected_keepers_mocks.go | 7 +- x/distribution/types/expected_keepers.go | 8 +- x/evidence/testutil/expected_keepers_mocks.go | 3 +- x/evidence/types/expected_keepers.go | 3 +- x/feegrant/expected_keepers.go | 10 ++- x/feegrant/go.mod | 2 +- x/feegrant/go.sum | 4 + x/feegrant/testutil/expected_keepers_mocks.go | 9 ++- x/genutil/testutil/expected_keepers_mocks.go | 7 +- x/genutil/types/expected_keepers.go | 7 +- x/gov/testutil/expected_keepers.go | 4 +- x/gov/testutil/expected_keepers_mocks.go | 8 +- x/gov/types/expected_keepers.go | 8 +- x/group/expected_keepers.go | 10 ++- x/group/migrations/v2/migrate_test.go | 3 +- x/group/testutil/expected_keepers_mocks.go | 8 +- x/mint/testutil/expected_keepers_mocks.go | 5 +- x/mint/types/expected_keepers.go | 6 +- x/nft/expected_keepers.go | 4 +- x/nft/go.mod | 2 +- x/nft/go.sum | 6 +- x/nft/testutil/expected_keepers_mocks.go | 3 +- x/simulation/expected_keepers.go | 4 +- x/slashing/testutil/expected_keepers_mocks.go | 5 +- x/slashing/types/expected_keepers.go | 6 +- x/staking/testutil/expected_keepers_mocks.go | 9 ++- x/staking/types/expected_keepers.go | 10 ++- 54 files changed, 404 insertions(+), 207 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63d54ecae842..5f681ba78916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* (x/auth) [#15517](https://github.com/cosmos/cosmos-sdk/pull/15517) `NewAccountKeeper` now takes a `KVStoreService` instead of a `StoreKey` and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context`. * (x/consensus) [#15517](https://github.com/cosmos/cosmos-sdk/pull/15517) `NewKeeper` now takes a `KVStoreService` instead of a `StoreKey`. * (x/bank) [#15477](https://github.com/cosmos/cosmos-sdk/pull/15477) `banktypes.NewMsgMultiSend` and `keeper.InputOutputCoins` only accept one input. * (mempool) [#15328](https://github.com/cosmos/cosmos-sdk/pull/15328) The `PriorityNonceMempool` is now generic over type `C comparable` and takes a single `PriorityNonceMempoolConfig[C]` argument. See `DefaultPriorityNonceMempoolConfig` for how to construct the configuration and a `TxPriority` type. diff --git a/UPGRADING.md b/UPGRADING.md index 19da06f04ccd..e29a8b2c8cfe 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -62,6 +62,25 @@ The `gogoproto.goproto_stringer = false` annotation has been removed from most p Previously, all modules were required to be set in `OrderBeginBlockers`, `OrderEndBlockers` and `OrderInitGenesis / OrderExportGenesis` in `app.go` / `app_config.go`. This is no longer the case, the assertion has been loosened to only require modules implementing, respectively, the `module.BeginBlockAppModule`, `module.EndBlockAppModule` and `module.HasGenesis` interfaces. +### Modules Keepers + +The following modules `NewKeeper` function now take a `KVStoreService` instead of a `StoreKey`: + +- `x/auth` +- `x/consensus` + +When not using depinject, the `runtime.NewKVStoreService` method can be used to create a `KVStoreService` from a `StoreKey`: + +```diff +- app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) ++ app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), +) +``` + + ### Packages #### Store @@ -75,18 +94,13 @@ All the store imports are now renamed to use `cosmossdk.io/store` instead of `gi ### Modules -#### `x/capability` +#### `x/auth` -Capability was moved to [IBC-GO](https://github.com/cosmos/ibc-go). IBC V8 will contain the necessary changes to incorporate the new module location +Methods in the `AccountKeeper` now use `context.Context` instead of `sdk.Context`. Any module that has an interface for it will need to update and re-generate mocks if needed. -#### `x/consensus` - -The `NewKeeper` method now takes a `KVStoreService` instead of a `StoreKey`. When not using depinject, the `runtime.NewKVStoreService` method can be used to create a `KVStoreService` from a `StoreKey`. +#### `x/capability` -```diff -- app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) -+ app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String()) -``` +Capability was moved to [IBC-GO](https://github.com/cosmos/ibc-go). IBC V8 will contain the necessary changes to incorporate the new module location #### `x/gov` diff --git a/runtime/store.go b/runtime/store.go index ed4a11dda11b..ec86f99964ba 100644 --- a/runtime/store.go +++ b/runtime/store.go @@ -2,11 +2,14 @@ package runtime import ( "context" + "io" "cosmossdk.io/core/store" storetypes "cosmossdk.io/store/types" + dbm "github.com/cosmos/cosmos-db" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -90,3 +93,72 @@ func (store coreKVStore) Iterator(start, end []byte) (store.Iterator, error) { func (store coreKVStore) ReverseIterator(start, end []byte) (store.Iterator, error) { return store.kvStore.ReverseIterator(start, end), nil } + +// Adapter +var _ storetypes.KVStore = kvStoreAdapter{} + +type kvStoreAdapter struct { + store store.KVStore +} + +func (kvStoreAdapter) CacheWrap() storetypes.CacheWrap { + panic("unimplemented") +} + +func (kvStoreAdapter) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap { + panic("unimplemented") +} + +func (kvStoreAdapter) GetStoreType() storetypes.StoreType { + panic("unimplemented") +} + +func (s kvStoreAdapter) Delete(key []byte) { + err := s.store.Delete(key) + if err != nil { + panic(err) + } +} + +func (s kvStoreAdapter) Get(key []byte) []byte { + bz, err := s.store.Get(key) + if err != nil { + panic(err) + } + return bz +} + +func (s kvStoreAdapter) Has(key []byte) bool { + has, err := s.store.Has(key) + if err != nil { + panic(err) + } + return has +} + +func (s kvStoreAdapter) Set(key []byte, value []byte) { + err := s.store.Set(key, value) + if err != nil { + panic(err) + } +} + +func (s kvStoreAdapter) Iterator(start []byte, end []byte) dbm.Iterator { + it, err := s.store.Iterator(start, end) + if err != nil { + panic(err) + } + return it +} + +func (s kvStoreAdapter) ReverseIterator(start []byte, end []byte) dbm.Iterator { + it, err := s.store.ReverseIterator(start, end) + if err != nil { + panic(err) + } + return it +} + +func KVStoreAdapter(store store.KVStore) storetypes.KVStore { + return &kvStoreAdapter{store} +} diff --git a/simapp/app.go b/simapp/app.go index 61ff5568319d..f4734dc4e957 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -289,7 +289,7 @@ func NewSimApp( bApp.SetParamStore(&app.ConsensusParamsKeeper) // add keepers - app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, keys[authtypes.StoreKey], authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, diff --git a/tests/integration/bank/keeper/keeper_test.go b/tests/integration/bank/keeper/keeper_test.go index cfbc59072959..3daaa4f9a099 100644 --- a/tests/integration/bank/keeper/keeper_test.go +++ b/tests/integration/bank/keeper/keeper_test.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/configurator" "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -158,8 +159,10 @@ func initKeepersWithmAccPerms(f *fixture, blockedAddrs map[string]bool) (authkee maccPerms[authtypes.Minter] = []string{authtypes.Minter} maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} maccPerms[randomPerm] = []string{"random"} + + storeService := runtime.NewKVStoreService(f.fetchStoreKey(authtypes.StoreKey).(*storetypes.KVStoreKey)) authKeeper := authkeeper.NewAccountKeeper( - appCodec, f.fetchStoreKey(types.StoreKey), authtypes.ProtoBaseAccount, + appCodec, storeService, authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) bankKeeper := keeper.NewBaseKeeper( @@ -1194,8 +1197,9 @@ func TestBalanceTrackingEvents(t *testing.T) { maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} + storeService := runtime.NewKVStoreService(f.fetchStoreKey(authtypes.StoreKey).(*storetypes.KVStoreKey)) f.accountKeeper = authkeeper.NewAccountKeeper( - f.appCodec, f.fetchStoreKey(authtypes.StoreKey), + f.appCodec, storeService, authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -1324,9 +1328,10 @@ func TestMintCoinRestrictions(t *testing.T) { maccPerms := make(map[string][]string) maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} + storeService := runtime.NewKVStoreService(f.fetchStoreKey(authtypes.StoreKey).(*storetypes.KVStoreKey)) f.accountKeeper = authkeeper.NewAccountKeeper( - f.appCodec, f.fetchStoreKey(authtypes.StoreKey), + f.appCodec, storeService, authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 1db0dff716c1..78575f3e004b 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -1,6 +1,8 @@ package ante import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -8,9 +10,9 @@ import ( // AccountKeeper defines the contract needed for AccountKeeper related APIs. // Interface provides support to use non-sdk AccountKeeper for AnteHandler's decorators. type AccountKeeper interface { - GetParams(ctx sdk.Context) (params types.Params) - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - SetAccount(ctx sdk.Context, acc sdk.AccountI) + GetParams(ctx context.Context) (params types.Params) + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + SetAccount(ctx context.Context, acc sdk.AccountI) GetModuleAddress(moduleName string) sdk.AccAddress } diff --git a/x/auth/ante/testutil/expected_keepers_mocks.go b/x/auth/ante/testutil/expected_keepers_mocks.go index 34c7c68e4ef8..f85a6eed9288 100644 --- a/x/auth/ante/testutil/expected_keepers_mocks.go +++ b/x/auth/ante/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" @@ -36,7 +37,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -64,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{} } // GetParams mocks base method. -func (m *MockAccountKeeper) GetParams(ctx types.Context) types0.Params { +func (m *MockAccountKeeper) GetParams(ctx context.Context) types0.Params { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetParams", ctx) ret0, _ := ret[0].(types0.Params) @@ -78,7 +79,7 @@ func (mr *MockAccountKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index ea539c77ed26..c6207c39aea7 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -11,6 +11,8 @@ import ( // ref: https://github.com/cosmos/cosmos-sdk/issues/14647 _ "cosmossdk.io/api/cosmos/bank/v1beta1" _ "cosmossdk.io/api/cosmos/crypto/secp256k1" + + "github.com/cosmos/cosmos-sdk/runtime" _ "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" storetypes "cosmossdk.io/store/types" @@ -77,7 +79,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { } suite.accountKeeper = keeper.NewAccountKeeper( - suite.encCfg.Codec, key, types.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(), + suite.encCfg.Codec, runtime.NewKVStoreService(key), types.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(), ) suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName) err := suite.accountKeeper.SetParams(suite.ctx, types.DefaultParams()) diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index 80d0a1f77b31..5336ecbec4e6 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -1,6 +1,8 @@ package keeper import ( + "context" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -8,7 +10,7 @@ import ( ) // NewAccountWithAddress implements AccountKeeperI. -func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { +func (ak AccountKeeper) NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI { acc := ak.proto() err := acc.SetAddress(addr) if err != nil { @@ -19,7 +21,7 @@ func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddre } // NewAccount sets the next account number to a given account interface -func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc sdk.AccountI) sdk.AccountI { +func (ak AccountKeeper) NewAccount(ctx context.Context, acc sdk.AccountI) sdk.AccountI { if err := acc.SetAccountNumber(ak.NextAccountNumber(ctx)); err != nil { panic(err) } @@ -28,21 +30,33 @@ func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc sdk.AccountI) sdk.Accoun } // HasAccount implements AccountKeeperI. -func (ak AccountKeeper) HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool { - store := ctx.KVStore(ak.storeKey) - return store.Has(types.AddressStoreKey(addr)) +func (ak AccountKeeper) HasAccount(ctx context.Context, addr sdk.AccAddress) bool { + store := ak.storeService.OpenKVStore(ctx) + has, err := store.Has(types.AddressStoreKey(addr)) + if err != nil { + panic(err) + } + return has } // HasAccountAddressByID checks account address exists by id. -func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool { - store := ctx.KVStore(ak.storeKey) - return store.Has(types.AccountNumberStoreKey(id)) +func (ak AccountKeeper) HasAccountAddressByID(ctx context.Context, id uint64) bool { + store := ak.storeService.OpenKVStore(ctx) + has, err := store.Has(types.AccountNumberStoreKey(id)) + if err != nil { + panic(err) + } + return has } // GetAccount implements AccountKeeperI. -func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { - store := ctx.KVStore(ak.storeKey) - bz := store.Get(types.AddressStoreKey(addr)) +func (ak AccountKeeper) GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI { + store := ak.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.AddressStoreKey(addr)) + if err != nil { + panic(err) + } + if bz == nil { return nil } @@ -51,9 +65,13 @@ func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.Acc } // GetAccountAddressById returns account address by id. -func (ak AccountKeeper) GetAccountAddressByID(ctx sdk.Context, id uint64) string { - store := ctx.KVStore(ak.storeKey) - bz := store.Get(types.AccountNumberStoreKey(id)) +func (ak AccountKeeper) GetAccountAddressByID(ctx context.Context, id uint64) string { + store := ak.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.AccountNumberStoreKey(id)) + if err != nil { + panic(err) + } + if bz == nil { return "" } @@ -61,7 +79,7 @@ func (ak AccountKeeper) GetAccountAddressByID(ctx sdk.Context, id uint64) string } // GetAllAccounts returns all accounts in the accountKeeper. -func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []sdk.AccountI) { +func (ak AccountKeeper) GetAllAccounts(ctx context.Context) (accounts []sdk.AccountI) { ak.IterateAccounts(ctx, func(acc sdk.AccountI) (stop bool) { accounts = append(accounts, acc) return false @@ -71,9 +89,9 @@ func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []sdk.AccountI } // SetAccount implements AccountKeeperI. -func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc sdk.AccountI) { +func (ak AccountKeeper) SetAccount(ctx context.Context, acc sdk.AccountI) { addr := acc.GetAddress() - store := ctx.KVStore(ak.storeKey) + store := ak.storeService.OpenKVStore(ctx) bz, err := ak.MarshalAccount(acc) if err != nil { @@ -86,18 +104,28 @@ func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc sdk.AccountI) { // RemoveAccount removes an account for the account mapper store. // NOTE: this will cause supply invariant violation if called -func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc sdk.AccountI) { +func (ak AccountKeeper) RemoveAccount(ctx context.Context, acc sdk.AccountI) { addr := acc.GetAddress() - store := ctx.KVStore(ak.storeKey) - store.Delete(types.AddressStoreKey(addr)) - store.Delete(types.AccountNumberStoreKey(acc.GetAccountNumber())) + store := ak.storeService.OpenKVStore(ctx) + err := store.Delete(types.AddressStoreKey(addr)) + if err != nil { + panic(err) + } + + err = store.Delete(types.AccountNumberStoreKey(acc.GetAccountNumber())) + if err != nil { + panic(err) + } } // IterateAccounts iterates over all the stored accounts and performs a callback function. // Stops iteration when callback returns true. -func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool)) { - store := ctx.KVStore(ak.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix) +func (ak AccountKeeper) IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) (stop bool)) { + store := ak.storeService.OpenKVStore(ctx) + iterator, err := store.Iterator(types.AddressStoreKeyPrefix, storetypes.PrefixEndBytes(types.AddressStoreKeyPrefix)) + if err != nil { + panic(err) + } defer iterator.Close() for ; iterator.Valid(); iterator.Next() { diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 829d28286fc7..f003033a0fb2 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -5,13 +5,16 @@ import ( "sort" "testing" - storetypes "cosmossdk.io/store/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/suite" "pgregory.net/rapid" + corestore "cosmossdk.io/core/store" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -25,6 +28,7 @@ type DeterministicTestSuite struct { suite.Suite key *storetypes.KVStoreKey + storeService corestore.KVStoreService ctx sdk.Context queryClient types.QueryClient accountKeeper keeper.AccountKeeper @@ -47,6 +51,7 @@ func (suite *DeterministicTestSuite) SetupTest() { suite.Require() key := storetypes.NewKVStoreKey(types.StoreKey) + storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) suite.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{}) @@ -61,7 +66,7 @@ func (suite *DeterministicTestSuite) SetupTest() { suite.accountKeeper = keeper.NewAccountKeeper( suite.encCfg.Codec, - key, + storeService, types.ProtoBaseAccount, maccPerms, "cosmos", @@ -73,6 +78,7 @@ func (suite *DeterministicTestSuite) SetupTest() { suite.queryClient = types.NewQueryClient(queryHelper) suite.key = key + suite.storeService = storeService suite.maccPerms = maccPerms } @@ -280,7 +286,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() { ak := keeper.NewAccountKeeper( suite.encCfg.Codec, - suite.key, + suite.storeService, types.ProtoBaseAccount, maccPerms, "cosmos", @@ -326,7 +332,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() { ak := keeper.NewAccountKeeper( suite.encCfg.Codec, - suite.key, + suite.storeService, types.ProtoBaseAccount, maccPerms, "cosmos", diff --git a/x/auth/keeper/grpc_query.go b/x/auth/keeper/grpc_query.go index f8e51411eca1..7571d61361be 100644 --- a/x/auth/keeper/grpc_query.go +++ b/x/auth/keeper/grpc_query.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/store/prefix" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" @@ -40,14 +41,13 @@ func (ak AccountKeeper) AccountAddressByID(c context.Context, req *types.QueryAc return &types.QueryAccountAddressByIDResponse{AccountAddress: address}, nil } -func (ak AccountKeeper) Accounts(c context.Context, req *types.QueryAccountsRequest) (*types.QueryAccountsResponse, error) { +func (ak AccountKeeper) Accounts(ctx context.Context, req *types.QueryAccountsRequest) (*types.QueryAccountsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - ctx := sdk.UnwrapSDKContext(c) - store := ctx.KVStore(ak.storeKey) - accountsStore := prefix.NewStore(store, types.AddressStoreKeyPrefix) + store := ak.storeService.OpenKVStore(ctx) + accountsStore := prefix.NewStore(runtime.KVStoreAdapter(store), types.AddressStoreKeyPrefix) var accounts []*codectypes.Any pageRes, err := query.Paginate(accountsStore, req.Pagination, func(key, value []byte) error { diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index d3b862e7cfee..a59785039623 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -1,14 +1,15 @@ package keeper import ( + "context" "fmt" "cosmossdk.io/log" gogotypes "github.com/cosmos/gogoproto/types" "cosmossdk.io/core/address" + "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" - storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -20,34 +21,34 @@ import ( // AccountKeeperI is the interface contract that x/auth's keeper implements. type AccountKeeperI interface { // Return a new account with the next account number and the specified address. Does not save the new account to the store. - NewAccountWithAddress(sdk.Context, sdk.AccAddress) sdk.AccountI + NewAccountWithAddress(context.Context, sdk.AccAddress) sdk.AccountI // Return a new account with the next account number. Does not save the new account to the store. - NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI + NewAccount(context.Context, sdk.AccountI) sdk.AccountI // Check if an account exists in the store. - HasAccount(sdk.Context, sdk.AccAddress) bool + HasAccount(context.Context, sdk.AccAddress) bool // Retrieve an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI + GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // Set an account in the store. - SetAccount(sdk.Context, sdk.AccountI) + SetAccount(context.Context, sdk.AccountI) // Remove an account from the store. - RemoveAccount(sdk.Context, sdk.AccountI) + RemoveAccount(context.Context, sdk.AccountI) // Iterate over all accounts, calling the provided function. Stop iteration when it returns true. - IterateAccounts(sdk.Context, func(sdk.AccountI) bool) + IterateAccounts(context.Context, func(sdk.AccountI) bool) // Fetch the public key of an account at a specified address - GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error) + GetPubKey(context.Context, sdk.AccAddress) (cryptotypes.PubKey, error) // Fetch the sequence of an account at a specified address. - GetSequence(sdk.Context, sdk.AccAddress) (uint64, error) + GetSequence(context.Context, sdk.AccAddress) (uint64, error) // Fetch the next account number, and increment the internal counter. - NextAccountNumber(sdk.Context) uint64 + NextAccountNumber(context.Context) uint64 // GetModulePermissions fetches per-module account permissions GetModulePermissions() map[string]types.PermissionsForAddress @@ -56,9 +57,9 @@ type AccountKeeperI interface { // AccountKeeper encodes/decodes accounts using the go-amino (binary) // encoding/decoding library. type AccountKeeper struct { - storeKey storetypes.StoreKey - cdc codec.BinaryCodec - permAddrs map[string]types.PermissionsForAddress + storeService store.KVStoreService + cdc codec.BinaryCodec + permAddrs map[string]types.PermissionsForAddress // The prototypical AccountI constructor. proto func() sdk.AccountI @@ -78,7 +79,7 @@ var _ AccountKeeperI = &AccountKeeper{} // and don't have to fit into any predefined structure. This auth module does not use account permissions internally, though other modules // may use auth.Keeper to access the accounts permissions map. func NewAccountKeeper( - cdc codec.BinaryCodec, storeKey storetypes.StoreKey, proto func() sdk.AccountI, + cdc codec.BinaryCodec, storeService store.KVStoreService, proto func() sdk.AccountI, maccPerms map[string][]string, bech32Prefix string, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) @@ -89,12 +90,12 @@ func NewAccountKeeper( bech32Codec := NewBech32Codec(bech32Prefix) return AccountKeeper{ - storeKey: storeKey, - proto: proto, - cdc: cdc, - permAddrs: permAddrs, - addressCdc: bech32Codec, - authority: authority, + storeService: storeService, + proto: proto, + cdc: cdc, + permAddrs: permAddrs, + addressCdc: bech32Codec, + authority: authority, } } @@ -110,12 +111,12 @@ func (ak AccountKeeper) GetAddressCodec() address.Codec { } // Logger returns a module-specific logger. -func (ak AccountKeeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) +func (ak AccountKeeper) Logger(ctx context.Context) log.Logger { + return sdk.UnwrapSDKContext(ctx).Logger().With("module", "x/"+types.ModuleName) } // GetPubKey Returns the PubKey of the account at address -func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) { +func (ak AccountKeeper) GetPubKey(ctx context.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) { acc := ak.GetAccount(ctx, addr) if acc == nil { return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr) @@ -125,7 +126,7 @@ func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptot } // GetSequence Returns the Sequence of the account at address -func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, error) { +func (ak AccountKeeper) GetSequence(ctx context.Context, addr sdk.AccAddress) (uint64, error) { acc := ak.GetAccount(ctx, addr) if acc == nil { return 0, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr) @@ -136,11 +137,15 @@ func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint6 // NextAccountNumber returns and increments the global account number counter. // If the global account number is not set, it initializes it with value 0. -func (ak AccountKeeper) NextAccountNumber(ctx sdk.Context) uint64 { +func (ak AccountKeeper) NextAccountNumber(ctx context.Context) uint64 { var accNumber uint64 - store := ctx.KVStore(ak.storeKey) + store := ak.storeService.OpenKVStore(ctx) - bz := store.Get(types.GlobalAccountNumberKey) + bz, err := store.Get(types.GlobalAccountNumberKey) + if err != nil { + // panics only on nil key, which should not be possible + panic(err) + } if bz == nil { // initialize the account numbers accNumber = 0 @@ -201,7 +206,7 @@ func (ak AccountKeeper) GetModuleAddressAndPermissions(moduleName string) (addr // GetModuleAccountAndPermissions gets the module account from the auth account store and its // registered permissions -func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleName string) (sdk.ModuleAccountI, []string) { +func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (sdk.ModuleAccountI, []string) { addr, perms := ak.GetModuleAddressAndPermissions(moduleName) if addr == nil { return nil, []string{} @@ -226,13 +231,13 @@ func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleNa // GetModuleAccount gets the module account from the auth account store, if the account does not // exist in the AccountKeeper, then it is created. -func (ak AccountKeeper) GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI { +func (ak AccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI { acc, _ := ak.GetModuleAccountAndPermissions(ctx, moduleName) return acc } // SetModuleAccount sets the module account to the auth account store -func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc sdk.ModuleAccountI) { +func (ak AccountKeeper) SetModuleAccount(ctx context.Context, macc sdk.ModuleAccountI) { ak.SetAccount(ctx, macc) } diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 94a6744596ff..15be29c04b5d 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "testing" + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/stretchr/testify/suite" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -46,6 +48,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) key := storetypes.NewKVStoreKey(types.StoreKey) + storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) suite.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{}) @@ -60,7 +63,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.accountKeeper = keeper.NewAccountKeeper( suite.encCfg.Codec, - key, + storeService, types.ProtoBaseAccount, maccPerms, "cosmos", diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index ec2f49512b33..5f75deaa965a 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -48,7 +48,7 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error { // Migrate2to3 migrates from consensus version 2 to version 3. Specifically, for each account // we index the account's ID to their address. func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) + return v3.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc) } // Migrate3to4 migrates the x/auth module state from the consensus version 3 to @@ -56,7 +56,7 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error { // and managed by the x/params modules and stores them directly into the x/auth // module state. func (m Migrator) Migrate3to4(ctx sdk.Context) error { - return v4.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc) + return v4.Migrate(ctx, m.keeper.storeService, m.legacySubspace, m.keeper.cdc) } // V45_SetAccount implements V45_SetAccount @@ -65,13 +65,12 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { // NOTE: This is used for testing purposes only. func (m Migrator) V45_SetAccount(ctx sdk.Context, acc sdk.AccountI) error { //nolint:revive addr := acc.GetAddress() - store := ctx.KVStore(m.keeper.storeKey) + store := m.keeper.storeService.OpenKVStore(ctx) bz, err := m.keeper.MarshalAccount(acc) if err != nil { return err } - store.Set(types.AddressStoreKey(addr), bz) - return nil + return store.Set(types.AddressStoreKey(addr), bz) } diff --git a/x/auth/keeper/params.go b/x/auth/keeper/params.go index 680f7c1583e2..a716d81ab8ec 100644 --- a/x/auth/keeper/params.go +++ b/x/auth/keeper/params.go @@ -1,27 +1,30 @@ package keeper import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "context" + "github.com/cosmos/cosmos-sdk/x/auth/types" ) // SetParams sets the auth module's parameters. -func (ak AccountKeeper) SetParams(ctx sdk.Context, params types.Params) error { +func (ak AccountKeeper) SetParams(ctx context.Context, params types.Params) error { if err := params.Validate(); err != nil { return err } - store := ctx.KVStore(ak.storeKey) + store := ak.storeService.OpenKVStore(ctx) bz := ak.cdc.MustMarshal(¶ms) - store.Set(types.ParamsKey, bz) - - return nil + return store.Set(types.ParamsKey, bz) } // GetParams gets the auth module's parameters. -func (ak AccountKeeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(ak.storeKey) - bz := store.Get(types.ParamsKey) +func (ak AccountKeeper) GetParams(ctx context.Context) (params types.Params) { + store := ak.storeService.OpenKVStore(ctx) + bz, err := store.Get(types.ParamsKey) + if err != nil { + panic(err) + } + if bz == nil { return params } diff --git a/x/auth/migrations/v2/store_test.go b/x/auth/migrations/v2/store_test.go index eccc71fbe2e2..803a33f337eb 100644 --- a/x/auth/migrations/v2/store_test.go +++ b/x/auth/migrations/v2/store_test.go @@ -10,6 +10,7 @@ import ( storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -48,7 +49,7 @@ func TestMigrateVestingAccounts(t *testing.T) { storeKey := storetypes.NewKVStoreKey(v1.ModuleName) tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) - store := ctx.KVStore(storeKey) + storeService := runtime.NewKVStoreService(storeKey) var ( accountKeeper keeper.AccountKeeper @@ -64,7 +65,7 @@ func TestMigrateVestingAccounts(t *testing.T) { require.NoError(t, err) legacySubspace := newMockSubspace(authtypes.DefaultParams()) - require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc)) + require.NoError(t, v4.Migrate(ctx, storeService, legacySubspace, cdc)) ctx = app.BaseApp.NewContext(false, cmtproto.Header{Time: time.Now()}) stakingKeeper.SetParams(ctx, stakingtypes.DefaultParams()) diff --git a/x/auth/migrations/v3/store.go b/x/auth/migrations/v3/store.go index 5e188a9639bf..6aee1dc1a356 100644 --- a/x/auth/migrations/v3/store.go +++ b/x/auth/migrations/v3/store.go @@ -1,6 +1,7 @@ package v3 import ( + corestore "cosmossdk.io/core/store" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" @@ -8,9 +9,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/types" ) -func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - store := ctx.KVStore(storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix) +func mapAccountAddressToAccountID(ctx sdk.Context, storeService corestore.KVStoreService, cdc codec.BinaryCodec) error { + store := storeService.OpenKVStore(ctx) + iterator, err := store.Iterator(types.AddressStoreKeyPrefix, storetypes.PrefixEndBytes(types.AddressStoreKeyPrefix)) + if err != nil { + return err + } defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -27,6 +31,6 @@ func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey, // MigrateStore performs in-place store migrations from v0.45 to v0.46. The // migration includes: // - Add an Account number as an index to get the account address -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - return mapAccountAddressToAccountID(ctx, storeKey, cdc) +func MigrateStore(ctx sdk.Context, storeService corestore.KVStoreService, cdc codec.BinaryCodec) error { + return mapAccountAddressToAccountID(ctx, storeService, cdc) } diff --git a/x/auth/migrations/v3/store_test.go b/x/auth/migrations/v3/store_test.go index 633735870702..93d1b49b9b37 100644 --- a/x/auth/migrations/v3/store_test.go +++ b/x/auth/migrations/v3/store_test.go @@ -11,6 +11,7 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -44,7 +45,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) { storeKey := storetypes.NewKVStoreKey(v1.ModuleName) tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) - store := ctx.KVStore(storeKey) + storeService := runtime.NewKVStoreService(storeKey) var accountKeeper keeper.AccountKeeper @@ -55,7 +56,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) { require.NoError(t, err) legacySubspace := newMockSubspace(authtypes.DefaultParams()) - require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc)) + require.NoError(t, v4.Migrate(ctx, storeService, legacySubspace, cdc)) // new base account senderPrivKey := secp256k1.GenPrivKey() diff --git a/x/auth/migrations/v4/migrate.go b/x/auth/migrations/v4/migrate.go index 0730f081147c..3372b248c6f6 100644 --- a/x/auth/migrations/v4/migrate.go +++ b/x/auth/migrations/v4/migrate.go @@ -1,7 +1,7 @@ package v4 import ( - storetypes "cosmossdk.io/store/types" + storetypes "cosmossdk.io/core/store" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,7 +15,8 @@ var ParamsKey = []byte{0x00} // version 4. Specifically, it takes the parameters that are currently stored // and managed by the x/params modules and stores them directly into the x/auth // module state. -func Migrate(ctx sdk.Context, store storetypes.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error { +func Migrate(ctx sdk.Context, storeService storetypes.KVStoreService, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error { + store := storeService.OpenKVStore(ctx) var currParams types.Params legacySubspace.GetParamSet(ctx, &currParams) diff --git a/x/auth/migrations/v4/migrate_test.go b/x/auth/migrations/v4/migrate_test.go index f0b62a26c5b9..bc55fbe3985d 100644 --- a/x/auth/migrations/v4/migrate_test.go +++ b/x/auth/migrations/v4/migrate_test.go @@ -7,6 +7,7 @@ import ( storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -36,13 +37,14 @@ func TestMigrate(t *testing.T) { storeKey := storetypes.NewKVStoreKey(v1.ModuleName) tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) - store := ctx.KVStore(storeKey) + storeService := runtime.NewKVStoreService(storeKey) legacySubspace := newMockSubspace(types.DefaultParams()) - require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc)) + require.NoError(t, v4.Migrate(ctx, storeService, legacySubspace, cdc)) var res types.Params - bz := store.Get(v4.ParamsKey) + bz, err := storeService.OpenKVStore(ctx).Get(v4.ParamsKey) + require.NoError(t, err) require.NoError(t, cdc.Unmarshal(bz, &res)) require.Equal(t, legacySubspace.ps, res) } diff --git a/x/auth/module.go b/x/auth/module.go index b2fff09f8a17..4c0703b2b05f 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -16,7 +16,7 @@ import ( modulev1 "cosmossdk.io/api/cosmos/auth/module/v1" - store "cosmossdk.io/store/types" + "cosmossdk.io/core/store" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -214,9 +214,9 @@ func ProvideAddressCodec(config *modulev1.Module) address.Codec { type AuthInputs struct { depinject.In - Config *modulev1.Module - Key *store.KVStoreKey - Cdc codec.Codec + Config *modulev1.Module + StoreService store.KVStoreService + Cdc codec.Codec RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"` AccountI func() sdk.AccountI `optional:"true"` @@ -253,7 +253,7 @@ func ProvideModule(in AuthInputs) AuthOutputs { in.AccountI = types.ProtoBaseAccount } - k := keeper.NewAccountKeeper(in.Cdc, in.Key, in.AccountI, maccPerms, in.Config.Bech32Prefix, authority.String()) + k := keeper.NewAccountKeeper(in.Cdc, in.StoreService, in.AccountI, maccPerms, in.Config.Bech32Prefix, authority.String()) m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn, in.LegacySubspace) return AuthOutputs{AccountKeeper: k, Module: m} diff --git a/x/auth/vesting/msg_server_test.go b/x/auth/vesting/msg_server_test.go index f5e6fe58213a..823d31278bfe 100644 --- a/x/auth/vesting/msg_server_test.go +++ b/x/auth/vesting/msg_server_test.go @@ -11,6 +11,7 @@ import ( storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -41,6 +42,7 @@ type VestingTestSuite struct { func (s *VestingTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(authtypes.StoreKey) + storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) encCfg := moduletestutil.MakeTestEncodingConfig() @@ -51,7 +53,7 @@ func (s *VestingTestSuite) SetupTest() { s.bankKeeper = vestingtestutil.NewMockBankKeeper(ctrl) s.accountKeeper = authkeeper.NewAccountKeeper( encCfg.Codec, - key, + storeService, authtypes.ProtoBaseAccount, maccPerms, "cosmos", diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index 46502aff0f41..502416f6522a 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -12,6 +12,7 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -39,6 +40,7 @@ func (s *VestingAccountTestSuite) SetupTest() { encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModuleBasic{}) key := storetypes.NewKVStoreKey(authtypes.StoreKey) + storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{}) @@ -53,7 +55,7 @@ func (s *VestingAccountTestSuite) SetupTest() { s.accountKeeper = keeper.NewAccountKeeper( encCfg.Codec, - key, + storeService, authtypes.ProtoBaseAccount, maccPerms, "cosmos", diff --git a/x/authz/expected_keepers.go b/x/authz/expected_keepers.go index 812daa518f52..0edbdae58fc4 100644 --- a/x/authz/expected_keepers.go +++ b/x/authz/expected_keepers.go @@ -1,14 +1,16 @@ package authz import ( + context "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - SetAccount(ctx sdk.Context, acc sdk.AccountI) + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + SetAccount(ctx context.Context, acc sdk.AccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/authz/testutil/expected_keepers_mocks.go b/x/authz/testutil/expected_keepers_mocks.go index 82cb5c48d460..dc0940dd3cf5 100644 --- a/x/authz/testutil/expected_keepers_mocks.go +++ b/x/authz/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" @@ -35,7 +36,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -49,7 +50,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -63,7 +64,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/bank/testutil/expected_keepers_mocks.go b/x/bank/testutil/expected_keepers_mocks.go index f39abb0b4b57..3b5668228444 100644 --- a/x/bank/testutil/expected_keepers_mocks.go +++ b/x/bank/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" @@ -36,7 +37,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -50,7 +51,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetAllAccounts mocks base method. -func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types.AccountI { +func (m *MockAccountKeeper) GetAllAccounts(ctx context.Context) []types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllAccounts", ctx) ret0, _ := ret[0].([]types.AccountI) @@ -64,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAllAccounts(ctx interface{}) *gomock } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) ret0, _ := ret[0].(types.ModuleAccountI) @@ -78,7 +79,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interf } // GetModuleAccountAndPermissions mocks base method. -func (m *MockAccountKeeper) GetModuleAccountAndPermissions(ctx types.Context, moduleName string) (types.ModuleAccountI, []string) { +func (m *MockAccountKeeper) GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (types.ModuleAccountI, []string) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccountAndPermissions", ctx, moduleName) ret0, _ := ret[0].(types.ModuleAccountI) @@ -136,7 +137,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModulePermissions() *gomock.Call { } // HasAccount mocks base method. -func (m *MockAccountKeeper) HasAccount(ctx types.Context, addr types.AccAddress) bool { +func (m *MockAccountKeeper) HasAccount(ctx context.Context, addr types.AccAddress) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "HasAccount", ctx, addr) ret0, _ := ret[0].(bool) @@ -150,7 +151,7 @@ func (mr *MockAccountKeeperMockRecorder) HasAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -162,7 +163,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 context.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) ret0, _ := ret[0].(types.AccountI) @@ -176,7 +177,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -190,7 +191,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } @@ -202,7 +203,7 @@ func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomoc } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(ctx types.Context, macc types.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(ctx context.Context, macc types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", ctx, macc) } diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index a56aeace3b5f..c1a8911107c6 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -1,6 +1,8 @@ package types import ( + context "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -8,22 +10,22 @@ import ( // AccountKeeper defines the account contract that must be fulfilled when // creating a x/bank keeper. type AccountKeeper interface { - NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + NewAccount(context.Context, sdk.AccountI) sdk.AccountI + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - GetAllAccounts(ctx sdk.Context) []sdk.AccountI - HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool - SetAccount(ctx sdk.Context, acc sdk.AccountI) + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + GetAllAccounts(ctx context.Context) []sdk.AccountI + HasAccount(ctx context.Context, addr sdk.AccAddress) bool + SetAccount(ctx context.Context, acc sdk.AccountI) - IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) bool) + IterateAccounts(ctx context.Context, process func(sdk.AccountI) bool) ValidatePermissions(macc sdk.ModuleAccountI) error GetModuleAddress(moduleName string) sdk.AccAddress GetModuleAddressAndPermissions(moduleName string) (addr sdk.AccAddress, permissions []string) - GetModuleAccountAndPermissions(ctx sdk.Context, moduleName string) (sdk.ModuleAccountI, []string) - GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI - SetModuleAccount(ctx sdk.Context, macc sdk.ModuleAccountI) + GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (sdk.ModuleAccountI, []string) + GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI + SetModuleAccount(ctx context.Context, macc sdk.ModuleAccountI) GetModulePermissions() map[string]types.PermissionsForAddress } diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index ad1e01864a56..550463aee2c5 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" @@ -36,7 +37,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -50,7 +51,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, name string) types.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name) ret0, _ := ret[0].(types.ModuleAccountI) @@ -78,7 +79,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) } diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 3f53b4a550cf..3360b83f156b 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -1,19 +1,21 @@ package types import ( + context "context" + sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, name string) sdk.ModuleAccountI + GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, sdk.ModuleAccountI) + SetModuleAccount(context.Context, sdk.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/evidence/testutil/expected_keepers_mocks.go b/x/evidence/testutil/expected_keepers_mocks.go index f9021ea468ae..845322d2ce1a 100644 --- a/x/evidence/testutil/expected_keepers_mocks.go +++ b/x/evidence/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" time "time" @@ -229,7 +230,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types0.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types0.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/evidence/types/expected_keepers.go b/x/evidence/types/expected_keepers.go index f7355ee3a3a8..a6405763f52d 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -1,6 +1,7 @@ package types import ( + context "context" "time" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -32,7 +33,7 @@ type ( // AccountKeeper define the account keeper interface contracted needed by the evidence module AccountKeeper interface { - SetAccount(ctx sdk.Context, acc sdk.AccountI) + SetAccount(ctx context.Context, acc sdk.AccountI) } // BankKeeper define the account keeper interface contracted needed by the evidence module diff --git a/x/feegrant/expected_keepers.go b/x/feegrant/expected_keepers.go index 1ec0ddeff2eb..ae30f5830e2c 100644 --- a/x/feegrant/expected_keepers.go +++ b/x/feegrant/expected_keepers.go @@ -1,17 +1,19 @@ package feegrant import ( + context "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) // AccountKeeper defines the expected auth Account Keeper (noalias) type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI + GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - SetAccount(ctx sdk.Context, acc sdk.AccountI) + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + SetAccount(ctx context.Context, acc sdk.AccountI) // StringToBytes decodes text to bytes StringToBytes(text string) ([]byte, error) diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index 6cf8f6b20be6..218708d9c3ea 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -12,7 +12,7 @@ require ( cosmossdk.io/store v0.1.0-alpha.1 github.com/cometbft/cometbft v0.37.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230324171029-0176e313261d + github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e github.com/cosmos/gogoproto v1.4.6 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum index 67eed43ad41d..0547d7286470 100644 --- a/x/feegrant/go.sum +++ b/x/feegrant/go.sum @@ -186,8 +186,12 @@ github.com/cosmos/cosmos-db v1.0.0-rc.1 h1:SjnT8B6WKMW9WEIX32qMhnEEKcI7ZP0+G1Sa9 github.com/cosmos/cosmos-db v1.0.0-rc.1/go.mod h1:Dnmk3flSf5lkwCqvvjNpoxjpXzhxnCAFzKHlbaForso= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230322203107-65e40ff4dacb h1:EaISkBPki6apzaD2Yjw3HtCOOj/yW4OuG6V3Oig2HlA= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230322203107-65e40ff4dacb/go.mod h1:9zqhqPooktWYyV2CiTFh+uQBVbR+Ozy9cr3KrY5UNHQ= github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230324171029-0176e313261d h1:FmHvrGoLwiF/4UviweBbWtpEXcNo6IOjnZMgNHcP4mU= github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230324171029-0176e313261d/go.mod h1:X5eCGsQaPQWvFwRzAbneZZaLjnZcral+yoLqAN2QTRI= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e h1:n3/Z5dwxBnPLrcUiudoxAhASuz7DCGdLQNBpc9dt4jU= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e/go.mod h1:X5eCGsQaPQWvFwRzAbneZZaLjnZcral+yoLqAN2QTRI= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= diff --git a/x/feegrant/testutil/expected_keepers_mocks.go b/x/feegrant/testutil/expected_keepers_mocks.go index 5145192c17fa..b73d1735322d 100644 --- a/x/feegrant/testutil/expected_keepers_mocks.go +++ b/x/feegrant/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" @@ -50,7 +51,7 @@ func (mr *MockAccountKeeperMockRecorder) BytesToString(bz interface{}) *gomock.C } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -64,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) ret0, _ := ret[0].(types.ModuleAccountI) @@ -92,7 +93,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{} } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -106,7 +107,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/genutil/testutil/expected_keepers_mocks.go b/x/genutil/testutil/expected_keepers_mocks.go index 51d75e6e8962..1b33fb0d3092 100644 --- a/x/genutil/testutil/expected_keepers_mocks.go +++ b/x/genutil/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" json "encoding/json" reflect "reflect" @@ -77,7 +78,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types0.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, process func(types0.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -89,7 +90,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types0.Context, arg1 types0.AccountI) types0.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 context.Context, arg1 types0.AccountI) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) ret0, _ := ret[0].(types0.AccountI) @@ -103,7 +104,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types0.Context, arg1 types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(arg0 context.Context, arg1 types0.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } diff --git a/x/genutil/types/expected_keepers.go b/x/genutil/types/expected_keepers.go index ed62ea3ab4e3..634109a7e1e5 100644 --- a/x/genutil/types/expected_keepers.go +++ b/x/genutil/types/expected_keepers.go @@ -1,6 +1,7 @@ package types import ( + "context" "encoding/json" abci "github.com/cometbft/cometbft/abci/types" @@ -17,9 +18,9 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI - SetAccount(sdk.Context, sdk.AccountI) - IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool)) + NewAccount(context.Context, sdk.AccountI) sdk.AccountI + SetAccount(context.Context, sdk.AccountI) + IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool)) } // GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias) diff --git a/x/gov/testutil/expected_keepers.go b/x/gov/testutil/expected_keepers.go index 312c8292c434..9652b94602fc 100644 --- a/x/gov/testutil/expected_keepers.go +++ b/x/gov/testutil/expected_keepers.go @@ -3,6 +3,8 @@ package testutil import ( + context "context" + math "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,7 +17,7 @@ import ( type AccountKeeper interface { types.AccountKeeper - IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool)) + IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) (stop bool)) } // BankKeeper extends gov's actual expected BankKeeper with additional diff --git a/x/gov/testutil/expected_keepers_mocks.go b/x/gov/testutil/expected_keepers_mocks.go index 62bdf8b03715..e59d2a5656ce 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -41,7 +41,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -55,7 +55,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, name string) types.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name) ret0, _ := ret[0].(types.ModuleAccountI) @@ -83,7 +83,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, cb func(types.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, cb func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, cb) } @@ -95,7 +95,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, cb interface{}) *g } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) } diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index 94b35219da7e..81e488851035 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -1,6 +1,8 @@ package types import ( + "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,13 +36,13 @@ type DistributionKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, name string) sdk.ModuleAccountI + GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, sdk.ModuleAccountI) + SetModuleAccount(context.Context, sdk.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/group/expected_keepers.go b/x/group/expected_keepers.go index 31334a3413b7..037d639604a3 100644 --- a/x/group/expected_keepers.go +++ b/x/group/expected_keepers.go @@ -1,21 +1,23 @@ package group import ( + context "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) type AccountKeeper interface { // NewAccount returns a new account with the next account number. Does not save the new account to the store. - NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI + NewAccount(context.Context, sdk.AccountI) sdk.AccountI // GetAccount retrieves an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI + GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // SetAccount sets an account in the store. - SetAccount(sdk.Context, sdk.AccountI) + SetAccount(context.Context, sdk.AccountI) // RemoveAccount Remove an account in the store. - RemoveAccount(ctx sdk.Context, acc sdk.AccountI) + RemoveAccount(ctx context.Context, acc sdk.AccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/group/migrations/v2/migrate_test.go b/x/group/migrations/v2/migrate_test.go index 20902ebdde7f..be7243eaa24a 100644 --- a/x/group/migrations/v2/migrate_test.go +++ b/x/group/migrations/v2/migrate_test.go @@ -8,6 +8,7 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -78,7 +79,7 @@ func createGroupPolicies(ctx sdk.Context, storeKey storetypes.StoreKey, cdc code // createOldPolicyAccount re-creates the group policy account using a module account func createOldPolicyAccount(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec) group.AccountKeeper { - accountKeeper := authkeeper.NewAccountKeeper(cdc, storeKey, authtypes.ProtoBaseAccount, nil, sdk.Bech32MainPrefix, accountAddr.String()) + accountKeeper := authkeeper.NewAccountKeeper(cdc, runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), authtypes.ProtoBaseAccount, nil, sdk.Bech32MainPrefix, accountAddr.String()) for _, policyAddr := range policies { acc := accountKeeper.NewAccount(ctx, &authtypes.ModuleAccount{ BaseAccount: &authtypes.BaseAccount{ diff --git a/x/group/testutil/expected_keepers_mocks.go b/x/group/testutil/expected_keepers_mocks.go index 8f614b6be1e2..a03a662ee176 100644 --- a/x/group/testutil/expected_keepers_mocks.go +++ b/x/group/testutil/expected_keepers_mocks.go @@ -37,7 +37,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(arg0 types.Context, arg1 types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(arg0 context.Context, arg1 types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", arg0, arg1) ret0, _ := ret[0].(types.AccountI) @@ -51,7 +51,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(arg0, arg1 interface{}) *gom } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 context.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) ret0, _ := ret[0].(types.AccountI) @@ -65,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // RemoveAccount mocks base method. -func (m *MockAccountKeeper) RemoveAccount(ctx types.Context, acc types.AccountI) { +func (m *MockAccountKeeper) RemoveAccount(ctx context.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "RemoveAccount", ctx, acc) } @@ -77,7 +77,7 @@ func (mr *MockAccountKeeperMockRecorder) RemoveAccount(ctx, acc interface{}) *go } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types.AccountI) { +func (m *MockAccountKeeper) SetAccount(arg0 context.Context, arg1 types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } diff --git a/x/mint/testutil/expected_keepers_mocks.go b/x/mint/testutil/expected_keepers_mocks.go index 47af766c6b9b..9fb2e88af02e 100644 --- a/x/mint/testutil/expected_keepers_mocks.go +++ b/x/mint/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" math "cosmossdk.io/math" @@ -87,7 +88,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) ret0, _ := ret[0].(types.ModuleAccountI) @@ -115,7 +116,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) } diff --git a/x/mint/types/expected_keepers.go b/x/mint/types/expected_keepers.go index 46c2f4ed93a0..e3ec0173c798 100644 --- a/x/mint/types/expected_keepers.go +++ b/x/mint/types/expected_keepers.go @@ -1,6 +1,8 @@ package types // noalias import ( + context "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,8 +19,8 @@ type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, sdk.ModuleAccountI) - GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI + SetModuleAccount(context.Context, sdk.ModuleAccountI) + GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI } // BankKeeper defines the contract needed to be fulfilled for banking and supply diff --git a/x/nft/expected_keepers.go b/x/nft/expected_keepers.go index ec7976e294b9..b96a8ba11bc7 100644 --- a/x/nft/expected_keepers.go +++ b/x/nft/expected_keepers.go @@ -1,6 +1,8 @@ package nft import ( + context "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -13,5 +15,5 @@ type BankKeeper interface { // AccountKeeper defines the contract required for account APIs. type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI } diff --git a/x/nft/go.mod b/x/nft/go.mod index bb1710e45ee2..2f053b58e05e 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -11,7 +11,7 @@ require ( cosmossdk.io/store v0.1.0-alpha.1 github.com/cometbft/cometbft v0.37.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230321173237-fe77d4bca302 + github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e github.com/cosmos/gogoproto v1.4.6 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 diff --git a/x/nft/go.sum b/x/nft/go.sum index f043bbb643f9..155440b33bbc 100644 --- a/x/nft/go.sum +++ b/x/nft/go.sum @@ -181,8 +181,10 @@ github.com/cosmos/cosmos-db v1.0.0-rc.1 h1:SjnT8B6WKMW9WEIX32qMhnEEKcI7ZP0+G1Sa9 github.com/cosmos/cosmos-db v1.0.0-rc.1/go.mod h1:Dnmk3flSf5lkwCqvvjNpoxjpXzhxnCAFzKHlbaForso= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230321173237-fe77d4bca302 h1:wffm9LPPG/FBW/tSRdJp2DCgkJQRX+Zsbdmn4I0aWeQ= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230321173237-fe77d4bca302/go.mod h1:HzOsWXtPxhO8+Y8P4Ru+G3UWx6dTkpGXU9yvT35VEuI= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230322203107-65e40ff4dacb h1:EaISkBPki6apzaD2Yjw3HtCOOj/yW4OuG6V3Oig2HlA= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230322203107-65e40ff4dacb/go.mod h1:9zqhqPooktWYyV2CiTFh+uQBVbR+Ozy9cr3KrY5UNHQ= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e h1:n3/Z5dwxBnPLrcUiudoxAhASuz7DCGdLQNBpc9dt4jU= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e/go.mod h1:X5eCGsQaPQWvFwRzAbneZZaLjnZcral+yoLqAN2QTRI= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= diff --git a/x/nft/testutil/expected_keepers_mocks.go b/x/nft/testutil/expected_keepers_mocks.go index cf85857c6717..545212bdcffd 100644 --- a/x/nft/testutil/expected_keepers_mocks.go +++ b/x/nft/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" @@ -72,7 +73,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) diff --git a/x/simulation/expected_keepers.go b/x/simulation/expected_keepers.go index 346d695f66dc..345205996eb0 100644 --- a/x/simulation/expected_keepers.go +++ b/x/simulation/expected_keepers.go @@ -1,12 +1,14 @@ package simulation import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/slashing/testutil/expected_keepers_mocks.go b/x/slashing/testutil/expected_keepers_mocks.go index 1de66b89e99a..2cc775c7fbf7 100644 --- a/x/slashing/testutil/expected_keepers_mocks.go +++ b/x/slashing/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" math "cosmossdk.io/math" @@ -38,7 +39,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -52,7 +53,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } diff --git a/x/slashing/types/expected_keepers.go b/x/slashing/types/expected_keepers.go index 3306be791a27..d3a856769f1b 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -1,6 +1,8 @@ package types import ( + context "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,8 +12,8 @@ import ( // AccountKeeper expected account keeper type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool)) + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool)) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/staking/testutil/expected_keepers_mocks.go b/x/staking/testutil/expected_keepers_mocks.go index 3c69110153cc..03e60271606e 100644 --- a/x/staking/testutil/expected_keepers_mocks.go +++ b/x/staking/testutil/expected_keepers_mocks.go @@ -5,6 +5,7 @@ package testutil import ( + context "context" reflect "reflect" math "cosmossdk.io/math" @@ -88,7 +89,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types.AccountI) @@ -102,7 +103,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) ret0, _ := ret[0].(types.ModuleAccountI) @@ -130,7 +131,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -142,7 +143,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) } diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index 5a9e22344c49..e6e44ba3c777 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -1,6 +1,8 @@ package types import ( + context "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,14 +16,14 @@ type DistributionKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool)) - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation + IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool)) + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI + GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, sdk.ModuleAccountI) + SetModuleAccount(context.Context, sdk.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances.