refactor(auth): migrate to use env (#19476)
This commit is contained in:
parent
72eae6dc50
commit
c8836248d1
@ -305,7 +305,7 @@ func NewSimApp(
|
||||
}
|
||||
app.AccountsKeeper = accountsKeeper
|
||||
|
||||
app.AuthKeeper = authkeeper.NewAccountKeeper(appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addressCodec, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, maccPerms, addressCodec, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
|
||||
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
||||
appCodec,
|
||||
|
||||
@ -77,8 +77,8 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
}
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
|
||||
@ -84,8 +84,8 @@ func initFixture(t *testing.T) *fixture {
|
||||
}
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
|
||||
@ -104,8 +104,8 @@ func initFixture(tb testing.TB) *fixture {
|
||||
}
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
|
||||
@ -40,8 +40,8 @@ func Example() {
|
||||
newCtx := sdk.NewContext(cms, true, logger)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
encodingCfg.Codec,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
map[string][]string{minttypes.ModuleName: {authtypes.Minter}},
|
||||
addresscodec.NewBech32Codec("cosmos"),
|
||||
@ -129,8 +129,8 @@ func Example_oneModule() {
|
||||
newCtx := sdk.NewContext(cms, true, logger)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
encodingCfg.Codec,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
map[string][]string{minttypes.ModuleName: {authtypes.Minter}},
|
||||
addresscodec.NewBech32Codec("cosmos"),
|
||||
|
||||
@ -71,8 +71,8 @@ func initFixture(tb testing.TB) *fixture {
|
||||
}
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
|
||||
@ -72,8 +72,8 @@ func initFixture(tb testing.TB) *fixture {
|
||||
}
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
|
||||
@ -121,8 +121,8 @@ func initFixture(tb testing.TB) *fixture {
|
||||
}
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
|
||||
@ -85,8 +85,8 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
}
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
|
||||
@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* [#17985](https://github.com/cosmos/cosmos-sdk/pull/17985) Remove `StdTxConfig`
|
||||
* [#19161](https://github.com/cosmos/cosmos-sdk/pull/19161) Remove `simulate` from `SetGasMeter`
|
||||
* [#19363](https://github.com/cosmos/cosmos-sdk/pull/19363) Remove `IterateAccounts` and `GetAllAccounts` methods from the AccountKeeper interface and Keeper.
|
||||
* [#19290](https://github.com/cosmos/cosmos-sdk/issues/19290) Pass `appmodule.Environment` to NewKeeper instead of passing individual services.
|
||||
|
||||
### Consensus Breaking Changes
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/14647
|
||||
_ "cosmossdk.io/api/cosmos/bank/v1beta1"
|
||||
_ "cosmossdk.io/api/cosmos/crypto/secp256k1"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/auth"
|
||||
"cosmossdk.io/x/auth/ante"
|
||||
@ -78,7 +79,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
|
||||
}
|
||||
|
||||
suite.accountKeeper = keeper.NewAccountKeeper(
|
||||
suite.encCfg.Codec, runtime.NewKVStoreService(key), types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"),
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()), suite.encCfg.Codec, types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"),
|
||||
sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(),
|
||||
)
|
||||
suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName)
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
modulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/depinject/appconfig"
|
||||
"cosmossdk.io/x/auth/keeper"
|
||||
@ -29,9 +28,9 @@ func init() {
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
Config *modulev1.Module
|
||||
StoreService store.KVStoreService
|
||||
Cdc codec.Codec
|
||||
Config *modulev1.Module
|
||||
Environment appmodule.Environment
|
||||
Cdc codec.Codec
|
||||
|
||||
AddressCodec address.Codec
|
||||
RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"`
|
||||
@ -70,7 +69,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
k := keeper.NewAccountKeeper(in.Cdc, in.StoreService, in.AccountI, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth)
|
||||
k := keeper.NewAccountKeeper(in.Environment, in.Cdc, in.AccountI, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth)
|
||||
m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn)
|
||||
|
||||
return ModuleOutputs{AccountKeeper: k, Module: m}
|
||||
|
||||
@ -9,8 +9,9 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
"pgregory.net/rapid"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/header"
|
||||
corestore "cosmossdk.io/core/store"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/auth"
|
||||
authcodec "cosmossdk.io/x/auth/codec"
|
||||
@ -32,7 +33,7 @@ type DeterministicTestSuite struct {
|
||||
accountNumberLanes uint64
|
||||
|
||||
key *storetypes.KVStoreKey
|
||||
storeService corestore.KVStoreService
|
||||
environment appmodule.Environment
|
||||
ctx sdk.Context
|
||||
queryClient types.QueryClient
|
||||
accountKeeper keeper.AccountKeeper
|
||||
@ -56,6 +57,7 @@ func (suite *DeterministicTestSuite) SetupTest() {
|
||||
suite.Require()
|
||||
key := storetypes.NewKVStoreKey(types.StoreKey)
|
||||
storeService := runtime.NewKVStoreService(key)
|
||||
env := runtime.NewEnvironment(storeService, log.NewNopLogger())
|
||||
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{})
|
||||
|
||||
@ -69,8 +71,8 @@ func (suite *DeterministicTestSuite) SetupTest() {
|
||||
}
|
||||
|
||||
suite.accountKeeper = keeper.NewAccountKeeper(
|
||||
env,
|
||||
suite.encCfg.Codec,
|
||||
storeService,
|
||||
types.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
@ -83,7 +85,7 @@ func (suite *DeterministicTestSuite) SetupTest() {
|
||||
suite.queryClient = types.NewQueryClient(queryHelper)
|
||||
|
||||
suite.key = key
|
||||
suite.storeService = storeService
|
||||
suite.environment = env
|
||||
suite.maccPerms = maccPerms
|
||||
suite.accountNumberLanes = 1
|
||||
}
|
||||
@ -289,8 +291,8 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() {
|
||||
}
|
||||
|
||||
ak := keeper.NewAccountKeeper(
|
||||
suite.environment,
|
||||
suite.encCfg.Codec,
|
||||
suite.storeService,
|
||||
types.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
@ -336,8 +338,8 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() {
|
||||
maccPerms[mName] = mPerms
|
||||
|
||||
ak := keeper.NewAccountKeeper(
|
||||
suite.environment,
|
||||
suite.encCfg.Codec,
|
||||
suite.storeService,
|
||||
types.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/collections/indexes"
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/x/auth/types"
|
||||
@ -82,7 +82,7 @@ func (a AccountsIndexes) IndexesList() []collections.Index[sdk.AccAddress, sdk.A
|
||||
type AccountKeeper struct {
|
||||
addressCodec address.Codec
|
||||
|
||||
storeService store.KVStoreService
|
||||
Environment appmodule.Environment
|
||||
cdc codec.BinaryCodec
|
||||
permAddrs map[string]types.PermissionsForAddress
|
||||
bech32Prefix string
|
||||
@ -111,7 +111,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, storeService store.KVStoreService, proto func() sdk.AccountI,
|
||||
env appmodule.Environment, cdc codec.BinaryCodec, proto func() sdk.AccountI,
|
||||
maccPerms map[string][]string, ac address.Codec, bech32Prefix, authority string,
|
||||
) AccountKeeper {
|
||||
permAddrs := make(map[string]types.PermissionsForAddress)
|
||||
@ -119,12 +119,12 @@ func NewAccountKeeper(
|
||||
permAddrs[name] = types.NewPermissionsForAddress(name, perms)
|
||||
}
|
||||
|
||||
sb := collections.NewSchemaBuilder(storeService)
|
||||
sb := collections.NewSchemaBuilder(env.KVStoreService)
|
||||
|
||||
ak := AccountKeeper{
|
||||
addressCodec: ac,
|
||||
bech32Prefix: bech32Prefix,
|
||||
storeService: storeService,
|
||||
Environment: env,
|
||||
proto: proto,
|
||||
cdc: cdc,
|
||||
permAddrs: permAddrs,
|
||||
@ -154,7 +154,7 @@ func (ak AccountKeeper) AddressCodec() address.Codec {
|
||||
|
||||
// Logger returns a module-specific logger.
|
||||
func (ak AccountKeeper) Logger(ctx context.Context) log.Logger {
|
||||
return sdk.UnwrapSDKContext(ctx).Logger().With("module", "x/"+types.ModuleName)
|
||||
return ak.Environment.Logger.With("module", "x/"+types.ModuleName)
|
||||
}
|
||||
|
||||
// GetPubKey Returns the PubKey of the account at address
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/auth"
|
||||
authcodec "cosmossdk.io/x/auth/codec"
|
||||
@ -49,6 +50,7 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
|
||||
key := storetypes.NewKVStoreKey(types.StoreKey)
|
||||
storeService := runtime.NewKVStoreService(key)
|
||||
env := runtime.NewEnvironment(storeService, log.NewNopLogger())
|
||||
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{})
|
||||
|
||||
@ -62,8 +64,8 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
}
|
||||
|
||||
suite.accountKeeper = keeper.NewAccountKeeper(
|
||||
env,
|
||||
suite.encCfg.Codec,
|
||||
storeService,
|
||||
types.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
|
||||
@ -42,7 +42,7 @@ func (m Migrator) Migrate3to4(ctx context.Context) error {
|
||||
// It migrates the GlobalAccountNumber from being a protobuf defined value to a
|
||||
// big-endian encoded uint64, it also migrates it to use a more canonical prefix.
|
||||
func (m Migrator) Migrate4To5(ctx context.Context) error {
|
||||
return v5.Migrate(ctx, m.keeper.storeService, m.keeper.AccountNumber)
|
||||
return v5.Migrate(ctx, m.keeper.Environment.KVStoreService, m.keeper.AccountNumber)
|
||||
}
|
||||
|
||||
// V45_SetAccount implements V45_SetAccount
|
||||
@ -51,7 +51,7 @@ func (m Migrator) Migrate4To5(ctx context.Context) error {
|
||||
// NOTE: This is used for testing purposes only.
|
||||
func (m Migrator) V45SetAccount(ctx context.Context, acc sdk.AccountI) error {
|
||||
addr := acc.GetAddress()
|
||||
store := m.keeper.storeService.OpenKVStore(ctx)
|
||||
store := m.keeper.Environment.KVStoreService.OpenKVStore(ctx)
|
||||
|
||||
bz, err := m.keeper.Accounts.ValueCodec().Encode(acc)
|
||||
if err != nil {
|
||||
|
||||
@ -5,8 +5,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/x/auth/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
@ -22,7 +20,7 @@ func NewMsgServerImpl(ak AccountKeeper) types.MsgServer {
|
||||
}
|
||||
}
|
||||
|
||||
func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
|
||||
func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
|
||||
if ms.ak.authority != msg.Authority {
|
||||
return nil, fmt.Errorf(
|
||||
"expected authority account as only signer for proposal message; invalid authority; expected %s, got %s",
|
||||
@ -33,7 +31,6 @@ func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdatePara
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
if err := ms.ak.Params.Set(ctx, msg.Params); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -77,14 +77,13 @@ func FuzzMsgServerCreateVestingAccount(f *testing.F) {
|
||||
}
|
||||
|
||||
key := storetypes.NewKVStoreKey(authtypes.StoreKey)
|
||||
storeService := runtime.NewKVStoreService(key)
|
||||
|
||||
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger())
|
||||
maccPerms := map[string][]string{}
|
||||
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig()
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
env,
|
||||
encCfg.Codec,
|
||||
storeService,
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
address.NewBech32Codec("cosmos"),
|
||||
@ -103,6 +102,7 @@ func FuzzMsgServerCreateVestingAccount(f *testing.F) {
|
||||
return
|
||||
}
|
||||
|
||||
storeService := runtime.NewKVStoreService(key)
|
||||
ctrl := gomock.NewController(t)
|
||||
authKeeper := banktestutil.NewMockAccountKeeper(ctrl)
|
||||
authKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes()
|
||||
|
||||
@ -80,8 +80,7 @@ func (s msgServer) CreateVestingAccount(ctx context.Context, msg *types.MsgCreat
|
||||
} else {
|
||||
start := msg.StartTime
|
||||
if msg.StartTime == 0 {
|
||||
sdkctx := sdk.UnwrapSDKContext(ctx)
|
||||
start = sdkctx.HeaderInfo().Time.Unix()
|
||||
start = s.AccountKeeper.Environment.HeaderService.GetHeaderInfo(ctx).Time.Unix()
|
||||
}
|
||||
vestingAccount = types.NewContinuousVestingAccountRaw(baseVestingAccount, start)
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
authcodec "cosmossdk.io/x/auth/codec"
|
||||
@ -43,7 +44,8 @@ type VestingTestSuite struct {
|
||||
|
||||
func (s *VestingTestSuite) SetupTest() {
|
||||
key := storetypes.NewKVStoreKey(authtypes.StoreKey)
|
||||
storeService := runtime.NewKVStoreService(key)
|
||||
|
||||
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger())
|
||||
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()})
|
||||
|
||||
@ -54,8 +56,8 @@ func (s *VestingTestSuite) SetupTest() {
|
||||
ctrl := gomock.NewController(s.T())
|
||||
s.bankKeeper = vestingtestutil.NewMockBankKeeper(ctrl)
|
||||
s.accountKeeper = authkeeper.NewAccountKeeper(
|
||||
env,
|
||||
encCfg.Codec,
|
||||
storeService,
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
authcodec "cosmossdk.io/x/auth/codec"
|
||||
"cosmossdk.io/x/auth/keeper"
|
||||
@ -40,7 +41,7 @@ func (s *VestingAccountTestSuite) SetupTest() {
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModuleBasic{})
|
||||
|
||||
key := storetypes.NewKVStoreKey(authtypes.StoreKey)
|
||||
storeService := runtime.NewKVStoreService(key)
|
||||
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger())
|
||||
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{})
|
||||
|
||||
@ -54,8 +55,8 @@ func (s *VestingAccountTestSuite) SetupTest() {
|
||||
}
|
||||
|
||||
s.accountKeeper = keeper.NewAccountKeeper(
|
||||
env,
|
||||
encCfg.Codec,
|
||||
storeService,
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
|
||||
@ -46,8 +46,8 @@ func TestFundsMigration(t *testing.T) {
|
||||
|
||||
// create account keeper
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
encCfg.Codec,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
corestore "cosmossdk.io/core/store"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/auth"
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
@ -82,7 +83,7 @@ func createGroupPolicies(ctx sdk.Context, storeService corestore.KVStoreService,
|
||||
|
||||
// createOldPolicyAccount re-creates the group policy account using a module account
|
||||
func createOldPolicyAccount(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec, policies []sdk.AccAddress) ([]*authtypes.ModuleAccount, group.AccountKeeper) {
|
||||
accountKeeper := authkeeper.NewAccountKeeper(cdc, runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), authtypes.ProtoBaseAccount, nil, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), sdk.Bech32MainPrefix, authorityAddr.String())
|
||||
accountKeeper := authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), log.NewNopLogger()), cdc, authtypes.ProtoBaseAccount, nil, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), sdk.Bech32MainPrefix, authorityAddr.String())
|
||||
|
||||
oldPolicyAccounts := make([]*authtypes.ModuleAccount, len(policies))
|
||||
for i, policyAddr := range policies {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user