refactor!: use KVStoreService in x/auth (#15520)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Facundo Medica 2023-03-27 15:57:02 -03:00 committed by GitHub
parent 6cc4e22c2f
commit d29e8eb4f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 404 additions and 207 deletions

View File

@ -103,6 +103,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### API Breaking Changes
* (x/auth) [#15517](https://github.com/cosmos/cosmos-sdk/pull/15517) `NewAccountKeeper` now takes a `KVStoreService` instead of a `StoreKey` and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context`.
* (x/consensus) [#15517](https://github.com/cosmos/cosmos-sdk/pull/15517) `NewKeeper` now takes a `KVStoreService` instead of a `StoreKey`.
* (x/bank) [#15477](https://github.com/cosmos/cosmos-sdk/pull/15477) `banktypes.NewMsgMultiSend` and `keeper.InputOutputCoins` only accept one input.
* (mempool) [#15328](https://github.com/cosmos/cosmos-sdk/pull/15328) The `PriorityNonceMempool` is now generic over type `C comparable` and takes a single `PriorityNonceMempoolConfig[C]` argument. See `DefaultPriorityNonceMempoolConfig` for how to construct the configuration and a `TxPriority` type.

View File

@ -62,6 +62,25 @@ The `gogoproto.goproto_stringer = false` annotation has been removed from most p
Previously, all modules were required to be set in `OrderBeginBlockers`, `OrderEndBlockers` and `OrderInitGenesis / OrderExportGenesis` in `app.go` / `app_config.go`.
This is no longer the case, the assertion has been loosened to only require modules implementing, respectively, the `module.BeginBlockAppModule`, `module.EndBlockAppModule` and `module.HasGenesis` interfaces.
### Modules Keepers
The following modules `NewKeeper` function now take a `KVStoreService` instead of a `StoreKey`:
- `x/auth`
- `x/consensus`
When not using depinject, the `runtime.NewKVStoreService` method can be used to create a `KVStoreService` from a `StoreKey`:
```diff
- app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
+ app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
```
### Packages
#### Store
@ -75,19 +94,14 @@ All the store imports are now renamed to use `cosmossdk.io/store` instead of `gi
### Modules
#### `x/auth`
Methods in the `AccountKeeper` now use `context.Context` instead of `sdk.Context`. Any module that has an interface for it will need to update and re-generate mocks if needed.
#### `x/capability`
Capability was moved to [IBC-GO](https://github.com/cosmos/ibc-go). IBC V8 will contain the necessary changes to incorporate the new module location
#### `x/consensus`
The `NewKeeper` method now takes a `KVStoreService` instead of a `StoreKey`. When not using depinject, the `runtime.NewKVStoreService` method can be used to create a `KVStoreService` from a `StoreKey`.
```diff
- app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
+ app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String())
```
#### `x/gov`
##### Expedited Proposals

View File

@ -2,11 +2,14 @@ package runtime
import (
"context"
"io"
"cosmossdk.io/core/store"
storetypes "cosmossdk.io/store/types"
dbm "github.com/cosmos/cosmos-db"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -90,3 +93,72 @@ func (store coreKVStore) Iterator(start, end []byte) (store.Iterator, error) {
func (store coreKVStore) ReverseIterator(start, end []byte) (store.Iterator, error) {
return store.kvStore.ReverseIterator(start, end), nil
}
// Adapter
var _ storetypes.KVStore = kvStoreAdapter{}
type kvStoreAdapter struct {
store store.KVStore
}
func (kvStoreAdapter) CacheWrap() storetypes.CacheWrap {
panic("unimplemented")
}
func (kvStoreAdapter) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap {
panic("unimplemented")
}
func (kvStoreAdapter) GetStoreType() storetypes.StoreType {
panic("unimplemented")
}
func (s kvStoreAdapter) Delete(key []byte) {
err := s.store.Delete(key)
if err != nil {
panic(err)
}
}
func (s kvStoreAdapter) Get(key []byte) []byte {
bz, err := s.store.Get(key)
if err != nil {
panic(err)
}
return bz
}
func (s kvStoreAdapter) Has(key []byte) bool {
has, err := s.store.Has(key)
if err != nil {
panic(err)
}
return has
}
func (s kvStoreAdapter) Set(key []byte, value []byte) {
err := s.store.Set(key, value)
if err != nil {
panic(err)
}
}
func (s kvStoreAdapter) Iterator(start []byte, end []byte) dbm.Iterator {
it, err := s.store.Iterator(start, end)
if err != nil {
panic(err)
}
return it
}
func (s kvStoreAdapter) ReverseIterator(start []byte, end []byte) dbm.Iterator {
it, err := s.store.ReverseIterator(start, end)
if err != nil {
panic(err)
}
return it
}
func KVStoreAdapter(store store.KVStore) storetypes.KVStore {
return &kvStoreAdapter{store}
}

View File

@ -289,7 +289,7 @@ func NewSimApp(
bApp.SetParamStore(&app.ConsensusParamsKeeper)
// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, keys[authtypes.StoreKey], authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,

View File

@ -19,6 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
"github.com/cosmos/cosmos-sdk/testutil/sims"
@ -158,8 +159,10 @@ func initKeepersWithmAccPerms(f *fixture, blockedAddrs map[string]bool) (authkee
maccPerms[authtypes.Minter] = []string{authtypes.Minter}
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
maccPerms[randomPerm] = []string{"random"}
storeService := runtime.NewKVStoreService(f.fetchStoreKey(authtypes.StoreKey).(*storetypes.KVStoreKey))
authKeeper := authkeeper.NewAccountKeeper(
appCodec, f.fetchStoreKey(types.StoreKey), authtypes.ProtoBaseAccount,
appCodec, storeService, authtypes.ProtoBaseAccount,
maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
bankKeeper := keeper.NewBaseKeeper(
@ -1194,8 +1197,9 @@ func TestBalanceTrackingEvents(t *testing.T) {
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
storeService := runtime.NewKVStoreService(f.fetchStoreKey(authtypes.StoreKey).(*storetypes.KVStoreKey))
f.accountKeeper = authkeeper.NewAccountKeeper(
f.appCodec, f.fetchStoreKey(authtypes.StoreKey),
f.appCodec, storeService,
authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
@ -1324,9 +1328,10 @@ func TestMintCoinRestrictions(t *testing.T) {
maccPerms := make(map[string][]string)
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
storeService := runtime.NewKVStoreService(f.fetchStoreKey(authtypes.StoreKey).(*storetypes.KVStoreKey))
f.accountKeeper = authkeeper.NewAccountKeeper(
f.appCodec, f.fetchStoreKey(authtypes.StoreKey),
f.appCodec, storeService,
authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

View File

@ -1,6 +1,8 @@
package ante
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
@ -8,9 +10,9 @@ import (
// AccountKeeper defines the contract needed for AccountKeeper related APIs.
// Interface provides support to use non-sdk AccountKeeper for AnteHandler's decorators.
type AccountKeeper interface {
GetParams(ctx sdk.Context) (params types.Params)
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
SetAccount(ctx sdk.Context, acc sdk.AccountI)
GetParams(ctx context.Context) (params types.Params)
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
SetAccount(ctx context.Context, acc sdk.AccountI)
GetModuleAddress(moduleName string) sdk.AccAddress
}

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
types "github.com/cosmos/cosmos-sdk/types"
@ -36,7 +37,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -64,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{}
}
// GetParams mocks base method.
func (m *MockAccountKeeper) GetParams(ctx types.Context) types0.Params {
func (m *MockAccountKeeper) GetParams(ctx context.Context) types0.Params {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetParams", ctx)
ret0, _ := ret[0].(types0.Params)
@ -78,7 +79,7 @@ func (mr *MockAccountKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) {
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", ctx, acc)
}

View File

@ -11,6 +11,8 @@ import (
// ref: https://github.com/cosmos/cosmos-sdk/issues/14647
_ "cosmossdk.io/api/cosmos/bank/v1beta1"
_ "cosmossdk.io/api/cosmos/crypto/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
storetypes "cosmossdk.io/store/types"
@ -77,7 +79,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
}
suite.accountKeeper = keeper.NewAccountKeeper(
suite.encCfg.Codec, key, types.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(),
suite.encCfg.Codec, runtime.NewKVStoreService(key), types.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(),
)
suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName)
err := suite.accountKeeper.SetParams(suite.ctx, types.DefaultParams())

View File

@ -1,6 +1,8 @@
package keeper
import (
"context"
storetypes "cosmossdk.io/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -8,7 +10,7 @@ import (
)
// NewAccountWithAddress implements AccountKeeperI.
func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI {
func (ak AccountKeeper) NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI {
acc := ak.proto()
err := acc.SetAddress(addr)
if err != nil {
@ -19,7 +21,7 @@ func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddre
}
// NewAccount sets the next account number to a given account interface
func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc sdk.AccountI) sdk.AccountI {
func (ak AccountKeeper) NewAccount(ctx context.Context, acc sdk.AccountI) sdk.AccountI {
if err := acc.SetAccountNumber(ak.NextAccountNumber(ctx)); err != nil {
panic(err)
}
@ -28,21 +30,33 @@ func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc sdk.AccountI) sdk.Accoun
}
// HasAccount implements AccountKeeperI.
func (ak AccountKeeper) HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
store := ctx.KVStore(ak.storeKey)
return store.Has(types.AddressStoreKey(addr))
func (ak AccountKeeper) HasAccount(ctx context.Context, addr sdk.AccAddress) bool {
store := ak.storeService.OpenKVStore(ctx)
has, err := store.Has(types.AddressStoreKey(addr))
if err != nil {
panic(err)
}
return has
}
// HasAccountAddressByID checks account address exists by id.
func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool {
store := ctx.KVStore(ak.storeKey)
return store.Has(types.AccountNumberStoreKey(id))
func (ak AccountKeeper) HasAccountAddressByID(ctx context.Context, id uint64) bool {
store := ak.storeService.OpenKVStore(ctx)
has, err := store.Has(types.AccountNumberStoreKey(id))
if err != nil {
panic(err)
}
return has
}
// GetAccount implements AccountKeeperI.
func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI {
store := ctx.KVStore(ak.storeKey)
bz := store.Get(types.AddressStoreKey(addr))
func (ak AccountKeeper) GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI {
store := ak.storeService.OpenKVStore(ctx)
bz, err := store.Get(types.AddressStoreKey(addr))
if err != nil {
panic(err)
}
if bz == nil {
return nil
}
@ -51,9 +65,13 @@ func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.Acc
}
// GetAccountAddressById returns account address by id.
func (ak AccountKeeper) GetAccountAddressByID(ctx sdk.Context, id uint64) string {
store := ctx.KVStore(ak.storeKey)
bz := store.Get(types.AccountNumberStoreKey(id))
func (ak AccountKeeper) GetAccountAddressByID(ctx context.Context, id uint64) string {
store := ak.storeService.OpenKVStore(ctx)
bz, err := store.Get(types.AccountNumberStoreKey(id))
if err != nil {
panic(err)
}
if bz == nil {
return ""
}
@ -61,7 +79,7 @@ func (ak AccountKeeper) GetAccountAddressByID(ctx sdk.Context, id uint64) string
}
// GetAllAccounts returns all accounts in the accountKeeper.
func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []sdk.AccountI) {
func (ak AccountKeeper) GetAllAccounts(ctx context.Context) (accounts []sdk.AccountI) {
ak.IterateAccounts(ctx, func(acc sdk.AccountI) (stop bool) {
accounts = append(accounts, acc)
return false
@ -71,9 +89,9 @@ func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []sdk.AccountI
}
// SetAccount implements AccountKeeperI.
func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc sdk.AccountI) {
func (ak AccountKeeper) SetAccount(ctx context.Context, acc sdk.AccountI) {
addr := acc.GetAddress()
store := ctx.KVStore(ak.storeKey)
store := ak.storeService.OpenKVStore(ctx)
bz, err := ak.MarshalAccount(acc)
if err != nil {
@ -86,18 +104,28 @@ func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc sdk.AccountI) {
// RemoveAccount removes an account for the account mapper store.
// NOTE: this will cause supply invariant violation if called
func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc sdk.AccountI) {
func (ak AccountKeeper) RemoveAccount(ctx context.Context, acc sdk.AccountI) {
addr := acc.GetAddress()
store := ctx.KVStore(ak.storeKey)
store.Delete(types.AddressStoreKey(addr))
store.Delete(types.AccountNumberStoreKey(acc.GetAccountNumber()))
store := ak.storeService.OpenKVStore(ctx)
err := store.Delete(types.AddressStoreKey(addr))
if err != nil {
panic(err)
}
err = store.Delete(types.AccountNumberStoreKey(acc.GetAccountNumber()))
if err != nil {
panic(err)
}
}
// IterateAccounts iterates over all the stored accounts and performs a callback function.
// Stops iteration when callback returns true.
func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool)) {
store := ctx.KVStore(ak.storeKey)
iterator := storetypes.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix)
func (ak AccountKeeper) IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) (stop bool)) {
store := ak.storeService.OpenKVStore(ctx)
iterator, err := store.Iterator(types.AddressStoreKeyPrefix, storetypes.PrefixEndBytes(types.AddressStoreKeyPrefix))
if err != nil {
panic(err)
}
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {

View File

@ -5,13 +5,16 @@ import (
"sort"
"testing"
storetypes "cosmossdk.io/store/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/suite"
"pgregory.net/rapid"
corestore "cosmossdk.io/core/store"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -25,6 +28,7 @@ type DeterministicTestSuite struct {
suite.Suite
key *storetypes.KVStoreKey
storeService corestore.KVStoreService
ctx sdk.Context
queryClient types.QueryClient
accountKeeper keeper.AccountKeeper
@ -47,6 +51,7 @@ func (suite *DeterministicTestSuite) SetupTest() {
suite.Require()
key := storetypes.NewKVStoreKey(types.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{})
@ -61,7 +66,7 @@ func (suite *DeterministicTestSuite) SetupTest() {
suite.accountKeeper = keeper.NewAccountKeeper(
suite.encCfg.Codec,
key,
storeService,
types.ProtoBaseAccount,
maccPerms,
"cosmos",
@ -73,6 +78,7 @@ func (suite *DeterministicTestSuite) SetupTest() {
suite.queryClient = types.NewQueryClient(queryHelper)
suite.key = key
suite.storeService = storeService
suite.maccPerms = maccPerms
}
@ -280,7 +286,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() {
ak := keeper.NewAccountKeeper(
suite.encCfg.Codec,
suite.key,
suite.storeService,
types.ProtoBaseAccount,
maccPerms,
"cosmos",
@ -326,7 +332,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() {
ak := keeper.NewAccountKeeper(
suite.encCfg.Codec,
suite.key,
suite.storeService,
types.ProtoBaseAccount,
maccPerms,
"cosmos",

View File

@ -8,6 +8,7 @@ import (
"cosmossdk.io/store/prefix"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/types/query"
"google.golang.org/grpc/codes"
@ -40,14 +41,13 @@ func (ak AccountKeeper) AccountAddressByID(c context.Context, req *types.QueryAc
return &types.QueryAccountAddressByIDResponse{AccountAddress: address}, nil
}
func (ak AccountKeeper) Accounts(c context.Context, req *types.QueryAccountsRequest) (*types.QueryAccountsResponse, error) {
func (ak AccountKeeper) Accounts(ctx context.Context, req *types.QueryAccountsRequest) (*types.QueryAccountsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
ctx := sdk.UnwrapSDKContext(c)
store := ctx.KVStore(ak.storeKey)
accountsStore := prefix.NewStore(store, types.AddressStoreKeyPrefix)
store := ak.storeService.OpenKVStore(ctx)
accountsStore := prefix.NewStore(runtime.KVStoreAdapter(store), types.AddressStoreKeyPrefix)
var accounts []*codectypes.Any
pageRes, err := query.Paginate(accountsStore, req.Pagination, func(key, value []byte) error {

View File

@ -1,14 +1,15 @@
package keeper
import (
"context"
"fmt"
"cosmossdk.io/log"
gogotypes "github.com/cosmos/gogoproto/types"
"cosmossdk.io/core/address"
"cosmossdk.io/core/store"
errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -20,34 +21,34 @@ import (
// AccountKeeperI is the interface contract that x/auth's keeper implements.
type AccountKeeperI interface {
// Return a new account with the next account number and the specified address. Does not save the new account to the store.
NewAccountWithAddress(sdk.Context, sdk.AccAddress) sdk.AccountI
NewAccountWithAddress(context.Context, sdk.AccAddress) sdk.AccountI
// Return a new account with the next account number. Does not save the new account to the store.
NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI
NewAccount(context.Context, sdk.AccountI) sdk.AccountI
// Check if an account exists in the store.
HasAccount(sdk.Context, sdk.AccAddress) bool
HasAccount(context.Context, sdk.AccAddress) bool
// Retrieve an account from the store.
GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI
GetAccount(context.Context, sdk.AccAddress) sdk.AccountI
// Set an account in the store.
SetAccount(sdk.Context, sdk.AccountI)
SetAccount(context.Context, sdk.AccountI)
// Remove an account from the store.
RemoveAccount(sdk.Context, sdk.AccountI)
RemoveAccount(context.Context, sdk.AccountI)
// Iterate over all accounts, calling the provided function. Stop iteration when it returns true.
IterateAccounts(sdk.Context, func(sdk.AccountI) bool)
IterateAccounts(context.Context, func(sdk.AccountI) bool)
// Fetch the public key of an account at a specified address
GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error)
GetPubKey(context.Context, sdk.AccAddress) (cryptotypes.PubKey, error)
// Fetch the sequence of an account at a specified address.
GetSequence(sdk.Context, sdk.AccAddress) (uint64, error)
GetSequence(context.Context, sdk.AccAddress) (uint64, error)
// Fetch the next account number, and increment the internal counter.
NextAccountNumber(sdk.Context) uint64
NextAccountNumber(context.Context) uint64
// GetModulePermissions fetches per-module account permissions
GetModulePermissions() map[string]types.PermissionsForAddress
@ -56,9 +57,9 @@ type AccountKeeperI interface {
// AccountKeeper encodes/decodes accounts using the go-amino (binary)
// encoding/decoding library.
type AccountKeeper struct {
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
permAddrs map[string]types.PermissionsForAddress
storeService store.KVStoreService
cdc codec.BinaryCodec
permAddrs map[string]types.PermissionsForAddress
// The prototypical AccountI constructor.
proto func() sdk.AccountI
@ -78,7 +79,7 @@ var _ AccountKeeperI = &AccountKeeper{}
// and don't have to fit into any predefined structure. This auth module does not use account permissions internally, though other modules
// may use auth.Keeper to access the accounts permissions map.
func NewAccountKeeper(
cdc codec.BinaryCodec, storeKey storetypes.StoreKey, proto func() sdk.AccountI,
cdc codec.BinaryCodec, storeService store.KVStoreService, proto func() sdk.AccountI,
maccPerms map[string][]string, bech32Prefix string, authority string,
) AccountKeeper {
permAddrs := make(map[string]types.PermissionsForAddress)
@ -89,12 +90,12 @@ func NewAccountKeeper(
bech32Codec := NewBech32Codec(bech32Prefix)
return AccountKeeper{
storeKey: storeKey,
proto: proto,
cdc: cdc,
permAddrs: permAddrs,
addressCdc: bech32Codec,
authority: authority,
storeService: storeService,
proto: proto,
cdc: cdc,
permAddrs: permAddrs,
addressCdc: bech32Codec,
authority: authority,
}
}
@ -110,12 +111,12 @@ func (ak AccountKeeper) GetAddressCodec() address.Codec {
}
// Logger returns a module-specific logger.
func (ak AccountKeeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", "x/"+types.ModuleName)
func (ak AccountKeeper) Logger(ctx context.Context) log.Logger {
return sdk.UnwrapSDKContext(ctx).Logger().With("module", "x/"+types.ModuleName)
}
// GetPubKey Returns the PubKey of the account at address
func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) {
func (ak AccountKeeper) GetPubKey(ctx context.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) {
acc := ak.GetAccount(ctx, addr)
if acc == nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
@ -125,7 +126,7 @@ func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptot
}
// GetSequence Returns the Sequence of the account at address
func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, error) {
func (ak AccountKeeper) GetSequence(ctx context.Context, addr sdk.AccAddress) (uint64, error) {
acc := ak.GetAccount(ctx, addr)
if acc == nil {
return 0, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
@ -136,11 +137,15 @@ func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint6
// NextAccountNumber returns and increments the global account number counter.
// If the global account number is not set, it initializes it with value 0.
func (ak AccountKeeper) NextAccountNumber(ctx sdk.Context) uint64 {
func (ak AccountKeeper) NextAccountNumber(ctx context.Context) uint64 {
var accNumber uint64
store := ctx.KVStore(ak.storeKey)
store := ak.storeService.OpenKVStore(ctx)
bz := store.Get(types.GlobalAccountNumberKey)
bz, err := store.Get(types.GlobalAccountNumberKey)
if err != nil {
// panics only on nil key, which should not be possible
panic(err)
}
if bz == nil {
// initialize the account numbers
accNumber = 0
@ -201,7 +206,7 @@ func (ak AccountKeeper) GetModuleAddressAndPermissions(moduleName string) (addr
// GetModuleAccountAndPermissions gets the module account from the auth account store and its
// registered permissions
func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleName string) (sdk.ModuleAccountI, []string) {
func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (sdk.ModuleAccountI, []string) {
addr, perms := ak.GetModuleAddressAndPermissions(moduleName)
if addr == nil {
return nil, []string{}
@ -226,13 +231,13 @@ func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleNa
// GetModuleAccount gets the module account from the auth account store, if the account does not
// exist in the AccountKeeper, then it is created.
func (ak AccountKeeper) GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI {
func (ak AccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI {
acc, _ := ak.GetModuleAccountAndPermissions(ctx, moduleName)
return acc
}
// SetModuleAccount sets the module account to the auth account store
func (ak AccountKeeper) SetModuleAccount(ctx sdk.Context, macc sdk.ModuleAccountI) {
func (ak AccountKeeper) SetModuleAccount(ctx context.Context, macc sdk.ModuleAccountI) {
ak.SetAccount(ctx, macc)
}

View File

@ -3,6 +3,8 @@ package keeper_test
import (
"testing"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/stretchr/testify/suite"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
@ -46,6 +48,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
key := storetypes.NewKVStoreKey(types.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{})
@ -60,7 +63,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.accountKeeper = keeper.NewAccountKeeper(
suite.encCfg.Codec,
key,
storeService,
types.ProtoBaseAccount,
maccPerms,
"cosmos",

View File

@ -48,7 +48,7 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error {
// Migrate2to3 migrates from consensus version 2 to version 3. Specifically, for each account
// we index the account's ID to their address.
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
return v3.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc)
}
// Migrate3to4 migrates the x/auth module state from the consensus version 3 to
@ -56,7 +56,7 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error {
// and managed by the x/params modules and stores them directly into the x/auth
// module state.
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v4.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc)
return v4.Migrate(ctx, m.keeper.storeService, m.legacySubspace, m.keeper.cdc)
}
// V45_SetAccount implements V45_SetAccount
@ -65,13 +65,12 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error {
// NOTE: This is used for testing purposes only.
func (m Migrator) V45_SetAccount(ctx sdk.Context, acc sdk.AccountI) error { //nolint:revive
addr := acc.GetAddress()
store := ctx.KVStore(m.keeper.storeKey)
store := m.keeper.storeService.OpenKVStore(ctx)
bz, err := m.keeper.MarshalAccount(acc)
if err != nil {
return err
}
store.Set(types.AddressStoreKey(addr), bz)
return nil
return store.Set(types.AddressStoreKey(addr), bz)
}

View File

@ -1,27 +1,30 @@
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"context"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
// SetParams sets the auth module's parameters.
func (ak AccountKeeper) SetParams(ctx sdk.Context, params types.Params) error {
func (ak AccountKeeper) SetParams(ctx context.Context, params types.Params) error {
if err := params.Validate(); err != nil {
return err
}
store := ctx.KVStore(ak.storeKey)
store := ak.storeService.OpenKVStore(ctx)
bz := ak.cdc.MustMarshal(&params)
store.Set(types.ParamsKey, bz)
return nil
return store.Set(types.ParamsKey, bz)
}
// GetParams gets the auth module's parameters.
func (ak AccountKeeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(ak.storeKey)
bz := store.Get(types.ParamsKey)
func (ak AccountKeeper) GetParams(ctx context.Context) (params types.Params) {
store := ak.storeService.OpenKVStore(ctx)
bz, err := store.Get(types.ParamsKey)
if err != nil {
panic(err)
}
if bz == nil {
return params
}

View File

@ -10,6 +10,7 @@ import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -48,7 +49,7 @@ func TestMigrateVestingAccounts(t *testing.T) {
storeKey := storetypes.NewKVStoreKey(v1.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)
storeService := runtime.NewKVStoreService(storeKey)
var (
accountKeeper keeper.AccountKeeper
@ -64,7 +65,7 @@ func TestMigrateVestingAccounts(t *testing.T) {
require.NoError(t, err)
legacySubspace := newMockSubspace(authtypes.DefaultParams())
require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc))
require.NoError(t, v4.Migrate(ctx, storeService, legacySubspace, cdc))
ctx = app.BaseApp.NewContext(false, cmtproto.Header{Time: time.Now()})
stakingKeeper.SetParams(ctx, stakingtypes.DefaultParams())

View File

@ -1,6 +1,7 @@
package v3
import (
corestore "cosmossdk.io/core/store"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
@ -8,9 +9,12 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
store := ctx.KVStore(storeKey)
iterator := storetypes.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix)
func mapAccountAddressToAccountID(ctx sdk.Context, storeService corestore.KVStoreService, cdc codec.BinaryCodec) error {
store := storeService.OpenKVStore(ctx)
iterator, err := store.Iterator(types.AddressStoreKeyPrefix, storetypes.PrefixEndBytes(types.AddressStoreKeyPrefix))
if err != nil {
return err
}
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
@ -27,6 +31,6 @@ func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey,
// MigrateStore performs in-place store migrations from v0.45 to v0.46. The
// migration includes:
// - Add an Account number as an index to get the account address
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
return mapAccountAddressToAccountID(ctx, storeKey, cdc)
func MigrateStore(ctx sdk.Context, storeService corestore.KVStoreService, cdc codec.BinaryCodec) error {
return mapAccountAddressToAccountID(ctx, storeService, cdc)
}

View File

@ -11,6 +11,7 @@ import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -44,7 +45,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
storeKey := storetypes.NewKVStoreKey(v1.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)
storeService := runtime.NewKVStoreService(storeKey)
var accountKeeper keeper.AccountKeeper
@ -55,7 +56,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
require.NoError(t, err)
legacySubspace := newMockSubspace(authtypes.DefaultParams())
require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc))
require.NoError(t, v4.Migrate(ctx, storeService, legacySubspace, cdc))
// new base account
senderPrivKey := secp256k1.GenPrivKey()

View File

@ -1,7 +1,7 @@
package v4
import (
storetypes "cosmossdk.io/store/types"
storetypes "cosmossdk.io/core/store"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -15,7 +15,8 @@ var ParamsKey = []byte{0x00}
// version 4. Specifically, it takes the parameters that are currently stored
// and managed by the x/params modules and stores them directly into the x/auth
// module state.
func Migrate(ctx sdk.Context, store storetypes.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
func Migrate(ctx sdk.Context, storeService storetypes.KVStoreService, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
store := storeService.OpenKVStore(ctx)
var currParams types.Params
legacySubspace.GetParamSet(ctx, &currParams)

View File

@ -7,6 +7,7 @@ import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -36,13 +37,14 @@ func TestMigrate(t *testing.T) {
storeKey := storetypes.NewKVStoreKey(v1.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)
storeService := runtime.NewKVStoreService(storeKey)
legacySubspace := newMockSubspace(types.DefaultParams())
require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc))
require.NoError(t, v4.Migrate(ctx, storeService, legacySubspace, cdc))
var res types.Params
bz := store.Get(v4.ParamsKey)
bz, err := storeService.OpenKVStore(ctx).Get(v4.ParamsKey)
require.NoError(t, err)
require.NoError(t, cdc.Unmarshal(bz, &res))
require.Equal(t, legacySubspace.ps, res)
}

View File

@ -16,7 +16,7 @@ import (
modulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
store "cosmossdk.io/store/types"
"cosmossdk.io/core/store"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
@ -214,9 +214,9 @@ func ProvideAddressCodec(config *modulev1.Module) address.Codec {
type AuthInputs struct {
depinject.In
Config *modulev1.Module
Key *store.KVStoreKey
Cdc codec.Codec
Config *modulev1.Module
StoreService store.KVStoreService
Cdc codec.Codec
RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"`
AccountI func() sdk.AccountI `optional:"true"`
@ -253,7 +253,7 @@ func ProvideModule(in AuthInputs) AuthOutputs {
in.AccountI = types.ProtoBaseAccount
}
k := keeper.NewAccountKeeper(in.Cdc, in.Key, in.AccountI, maccPerms, in.Config.Bech32Prefix, authority.String())
k := keeper.NewAccountKeeper(in.Cdc, in.StoreService, in.AccountI, maccPerms, in.Config.Bech32Prefix, authority.String())
m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn, in.LegacySubspace)
return AuthOutputs{AccountKeeper: k, Module: m}

View File

@ -11,6 +11,7 @@ import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -41,6 +42,7 @@ type VestingTestSuite struct {
func (s *VestingTestSuite) SetupTest() {
key := storetypes.NewKVStoreKey(authtypes.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()})
encCfg := moduletestutil.MakeTestEncodingConfig()
@ -51,7 +53,7 @@ func (s *VestingTestSuite) SetupTest() {
s.bankKeeper = vestingtestutil.NewMockBankKeeper(ctrl)
s.accountKeeper = authkeeper.NewAccountKeeper(
encCfg.Codec,
key,
storeService,
authtypes.ProtoBaseAccount,
maccPerms,
"cosmos",

View File

@ -12,6 +12,7 @@ import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -39,6 +40,7 @@ func (s *VestingAccountTestSuite) SetupTest() {
encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModuleBasic{})
key := storetypes.NewKVStoreKey(authtypes.StoreKey)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{})
@ -53,7 +55,7 @@ func (s *VestingAccountTestSuite) SetupTest() {
s.accountKeeper = keeper.NewAccountKeeper(
encCfg.Codec,
key,
storeService,
authtypes.ProtoBaseAccount,
maccPerms,
"cosmos",

View File

@ -1,14 +1,16 @@
package authz
import (
context "context"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// AccountKeeper defines the expected account keeper (noalias)
type AccountKeeper interface {
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
SetAccount(ctx sdk.Context, acc sdk.AccountI)
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
SetAccount(ctx context.Context, acc sdk.AccountI)
}
// BankKeeper defines the expected interface needed to retrieve account balances.

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
types "github.com/cosmos/cosmos-sdk/types"
@ -35,7 +36,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -49,7 +50,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// NewAccountWithAddress mocks base method.
func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -63,7 +64,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) {
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", ctx, acc)
}

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
types "github.com/cosmos/cosmos-sdk/types"
@ -36,7 +37,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -50,7 +51,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// GetAllAccounts mocks base method.
func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types.AccountI {
func (m *MockAccountKeeper) GetAllAccounts(ctx context.Context) []types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllAccounts", ctx)
ret0, _ := ret[0].([]types.AccountI)
@ -64,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAllAccounts(ctx interface{}) *gomock
}
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI {
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName)
ret0, _ := ret[0].(types.ModuleAccountI)
@ -78,7 +79,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interf
}
// GetModuleAccountAndPermissions mocks base method.
func (m *MockAccountKeeper) GetModuleAccountAndPermissions(ctx types.Context, moduleName string) (types.ModuleAccountI, []string) {
func (m *MockAccountKeeper) GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (types.ModuleAccountI, []string) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccountAndPermissions", ctx, moduleName)
ret0, _ := ret[0].(types.ModuleAccountI)
@ -136,7 +137,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModulePermissions() *gomock.Call {
}
// HasAccount mocks base method.
func (m *MockAccountKeeper) HasAccount(ctx types.Context, addr types.AccAddress) bool {
func (m *MockAccountKeeper) HasAccount(ctx context.Context, addr types.AccAddress) bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HasAccount", ctx, addr)
ret0, _ := ret[0].(bool)
@ -150,7 +151,7 @@ func (mr *MockAccountKeeperMockRecorder) HasAccount(ctx, addr interface{}) *gomo
}
// IterateAccounts mocks base method.
func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) {
func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, process func(types.AccountI) bool) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IterateAccounts", ctx, process)
}
@ -162,7 +163,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{
}
// NewAccount mocks base method.
func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI {
func (m *MockAccountKeeper) NewAccount(arg0 context.Context, arg1 types.AccountI) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewAccount", arg0, arg1)
ret0, _ := ret[0].(types.AccountI)
@ -176,7 +177,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom
}
// NewAccountWithAddress mocks base method.
func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -190,7 +191,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) {
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", ctx, acc)
}
@ -202,7 +203,7 @@ func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomoc
}
// SetModuleAccount mocks base method.
func (m *MockAccountKeeper) SetModuleAccount(ctx types.Context, macc types.ModuleAccountI) {
func (m *MockAccountKeeper) SetModuleAccount(ctx context.Context, macc types.ModuleAccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetModuleAccount", ctx, macc)
}

View File

@ -1,6 +1,8 @@
package types
import (
context "context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
@ -8,22 +10,22 @@ import (
// AccountKeeper defines the account contract that must be fulfilled when
// creating a x/bank keeper.
type AccountKeeper interface {
NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI
NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
NewAccount(context.Context, sdk.AccountI) sdk.AccountI
NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
GetAllAccounts(ctx sdk.Context) []sdk.AccountI
HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool
SetAccount(ctx sdk.Context, acc sdk.AccountI)
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
GetAllAccounts(ctx context.Context) []sdk.AccountI
HasAccount(ctx context.Context, addr sdk.AccAddress) bool
SetAccount(ctx context.Context, acc sdk.AccountI)
IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) bool)
IterateAccounts(ctx context.Context, process func(sdk.AccountI) bool)
ValidatePermissions(macc sdk.ModuleAccountI) error
GetModuleAddress(moduleName string) sdk.AccAddress
GetModuleAddressAndPermissions(moduleName string) (addr sdk.AccAddress, permissions []string)
GetModuleAccountAndPermissions(ctx sdk.Context, moduleName string) (sdk.ModuleAccountI, []string)
GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI
SetModuleAccount(ctx sdk.Context, macc sdk.ModuleAccountI)
GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (sdk.ModuleAccountI, []string)
GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI
SetModuleAccount(ctx context.Context, macc sdk.ModuleAccountI)
GetModulePermissions() map[string]types.PermissionsForAddress
}

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
types "github.com/cosmos/cosmos-sdk/types"
@ -36,7 +37,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -50,7 +51,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, name string) types.ModuleAccountI {
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types.ModuleAccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name)
ret0, _ := ret[0].(types.ModuleAccountI)
@ -78,7 +79,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom
}
// SetModuleAccount mocks base method.
func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) {
func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetModuleAccount", arg0, arg1)
}

View File

@ -1,19 +1,21 @@
package types
import (
context "context"
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
// AccountKeeper defines the expected account keeper used for simulations (noalias)
type AccountKeeper interface {
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, name string) sdk.ModuleAccountI
GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI
// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
SetModuleAccount(sdk.Context, sdk.ModuleAccountI)
SetModuleAccount(context.Context, sdk.ModuleAccountI)
}
// BankKeeper defines the expected interface needed to retrieve account balances.

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
time "time"
@ -229,7 +230,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(ctx types0.Context, acc types0.AccountI) {
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types0.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", ctx, acc)
}

View File

@ -1,6 +1,7 @@
package types
import (
context "context"
"time"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -32,7 +33,7 @@ type (
// AccountKeeper define the account keeper interface contracted needed by the evidence module
AccountKeeper interface {
SetAccount(ctx sdk.Context, acc sdk.AccountI)
SetAccount(ctx context.Context, acc sdk.AccountI)
}
// BankKeeper define the account keeper interface contracted needed by the evidence module

View File

@ -1,17 +1,19 @@
package feegrant
import (
context "context"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// AccountKeeper defines the expected auth Account Keeper (noalias)
type AccountKeeper interface {
GetModuleAddress(moduleName string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI
GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI
NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
SetAccount(ctx sdk.Context, acc sdk.AccountI)
NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
SetAccount(ctx context.Context, acc sdk.AccountI)
// StringToBytes decodes text to bytes
StringToBytes(text string) ([]byte, error)

View File

@ -12,7 +12,7 @@ require (
cosmossdk.io/store v0.1.0-alpha.1
github.com/cometbft/cometbft v0.37.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230324171029-0176e313261d
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e
github.com/cosmos/gogoproto v1.4.6
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3

View File

@ -186,8 +186,12 @@ github.com/cosmos/cosmos-db v1.0.0-rc.1 h1:SjnT8B6WKMW9WEIX32qMhnEEKcI7ZP0+G1Sa9
github.com/cosmos/cosmos-db v1.0.0-rc.1/go.mod h1:Dnmk3flSf5lkwCqvvjNpoxjpXzhxnCAFzKHlbaForso=
github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o=
github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230322203107-65e40ff4dacb h1:EaISkBPki6apzaD2Yjw3HtCOOj/yW4OuG6V3Oig2HlA=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230322203107-65e40ff4dacb/go.mod h1:9zqhqPooktWYyV2CiTFh+uQBVbR+Ozy9cr3KrY5UNHQ=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230324171029-0176e313261d h1:FmHvrGoLwiF/4UviweBbWtpEXcNo6IOjnZMgNHcP4mU=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230324171029-0176e313261d/go.mod h1:X5eCGsQaPQWvFwRzAbneZZaLjnZcral+yoLqAN2QTRI=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e h1:n3/Z5dwxBnPLrcUiudoxAhASuz7DCGdLQNBpc9dt4jU=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e/go.mod h1:X5eCGsQaPQWvFwRzAbneZZaLjnZcral+yoLqAN2QTRI=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
types "github.com/cosmos/cosmos-sdk/types"
@ -50,7 +51,7 @@ func (mr *MockAccountKeeperMockRecorder) BytesToString(bz interface{}) *gomock.C
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -64,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI {
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName)
ret0, _ := ret[0].(types.ModuleAccountI)
@ -92,7 +93,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{}
}
// NewAccountWithAddress mocks base method.
func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -106,7 +107,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types.AccountI) {
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", ctx, acc)
}

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
json "encoding/json"
reflect "reflect"
@ -77,7 +78,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// IterateAccounts mocks base method.
func (m *MockAccountKeeper) IterateAccounts(ctx types0.Context, process func(types0.AccountI) bool) {
func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, process func(types0.AccountI) bool) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IterateAccounts", ctx, process)
}
@ -89,7 +90,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{
}
// NewAccount mocks base method.
func (m *MockAccountKeeper) NewAccount(arg0 types0.Context, arg1 types0.AccountI) types0.AccountI {
func (m *MockAccountKeeper) NewAccount(arg0 context.Context, arg1 types0.AccountI) types0.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewAccount", arg0, arg1)
ret0, _ := ret[0].(types0.AccountI)
@ -103,7 +104,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(arg0 types0.Context, arg1 types0.AccountI) {
func (m *MockAccountKeeper) SetAccount(arg0 context.Context, arg1 types0.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", arg0, arg1)
}

View File

@ -1,6 +1,7 @@
package types
import (
"context"
"encoding/json"
abci "github.com/cometbft/cometbft/abci/types"
@ -17,9 +18,9 @@ type StakingKeeper interface {
// AccountKeeper defines the expected account keeper (noalias)
type AccountKeeper interface {
NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI
SetAccount(sdk.Context, sdk.AccountI)
IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool))
NewAccount(context.Context, sdk.AccountI) sdk.AccountI
SetAccount(context.Context, sdk.AccountI)
IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool))
}
// GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias)

View File

@ -3,6 +3,8 @@
package testutil
import (
context "context"
math "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -15,7 +17,7 @@ import (
type AccountKeeper interface {
types.AccountKeeper
IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool))
IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) (stop bool))
}
// BankKeeper extends gov's actual expected BankKeeper with additional

View File

@ -41,7 +41,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -55,7 +55,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, name string) types.ModuleAccountI {
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types.ModuleAccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name)
ret0, _ := ret[0].(types.ModuleAccountI)
@ -83,7 +83,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom
}
// IterateAccounts mocks base method.
func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, cb func(types.AccountI) bool) {
func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, cb func(types.AccountI) bool) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IterateAccounts", ctx, cb)
}
@ -95,7 +95,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, cb interface{}) *g
}
// SetModuleAccount mocks base method.
func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) {
func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetModuleAccount", arg0, arg1)
}

View File

@ -1,6 +1,8 @@
package types
import (
"context"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -34,13 +36,13 @@ type DistributionKeeper interface {
// AccountKeeper defines the expected account keeper (noalias)
type AccountKeeper interface {
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, name string) sdk.ModuleAccountI
GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI
// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
SetModuleAccount(sdk.Context, sdk.ModuleAccountI)
SetModuleAccount(context.Context, sdk.ModuleAccountI)
}
// BankKeeper defines the expected interface needed to retrieve account balances.

View File

@ -1,21 +1,23 @@
package group
import (
context "context"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type AccountKeeper interface {
// NewAccount returns a new account with the next account number. Does not save the new account to the store.
NewAccount(sdk.Context, sdk.AccountI) sdk.AccountI
NewAccount(context.Context, sdk.AccountI) sdk.AccountI
// GetAccount retrieves an account from the store.
GetAccount(sdk.Context, sdk.AccAddress) sdk.AccountI
GetAccount(context.Context, sdk.AccAddress) sdk.AccountI
// SetAccount sets an account in the store.
SetAccount(sdk.Context, sdk.AccountI)
SetAccount(context.Context, sdk.AccountI)
// RemoveAccount Remove an account in the store.
RemoveAccount(ctx sdk.Context, acc sdk.AccountI)
RemoveAccount(ctx context.Context, acc sdk.AccountI)
}
// BankKeeper defines the expected interface needed to retrieve account balances.

View File

@ -8,6 +8,7 @@ import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -78,7 +79,7 @@ func createGroupPolicies(ctx sdk.Context, storeKey storetypes.StoreKey, cdc code
// createOldPolicyAccount re-creates the group policy account using a module account
func createOldPolicyAccount(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec) group.AccountKeeper {
accountKeeper := authkeeper.NewAccountKeeper(cdc, storeKey, authtypes.ProtoBaseAccount, nil, sdk.Bech32MainPrefix, accountAddr.String())
accountKeeper := authkeeper.NewAccountKeeper(cdc, runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), authtypes.ProtoBaseAccount, nil, sdk.Bech32MainPrefix, accountAddr.String())
for _, policyAddr := range policies {
acc := accountKeeper.NewAccount(ctx, &authtypes.ModuleAccount{
BaseAccount: &authtypes.BaseAccount{

View File

@ -37,7 +37,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(arg0 types.Context, arg1 types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(arg0 context.Context, arg1 types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", arg0, arg1)
ret0, _ := ret[0].(types.AccountI)
@ -51,7 +51,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(arg0, arg1 interface{}) *gom
}
// NewAccount mocks base method.
func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types.AccountI) types.AccountI {
func (m *MockAccountKeeper) NewAccount(arg0 context.Context, arg1 types.AccountI) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewAccount", arg0, arg1)
ret0, _ := ret[0].(types.AccountI)
@ -65,7 +65,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gom
}
// RemoveAccount mocks base method.
func (m *MockAccountKeeper) RemoveAccount(ctx types.Context, acc types.AccountI) {
func (m *MockAccountKeeper) RemoveAccount(ctx context.Context, acc types.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RemoveAccount", ctx, acc)
}
@ -77,7 +77,7 @@ func (mr *MockAccountKeeperMockRecorder) RemoveAccount(ctx, acc interface{}) *go
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(arg0 types.Context, arg1 types.AccountI) {
func (m *MockAccountKeeper) SetAccount(arg0 context.Context, arg1 types.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", arg0, arg1)
}

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
math "cosmossdk.io/math"
@ -87,7 +88,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI {
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName)
ret0, _ := ret[0].(types.ModuleAccountI)
@ -115,7 +116,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom
}
// SetModuleAccount mocks base method.
func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) {
func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetModuleAccount", arg0, arg1)
}

View File

@ -1,6 +1,8 @@
package types // noalias
import (
context "context"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -17,8 +19,8 @@ type AccountKeeper interface {
GetModuleAddress(name string) sdk.AccAddress
// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
SetModuleAccount(sdk.Context, sdk.ModuleAccountI)
GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI
SetModuleAccount(context.Context, sdk.ModuleAccountI)
GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI
}
// BankKeeper defines the contract needed to be fulfilled for banking and supply

View File

@ -1,6 +1,8 @@
package nft
import (
context "context"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -13,5 +15,5 @@ type BankKeeper interface {
// AccountKeeper defines the contract required for account APIs.
type AccountKeeper interface {
GetModuleAddress(name string) sdk.AccAddress
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
}

View File

@ -11,7 +11,7 @@ require (
cosmossdk.io/store v0.1.0-alpha.1
github.com/cometbft/cometbft v0.37.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230321173237-fe77d4bca302
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e
github.com/cosmos/gogoproto v1.4.6
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3

View File

@ -181,8 +181,10 @@ github.com/cosmos/cosmos-db v1.0.0-rc.1 h1:SjnT8B6WKMW9WEIX32qMhnEEKcI7ZP0+G1Sa9
github.com/cosmos/cosmos-db v1.0.0-rc.1/go.mod h1:Dnmk3flSf5lkwCqvvjNpoxjpXzhxnCAFzKHlbaForso=
github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o=
github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230321173237-fe77d4bca302 h1:wffm9LPPG/FBW/tSRdJp2DCgkJQRX+Zsbdmn4I0aWeQ=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230321173237-fe77d4bca302/go.mod h1:HzOsWXtPxhO8+Y8P4Ru+G3UWx6dTkpGXU9yvT35VEuI=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230322203107-65e40ff4dacb h1:EaISkBPki6apzaD2Yjw3HtCOOj/yW4OuG6V3Oig2HlA=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230322203107-65e40ff4dacb/go.mod h1:9zqhqPooktWYyV2CiTFh+uQBVbR+Ozy9cr3KrY5UNHQ=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e h1:n3/Z5dwxBnPLrcUiudoxAhASuz7DCGdLQNBpc9dt4jU=
github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230327134358-9689f9993c7e/go.mod h1:X5eCGsQaPQWvFwRzAbneZZaLjnZcral+yoLqAN2QTRI=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
types "github.com/cosmos/cosmos-sdk/types"
@ -72,7 +73,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)

View File

@ -1,12 +1,14 @@
package simulation
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// AccountKeeper defines the expected account keeper used for simulations (noalias)
type AccountKeeper interface {
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
}
// BankKeeper defines the expected interface needed to retrieve account balances.

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
math "cosmossdk.io/math"
@ -38,7 +39,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -52,7 +53,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// IterateAccounts mocks base method.
func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) {
func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, process func(types.AccountI) bool) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IterateAccounts", ctx, process)
}

View File

@ -1,6 +1,8 @@
package types
import (
context "context"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -10,8 +12,8 @@ import (
// AccountKeeper expected account keeper
type AccountKeeper interface {
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI
IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool))
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool))
}
// BankKeeper defines the expected interface needed to retrieve account balances.

View File

@ -5,6 +5,7 @@
package testutil
import (
context "context"
reflect "reflect"
math "cosmossdk.io/math"
@ -88,7 +89,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types.AccountI)
@ -102,7 +103,7 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types.ModuleAccountI {
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName)
ret0, _ := ret[0].(types.ModuleAccountI)
@ -130,7 +131,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom
}
// IterateAccounts mocks base method.
func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types.AccountI) bool) {
func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, process func(types.AccountI) bool) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IterateAccounts", ctx, process)
}
@ -142,7 +143,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{
}
// SetModuleAccount mocks base method.
func (m *MockAccountKeeper) SetModuleAccount(arg0 types.Context, arg1 types.ModuleAccountI) {
func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetModuleAccount", arg0, arg1)
}

View File

@ -1,6 +1,8 @@
package types
import (
context "context"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -14,14 +16,14 @@ type DistributionKeeper interface {
// AccountKeeper defines the expected account keeper (noalias)
type AccountKeeper interface {
IterateAccounts(ctx sdk.Context, process func(sdk.AccountI) (stop bool))
GetAccount(ctx sdk.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation
IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool))
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation
GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, moduleName string) sdk.ModuleAccountI
GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI
// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
SetModuleAccount(sdk.Context, sdk.ModuleAccountI)
SetModuleAccount(context.Context, sdk.ModuleAccountI)
}
// BankKeeper defines the expected interface needed to retrieve account balances.