From 45d1e2a1d957da406df39b33bcd050834d77f73f Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 21 Nov 2022 09:01:57 +0530 Subject: [PATCH 01/21] move auth's AccountI interface to types package --- types/dependencies.go | 32 +++++++++++++++ x/auth/ante/expected_keepers.go | 4 +- x/auth/ante/fee.go | 2 +- x/auth/ante/sigverify.go | 2 +- .../ante/testutil/expected_keepers_mocks.go | 6 +-- x/auth/ante/testutil_test.go | 2 +- x/auth/keeper/account.go | 16 ++++---- x/auth/keeper/deterministic_test.go | 10 ++--- x/auth/keeper/genesis.go | 2 +- x/auth/keeper/grpc_query_test.go | 12 +++--- x/auth/keeper/keeper.go | 24 ++++++------ x/auth/keeper/keeper_test.go | 4 +- x/auth/keeper/migrations.go | 4 +- x/auth/migrations/v2/store.go | 7 ++-- x/auth/migrations/v3/store.go | 2 +- x/auth/module.go | 2 +- x/auth/simulation/decoder.go | 2 +- x/auth/types/account.go | 34 ++-------------- x/auth/types/account_retriever.go | 4 +- x/auth/types/codec.go | 4 +- x/auth/types/genesis.go | 5 ++- x/auth/types/genesis_test.go | 5 ++- x/auth/types/query.go | 7 +++- x/auth/vesting/exported/exported.go | 4 +- x/auth/vesting/msg_server.go | 2 +- x/auth/vesting/types/codec.go | 2 +- x/auth/vesting/types/vesting_account.go | 2 +- x/authz/expected_keepers.go | 7 ++-- x/authz/testutil/expected_keepers_mocks.go | 11 +++--- x/bank/keeper/keeper.go | 1 + x/bank/keeper/keeper_test.go | 20 +++++----- x/bank/keeper/msg_service_test.go | 3 +- x/bank/testutil/expected_keepers_mocks.go | 20 +++++----- x/bank/types/expected_keepers.go | 12 +++--- .../testutil/expected_keepers_mocks.go | 20 +++++----- .../testutil/expected_keepers_mocks.go | 4 +- x/distribution/types/expected_keepers.go | 2 +- x/evidence/testutil/expected_keepers_mocks.go | 15 ++++--- x/evidence/types/expected_keepers.go | 4 +- x/feegrant/expected_keepers.go | 6 +-- x/feegrant/testutil/expected_keepers_mocks.go | 10 ++--- x/genutil/testutil/expected_keepers_mocks.go | 17 ++++---- x/genutil/types/expected_keepers.go | 9 ++--- x/gov/testutil/expected_keepers.go | 3 +- x/gov/testutil/expected_keepers_mocks.go | 6 +-- x/gov/types/expected_keepers.go | 3 +- x/group/expected_keepers.go | 7 ++-- x/group/simulation/operations.go | 7 ++-- x/group/testutil/expected_keepers_mocks.go | 29 +++++++------- x/nft/expected_keepers.go | 3 +- x/nft/testutil/expected_keepers_mocks.go | 5 +-- x/simulation/expected_keepers.go | 3 +- x/slashing/testutil/expected_keepers_mocks.go | 39 +++++++++---------- x/slashing/types/expected_keepers.go | 6 +-- x/staking/testutil/expected_keepers_mocks.go | 6 +-- x/staking/types/expected_keepers.go | 4 +- 56 files changed, 239 insertions(+), 245 deletions(-) create mode 100644 types/dependencies.go diff --git a/types/dependencies.go b/types/dependencies.go new file mode 100644 index 000000000000..d5c5ddbd39b6 --- /dev/null +++ b/types/dependencies.go @@ -0,0 +1,32 @@ +package types + +import ( + "github.com/cosmos/gogoproto/proto" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" +) + +// AccountI is an interface used to store coins at a given address within state. +// It presumes a notion of sequence numbers for replay protection, +// a notion of account numbers for replay protection for previously pruned accounts, +// and a pubkey for authentication purposes. +// +// Many complex conditions can be used in the concrete struct which implements AccountI. +type AccountI interface { + proto.Message + + GetAddress() AccAddress + SetAddress(AccAddress) error // errors if already set. + + GetPubKey() cryptotypes.PubKey // can return nil. + SetPubKey(cryptotypes.PubKey) error + + GetAccountNumber() uint64 + SetAccountNumber(uint64) error + + GetSequence() uint64 + SetSequence(uint64) error + + // Ensure that account implements stringer + String() string +} diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 4dbbbd21c713..1db0dff716c1 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -9,8 +9,8 @@ import ( // 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) types.AccountI - SetAccount(ctx sdk.Context, acc types.AccountI) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + SetAccount(ctx sdk.Context, acc sdk.AccountI) GetModuleAddress(moduleName string) sdk.AccAddress } diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 4ab9dda9ee1a..09d4de6438b3 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -122,7 +122,7 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee } // DeductFees deducts fees from the given account. -func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error { +func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc sdk.AccountI, fees sdk.Coins) error { if !fees.IsValid() { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index a24af86667e0..437b86025a11 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -449,7 +449,7 @@ func ConsumeMultisignatureVerificationGas( // GetSignerAcc returns an account for a given address that is expected to sign // a transaction. -func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (types.AccountI, error) { +func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (sdk.AccountI, error) { if acc := ak.GetAccount(ctx, addr); acc != nil { return acc, nil } diff --git a/x/auth/ante/testutil/expected_keepers_mocks.go b/x/auth/ante/testutil/expected_keepers_mocks.go index ff2803af07bf..34c7c68e4ef8 100644 --- a/x/auth/ante/testutil/expected_keepers_mocks.go +++ b/x/auth/ante/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -78,7 +78,7 @@ func (mr *MockAccountKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.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 93318e7fdb4c..c81ba1aa459c 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -26,7 +26,7 @@ import ( // TestAccount represents an account used in the tests in x/auth/ante. type TestAccount struct { - acc types.AccountI + acc sdk.AccountI priv cryptotypes.PrivKey } diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index 446f0c97774a..f6f8613de369 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -6,7 +6,7 @@ import ( ) // NewAccountWithAddress implements AccountKeeperI. -func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountI { +func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { acc := ak.proto() err := acc.SetAddress(addr) if err != nil { @@ -17,7 +17,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 types.AccountI) types.AccountI { +func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc sdk.AccountI) sdk.AccountI { if err := acc.SetAccountNumber(ak.NextAccountNumber(ctx)); err != nil { panic(err) } @@ -38,7 +38,7 @@ func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool { } // GetAccount implements AccountKeeperI. -func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI { +func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { store := ctx.KVStore(ak.storeKey) bz := store.Get(types.AddressStoreKey(addr)) if bz == nil { @@ -59,8 +59,8 @@ 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 []types.AccountI) { - ak.IterateAccounts(ctx, func(acc types.AccountI) (stop bool) { +func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []sdk.AccountI) { + ak.IterateAccounts(ctx, func(acc sdk.AccountI) (stop bool) { accounts = append(accounts, acc) return false }) @@ -69,7 +69,7 @@ func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []types.Accoun } // SetAccount implements AccountKeeperI. -func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.AccountI) { +func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc sdk.AccountI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) @@ -84,7 +84,7 @@ func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.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 types.AccountI) { +func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc sdk.AccountI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) store.Delete(types.AddressStoreKey(addr)) @@ -93,7 +93,7 @@ func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc types.AccountI) { // 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 types.AccountI) (stop bool)) { +func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool)) { store := ctx.KVStore(ak.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix) diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 440de458e7c7..1978ef0a03c0 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -77,8 +77,8 @@ func (suite *DeterministicTestSuite) SetupTest() { } // createAndSetAccount creates a random account and sets to the keeper store. -func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []types.AccountI { - accs := make([]types.AccountI, 0, count) +func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []sdk.AccountI { + accs := make([]sdk.AccountI, 0, count) // We need all generated account-numbers unique accNums := rapid.SliceOfNDistinct(rapid.Uint64(), count, count, func(i uint64) uint64 { return i }).Draw(t, "acc-numss") @@ -239,12 +239,12 @@ func (suite *DeterministicTestSuite) createAndReturnQueryClient(ak keeper.Accoun func (suite *DeterministicTestSuite) setModuleAccounts( ctx sdk.Context, ak keeper.AccountKeeper, maccs []string, -) []types.AccountI { +) []sdk.AccountI { sort.Strings(maccs) - moduleAccounts := make([]types.AccountI, 0, len(maccs)) + moduleAccounts := make([]sdk.AccountI, 0, len(maccs)) for _, m := range maccs { acc, _ := ak.GetModuleAccountAndPermissions(ctx, m) - acc1, ok := acc.(types.AccountI) + acc1, ok := acc.(sdk.AccountI) suite.Require().True(ok) moduleAccounts = append(moduleAccounts, acc1) } diff --git a/x/auth/keeper/genesis.go b/x/auth/keeper/genesis.go index 6e748ef5b44a..ad830ef54e21 100644 --- a/x/auth/keeper/genesis.go +++ b/x/auth/keeper/genesis.go @@ -39,7 +39,7 @@ func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := ak.GetParams(ctx) var genAccounts types.GenesisAccounts - ak.IterateAccounts(ctx, func(account types.AccountI) bool { + ak.IterateAccounts(ctx, func(account sdk.AccountI) bool { genAccount := account.(types.GenesisAccount) genAccounts = append(genAccounts, genAccount) return false diff --git a/x/auth/keeper/grpc_query_test.go b/x/auth/keeper/grpc_query_test.go index a1bc322a778a..469a40f45e28 100644 --- a/x/auth/keeper/grpc_query_test.go +++ b/x/auth/keeper/grpc_query_test.go @@ -42,7 +42,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccounts() { func(res *types.QueryAccountsResponse) { addresses := make([]sdk.AccAddress, len(res.Accounts)) for i, acc := range res.Accounts { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) addresses[i] = account.GetAddress() @@ -125,7 +125,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccount() { }, true, func(res *types.QueryAccountResponse) { - var newAccount types.AccountI + var newAccount sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &newAccount) suite.Require().NoError(err) suite.Require().NotNil(newAccount) @@ -278,7 +278,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { func(res *types.QueryModuleAccountsResponse) { mintModuleExists := false for _, acc := range res.Accounts { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) @@ -301,7 +301,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { func(res *types.QueryModuleAccountsResponse) { mintModuleExists := false for _, acc := range res.Accounts { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) @@ -332,7 +332,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { // Make sure output is sorted alphabetically. var moduleNames []string for _, any := range res.Accounts { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(any, &account) suite.Require().NoError(err) moduleAccount, ok := account.(types.ModuleAccountI) @@ -366,7 +366,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccountByName() { }, true, func(res *types.QueryModuleAccountByNameResponse) { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &account) suite.Require().NoError(err) diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index e42183ad0193..edd210f64173 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -19,25 +19,25 @@ 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) types.AccountI + NewAccountWithAddress(sdk.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, types.AccountI) types.AccountI + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI // Check if an account exists in the store. HasAccount(sdk.Context, sdk.AccAddress) bool // Retrieve an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) types.AccountI + GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI // Set an account in the store. - SetAccount(sdk.Context, types.AccountI) + SetAccount(sdk.Context, sdk.AccountI) // Remove an account from the store. - RemoveAccount(sdk.Context, types.AccountI) + RemoveAccount(sdk.Context, sdk.AccountI) // Iterate over all accounts, calling the provided function. Stop iteration when it returns true. - IterateAccounts(sdk.Context, func(types.AccountI) bool) + IterateAccounts(sdk.Context, func(sdk.AccountI) bool) // Fetch the public key of an account at a specified address GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error) @@ -60,7 +60,7 @@ type AccountKeeper struct { permAddrs map[string]types.PermissionsForAddress // The prototypical AccountI constructor. - proto func() types.AccountI + proto func() sdk.AccountI addressCdc address.Codec // the address capable of executing a MsgUpdateParams message. Typically, this @@ -77,7 +77,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() types.AccountI, + cdc codec.BinaryCodec, storeKey storetypes.StoreKey, proto func() sdk.AccountI, maccPerms map[string][]string, bech32Prefix string, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) @@ -230,7 +230,7 @@ func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc types.ModuleAccou ak.SetAccount(ctx, macc) } -func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountI { +func (ak AccountKeeper) decodeAccount(bz []byte) sdk.AccountI { acc, err := ak.UnmarshalAccount(bz) if err != nil { panic(err) @@ -240,14 +240,14 @@ func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountI { } // MarshalAccount protobuf serializes an Account interface -func (ak AccountKeeper) MarshalAccount(accountI types.AccountI) ([]byte, error) { //nolint:interfacer +func (ak AccountKeeper) MarshalAccount(accountI sdk.AccountI) ([]byte, error) { //nolint:interfacer return ak.cdc.MarshalInterface(accountI) } // UnmarshalAccount returns an Account interface from raw encoded account // bytes of a Proto-based Account type -func (ak AccountKeeper) UnmarshalAccount(bz []byte) (types.AccountI, error) { - var acc types.AccountI +func (ak AccountKeeper) UnmarshalAccount(bz []byte) (sdk.AccountI, error) { + var acc sdk.AccountI return acc, ak.cdc.UnmarshalInterface(bz, &acc) } diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 7448fa5e4df6..29dc06efbb72 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -190,7 +190,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { // Fix duplicate account numbers pubKey1 := ed25519.GenPrivKey().PubKey() pubKey2 := ed25519.GenPrivKey().PubKey() - accts := []types.AccountI{ + accts := []sdk.AccountI{ &types.BaseAccount{ Address: sdk.AccAddress(pubKey1.Address()).String(), PubKey: codectypes.UnsafePackAny(pubKey1), @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().Equal(len(keeperAccts), len(accts)+1, "number of accounts in the keeper vs in genesis state") for i, genAcct := range accts { genAcctAddr := genAcct.GetAddress() - var keeperAcct types.AccountI + var keeperAcct sdk.AccountI for _, kacct := range keeperAccts { if genAcctAddr.Equals(kacct.GetAddress()) { keeperAcct = kacct diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index 16c7ffabb2b7..57f233d45d71 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -27,7 +27,7 @@ func NewMigrator(keeper AccountKeeper, queryServer grpc.Server, ss exported.Subs func (m Migrator) Migrate1to2(ctx sdk.Context) error { var iterErr error - m.keeper.IterateAccounts(ctx, func(account types.AccountI) (stop bool) { + m.keeper.IterateAccounts(ctx, func(account sdk.AccountI) (stop bool) { wb, err := v2.MigrateAccount(ctx, account, m.queryServer) if err != nil { iterErr = err @@ -63,7 +63,7 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { // set the account without map to accAddr to accNumber. // // NOTE: This is used for testing purposes only. -func (m Migrator) V45_SetAccount(ctx sdk.Context, acc types.AccountI) error { +func (m Migrator) V45_SetAccount(ctx sdk.Context, acc sdk.AccountI) error { addr := acc.GetAddress() store := ctx.KVStore(m.keeper.storeKey) diff --git a/x/auth/migrations/v2/store.go b/x/auth/migrations/v2/store.go index d1b33350bc2b..abebf9afb052 100644 --- a/x/auth/migrations/v2/store.go +++ b/x/auth/migrations/v2/store.go @@ -30,7 +30,6 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -46,7 +45,7 @@ const ( // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer grpc.Server) (types.AccountI, error) { +func migrateVestingAccounts(ctx sdk.Context, account sdk.AccountI, queryServer grpc.Server) (sdk.AccountI, error) { bondDenom, err := getBondDenom(ctx, queryServer) if err != nil { return nil, err @@ -100,7 +99,7 @@ func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer asVesting.TrackDelegation(ctx.BlockTime(), balance, delegations) - return asVesting.(types.AccountI), nil + return asVesting.(sdk.AccountI), nil } func resetVestingDelegatedBalances(evacct exported.VestingAccount) (exported.VestingAccount, bool) { @@ -290,6 +289,6 @@ func getBondDenom(ctx sdk.Context, queryServer grpc.Server) (string, error) { // // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func MigrateAccount(ctx sdk.Context, account types.AccountI, queryServer grpc.Server) (types.AccountI, error) { +func MigrateAccount(ctx sdk.Context, account sdk.AccountI, queryServer grpc.Server) (sdk.AccountI, error) { return migrateVestingAccounts(ctx, account, queryServer) } diff --git a/x/auth/migrations/v3/store.go b/x/auth/migrations/v3/store.go index 8e93a87e0bf4..b8b87646d223 100644 --- a/x/auth/migrations/v3/store.go +++ b/x/auth/migrations/v3/store.go @@ -13,7 +13,7 @@ func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey, defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var acc types.AccountI + var acc sdk.AccountI if err := cdc.UnmarshalInterface(iterator.Value(), &acc); err != nil { return err } diff --git a/x/auth/module.go b/x/auth/module.go index 3d62fd6fa9fd..e3a0142657cd 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -206,7 +206,7 @@ type AuthInputs struct { Cdc codec.Codec RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"` - AccountI func() types.AccountI `optional:"true"` + AccountI func() sdk.AccountI `optional:"true"` // LegacySubspace is used solely for migration of x/params managed parameters LegacySubspace exported.Subspace `optional:"true"` diff --git a/x/auth/simulation/decoder.go b/x/auth/simulation/decoder.go index 4f4f25f07e77..4d32123e416d 100644 --- a/x/auth/simulation/decoder.go +++ b/x/auth/simulation/decoder.go @@ -13,7 +13,7 @@ import ( ) type AuthUnmarshaler interface { - UnmarshalAccount([]byte) (types.AccountI, error) + UnmarshalAccount([]byte) (sdk.AccountI, error) GetCodec() codec.BinaryCodec } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 16ffaf293581..2da752661cea 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -7,7 +7,6 @@ import ( "fmt" "strings" - "github.com/cosmos/gogoproto/proto" "github.com/tendermint/tendermint/crypto" "sigs.k8s.io/yaml" @@ -19,7 +18,7 @@ import ( ) var ( - _ AccountI = (*BaseAccount)(nil) + _ sdk.AccountI = (*BaseAccount)(nil) _ GenesisAccount = (*BaseAccount)(nil) _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) _ GenesisAccount = (*ModuleAccount)(nil) @@ -45,7 +44,7 @@ func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNu } // ProtoBaseAccount - a prototype function for BaseAccount -func ProtoBaseAccount() AccountI { +func ProtoBaseAccount() sdk.AccountI { return &BaseAccount{} } @@ -313,35 +312,10 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { return nil } -// AccountI is an interface used to store coins at a given address within state. -// It presumes a notion of sequence numbers for replay protection, -// a notion of account numbers for replay protection for previously pruned accounts, -// and a pubkey for authentication purposes. -// -// Many complex conditions can be used in the concrete struct which implements AccountI. -type AccountI interface { - proto.Message - - GetAddress() sdk.AccAddress - SetAddress(sdk.AccAddress) error // errors if already set. - - GetPubKey() cryptotypes.PubKey // can return nil. - SetPubKey(cryptotypes.PubKey) error - - GetAccountNumber() uint64 - SetAccountNumber(uint64) error - - GetSequence() uint64 - SetSequence(uint64) error - - // Ensure that account implements stringer - String() string -} - // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. type ModuleAccountI interface { - AccountI + sdk.AccountI GetName() string GetPermissions() []string @@ -365,7 +339,7 @@ func (ga GenesisAccounts) Contains(addr sdk.Address) bool { // GenesisAccount defines a genesis account that embeds an AccountI with validation capabilities. type GenesisAccount interface { - AccountI + sdk.AccountI Validate() error } diff --git a/x/auth/types/account_retriever.go b/x/auth/types/account_retriever.go index 792524fff017..7727607e8d28 100644 --- a/x/auth/types/account_retriever.go +++ b/x/auth/types/account_retriever.go @@ -14,7 +14,7 @@ import ( ) var ( - _ client.Account = AccountI(nil) + _ client.Account = sdk.AccountI(nil) _ client.AccountRetriever = AccountRetriever{} ) @@ -51,7 +51,7 @@ func (ar AccountRetriever) GetAccountWithHeight(clientCtx client.Context, addr s return nil, 0, fmt.Errorf("failed to parse block height: %w", err) } - var acc AccountI + var acc sdk.AccountI if err := clientCtx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil { return nil, 0, err } diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index 76680d824d5b..0463072f6f44 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -17,7 +17,7 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*ModuleAccountI)(nil), nil) cdc.RegisterInterface((*GenesisAccount)(nil), nil) - cdc.RegisterInterface((*AccountI)(nil), nil) + cdc.RegisterInterface((*sdk.AccountI)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil) cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params", nil) @@ -32,7 +32,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterInterface( "cosmos.auth.v1beta1.AccountI", - (*AccountI)(nil), + (*sdk.AccountI)(nil), &BaseAccount{}, &ModuleAccount{}, ) diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index 82e658d60748..b3a66869da83 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -148,10 +149,10 @@ type GenesisAccountIterator struct{} // appGenesis and invokes a callback on each genesis account. If any call // returns true, iteration stops. func (GenesisAccountIterator) IterateGenesisAccounts( - cdc codec.Codec, appGenesis map[string]json.RawMessage, cb func(AccountI) (stop bool), + cdc codec.Codec, appGenesis map[string]json.RawMessage, cb func(sdk.AccountI) (stop bool), ) { for _, genAcc := range GetGenesisStateFromAppState(cdc, appGenesis).Accounts { - acc, ok := genAcc.GetCachedValue().(AccountI) + acc, ok := genAcc.GetCachedValue().(sdk.AccountI) if !ok { panic("expected account") } diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index 5f2001482877..ba8a230a9922 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -5,10 +5,11 @@ import ( "testing" "cosmossdk.io/depinject" - "github.com/cosmos/cosmos-sdk/codec" proto "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" @@ -75,7 +76,7 @@ func TestGenesisAccountIterator(t *testing.T) { var addresses []sdk.AccAddress types.GenesisAccountIterator{}.IterateGenesisAccounts( - cdc, appGenesis, func(acc types.AccountI) (stop bool) { + cdc, appGenesis, func(acc sdk.AccountI) (stop bool) { addresses = append(addresses, acc.GetAddress()) return false }, diff --git a/x/auth/types/query.go b/x/auth/types/query.go index ce0fa7fe2c44..8ab9df38f9f0 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,9 +1,12 @@ package types -import codectypes "github.com/cosmos/cosmos-sdk/codec/types" +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var account AccountI + var account sdk.AccountI return unpacker.UnpackAny(m.Account, &account) } diff --git a/x/auth/vesting/exported/exported.go b/x/auth/vesting/exported/exported.go index 858e53ed4f98..bfc15f7175cb 100644 --- a/x/auth/vesting/exported/exported.go +++ b/x/auth/vesting/exported/exported.go @@ -3,14 +3,12 @@ package exported import ( "time" - "github.com/cosmos/cosmos-sdk/x/auth/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // VestingAccount defines an account type that vests coins via a vesting schedule. type VestingAccount interface { - types.AccountI + sdk.AccountI // LockedCoins returns the set of coins that are not spendable (i.e. locked), // defined as the vesting coins that are not delegated. diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 2ec28589081c..eb9f2497fe97 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -56,7 +56,7 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount) baseVestingAccount := types.NewBaseVestingAccount(baseAccount, msg.Amount.Sort(), msg.EndTime) - var vestingAccount authtypes.AccountI + var vestingAccount sdk.AccountI if msg.Delayed { vestingAccount = types.NewDelayedVestingAccountRaw(baseVestingAccount) } else { diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 2dd2c5a8196f..9a95ccf62a1e 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -41,7 +41,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) registry.RegisterImplementations( - (*authtypes.AccountI)(nil), + (*sdk.AccountI)(nil), &BaseVestingAccount{}, &DelayedVestingAccount{}, &ContinuousVestingAccount{}, diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 892794f669cc..ae9b1550d2d1 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -15,7 +15,7 @@ import ( // Compile-time type assertions var ( - _ authtypes.AccountI = (*BaseVestingAccount)(nil) + _ sdk.AccountI = (*BaseVestingAccount)(nil) _ vestexported.VestingAccount = (*ContinuousVestingAccount)(nil) _ vestexported.VestingAccount = (*PeriodicVestingAccount)(nil) _ vestexported.VestingAccount = (*DelayedVestingAccount)(nil) diff --git a/x/authz/expected_keepers.go b/x/authz/expected_keepers.go index 186ac955e909..812daa518f52 100644 --- a/x/authz/expected_keepers.go +++ b/x/authz/expected_keepers.go @@ -2,14 +2,13 @@ package authz import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - SetAccount(ctx sdk.Context, acc authtypes.AccountI) + 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) } // 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 f5bb29a5f8cf..82cb5c48d460 100644 --- a/x/authz/testutil/expected_keepers_mocks.go +++ b/x/authz/testutil/expected_keepers_mocks.go @@ -8,7 +8,6 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -36,10 +35,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -50,10 +49,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -64,7 +63,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 4fbb622ad9e6..132e76886c80 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "fmt" "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/internal/conv" "github.com/cosmos/cosmos-sdk/store/prefix" diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 45746bd39ecb..7df87ede0aad 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -149,7 +149,7 @@ func (suite *KeeperTestSuite) mockSendCoinsFromAccountToModule(acc *authtypes.Ba suite.authKeeper.EXPECT().HasAccount(suite.ctx, moduleAcc.GetAddress()).Return(true) } -func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender authtypes.AccountI, receiver sdk.AccAddress) { +func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender sdk.AccountI, receiver sdk.AccAddress) { suite.authKeeper.EXPECT().GetAccount(ctx, sender.GetAddress()).Return(sender) suite.authKeeper.EXPECT().HasAccount(ctx, receiver).Return(true) } @@ -159,7 +159,7 @@ func (suite *KeeperTestSuite) mockFundAccount(receiver sdk.AccAddress) { suite.mockSendCoinsFromModuleToAccount(mintAcc, receiver) } -func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountI, outputs []sdk.AccAddress) { +func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []sdk.AccountI, outputs []sdk.AccAddress) { for _, input := range inputs { suite.authKeeper.EXPECT().GetAccount(suite.ctx, input.GetAddress()).Return(input) } @@ -168,15 +168,15 @@ func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountI, } } -func (suite *KeeperTestSuite) mockValidateBalance(acc authtypes.AccountI) { +func (suite *KeeperTestSuite) mockValidateBalance(acc sdk.AccountI) { suite.authKeeper.EXPECT().GetAccount(suite.ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc authtypes.AccountI) { +func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc sdk.AccountI) { suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.AccountI, mAcc authtypes.AccountI) { +func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -185,7 +185,7 @@ func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.A suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) } -func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc authtypes.AccountI, mAcc authtypes.AccountI) { +func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -466,7 +466,7 @@ func (suite *KeeperTestSuite) TestInputOutputNewAccount() { require.Empty(suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) - suite.mockInputOutputCoins([]authtypes.AccountI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) + suite.mockInputOutputCoins([]sdk.AccountI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) inputs := []banktypes.Input{ {Address: accAddrs[0].String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, } @@ -516,7 +516,7 @@ func (suite *KeeperTestSuite) TestInputOutputCoins() { require.Error(suite.bankKeeper.InputOutputCoins(ctx, insufficientInputs, insufficientOutputs)) - suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[1:3]) + suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[1:3]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) acc1Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) @@ -746,7 +746,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { suite.mockFundAccount(accAddrs[0]) require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100)))) - suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[2:4]) + suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[2:4]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() @@ -771,7 +771,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)))) newCoins2 = sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) - suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[2:4]) + suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[2:4]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() diff --git a/x/bank/keeper/msg_service_test.go b/x/bank/keeper/msg_service_test.go index 87b5c4b6fcb9..a6454b6a8531 100644 --- a/x/bank/keeper/msg_service_test.go +++ b/x/bank/keeper/msg_service_test.go @@ -2,7 +2,6 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -159,7 +158,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSend() { suite.mockMintCoins(minterAcc) suite.bankKeeper.MintCoins(suite.ctx, minterAcc.Name, origCoins) if !tc.expErr { - suite.mockInputOutputCoins([]authtypes.AccountI{minterAcc}, accAddrs[:2]) + suite.mockInputOutputCoins([]sdk.AccountI{minterAcc}, accAddrs[:2]) } _, err := suite.msgServer.MultiSend(suite.ctx, tc.input) if tc.expErr { diff --git a/x/bank/testutil/expected_keepers_mocks.go b/x/bank/testutil/expected_keepers_mocks.go index c27addd028fd..35929b606df5 100644 --- a/x/bank/testutil/expected_keepers_mocks.go +++ b/x/bank/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -50,10 +50,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetAllAccounts mocks base method. -func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types0.AccountI { +func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllAccounts", ctx) - ret0, _ := ret[0].([]types0.AccountI) + ret0, _ := ret[0].([]types.AccountI) return ret0 } @@ -150,7 +150,7 @@ func (mr *MockAccountKeeperMockRecorder) HasAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -162,10 +162,10 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -176,10 +176,10 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -190,7 +190,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 191d6b5a836a..5899d8505f99 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -8,15 +8,15 @@ import ( // AccountKeeper defines the account contract that must be fulfilled when // creating a x/bank keeper. type AccountKeeper interface { - NewAccount(sdk.Context, types.AccountI) types.AccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI - GetAllAccounts(ctx sdk.Context) []types.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 types.AccountI) + SetAccount(ctx sdk.Context, acc sdk.AccountI) - IterateAccounts(ctx sdk.Context, process func(types.AccountI) bool) + IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) bool) ValidatePermissions(macc types.ModuleAccountI) error diff --git a/x/consensus/testutil/expected_keepers_mocks.go b/x/consensus/testutil/expected_keepers_mocks.go index c27addd028fd..35929b606df5 100644 --- a/x/consensus/testutil/expected_keepers_mocks.go +++ b/x/consensus/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -50,10 +50,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetAllAccounts mocks base method. -func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types0.AccountI { +func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllAccounts", ctx) - ret0, _ := ret[0].([]types0.AccountI) + ret0, _ := ret[0].([]types.AccountI) return ret0 } @@ -150,7 +150,7 @@ func (mr *MockAccountKeeperMockRecorder) HasAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -162,10 +162,10 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -176,10 +176,10 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -190,7 +190,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index 585d2cb57792..224e8e73f5d9 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -37,10 +37,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 94cea333ab06..8526cdb76a4e 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -8,7 +8,7 @@ import ( // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI diff --git a/x/evidence/testutil/expected_keepers_mocks.go b/x/evidence/testutil/expected_keepers_mocks.go index 7f609130b457..c80700532ca2 100644 --- a/x/evidence/testutil/expected_keepers_mocks.go +++ b/x/evidence/testutil/expected_keepers_mocks.go @@ -10,8 +10,7 @@ import ( types "github.com/cosmos/cosmos-sdk/crypto/types" types0 "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/x/auth/types" - types2 "github.com/cosmos/cosmos-sdk/x/staking/types" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -39,10 +38,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // GetParams mocks base method. -func (m *MockStakingKeeper) GetParams(ctx types0.Context) types2.Params { +func (m *MockStakingKeeper) GetParams(ctx types0.Context) types1.Params { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetParams", ctx) - ret0, _ := ret[0].(types2.Params) + ret0, _ := ret[0].(types1.Params) return ret0 } @@ -53,10 +52,10 @@ func (mr *MockStakingKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types0.Context, arg1 types0.ConsAddress) types2.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types0.Context, arg1 types0.ConsAddress) types1.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types2.ValidatorI) + ret0, _ := ret[0].(types1.ValidatorI) return ret0 } @@ -157,7 +156,7 @@ func (mr *MockSlashingKeeperMockRecorder) JailUntil(arg0, arg1, arg2 interface{} } // Slash mocks base method. -func (m *MockSlashingKeeper) Slash(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64, arg5 types2.Infraction) { +func (m *MockSlashingKeeper) Slash(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64, arg5 types1.Infraction) { m.ctrl.T.Helper() m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4, arg5) } @@ -218,7 +217,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types0.Context, acc types1.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types0.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 8c157aff0c97..820cb23ab6eb 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -3,8 +3,6 @@ package types import ( "time" - "github.com/cosmos/cosmos-sdk/x/auth/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -33,7 +31,7 @@ type ( // AccountKeeper define the account keeper interface contracted needed by the evidence module AccountKeeper interface { - SetAccount(ctx sdk.Context, acc types.AccountI) + SetAccount(ctx sdk.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 eb5d4bf04465..2be5d9b95841 100644 --- a/x/feegrant/expected_keepers.go +++ b/x/feegrant/expected_keepers.go @@ -10,9 +10,9 @@ type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, moduleName string) auth.ModuleAccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI - SetAccount(ctx sdk.Context, acc auth.AccountI) + 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) } // BankKeeper defines the expected supply Keeper (noalias) diff --git a/x/feegrant/testutil/expected_keepers_mocks.go b/x/feegrant/testutil/expected_keepers_mocks.go index c00c4b0d71fc..30e7854ef93c 100644 --- a/x/feegrant/testutil/expected_keepers_mocks.go +++ b/x/feegrant/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -78,10 +78,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{} } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -92,7 +92,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.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 f51fa2eb2733..7822c4527b06 100644 --- a/x/genutil/testutil/expected_keepers_mocks.go +++ b/x/genutil/testutil/expected_keepers_mocks.go @@ -10,10 +10,9 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" exported "github.com/cosmos/cosmos-sdk/x/bank/exported" gomock "github.com/golang/mock/gomock" - types1 "github.com/tendermint/tendermint/abci/types" + types0 "github.com/tendermint/tendermint/abci/types" ) // MockStakingKeeper is a mock of StakingKeeper interface. @@ -40,10 +39,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // ApplyAndReturnValidatorSetUpdates mocks base method. -func (m *MockStakingKeeper) ApplyAndReturnValidatorSetUpdates(arg0 types.Context) ([]types1.ValidatorUpdate, error) { +func (m *MockStakingKeeper) ApplyAndReturnValidatorSetUpdates(arg0 types.Context) ([]types0.ValidatorUpdate, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ApplyAndReturnValidatorSetUpdates", arg0) - ret0, _ := ret[0].([]types1.ValidatorUpdate) + ret0, _ := ret[0].([]types0.ValidatorUpdate) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -78,7 +77,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -90,10 +89,10 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -104,7 +103,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } @@ -139,7 +138,7 @@ func (m *MockGenesisAccountsIterator) EXPECT() *MockGenesisAccountsIteratorMockR } // IterateGenesisAccounts mocks base method. -func (m *MockGenesisAccountsIterator) IterateGenesisAccounts(cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, cb func(types0.AccountI) bool) { +func (m *MockGenesisAccountsIterator) IterateGenesisAccounts(cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, cb func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateGenesisAccounts", cdc, appGenesis, cb) } diff --git a/x/genutil/types/expected_keepers.go b/x/genutil/types/expected_keepers.go index 854422a3c990..a55c7a7a0330 100644 --- a/x/genutil/types/expected_keepers.go +++ b/x/genutil/types/expected_keepers.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported" ) @@ -18,9 +17,9 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - NewAccount(sdk.Context, auth.AccountI) auth.AccountI - SetAccount(sdk.Context, auth.AccountI) - IterateAccounts(ctx sdk.Context, process func(auth.AccountI) (stop bool)) + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI + SetAccount(sdk.Context, sdk.AccountI) + IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool)) } // GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias) @@ -28,7 +27,7 @@ type GenesisAccountsIterator interface { IterateGenesisAccounts( cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, - cb func(auth.AccountI) (stop bool), + cb func(sdk.AccountI) (stop bool), ) } diff --git a/x/gov/testutil/expected_keepers.go b/x/gov/testutil/expected_keepers.go index 669dbc010b2d..50ace59c6611 100644 --- a/x/gov/testutil/expected_keepers.go +++ b/x/gov/testutil/expected_keepers.go @@ -6,7 +6,6 @@ import ( math "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -16,7 +15,7 @@ import ( type AccountKeeper interface { types.AccountKeeper - IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountI) (stop bool)) + IterateAccounts(ctx sdk.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 e119ee2bf6e9..4c922b5a2182 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -42,10 +42,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -84,7 +84,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, cb func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, cb func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, cb) } diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index 70f0e5fbe994..1e8a106b34d3 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -29,7 +30,7 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI diff --git a/x/group/expected_keepers.go b/x/group/expected_keepers.go index f5baa0d486ea..37f7dbd97120 100644 --- a/x/group/expected_keepers.go +++ b/x/group/expected_keepers.go @@ -2,18 +2,17 @@ package group import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) type AccountKeeper interface { // Return a new account with the next account number. Does not save the new account to the store. - NewAccount(sdk.Context, authtypes.AccountI) authtypes.AccountI + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI // Retrieve an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountI + GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI // Set an account in the store. - SetAccount(sdk.Context, authtypes.AccountI) + SetAccount(sdk.Context, sdk.AccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index d210ff508929..61063bc0ddaf 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -14,7 +14,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/auth/tx" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/group/keeper" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -1201,7 +1200,7 @@ func SimulateMsgLeaveGroup(cdc *codec.ProtoCodec, k keeper.Keeper, ak group.Acco func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, ctx sdk.Context, accounts []simtypes.Account, -) (groupInfo *group.GroupInfo, acc simtypes.Account, account authtypes.AccountI, err error) { +) (groupInfo *group.GroupInfo, acc simtypes.Account, account sdk.AccountI, err error) { groupID := k.GetGroupSequence(ctx) switch { @@ -1239,7 +1238,7 @@ func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, ctx sdk.Context, accounts []simtypes.Account, -) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account authtypes.AccountI, err error) { +) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account sdk.AccountI, err error) { groupInfo, _, _, err = randomGroup(r, k, ak, ctx, accounts) if err != nil { return nil, nil, simtypes.Account{}, nil, err @@ -1271,7 +1270,7 @@ func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, func randomMember(ctx context.Context, r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, accounts []simtypes.Account, groupID uint64, -) (acc simtypes.Account, account authtypes.AccountI, err error) { +) (acc simtypes.Account, account sdk.AccountI, err error) { res, err := k.GroupMembers(ctx, &group.QueryGroupMembersRequest{ GroupId: groupID, }) diff --git a/x/group/testutil/expected_keepers_mocks.go b/x/group/testutil/expected_keepers_mocks.go index ea9ae48066e6..b335f6f76849 100644 --- a/x/group/testutil/expected_keepers_mocks.go +++ b/x/group/testutil/expected_keepers_mocks.go @@ -9,8 +9,7 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" - types1 "github.com/cosmos/cosmos-sdk/x/bank/types" + types0 "github.com/cosmos/cosmos-sdk/x/bank/types" gomock "github.com/golang/mock/gomock" ) @@ -38,10 +37,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(arg0 types.Context, arg1 types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(arg0 types.Context, arg1 types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -52,10 +51,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(arg0, arg1 interface{}) *gom } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -66,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } @@ -129,10 +128,10 @@ func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amt interface{} } // MultiSend mocks base method. -func (m *MockBankKeeper) MultiSend(arg0 context.Context, arg1 *types1.MsgMultiSend) (*types1.MsgMultiSendResponse, error) { +func (m *MockBankKeeper) MultiSend(arg0 context.Context, arg1 *types0.MsgMultiSend) (*types0.MsgMultiSendResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MultiSend", arg0, arg1) - ret0, _ := ret[0].(*types1.MsgMultiSendResponse) + ret0, _ := ret[0].(*types0.MsgMultiSendResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -144,10 +143,10 @@ func (mr *MockBankKeeperMockRecorder) MultiSend(arg0, arg1 interface{}) *gomock. } // Send mocks base method. -func (m *MockBankKeeper) Send(arg0 context.Context, arg1 *types1.MsgSend) (*types1.MsgSendResponse, error) { +func (m *MockBankKeeper) Send(arg0 context.Context, arg1 *types0.MsgSend) (*types0.MsgSendResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Send", arg0, arg1) - ret0, _ := ret[0].(*types1.MsgSendResponse) + ret0, _ := ret[0].(*types0.MsgSendResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -173,10 +172,10 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderMo } // SetSendEnabled mocks base method. -func (m *MockBankKeeper) SetSendEnabled(arg0 context.Context, arg1 *types1.MsgSetSendEnabled) (*types1.MsgSetSendEnabledResponse, error) { +func (m *MockBankKeeper) SetSendEnabled(arg0 context.Context, arg1 *types0.MsgSetSendEnabled) (*types0.MsgSetSendEnabledResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetSendEnabled", arg0, arg1) - ret0, _ := ret[0].(*types1.MsgSetSendEnabledResponse) + ret0, _ := ret[0].(*types0.MsgSetSendEnabledResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -202,10 +201,10 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom } // UpdateParams mocks base method. -func (m *MockBankKeeper) UpdateParams(arg0 context.Context, arg1 *types1.MsgUpdateParams) (*types1.MsgUpdateParamsResponse, error) { +func (m *MockBankKeeper) UpdateParams(arg0 context.Context, arg1 *types0.MsgUpdateParams) (*types0.MsgUpdateParamsResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateParams", arg0, arg1) - ret0, _ := ret[0].(*types1.MsgUpdateParamsResponse) + ret0, _ := ret[0].(*types0.MsgUpdateParamsResponse) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/x/nft/expected_keepers.go b/x/nft/expected_keepers.go index 0e0f1efd6e45..ec7976e294b9 100644 --- a/x/nft/expected_keepers.go +++ b/x/nft/expected_keepers.go @@ -2,7 +2,6 @@ package nft import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // BankKeeper defines the contract needed to be fulfilled for banking and supply @@ -14,5 +13,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) authtypes.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI } diff --git a/x/nft/testutil/expected_keepers_mocks.go b/x/nft/testutil/expected_keepers_mocks.go index 49d193397ee2..cf85857c6717 100644 --- a/x/nft/testutil/expected_keepers_mocks.go +++ b/x/nft/testutil/expected_keepers_mocks.go @@ -8,7 +8,6 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -73,10 +72,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } diff --git a/x/simulation/expected_keepers.go b/x/simulation/expected_keepers.go index c54831b8a401..346d695f66dc 100644 --- a/x/simulation/expected_keepers.go +++ b/x/simulation/expected_keepers.go @@ -2,12 +2,11 @@ package simulation import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetAccount(ctx sdk.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 d30b21f06178..498d097bd137 100644 --- a/x/slashing/testutil/expected_keepers_mocks.go +++ b/x/slashing/testutil/expected_keepers_mocks.go @@ -9,9 +9,8 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" - types1 "github.com/cosmos/cosmos-sdk/x/params/types" - types2 "github.com/cosmos/cosmos-sdk/x/staking/types" + types0 "github.com/cosmos/cosmos-sdk/x/params/types" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -39,10 +38,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -53,7 +52,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -179,7 +178,7 @@ func (mr *MockParamSubspaceMockRecorder) Get(ctx, key, ptr interface{}) *gomock. } // GetParamSet mocks base method. -func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types1.ParamSet) { +func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types0.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "GetParamSet", ctx, ps) } @@ -205,7 +204,7 @@ func (mr *MockParamSubspaceMockRecorder) HasKeyTable() *gomock.Call { } // SetParamSet mocks base method. -func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types1.ParamSet) { +func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types0.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetParamSet", ctx, ps) } @@ -217,10 +216,10 @@ func (mr *MockParamSubspaceMockRecorder) SetParamSet(ctx, ps interface{}) *gomoc } // WithKeyTable mocks base method. -func (m *MockParamSubspace) WithKeyTable(table types1.KeyTable) types1.Subspace { +func (m *MockParamSubspace) WithKeyTable(table types0.KeyTable) types0.Subspace { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "WithKeyTable", table) - ret0, _ := ret[0].(types1.Subspace) + ret0, _ := ret[0].(types0.Subspace) return ret0 } @@ -254,10 +253,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // Delegation mocks base method. -func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types2.DelegationI { +func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types1.DelegationI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2) - ret0, _ := ret[0].(types2.DelegationI) + ret0, _ := ret[0].(types1.DelegationI) return ret0 } @@ -268,10 +267,10 @@ func (mr *MockStakingKeeperMockRecorder) Delegation(arg0, arg1, arg2 interface{} } // GetAllValidators mocks base method. -func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types2.Validator { +func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types1.Validator { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllValidators", ctx) - ret0, _ := ret[0].([]types2.Validator) + ret0, _ := ret[0].([]types1.Validator) return ret0 } @@ -296,7 +295,7 @@ func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{} } // IterateValidators mocks base method. -func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types2.ValidatorI) bool) { +func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateValidators", arg0, arg1) } @@ -334,7 +333,7 @@ func (mr *MockStakingKeeperMockRecorder) MaxValidators(arg0 interface{}) *gomock } // Slash mocks base method. -func (m *MockStakingKeeper) Slash(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types2.Infraction) math.Int { +func (m *MockStakingKeeper) Slash(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types1.Infraction) math.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(math.Int) @@ -360,10 +359,10 @@ func (mr *MockStakingKeeperMockRecorder) Unjail(arg0, arg1 interface{}) *gomock. } // Validator mocks base method. -func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types2.ValidatorI { +func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types1.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", arg0, arg1) - ret0, _ := ret[0].(types2.ValidatorI) + ret0, _ := ret[0].(types1.ValidatorI) return ret0 } @@ -374,10 +373,10 @@ func (mr *MockStakingKeeperMockRecorder) Validator(arg0, arg1 interface{}) *gomo } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types2.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types1.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types2.ValidatorI) + ret0, _ := ret[0].(types1.ValidatorI) return ret0 } diff --git a/x/slashing/types/expected_keepers.go b/x/slashing/types/expected_keepers.go index 5698c08ae2f7..74a61be5fe34 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -2,16 +2,16 @@ package types import ( "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // AccountKeeper expected account keeper type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI - IterateAccounts(ctx sdk.Context, process func(auth.AccountI) (stop bool)) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + IterateAccounts(ctx sdk.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 18f3e82fce2b..650942cc9fd7 100644 --- a/x/staking/testutil/expected_keepers_mocks.go +++ b/x/staking/testutil/expected_keepers_mocks.go @@ -89,10 +89,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -131,7 +131,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index 0a3ef7477ab4..e4b85950dc99 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -15,8 +15,8 @@ type DistributionKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - IterateAccounts(ctx sdk.Context, process func(authtypes.AccountI) (stop bool)) - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI // only used for simulation + IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool)) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI From 254fad6923fbaa7f2b946f53bc99c9f1479b0796 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 21 Nov 2022 10:50:46 +0530 Subject: [PATCH 02/21] wip: more changes --- simapp/state.go | 3 ++- tests/e2e/auth/suite.go | 8 ++++---- tools/rosetta/converter.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/simapp/state.go b/simapp/state.go index 29b3259ffe78..0a5fb948c020 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -13,6 +13,7 @@ import ( "cosmossdk.io/math" simappparams "cosmossdk.io/simapp/params" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" @@ -233,7 +234,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str privKey := secp256k1.GenPrivKeyFromSecret(privkeySeed) - a, ok := acc.GetCachedValue().(authtypes.AccountI) + a, ok := acc.GetCachedValue().(sdk.AccountI) if !ok { panic("expected account") } diff --git a/tests/e2e/auth/suite.go b/tests/e2e/auth/suite.go index d82c39b32b87..1466356f9b2a 100644 --- a/tests/e2e/auth/suite.go +++ b/tests/e2e/auth/suite.go @@ -397,7 +397,7 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() { // query account info queryResJSON, err := authclitestutil.QueryAccountExec(val1.ClientCtx, val1.Address) require.NoError(err) - var account authtypes.AccountI + var account sdk.AccountI require.NoError(val1.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) /**** test signature-only ****/ @@ -1328,7 +1328,7 @@ func (s *IntegrationTestSuite) TestMultisignBatch() { queryResJSON, err := authclitestutil.QueryAccountExec(val.ClientCtx, addr) s.Require().NoError(err) - var account authtypes.AccountI + var account sdk.AccountI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) // sign-batch file @@ -1399,7 +1399,7 @@ func (s *IntegrationTestSuite) TestGetAccountCmd() { s.Require().Error(err) s.Require().NotEqual("internal", err.Error()) } else { - var acc authtypes.AccountI + var acc sdk.AccountI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(out.Bytes(), &acc)) s.Require().Equal(val.Address, acc.GetAddress()) } @@ -1457,7 +1457,7 @@ func (s *IntegrationTestSuite) TestQueryModuleAccountByNameCmd() { var res authtypes.QueryModuleAccountByNameResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - var account authtypes.AccountI + var account sdk.AccountI err := val.ClientCtx.InterfaceRegistry.UnpackAny(res.Account, &account) s.Require().NoError(err) diff --git a/tools/rosetta/converter.go b/tools/rosetta/converter.go index 4fd1f8366dc9..0c4e217ec228 100644 --- a/tools/rosetta/converter.go +++ b/tools/rosetta/converter.go @@ -16,6 +16,7 @@ import ( crgerrs "cosmossdk.io/tools/rosetta/lib/errors" crgtypes "cosmossdk.io/tools/rosetta/lib/types" + sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -24,7 +25,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -755,7 +755,7 @@ func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMe // SignerData converts the given any account to signer data func (c converter) SignerData(anyAccount *codectypes.Any) (*SignerData, error) { - var acc auth.AccountI + var acc sdk.AccountI err := c.ir.UnpackAny(anyAccount, &acc) if err != nil { return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) From 544dbf074f1e6703ec24bcfccf2d7e688b0dfb44 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Thu, 22 Dec 2022 11:19:57 +0530 Subject: [PATCH 03/21] small fix --- x/group/keeper/keeper_test.go | 2 +- x/group/testutil/expected_keepers_mocks.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index f8c24db88009..5fdf2839ceb7 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -135,7 +135,7 @@ func (s TestSuite) setNextAccount() { //nolint:govet // this is a test and we're s.accountKeeper.EXPECT().GetAccount(gomock.Any(), sdk.AccAddress(accountCredentials.Address())).Return(nil).AnyTimes() s.accountKeeper.EXPECT().NewAccount(gomock.Any(), groupPolicyAcc).Return(groupPolicyAccBumpAccountNumber).AnyTimes() - s.accountKeeper.EXPECT().SetAccount(gomock.Any(), authtypes.AccountI(groupPolicyAccBumpAccountNumber)).Return().AnyTimes() + s.accountKeeper.EXPECT().SetAccount(gomock.Any(), sdk.AccountI(groupPolicyAccBumpAccountNumber)).Return().AnyTimes() } func TestKeeperTestSuite(t *testing.T) { diff --git a/x/group/testutil/expected_keepers_mocks.go b/x/group/testutil/expected_keepers_mocks.go index 2f39856c816f..8f614b6be1e2 100644 --- a/x/group/testutil/expected_keepers_mocks.go +++ b/x/group/testutil/expected_keepers_mocks.go @@ -65,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // RemoveAccount mocks base method. -func (m *MockAccountKeeper) RemoveAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) RemoveAccount(ctx types.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "RemoveAccount", ctx, acc) } From 9a9cf2f7b8968163a75667817dcffa528a9875da Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Fri, 23 Dec 2022 11:13:42 +0530 Subject: [PATCH 04/21] wip --- x/auth/keeper/account.go | 21 +++---- x/auth/keeper/deterministic_test.go | 26 ++++----- x/auth/keeper/genesis.go | 9 +-- x/auth/keeper/keeper.go | 28 +++++----- x/auth/keeper/keeper_test.go | 4 +- x/auth/keeper/migrations.go | 2 +- x/auth/migrations/v2/store.go | 3 +- x/auth/types/account.go | 56 +++++++++++++++++++ x/slashing/testutil/expected_keepers_mocks.go | 39 ++++++------- x/slashing/types/expected_keepers.go | 5 +- 10 files changed, 127 insertions(+), 66 deletions(-) diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index f6f8613de369..4b22d17f0059 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -6,8 +6,9 @@ import ( ) // NewAccountWithAddress implements AccountKeeperI. -func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { - acc := ak.proto() +func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.BaseAccount { + acc := ak.proto + err := acc.SetAddress(addr) if err != nil { panic(err) @@ -17,7 +18,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 sdk.Context, acc types.BaseAccount) types.BaseAccount { if err := acc.SetAccountNumber(ak.NextAccountNumber(ctx)); err != nil { panic(err) } @@ -38,11 +39,11 @@ func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool { } // GetAccount implements AccountKeeperI. -func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { +func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.BaseAccount { store := ctx.KVStore(ak.storeKey) bz := store.Get(types.AddressStoreKey(addr)) if bz == nil { - return nil + return types.BaseAccount{} } return ak.decodeAccount(bz) @@ -59,8 +60,8 @@ 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) { - ak.IterateAccounts(ctx, func(acc sdk.AccountI) (stop bool) { +func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []types.BaseAccount) { + ak.IterateAccounts(ctx, func(acc types.BaseAccount) (stop bool) { accounts = append(accounts, acc) return false }) @@ -69,7 +70,7 @@ 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 sdk.Context, acc types.BaseAccount) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) @@ -84,7 +85,7 @@ 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 sdk.Context, acc types.BaseAccount) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) store.Delete(types.AddressStoreKey(addr)) @@ -93,7 +94,7 @@ func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc sdk.AccountI) { // 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)) { +func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account types.BaseAccount) (stop bool)) { store := ctx.KVStore(ak.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix) diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 2cf9e73d2ed6..30638723b3c5 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -62,7 +62,7 @@ func (suite *DeterministicTestSuite) SetupTest() { suite.accountKeeper = keeper.NewAccountKeeper( suite.encCfg.Codec, key, - types.ProtoBaseAccount, + types.BaseAccount{}, maccPerms, "cosmos", types.NewModuleAddress("gov").String(), @@ -77,8 +77,8 @@ func (suite *DeterministicTestSuite) SetupTest() { } // createAndSetAccount creates a random account and sets to the keeper store. -func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []sdk.AccountI { - accs := make([]sdk.AccountI, 0, count) +func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []types.BaseAccount { + accs := make([]types.BaseAccount, 0, count) // We need all generated account-numbers unique accNums := rapid.SliceOfNDistinct(rapid.Uint64(), count, count, func(i uint64) uint64 { return i }).Draw(t, "acc-numss") @@ -90,8 +90,8 @@ func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) seq := rapid.Uint64().Draw(t, "sequence") acc1 := types.NewBaseAccount(addr, &pub, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, acc1) - accs = append(accs, acc1) + suite.accountKeeper.SetAccount(suite.ctx, *acc1) + accs = append(accs, *acc1) } return accs @@ -110,7 +110,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccount() { seq := uint64(98) acc1 := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, acc1) + suite.accountKeeper.SetAccount(suite.ctx, *acc1) req := &types.QueryAccountRequest{Address: acc1.GetAddress().String()} @@ -152,8 +152,8 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccounts() { acc1 := types.NewBaseAccount(addr1, &secp256k1.PubKey{Key: pub1}, accNum1, seq1) acc2 := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum2, seq2) - suite.accountKeeper.SetAccount(suite.ctx, acc1) - suite.accountKeeper.SetAccount(suite.ctx, acc2) + suite.accountKeeper.SetAccount(suite.ctx, *acc1) + suite.accountKeeper.SetAccount(suite.ctx, *acc2) req := &types.QueryAccountsRequest{} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.Accounts, 1716, false) @@ -168,7 +168,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccountAddressByID() { seq := rapid.Uint64().Draw(t, "sequence") acc1 := types.NewBaseAccount(addr, &pub, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, acc1) + suite.accountKeeper.SetAccount(suite.ctx, *acc1) req := &types.QueryAccountAddressByIDRequest{AccountId: accNum} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.AccountAddressByID, 0, true) @@ -180,7 +180,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccountAddressByID() { acc1 := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, acc1) + suite.accountKeeper.SetAccount(suite.ctx, *acc1) req := &types.QueryAccountAddressByIDRequest{AccountId: accNum} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.AccountAddressByID, 1123, false) } @@ -226,7 +226,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccountInfo() { acc := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, acc) + suite.accountKeeper.SetAccount(suite.ctx, *acc) req := &types.QueryAccountInfoRequest{Address: acc.GetAddress().String()} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.AccountInfo, 1543, false) } @@ -281,7 +281,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() { ak := keeper.NewAccountKeeper( suite.encCfg.Codec, suite.key, - types.ProtoBaseAccount, + types.BaseAccount{}, maccPerms, "cosmos", types.NewModuleAddress("gov").String(), @@ -327,7 +327,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() { ak := keeper.NewAccountKeeper( suite.encCfg.Codec, suite.key, - types.ProtoBaseAccount, + types.BaseAccount{}, maccPerms, "cosmos", types.NewModuleAddress("gov").String(), diff --git a/x/auth/keeper/genesis.go b/x/auth/keeper/genesis.go index ad830ef54e21..b1f32f0e156f 100644 --- a/x/auth/keeper/genesis.go +++ b/x/auth/keeper/genesis.go @@ -28,7 +28,8 @@ func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { n := ak.NextAccountNumber(ctx) lastAccNum = &n } - ak.SetAccount(ctx, acc) + baseAcc := types.NewBaseAccount(acc.GetAddress(), acc.GetPubKey(), acc.GetAccountNumber(), acc.GetSequence()) + ak.SetAccount(ctx, *baseAcc) } ak.GetModuleAccount(ctx, types.FeeCollectorName) @@ -39,9 +40,9 @@ func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := ak.GetParams(ctx) var genAccounts types.GenesisAccounts - ak.IterateAccounts(ctx, func(account sdk.AccountI) bool { - genAccount := account.(types.GenesisAccount) - genAccounts = append(genAccounts, genAccount) + ak.IterateAccounts(ctx, func(account types.BaseAccount) bool { + // genAccount := account.(types.GenesisAccount) + genAccounts = append(genAccounts, &account) return false }) diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 934c3fdbf9de..f73972c7acfc 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -18,25 +18,25 @@ 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(sdk.Context, sdk.AccAddress) types.BaseAccount // 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(sdk.Context, types.BaseAccount) types.BaseAccount // Check if an account exists in the store. HasAccount(sdk.Context, sdk.AccAddress) bool // Retrieve an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI + GetAccount(sdk.Context, sdk.AccAddress) types.BaseAccount // Set an account in the store. - SetAccount(sdk.Context, sdk.AccountI) + SetAccount(sdk.Context, types.BaseAccount) // Remove an account from the store. - RemoveAccount(sdk.Context, sdk.AccountI) + RemoveAccount(sdk.Context, types.BaseAccount) // Iterate over all accounts, calling the provided function. Stop iteration when it returns true. - IterateAccounts(sdk.Context, func(sdk.AccountI) bool) + IterateAccounts(sdk.Context, func(types.BaseAccount) bool) // Fetch the public key of an account at a specified address GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error) @@ -59,7 +59,7 @@ type AccountKeeper struct { permAddrs map[string]types.PermissionsForAddress // The prototypical AccountI constructor. - proto func() sdk.AccountI + proto types.BaseAccount addressCdc address.Codec // the address capable of executing a MsgUpdateParams message. Typically, this @@ -76,7 +76,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, storeKey storetypes.StoreKey, proto types.BaseAccount, maccPerms map[string][]string, bech32Prefix string, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) @@ -109,7 +109,7 @@ func (ak AccountKeeper) Logger(ctx sdk.Context) log.Logger { // GetPubKey Returns the PubKey of the account at address func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) { acc := ak.GetAccount(ctx, addr) - if acc == nil { + if acc.GetPubKey() == nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr) } @@ -228,7 +228,7 @@ func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc types.ModuleAccou ak.SetAccount(ctx, macc) } -func (ak AccountKeeper) decodeAccount(bz []byte) sdk.AccountI { +func (ak AccountKeeper) decodeAccount(bz []byte) types.BaseAccount { acc, err := ak.UnmarshalAccount(bz) if err != nil { panic(err) @@ -238,14 +238,14 @@ func (ak AccountKeeper) decodeAccount(bz []byte) sdk.AccountI { } // MarshalAccount protobuf serializes an Account interface -func (ak AccountKeeper) MarshalAccount(accountI sdk.AccountI) ([]byte, error) { //nolint:interfacer - return ak.cdc.MarshalInterface(accountI) +func (ak AccountKeeper) MarshalAccount(baseAcc types.BaseAccount) ([]byte, error) { //nolint:interfacer + return ak.cdc.MarshalInterface(&baseAcc) } // UnmarshalAccount returns an Account interface from raw encoded account // bytes of a Proto-based Account type -func (ak AccountKeeper) UnmarshalAccount(bz []byte) (sdk.AccountI, error) { - var acc sdk.AccountI +func (ak AccountKeeper) UnmarshalAccount(bz []byte) (types.BaseAccount, error) { + var acc types.BaseAccount return acc, ak.cdc.UnmarshalInterface(bz, &acc) } diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 29dc06efbb72..13a79abcd869 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -59,7 +59,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.accountKeeper = keeper.NewAccountKeeper( suite.encCfg.Codec, key, - types.ProtoBaseAccount, + types.BaseAccount{}, maccPerms, "cosmos", types.NewModuleAddress("gov").String(), @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().Equal(len(keeperAccts), len(accts)+1, "number of accounts in the keeper vs in genesis state") for i, genAcct := range accts { genAcctAddr := genAcct.GetAddress() - var keeperAcct sdk.AccountI + var keeperAcct types.BaseAccount for _, kacct := range keeperAccts { if genAcctAddr.Equals(kacct.GetAddress()) { keeperAcct = kacct diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index ec2f49512b33..7e5ef7e62a5f 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -27,7 +27,7 @@ func NewMigrator(keeper AccountKeeper, queryServer grpc.Server, ss exported.Subs func (m Migrator) Migrate1to2(ctx sdk.Context) error { var iterErr error - m.keeper.IterateAccounts(ctx, func(account sdk.AccountI) (stop bool) { + m.keeper.IterateAccounts(ctx, func(account types.BaseAccount) (stop bool) { wb, err := v2.MigrateAccount(ctx, account, m.queryServer) if err != nil { iterErr = err diff --git a/x/auth/migrations/v2/store.go b/x/auth/migrations/v2/store.go index abebf9afb052..3094303a7c19 100644 --- a/x/auth/migrations/v2/store.go +++ b/x/auth/migrations/v2/store.go @@ -30,6 +30,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -289,6 +290,6 @@ func getBondDenom(ctx sdk.Context, queryServer grpc.Server) (string, error) { // // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func MigrateAccount(ctx sdk.Context, account sdk.AccountI, queryServer grpc.Server) (sdk.AccountI, error) { +func MigrateAccount(ctx sdk.Context, account types.BaseAccount, queryServer grpc.Server) (sdk.AccountI, error) { return migrateVestingAccounts(ctx, account, queryServer) } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index cdd14c2bc5f0..af1a715fa34d 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -15,6 +15,8 @@ import ( ) var ( + _ sdk.AccountI = AccountIWrapper{} + _ sdk.AccountI = (*BaseAccount)(nil) _ GenesisAccount = (*BaseAccount)(nil) _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) @@ -266,6 +268,60 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { return nil } +// AccountIWrapper is a wrapper struct around sdk.AccountI to support the interface for users. +type AccountIWrapper struct { + AccountI sdk.AccountI +} + +// ProtoMessage implements types.AccountI +func (AccountIWrapper) ProtoMessage() {} + +// Reset implements types.AccountI +func (AccountIWrapper) Reset() {} + +// String implements types.AccountI +func (AccountIWrapper) String() string { return "" } + +// GetAddress implements types.AccountI +func (acc AccountIWrapper) GetAddress() sdk.AccAddress { + return acc.AccountI.GetAddress() +} + +// SetAddress implements types.AccountI +func (acc AccountIWrapper) SetAddress(addr sdk.AccAddress) error { + return acc.AccountI.SetAddress(addr) +} + +// GetPubKey implements types.AccountI +func (acc AccountIWrapper) GetPubKey() (pk cryptotypes.PubKey) { + return acc.AccountI.GetPubKey() +} + +// SetPubKey implements types.AccountI +func (acc AccountIWrapper) SetPubKey(pubkey cryptotypes.PubKey) error { + return acc.AccountI.SetPubKey(pubkey) +} + +// GetAccountNumber implements types.AccountI +func (acc AccountIWrapper) GetAccountNumber() uint64 { + return acc.AccountI.GetAccountNumber() +} + +// SetAccountNumber implements types.AccountI +func (acc AccountIWrapper) SetAccountNumber(accNumber uint64) error { + return acc.AccountI.SetAccountNumber(accNumber) +} + +// GetSequence implements types.AccountI +func (acc AccountIWrapper) GetSequence() uint64 { + return acc.AccountI.GetSequence() +} + +// SetSequence implements types.AccountI +func (acc AccountIWrapper) SetSequence(seq uint64) error { + return acc.AccountI.SetSequence(seq) +} + // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. type ModuleAccountI interface { diff --git a/x/slashing/testutil/expected_keepers_mocks.go b/x/slashing/testutil/expected_keepers_mocks.go index 1de66b89e99a..5140c416bb9b 100644 --- a/x/slashing/testutil/expected_keepers_mocks.go +++ b/x/slashing/testutil/expected_keepers_mocks.go @@ -9,8 +9,9 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/params/types" - types1 "github.com/cosmos/cosmos-sdk/x/staking/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" + types1 "github.com/cosmos/cosmos-sdk/x/params/types" + types2 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -38,10 +39,10 @@ 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 types.Context, addr types.AccAddress) types0.BaseAccount { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.BaseAccount) return ret0 } @@ -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 types.Context, process func(types0.BaseAccount) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -178,7 +179,7 @@ func (mr *MockParamSubspaceMockRecorder) Get(ctx, key, ptr interface{}) *gomock. } // GetParamSet mocks base method. -func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types0.ParamSet) { +func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types1.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "GetParamSet", ctx, ps) } @@ -204,7 +205,7 @@ func (mr *MockParamSubspaceMockRecorder) HasKeyTable() *gomock.Call { } // SetParamSet mocks base method. -func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types0.ParamSet) { +func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types1.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetParamSet", ctx, ps) } @@ -216,10 +217,10 @@ func (mr *MockParamSubspaceMockRecorder) SetParamSet(ctx, ps interface{}) *gomoc } // WithKeyTable mocks base method. -func (m *MockParamSubspace) WithKeyTable(table types0.KeyTable) types0.Subspace { +func (m *MockParamSubspace) WithKeyTable(table types1.KeyTable) types1.Subspace { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "WithKeyTable", table) - ret0, _ := ret[0].(types0.Subspace) + ret0, _ := ret[0].(types1.Subspace) return ret0 } @@ -253,10 +254,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // Delegation mocks base method. -func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types1.DelegationI { +func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types2.DelegationI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2) - ret0, _ := ret[0].(types1.DelegationI) + ret0, _ := ret[0].(types2.DelegationI) return ret0 } @@ -267,10 +268,10 @@ func (mr *MockStakingKeeperMockRecorder) Delegation(arg0, arg1, arg2 interface{} } // GetAllValidators mocks base method. -func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types1.Validator { +func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types2.Validator { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllValidators", ctx) - ret0, _ := ret[0].([]types1.Validator) + ret0, _ := ret[0].([]types2.Validator) return ret0 } @@ -295,7 +296,7 @@ func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{} } // IterateValidators mocks base method. -func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { +func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types2.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateValidators", arg0, arg1) } @@ -347,7 +348,7 @@ func (mr *MockStakingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 inte } // SlashWithInfractionReason mocks base method. -func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types1.Infraction) math.Int { +func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types2.Infraction) math.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(math.Int) @@ -373,10 +374,10 @@ func (mr *MockStakingKeeperMockRecorder) Unjail(arg0, arg1 interface{}) *gomock. } // Validator mocks base method. -func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types1.ValidatorI { +func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types2.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types2.ValidatorI) return ret0 } @@ -387,10 +388,10 @@ func (mr *MockStakingKeeperMockRecorder) Validator(arg0, arg1 interface{}) *gomo } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types1.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types2.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types2.ValidatorI) return ret0 } diff --git a/x/slashing/types/expected_keepers.go b/x/slashing/types/expected_keepers.go index 3306be791a27..e10f59022af6 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -4,14 +4,15 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // 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 sdk.Context, addr sdk.AccAddress) types.BaseAccount + IterateAccounts(ctx sdk.Context, process func(types.BaseAccount) (stop bool)) } // BankKeeper defines the expected interface needed to retrieve account balances. From 951e1c4b892473061d33d988fe2735ad8761d2f7 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Fri, 23 Dec 2022 18:52:29 +0530 Subject: [PATCH 05/21] Revert "wip" This reverts commit 9a9cf2f7b8968163a75667817dcffa528a9875da. --- x/auth/keeper/account.go | 21 ++++--- x/auth/keeper/deterministic_test.go | 26 ++++----- x/auth/keeper/genesis.go | 9 ++- x/auth/keeper/keeper.go | 28 +++++----- x/auth/keeper/keeper_test.go | 4 +- x/auth/keeper/migrations.go | 2 +- x/auth/migrations/v2/store.go | 3 +- x/auth/types/account.go | 56 ------------------- x/slashing/testutil/expected_keepers_mocks.go | 39 +++++++------ x/slashing/types/expected_keepers.go | 5 +- 10 files changed, 66 insertions(+), 127 deletions(-) diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index 4b22d17f0059..f6f8613de369 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -6,9 +6,8 @@ import ( ) // NewAccountWithAddress implements AccountKeeperI. -func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.BaseAccount { - acc := ak.proto - +func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { + acc := ak.proto() err := acc.SetAddress(addr) if err != nil { panic(err) @@ -18,7 +17,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 types.BaseAccount) types.BaseAccount { +func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc sdk.AccountI) sdk.AccountI { if err := acc.SetAccountNumber(ak.NextAccountNumber(ctx)); err != nil { panic(err) } @@ -39,11 +38,11 @@ func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool { } // GetAccount implements AccountKeeperI. -func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.BaseAccount { +func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { store := ctx.KVStore(ak.storeKey) bz := store.Get(types.AddressStoreKey(addr)) if bz == nil { - return types.BaseAccount{} + return nil } return ak.decodeAccount(bz) @@ -60,8 +59,8 @@ 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 []types.BaseAccount) { - ak.IterateAccounts(ctx, func(acc types.BaseAccount) (stop bool) { +func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []sdk.AccountI) { + ak.IterateAccounts(ctx, func(acc sdk.AccountI) (stop bool) { accounts = append(accounts, acc) return false }) @@ -70,7 +69,7 @@ func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []types.BaseAc } // SetAccount implements AccountKeeperI. -func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.BaseAccount) { +func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc sdk.AccountI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) @@ -85,7 +84,7 @@ func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.BaseAccount) { // 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 types.BaseAccount) { +func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc sdk.AccountI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) store.Delete(types.AddressStoreKey(addr)) @@ -94,7 +93,7 @@ func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc types.BaseAccount) { // 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 types.BaseAccount) (stop bool)) { +func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool)) { store := ctx.KVStore(ak.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix) diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 30638723b3c5..2cf9e73d2ed6 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -62,7 +62,7 @@ func (suite *DeterministicTestSuite) SetupTest() { suite.accountKeeper = keeper.NewAccountKeeper( suite.encCfg.Codec, key, - types.BaseAccount{}, + types.ProtoBaseAccount, maccPerms, "cosmos", types.NewModuleAddress("gov").String(), @@ -77,8 +77,8 @@ func (suite *DeterministicTestSuite) SetupTest() { } // createAndSetAccount creates a random account and sets to the keeper store. -func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []types.BaseAccount { - accs := make([]types.BaseAccount, 0, count) +func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []sdk.AccountI { + accs := make([]sdk.AccountI, 0, count) // We need all generated account-numbers unique accNums := rapid.SliceOfNDistinct(rapid.Uint64(), count, count, func(i uint64) uint64 { return i }).Draw(t, "acc-numss") @@ -90,8 +90,8 @@ func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) seq := rapid.Uint64().Draw(t, "sequence") acc1 := types.NewBaseAccount(addr, &pub, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, *acc1) - accs = append(accs, *acc1) + suite.accountKeeper.SetAccount(suite.ctx, acc1) + accs = append(accs, acc1) } return accs @@ -110,7 +110,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccount() { seq := uint64(98) acc1 := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, *acc1) + suite.accountKeeper.SetAccount(suite.ctx, acc1) req := &types.QueryAccountRequest{Address: acc1.GetAddress().String()} @@ -152,8 +152,8 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccounts() { acc1 := types.NewBaseAccount(addr1, &secp256k1.PubKey{Key: pub1}, accNum1, seq1) acc2 := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum2, seq2) - suite.accountKeeper.SetAccount(suite.ctx, *acc1) - suite.accountKeeper.SetAccount(suite.ctx, *acc2) + suite.accountKeeper.SetAccount(suite.ctx, acc1) + suite.accountKeeper.SetAccount(suite.ctx, acc2) req := &types.QueryAccountsRequest{} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.Accounts, 1716, false) @@ -168,7 +168,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccountAddressByID() { seq := rapid.Uint64().Draw(t, "sequence") acc1 := types.NewBaseAccount(addr, &pub, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, *acc1) + suite.accountKeeper.SetAccount(suite.ctx, acc1) req := &types.QueryAccountAddressByIDRequest{AccountId: accNum} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.AccountAddressByID, 0, true) @@ -180,7 +180,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccountAddressByID() { acc1 := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, *acc1) + suite.accountKeeper.SetAccount(suite.ctx, acc1) req := &types.QueryAccountAddressByIDRequest{AccountId: accNum} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.AccountAddressByID, 1123, false) } @@ -226,7 +226,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccountInfo() { acc := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum, seq) - suite.accountKeeper.SetAccount(suite.ctx, *acc) + suite.accountKeeper.SetAccount(suite.ctx, acc) req := &types.QueryAccountInfoRequest{Address: acc.GetAddress().String()} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.AccountInfo, 1543, false) } @@ -281,7 +281,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() { ak := keeper.NewAccountKeeper( suite.encCfg.Codec, suite.key, - types.BaseAccount{}, + types.ProtoBaseAccount, maccPerms, "cosmos", types.NewModuleAddress("gov").String(), @@ -327,7 +327,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() { ak := keeper.NewAccountKeeper( suite.encCfg.Codec, suite.key, - types.BaseAccount{}, + types.ProtoBaseAccount, maccPerms, "cosmos", types.NewModuleAddress("gov").String(), diff --git a/x/auth/keeper/genesis.go b/x/auth/keeper/genesis.go index b1f32f0e156f..ad830ef54e21 100644 --- a/x/auth/keeper/genesis.go +++ b/x/auth/keeper/genesis.go @@ -28,8 +28,7 @@ func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { n := ak.NextAccountNumber(ctx) lastAccNum = &n } - baseAcc := types.NewBaseAccount(acc.GetAddress(), acc.GetPubKey(), acc.GetAccountNumber(), acc.GetSequence()) - ak.SetAccount(ctx, *baseAcc) + ak.SetAccount(ctx, acc) } ak.GetModuleAccount(ctx, types.FeeCollectorName) @@ -40,9 +39,9 @@ func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := ak.GetParams(ctx) var genAccounts types.GenesisAccounts - ak.IterateAccounts(ctx, func(account types.BaseAccount) bool { - // genAccount := account.(types.GenesisAccount) - genAccounts = append(genAccounts, &account) + ak.IterateAccounts(ctx, func(account sdk.AccountI) bool { + genAccount := account.(types.GenesisAccount) + genAccounts = append(genAccounts, genAccount) return false }) diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index f73972c7acfc..934c3fdbf9de 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -18,25 +18,25 @@ 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) types.BaseAccount + NewAccountWithAddress(sdk.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, types.BaseAccount) types.BaseAccount + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI // Check if an account exists in the store. HasAccount(sdk.Context, sdk.AccAddress) bool // Retrieve an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) types.BaseAccount + GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI // Set an account in the store. - SetAccount(sdk.Context, types.BaseAccount) + SetAccount(sdk.Context, sdk.AccountI) // Remove an account from the store. - RemoveAccount(sdk.Context, types.BaseAccount) + RemoveAccount(sdk.Context, sdk.AccountI) // Iterate over all accounts, calling the provided function. Stop iteration when it returns true. - IterateAccounts(sdk.Context, func(types.BaseAccount) bool) + IterateAccounts(sdk.Context, func(sdk.AccountI) bool) // Fetch the public key of an account at a specified address GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error) @@ -59,7 +59,7 @@ type AccountKeeper struct { permAddrs map[string]types.PermissionsForAddress // The prototypical AccountI constructor. - proto types.BaseAccount + proto func() sdk.AccountI addressCdc address.Codec // the address capable of executing a MsgUpdateParams message. Typically, this @@ -76,7 +76,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 types.BaseAccount, + cdc codec.BinaryCodec, storeKey storetypes.StoreKey, proto func() sdk.AccountI, maccPerms map[string][]string, bech32Prefix string, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) @@ -109,7 +109,7 @@ func (ak AccountKeeper) Logger(ctx sdk.Context) log.Logger { // GetPubKey Returns the PubKey of the account at address func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) { acc := ak.GetAccount(ctx, addr) - if acc.GetPubKey() == nil { + if acc == nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr) } @@ -228,7 +228,7 @@ func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc types.ModuleAccou ak.SetAccount(ctx, macc) } -func (ak AccountKeeper) decodeAccount(bz []byte) types.BaseAccount { +func (ak AccountKeeper) decodeAccount(bz []byte) sdk.AccountI { acc, err := ak.UnmarshalAccount(bz) if err != nil { panic(err) @@ -238,14 +238,14 @@ func (ak AccountKeeper) decodeAccount(bz []byte) types.BaseAccount { } // MarshalAccount protobuf serializes an Account interface -func (ak AccountKeeper) MarshalAccount(baseAcc types.BaseAccount) ([]byte, error) { //nolint:interfacer - return ak.cdc.MarshalInterface(&baseAcc) +func (ak AccountKeeper) MarshalAccount(accountI sdk.AccountI) ([]byte, error) { //nolint:interfacer + return ak.cdc.MarshalInterface(accountI) } // UnmarshalAccount returns an Account interface from raw encoded account // bytes of a Proto-based Account type -func (ak AccountKeeper) UnmarshalAccount(bz []byte) (types.BaseAccount, error) { - var acc types.BaseAccount +func (ak AccountKeeper) UnmarshalAccount(bz []byte) (sdk.AccountI, error) { + var acc sdk.AccountI return acc, ak.cdc.UnmarshalInterface(bz, &acc) } diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 13a79abcd869..29dc06efbb72 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -59,7 +59,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.accountKeeper = keeper.NewAccountKeeper( suite.encCfg.Codec, key, - types.BaseAccount{}, + types.ProtoBaseAccount, maccPerms, "cosmos", types.NewModuleAddress("gov").String(), @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().Equal(len(keeperAccts), len(accts)+1, "number of accounts in the keeper vs in genesis state") for i, genAcct := range accts { genAcctAddr := genAcct.GetAddress() - var keeperAcct types.BaseAccount + var keeperAcct sdk.AccountI for _, kacct := range keeperAccts { if genAcctAddr.Equals(kacct.GetAddress()) { keeperAcct = kacct diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index 7e5ef7e62a5f..ec2f49512b33 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -27,7 +27,7 @@ func NewMigrator(keeper AccountKeeper, queryServer grpc.Server, ss exported.Subs func (m Migrator) Migrate1to2(ctx sdk.Context) error { var iterErr error - m.keeper.IterateAccounts(ctx, func(account types.BaseAccount) (stop bool) { + m.keeper.IterateAccounts(ctx, func(account sdk.AccountI) (stop bool) { wb, err := v2.MigrateAccount(ctx, account, m.queryServer) if err != nil { iterErr = err diff --git a/x/auth/migrations/v2/store.go b/x/auth/migrations/v2/store.go index 3094303a7c19..abebf9afb052 100644 --- a/x/auth/migrations/v2/store.go +++ b/x/auth/migrations/v2/store.go @@ -30,7 +30,6 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -290,6 +289,6 @@ func getBondDenom(ctx sdk.Context, queryServer grpc.Server) (string, error) { // // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func MigrateAccount(ctx sdk.Context, account types.BaseAccount, queryServer grpc.Server) (sdk.AccountI, error) { +func MigrateAccount(ctx sdk.Context, account sdk.AccountI, queryServer grpc.Server) (sdk.AccountI, error) { return migrateVestingAccounts(ctx, account, queryServer) } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index af1a715fa34d..cdd14c2bc5f0 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -15,8 +15,6 @@ import ( ) var ( - _ sdk.AccountI = AccountIWrapper{} - _ sdk.AccountI = (*BaseAccount)(nil) _ GenesisAccount = (*BaseAccount)(nil) _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) @@ -268,60 +266,6 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { return nil } -// AccountIWrapper is a wrapper struct around sdk.AccountI to support the interface for users. -type AccountIWrapper struct { - AccountI sdk.AccountI -} - -// ProtoMessage implements types.AccountI -func (AccountIWrapper) ProtoMessage() {} - -// Reset implements types.AccountI -func (AccountIWrapper) Reset() {} - -// String implements types.AccountI -func (AccountIWrapper) String() string { return "" } - -// GetAddress implements types.AccountI -func (acc AccountIWrapper) GetAddress() sdk.AccAddress { - return acc.AccountI.GetAddress() -} - -// SetAddress implements types.AccountI -func (acc AccountIWrapper) SetAddress(addr sdk.AccAddress) error { - return acc.AccountI.SetAddress(addr) -} - -// GetPubKey implements types.AccountI -func (acc AccountIWrapper) GetPubKey() (pk cryptotypes.PubKey) { - return acc.AccountI.GetPubKey() -} - -// SetPubKey implements types.AccountI -func (acc AccountIWrapper) SetPubKey(pubkey cryptotypes.PubKey) error { - return acc.AccountI.SetPubKey(pubkey) -} - -// GetAccountNumber implements types.AccountI -func (acc AccountIWrapper) GetAccountNumber() uint64 { - return acc.AccountI.GetAccountNumber() -} - -// SetAccountNumber implements types.AccountI -func (acc AccountIWrapper) SetAccountNumber(accNumber uint64) error { - return acc.AccountI.SetAccountNumber(accNumber) -} - -// GetSequence implements types.AccountI -func (acc AccountIWrapper) GetSequence() uint64 { - return acc.AccountI.GetSequence() -} - -// SetSequence implements types.AccountI -func (acc AccountIWrapper) SetSequence(seq uint64) error { - return acc.AccountI.SetSequence(seq) -} - // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. type ModuleAccountI interface { diff --git a/x/slashing/testutil/expected_keepers_mocks.go b/x/slashing/testutil/expected_keepers_mocks.go index 5140c416bb9b..1de66b89e99a 100644 --- a/x/slashing/testutil/expected_keepers_mocks.go +++ b/x/slashing/testutil/expected_keepers_mocks.go @@ -9,9 +9,8 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" - types1 "github.com/cosmos/cosmos-sdk/x/params/types" - types2 "github.com/cosmos/cosmos-sdk/x/staking/types" + types0 "github.com/cosmos/cosmos-sdk/x/params/types" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -39,10 +38,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.BaseAccount { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.BaseAccount) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -53,7 +52,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.BaseAccount) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -179,7 +178,7 @@ func (mr *MockParamSubspaceMockRecorder) Get(ctx, key, ptr interface{}) *gomock. } // GetParamSet mocks base method. -func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types1.ParamSet) { +func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types0.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "GetParamSet", ctx, ps) } @@ -205,7 +204,7 @@ func (mr *MockParamSubspaceMockRecorder) HasKeyTable() *gomock.Call { } // SetParamSet mocks base method. -func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types1.ParamSet) { +func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types0.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetParamSet", ctx, ps) } @@ -217,10 +216,10 @@ func (mr *MockParamSubspaceMockRecorder) SetParamSet(ctx, ps interface{}) *gomoc } // WithKeyTable mocks base method. -func (m *MockParamSubspace) WithKeyTable(table types1.KeyTable) types1.Subspace { +func (m *MockParamSubspace) WithKeyTable(table types0.KeyTable) types0.Subspace { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "WithKeyTable", table) - ret0, _ := ret[0].(types1.Subspace) + ret0, _ := ret[0].(types0.Subspace) return ret0 } @@ -254,10 +253,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // Delegation mocks base method. -func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types2.DelegationI { +func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types1.DelegationI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2) - ret0, _ := ret[0].(types2.DelegationI) + ret0, _ := ret[0].(types1.DelegationI) return ret0 } @@ -268,10 +267,10 @@ func (mr *MockStakingKeeperMockRecorder) Delegation(arg0, arg1, arg2 interface{} } // GetAllValidators mocks base method. -func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types2.Validator { +func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types1.Validator { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllValidators", ctx) - ret0, _ := ret[0].([]types2.Validator) + ret0, _ := ret[0].([]types1.Validator) return ret0 } @@ -296,7 +295,7 @@ func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{} } // IterateValidators mocks base method. -func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types2.ValidatorI) bool) { +func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateValidators", arg0, arg1) } @@ -348,7 +347,7 @@ func (mr *MockStakingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 inte } // SlashWithInfractionReason mocks base method. -func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types2.Infraction) math.Int { +func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types1.Infraction) math.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(math.Int) @@ -374,10 +373,10 @@ func (mr *MockStakingKeeperMockRecorder) Unjail(arg0, arg1 interface{}) *gomock. } // Validator mocks base method. -func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types2.ValidatorI { +func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types1.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", arg0, arg1) - ret0, _ := ret[0].(types2.ValidatorI) + ret0, _ := ret[0].(types1.ValidatorI) return ret0 } @@ -388,10 +387,10 @@ func (mr *MockStakingKeeperMockRecorder) Validator(arg0, arg1 interface{}) *gomo } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types2.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types1.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types2.ValidatorI) + ret0, _ := ret[0].(types1.ValidatorI) return ret0 } diff --git a/x/slashing/types/expected_keepers.go b/x/slashing/types/expected_keepers.go index e10f59022af6..3306be791a27 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -4,15 +4,14 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // AccountKeeper expected account keeper type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.BaseAccount - IterateAccounts(ctx sdk.Context, process func(types.BaseAccount) (stop bool)) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool)) } // BankKeeper defines the expected interface needed to retrieve account balances. From fad126a49241d9aedd6164bbeedc9620ccd8ec00 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 26 Dec 2022 15:45:26 +0530 Subject: [PATCH 06/21] wip --- x/auth/types/expected_keepers.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/x/auth/types/expected_keepers.go b/x/auth/types/expected_keepers.go index 7f242c63fd3a..c491dd6ed46a 100644 --- a/x/auth/types/expected_keepers.go +++ b/x/auth/types/expected_keepers.go @@ -1,9 +1,27 @@ package types import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) +type AccountI interface { + GetAddress(sdk.Context) sdk.AccAddress + SetAddress(sdk.Context, sdk.AccAddress) error // errors if already set. + + GetPubKey(sdk.Context) cryptotypes.PubKey // can return nil. + SetPubKey(sdk.Context, cryptotypes.PubKey) error + + GetAccountNumber(sdk.Context) uint64 + SetAccountNumber(sdk.Context, uint64) error + + GetSequence(sdk.Context) uint64 + SetSequence(sdk.Context, uint64) error + + // Ensure that account implements stringer + String() string +} + // BankKeeper defines the contract needed for supply related APIs (noalias) type BankKeeper interface { SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error From ae0204f76b41cd1d5877a05eb5be73befabaabd5 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 26 Dec 2022 16:01:31 +0530 Subject: [PATCH 07/21] wip --- tools/rosetta/converter.go | 3 ++- x/auth/types/expected_keepers.go | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/rosetta/converter.go b/tools/rosetta/converter.go index 0c4e217ec228..889101aea715 100644 --- a/tools/rosetta/converter.go +++ b/tools/rosetta/converter.go @@ -25,6 +25,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + auth "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -755,7 +756,7 @@ func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMe // SignerData converts the given any account to signer data func (c converter) SignerData(anyAccount *codectypes.Any) (*SignerData, error) { - var acc sdk.AccountI + var acc auth.AccountI err := c.ir.UnpackAny(anyAccount, &acc) if err != nil { return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) diff --git a/x/auth/types/expected_keepers.go b/x/auth/types/expected_keepers.go index c491dd6ed46a..0099d0620047 100644 --- a/x/auth/types/expected_keepers.go +++ b/x/auth/types/expected_keepers.go @@ -12,10 +12,12 @@ type AccountI interface { GetPubKey(sdk.Context) cryptotypes.PubKey // can return nil. SetPubKey(sdk.Context, cryptotypes.PubKey) error - GetAccountNumber(sdk.Context) uint64 + // GetAccountNumber(sdk.Context) uint64 + GetAccountNumber() uint64 SetAccountNumber(sdk.Context, uint64) error - GetSequence(sdk.Context) uint64 + // GetSequence(sdk.Context) uint64 + GetSequence() uint64 SetSequence(sdk.Context, uint64) error // Ensure that account implements stringer From 31559318a3c7a3c02bb35818058fb8956c56802c Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 26 Dec 2022 16:49:53 +0530 Subject: [PATCH 08/21] wip: add alias AccountI interface --- simapp/state.go | 2 +- tests/e2e/auth/suite.go | 8 ++-- x/auth/ante/expected_keepers.go | 4 +- x/auth/ante/fee.go | 2 +- x/auth/ante/sigverify.go | 2 +- .../ante/testutil/expected_keepers_mocks.go | 6 +-- x/auth/ante/testutil_test.go | 2 +- x/auth/keeper/account.go | 16 ++++---- x/auth/keeper/deterministic_test.go | 10 ++--- x/auth/keeper/genesis.go | 2 +- x/auth/keeper/grpc_query_test.go | 12 +++--- x/auth/keeper/keeper.go | 24 ++++++------ x/auth/keeper/keeper_test.go | 4 +- x/auth/keeper/migrations.go | 4 +- x/auth/migrations/v2/store.go | 7 ++-- x/auth/migrations/v3/store.go | 2 +- x/auth/module.go | 2 +- x/auth/simulation/decoder.go | 2 +- x/auth/simulation/decoder_test.go | 1 + x/auth/types/account.go | 36 +++++++++++++++-- x/auth/types/account_retriever.go | 4 +- x/auth/types/alias.go | 27 +++++++++++++ x/auth/types/codec.go | 4 +- x/auth/types/expected_keepers.go | 20 ---------- x/auth/types/genesis.go | 5 +-- x/auth/types/genesis_test.go | 2 +- x/auth/types/query.go | 7 +--- x/auth/vesting/exported/exported.go | 3 +- x/auth/vesting/msg_server.go | 2 +- x/auth/vesting/types/codec.go | 2 +- x/auth/vesting/types/vesting_account.go | 2 +- x/authz/expected_keepers.go | 7 ++-- x/authz/testutil/expected_keepers_mocks.go | 11 +++--- x/bank/keeper/keeper_test.go | 20 +++++----- x/bank/keeper/msg_service_test.go | 3 +- x/bank/testutil/expected_keepers_mocks.go | 20 +++++----- x/bank/types/expected_keepers.go | 12 +++--- .../testutil/expected_keepers_mocks.go | 4 +- x/distribution/types/expected_keepers.go | 2 +- x/evidence/testutil/expected_keepers_mocks.go | 15 +++---- x/evidence/types/expected_keepers.go | 3 +- x/feegrant/expected_keepers.go | 6 +-- x/feegrant/testutil/expected_keepers_mocks.go | 10 ++--- x/genutil/testutil/expected_keepers_mocks.go | 17 ++++---- x/genutil/types/expected_keepers.go | 9 +++-- x/gov/testutil/expected_keepers.go | 3 +- x/gov/testutil/expected_keepers_mocks.go | 6 +-- x/gov/types/expected_keepers.go | 2 +- x/group/expected_keepers.go | 9 +++-- x/group/keeper/keeper_test.go | 2 +- x/group/simulation/operations.go | 7 ++-- x/group/testutil/expected_keepers_mocks.go | 31 ++++++++------- x/nft/expected_keepers.go | 3 +- x/nft/testutil/expected_keepers_mocks.go | 5 ++- x/simulation/expected_keepers.go | 3 +- x/slashing/testutil/expected_keepers_mocks.go | 39 ++++++++++--------- x/slashing/types/expected_keepers.go | 5 ++- x/staking/testutil/expected_keepers_mocks.go | 6 +-- x/staking/types/expected_keepers.go | 4 +- 59 files changed, 271 insertions(+), 219 deletions(-) create mode 100644 x/auth/types/alias.go diff --git a/simapp/state.go b/simapp/state.go index 632711358ec1..9669c18cd04e 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -234,7 +234,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str privKey := secp256k1.GenPrivKeyFromSecret(privkeySeed) - a, ok := acc.GetCachedValue().(sdk.AccountI) + a, ok := acc.GetCachedValue().(authtypes.AccountAliasI) if !ok { panic("expected account") } diff --git a/tests/e2e/auth/suite.go b/tests/e2e/auth/suite.go index dddb64082d51..c47ba9a851e4 100644 --- a/tests/e2e/auth/suite.go +++ b/tests/e2e/auth/suite.go @@ -397,7 +397,7 @@ func (s *E2ETestSuite) TestCLISignAminoJSON() { // query account info queryResJSON, err := authclitestutil.QueryAccountExec(val1.ClientCtx, val1.Address) require.NoError(err) - var account sdk.AccountI + var account authtypes.AccountAliasI require.NoError(val1.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) /**** test signature-only ****/ @@ -1327,7 +1327,7 @@ func (s *E2ETestSuite) TestMultisignBatch() { queryResJSON, err := authclitestutil.QueryAccountExec(val.ClientCtx, addr) s.Require().NoError(err) - var account sdk.AccountI + var account authtypes.AccountAliasI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) // sign-batch file @@ -1398,7 +1398,7 @@ func (s *E2ETestSuite) TestGetAccountCmd() { s.Require().Error(err) s.Require().NotEqual("internal", err.Error()) } else { - var acc sdk.AccountI + var acc authtypes.AccountAliasI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(out.Bytes(), &acc)) s.Require().Equal(val.Address, acc.GetAddress()) } @@ -1456,7 +1456,7 @@ func (s *E2ETestSuite) TestQueryModuleAccountByNameCmd() { var res authtypes.QueryModuleAccountByNameResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - var account sdk.AccountI + var account authtypes.AccountAliasI err := val.ClientCtx.InterfaceRegistry.UnpackAny(res.Account, &account) s.Require().NoError(err) diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 1db0dff716c1..d60a0673811a 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -9,8 +9,8 @@ import ( // 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) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI + SetAccount(ctx sdk.Context, acc types.AccountAliasI) GetModuleAddress(moduleName string) sdk.AccAddress } diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 20cace9403ab..0a8031e1b172 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -122,7 +122,7 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee } // DeductFees deducts fees from the given account. -func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc sdk.AccountI, fees sdk.Coins) error { +func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountAliasI, fees sdk.Coins) error { if !fees.IsValid() { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 9db289b3d81a..362e704cbf58 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -449,7 +449,7 @@ func ConsumeMultisignatureVerificationGas( // GetSignerAcc returns an account for a given address that is expected to sign // a transaction. -func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (sdk.AccountI, error) { +func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (types.AccountAliasI, error) { if acc := ak.GetAccount(ctx, addr); acc != nil { return acc, nil } diff --git a/x/auth/ante/testutil/expected_keepers_mocks.go b/x/auth/ante/testutil/expected_keepers_mocks.go index 34c7c68e4ef8..dd2ea42d3206 100644 --- a/x/auth/ante/testutil/expected_keepers_mocks.go +++ b/x/auth/ante/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -78,7 +78,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 types.Context, acc types0.AccountAliasI) { 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 38e38b4bad09..04bfc9418255 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -26,7 +26,7 @@ import ( // TestAccount represents an account used in the tests in x/auth/ante. type TestAccount struct { - acc sdk.AccountI + acc types.AccountAliasI priv cryptotypes.PrivKey } diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index f6f8613de369..5e20ff3ef63b 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -6,7 +6,7 @@ import ( ) // NewAccountWithAddress implements AccountKeeperI. -func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { +func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI { acc := ak.proto() err := acc.SetAddress(addr) if err != nil { @@ -17,7 +17,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 sdk.Context, acc types.AccountAliasI) types.AccountAliasI { if err := acc.SetAccountNumber(ak.NextAccountNumber(ctx)); err != nil { panic(err) } @@ -38,7 +38,7 @@ func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool { } // GetAccount implements AccountKeeperI. -func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { +func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI { store := ctx.KVStore(ak.storeKey) bz := store.Get(types.AddressStoreKey(addr)) if bz == nil { @@ -59,8 +59,8 @@ 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) { - ak.IterateAccounts(ctx, func(acc sdk.AccountI) (stop bool) { +func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []types.AccountAliasI) { + ak.IterateAccounts(ctx, func(acc types.AccountAliasI) (stop bool) { accounts = append(accounts, acc) return false }) @@ -69,7 +69,7 @@ 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 sdk.Context, acc types.AccountAliasI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) @@ -84,7 +84,7 @@ 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 sdk.Context, acc types.AccountAliasI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) store.Delete(types.AddressStoreKey(addr)) @@ -93,7 +93,7 @@ func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc sdk.AccountI) { // 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)) { +func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account types.AccountAliasI) (stop bool)) { store := ctx.KVStore(ak.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix) diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 2cf9e73d2ed6..177769379c3e 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -77,8 +77,8 @@ func (suite *DeterministicTestSuite) SetupTest() { } // createAndSetAccount creates a random account and sets to the keeper store. -func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []sdk.AccountI { - accs := make([]sdk.AccountI, 0, count) +func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []types.AccountAliasI { + accs := make([]types.AccountAliasI, 0, count) // We need all generated account-numbers unique accNums := rapid.SliceOfNDistinct(rapid.Uint64(), count, count, func(i uint64) uint64 { return i }).Draw(t, "acc-numss") @@ -239,12 +239,12 @@ func (suite *DeterministicTestSuite) createAndReturnQueryClient(ak keeper.Accoun func (suite *DeterministicTestSuite) setModuleAccounts( ctx sdk.Context, ak keeper.AccountKeeper, maccs []string, -) []sdk.AccountI { +) []types.AccountAliasI { sort.Strings(maccs) - moduleAccounts := make([]sdk.AccountI, 0, len(maccs)) + moduleAccounts := make([]types.AccountAliasI, 0, len(maccs)) for _, m := range maccs { acc, _ := ak.GetModuleAccountAndPermissions(ctx, m) - acc1, ok := acc.(sdk.AccountI) + acc1, ok := acc.(types.AccountAliasI) suite.Require().True(ok) moduleAccounts = append(moduleAccounts, acc1) } diff --git a/x/auth/keeper/genesis.go b/x/auth/keeper/genesis.go index ad830ef54e21..b7bdd8ff87f8 100644 --- a/x/auth/keeper/genesis.go +++ b/x/auth/keeper/genesis.go @@ -39,7 +39,7 @@ func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := ak.GetParams(ctx) var genAccounts types.GenesisAccounts - ak.IterateAccounts(ctx, func(account sdk.AccountI) bool { + ak.IterateAccounts(ctx, func(account types.AccountAliasI) bool { genAccount := account.(types.GenesisAccount) genAccounts = append(genAccounts, genAccount) return false diff --git a/x/auth/keeper/grpc_query_test.go b/x/auth/keeper/grpc_query_test.go index 3d2a2010955b..22d25273353e 100644 --- a/x/auth/keeper/grpc_query_test.go +++ b/x/auth/keeper/grpc_query_test.go @@ -42,7 +42,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccounts() { func(res *types.QueryAccountsResponse) { addresses := make([]sdk.AccAddress, len(res.Accounts)) for i, acc := range res.Accounts { - var account sdk.AccountI + var account types.AccountAliasI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) addresses[i] = account.GetAddress() @@ -123,7 +123,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccount() { }, true, func(res *types.QueryAccountResponse) { - var newAccount sdk.AccountI + var newAccount types.AccountAliasI err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &newAccount) suite.Require().NoError(err) suite.Require().NotNil(newAccount) @@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { func(res *types.QueryModuleAccountsResponse) { mintModuleExists := false for _, acc := range res.Accounts { - var account sdk.AccountI + var account types.AccountAliasI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) @@ -303,7 +303,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { func(res *types.QueryModuleAccountsResponse) { mintModuleExists := false for _, acc := range res.Accounts { - var account sdk.AccountI + var account types.AccountAliasI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) @@ -332,7 +332,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { // Make sure output is sorted alphabetically. var moduleNames []string for _, any := range res.Accounts { - var account sdk.AccountI + var account types.AccountAliasI err := suite.encCfg.InterfaceRegistry.UnpackAny(any, &account) suite.Require().NoError(err) moduleAccount, ok := account.(types.ModuleAccountI) @@ -366,7 +366,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccountByName() { }, true, func(res *types.QueryModuleAccountByNameResponse) { - var account sdk.AccountI + var account types.AccountAliasI err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &account) suite.Require().NoError(err) diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 934c3fdbf9de..f477037fb55f 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -18,25 +18,25 @@ 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(sdk.Context, sdk.AccAddress) types.AccountAliasI // 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(sdk.Context, types.AccountAliasI) types.AccountAliasI // Check if an account exists in the store. HasAccount(sdk.Context, sdk.AccAddress) bool // Retrieve an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI + GetAccount(sdk.Context, sdk.AccAddress) types.AccountAliasI // Set an account in the store. - SetAccount(sdk.Context, sdk.AccountI) + SetAccount(sdk.Context, types.AccountAliasI) // Remove an account from the store. - RemoveAccount(sdk.Context, sdk.AccountI) + RemoveAccount(sdk.Context, types.AccountAliasI) // Iterate over all accounts, calling the provided function. Stop iteration when it returns true. - IterateAccounts(sdk.Context, func(sdk.AccountI) bool) + IterateAccounts(sdk.Context, func(types.AccountAliasI) bool) // Fetch the public key of an account at a specified address GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error) @@ -59,7 +59,7 @@ type AccountKeeper struct { permAddrs map[string]types.PermissionsForAddress // The prototypical AccountI constructor. - proto func() sdk.AccountI + proto func() types.AccountAliasI addressCdc address.Codec // the address capable of executing a MsgUpdateParams message. Typically, this @@ -76,7 +76,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, storeKey storetypes.StoreKey, proto func() types.AccountAliasI, maccPerms map[string][]string, bech32Prefix string, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) @@ -228,7 +228,7 @@ func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc types.ModuleAccou ak.SetAccount(ctx, macc) } -func (ak AccountKeeper) decodeAccount(bz []byte) sdk.AccountI { +func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountAliasI { acc, err := ak.UnmarshalAccount(bz) if err != nil { panic(err) @@ -238,14 +238,14 @@ func (ak AccountKeeper) decodeAccount(bz []byte) sdk.AccountI { } // MarshalAccount protobuf serializes an Account interface -func (ak AccountKeeper) MarshalAccount(accountI sdk.AccountI) ([]byte, error) { //nolint:interfacer +func (ak AccountKeeper) MarshalAccount(accountI types.AccountAliasI) ([]byte, error) { //nolint:interfacer return ak.cdc.MarshalInterface(accountI) } // UnmarshalAccount returns an Account interface from raw encoded account // bytes of a Proto-based Account type -func (ak AccountKeeper) UnmarshalAccount(bz []byte) (sdk.AccountI, error) { - var acc sdk.AccountI +func (ak AccountKeeper) UnmarshalAccount(bz []byte) (types.AccountAliasI, error) { + var acc types.AccountAliasI return acc, ak.cdc.UnmarshalInterface(bz, &acc) } diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 29dc06efbb72..5b93bca1b43e 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -190,7 +190,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { // Fix duplicate account numbers pubKey1 := ed25519.GenPrivKey().PubKey() pubKey2 := ed25519.GenPrivKey().PubKey() - accts := []sdk.AccountI{ + accts := []types.AccountAliasI{ &types.BaseAccount{ Address: sdk.AccAddress(pubKey1.Address()).String(), PubKey: codectypes.UnsafePackAny(pubKey1), @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().Equal(len(keeperAccts), len(accts)+1, "number of accounts in the keeper vs in genesis state") for i, genAcct := range accts { genAcctAddr := genAcct.GetAddress() - var keeperAcct sdk.AccountI + var keeperAcct types.AccountAliasI for _, kacct := range keeperAccts { if genAcctAddr.Equals(kacct.GetAddress()) { keeperAcct = kacct diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index ec2f49512b33..9a2aaaeaca0f 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -27,7 +27,7 @@ func NewMigrator(keeper AccountKeeper, queryServer grpc.Server, ss exported.Subs func (m Migrator) Migrate1to2(ctx sdk.Context) error { var iterErr error - m.keeper.IterateAccounts(ctx, func(account sdk.AccountI) (stop bool) { + m.keeper.IterateAccounts(ctx, func(account types.AccountAliasI) (stop bool) { wb, err := v2.MigrateAccount(ctx, account, m.queryServer) if err != nil { iterErr = err @@ -63,7 +63,7 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { // set the account without map to accAddr to accNumber. // // NOTE: This is used for testing purposes only. -func (m Migrator) V45_SetAccount(ctx sdk.Context, acc sdk.AccountI) error { //nolint:revive +func (m Migrator) V45_SetAccount(ctx sdk.Context, acc types.AccountAliasI) error { //nolint:revive addr := acc.GetAddress() store := ctx.KVStore(m.keeper.storeKey) diff --git a/x/auth/migrations/v2/store.go b/x/auth/migrations/v2/store.go index abebf9afb052..b7cd3a97857a 100644 --- a/x/auth/migrations/v2/store.go +++ b/x/auth/migrations/v2/store.go @@ -30,6 +30,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -45,7 +46,7 @@ const ( // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func migrateVestingAccounts(ctx sdk.Context, account sdk.AccountI, queryServer grpc.Server) (sdk.AccountI, error) { +func migrateVestingAccounts(ctx sdk.Context, account types.AccountAliasI, queryServer grpc.Server) (types.AccountAliasI, error) { bondDenom, err := getBondDenom(ctx, queryServer) if err != nil { return nil, err @@ -99,7 +100,7 @@ func migrateVestingAccounts(ctx sdk.Context, account sdk.AccountI, queryServer g asVesting.TrackDelegation(ctx.BlockTime(), balance, delegations) - return asVesting.(sdk.AccountI), nil + return asVesting.(types.AccountAliasI), nil } func resetVestingDelegatedBalances(evacct exported.VestingAccount) (exported.VestingAccount, bool) { @@ -289,6 +290,6 @@ func getBondDenom(ctx sdk.Context, queryServer grpc.Server) (string, error) { // // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func MigrateAccount(ctx sdk.Context, account sdk.AccountI, queryServer grpc.Server) (sdk.AccountI, error) { +func MigrateAccount(ctx sdk.Context, account types.AccountAliasI, queryServer grpc.Server) (types.AccountAliasI, error) { return migrateVestingAccounts(ctx, account, queryServer) } diff --git a/x/auth/migrations/v3/store.go b/x/auth/migrations/v3/store.go index b8b87646d223..c638c7cda72e 100644 --- a/x/auth/migrations/v3/store.go +++ b/x/auth/migrations/v3/store.go @@ -13,7 +13,7 @@ func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey, defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var acc sdk.AccountI + var acc types.AccountAliasI if err := cdc.UnmarshalInterface(iterator.Value(), &acc); err != nil { return err } diff --git a/x/auth/module.go b/x/auth/module.go index 26e54997177f..bdbb06e687c8 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -212,7 +212,7 @@ type AuthInputs struct { Cdc codec.Codec RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"` - AccountI func() sdk.AccountI `optional:"true"` + AccountI func() types.AccountAliasI `optional:"true"` // LegacySubspace is used solely for migration of x/params managed parameters LegacySubspace exported.Subspace `optional:"true"` diff --git a/x/auth/simulation/decoder.go b/x/auth/simulation/decoder.go index 4d32123e416d..d6d74a430db9 100644 --- a/x/auth/simulation/decoder.go +++ b/x/auth/simulation/decoder.go @@ -13,7 +13,7 @@ import ( ) type AuthUnmarshaler interface { - UnmarshalAccount([]byte) (sdk.AccountI, error) + UnmarshalAccount([]byte) (types.AccountAliasI, error) GetCodec() codec.BinaryCodec } diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index 1d71ce7ece9a..da1099ed59bf 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/depinject" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/auth/types/account.go b/x/auth/types/account.go index cdd14c2bc5f0..ae113a4cfbb7 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -9,6 +9,8 @@ import ( "github.com/tendermint/tendermint/crypto" + proto "github.com/cosmos/gogoproto/proto" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,6 +18,7 @@ import ( var ( _ sdk.AccountI = (*BaseAccount)(nil) + _ AccountAliasI = (*BaseAccount)(nil) _ GenesisAccount = (*BaseAccount)(nil) _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) _ GenesisAccount = (*ModuleAccount)(nil) @@ -41,7 +44,7 @@ func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNu } // ProtoBaseAccount - a prototype function for BaseAccount -func ProtoBaseAccount() sdk.AccountI { +func ProtoBaseAccount() AccountAliasI { return &BaseAccount{} } @@ -266,10 +269,37 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { return nil } +// AccountI is an interface used to store coins at a given address within state. +// It presumes a notion of sequence numbers for replay protection, +// a notion of account numbers for replay protection for previously pruned accounts, +// and a pubkey for authentication purposes. +// +// Many complex conditions can be used in the concrete struct which implements AccountI. +// +// Deprecated +type AccountI interface { + proto.Message + + GetAddress() sdk.AccAddress + SetAddress(sdk.AccAddress) error // errors if already set. + + GetPubKey() cryptotypes.PubKey // can return nil. + SetPubKey(cryptotypes.PubKey) error + + GetAccountNumber() uint64 + SetAccountNumber(uint64) error + + GetSequence() uint64 + SetSequence(uint64) error + + // Ensure that account implements stringer + String() string +} + // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. type ModuleAccountI interface { - sdk.AccountI + AccountAliasI GetName() string GetPermissions() []string @@ -293,7 +323,7 @@ func (ga GenesisAccounts) Contains(addr sdk.Address) bool { // GenesisAccount defines a genesis account that embeds an AccountI with validation capabilities. type GenesisAccount interface { - sdk.AccountI + AccountAliasI Validate() error } diff --git a/x/auth/types/account_retriever.go b/x/auth/types/account_retriever.go index 7727607e8d28..7ad53a3686bb 100644 --- a/x/auth/types/account_retriever.go +++ b/x/auth/types/account_retriever.go @@ -14,7 +14,7 @@ import ( ) var ( - _ client.Account = sdk.AccountI(nil) + _ client.Account = AccountAliasI(nil) _ client.AccountRetriever = AccountRetriever{} ) @@ -51,7 +51,7 @@ func (ar AccountRetriever) GetAccountWithHeight(clientCtx client.Context, addr s return nil, 0, fmt.Errorf("failed to parse block height: %w", err) } - var acc sdk.AccountI + var acc AccountAliasI if err := clientCtx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil { return nil, 0, err } diff --git a/x/auth/types/alias.go b/x/auth/types/alias.go new file mode 100644 index 000000000000..d6fe8ae53424 --- /dev/null +++ b/x/auth/types/alias.go @@ -0,0 +1,27 @@ +package types + +import ( + proto "github.com/cosmos/gogoproto/proto" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type AccountAliasI interface { + proto.Message + + GetAddress() sdk.AccAddress + SetAddress(sdk.AccAddress) error // errors if already set. + + GetPubKey() cryptotypes.PubKey // can return nil. + SetPubKey(cryptotypes.PubKey) error + + GetAccountNumber() uint64 + SetAccountNumber(uint64) error + + GetSequence() uint64 + SetSequence(uint64) error + + // Ensure that account implements stringer + String() string +} diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index d18d1c38b2e6..d80951acafcc 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -18,7 +18,7 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*ModuleAccountI)(nil), nil) cdc.RegisterInterface((*GenesisAccount)(nil), nil) - cdc.RegisterInterface((*sdk.AccountI)(nil), nil) + cdc.RegisterInterface((*AccountAliasI)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil) cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params", nil) @@ -34,7 +34,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterInterface( "cosmos.auth.v1beta1.AccountI", - (*sdk.AccountI)(nil), + (*AccountAliasI)(nil), &BaseAccount{}, &ModuleAccount{}, ) diff --git a/x/auth/types/expected_keepers.go b/x/auth/types/expected_keepers.go index 0099d0620047..7f242c63fd3a 100644 --- a/x/auth/types/expected_keepers.go +++ b/x/auth/types/expected_keepers.go @@ -1,29 +1,9 @@ package types import ( - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -type AccountI interface { - GetAddress(sdk.Context) sdk.AccAddress - SetAddress(sdk.Context, sdk.AccAddress) error // errors if already set. - - GetPubKey(sdk.Context) cryptotypes.PubKey // can return nil. - SetPubKey(sdk.Context, cryptotypes.PubKey) error - - // GetAccountNumber(sdk.Context) uint64 - GetAccountNumber() uint64 - SetAccountNumber(sdk.Context, uint64) error - - // GetSequence(sdk.Context) uint64 - GetSequence() uint64 - SetSequence(sdk.Context, uint64) error - - // Ensure that account implements stringer - String() string -} - // BankKeeper defines the contract needed for supply related APIs (noalias) type BankKeeper interface { SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index b3a66869da83..02138cb596b1 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -149,10 +148,10 @@ type GenesisAccountIterator struct{} // appGenesis and invokes a callback on each genesis account. If any call // returns true, iteration stops. func (GenesisAccountIterator) IterateGenesisAccounts( - cdc codec.Codec, appGenesis map[string]json.RawMessage, cb func(sdk.AccountI) (stop bool), + cdc codec.Codec, appGenesis map[string]json.RawMessage, cb func(AccountAliasI) (stop bool), ) { for _, genAcc := range GetGenesisStateFromAppState(cdc, appGenesis).Accounts { - acc, ok := genAcc.GetCachedValue().(sdk.AccountI) + acc, ok := genAcc.GetCachedValue().(AccountAliasI) if !ok { panic("expected account") } diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index ba8a230a9922..b935f46a8de1 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -76,7 +76,7 @@ func TestGenesisAccountIterator(t *testing.T) { var addresses []sdk.AccAddress types.GenesisAccountIterator{}.IterateGenesisAccounts( - cdc, appGenesis, func(acc sdk.AccountI) (stop bool) { + cdc, appGenesis, func(acc types.AccountAliasI) (stop bool) { addresses = append(addresses, acc.GetAddress()) return false }, diff --git a/x/auth/types/query.go b/x/auth/types/query.go index 8ab9df38f9f0..d0c97b50cf67 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,12 +1,9 @@ package types -import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) +import codectypes "github.com/cosmos/cosmos-sdk/codec/types" func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var account sdk.AccountI + var account AccountAliasI return unpacker.UnpackAny(m.Account, &account) } diff --git a/x/auth/vesting/exported/exported.go b/x/auth/vesting/exported/exported.go index bfc15f7175cb..8471e2add0b4 100644 --- a/x/auth/vesting/exported/exported.go +++ b/x/auth/vesting/exported/exported.go @@ -4,11 +4,12 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" ) // VestingAccount defines an account type that vests coins via a vesting schedule. type VestingAccount interface { - sdk.AccountI + types.AccountAliasI // LockedCoins returns the set of coins that are not spendable (i.e. locked), // defined as the vesting coins that are not delegated. diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index eb9f2497fe97..5a10219c5a92 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -56,7 +56,7 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount) baseVestingAccount := types.NewBaseVestingAccount(baseAccount, msg.Amount.Sort(), msg.EndTime) - var vestingAccount sdk.AccountI + var vestingAccount authtypes.AccountAliasI if msg.Delayed { vestingAccount = types.NewDelayedVestingAccountRaw(baseVestingAccount) } else { diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 9a95ccf62a1e..284f2e018462 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -41,7 +41,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) registry.RegisterImplementations( - (*sdk.AccountI)(nil), + (*authtypes.AccountAliasI)(nil), &BaseVestingAccount{}, &DelayedVestingAccount{}, &ContinuousVestingAccount{}, diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 26a95d84d9d0..96410a68b0d5 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -13,7 +13,7 @@ import ( // Compile-time type assertions var ( - _ sdk.AccountI = (*BaseVestingAccount)(nil) + _ authtypes.AccountAliasI = (*BaseVestingAccount)(nil) _ vestexported.VestingAccount = (*ContinuousVestingAccount)(nil) _ vestexported.VestingAccount = (*PeriodicVestingAccount)(nil) _ vestexported.VestingAccount = (*DelayedVestingAccount)(nil) diff --git a/x/authz/expected_keepers.go b/x/authz/expected_keepers.go index 812daa518f52..f4acac10e25d 100644 --- a/x/authz/expected_keepers.go +++ b/x/authz/expected_keepers.go @@ -2,13 +2,14 @@ package authz import ( sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/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 sdk.Context, addr sdk.AccAddress) authtypes.AccountAliasI + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountAliasI + SetAccount(ctx sdk.Context, acc authtypes.AccountAliasI) } // 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..db5f71b67be5 100644 --- a/x/authz/testutil/expected_keepers_mocks.go +++ b/x/authz/testutil/expected_keepers_mocks.go @@ -8,6 +8,7 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -35,10 +36,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -49,10 +50,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -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 types.Context, acc types0.AccountAliasI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index a4ee759b318e..355125570371 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -149,7 +149,7 @@ func (suite *KeeperTestSuite) mockSendCoinsFromAccountToModule(acc *authtypes.Ba suite.authKeeper.EXPECT().HasAccount(suite.ctx, moduleAcc.GetAddress()).Return(true) } -func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender sdk.AccountI, receiver sdk.AccAddress) { +func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender authtypes.AccountAliasI, receiver sdk.AccAddress) { suite.authKeeper.EXPECT().GetAccount(ctx, sender.GetAddress()).Return(sender) suite.authKeeper.EXPECT().HasAccount(ctx, receiver).Return(true) } @@ -159,7 +159,7 @@ func (suite *KeeperTestSuite) mockFundAccount(receiver sdk.AccAddress) { suite.mockSendCoinsFromModuleToAccount(mintAcc, receiver) } -func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []sdk.AccountI, outputs []sdk.AccAddress) { +func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountAliasI, outputs []sdk.AccAddress) { for _, input := range inputs { suite.authKeeper.EXPECT().GetAccount(suite.ctx, input.GetAddress()).Return(input) } @@ -168,15 +168,15 @@ func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []sdk.AccountI, output } } -func (suite *KeeperTestSuite) mockValidateBalance(acc sdk.AccountI) { +func (suite *KeeperTestSuite) mockValidateBalance(acc authtypes.AccountAliasI) { suite.authKeeper.EXPECT().GetAccount(suite.ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc sdk.AccountI) { +func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc authtypes.AccountAliasI) { suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) { +func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.AccountAliasI, mAcc authtypes.AccountAliasI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -185,7 +185,7 @@ func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc sdk.Account suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) } -func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) { +func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc authtypes.AccountAliasI, mAcc authtypes.AccountAliasI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -466,7 +466,7 @@ func (suite *KeeperTestSuite) TestInputOutputNewAccount() { require.Empty(suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) - suite.mockInputOutputCoins([]sdk.AccountI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) + suite.mockInputOutputCoins([]authtypes.AccountAliasI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) inputs := []banktypes.Input{ {Address: accAddrs[0].String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, } @@ -516,7 +516,7 @@ func (suite *KeeperTestSuite) TestInputOutputCoins() { require.Error(suite.bankKeeper.InputOutputCoins(ctx, insufficientInputs, insufficientOutputs)) - suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[1:3]) + suite.mockInputOutputCoins([]authtypes.AccountAliasI{acc0}, accAddrs[1:3]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) acc1Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) @@ -746,7 +746,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { suite.mockFundAccount(accAddrs[0]) require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100)))) - suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[2:4]) + suite.mockInputOutputCoins([]authtypes.AccountAliasI{acc0}, accAddrs[2:4]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() @@ -771,7 +771,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)))) newCoins2 = sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) - suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[2:4]) + suite.mockInputOutputCoins([]authtypes.AccountAliasI{acc0}, accAddrs[2:4]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() diff --git a/x/bank/keeper/msg_service_test.go b/x/bank/keeper/msg_service_test.go index a6454b6a8531..f6cbc07bb440 100644 --- a/x/bank/keeper/msg_service_test.go +++ b/x/bank/keeper/msg_service_test.go @@ -2,6 +2,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -158,7 +159,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSend() { suite.mockMintCoins(minterAcc) suite.bankKeeper.MintCoins(suite.ctx, minterAcc.Name, origCoins) if !tc.expErr { - suite.mockInputOutputCoins([]sdk.AccountI{minterAcc}, accAddrs[:2]) + suite.mockInputOutputCoins([]authtypes.AccountAliasI{minterAcc}, accAddrs[:2]) } _, err := suite.msgServer.MultiSend(suite.ctx, tc.input) if tc.expErr { diff --git a/x/bank/testutil/expected_keepers_mocks.go b/x/bank/testutil/expected_keepers_mocks.go index 35929b606df5..7f32b6f3a97a 100644 --- a/x/bank/testutil/expected_keepers_mocks.go +++ b/x/bank/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -50,10 +50,10 @@ 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 types.Context) []types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllAccounts", ctx) - ret0, _ := ret[0].([]types.AccountI) + ret0, _ := ret[0].([]types0.AccountAliasI) return ret0 } @@ -150,7 +150,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 types.Context, process func(types0.AccountAliasI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -162,10 +162,10 @@ 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 types.Context, arg1 types0.AccountAliasI) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -176,10 +176,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -190,7 +190,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 types.Context, acc types0.AccountAliasI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 5899d8505f99..1f4944c44997 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -8,15 +8,15 @@ 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(sdk.Context, types.AccountAliasI) types.AccountAliasI + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - GetAllAccounts(ctx sdk.Context) []sdk.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI + GetAllAccounts(ctx sdk.Context) []types.AccountAliasI HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool - SetAccount(ctx sdk.Context, acc sdk.AccountI) + SetAccount(ctx sdk.Context, acc types.AccountAliasI) - IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) bool) + IterateAccounts(ctx sdk.Context, process func(types.AccountAliasI) bool) ValidatePermissions(macc types.ModuleAccountI) error diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index 224e8e73f5d9..c491dc1fa720 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -37,10 +37,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 8526cdb76a4e..9fd365534ce9 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -8,7 +8,7 @@ import ( // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI diff --git a/x/evidence/testutil/expected_keepers_mocks.go b/x/evidence/testutil/expected_keepers_mocks.go index f9021ea468ae..fecb99853df2 100644 --- a/x/evidence/testutil/expected_keepers_mocks.go +++ b/x/evidence/testutil/expected_keepers_mocks.go @@ -10,7 +10,8 @@ import ( types "github.com/cosmos/cosmos-sdk/crypto/types" types0 "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/x/staking/types" + types1 "github.com/cosmos/cosmos-sdk/x/auth/types" + types2 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -38,10 +39,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // GetParams mocks base method. -func (m *MockStakingKeeper) GetParams(ctx types0.Context) types1.Params { +func (m *MockStakingKeeper) GetParams(ctx types0.Context) types2.Params { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetParams", ctx) - ret0, _ := ret[0].(types1.Params) + ret0, _ := ret[0].(types2.Params) return ret0 } @@ -52,10 +53,10 @@ func (mr *MockStakingKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types0.Context, arg1 types0.ConsAddress) types1.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types0.Context, arg1 types0.ConsAddress) types2.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types2.ValidatorI) return ret0 } @@ -182,7 +183,7 @@ func (mr *MockSlashingKeeperMockRecorder) SlashFractionDoubleSign(arg0 interface } // SlashWithInfractionReason mocks base method. -func (m *MockSlashingKeeper) SlashWithInfractionReason(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64, arg5 types1.Infraction) { +func (m *MockSlashingKeeper) SlashWithInfractionReason(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64, arg5 types2.Infraction) { m.ctrl.T.Helper() m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5) } @@ -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 types0.Context, acc types1.AccountAliasI) { 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..3c527d8a2e05 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -5,6 +5,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/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 sdk.Context, acc types.AccountAliasI) } // 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 2be5d9b95841..07d93c5d8f58 100644 --- a/x/feegrant/expected_keepers.go +++ b/x/feegrant/expected_keepers.go @@ -10,9 +10,9 @@ type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, moduleName string) auth.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 sdk.Context, addr sdk.AccAddress) auth.AccountAliasI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountAliasI + SetAccount(ctx sdk.Context, acc auth.AccountAliasI) } // BankKeeper defines the expected supply Keeper (noalias) diff --git a/x/feegrant/testutil/expected_keepers_mocks.go b/x/feegrant/testutil/expected_keepers_mocks.go index 30e7854ef93c..bdadea2a6771 100644 --- a/x/feegrant/testutil/expected_keepers_mocks.go +++ b/x/feegrant/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -78,10 +78,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -92,7 +92,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 types.Context, acc types0.AccountAliasI) { 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 7822c4527b06..76fe89d76904 100644 --- a/x/genutil/testutil/expected_keepers_mocks.go +++ b/x/genutil/testutil/expected_keepers_mocks.go @@ -10,9 +10,10 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" types "github.com/cosmos/cosmos-sdk/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" exported "github.com/cosmos/cosmos-sdk/x/bank/exported" gomock "github.com/golang/mock/gomock" - types0 "github.com/tendermint/tendermint/abci/types" + types1 "github.com/tendermint/tendermint/abci/types" ) // MockStakingKeeper is a mock of StakingKeeper interface. @@ -39,10 +40,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // ApplyAndReturnValidatorSetUpdates mocks base method. -func (m *MockStakingKeeper) ApplyAndReturnValidatorSetUpdates(arg0 types.Context) ([]types0.ValidatorUpdate, error) { +func (m *MockStakingKeeper) ApplyAndReturnValidatorSetUpdates(arg0 types.Context) ([]types1.ValidatorUpdate, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ApplyAndReturnValidatorSetUpdates", arg0) - ret0, _ := ret[0].([]types0.ValidatorUpdate) + ret0, _ := ret[0].([]types1.ValidatorUpdate) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -77,7 +78,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountAliasI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -89,10 +90,10 @@ 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 types.Context, arg1 types0.AccountAliasI) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -103,7 +104,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types.AccountI) { +func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountAliasI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } @@ -138,7 +139,7 @@ func (m *MockGenesisAccountsIterator) EXPECT() *MockGenesisAccountsIteratorMockR } // IterateGenesisAccounts mocks base method. -func (m *MockGenesisAccountsIterator) IterateGenesisAccounts(cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, cb func(types.AccountI) bool) { +func (m *MockGenesisAccountsIterator) IterateGenesisAccounts(cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, cb func(types0.AccountAliasI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateGenesisAccounts", cdc, appGenesis, cb) } diff --git a/x/genutil/types/expected_keepers.go b/x/genutil/types/expected_keepers.go index a55c7a7a0330..8f349d9eae25 100644 --- a/x/genutil/types/expected_keepers.go +++ b/x/genutil/types/expected_keepers.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + auth "github.com/cosmos/cosmos-sdk/x/auth/types" bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported" ) @@ -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(sdk.Context, auth.AccountAliasI) auth.AccountAliasI + SetAccount(sdk.Context, auth.AccountAliasI) + IterateAccounts(ctx sdk.Context, process func(auth.AccountAliasI) (stop bool)) } // GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias) @@ -27,7 +28,7 @@ type GenesisAccountsIterator interface { IterateGenesisAccounts( cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, - cb func(sdk.AccountI) (stop bool), + cb func(auth.AccountAliasI) (stop bool), ) } diff --git a/x/gov/testutil/expected_keepers.go b/x/gov/testutil/expected_keepers.go index 50ace59c6611..59d22d4afc72 100644 --- a/x/gov/testutil/expected_keepers.go +++ b/x/gov/testutil/expected_keepers.go @@ -6,6 +6,7 @@ import ( math "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -15,7 +16,7 @@ import ( type AccountKeeper interface { types.AccountKeeper - IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool)) + IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountAliasI) (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 4c922b5a2182..9d5574691bfe 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -42,10 +42,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -84,7 +84,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 types.Context, cb func(types0.AccountAliasI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, cb) } diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index 1e8a106b34d3..1c0603b482d4 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -30,7 +30,7 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI diff --git a/x/group/expected_keepers.go b/x/group/expected_keepers.go index 31334a3413b7..969492ed1ced 100644 --- a/x/group/expected_keepers.go +++ b/x/group/expected_keepers.go @@ -2,20 +2,21 @@ package group import ( sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/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(sdk.Context, authtypes.AccountAliasI) authtypes.AccountAliasI // GetAccount retrieves an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI + GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountAliasI // SetAccount sets an account in the store. - SetAccount(sdk.Context, sdk.AccountI) + SetAccount(sdk.Context, authtypes.AccountAliasI) // RemoveAccount Remove an account in the store. - RemoveAccount(ctx sdk.Context, acc sdk.AccountI) + RemoveAccount(ctx sdk.Context, acc authtypes.AccountAliasI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index e510cfe06be5..68d9a38ee18a 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -138,7 +138,7 @@ func (s TestSuite) setNextAccount() { //nolint:govet // this is a test and we're s.accountKeeper.EXPECT().GetAccount(gomock.Any(), sdk.AccAddress(accountCredentials.Address())).Return(nil).AnyTimes() s.accountKeeper.EXPECT().NewAccount(gomock.Any(), groupPolicyAcc).Return(groupPolicyAccBumpAccountNumber).AnyTimes() - s.accountKeeper.EXPECT().SetAccount(gomock.Any(), sdk.AccountI(groupPolicyAccBumpAccountNumber)).Return().AnyTimes() + s.accountKeeper.EXPECT().SetAccount(gomock.Any(), authtypes.AccountAliasI(groupPolicyAccBumpAccountNumber)).Return().AnyTimes() } func TestKeeperTestSuite(t *testing.T) { diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index b7b3558666d6..60b6e04579c7 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -14,6 +14,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/auth/tx" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/group/keeper" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -1194,7 +1195,7 @@ func SimulateMsgLeaveGroup(cdc *codec.ProtoCodec, k keeper.Keeper, ak group.Acco func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, ctx sdk.Context, accounts []simtypes.Account, -) (groupInfo *group.GroupInfo, acc simtypes.Account, account sdk.AccountI, err error) { +) (groupInfo *group.GroupInfo, acc simtypes.Account, account authtypes.AccountAliasI, err error) { groupID := k.GetGroupSequence(ctx) switch { @@ -1232,7 +1233,7 @@ func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, ctx sdk.Context, accounts []simtypes.Account, -) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account sdk.AccountI, err error) { +) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account authtypes.AccountAliasI, err error) { groupInfo, _, _, err = randomGroup(r, k, ak, ctx, accounts) if err != nil { return nil, nil, simtypes.Account{}, nil, err @@ -1264,7 +1265,7 @@ func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, func randomMember(ctx context.Context, r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, accounts []simtypes.Account, groupID uint64, -) (acc simtypes.Account, account sdk.AccountI, err error) { +) (acc simtypes.Account, account authtypes.AccountAliasI, err error) { res, err := k.GroupMembers(ctx, &group.QueryGroupMembersRequest{ GroupId: groupID, }) diff --git a/x/group/testutil/expected_keepers_mocks.go b/x/group/testutil/expected_keepers_mocks.go index 8f614b6be1e2..7855096f4cf5 100644 --- a/x/group/testutil/expected_keepers_mocks.go +++ b/x/group/testutil/expected_keepers_mocks.go @@ -9,7 +9,8 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/bank/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" + types1 "github.com/cosmos/cosmos-sdk/x/bank/types" gomock "github.com/golang/mock/gomock" ) @@ -37,10 +38,10 @@ 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 types.Context, arg1 types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", arg0, arg1) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -51,10 +52,10 @@ 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 types.Context, arg1 types0.AccountAliasI) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -65,7 +66,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 types.Context, acc types0.AccountAliasI) { m.ctrl.T.Helper() m.ctrl.Call(m, "RemoveAccount", ctx, acc) } @@ -77,7 +78,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 types.Context, arg1 types0.AccountAliasI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } @@ -140,10 +141,10 @@ func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amt interface{} } // MultiSend mocks base method. -func (m *MockBankKeeper) MultiSend(arg0 context.Context, arg1 *types0.MsgMultiSend) (*types0.MsgMultiSendResponse, error) { +func (m *MockBankKeeper) MultiSend(arg0 context.Context, arg1 *types1.MsgMultiSend) (*types1.MsgMultiSendResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MultiSend", arg0, arg1) - ret0, _ := ret[0].(*types0.MsgMultiSendResponse) + ret0, _ := ret[0].(*types1.MsgMultiSendResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -155,10 +156,10 @@ func (mr *MockBankKeeperMockRecorder) MultiSend(arg0, arg1 interface{}) *gomock. } // Send mocks base method. -func (m *MockBankKeeper) Send(arg0 context.Context, arg1 *types0.MsgSend) (*types0.MsgSendResponse, error) { +func (m *MockBankKeeper) Send(arg0 context.Context, arg1 *types1.MsgSend) (*types1.MsgSendResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Send", arg0, arg1) - ret0, _ := ret[0].(*types0.MsgSendResponse) + ret0, _ := ret[0].(*types1.MsgSendResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -184,10 +185,10 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderMo } // SetSendEnabled mocks base method. -func (m *MockBankKeeper) SetSendEnabled(arg0 context.Context, arg1 *types0.MsgSetSendEnabled) (*types0.MsgSetSendEnabledResponse, error) { +func (m *MockBankKeeper) SetSendEnabled(arg0 context.Context, arg1 *types1.MsgSetSendEnabled) (*types1.MsgSetSendEnabledResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetSendEnabled", arg0, arg1) - ret0, _ := ret[0].(*types0.MsgSetSendEnabledResponse) + ret0, _ := ret[0].(*types1.MsgSetSendEnabledResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -213,10 +214,10 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom } // UpdateParams mocks base method. -func (m *MockBankKeeper) UpdateParams(arg0 context.Context, arg1 *types0.MsgUpdateParams) (*types0.MsgUpdateParamsResponse, error) { +func (m *MockBankKeeper) UpdateParams(arg0 context.Context, arg1 *types1.MsgUpdateParams) (*types1.MsgUpdateParamsResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateParams", arg0, arg1) - ret0, _ := ret[0].(*types0.MsgUpdateParamsResponse) + ret0, _ := ret[0].(*types1.MsgUpdateParamsResponse) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/x/nft/expected_keepers.go b/x/nft/expected_keepers.go index ec7976e294b9..07b1b0c353e4 100644 --- a/x/nft/expected_keepers.go +++ b/x/nft/expected_keepers.go @@ -2,6 +2,7 @@ package nft import ( sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // BankKeeper defines the contract needed to be fulfilled for banking and supply @@ -13,5 +14,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 sdk.Context, addr sdk.AccAddress) authtypes.AccountAliasI } diff --git a/x/nft/testutil/expected_keepers_mocks.go b/x/nft/testutil/expected_keepers_mocks.go index cf85857c6717..33b01327144b 100644 --- a/x/nft/testutil/expected_keepers_mocks.go +++ b/x/nft/testutil/expected_keepers_mocks.go @@ -8,6 +8,7 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -72,10 +73,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } diff --git a/x/simulation/expected_keepers.go b/x/simulation/expected_keepers.go index 346d695f66dc..a9275879803f 100644 --- a/x/simulation/expected_keepers.go +++ b/x/simulation/expected_keepers.go @@ -2,11 +2,12 @@ package simulation import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/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 sdk.Context, addr sdk.AccAddress) types.AccountAliasI } // 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..92abd39e5d69 100644 --- a/x/slashing/testutil/expected_keepers_mocks.go +++ b/x/slashing/testutil/expected_keepers_mocks.go @@ -9,8 +9,9 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/params/types" - types1 "github.com/cosmos/cosmos-sdk/x/staking/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" + types1 "github.com/cosmos/cosmos-sdk/x/params/types" + types2 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -38,10 +39,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -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 types.Context, process func(types0.AccountAliasI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -178,7 +179,7 @@ func (mr *MockParamSubspaceMockRecorder) Get(ctx, key, ptr interface{}) *gomock. } // GetParamSet mocks base method. -func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types0.ParamSet) { +func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types1.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "GetParamSet", ctx, ps) } @@ -204,7 +205,7 @@ func (mr *MockParamSubspaceMockRecorder) HasKeyTable() *gomock.Call { } // SetParamSet mocks base method. -func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types0.ParamSet) { +func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types1.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetParamSet", ctx, ps) } @@ -216,10 +217,10 @@ func (mr *MockParamSubspaceMockRecorder) SetParamSet(ctx, ps interface{}) *gomoc } // WithKeyTable mocks base method. -func (m *MockParamSubspace) WithKeyTable(table types0.KeyTable) types0.Subspace { +func (m *MockParamSubspace) WithKeyTable(table types1.KeyTable) types1.Subspace { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "WithKeyTable", table) - ret0, _ := ret[0].(types0.Subspace) + ret0, _ := ret[0].(types1.Subspace) return ret0 } @@ -253,10 +254,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // Delegation mocks base method. -func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types1.DelegationI { +func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types2.DelegationI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2) - ret0, _ := ret[0].(types1.DelegationI) + ret0, _ := ret[0].(types2.DelegationI) return ret0 } @@ -267,10 +268,10 @@ func (mr *MockStakingKeeperMockRecorder) Delegation(arg0, arg1, arg2 interface{} } // GetAllValidators mocks base method. -func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types1.Validator { +func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types2.Validator { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllValidators", ctx) - ret0, _ := ret[0].([]types1.Validator) + ret0, _ := ret[0].([]types2.Validator) return ret0 } @@ -295,7 +296,7 @@ func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{} } // IterateValidators mocks base method. -func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { +func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types2.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateValidators", arg0, arg1) } @@ -347,7 +348,7 @@ func (mr *MockStakingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 inte } // SlashWithInfractionReason mocks base method. -func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types1.Infraction) math.Int { +func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types2.Infraction) math.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(math.Int) @@ -373,10 +374,10 @@ func (mr *MockStakingKeeperMockRecorder) Unjail(arg0, arg1 interface{}) *gomock. } // Validator mocks base method. -func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types1.ValidatorI { +func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types2.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types2.ValidatorI) return ret0 } @@ -387,10 +388,10 @@ func (mr *MockStakingKeeperMockRecorder) Validator(arg0, arg1 interface{}) *gomo } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types1.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types2.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types2.ValidatorI) return ret0 } diff --git a/x/slashing/types/expected_keepers.go b/x/slashing/types/expected_keepers.go index 3306be791a27..b21b9a076f0a 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -4,14 +4,15 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + auth "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // 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 sdk.Context, addr sdk.AccAddress) auth.AccountAliasI + IterateAccounts(ctx sdk.Context, process func(auth.AccountAliasI) (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 03f8cf96f47d..402857e6e57d 100644 --- a/x/staking/testutil/expected_keepers_mocks.go +++ b/x/staking/testutil/expected_keepers_mocks.go @@ -89,10 +89,10 @@ 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 types.Context, addr types.AccAddress) types0.AccountAliasI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) + ret0, _ := ret[0].(types0.AccountAliasI) return ret0 } @@ -131,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 types.Context, process func(types0.AccountAliasI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index 1c32d6e0b3f2..6ae798848eac 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -15,8 +15,8 @@ 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 sdk.Context, process func(authtypes.AccountAliasI) (stop bool)) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountAliasI // only used for simulation GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI From 34b37b5d1e69b0a21057c03a477cd907a73fe217 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 26 Dec 2022 17:10:06 +0530 Subject: [PATCH 09/21] wip: final changes --- x/auth/types/account.go | 3 +-- x/auth/types/alias.go | 20 +------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/x/auth/types/account.go b/x/auth/types/account.go index ae113a4cfbb7..07e6afc9dc38 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -7,10 +7,9 @@ import ( "fmt" "strings" + "github.com/cosmos/gogoproto/proto" "github.com/tendermint/tendermint/crypto" - proto "github.com/cosmos/gogoproto/proto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/auth/types/alias.go b/x/auth/types/alias.go index d6fe8ae53424..7b2fc7acbb3f 100644 --- a/x/auth/types/alias.go +++ b/x/auth/types/alias.go @@ -1,27 +1,9 @@ package types import ( - proto "github.com/cosmos/gogoproto/proto" - - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) type AccountAliasI interface { - proto.Message - - GetAddress() sdk.AccAddress - SetAddress(sdk.AccAddress) error // errors if already set. - - GetPubKey() cryptotypes.PubKey // can return nil. - SetPubKey(cryptotypes.PubKey) error - - GetAccountNumber() uint64 - SetAccountNumber(uint64) error - - GetSequence() uint64 - SetSequence(uint64) error - - // Ensure that account implements stringer - String() string + sdk.AccountI } From d5ee7ec96bdc07b2426c2dcf212314231e444d3c Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 26 Dec 2022 17:56:32 +0530 Subject: [PATCH 10/21] wip --- simapp/state.go | 2 +- tests/e2e/auth/suite.go | 8 +++---- x/auth/ante/expected_keepers.go | 4 ++-- x/auth/ante/fee.go | 2 +- x/auth/ante/sigverify.go | 2 +- .../ante/testutil/expected_keepers_mocks.go | 6 ++--- x/auth/ante/testutil_test.go | 2 +- x/auth/keeper/account.go | 16 ++++++------- x/auth/keeper/deterministic_test.go | 10 ++++---- x/auth/keeper/genesis.go | 2 +- x/auth/keeper/grpc_query_test.go | 12 +++++----- x/auth/keeper/keeper.go | 24 +++++++++---------- x/auth/keeper/keeper_test.go | 4 ++-- x/auth/keeper/migrations.go | 4 ++-- x/auth/migrations/v2/store.go | 6 ++--- x/auth/migrations/v3/store.go | 2 +- x/auth/module.go | 2 +- x/auth/simulation/decoder.go | 2 +- x/auth/types/account.go | 7 +++--- x/auth/types/account_retriever.go | 4 ++-- x/auth/types/alias.go | 9 ------- x/auth/types/codec.go | 4 ++-- x/auth/types/genesis.go | 4 ++-- x/auth/types/genesis_test.go | 2 +- x/auth/types/query.go | 2 +- x/auth/vesting/exported/exported.go | 2 +- x/auth/vesting/msg_server.go | 2 +- x/auth/vesting/types/codec.go | 2 +- x/auth/vesting/types/vesting_account.go | 2 +- x/authz/expected_keepers.go | 6 ++--- x/authz/testutil/expected_keepers_mocks.go | 10 ++++---- x/bank/keeper/keeper_test.go | 20 ++++++++-------- x/bank/keeper/msg_service_test.go | 2 +- x/bank/testutil/expected_keepers_mocks.go | 20 ++++++++-------- x/bank/types/expected_keepers.go | 12 +++++----- .../testutil/expected_keepers_mocks.go | 4 ++-- x/distribution/types/expected_keepers.go | 2 +- x/evidence/testutil/expected_keepers_mocks.go | 2 +- x/evidence/types/expected_keepers.go | 2 +- x/feegrant/expected_keepers.go | 6 ++--- x/feegrant/testutil/expected_keepers_mocks.go | 10 ++++---- x/genutil/testutil/expected_keepers_mocks.go | 10 ++++---- x/genutil/types/expected_keepers.go | 8 +++---- x/gov/testutil/expected_keepers.go | 2 +- x/gov/testutil/expected_keepers_mocks.go | 6 ++--- x/gov/types/expected_keepers.go | 2 +- x/group/expected_keepers.go | 8 +++---- x/group/keeper/keeper_test.go | 2 +- x/group/simulation/operations.go | 6 ++--- x/group/testutil/expected_keepers_mocks.go | 12 +++++----- x/nft/expected_keepers.go | 2 +- x/nft/testutil/expected_keepers_mocks.go | 4 ++-- x/simulation/expected_keepers.go | 2 +- x/slashing/testutil/expected_keepers_mocks.go | 6 ++--- x/slashing/types/expected_keepers.go | 4 ++-- x/staking/testutil/expected_keepers_mocks.go | 6 ++--- x/staking/types/expected_keepers.go | 4 ++-- 57 files changed, 160 insertions(+), 170 deletions(-) delete mode 100644 x/auth/types/alias.go diff --git a/simapp/state.go b/simapp/state.go index 9669c18cd04e..51fd1d007fcc 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -234,7 +234,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str privKey := secp256k1.GenPrivKeyFromSecret(privkeySeed) - a, ok := acc.GetCachedValue().(authtypes.AccountAliasI) + a, ok := acc.GetCachedValue().(authtypes.AccountI) if !ok { panic("expected account") } diff --git a/tests/e2e/auth/suite.go b/tests/e2e/auth/suite.go index c47ba9a851e4..9d519e4413da 100644 --- a/tests/e2e/auth/suite.go +++ b/tests/e2e/auth/suite.go @@ -397,7 +397,7 @@ func (s *E2ETestSuite) TestCLISignAminoJSON() { // query account info queryResJSON, err := authclitestutil.QueryAccountExec(val1.ClientCtx, val1.Address) require.NoError(err) - var account authtypes.AccountAliasI + var account authtypes.AccountI require.NoError(val1.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) /**** test signature-only ****/ @@ -1327,7 +1327,7 @@ func (s *E2ETestSuite) TestMultisignBatch() { queryResJSON, err := authclitestutil.QueryAccountExec(val.ClientCtx, addr) s.Require().NoError(err) - var account authtypes.AccountAliasI + var account authtypes.AccountI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) // sign-batch file @@ -1398,7 +1398,7 @@ func (s *E2ETestSuite) TestGetAccountCmd() { s.Require().Error(err) s.Require().NotEqual("internal", err.Error()) } else { - var acc authtypes.AccountAliasI + var acc authtypes.AccountI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(out.Bytes(), &acc)) s.Require().Equal(val.Address, acc.GetAddress()) } @@ -1456,7 +1456,7 @@ func (s *E2ETestSuite) TestQueryModuleAccountByNameCmd() { var res authtypes.QueryModuleAccountByNameResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - var account authtypes.AccountAliasI + var account authtypes.AccountI err := val.ClientCtx.InterfaceRegistry.UnpackAny(res.Account, &account) s.Require().NoError(err) diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index d60a0673811a..4dbbbd21c713 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -9,8 +9,8 @@ import ( // 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) types.AccountAliasI - SetAccount(ctx sdk.Context, acc types.AccountAliasI) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + SetAccount(ctx sdk.Context, acc types.AccountI) GetModuleAddress(moduleName string) sdk.AccAddress } diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 0a8031e1b172..80141ef0b5dc 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -122,7 +122,7 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee } // DeductFees deducts fees from the given account. -func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountAliasI, fees sdk.Coins) error { +func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error { if !fees.IsValid() { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 362e704cbf58..e95f7ca37215 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -449,7 +449,7 @@ func ConsumeMultisignatureVerificationGas( // GetSignerAcc returns an account for a given address that is expected to sign // a transaction. -func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (types.AccountAliasI, error) { +func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (types.AccountI, error) { if acc := ak.GetAccount(ctx, addr); acc != nil { return acc, nil } diff --git a/x/auth/ante/testutil/expected_keepers_mocks.go b/x/auth/ante/testutil/expected_keepers_mocks.go index dd2ea42d3206..ff2803af07bf 100644 --- a/x/auth/ante/testutil/expected_keepers_mocks.go +++ b/x/auth/ante/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -78,7 +78,7 @@ func (mr *MockAccountKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountAliasI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.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 04bfc9418255..7fbaf588800e 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -26,7 +26,7 @@ import ( // TestAccount represents an account used in the tests in x/auth/ante. type TestAccount struct { - acc types.AccountAliasI + acc types.AccountI priv cryptotypes.PrivKey } diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index 5e20ff3ef63b..446f0c97774a 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -6,7 +6,7 @@ import ( ) // NewAccountWithAddress implements AccountKeeperI. -func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI { +func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountI { acc := ak.proto() err := acc.SetAddress(addr) if err != nil { @@ -17,7 +17,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 types.AccountAliasI) types.AccountAliasI { +func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc types.AccountI) types.AccountI { if err := acc.SetAccountNumber(ak.NextAccountNumber(ctx)); err != nil { panic(err) } @@ -38,7 +38,7 @@ func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool { } // GetAccount implements AccountKeeperI. -func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI { +func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI { store := ctx.KVStore(ak.storeKey) bz := store.Get(types.AddressStoreKey(addr)) if bz == nil { @@ -59,8 +59,8 @@ 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 []types.AccountAliasI) { - ak.IterateAccounts(ctx, func(acc types.AccountAliasI) (stop bool) { +func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []types.AccountI) { + ak.IterateAccounts(ctx, func(acc types.AccountI) (stop bool) { accounts = append(accounts, acc) return false }) @@ -69,7 +69,7 @@ func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []types.Accoun } // SetAccount implements AccountKeeperI. -func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.AccountAliasI) { +func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.AccountI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) @@ -84,7 +84,7 @@ func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.AccountAliasI) { // 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 types.AccountAliasI) { +func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc types.AccountI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) store.Delete(types.AddressStoreKey(addr)) @@ -93,7 +93,7 @@ func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc types.AccountAliasI) // 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 types.AccountAliasI) (stop bool)) { +func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account types.AccountI) (stop bool)) { store := ctx.KVStore(ak.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix) diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 177769379c3e..829f2073172a 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -77,8 +77,8 @@ func (suite *DeterministicTestSuite) SetupTest() { } // createAndSetAccount creates a random account and sets to the keeper store. -func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []types.AccountAliasI { - accs := make([]types.AccountAliasI, 0, count) +func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []types.AccountI { + accs := make([]types.AccountI, 0, count) // We need all generated account-numbers unique accNums := rapid.SliceOfNDistinct(rapid.Uint64(), count, count, func(i uint64) uint64 { return i }).Draw(t, "acc-numss") @@ -239,12 +239,12 @@ func (suite *DeterministicTestSuite) createAndReturnQueryClient(ak keeper.Accoun func (suite *DeterministicTestSuite) setModuleAccounts( ctx sdk.Context, ak keeper.AccountKeeper, maccs []string, -) []types.AccountAliasI { +) []types.AccountI { sort.Strings(maccs) - moduleAccounts := make([]types.AccountAliasI, 0, len(maccs)) + moduleAccounts := make([]types.AccountI, 0, len(maccs)) for _, m := range maccs { acc, _ := ak.GetModuleAccountAndPermissions(ctx, m) - acc1, ok := acc.(types.AccountAliasI) + acc1, ok := acc.(types.AccountI) suite.Require().True(ok) moduleAccounts = append(moduleAccounts, acc1) } diff --git a/x/auth/keeper/genesis.go b/x/auth/keeper/genesis.go index b7bdd8ff87f8..6e748ef5b44a 100644 --- a/x/auth/keeper/genesis.go +++ b/x/auth/keeper/genesis.go @@ -39,7 +39,7 @@ func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := ak.GetParams(ctx) var genAccounts types.GenesisAccounts - ak.IterateAccounts(ctx, func(account types.AccountAliasI) bool { + ak.IterateAccounts(ctx, func(account types.AccountI) bool { genAccount := account.(types.GenesisAccount) genAccounts = append(genAccounts, genAccount) return false diff --git a/x/auth/keeper/grpc_query_test.go b/x/auth/keeper/grpc_query_test.go index 22d25273353e..1d3854b23e76 100644 --- a/x/auth/keeper/grpc_query_test.go +++ b/x/auth/keeper/grpc_query_test.go @@ -42,7 +42,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccounts() { func(res *types.QueryAccountsResponse) { addresses := make([]sdk.AccAddress, len(res.Accounts)) for i, acc := range res.Accounts { - var account types.AccountAliasI + var account types.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) addresses[i] = account.GetAddress() @@ -123,7 +123,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccount() { }, true, func(res *types.QueryAccountResponse) { - var newAccount types.AccountAliasI + var newAccount types.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &newAccount) suite.Require().NoError(err) suite.Require().NotNil(newAccount) @@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { func(res *types.QueryModuleAccountsResponse) { mintModuleExists := false for _, acc := range res.Accounts { - var account types.AccountAliasI + var account types.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) @@ -303,7 +303,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { func(res *types.QueryModuleAccountsResponse) { mintModuleExists := false for _, acc := range res.Accounts { - var account types.AccountAliasI + var account types.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) @@ -332,7 +332,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { // Make sure output is sorted alphabetically. var moduleNames []string for _, any := range res.Accounts { - var account types.AccountAliasI + var account types.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(any, &account) suite.Require().NoError(err) moduleAccount, ok := account.(types.ModuleAccountI) @@ -366,7 +366,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccountByName() { }, true, func(res *types.QueryModuleAccountByNameResponse) { - var account types.AccountAliasI + var account types.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &account) suite.Require().NoError(err) diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index f477037fb55f..106fd9566584 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -18,25 +18,25 @@ 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) types.AccountAliasI + NewAccountWithAddress(sdk.Context, sdk.AccAddress) types.AccountI // Return a new account with the next account number. Does not save the new account to the store. - NewAccount(sdk.Context, types.AccountAliasI) types.AccountAliasI + NewAccount(sdk.Context, types.AccountI) types.AccountI // Check if an account exists in the store. HasAccount(sdk.Context, sdk.AccAddress) bool // Retrieve an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) types.AccountAliasI + GetAccount(sdk.Context, sdk.AccAddress) types.AccountI // Set an account in the store. - SetAccount(sdk.Context, types.AccountAliasI) + SetAccount(sdk.Context, types.AccountI) // Remove an account from the store. - RemoveAccount(sdk.Context, types.AccountAliasI) + RemoveAccount(sdk.Context, types.AccountI) // Iterate over all accounts, calling the provided function. Stop iteration when it returns true. - IterateAccounts(sdk.Context, func(types.AccountAliasI) bool) + IterateAccounts(sdk.Context, func(types.AccountI) bool) // Fetch the public key of an account at a specified address GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error) @@ -59,7 +59,7 @@ type AccountKeeper struct { permAddrs map[string]types.PermissionsForAddress // The prototypical AccountI constructor. - proto func() types.AccountAliasI + proto func() types.AccountI addressCdc address.Codec // the address capable of executing a MsgUpdateParams message. Typically, this @@ -76,7 +76,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() types.AccountAliasI, + cdc codec.BinaryCodec, storeKey storetypes.StoreKey, proto func() types.AccountI, maccPerms map[string][]string, bech32Prefix string, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) @@ -228,7 +228,7 @@ func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc types.ModuleAccou ak.SetAccount(ctx, macc) } -func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountAliasI { +func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountI { acc, err := ak.UnmarshalAccount(bz) if err != nil { panic(err) @@ -238,14 +238,14 @@ func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountAliasI { } // MarshalAccount protobuf serializes an Account interface -func (ak AccountKeeper) MarshalAccount(accountI types.AccountAliasI) ([]byte, error) { //nolint:interfacer +func (ak AccountKeeper) MarshalAccount(accountI types.AccountI) ([]byte, error) { //nolint:interfacer return ak.cdc.MarshalInterface(accountI) } // UnmarshalAccount returns an Account interface from raw encoded account // bytes of a Proto-based Account type -func (ak AccountKeeper) UnmarshalAccount(bz []byte) (types.AccountAliasI, error) { - var acc types.AccountAliasI +func (ak AccountKeeper) UnmarshalAccount(bz []byte) (types.AccountI, error) { + var acc types.AccountI return acc, ak.cdc.UnmarshalInterface(bz, &acc) } diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 5b93bca1b43e..7448fa5e4df6 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -190,7 +190,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { // Fix duplicate account numbers pubKey1 := ed25519.GenPrivKey().PubKey() pubKey2 := ed25519.GenPrivKey().PubKey() - accts := []types.AccountAliasI{ + accts := []types.AccountI{ &types.BaseAccount{ Address: sdk.AccAddress(pubKey1.Address()).String(), PubKey: codectypes.UnsafePackAny(pubKey1), @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().Equal(len(keeperAccts), len(accts)+1, "number of accounts in the keeper vs in genesis state") for i, genAcct := range accts { genAcctAddr := genAcct.GetAddress() - var keeperAcct types.AccountAliasI + var keeperAcct types.AccountI for _, kacct := range keeperAccts { if genAcctAddr.Equals(kacct.GetAddress()) { keeperAcct = kacct diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index 9a2aaaeaca0f..fc58d2f4e976 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -27,7 +27,7 @@ func NewMigrator(keeper AccountKeeper, queryServer grpc.Server, ss exported.Subs func (m Migrator) Migrate1to2(ctx sdk.Context) error { var iterErr error - m.keeper.IterateAccounts(ctx, func(account types.AccountAliasI) (stop bool) { + m.keeper.IterateAccounts(ctx, func(account types.AccountI) (stop bool) { wb, err := v2.MigrateAccount(ctx, account, m.queryServer) if err != nil { iterErr = err @@ -63,7 +63,7 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { // set the account without map to accAddr to accNumber. // // NOTE: This is used for testing purposes only. -func (m Migrator) V45_SetAccount(ctx sdk.Context, acc types.AccountAliasI) error { //nolint:revive +func (m Migrator) V45_SetAccount(ctx sdk.Context, acc types.AccountI) error { //nolint:revive addr := acc.GetAddress() store := ctx.KVStore(m.keeper.storeKey) diff --git a/x/auth/migrations/v2/store.go b/x/auth/migrations/v2/store.go index b7cd3a97857a..d1b33350bc2b 100644 --- a/x/auth/migrations/v2/store.go +++ b/x/auth/migrations/v2/store.go @@ -46,7 +46,7 @@ const ( // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func migrateVestingAccounts(ctx sdk.Context, account types.AccountAliasI, queryServer grpc.Server) (types.AccountAliasI, error) { +func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer grpc.Server) (types.AccountI, error) { bondDenom, err := getBondDenom(ctx, queryServer) if err != nil { return nil, err @@ -100,7 +100,7 @@ func migrateVestingAccounts(ctx sdk.Context, account types.AccountAliasI, queryS asVesting.TrackDelegation(ctx.BlockTime(), balance, delegations) - return asVesting.(types.AccountAliasI), nil + return asVesting.(types.AccountI), nil } func resetVestingDelegatedBalances(evacct exported.VestingAccount) (exported.VestingAccount, bool) { @@ -290,6 +290,6 @@ func getBondDenom(ctx sdk.Context, queryServer grpc.Server) (string, error) { // // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func MigrateAccount(ctx sdk.Context, account types.AccountAliasI, queryServer grpc.Server) (types.AccountAliasI, error) { +func MigrateAccount(ctx sdk.Context, account types.AccountI, queryServer grpc.Server) (types.AccountI, error) { return migrateVestingAccounts(ctx, account, queryServer) } diff --git a/x/auth/migrations/v3/store.go b/x/auth/migrations/v3/store.go index c638c7cda72e..8e93a87e0bf4 100644 --- a/x/auth/migrations/v3/store.go +++ b/x/auth/migrations/v3/store.go @@ -13,7 +13,7 @@ func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey, defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var acc types.AccountAliasI + var acc types.AccountI if err := cdc.UnmarshalInterface(iterator.Value(), &acc); err != nil { return err } diff --git a/x/auth/module.go b/x/auth/module.go index bdbb06e687c8..6c3c5ba8544a 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -212,7 +212,7 @@ type AuthInputs struct { Cdc codec.Codec RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"` - AccountI func() types.AccountAliasI `optional:"true"` + AccountI func() types.AccountI `optional:"true"` // LegacySubspace is used solely for migration of x/params managed parameters LegacySubspace exported.Subspace `optional:"true"` diff --git a/x/auth/simulation/decoder.go b/x/auth/simulation/decoder.go index d6d74a430db9..4f4f25f07e77 100644 --- a/x/auth/simulation/decoder.go +++ b/x/auth/simulation/decoder.go @@ -13,7 +13,7 @@ import ( ) type AuthUnmarshaler interface { - UnmarshalAccount([]byte) (types.AccountAliasI, error) + UnmarshalAccount([]byte) (types.AccountI, error) GetCodec() codec.BinaryCodec } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 07e6afc9dc38..d7d8eb5c37d8 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -17,7 +17,6 @@ import ( var ( _ sdk.AccountI = (*BaseAccount)(nil) - _ AccountAliasI = (*BaseAccount)(nil) _ GenesisAccount = (*BaseAccount)(nil) _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) _ GenesisAccount = (*ModuleAccount)(nil) @@ -43,7 +42,7 @@ func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNu } // ProtoBaseAccount - a prototype function for BaseAccount -func ProtoBaseAccount() AccountAliasI { +func ProtoBaseAccount() AccountI { return &BaseAccount{} } @@ -298,7 +297,7 @@ type AccountI interface { // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. type ModuleAccountI interface { - AccountAliasI + AccountI GetName() string GetPermissions() []string @@ -322,7 +321,7 @@ func (ga GenesisAccounts) Contains(addr sdk.Address) bool { // GenesisAccount defines a genesis account that embeds an AccountI with validation capabilities. type GenesisAccount interface { - AccountAliasI + AccountI Validate() error } diff --git a/x/auth/types/account_retriever.go b/x/auth/types/account_retriever.go index 7ad53a3686bb..792524fff017 100644 --- a/x/auth/types/account_retriever.go +++ b/x/auth/types/account_retriever.go @@ -14,7 +14,7 @@ import ( ) var ( - _ client.Account = AccountAliasI(nil) + _ client.Account = AccountI(nil) _ client.AccountRetriever = AccountRetriever{} ) @@ -51,7 +51,7 @@ func (ar AccountRetriever) GetAccountWithHeight(clientCtx client.Context, addr s return nil, 0, fmt.Errorf("failed to parse block height: %w", err) } - var acc AccountAliasI + var acc AccountI if err := clientCtx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil { return nil, 0, err } diff --git a/x/auth/types/alias.go b/x/auth/types/alias.go deleted file mode 100644 index 7b2fc7acbb3f..000000000000 --- a/x/auth/types/alias.go +++ /dev/null @@ -1,9 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type AccountAliasI interface { - sdk.AccountI -} diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index d80951acafcc..9182f0ef976c 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -18,7 +18,7 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*ModuleAccountI)(nil), nil) cdc.RegisterInterface((*GenesisAccount)(nil), nil) - cdc.RegisterInterface((*AccountAliasI)(nil), nil) + cdc.RegisterInterface((*AccountI)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil) cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params", nil) @@ -34,7 +34,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterInterface( "cosmos.auth.v1beta1.AccountI", - (*AccountAliasI)(nil), + (*AccountI)(nil), &BaseAccount{}, &ModuleAccount{}, ) diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index 02138cb596b1..82e658d60748 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -148,10 +148,10 @@ type GenesisAccountIterator struct{} // appGenesis and invokes a callback on each genesis account. If any call // returns true, iteration stops. func (GenesisAccountIterator) IterateGenesisAccounts( - cdc codec.Codec, appGenesis map[string]json.RawMessage, cb func(AccountAliasI) (stop bool), + cdc codec.Codec, appGenesis map[string]json.RawMessage, cb func(AccountI) (stop bool), ) { for _, genAcc := range GetGenesisStateFromAppState(cdc, appGenesis).Accounts { - acc, ok := genAcc.GetCachedValue().(AccountAliasI) + acc, ok := genAcc.GetCachedValue().(AccountI) if !ok { panic("expected account") } diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index b935f46a8de1..838a975d9e4a 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -76,7 +76,7 @@ func TestGenesisAccountIterator(t *testing.T) { var addresses []sdk.AccAddress types.GenesisAccountIterator{}.IterateGenesisAccounts( - cdc, appGenesis, func(acc types.AccountAliasI) (stop bool) { + cdc, appGenesis, func(acc types.AccountI) (stop bool) { addresses = append(addresses, acc.GetAddress()) return false }, diff --git a/x/auth/types/query.go b/x/auth/types/query.go index d0c97b50cf67..ce0fa7fe2c44 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -3,7 +3,7 @@ package types import codectypes "github.com/cosmos/cosmos-sdk/codec/types" func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var account AccountAliasI + var account AccountI return unpacker.UnpackAny(m.Account, &account) } diff --git a/x/auth/vesting/exported/exported.go b/x/auth/vesting/exported/exported.go index 8471e2add0b4..835ea59c1c0f 100644 --- a/x/auth/vesting/exported/exported.go +++ b/x/auth/vesting/exported/exported.go @@ -9,7 +9,7 @@ import ( // VestingAccount defines an account type that vests coins via a vesting schedule. type VestingAccount interface { - types.AccountAliasI + types.AccountI // LockedCoins returns the set of coins that are not spendable (i.e. locked), // defined as the vesting coins that are not delegated. diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 5a10219c5a92..2ec28589081c 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -56,7 +56,7 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount) baseVestingAccount := types.NewBaseVestingAccount(baseAccount, msg.Amount.Sort(), msg.EndTime) - var vestingAccount authtypes.AccountAliasI + var vestingAccount authtypes.AccountI if msg.Delayed { vestingAccount = types.NewDelayedVestingAccountRaw(baseVestingAccount) } else { diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 284f2e018462..2dd2c5a8196f 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -41,7 +41,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) registry.RegisterImplementations( - (*authtypes.AccountAliasI)(nil), + (*authtypes.AccountI)(nil), &BaseVestingAccount{}, &DelayedVestingAccount{}, &ContinuousVestingAccount{}, diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 96410a68b0d5..4a1e0e427015 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -13,7 +13,7 @@ import ( // Compile-time type assertions var ( - _ authtypes.AccountAliasI = (*BaseVestingAccount)(nil) + _ authtypes.AccountI = (*BaseVestingAccount)(nil) _ vestexported.VestingAccount = (*ContinuousVestingAccount)(nil) _ vestexported.VestingAccount = (*PeriodicVestingAccount)(nil) _ vestexported.VestingAccount = (*DelayedVestingAccount)(nil) diff --git a/x/authz/expected_keepers.go b/x/authz/expected_keepers.go index f4acac10e25d..186ac955e909 100644 --- a/x/authz/expected_keepers.go +++ b/x/authz/expected_keepers.go @@ -7,9 +7,9 @@ import ( // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountAliasI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountAliasI - SetAccount(ctx sdk.Context, acc authtypes.AccountAliasI) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + SetAccount(ctx sdk.Context, acc authtypes.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 db5f71b67be5..f5bb29a5f8cf 100644 --- a/x/authz/testutil/expected_keepers_mocks.go +++ b/x/authz/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -50,10 +50,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -64,7 +64,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountAliasI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 355125570371..d37e14ac8e83 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -149,7 +149,7 @@ func (suite *KeeperTestSuite) mockSendCoinsFromAccountToModule(acc *authtypes.Ba suite.authKeeper.EXPECT().HasAccount(suite.ctx, moduleAcc.GetAddress()).Return(true) } -func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender authtypes.AccountAliasI, receiver sdk.AccAddress) { +func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender authtypes.AccountI, receiver sdk.AccAddress) { suite.authKeeper.EXPECT().GetAccount(ctx, sender.GetAddress()).Return(sender) suite.authKeeper.EXPECT().HasAccount(ctx, receiver).Return(true) } @@ -159,7 +159,7 @@ func (suite *KeeperTestSuite) mockFundAccount(receiver sdk.AccAddress) { suite.mockSendCoinsFromModuleToAccount(mintAcc, receiver) } -func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountAliasI, outputs []sdk.AccAddress) { +func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountI, outputs []sdk.AccAddress) { for _, input := range inputs { suite.authKeeper.EXPECT().GetAccount(suite.ctx, input.GetAddress()).Return(input) } @@ -168,15 +168,15 @@ func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountAli } } -func (suite *KeeperTestSuite) mockValidateBalance(acc authtypes.AccountAliasI) { +func (suite *KeeperTestSuite) mockValidateBalance(acc authtypes.AccountI) { suite.authKeeper.EXPECT().GetAccount(suite.ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc authtypes.AccountAliasI) { +func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc authtypes.AccountI) { suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.AccountAliasI, mAcc authtypes.AccountAliasI) { +func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.AccountI, mAcc authtypes.AccountI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -185,7 +185,7 @@ func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.A suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) } -func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc authtypes.AccountAliasI, mAcc authtypes.AccountAliasI) { +func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc authtypes.AccountI, mAcc authtypes.AccountI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -466,7 +466,7 @@ func (suite *KeeperTestSuite) TestInputOutputNewAccount() { require.Empty(suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) - suite.mockInputOutputCoins([]authtypes.AccountAliasI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) + suite.mockInputOutputCoins([]authtypes.AccountI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) inputs := []banktypes.Input{ {Address: accAddrs[0].String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, } @@ -516,7 +516,7 @@ func (suite *KeeperTestSuite) TestInputOutputCoins() { require.Error(suite.bankKeeper.InputOutputCoins(ctx, insufficientInputs, insufficientOutputs)) - suite.mockInputOutputCoins([]authtypes.AccountAliasI{acc0}, accAddrs[1:3]) + suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[1:3]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) acc1Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) @@ -746,7 +746,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { suite.mockFundAccount(accAddrs[0]) require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100)))) - suite.mockInputOutputCoins([]authtypes.AccountAliasI{acc0}, accAddrs[2:4]) + suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[2:4]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() @@ -771,7 +771,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)))) newCoins2 = sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) - suite.mockInputOutputCoins([]authtypes.AccountAliasI{acc0}, accAddrs[2:4]) + suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[2:4]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() diff --git a/x/bank/keeper/msg_service_test.go b/x/bank/keeper/msg_service_test.go index f6cbc07bb440..87b5c4b6fcb9 100644 --- a/x/bank/keeper/msg_service_test.go +++ b/x/bank/keeper/msg_service_test.go @@ -159,7 +159,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSend() { suite.mockMintCoins(minterAcc) suite.bankKeeper.MintCoins(suite.ctx, minterAcc.Name, origCoins) if !tc.expErr { - suite.mockInputOutputCoins([]authtypes.AccountAliasI{minterAcc}, accAddrs[:2]) + suite.mockInputOutputCoins([]authtypes.AccountI{minterAcc}, accAddrs[:2]) } _, err := suite.msgServer.MultiSend(suite.ctx, tc.input) if tc.expErr { diff --git a/x/bank/testutil/expected_keepers_mocks.go b/x/bank/testutil/expected_keepers_mocks.go index 7f32b6f3a97a..c27addd028fd 100644 --- a/x/bank/testutil/expected_keepers_mocks.go +++ b/x/bank/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -50,10 +50,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetAllAccounts mocks base method. -func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types0.AccountAliasI { +func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllAccounts", ctx) - ret0, _ := ret[0].([]types0.AccountAliasI) + ret0, _ := ret[0].([]types0.AccountI) return ret0 } @@ -150,7 +150,7 @@ func (mr *MockAccountKeeperMockRecorder) HasAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountAliasI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -162,10 +162,10 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountAliasI) types0.AccountAliasI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -176,10 +176,10 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -190,7 +190,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountAliasI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 1f4944c44997..191d6b5a836a 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -8,15 +8,15 @@ import ( // AccountKeeper defines the account contract that must be fulfilled when // creating a x/bank keeper. type AccountKeeper interface { - NewAccount(sdk.Context, types.AccountAliasI) types.AccountAliasI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI + NewAccount(sdk.Context, types.AccountI) types.AccountI + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI - GetAllAccounts(ctx sdk.Context) []types.AccountAliasI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetAllAccounts(ctx sdk.Context) []types.AccountI HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool - SetAccount(ctx sdk.Context, acc types.AccountAliasI) + SetAccount(ctx sdk.Context, acc types.AccountI) - IterateAccounts(ctx sdk.Context, process func(types.AccountAliasI) bool) + IterateAccounts(ctx sdk.Context, process func(types.AccountI) bool) ValidatePermissions(macc types.ModuleAccountI) error diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index c491dc1fa720..585d2cb57792 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -37,10 +37,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 9fd365534ce9..94cea333ab06 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -8,7 +8,7 @@ import ( // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI diff --git a/x/evidence/testutil/expected_keepers_mocks.go b/x/evidence/testutil/expected_keepers_mocks.go index fecb99853df2..16478b7908be 100644 --- a/x/evidence/testutil/expected_keepers_mocks.go +++ b/x/evidence/testutil/expected_keepers_mocks.go @@ -230,7 +230,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types0.Context, acc types1.AccountAliasI) { +func (m *MockAccountKeeper) SetAccount(ctx types0.Context, acc types1.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 3c527d8a2e05..8bb2a7f79b10 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -33,7 +33,7 @@ type ( // AccountKeeper define the account keeper interface contracted needed by the evidence module AccountKeeper interface { - SetAccount(ctx sdk.Context, acc types.AccountAliasI) + SetAccount(ctx sdk.Context, acc types.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 07d93c5d8f58..eb5d4bf04465 100644 --- a/x/feegrant/expected_keepers.go +++ b/x/feegrant/expected_keepers.go @@ -10,9 +10,9 @@ type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, moduleName string) auth.ModuleAccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.AccountAliasI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountAliasI - SetAccount(ctx sdk.Context, acc auth.AccountAliasI) + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI + SetAccount(ctx sdk.Context, acc auth.AccountI) } // BankKeeper defines the expected supply Keeper (noalias) diff --git a/x/feegrant/testutil/expected_keepers_mocks.go b/x/feegrant/testutil/expected_keepers_mocks.go index bdadea2a6771..c00c4b0d71fc 100644 --- a/x/feegrant/testutil/expected_keepers_mocks.go +++ b/x/feegrant/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -78,10 +78,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{} } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -92,7 +92,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountAliasI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.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 76fe89d76904..f51fa2eb2733 100644 --- a/x/genutil/testutil/expected_keepers_mocks.go +++ b/x/genutil/testutil/expected_keepers_mocks.go @@ -78,7 +78,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountAliasI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -90,10 +90,10 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountAliasI) types0.AccountAliasI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -104,7 +104,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountAliasI) { +func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } @@ -139,7 +139,7 @@ func (m *MockGenesisAccountsIterator) EXPECT() *MockGenesisAccountsIteratorMockR } // IterateGenesisAccounts mocks base method. -func (m *MockGenesisAccountsIterator) IterateGenesisAccounts(cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, cb func(types0.AccountAliasI) bool) { +func (m *MockGenesisAccountsIterator) IterateGenesisAccounts(cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, cb func(types0.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateGenesisAccounts", cdc, appGenesis, cb) } diff --git a/x/genutil/types/expected_keepers.go b/x/genutil/types/expected_keepers.go index 8f349d9eae25..854422a3c990 100644 --- a/x/genutil/types/expected_keepers.go +++ b/x/genutil/types/expected_keepers.go @@ -18,9 +18,9 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - NewAccount(sdk.Context, auth.AccountAliasI) auth.AccountAliasI - SetAccount(sdk.Context, auth.AccountAliasI) - IterateAccounts(ctx sdk.Context, process func(auth.AccountAliasI) (stop bool)) + NewAccount(sdk.Context, auth.AccountI) auth.AccountI + SetAccount(sdk.Context, auth.AccountI) + IterateAccounts(ctx sdk.Context, process func(auth.AccountI) (stop bool)) } // GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias) @@ -28,7 +28,7 @@ type GenesisAccountsIterator interface { IterateGenesisAccounts( cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, - cb func(auth.AccountAliasI) (stop bool), + cb func(auth.AccountI) (stop bool), ) } diff --git a/x/gov/testutil/expected_keepers.go b/x/gov/testutil/expected_keepers.go index 59d22d4afc72..669dbc010b2d 100644 --- a/x/gov/testutil/expected_keepers.go +++ b/x/gov/testutil/expected_keepers.go @@ -16,7 +16,7 @@ import ( type AccountKeeper interface { types.AccountKeeper - IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountAliasI) (stop bool)) + IterateAccounts(ctx sdk.Context, cb func(account authtypes.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 9d5574691bfe..e119ee2bf6e9 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -42,10 +42,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -84,7 +84,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, cb func(types0.AccountAliasI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, cb func(types0.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, cb) } diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index 1c0603b482d4..b486e5daf91f 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -30,7 +30,7 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI diff --git a/x/group/expected_keepers.go b/x/group/expected_keepers.go index 969492ed1ced..f8677fc3c26c 100644 --- a/x/group/expected_keepers.go +++ b/x/group/expected_keepers.go @@ -7,16 +7,16 @@ import ( 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, authtypes.AccountAliasI) authtypes.AccountAliasI + NewAccount(sdk.Context, authtypes.AccountI) authtypes.AccountI // GetAccount retrieves an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountAliasI + GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountI // SetAccount sets an account in the store. - SetAccount(sdk.Context, authtypes.AccountAliasI) + SetAccount(sdk.Context, authtypes.AccountI) // RemoveAccount Remove an account in the store. - RemoveAccount(ctx sdk.Context, acc authtypes.AccountAliasI) + RemoveAccount(ctx sdk.Context, acc authtypes.AccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 68d9a38ee18a..2c4cb9184935 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -138,7 +138,7 @@ func (s TestSuite) setNextAccount() { //nolint:govet // this is a test and we're s.accountKeeper.EXPECT().GetAccount(gomock.Any(), sdk.AccAddress(accountCredentials.Address())).Return(nil).AnyTimes() s.accountKeeper.EXPECT().NewAccount(gomock.Any(), groupPolicyAcc).Return(groupPolicyAccBumpAccountNumber).AnyTimes() - s.accountKeeper.EXPECT().SetAccount(gomock.Any(), authtypes.AccountAliasI(groupPolicyAccBumpAccountNumber)).Return().AnyTimes() + s.accountKeeper.EXPECT().SetAccount(gomock.Any(), authtypes.AccountI(groupPolicyAccBumpAccountNumber)).Return().AnyTimes() } func TestKeeperTestSuite(t *testing.T) { diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 60b6e04579c7..5c4eccffec3f 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -1195,7 +1195,7 @@ func SimulateMsgLeaveGroup(cdc *codec.ProtoCodec, k keeper.Keeper, ak group.Acco func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, ctx sdk.Context, accounts []simtypes.Account, -) (groupInfo *group.GroupInfo, acc simtypes.Account, account authtypes.AccountAliasI, err error) { +) (groupInfo *group.GroupInfo, acc simtypes.Account, account authtypes.AccountI, err error) { groupID := k.GetGroupSequence(ctx) switch { @@ -1233,7 +1233,7 @@ func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, ctx sdk.Context, accounts []simtypes.Account, -) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account authtypes.AccountAliasI, err error) { +) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account authtypes.AccountI, err error) { groupInfo, _, _, err = randomGroup(r, k, ak, ctx, accounts) if err != nil { return nil, nil, simtypes.Account{}, nil, err @@ -1265,7 +1265,7 @@ func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, func randomMember(ctx context.Context, r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, accounts []simtypes.Account, groupID uint64, -) (acc simtypes.Account, account authtypes.AccountAliasI, err error) { +) (acc simtypes.Account, account authtypes.AccountI, err error) { res, err := k.GroupMembers(ctx, &group.QueryGroupMembersRequest{ GroupId: groupID, }) diff --git a/x/group/testutil/expected_keepers_mocks.go b/x/group/testutil/expected_keepers_mocks.go index 7855096f4cf5..2e51cfad5476 100644 --- a/x/group/testutil/expected_keepers_mocks.go +++ b/x/group/testutil/expected_keepers_mocks.go @@ -38,10 +38,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(arg0 types.Context, arg1 types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(arg0 types.Context, arg1 types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -52,10 +52,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(arg0, arg1 interface{}) *gom } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountAliasI) types0.AccountAliasI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -66,7 +66,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // RemoveAccount mocks base method. -func (m *MockAccountKeeper) RemoveAccount(ctx types.Context, acc types0.AccountAliasI) { +func (m *MockAccountKeeper) RemoveAccount(ctx types.Context, acc types0.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "RemoveAccount", ctx, acc) } @@ -78,7 +78,7 @@ func (mr *MockAccountKeeperMockRecorder) RemoveAccount(ctx, acc interface{}) *go } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountAliasI) { +func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } diff --git a/x/nft/expected_keepers.go b/x/nft/expected_keepers.go index 07b1b0c353e4..0e0f1efd6e45 100644 --- a/x/nft/expected_keepers.go +++ b/x/nft/expected_keepers.go @@ -14,5 +14,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) authtypes.AccountAliasI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI } diff --git a/x/nft/testutil/expected_keepers_mocks.go b/x/nft/testutil/expected_keepers_mocks.go index 33b01327144b..49d193397ee2 100644 --- a/x/nft/testutil/expected_keepers_mocks.go +++ b/x/nft/testutil/expected_keepers_mocks.go @@ -73,10 +73,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } diff --git a/x/simulation/expected_keepers.go b/x/simulation/expected_keepers.go index a9275879803f..c54831b8a401 100644 --- a/x/simulation/expected_keepers.go +++ b/x/simulation/expected_keepers.go @@ -7,7 +7,7 @@ import ( // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountAliasI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.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 92abd39e5d69..86d57c5e2d68 100644 --- a/x/slashing/testutil/expected_keepers_mocks.go +++ b/x/slashing/testutil/expected_keepers_mocks.go @@ -39,10 +39,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -53,7 +53,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountAliasI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.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 b21b9a076f0a..569a26b546d5 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -11,8 +11,8 @@ import ( // AccountKeeper expected account keeper type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountAliasI - IterateAccounts(ctx sdk.Context, process func(auth.AccountAliasI) (stop bool)) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI + IterateAccounts(ctx sdk.Context, process func(auth.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 402857e6e57d..375c6ff3c729 100644 --- a/x/staking/testutil/expected_keepers_mocks.go +++ b/x/staking/testutil/expected_keepers_mocks.go @@ -89,10 +89,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountAliasI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountAliasI) + ret0, _ := ret[0].(types0.AccountI) return ret0 } @@ -131,7 +131,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountAliasI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index 6ae798848eac..05672ee256da 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -15,8 +15,8 @@ type DistributionKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - IterateAccounts(ctx sdk.Context, process func(authtypes.AccountAliasI) (stop bool)) - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountAliasI // only used for simulation + IterateAccounts(ctx sdk.Context, process func(authtypes.AccountI) (stop bool)) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI // only used for simulation GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI From f58f055a039ff021c8cc78214b846a9869138c94 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 26 Dec 2022 18:04:12 +0530 Subject: [PATCH 11/21] add nit --- x/auth/types/account.go | 2 +- x/auth/types/genesis_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/x/auth/types/account.go b/x/auth/types/account.go index d7d8eb5c37d8..ecb8118a8898 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -274,7 +274,7 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { // // Many complex conditions can be used in the concrete struct which implements AccountI. // -// Deprecated +// Deprecated: Use `AccountI` from types package instead. type AccountI interface { proto.Message diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index 838a975d9e4a..05faa8723125 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" From 326cd30027e3a953f94543aa869b0a8cb07e4bbc Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 27 Dec 2022 13:11:41 +0530 Subject: [PATCH 12/21] wip --- x/auth/ante/expected_keepers.go | 4 +- x/auth/ante/fee.go | 2 +- x/auth/ante/sigverify.go | 2 +- .../ante/testutil/expected_keepers_mocks.go | 6 +-- x/auth/keeper/account.go | 16 ++++---- x/auth/keeper/genesis.go | 2 +- x/auth/keeper/keeper.go | 24 ++++++------ x/auth/keeper/migrations.go | 4 +- x/auth/migrations/v2/store.go | 7 ++-- x/auth/migrations/v3/store.go | 2 +- x/auth/module.go | 2 +- x/auth/simulation/decoder.go | 2 +- x/auth/types/account.go | 25 +++--------- x/auth/types/account_retriever.go | 4 +- x/auth/types/codec.go | 4 +- x/auth/types/genesis.go | 5 ++- x/auth/types/genesis_test.go | 2 +- x/auth/types/query.go | 7 +++- x/auth/vesting/exported/exported.go | 3 +- x/auth/vesting/msg_server.go | 2 +- x/auth/vesting/types/codec.go | 2 +- x/auth/vesting/types/vesting_account.go | 2 +- x/authz/expected_keepers.go | 7 ++-- x/authz/testutil/expected_keepers_mocks.go | 11 +++--- x/bank/testutil/expected_keepers_mocks.go | 20 +++++----- x/bank/types/expected_keepers.go | 12 +++--- .../testutil/expected_keepers_mocks.go | 4 +- x/distribution/types/expected_keepers.go | 2 +- x/evidence/testutil/expected_keepers_mocks.go | 15 ++++--- x/evidence/types/expected_keepers.go | 3 +- x/feegrant/expected_keepers.go | 6 +-- x/feegrant/testutil/expected_keepers_mocks.go | 10 ++--- x/genutil/testutil/expected_keepers_mocks.go | 17 ++++---- x/genutil/types/expected_keepers.go | 9 ++--- x/gov/testutil/expected_keepers.go | 3 +- x/gov/testutil/expected_keepers_mocks.go | 6 +-- x/gov/types/expected_keepers.go | 2 +- x/group/expected_keepers.go | 9 ++--- x/group/simulation/operations.go | 7 ++-- x/group/testutil/expected_keepers_mocks.go | 31 +++++++-------- x/nft/expected_keepers.go | 3 +- x/nft/testutil/expected_keepers_mocks.go | 5 +-- x/simulation/expected_keepers.go | 3 +- x/slashing/testutil/expected_keepers_mocks.go | 39 +++++++++---------- x/slashing/types/expected_keepers.go | 5 +-- x/staking/testutil/expected_keepers_mocks.go | 6 +-- x/staking/types/expected_keepers.go | 4 +- 47 files changed, 170 insertions(+), 198 deletions(-) diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 4dbbbd21c713..1db0dff716c1 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -9,8 +9,8 @@ import ( // 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) types.AccountI - SetAccount(ctx sdk.Context, acc types.AccountI) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + SetAccount(ctx sdk.Context, acc sdk.AccountI) GetModuleAddress(moduleName string) sdk.AccAddress } diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 80141ef0b5dc..20cace9403ab 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -122,7 +122,7 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee } // DeductFees deducts fees from the given account. -func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error { +func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc sdk.AccountI, fees sdk.Coins) error { if !fees.IsValid() { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index e95f7ca37215..9db289b3d81a 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -449,7 +449,7 @@ func ConsumeMultisignatureVerificationGas( // GetSignerAcc returns an account for a given address that is expected to sign // a transaction. -func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (types.AccountI, error) { +func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (sdk.AccountI, error) { if acc := ak.GetAccount(ctx, addr); acc != nil { return acc, nil } diff --git a/x/auth/ante/testutil/expected_keepers_mocks.go b/x/auth/ante/testutil/expected_keepers_mocks.go index ff2803af07bf..34c7c68e4ef8 100644 --- a/x/auth/ante/testutil/expected_keepers_mocks.go +++ b/x/auth/ante/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -78,7 +78,7 @@ func (mr *MockAccountKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index 446f0c97774a..f6f8613de369 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -6,7 +6,7 @@ import ( ) // NewAccountWithAddress implements AccountKeeperI. -func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountI { +func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { acc := ak.proto() err := acc.SetAddress(addr) if err != nil { @@ -17,7 +17,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 types.AccountI) types.AccountI { +func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc sdk.AccountI) sdk.AccountI { if err := acc.SetAccountNumber(ak.NextAccountNumber(ctx)); err != nil { panic(err) } @@ -38,7 +38,7 @@ func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool { } // GetAccount implements AccountKeeperI. -func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI { +func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI { store := ctx.KVStore(ak.storeKey) bz := store.Get(types.AddressStoreKey(addr)) if bz == nil { @@ -59,8 +59,8 @@ 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 []types.AccountI) { - ak.IterateAccounts(ctx, func(acc types.AccountI) (stop bool) { +func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []sdk.AccountI) { + ak.IterateAccounts(ctx, func(acc sdk.AccountI) (stop bool) { accounts = append(accounts, acc) return false }) @@ -69,7 +69,7 @@ func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []types.Accoun } // SetAccount implements AccountKeeperI. -func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.AccountI) { +func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc sdk.AccountI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) @@ -84,7 +84,7 @@ func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.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 types.AccountI) { +func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc sdk.AccountI) { addr := acc.GetAddress() store := ctx.KVStore(ak.storeKey) store.Delete(types.AddressStoreKey(addr)) @@ -93,7 +93,7 @@ func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc types.AccountI) { // 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 types.AccountI) (stop bool)) { +func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool)) { store := ctx.KVStore(ak.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix) diff --git a/x/auth/keeper/genesis.go b/x/auth/keeper/genesis.go index 6e748ef5b44a..ad830ef54e21 100644 --- a/x/auth/keeper/genesis.go +++ b/x/auth/keeper/genesis.go @@ -39,7 +39,7 @@ func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := ak.GetParams(ctx) var genAccounts types.GenesisAccounts - ak.IterateAccounts(ctx, func(account types.AccountI) bool { + ak.IterateAccounts(ctx, func(account sdk.AccountI) bool { genAccount := account.(types.GenesisAccount) genAccounts = append(genAccounts, genAccount) return false diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 106fd9566584..934c3fdbf9de 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -18,25 +18,25 @@ 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) types.AccountI + NewAccountWithAddress(sdk.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, types.AccountI) types.AccountI + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI // Check if an account exists in the store. HasAccount(sdk.Context, sdk.AccAddress) bool // Retrieve an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) types.AccountI + GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI // Set an account in the store. - SetAccount(sdk.Context, types.AccountI) + SetAccount(sdk.Context, sdk.AccountI) // Remove an account from the store. - RemoveAccount(sdk.Context, types.AccountI) + RemoveAccount(sdk.Context, sdk.AccountI) // Iterate over all accounts, calling the provided function. Stop iteration when it returns true. - IterateAccounts(sdk.Context, func(types.AccountI) bool) + IterateAccounts(sdk.Context, func(sdk.AccountI) bool) // Fetch the public key of an account at a specified address GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error) @@ -59,7 +59,7 @@ type AccountKeeper struct { permAddrs map[string]types.PermissionsForAddress // The prototypical AccountI constructor. - proto func() types.AccountI + proto func() sdk.AccountI addressCdc address.Codec // the address capable of executing a MsgUpdateParams message. Typically, this @@ -76,7 +76,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() types.AccountI, + cdc codec.BinaryCodec, storeKey storetypes.StoreKey, proto func() sdk.AccountI, maccPerms map[string][]string, bech32Prefix string, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) @@ -228,7 +228,7 @@ func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc types.ModuleAccou ak.SetAccount(ctx, macc) } -func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountI { +func (ak AccountKeeper) decodeAccount(bz []byte) sdk.AccountI { acc, err := ak.UnmarshalAccount(bz) if err != nil { panic(err) @@ -238,14 +238,14 @@ func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountI { } // MarshalAccount protobuf serializes an Account interface -func (ak AccountKeeper) MarshalAccount(accountI types.AccountI) ([]byte, error) { //nolint:interfacer +func (ak AccountKeeper) MarshalAccount(accountI sdk.AccountI) ([]byte, error) { //nolint:interfacer return ak.cdc.MarshalInterface(accountI) } // UnmarshalAccount returns an Account interface from raw encoded account // bytes of a Proto-based Account type -func (ak AccountKeeper) UnmarshalAccount(bz []byte) (types.AccountI, error) { - var acc types.AccountI +func (ak AccountKeeper) UnmarshalAccount(bz []byte) (sdk.AccountI, error) { + var acc sdk.AccountI return acc, ak.cdc.UnmarshalInterface(bz, &acc) } diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index fc58d2f4e976..ec2f49512b33 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -27,7 +27,7 @@ func NewMigrator(keeper AccountKeeper, queryServer grpc.Server, ss exported.Subs func (m Migrator) Migrate1to2(ctx sdk.Context) error { var iterErr error - m.keeper.IterateAccounts(ctx, func(account types.AccountI) (stop bool) { + m.keeper.IterateAccounts(ctx, func(account sdk.AccountI) (stop bool) { wb, err := v2.MigrateAccount(ctx, account, m.queryServer) if err != nil { iterErr = err @@ -63,7 +63,7 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { // set the account without map to accAddr to accNumber. // // NOTE: This is used for testing purposes only. -func (m Migrator) V45_SetAccount(ctx sdk.Context, acc types.AccountI) error { //nolint:revive +func (m Migrator) V45_SetAccount(ctx sdk.Context, acc sdk.AccountI) error { //nolint:revive addr := acc.GetAddress() store := ctx.KVStore(m.keeper.storeKey) diff --git a/x/auth/migrations/v2/store.go b/x/auth/migrations/v2/store.go index d1b33350bc2b..abebf9afb052 100644 --- a/x/auth/migrations/v2/store.go +++ b/x/auth/migrations/v2/store.go @@ -30,7 +30,6 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -46,7 +45,7 @@ const ( // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer grpc.Server) (types.AccountI, error) { +func migrateVestingAccounts(ctx sdk.Context, account sdk.AccountI, queryServer grpc.Server) (sdk.AccountI, error) { bondDenom, err := getBondDenom(ctx, queryServer) if err != nil { return nil, err @@ -100,7 +99,7 @@ func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer asVesting.TrackDelegation(ctx.BlockTime(), balance, delegations) - return asVesting.(types.AccountI), nil + return asVesting.(sdk.AccountI), nil } func resetVestingDelegatedBalances(evacct exported.VestingAccount) (exported.VestingAccount, bool) { @@ -290,6 +289,6 @@ func getBondDenom(ctx sdk.Context, queryServer grpc.Server) (string, error) { // // We use the baseapp.QueryRouter here to do inter-module state querying. // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. -func MigrateAccount(ctx sdk.Context, account types.AccountI, queryServer grpc.Server) (types.AccountI, error) { +func MigrateAccount(ctx sdk.Context, account sdk.AccountI, queryServer grpc.Server) (sdk.AccountI, error) { return migrateVestingAccounts(ctx, account, queryServer) } diff --git a/x/auth/migrations/v3/store.go b/x/auth/migrations/v3/store.go index 8e93a87e0bf4..b8b87646d223 100644 --- a/x/auth/migrations/v3/store.go +++ b/x/auth/migrations/v3/store.go @@ -13,7 +13,7 @@ func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey, defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var acc types.AccountI + var acc sdk.AccountI if err := cdc.UnmarshalInterface(iterator.Value(), &acc); err != nil { return err } diff --git a/x/auth/module.go b/x/auth/module.go index 6c3c5ba8544a..26e54997177f 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -212,7 +212,7 @@ type AuthInputs struct { Cdc codec.Codec RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"` - AccountI func() types.AccountI `optional:"true"` + AccountI func() sdk.AccountI `optional:"true"` // LegacySubspace is used solely for migration of x/params managed parameters LegacySubspace exported.Subspace `optional:"true"` diff --git a/x/auth/simulation/decoder.go b/x/auth/simulation/decoder.go index 4f4f25f07e77..4d32123e416d 100644 --- a/x/auth/simulation/decoder.go +++ b/x/auth/simulation/decoder.go @@ -13,7 +13,7 @@ import ( ) type AuthUnmarshaler interface { - UnmarshalAccount([]byte) (types.AccountI, error) + UnmarshalAccount([]byte) (sdk.AccountI, error) GetCodec() codec.BinaryCodec } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index ecb8118a8898..895248699460 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -7,11 +7,11 @@ import ( "fmt" "strings" - "github.com/cosmos/gogoproto/proto" "github.com/tendermint/tendermint/crypto" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -42,7 +42,7 @@ func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNu } // ProtoBaseAccount - a prototype function for BaseAccount -func ProtoBaseAccount() AccountI { +func ProtoBaseAccount() sdk.AccountI { return &BaseAccount{} } @@ -276,28 +276,13 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { // // Deprecated: Use `AccountI` from types package instead. type AccountI interface { - proto.Message - - GetAddress() sdk.AccAddress - SetAddress(sdk.AccAddress) error // errors if already set. - - GetPubKey() cryptotypes.PubKey // can return nil. - SetPubKey(cryptotypes.PubKey) error - - GetAccountNumber() uint64 - SetAccountNumber(uint64) error - - GetSequence() uint64 - SetSequence(uint64) error - - // Ensure that account implements stringer - String() string + types.AccountI } // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. type ModuleAccountI interface { - AccountI + types.AccountI GetName() string GetPermissions() []string @@ -321,7 +306,7 @@ func (ga GenesisAccounts) Contains(addr sdk.Address) bool { // GenesisAccount defines a genesis account that embeds an AccountI with validation capabilities. type GenesisAccount interface { - AccountI + types.AccountI Validate() error } diff --git a/x/auth/types/account_retriever.go b/x/auth/types/account_retriever.go index 792524fff017..7727607e8d28 100644 --- a/x/auth/types/account_retriever.go +++ b/x/auth/types/account_retriever.go @@ -14,7 +14,7 @@ import ( ) var ( - _ client.Account = AccountI(nil) + _ client.Account = sdk.AccountI(nil) _ client.AccountRetriever = AccountRetriever{} ) @@ -51,7 +51,7 @@ func (ar AccountRetriever) GetAccountWithHeight(clientCtx client.Context, addr s return nil, 0, fmt.Errorf("failed to parse block height: %w", err) } - var acc AccountI + var acc sdk.AccountI if err := clientCtx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil { return nil, 0, err } diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index 9182f0ef976c..d18d1c38b2e6 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -18,7 +18,7 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*ModuleAccountI)(nil), nil) cdc.RegisterInterface((*GenesisAccount)(nil), nil) - cdc.RegisterInterface((*AccountI)(nil), nil) + cdc.RegisterInterface((*sdk.AccountI)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil) cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params", nil) @@ -34,7 +34,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterInterface( "cosmos.auth.v1beta1.AccountI", - (*AccountI)(nil), + (*sdk.AccountI)(nil), &BaseAccount{}, &ModuleAccount{}, ) diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index 82e658d60748..b3a66869da83 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -148,10 +149,10 @@ type GenesisAccountIterator struct{} // appGenesis and invokes a callback on each genesis account. If any call // returns true, iteration stops. func (GenesisAccountIterator) IterateGenesisAccounts( - cdc codec.Codec, appGenesis map[string]json.RawMessage, cb func(AccountI) (stop bool), + cdc codec.Codec, appGenesis map[string]json.RawMessage, cb func(sdk.AccountI) (stop bool), ) { for _, genAcc := range GetGenesisStateFromAppState(cdc, appGenesis).Accounts { - acc, ok := genAcc.GetCachedValue().(AccountI) + acc, ok := genAcc.GetCachedValue().(sdk.AccountI) if !ok { panic("expected account") } diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index 05faa8723125..99931a3a99d0 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -75,7 +75,7 @@ func TestGenesisAccountIterator(t *testing.T) { var addresses []sdk.AccAddress types.GenesisAccountIterator{}.IterateGenesisAccounts( - cdc, appGenesis, func(acc types.AccountI) (stop bool) { + cdc, appGenesis, func(acc sdk.AccountI) (stop bool) { addresses = append(addresses, acc.GetAddress()) return false }, diff --git a/x/auth/types/query.go b/x/auth/types/query.go index ce0fa7fe2c44..8ab9df38f9f0 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,9 +1,12 @@ package types -import codectypes "github.com/cosmos/cosmos-sdk/codec/types" +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var account AccountI + var account sdk.AccountI return unpacker.UnpackAny(m.Account, &account) } diff --git a/x/auth/vesting/exported/exported.go b/x/auth/vesting/exported/exported.go index 835ea59c1c0f..bfc15f7175cb 100644 --- a/x/auth/vesting/exported/exported.go +++ b/x/auth/vesting/exported/exported.go @@ -4,12 +4,11 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" ) // VestingAccount defines an account type that vests coins via a vesting schedule. type VestingAccount interface { - types.AccountI + sdk.AccountI // LockedCoins returns the set of coins that are not spendable (i.e. locked), // defined as the vesting coins that are not delegated. diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 2ec28589081c..eb9f2497fe97 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -56,7 +56,7 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount) baseVestingAccount := types.NewBaseVestingAccount(baseAccount, msg.Amount.Sort(), msg.EndTime) - var vestingAccount authtypes.AccountI + var vestingAccount sdk.AccountI if msg.Delayed { vestingAccount = types.NewDelayedVestingAccountRaw(baseVestingAccount) } else { diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 2dd2c5a8196f..9a95ccf62a1e 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -41,7 +41,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) registry.RegisterImplementations( - (*authtypes.AccountI)(nil), + (*sdk.AccountI)(nil), &BaseVestingAccount{}, &DelayedVestingAccount{}, &ContinuousVestingAccount{}, diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 4a1e0e427015..26a95d84d9d0 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -13,7 +13,7 @@ import ( // Compile-time type assertions var ( - _ authtypes.AccountI = (*BaseVestingAccount)(nil) + _ sdk.AccountI = (*BaseVestingAccount)(nil) _ vestexported.VestingAccount = (*ContinuousVestingAccount)(nil) _ vestexported.VestingAccount = (*PeriodicVestingAccount)(nil) _ vestexported.VestingAccount = (*DelayedVestingAccount)(nil) diff --git a/x/authz/expected_keepers.go b/x/authz/expected_keepers.go index 186ac955e909..812daa518f52 100644 --- a/x/authz/expected_keepers.go +++ b/x/authz/expected_keepers.go @@ -2,14 +2,13 @@ package authz import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - SetAccount(ctx sdk.Context, acc authtypes.AccountI) + 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) } // 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 f5bb29a5f8cf..82cb5c48d460 100644 --- a/x/authz/testutil/expected_keepers_mocks.go +++ b/x/authz/testutil/expected_keepers_mocks.go @@ -8,7 +8,6 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -36,10 +35,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -50,10 +49,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -64,7 +63,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.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 c27addd028fd..35929b606df5 100644 --- a/x/bank/testutil/expected_keepers_mocks.go +++ b/x/bank/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -50,10 +50,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetAllAccounts mocks base method. -func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types0.AccountI { +func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllAccounts", ctx) - ret0, _ := ret[0].([]types0.AccountI) + ret0, _ := ret[0].([]types.AccountI) return ret0 } @@ -150,7 +150,7 @@ func (mr *MockAccountKeeperMockRecorder) HasAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -162,10 +162,10 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -176,10 +176,10 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -190,7 +190,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", ctx, acc) } diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 191d6b5a836a..5899d8505f99 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -8,15 +8,15 @@ import ( // AccountKeeper defines the account contract that must be fulfilled when // creating a x/bank keeper. type AccountKeeper interface { - NewAccount(sdk.Context, types.AccountI) types.AccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI - GetAllAccounts(ctx sdk.Context) []types.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 types.AccountI) + SetAccount(ctx sdk.Context, acc sdk.AccountI) - IterateAccounts(ctx sdk.Context, process func(types.AccountI) bool) + IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) bool) ValidatePermissions(macc types.ModuleAccountI) error diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index 585d2cb57792..224e8e73f5d9 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -37,10 +37,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 94cea333ab06..8526cdb76a4e 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -8,7 +8,7 @@ import ( // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI diff --git a/x/evidence/testutil/expected_keepers_mocks.go b/x/evidence/testutil/expected_keepers_mocks.go index 16478b7908be..f9021ea468ae 100644 --- a/x/evidence/testutil/expected_keepers_mocks.go +++ b/x/evidence/testutil/expected_keepers_mocks.go @@ -10,8 +10,7 @@ import ( types "github.com/cosmos/cosmos-sdk/crypto/types" types0 "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/x/auth/types" - types2 "github.com/cosmos/cosmos-sdk/x/staking/types" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -39,10 +38,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // GetParams mocks base method. -func (m *MockStakingKeeper) GetParams(ctx types0.Context) types2.Params { +func (m *MockStakingKeeper) GetParams(ctx types0.Context) types1.Params { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetParams", ctx) - ret0, _ := ret[0].(types2.Params) + ret0, _ := ret[0].(types1.Params) return ret0 } @@ -53,10 +52,10 @@ func (mr *MockStakingKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types0.Context, arg1 types0.ConsAddress) types2.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types0.Context, arg1 types0.ConsAddress) types1.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types2.ValidatorI) + ret0, _ := ret[0].(types1.ValidatorI) return ret0 } @@ -183,7 +182,7 @@ func (mr *MockSlashingKeeperMockRecorder) SlashFractionDoubleSign(arg0 interface } // SlashWithInfractionReason mocks base method. -func (m *MockSlashingKeeper) SlashWithInfractionReason(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64, arg5 types2.Infraction) { +func (m *MockSlashingKeeper) SlashWithInfractionReason(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64, arg5 types1.Infraction) { m.ctrl.T.Helper() m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5) } @@ -230,7 +229,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types0.Context, acc types1.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types0.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 8bb2a7f79b10..f7355ee3a3a8 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -5,7 +5,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -33,7 +32,7 @@ type ( // AccountKeeper define the account keeper interface contracted needed by the evidence module AccountKeeper interface { - SetAccount(ctx sdk.Context, acc types.AccountI) + SetAccount(ctx sdk.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 eb5d4bf04465..2be5d9b95841 100644 --- a/x/feegrant/expected_keepers.go +++ b/x/feegrant/expected_keepers.go @@ -10,9 +10,9 @@ type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, moduleName string) auth.ModuleAccountI - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI - SetAccount(ctx sdk.Context, acc auth.AccountI) + 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) } // BankKeeper defines the expected supply Keeper (noalias) diff --git a/x/feegrant/testutil/expected_keepers_mocks.go b/x/feegrant/testutil/expected_keepers_mocks.go index c00c4b0d71fc..30e7854ef93c 100644 --- a/x/feegrant/testutil/expected_keepers_mocks.go +++ b/x/feegrant/testutil/expected_keepers_mocks.go @@ -36,10 +36,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -78,10 +78,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{} } // NewAccountWithAddress mocks base method. -func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -92,7 +92,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(ctx types.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 f51fa2eb2733..7822c4527b06 100644 --- a/x/genutil/testutil/expected_keepers_mocks.go +++ b/x/genutil/testutil/expected_keepers_mocks.go @@ -10,10 +10,9 @@ import ( codec "github.com/cosmos/cosmos-sdk/codec" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" exported "github.com/cosmos/cosmos-sdk/x/bank/exported" gomock "github.com/golang/mock/gomock" - types1 "github.com/tendermint/tendermint/abci/types" + types0 "github.com/tendermint/tendermint/abci/types" ) // MockStakingKeeper is a mock of StakingKeeper interface. @@ -40,10 +39,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // ApplyAndReturnValidatorSetUpdates mocks base method. -func (m *MockStakingKeeper) ApplyAndReturnValidatorSetUpdates(arg0 types.Context) ([]types1.ValidatorUpdate, error) { +func (m *MockStakingKeeper) ApplyAndReturnValidatorSetUpdates(arg0 types.Context) ([]types0.ValidatorUpdate, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ApplyAndReturnValidatorSetUpdates", arg0) - ret0, _ := ret[0].([]types1.ValidatorUpdate) + ret0, _ := ret[0].([]types0.ValidatorUpdate) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -78,7 +77,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -90,10 +89,10 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -104,7 +103,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } @@ -139,7 +138,7 @@ func (m *MockGenesisAccountsIterator) EXPECT() *MockGenesisAccountsIteratorMockR } // IterateGenesisAccounts mocks base method. -func (m *MockGenesisAccountsIterator) IterateGenesisAccounts(cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, cb func(types0.AccountI) bool) { +func (m *MockGenesisAccountsIterator) IterateGenesisAccounts(cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, cb func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateGenesisAccounts", cdc, appGenesis, cb) } diff --git a/x/genutil/types/expected_keepers.go b/x/genutil/types/expected_keepers.go index 854422a3c990..a55c7a7a0330 100644 --- a/x/genutil/types/expected_keepers.go +++ b/x/genutil/types/expected_keepers.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported" ) @@ -18,9 +17,9 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - NewAccount(sdk.Context, auth.AccountI) auth.AccountI - SetAccount(sdk.Context, auth.AccountI) - IterateAccounts(ctx sdk.Context, process func(auth.AccountI) (stop bool)) + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI + SetAccount(sdk.Context, sdk.AccountI) + IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool)) } // GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias) @@ -28,7 +27,7 @@ type GenesisAccountsIterator interface { IterateGenesisAccounts( cdc *codec.LegacyAmino, appGenesis map[string]json.RawMessage, - cb func(auth.AccountI) (stop bool), + cb func(sdk.AccountI) (stop bool), ) } diff --git a/x/gov/testutil/expected_keepers.go b/x/gov/testutil/expected_keepers.go index 669dbc010b2d..50ace59c6611 100644 --- a/x/gov/testutil/expected_keepers.go +++ b/x/gov/testutil/expected_keepers.go @@ -6,7 +6,6 @@ import ( math "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -16,7 +15,7 @@ import ( type AccountKeeper interface { types.AccountKeeper - IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountI) (stop bool)) + IterateAccounts(ctx sdk.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 e119ee2bf6e9..4c922b5a2182 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -42,10 +42,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -84,7 +84,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, cb func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, cb func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, cb) } diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index b486e5daf91f..1e8a106b34d3 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -30,7 +30,7 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI diff --git a/x/group/expected_keepers.go b/x/group/expected_keepers.go index f8677fc3c26c..31334a3413b7 100644 --- a/x/group/expected_keepers.go +++ b/x/group/expected_keepers.go @@ -2,21 +2,20 @@ package group import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/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, authtypes.AccountI) authtypes.AccountI + NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI // GetAccount retrieves an account from the store. - GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountI + GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI // SetAccount sets an account in the store. - SetAccount(sdk.Context, authtypes.AccountI) + SetAccount(sdk.Context, sdk.AccountI) // RemoveAccount Remove an account in the store. - RemoveAccount(ctx sdk.Context, acc authtypes.AccountI) + RemoveAccount(ctx sdk.Context, acc sdk.AccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 5c4eccffec3f..b7b3558666d6 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -14,7 +14,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/auth/tx" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/group/keeper" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -1195,7 +1194,7 @@ func SimulateMsgLeaveGroup(cdc *codec.ProtoCodec, k keeper.Keeper, ak group.Acco func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, ctx sdk.Context, accounts []simtypes.Account, -) (groupInfo *group.GroupInfo, acc simtypes.Account, account authtypes.AccountI, err error) { +) (groupInfo *group.GroupInfo, acc simtypes.Account, account sdk.AccountI, err error) { groupID := k.GetGroupSequence(ctx) switch { @@ -1233,7 +1232,7 @@ func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, ctx sdk.Context, accounts []simtypes.Account, -) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account authtypes.AccountI, err error) { +) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account sdk.AccountI, err error) { groupInfo, _, _, err = randomGroup(r, k, ak, ctx, accounts) if err != nil { return nil, nil, simtypes.Account{}, nil, err @@ -1265,7 +1264,7 @@ func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, func randomMember(ctx context.Context, r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, accounts []simtypes.Account, groupID uint64, -) (acc simtypes.Account, account authtypes.AccountI, err error) { +) (acc simtypes.Account, account sdk.AccountI, err error) { res, err := k.GroupMembers(ctx, &group.QueryGroupMembersRequest{ GroupId: groupID, }) diff --git a/x/group/testutil/expected_keepers_mocks.go b/x/group/testutil/expected_keepers_mocks.go index 2e51cfad5476..8f614b6be1e2 100644 --- a/x/group/testutil/expected_keepers_mocks.go +++ b/x/group/testutil/expected_keepers_mocks.go @@ -9,8 +9,7 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" - types1 "github.com/cosmos/cosmos-sdk/x/bank/types" + types0 "github.com/cosmos/cosmos-sdk/x/bank/types" gomock "github.com/golang/mock/gomock" ) @@ -38,10 +37,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(arg0 types.Context, arg1 types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(arg0 types.Context, arg1 types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -52,10 +51,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(arg0, arg1 interface{}) *gom } // NewAccount mocks base method. -func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -66,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom } // RemoveAccount mocks base method. -func (m *MockAccountKeeper) RemoveAccount(ctx types.Context, acc types0.AccountI) { +func (m *MockAccountKeeper) RemoveAccount(ctx types.Context, acc types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "RemoveAccount", ctx, acc) } @@ -78,7 +77,7 @@ func (mr *MockAccountKeeperMockRecorder) RemoveAccount(ctx, acc interface{}) *go } // SetAccount mocks base method. -func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types0.AccountI) { +func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types.AccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAccount", arg0, arg1) } @@ -141,10 +140,10 @@ func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amt interface{} } // MultiSend mocks base method. -func (m *MockBankKeeper) MultiSend(arg0 context.Context, arg1 *types1.MsgMultiSend) (*types1.MsgMultiSendResponse, error) { +func (m *MockBankKeeper) MultiSend(arg0 context.Context, arg1 *types0.MsgMultiSend) (*types0.MsgMultiSendResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MultiSend", arg0, arg1) - ret0, _ := ret[0].(*types1.MsgMultiSendResponse) + ret0, _ := ret[0].(*types0.MsgMultiSendResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -156,10 +155,10 @@ func (mr *MockBankKeeperMockRecorder) MultiSend(arg0, arg1 interface{}) *gomock. } // Send mocks base method. -func (m *MockBankKeeper) Send(arg0 context.Context, arg1 *types1.MsgSend) (*types1.MsgSendResponse, error) { +func (m *MockBankKeeper) Send(arg0 context.Context, arg1 *types0.MsgSend) (*types0.MsgSendResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Send", arg0, arg1) - ret0, _ := ret[0].(*types1.MsgSendResponse) + ret0, _ := ret[0].(*types0.MsgSendResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -185,10 +184,10 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderMo } // SetSendEnabled mocks base method. -func (m *MockBankKeeper) SetSendEnabled(arg0 context.Context, arg1 *types1.MsgSetSendEnabled) (*types1.MsgSetSendEnabledResponse, error) { +func (m *MockBankKeeper) SetSendEnabled(arg0 context.Context, arg1 *types0.MsgSetSendEnabled) (*types0.MsgSetSendEnabledResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetSendEnabled", arg0, arg1) - ret0, _ := ret[0].(*types1.MsgSetSendEnabledResponse) + ret0, _ := ret[0].(*types0.MsgSetSendEnabledResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -214,10 +213,10 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom } // UpdateParams mocks base method. -func (m *MockBankKeeper) UpdateParams(arg0 context.Context, arg1 *types1.MsgUpdateParams) (*types1.MsgUpdateParamsResponse, error) { +func (m *MockBankKeeper) UpdateParams(arg0 context.Context, arg1 *types0.MsgUpdateParams) (*types0.MsgUpdateParamsResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateParams", arg0, arg1) - ret0, _ := ret[0].(*types1.MsgUpdateParamsResponse) + ret0, _ := ret[0].(*types0.MsgUpdateParamsResponse) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/x/nft/expected_keepers.go b/x/nft/expected_keepers.go index 0e0f1efd6e45..ec7976e294b9 100644 --- a/x/nft/expected_keepers.go +++ b/x/nft/expected_keepers.go @@ -2,7 +2,6 @@ package nft import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // BankKeeper defines the contract needed to be fulfilled for banking and supply @@ -14,5 +13,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) authtypes.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI } diff --git a/x/nft/testutil/expected_keepers_mocks.go b/x/nft/testutil/expected_keepers_mocks.go index 49d193397ee2..cf85857c6717 100644 --- a/x/nft/testutil/expected_keepers_mocks.go +++ b/x/nft/testutil/expected_keepers_mocks.go @@ -8,7 +8,6 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -73,10 +72,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } diff --git a/x/simulation/expected_keepers.go b/x/simulation/expected_keepers.go index c54831b8a401..346d695f66dc 100644 --- a/x/simulation/expected_keepers.go +++ b/x/simulation/expected_keepers.go @@ -2,12 +2,11 @@ package simulation import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetAccount(ctx sdk.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 86d57c5e2d68..1de66b89e99a 100644 --- a/x/slashing/testutil/expected_keepers_mocks.go +++ b/x/slashing/testutil/expected_keepers_mocks.go @@ -9,9 +9,8 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" - types1 "github.com/cosmos/cosmos-sdk/x/params/types" - types2 "github.com/cosmos/cosmos-sdk/x/staking/types" + types0 "github.com/cosmos/cosmos-sdk/x/params/types" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -39,10 +38,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -53,7 +52,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } @@ -179,7 +178,7 @@ func (mr *MockParamSubspaceMockRecorder) Get(ctx, key, ptr interface{}) *gomock. } // GetParamSet mocks base method. -func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types1.ParamSet) { +func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types0.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "GetParamSet", ctx, ps) } @@ -205,7 +204,7 @@ func (mr *MockParamSubspaceMockRecorder) HasKeyTable() *gomock.Call { } // SetParamSet mocks base method. -func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types1.ParamSet) { +func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types0.ParamSet) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetParamSet", ctx, ps) } @@ -217,10 +216,10 @@ func (mr *MockParamSubspaceMockRecorder) SetParamSet(ctx, ps interface{}) *gomoc } // WithKeyTable mocks base method. -func (m *MockParamSubspace) WithKeyTable(table types1.KeyTable) types1.Subspace { +func (m *MockParamSubspace) WithKeyTable(table types0.KeyTable) types0.Subspace { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "WithKeyTable", table) - ret0, _ := ret[0].(types1.Subspace) + ret0, _ := ret[0].(types0.Subspace) return ret0 } @@ -254,10 +253,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // Delegation mocks base method. -func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types2.DelegationI { +func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types1.DelegationI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2) - ret0, _ := ret[0].(types2.DelegationI) + ret0, _ := ret[0].(types1.DelegationI) return ret0 } @@ -268,10 +267,10 @@ func (mr *MockStakingKeeperMockRecorder) Delegation(arg0, arg1, arg2 interface{} } // GetAllValidators mocks base method. -func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types2.Validator { +func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types1.Validator { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllValidators", ctx) - ret0, _ := ret[0].([]types2.Validator) + ret0, _ := ret[0].([]types1.Validator) return ret0 } @@ -296,7 +295,7 @@ func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{} } // IterateValidators mocks base method. -func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types2.ValidatorI) bool) { +func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateValidators", arg0, arg1) } @@ -348,7 +347,7 @@ func (mr *MockStakingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 inte } // SlashWithInfractionReason mocks base method. -func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types2.Infraction) math.Int { +func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types1.Infraction) math.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(math.Int) @@ -374,10 +373,10 @@ func (mr *MockStakingKeeperMockRecorder) Unjail(arg0, arg1 interface{}) *gomock. } // Validator mocks base method. -func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types2.ValidatorI { +func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types1.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", arg0, arg1) - ret0, _ := ret[0].(types2.ValidatorI) + ret0, _ := ret[0].(types1.ValidatorI) return ret0 } @@ -388,10 +387,10 @@ func (mr *MockStakingKeeperMockRecorder) Validator(arg0, arg1 interface{}) *gomo } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types2.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types1.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types2.ValidatorI) + ret0, _ := ret[0].(types1.ValidatorI) return ret0 } diff --git a/x/slashing/types/expected_keepers.go b/x/slashing/types/expected_keepers.go index 569a26b546d5..3306be791a27 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -4,15 +4,14 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // AccountKeeper expected account keeper type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI - IterateAccounts(ctx sdk.Context, process func(auth.AccountI) (stop bool)) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI + IterateAccounts(ctx sdk.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 375c6ff3c729..03f8cf96f47d 100644 --- a/x/staking/testutil/expected_keepers_mocks.go +++ b/x/staking/testutil/expected_keepers_mocks.go @@ -89,10 +89,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -131,7 +131,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, process) } diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index 05672ee256da..1c32d6e0b3f2 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -15,8 +15,8 @@ type DistributionKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - IterateAccounts(ctx sdk.Context, process func(authtypes.AccountI) (stop bool)) - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI // only used for simulation + IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool)) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI From 3dc41bae3c089bbb4357743935b3589fd41864f5 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 27 Dec 2022 13:27:14 +0530 Subject: [PATCH 13/21] wip: fix tests --- x/auth/ante/testutil_test.go | 2 +- x/auth/keeper/deterministic_test.go | 10 +++++----- x/auth/keeper/grpc_query_test.go | 12 ++++++------ x/auth/keeper/keeper_test.go | 4 ++-- x/bank/keeper/keeper_test.go | 20 ++++++++++---------- x/bank/keeper/msg_service_test.go | 3 +-- x/group/keeper/keeper_test.go | 2 +- 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index 7fbaf588800e..38e38b4bad09 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -26,7 +26,7 @@ import ( // TestAccount represents an account used in the tests in x/auth/ante. type TestAccount struct { - acc types.AccountI + acc sdk.AccountI priv cryptotypes.PrivKey } diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 829f2073172a..2cf9e73d2ed6 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -77,8 +77,8 @@ func (suite *DeterministicTestSuite) SetupTest() { } // createAndSetAccount creates a random account and sets to the keeper store. -func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []types.AccountI { - accs := make([]types.AccountI, 0, count) +func (suite *DeterministicTestSuite) createAndSetAccounts(t *rapid.T, count int) []sdk.AccountI { + accs := make([]sdk.AccountI, 0, count) // We need all generated account-numbers unique accNums := rapid.SliceOfNDistinct(rapid.Uint64(), count, count, func(i uint64) uint64 { return i }).Draw(t, "acc-numss") @@ -239,12 +239,12 @@ func (suite *DeterministicTestSuite) createAndReturnQueryClient(ak keeper.Accoun func (suite *DeterministicTestSuite) setModuleAccounts( ctx sdk.Context, ak keeper.AccountKeeper, maccs []string, -) []types.AccountI { +) []sdk.AccountI { sort.Strings(maccs) - moduleAccounts := make([]types.AccountI, 0, len(maccs)) + moduleAccounts := make([]sdk.AccountI, 0, len(maccs)) for _, m := range maccs { acc, _ := ak.GetModuleAccountAndPermissions(ctx, m) - acc1, ok := acc.(types.AccountI) + acc1, ok := acc.(sdk.AccountI) suite.Require().True(ok) moduleAccounts = append(moduleAccounts, acc1) } diff --git a/x/auth/keeper/grpc_query_test.go b/x/auth/keeper/grpc_query_test.go index 1d3854b23e76..3d2a2010955b 100644 --- a/x/auth/keeper/grpc_query_test.go +++ b/x/auth/keeper/grpc_query_test.go @@ -42,7 +42,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccounts() { func(res *types.QueryAccountsResponse) { addresses := make([]sdk.AccAddress, len(res.Accounts)) for i, acc := range res.Accounts { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) addresses[i] = account.GetAddress() @@ -123,7 +123,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccount() { }, true, func(res *types.QueryAccountResponse) { - var newAccount types.AccountI + var newAccount sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &newAccount) suite.Require().NoError(err) suite.Require().NotNil(newAccount) @@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { func(res *types.QueryModuleAccountsResponse) { mintModuleExists := false for _, acc := range res.Accounts { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) @@ -303,7 +303,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { func(res *types.QueryModuleAccountsResponse) { mintModuleExists := false for _, acc := range res.Accounts { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) @@ -332,7 +332,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { // Make sure output is sorted alphabetically. var moduleNames []string for _, any := range res.Accounts { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(any, &account) suite.Require().NoError(err) moduleAccount, ok := account.(types.ModuleAccountI) @@ -366,7 +366,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccountByName() { }, true, func(res *types.QueryModuleAccountByNameResponse) { - var account types.AccountI + var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &account) suite.Require().NoError(err) diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 7448fa5e4df6..29dc06efbb72 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -190,7 +190,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { // Fix duplicate account numbers pubKey1 := ed25519.GenPrivKey().PubKey() pubKey2 := ed25519.GenPrivKey().PubKey() - accts := []types.AccountI{ + accts := []sdk.AccountI{ &types.BaseAccount{ Address: sdk.AccAddress(pubKey1.Address()).String(), PubKey: codectypes.UnsafePackAny(pubKey1), @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().Equal(len(keeperAccts), len(accts)+1, "number of accounts in the keeper vs in genesis state") for i, genAcct := range accts { genAcctAddr := genAcct.GetAddress() - var keeperAcct types.AccountI + var keeperAcct sdk.AccountI for _, kacct := range keeperAccts { if genAcctAddr.Equals(kacct.GetAddress()) { keeperAcct = kacct diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index d37e14ac8e83..a4ee759b318e 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -149,7 +149,7 @@ func (suite *KeeperTestSuite) mockSendCoinsFromAccountToModule(acc *authtypes.Ba suite.authKeeper.EXPECT().HasAccount(suite.ctx, moduleAcc.GetAddress()).Return(true) } -func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender authtypes.AccountI, receiver sdk.AccAddress) { +func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender sdk.AccountI, receiver sdk.AccAddress) { suite.authKeeper.EXPECT().GetAccount(ctx, sender.GetAddress()).Return(sender) suite.authKeeper.EXPECT().HasAccount(ctx, receiver).Return(true) } @@ -159,7 +159,7 @@ func (suite *KeeperTestSuite) mockFundAccount(receiver sdk.AccAddress) { suite.mockSendCoinsFromModuleToAccount(mintAcc, receiver) } -func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountI, outputs []sdk.AccAddress) { +func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []sdk.AccountI, outputs []sdk.AccAddress) { for _, input := range inputs { suite.authKeeper.EXPECT().GetAccount(suite.ctx, input.GetAddress()).Return(input) } @@ -168,15 +168,15 @@ func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountI, } } -func (suite *KeeperTestSuite) mockValidateBalance(acc authtypes.AccountI) { +func (suite *KeeperTestSuite) mockValidateBalance(acc sdk.AccountI) { suite.authKeeper.EXPECT().GetAccount(suite.ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc authtypes.AccountI) { +func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc sdk.AccountI) { suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.AccountI, mAcc authtypes.AccountI) { +func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -185,7 +185,7 @@ func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.A suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) } -func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc authtypes.AccountI, mAcc authtypes.AccountI) { +func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -466,7 +466,7 @@ func (suite *KeeperTestSuite) TestInputOutputNewAccount() { require.Empty(suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) - suite.mockInputOutputCoins([]authtypes.AccountI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) + suite.mockInputOutputCoins([]sdk.AccountI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) inputs := []banktypes.Input{ {Address: accAddrs[0].String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, } @@ -516,7 +516,7 @@ func (suite *KeeperTestSuite) TestInputOutputCoins() { require.Error(suite.bankKeeper.InputOutputCoins(ctx, insufficientInputs, insufficientOutputs)) - suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[1:3]) + suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[1:3]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) acc1Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) @@ -746,7 +746,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { suite.mockFundAccount(accAddrs[0]) require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100)))) - suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[2:4]) + suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[2:4]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() @@ -771,7 +771,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)))) newCoins2 = sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) - suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[2:4]) + suite.mockInputOutputCoins([]sdk.AccountI{acc0}, accAddrs[2:4]) require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() diff --git a/x/bank/keeper/msg_service_test.go b/x/bank/keeper/msg_service_test.go index 87b5c4b6fcb9..a6454b6a8531 100644 --- a/x/bank/keeper/msg_service_test.go +++ b/x/bank/keeper/msg_service_test.go @@ -2,7 +2,6 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -159,7 +158,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSend() { suite.mockMintCoins(minterAcc) suite.bankKeeper.MintCoins(suite.ctx, minterAcc.Name, origCoins) if !tc.expErr { - suite.mockInputOutputCoins([]authtypes.AccountI{minterAcc}, accAddrs[:2]) + suite.mockInputOutputCoins([]sdk.AccountI{minterAcc}, accAddrs[:2]) } _, err := suite.msgServer.MultiSend(suite.ctx, tc.input) if tc.expErr { diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 2c4cb9184935..e510cfe06be5 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -138,7 +138,7 @@ func (s TestSuite) setNextAccount() { //nolint:govet // this is a test and we're s.accountKeeper.EXPECT().GetAccount(gomock.Any(), sdk.AccAddress(accountCredentials.Address())).Return(nil).AnyTimes() s.accountKeeper.EXPECT().NewAccount(gomock.Any(), groupPolicyAcc).Return(groupPolicyAccBumpAccountNumber).AnyTimes() - s.accountKeeper.EXPECT().SetAccount(gomock.Any(), authtypes.AccountI(groupPolicyAccBumpAccountNumber)).Return().AnyTimes() + s.accountKeeper.EXPECT().SetAccount(gomock.Any(), sdk.AccountI(groupPolicyAccBumpAccountNumber)).Return().AnyTimes() } func TestKeeperTestSuite(t *testing.T) { From 0d1aa39aeca38d330107c45d1fdef1483ed9ab46 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 27 Dec 2022 13:30:38 +0530 Subject: [PATCH 14/21] fix import --- x/auth/types/account.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 895248699460..de5199414395 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -11,7 +11,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -276,13 +275,13 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { // // Deprecated: Use `AccountI` from types package instead. type AccountI interface { - types.AccountI + sdk.AccountI } // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. type ModuleAccountI interface { - types.AccountI + sdk.AccountI GetName() string GetPermissions() []string @@ -306,7 +305,7 @@ func (ga GenesisAccounts) Contains(addr sdk.Address) bool { // GenesisAccount defines a genesis account that embeds an AccountI with validation capabilities. type GenesisAccount interface { - types.AccountI + sdk.AccountI Validate() error } From 6b977142318381cb1399e01cae765fce16a11316 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 27 Dec 2022 14:23:14 +0530 Subject: [PATCH 15/21] fix failing test --- tests/e2e/auth/suite.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/auth/suite.go b/tests/e2e/auth/suite.go index 9d519e4413da..dddb64082d51 100644 --- a/tests/e2e/auth/suite.go +++ b/tests/e2e/auth/suite.go @@ -397,7 +397,7 @@ func (s *E2ETestSuite) TestCLISignAminoJSON() { // query account info queryResJSON, err := authclitestutil.QueryAccountExec(val1.ClientCtx, val1.Address) require.NoError(err) - var account authtypes.AccountI + var account sdk.AccountI require.NoError(val1.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) /**** test signature-only ****/ @@ -1327,7 +1327,7 @@ func (s *E2ETestSuite) TestMultisignBatch() { queryResJSON, err := authclitestutil.QueryAccountExec(val.ClientCtx, addr) s.Require().NoError(err) - var account authtypes.AccountI + var account sdk.AccountI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) // sign-batch file @@ -1398,7 +1398,7 @@ func (s *E2ETestSuite) TestGetAccountCmd() { s.Require().Error(err) s.Require().NotEqual("internal", err.Error()) } else { - var acc authtypes.AccountI + var acc sdk.AccountI s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(out.Bytes(), &acc)) s.Require().Equal(val.Address, acc.GetAddress()) } @@ -1456,7 +1456,7 @@ func (s *E2ETestSuite) TestQueryModuleAccountByNameCmd() { var res authtypes.QueryModuleAccountByNameResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - var account authtypes.AccountI + var account sdk.AccountI err := val.ClientCtx.InterfaceRegistry.UnpackAny(res.Account, &account) s.Require().NoError(err) From da9828224596bfe0a025df486a0c8c317801e9f9 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Dec 2022 16:54:30 +0530 Subject: [PATCH 16/21] try fixing failing tests --- baseapp/options.go | 3 ++- store/streaming/constructor_test.go | 1 - tools/rosetta/converter.go | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/baseapp/options.go b/baseapp/options.go index a98992398d7f..21f168aba7db 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -238,7 +238,8 @@ func (app *BaseApp) SetInterfaceRegistry(registry types.InterfaceRegistry) { func (app *BaseApp) SetStreamingService( appOpts servertypes.AppOptions, appCodec storetypes.Codec, - keys map[string]*storetypes.KVStoreKey) error { + keys map[string]*storetypes.KVStoreKey, +) error { streamers, _, err := streaming.LoadStreamingServices(appOpts, appCodec, app.logger, keys) if err != nil { return err diff --git a/store/streaming/constructor_test.go b/store/streaming/constructor_test.go index 28f462a268fc..3f6b033a8198 100644 --- a/store/streaming/constructor_test.go +++ b/store/streaming/constructor_test.go @@ -47,7 +47,6 @@ func TestStreamingServiceConstructor(t *testing.T) { } func TestLoadStreamingServices(t *testing.T) { - encCdc := types.NewTestCodec() keys := types.NewKVStoreKeys("mockKey1", "mockKey2") diff --git a/tools/rosetta/converter.go b/tools/rosetta/converter.go index 889101aea715..0c4e217ec228 100644 --- a/tools/rosetta/converter.go +++ b/tools/rosetta/converter.go @@ -25,7 +25,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -756,7 +755,7 @@ func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMe // SignerData converts the given any account to signer data func (c converter) SignerData(anyAccount *codectypes.Any) (*SignerData, error) { - var acc auth.AccountI + var acc sdk.AccountI err := c.ir.UnpackAny(anyAccount, &acc) if err != nil { return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) From da166122c495d81fa84d7b9bc991ddb90028a0af Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Dec 2022 17:04:12 +0530 Subject: [PATCH 17/21] fix something --- tools/rosetta/converter.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/rosetta/converter.go b/tools/rosetta/converter.go index 0c4e217ec228..889101aea715 100644 --- a/tools/rosetta/converter.go +++ b/tools/rosetta/converter.go @@ -25,6 +25,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + auth "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -755,7 +756,7 @@ func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMe // SignerData converts the given any account to signer data func (c converter) SignerData(anyAccount *codectypes.Any) (*SignerData, error) { - var acc sdk.AccountI + var acc auth.AccountI err := c.ir.UnpackAny(anyAccount, &acc) if err != nil { return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) From 13ef65c6f4f2a1ff67cd679241253ecb220fb435 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Dec 2022 17:29:45 +0530 Subject: [PATCH 18/21] move ModuleAccountI interface to types package --- tests/e2e/auth/suite.go | 2 +- types/dependencies.go | 10 ++ x/auth/keeper/grpc_query_test.go | 8 +- x/auth/keeper/keeper.go | 12 +-- x/auth/types/account.go | 10 +- x/auth/types/codec.go | 2 +- x/bank/testutil/expected_keepers_mocks.go | 12 +-- x/bank/types/expected_keepers.go | 8 +- x/distribution/keeper/alias_functions.go | 3 +- .../testutil/expected_keepers_mocks.go | 37 ++++---- x/distribution/types/expected_keepers.go | 5 +- x/feegrant/expected_keepers.go | 3 +- x/feegrant/testutil/expected_keepers_mocks.go | 5 +- x/gov/keeper/keeper.go | 3 +- x/gov/testutil/expected_keepers_mocks.go | 91 +++++++++---------- x/gov/types/expected_keepers.go | 5 +- x/group/migrations/v2/gen_state.go | 3 +- x/mint/testutil/expected_keepers_mocks.go | 7 +- x/mint/types/expected_keepers.go | 6 +- x/staking/keeper/pool.go | 6 +- x/staking/testutil/expected_keepers_mocks.go | 35 ++++--- x/staking/types/expected_keepers.go | 5 +- 22 files changed, 138 insertions(+), 140 deletions(-) diff --git a/tests/e2e/auth/suite.go b/tests/e2e/auth/suite.go index dddb64082d51..ac5eca9a1c5f 100644 --- a/tests/e2e/auth/suite.go +++ b/tests/e2e/auth/suite.go @@ -1460,7 +1460,7 @@ func (s *E2ETestSuite) TestQueryModuleAccountByNameCmd() { err := val.ClientCtx.InterfaceRegistry.UnpackAny(res.Account, &account) s.Require().NoError(err) - moduleAccount, ok := account.(authtypes.ModuleAccountI) + moduleAccount, ok := account.(sdk.ModuleAccountI) s.Require().True(ok) s.Require().Equal(tc.moduleName, moduleAccount.GetName()) } diff --git a/types/dependencies.go b/types/dependencies.go index d5c5ddbd39b6..72e7a7b4eca5 100644 --- a/types/dependencies.go +++ b/types/dependencies.go @@ -30,3 +30,13 @@ type AccountI interface { // Ensure that account implements stringer String() string } + +// ModuleAccountI defines an account interface for modules that hold tokens in +// an escrow. +type ModuleAccountI interface { + AccountI + + GetName() string + GetPermissions() []string + HasPermission(string) bool +} diff --git a/x/auth/keeper/grpc_query_test.go b/x/auth/keeper/grpc_query_test.go index 3d2a2010955b..f2d0a766648c 100644 --- a/x/auth/keeper/grpc_query_test.go +++ b/x/auth/keeper/grpc_query_test.go @@ -284,7 +284,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) - moduleAccount, ok := account.(types.ModuleAccountI) + moduleAccount, ok := account.(sdk.ModuleAccountI) suite.Require().True(ok) if moduleAccount.GetName() == "mint" { @@ -307,7 +307,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) - moduleAccount, ok := account.(types.ModuleAccountI) + moduleAccount, ok := account.(sdk.ModuleAccountI) suite.Require().True(ok) if moduleAccount.GetName() == "falseCase" { @@ -335,7 +335,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { var account sdk.AccountI err := suite.encCfg.InterfaceRegistry.UnpackAny(any, &account) suite.Require().NoError(err) - moduleAccount, ok := account.(types.ModuleAccountI) + moduleAccount, ok := account.(sdk.ModuleAccountI) suite.Require().True(ok) moduleNames = append(moduleNames, moduleAccount.GetName()) } @@ -370,7 +370,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccountByName() { err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &account) suite.Require().NoError(err) - moduleAccount, ok := account.(types.ModuleAccountI) + moduleAccount, ok := account.(sdk.ModuleAccountI) suite.Require().True(ok) suite.Require().Equal(moduleAccount.GetName(), "mint") }, diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 934c3fdbf9de..0568edacc111 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -160,7 +160,7 @@ func (ak AccountKeeper) GetModulePermissions() map[string]types.PermissionsForAd // ValidatePermissions validates that the module account has been granted // permissions within its set of allowed permissions. -func (ak AccountKeeper) ValidatePermissions(macc types.ModuleAccountI) error { +func (ak AccountKeeper) ValidatePermissions(macc sdk.ModuleAccountI) error { permAddr := ak.permAddrs[macc.GetName()] for _, perm := range macc.GetPermissions() { if !permAddr.HasPermission(perm) { @@ -193,7 +193,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) (types.ModuleAccountI, []string) { +func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleName string) (sdk.ModuleAccountI, []string) { addr, perms := ak.GetModuleAddressAndPermissions(moduleName) if addr == nil { return nil, []string{} @@ -201,7 +201,7 @@ func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleNa acc := ak.GetAccount(ctx, addr) if acc != nil { - macc, ok := acc.(types.ModuleAccountI) + macc, ok := acc.(sdk.ModuleAccountI) if !ok { panic("account is not a module account") } @@ -210,7 +210,7 @@ func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleNa // create a new module account macc := types.NewEmptyModuleAccount(moduleName, perms...) - maccI := (ak.NewAccount(ctx, macc)).(types.ModuleAccountI) // set the account number + maccI := (ak.NewAccount(ctx, macc)).(sdk.ModuleAccountI) // set the account number ak.SetModuleAccount(ctx, maccI) return maccI, perms @@ -218,13 +218,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) types.ModuleAccountI { +func (ak AccountKeeper) GetModuleAccount(ctx sdk.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 types.ModuleAccountI) { +func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc sdk.ModuleAccountI) { ak.SetAccount(ctx, macc) } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index de5199414395..ad7655dc59dc 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -19,7 +19,7 @@ var ( _ GenesisAccount = (*BaseAccount)(nil) _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) _ GenesisAccount = (*ModuleAccount)(nil) - _ ModuleAccountI = (*ModuleAccount)(nil) + _ sdk.ModuleAccountI = (*ModuleAccount)(nil) ) // NewBaseAccount creates a new BaseAccount object @@ -280,12 +280,10 @@ type AccountI interface { // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. +// +// Deprecate: Use `ModuleAccountI` from types package instead. type ModuleAccountI interface { - sdk.AccountI - - GetName() string - GetPermissions() []string - HasPermission(string) bool + sdk.ModuleAccountI } // GenesisAccounts defines a slice of GenesisAccount objects diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index d18d1c38b2e6..0376d3c63371 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -16,7 +16,7 @@ import ( // RegisterLegacyAminoCodec registers the account interfaces and concrete types on the // provided LegacyAmino codec. These types are used for Amino JSON serialization func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterInterface((*ModuleAccountI)(nil), nil) + cdc.RegisterInterface((*sdk.ModuleAccountI)(nil), nil) cdc.RegisterInterface((*GenesisAccount)(nil), nil) cdc.RegisterInterface((*sdk.AccountI)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil) diff --git a/x/bank/testutil/expected_keepers_mocks.go b/x/bank/testutil/expected_keepers_mocks.go index 35929b606df5..f39abb0b4b57 100644 --- a/x/bank/testutil/expected_keepers_mocks.go +++ b/x/bank/testutil/expected_keepers_mocks.go @@ -64,10 +64,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAllAccounts(ctx interface{}) *gomock } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types0.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) - ret0, _ := ret[0].(types0.ModuleAccountI) + ret0, _ := ret[0].(types.ModuleAccountI) return ret0 } @@ -78,10 +78,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interf } // GetModuleAccountAndPermissions mocks base method. -func (m *MockAccountKeeper) GetModuleAccountAndPermissions(ctx types.Context, moduleName string) (types0.ModuleAccountI, []string) { +func (m *MockAccountKeeper) GetModuleAccountAndPermissions(ctx types.Context, moduleName string) (types.ModuleAccountI, []string) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccountAndPermissions", ctx, moduleName) - ret0, _ := ret[0].(types0.ModuleAccountI) + ret0, _ := ret[0].(types.ModuleAccountI) ret1, _ := ret[1].([]string) return ret0, ret1 } @@ -202,7 +202,7 @@ func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomoc } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(ctx types.Context, macc types0.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(ctx types.Context, macc types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", ctx, macc) } @@ -214,7 +214,7 @@ func (mr *MockAccountKeeperMockRecorder) SetModuleAccount(ctx, macc interface{}) } // ValidatePermissions mocks base method. -func (m *MockAccountKeeper) ValidatePermissions(macc types0.ModuleAccountI) error { +func (m *MockAccountKeeper) ValidatePermissions(macc types.ModuleAccountI) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatePermissions", macc) ret0, _ := ret[0].(error) diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 5899d8505f99..a56aeace3b5f 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -18,12 +18,12 @@ type AccountKeeper interface { IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) bool) - ValidatePermissions(macc types.ModuleAccountI) error + ValidatePermissions(macc sdk.ModuleAccountI) error GetModuleAddress(moduleName string) sdk.AccAddress GetModuleAddressAndPermissions(moduleName string) (addr sdk.AccAddress, permissions []string) - GetModuleAccountAndPermissions(ctx sdk.Context, moduleName string) (types.ModuleAccountI, []string) - GetModuleAccount(ctx sdk.Context, moduleName string) types.ModuleAccountI - SetModuleAccount(ctx sdk.Context, macc types.ModuleAccountI) + GetModuleAccountAndPermissions(ctx sdk.Context, moduleName string) (sdk.ModuleAccountI, []string) + GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI + SetModuleAccount(ctx sdk.Context, macc sdk.ModuleAccountI) GetModulePermissions() map[string]types.PermissionsForAddress } diff --git a/x/distribution/keeper/alias_functions.go b/x/distribution/keeper/alias_functions.go index 5d7f1b97f23c..9a5995893b91 100644 --- a/x/distribution/keeper/alias_functions.go +++ b/x/distribution/keeper/alias_functions.go @@ -2,7 +2,6 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" ) @@ -17,6 +16,6 @@ func (k Keeper) GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins { } // GetDistributionAccount returns the distribution ModuleAccount -func (k Keeper) GetDistributionAccount(ctx sdk.Context) authtypes.ModuleAccountI { +func (k Keeper) GetDistributionAccount(ctx sdk.Context) sdk.ModuleAccountI { return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) } diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index 224e8e73f5d9..ad1e01864a56 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -8,8 +8,7 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" - types1 "github.com/cosmos/cosmos-sdk/x/staking/types" + types0 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -51,10 +50,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, name string) types0.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, name string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name) - ret0, _ := ret[0].(types0.ModuleAccountI) + ret0, _ := ret[0].(types.ModuleAccountI) return ret0 } @@ -79,7 +78,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types0.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) } @@ -221,10 +220,10 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // Delegation mocks base method. -func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types1.DelegationI { +func (m *MockStakingKeeper) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types0.DelegationI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2) - ret0, _ := ret[0].(types1.DelegationI) + ret0, _ := ret[0].(types0.DelegationI) return ret0 } @@ -235,10 +234,10 @@ func (mr *MockStakingKeeperMockRecorder) Delegation(arg0, arg1, arg2 interface{} } // GetAllDelegatorDelegations mocks base method. -func (m *MockStakingKeeper) GetAllDelegatorDelegations(ctx types.Context, delegator types.AccAddress) []types1.Delegation { +func (m *MockStakingKeeper) GetAllDelegatorDelegations(ctx types.Context, delegator types.AccAddress) []types0.Delegation { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllDelegatorDelegations", ctx, delegator) - ret0, _ := ret[0].([]types1.Delegation) + ret0, _ := ret[0].([]types0.Delegation) return ret0 } @@ -249,10 +248,10 @@ func (mr *MockStakingKeeperMockRecorder) GetAllDelegatorDelegations(ctx, delegat } // GetAllSDKDelegations mocks base method. -func (m *MockStakingKeeper) GetAllSDKDelegations(ctx types.Context) []types1.Delegation { +func (m *MockStakingKeeper) GetAllSDKDelegations(ctx types.Context) []types0.Delegation { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllSDKDelegations", ctx) - ret0, _ := ret[0].([]types1.Delegation) + ret0, _ := ret[0].([]types0.Delegation) return ret0 } @@ -263,10 +262,10 @@ func (mr *MockStakingKeeperMockRecorder) GetAllSDKDelegations(ctx interface{}) * } // GetAllValidators mocks base method. -func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types1.Validator { +func (m *MockStakingKeeper) GetAllValidators(ctx types.Context) []types0.Validator { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllValidators", ctx) - ret0, _ := ret[0].([]types1.Validator) + ret0, _ := ret[0].([]types0.Validator) return ret0 } @@ -277,7 +276,7 @@ func (mr *MockStakingKeeperMockRecorder) GetAllValidators(ctx interface{}) *gomo } // IterateDelegations mocks base method. -func (m *MockStakingKeeper) IterateDelegations(ctx types.Context, delegator types.AccAddress, fn func(int64, types1.DelegationI) bool) { +func (m *MockStakingKeeper) IterateDelegations(ctx types.Context, delegator types.AccAddress, fn func(int64, types0.DelegationI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateDelegations", ctx, delegator, fn) } @@ -289,7 +288,7 @@ func (mr *MockStakingKeeperMockRecorder) IterateDelegations(ctx, delegator, fn i } // IterateValidators mocks base method. -func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { +func (m *MockStakingKeeper) IterateValidators(arg0 types.Context, arg1 func(int64, types0.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateValidators", arg0, arg1) } @@ -301,10 +300,10 @@ func (mr *MockStakingKeeperMockRecorder) IterateValidators(arg0, arg1 interface{ } // Validator mocks base method. -func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types1.ValidatorI { +func (m *MockStakingKeeper) Validator(arg0 types.Context, arg1 types.ValAddress) types0.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types0.ValidatorI) return ret0 } @@ -315,10 +314,10 @@ func (mr *MockStakingKeeperMockRecorder) Validator(arg0, arg1 interface{}) *gomo } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types1.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types0.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types0.ValidatorI) return ret0 } diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 8526cdb76a4e..3f53b4a550cf 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -2,7 +2,6 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -11,10 +10,10 @@ type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI + GetModuleAccount(ctx sdk.Context, name string) sdk.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, types.ModuleAccountI) + SetModuleAccount(sdk.Context, sdk.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/feegrant/expected_keepers.go b/x/feegrant/expected_keepers.go index 2be5d9b95841..39e7ca223495 100644 --- a/x/feegrant/expected_keepers.go +++ b/x/feegrant/expected_keepers.go @@ -2,13 +2,12 @@ package feegrant import ( sdk "github.com/cosmos/cosmos-sdk/types" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AccountKeeper defines the expected auth Account Keeper (noalias) type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) auth.ModuleAccountI + GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI diff --git a/x/feegrant/testutil/expected_keepers_mocks.go b/x/feegrant/testutil/expected_keepers_mocks.go index 30e7854ef93c..c49fc0ae9577 100644 --- a/x/feegrant/testutil/expected_keepers_mocks.go +++ b/x/feegrant/testutil/expected_keepers_mocks.go @@ -8,7 +8,6 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -50,10 +49,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types0.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) - ret0, _ := ret[0].(types0.ModuleAccountI) + ret0, _ := ret[0].(types.ModuleAccountI) return ret0 } diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 15ee1db46e3f..3cf98a29fd1d 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -135,7 +134,7 @@ func (k Keeper) LegacyRouter() v1beta1.Router { } // GetGovernanceAccount returns the governance ModuleAccount -func (k Keeper) GetGovernanceAccount(ctx sdk.Context) authtypes.ModuleAccountI { +func (k Keeper) GetGovernanceAccount(ctx sdk.Context) sdk.ModuleAccountI { return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) } diff --git a/x/gov/testutil/expected_keepers_mocks.go b/x/gov/testutil/expected_keepers_mocks.go index 4c922b5a2182..a414b68910cd 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -11,10 +11,9 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" keeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - types1 "github.com/cosmos/cosmos-sdk/x/bank/types" - types2 "github.com/cosmos/cosmos-sdk/x/staking/types" + types0 "github.com/cosmos/cosmos-sdk/x/bank/types" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -56,10 +55,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, name string) types0.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, name string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name) - ret0, _ := ret[0].(types0.ModuleAccountI) + ret0, _ := ret[0].(types.ModuleAccountI) return ret0 } @@ -96,7 +95,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, cb interface{}) *g } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types0.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) } @@ -131,10 +130,10 @@ func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { } // AllBalances mocks base method. -func (m *MockBankKeeper) AllBalances(arg0 context.Context, arg1 *types1.QueryAllBalancesRequest) (*types1.QueryAllBalancesResponse, error) { +func (m *MockBankKeeper) AllBalances(arg0 context.Context, arg1 *types0.QueryAllBalancesRequest) (*types0.QueryAllBalancesResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AllBalances", arg0, arg1) - ret0, _ := ret[0].(*types1.QueryAllBalancesResponse) + ret0, _ := ret[0].(*types0.QueryAllBalancesResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -146,10 +145,10 @@ func (mr *MockBankKeeperMockRecorder) AllBalances(arg0, arg1 interface{}) *gomoc } // Balance mocks base method. -func (m *MockBankKeeper) Balance(arg0 context.Context, arg1 *types1.QueryBalanceRequest) (*types1.QueryBalanceResponse, error) { +func (m *MockBankKeeper) Balance(arg0 context.Context, arg1 *types0.QueryBalanceRequest) (*types0.QueryBalanceResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Balance", arg0, arg1) - ret0, _ := ret[0].(*types1.QueryBalanceResponse) + ret0, _ := ret[0].(*types0.QueryBalanceResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -234,10 +233,10 @@ func (mr *MockBankKeeperMockRecorder) DeleteSendEnabled(ctx interface{}, denoms } // DenomMetadata mocks base method. -func (m *MockBankKeeper) DenomMetadata(arg0 context.Context, arg1 *types1.QueryDenomMetadataRequest) (*types1.QueryDenomMetadataResponse, error) { +func (m *MockBankKeeper) DenomMetadata(arg0 context.Context, arg1 *types0.QueryDenomMetadataRequest) (*types0.QueryDenomMetadataResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DenomMetadata", arg0, arg1) - ret0, _ := ret[0].(*types1.QueryDenomMetadataResponse) + ret0, _ := ret[0].(*types0.QueryDenomMetadataResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -249,10 +248,10 @@ func (mr *MockBankKeeperMockRecorder) DenomMetadata(arg0, arg1 interface{}) *gom } // DenomOwners mocks base method. -func (m *MockBankKeeper) DenomOwners(arg0 context.Context, arg1 *types1.QueryDenomOwnersRequest) (*types1.QueryDenomOwnersResponse, error) { +func (m *MockBankKeeper) DenomOwners(arg0 context.Context, arg1 *types0.QueryDenomOwnersRequest) (*types0.QueryDenomOwnersResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DenomOwners", arg0, arg1) - ret0, _ := ret[0].(*types1.QueryDenomOwnersResponse) + ret0, _ := ret[0].(*types0.QueryDenomOwnersResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -264,10 +263,10 @@ func (mr *MockBankKeeperMockRecorder) DenomOwners(arg0, arg1 interface{}) *gomoc } // DenomsMetadata mocks base method. -func (m *MockBankKeeper) DenomsMetadata(arg0 context.Context, arg1 *types1.QueryDenomsMetadataRequest) (*types1.QueryDenomsMetadataResponse, error) { +func (m *MockBankKeeper) DenomsMetadata(arg0 context.Context, arg1 *types0.QueryDenomsMetadataRequest) (*types0.QueryDenomsMetadataResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DenomsMetadata", arg0, arg1) - ret0, _ := ret[0].(*types1.QueryDenomsMetadataResponse) + ret0, _ := ret[0].(*types0.QueryDenomsMetadataResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -279,10 +278,10 @@ func (mr *MockBankKeeperMockRecorder) DenomsMetadata(arg0, arg1 interface{}) *go } // ExportGenesis mocks base method. -func (m *MockBankKeeper) ExportGenesis(arg0 types.Context) *types1.GenesisState { +func (m *MockBankKeeper) ExportGenesis(arg0 types.Context) *types0.GenesisState { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ExportGenesis", arg0) - ret0, _ := ret[0].(*types1.GenesisState) + ret0, _ := ret[0].(*types0.GenesisState) return ret0 } @@ -293,10 +292,10 @@ func (mr *MockBankKeeperMockRecorder) ExportGenesis(arg0 interface{}) *gomock.Ca } // GetAccountsBalances mocks base method. -func (m *MockBankKeeper) GetAccountsBalances(ctx types.Context) []types1.Balance { +func (m *MockBankKeeper) GetAccountsBalances(ctx types.Context) []types0.Balance { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccountsBalances", ctx) - ret0, _ := ret[0].([]types1.Balance) + ret0, _ := ret[0].([]types0.Balance) return ret0 } @@ -321,10 +320,10 @@ func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gom } // GetAllSendEnabledEntries mocks base method. -func (m *MockBankKeeper) GetAllSendEnabledEntries(ctx types.Context) []types1.SendEnabled { +func (m *MockBankKeeper) GetAllSendEnabledEntries(ctx types.Context) []types0.SendEnabled { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllSendEnabledEntries", ctx) - ret0, _ := ret[0].([]types1.SendEnabled) + ret0, _ := ret[0].([]types0.SendEnabled) return ret0 } @@ -377,10 +376,10 @@ func (mr *MockBankKeeperMockRecorder) GetBlockedAddresses() *gomock.Call { } // GetDenomMetaData mocks base method. -func (m *MockBankKeeper) GetDenomMetaData(ctx types.Context, denom string) (types1.Metadata, bool) { +func (m *MockBankKeeper) GetDenomMetaData(ctx types.Context, denom string) (types0.Metadata, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetDenomMetaData", ctx, denom) - ret0, _ := ret[0].(types1.Metadata) + ret0, _ := ret[0].(types0.Metadata) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -408,10 +407,10 @@ func (mr *MockBankKeeperMockRecorder) GetPaginatedTotalSupply(ctx, pagination in } // GetParams mocks base method. -func (m *MockBankKeeper) GetParams(ctx types.Context) types1.Params { +func (m *MockBankKeeper) GetParams(ctx types.Context) types0.Params { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetParams", ctx) - ret0, _ := ret[0].(types1.Params) + ret0, _ := ret[0].(types0.Params) return ret0 } @@ -422,10 +421,10 @@ func (mr *MockBankKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { } // GetSendEnabledEntry mocks base method. -func (m *MockBankKeeper) GetSendEnabledEntry(ctx types.Context, denom string) (types1.SendEnabled, bool) { +func (m *MockBankKeeper) GetSendEnabledEntry(ctx types.Context, denom string) (types0.SendEnabled, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetSendEnabledEntry", ctx, denom) - ret0, _ := ret[0].(types1.SendEnabled) + ret0, _ := ret[0].(types0.SendEnabled) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -493,7 +492,7 @@ func (mr *MockBankKeeperMockRecorder) HasSupply(ctx, denom interface{}) *gomock. } // InitGenesis mocks base method. -func (m *MockBankKeeper) InitGenesis(arg0 types.Context, arg1 *types1.GenesisState) { +func (m *MockBankKeeper) InitGenesis(arg0 types.Context, arg1 *types0.GenesisState) { m.ctrl.T.Helper() m.ctrl.Call(m, "InitGenesis", arg0, arg1) } @@ -505,7 +504,7 @@ func (mr *MockBankKeeperMockRecorder) InitGenesis(arg0, arg1 interface{}) *gomoc } // InputOutputCoins mocks base method. -func (m *MockBankKeeper) InputOutputCoins(ctx types.Context, inputs []types1.Input, outputs []types1.Output) error { +func (m *MockBankKeeper) InputOutputCoins(ctx types.Context, inputs []types0.Input, outputs []types0.Output) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "InputOutputCoins", ctx, inputs, outputs) ret0, _ := ret[0].(error) @@ -590,7 +589,7 @@ func (mr *MockBankKeeperMockRecorder) IterateAllBalances(ctx, cb interface{}) *g } // IterateAllDenomMetaData mocks base method. -func (m *MockBankKeeper) IterateAllDenomMetaData(ctx types.Context, cb func(types1.Metadata) bool) { +func (m *MockBankKeeper) IterateAllDenomMetaData(ctx types.Context, cb func(types0.Metadata) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAllDenomMetaData", ctx, cb) } @@ -654,10 +653,10 @@ func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amt interface{} } // Params mocks base method. -func (m *MockBankKeeper) Params(arg0 context.Context, arg1 *types1.QueryParamsRequest) (*types1.QueryParamsResponse, error) { +func (m *MockBankKeeper) Params(arg0 context.Context, arg1 *types0.QueryParamsRequest) (*types0.QueryParamsResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Params", arg0, arg1) - ret0, _ := ret[0].(*types1.QueryParamsResponse) + ret0, _ := ret[0].(*types0.QueryParamsResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -725,10 +724,10 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToModule(ctx, senderMod } // SendEnabled mocks base method. -func (m *MockBankKeeper) SendEnabled(arg0 context.Context, arg1 *types1.QuerySendEnabledRequest) (*types1.QuerySendEnabledResponse, error) { +func (m *MockBankKeeper) SendEnabled(arg0 context.Context, arg1 *types0.QuerySendEnabledRequest) (*types0.QuerySendEnabledResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendEnabled", arg0, arg1) - ret0, _ := ret[0].(*types1.QuerySendEnabledResponse) + ret0, _ := ret[0].(*types0.QuerySendEnabledResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -740,7 +739,7 @@ func (mr *MockBankKeeperMockRecorder) SendEnabled(arg0, arg1 interface{}) *gomoc } // SetAllSendEnabled mocks base method. -func (m *MockBankKeeper) SetAllSendEnabled(ctx types.Context, sendEnableds []*types1.SendEnabled) { +func (m *MockBankKeeper) SetAllSendEnabled(ctx types.Context, sendEnableds []*types0.SendEnabled) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetAllSendEnabled", ctx, sendEnableds) } @@ -752,7 +751,7 @@ func (mr *MockBankKeeperMockRecorder) SetAllSendEnabled(ctx, sendEnableds interf } // SetDenomMetaData mocks base method. -func (m *MockBankKeeper) SetDenomMetaData(ctx types.Context, denomMetaData types1.Metadata) { +func (m *MockBankKeeper) SetDenomMetaData(ctx types.Context, denomMetaData types0.Metadata) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetDenomMetaData", ctx, denomMetaData) } @@ -764,7 +763,7 @@ func (mr *MockBankKeeperMockRecorder) SetDenomMetaData(ctx, denomMetaData interf } // SetParams mocks base method. -func (m *MockBankKeeper) SetParams(ctx types.Context, params types1.Params) error { +func (m *MockBankKeeper) SetParams(ctx types.Context, params types0.Params) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetParams", ctx, params) ret0, _ := ret[0].(error) @@ -790,10 +789,10 @@ func (mr *MockBankKeeperMockRecorder) SetSendEnabled(ctx, denom, value interface } // SpendableBalances mocks base method. -func (m *MockBankKeeper) SpendableBalances(arg0 context.Context, arg1 *types1.QuerySpendableBalancesRequest) (*types1.QuerySpendableBalancesResponse, error) { +func (m *MockBankKeeper) SpendableBalances(arg0 context.Context, arg1 *types0.QuerySpendableBalancesRequest) (*types0.QuerySpendableBalancesResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SpendableBalances", arg0, arg1) - ret0, _ := ret[0].(*types1.QuerySpendableBalancesResponse) + ret0, _ := ret[0].(*types0.QuerySpendableBalancesResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -833,10 +832,10 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom } // SupplyOf mocks base method. -func (m *MockBankKeeper) SupplyOf(arg0 context.Context, arg1 *types1.QuerySupplyOfRequest) (*types1.QuerySupplyOfResponse, error) { +func (m *MockBankKeeper) SupplyOf(arg0 context.Context, arg1 *types0.QuerySupplyOfRequest) (*types0.QuerySupplyOfResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SupplyOf", arg0, arg1) - ret0, _ := ret[0].(*types1.QuerySupplyOfResponse) + ret0, _ := ret[0].(*types0.QuerySupplyOfResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -848,10 +847,10 @@ func (mr *MockBankKeeperMockRecorder) SupplyOf(arg0, arg1 interface{}) *gomock.C } // TotalSupply mocks base method. -func (m *MockBankKeeper) TotalSupply(arg0 context.Context, arg1 *types1.QueryTotalSupplyRequest) (*types1.QueryTotalSupplyResponse, error) { +func (m *MockBankKeeper) TotalSupply(arg0 context.Context, arg1 *types0.QueryTotalSupplyRequest) (*types0.QueryTotalSupplyResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "TotalSupply", arg0, arg1) - ret0, _ := ret[0].(*types1.QueryTotalSupplyResponse) + ret0, _ := ret[0].(*types0.QueryTotalSupplyResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -956,7 +955,7 @@ func (mr *MockStakingKeeperMockRecorder) BondDenom(ctx interface{}) *gomock.Call } // IterateBondedValidatorsByPower mocks base method. -func (m *MockStakingKeeper) IterateBondedValidatorsByPower(arg0 types.Context, arg1 func(int64, types2.ValidatorI) bool) { +func (m *MockStakingKeeper) IterateBondedValidatorsByPower(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateBondedValidatorsByPower", arg0, arg1) } @@ -968,7 +967,7 @@ func (mr *MockStakingKeeperMockRecorder) IterateBondedValidatorsByPower(arg0, ar } // IterateDelegations mocks base method. -func (m *MockStakingKeeper) IterateDelegations(ctx types.Context, delegator types.AccAddress, fn func(int64, types2.DelegationI) bool) { +func (m *MockStakingKeeper) IterateDelegations(ctx types.Context, delegator types.AccAddress, fn func(int64, types1.DelegationI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateDelegations", ctx, delegator, fn) } diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index 1e8a106b34d3..23add0cfd0ba 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -4,7 +4,6 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -33,10 +32,10 @@ type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI + GetModuleAccount(ctx sdk.Context, name string) sdk.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, types.ModuleAccountI) + SetModuleAccount(sdk.Context, sdk.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/group/migrations/v2/gen_state.go b/x/group/migrations/v2/gen_state.go index a8bce3a1be78..639d71b081ed 100644 --- a/x/group/migrations/v2/gen_state.go +++ b/x/group/migrations/v2/gen_state.go @@ -3,6 +3,7 @@ package v2 import ( "encoding/binary" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -19,7 +20,7 @@ func MigrateGenState(oldState *authtypes.GenesisState) *authtypes.GenesisState { groupPolicyAccountCounter := uint64(0) for i, acc := range accounts { - modAcc, ok := acc.(authtypes.ModuleAccountI) + modAcc, ok := acc.(sdk.ModuleAccountI) if !ok { continue } diff --git a/x/mint/testutil/expected_keepers_mocks.go b/x/mint/testutil/expected_keepers_mocks.go index c174f75d97cb..47af766c6b9b 100644 --- a/x/mint/testutil/expected_keepers_mocks.go +++ b/x/mint/testutil/expected_keepers_mocks.go @@ -9,7 +9,6 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -88,10 +87,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types0.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) - ret0, _ := ret[0].(types0.ModuleAccountI) + ret0, _ := ret[0].(types.ModuleAccountI) return ret0 } @@ -116,7 +115,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types0.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 types.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 68fb5765bf6d..46c2f4ed93a0 100644 --- a/x/mint/types/expected_keepers.go +++ b/x/mint/types/expected_keepers.go @@ -2,8 +2,8 @@ package types // noalias import ( "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" ) // StakingKeeper defines the expected staking keeper @@ -17,8 +17,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, types.ModuleAccountI) - GetModuleAccount(ctx sdk.Context, moduleName string) types.ModuleAccountI + SetModuleAccount(sdk.Context, sdk.ModuleAccountI) + GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI } // BankKeeper defines the contract needed to be fulfilled for banking and supply diff --git a/x/staking/keeper/pool.go b/x/staking/keeper/pool.go index ae2b089c2eee..722f6690d0f2 100644 --- a/x/staking/keeper/pool.go +++ b/x/staking/keeper/pool.go @@ -2,18 +2,18 @@ package keeper import ( "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/staking/types" ) // GetBondedPool returns the bonded tokens pool's module account -func (k Keeper) GetBondedPool(ctx sdk.Context) (bondedPool authtypes.ModuleAccountI) { +func (k Keeper) GetBondedPool(ctx sdk.Context) (bondedPool sdk.ModuleAccountI) { return k.authKeeper.GetModuleAccount(ctx, types.BondedPoolName) } // GetNotBondedPool returns the not bonded tokens pool's module account -func (k Keeper) GetNotBondedPool(ctx sdk.Context) (notBondedPool authtypes.ModuleAccountI) { +func (k Keeper) GetNotBondedPool(ctx sdk.Context) (notBondedPool sdk.ModuleAccountI) { return k.authKeeper.GetModuleAccount(ctx, types.NotBondedPoolName) } diff --git a/x/staking/testutil/expected_keepers_mocks.go b/x/staking/testutil/expected_keepers_mocks.go index 03f8cf96f47d..3c69110153cc 100644 --- a/x/staking/testutil/expected_keepers_mocks.go +++ b/x/staking/testutil/expected_keepers_mocks.go @@ -9,8 +9,7 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/cosmos-sdk/x/auth/types" - types1 "github.com/cosmos/cosmos-sdk/x/staking/types" + types0 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -103,10 +102,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types0.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) - ret0, _ := ret[0].(types0.ModuleAccountI) + ret0, _ := ret[0].(types.ModuleAccountI) return ret0 } @@ -143,7 +142,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{ } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types0.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) } @@ -327,10 +326,10 @@ func (m *MockValidatorSet) EXPECT() *MockValidatorSetMockRecorder { } // Delegation mocks base method. -func (m *MockValidatorSet) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types1.DelegationI { +func (m *MockValidatorSet) Delegation(arg0 types.Context, arg1 types.AccAddress, arg2 types.ValAddress) types0.DelegationI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2) - ret0, _ := ret[0].(types1.DelegationI) + ret0, _ := ret[0].(types0.DelegationI) return ret0 } @@ -341,7 +340,7 @@ func (mr *MockValidatorSetMockRecorder) Delegation(arg0, arg1, arg2 interface{}) } // IterateBondedValidatorsByPower mocks base method. -func (m *MockValidatorSet) IterateBondedValidatorsByPower(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { +func (m *MockValidatorSet) IterateBondedValidatorsByPower(arg0 types.Context, arg1 func(int64, types0.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateBondedValidatorsByPower", arg0, arg1) } @@ -353,7 +352,7 @@ func (mr *MockValidatorSetMockRecorder) IterateBondedValidatorsByPower(arg0, arg } // IterateLastValidators mocks base method. -func (m *MockValidatorSet) IterateLastValidators(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { +func (m *MockValidatorSet) IterateLastValidators(arg0 types.Context, arg1 func(int64, types0.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateLastValidators", arg0, arg1) } @@ -365,7 +364,7 @@ func (mr *MockValidatorSetMockRecorder) IterateLastValidators(arg0, arg1 interfa } // IterateValidators mocks base method. -func (m *MockValidatorSet) IterateValidators(arg0 types.Context, arg1 func(int64, types1.ValidatorI) bool) { +func (m *MockValidatorSet) IterateValidators(arg0 types.Context, arg1 func(int64, types0.ValidatorI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateValidators", arg0, arg1) } @@ -417,7 +416,7 @@ func (mr *MockValidatorSetMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 inter } // SlashWithInfractionReason mocks base method. -func (m *MockValidatorSet) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types1.Infraction) math.Int { +func (m *MockValidatorSet) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types0.Infraction) math.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(math.Int) @@ -471,10 +470,10 @@ func (mr *MockValidatorSetMockRecorder) Unjail(arg0, arg1 interface{}) *gomock.C } // Validator mocks base method. -func (m *MockValidatorSet) Validator(arg0 types.Context, arg1 types.ValAddress) types1.ValidatorI { +func (m *MockValidatorSet) Validator(arg0 types.Context, arg1 types.ValAddress) types0.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types0.ValidatorI) return ret0 } @@ -485,10 +484,10 @@ func (mr *MockValidatorSetMockRecorder) Validator(arg0, arg1 interface{}) *gomoc } // ValidatorByConsAddr mocks base method. -func (m *MockValidatorSet) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types1.ValidatorI { +func (m *MockValidatorSet) ValidatorByConsAddr(arg0 types.Context, arg1 types.ConsAddress) types0.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) - ret0, _ := ret[0].(types1.ValidatorI) + ret0, _ := ret[0].(types0.ValidatorI) return ret0 } @@ -522,10 +521,10 @@ func (m *MockDelegationSet) EXPECT() *MockDelegationSetMockRecorder { } // GetValidatorSet mocks base method. -func (m *MockDelegationSet) GetValidatorSet() types1.ValidatorSet { +func (m *MockDelegationSet) GetValidatorSet() types0.ValidatorSet { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetValidatorSet") - ret0, _ := ret[0].(types1.ValidatorSet) + ret0, _ := ret[0].(types0.ValidatorSet) return ret0 } @@ -536,7 +535,7 @@ func (mr *MockDelegationSetMockRecorder) GetValidatorSet() *gomock.Call { } // IterateDelegations mocks base method. -func (m *MockDelegationSet) IterateDelegations(ctx types.Context, delegator types.AccAddress, fn func(int64, types1.DelegationI) bool) { +func (m *MockDelegationSet) IterateDelegations(ctx types.Context, delegator types.AccAddress, fn func(int64, types0.DelegationI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateDelegations", ctx, delegator, fn) } diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index 1c32d6e0b3f2..5a9e22344c49 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -4,7 +4,6 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // DistributionKeeper expected distribution keeper (noalias) @@ -19,10 +18,10 @@ type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI + GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, authtypes.ModuleAccountI) + SetModuleAccount(sdk.Context, sdk.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. From 5454b01a62af9ae897fb4074ea11308c5a782234 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Dec 2022 17:37:20 +0530 Subject: [PATCH 19/21] fix lint --- x/auth/types/account.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auth/types/account.go b/x/auth/types/account.go index ad7655dc59dc..075c4fddefa9 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -281,7 +281,7 @@ type AccountI interface { // ModuleAccountI defines an account interface for modules that hold tokens in // an escrow. // -// Deprecate: Use `ModuleAccountI` from types package instead. +// Deprecated: Use `ModuleAccountI` from types package instead. type ModuleAccountI interface { sdk.ModuleAccountI } From 03a928d2e3db0cba174e67d3d6deb2121bb5843d Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 3 Jan 2023 14:41:20 +0530 Subject: [PATCH 20/21] try fixing rosetta test --- types/{dependencies.go => account.go} | 0 x/auth/types/codec.go | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename types/{dependencies.go => account.go} (100%) diff --git a/types/dependencies.go b/types/account.go similarity index 100% rename from types/dependencies.go rename to types/account.go diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index 0376d3c63371..50a049faa8ab 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -34,7 +34,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterInterface( "cosmos.auth.v1beta1.AccountI", - (*sdk.AccountI)(nil), + (*AccountI)(nil), &BaseAccount{}, &ModuleAccount{}, ) From 0e831de2ba4ab077ffdf3a050e60054cb02e6cf1 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 3 Jan 2023 14:49:13 +0530 Subject: [PATCH 21/21] wip: fix tests --- x/auth/types/codec.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index 50a049faa8ab..554e5dc73f5a 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -39,6 +39,13 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &ModuleAccount{}, ) + registry.RegisterInterface( + "cosmos.auth.v1beta1.AccountI", + (*sdk.AccountI)(nil), + &BaseAccount{}, + &ModuleAccount{}, + ) + registry.RegisterInterface( "cosmos.auth.v1beta1.GenesisAccount", (*GenesisAccount)(nil),