From a3d73dfed7a94f1b55ddcc3b768c813095187b1c Mon Sep 17 00:00:00 2001 From: skosito Date: Tue, 13 Feb 2024 22:28:38 +0100 Subject: [PATCH] Cleanup app module inits --- app/app.go | 7 ++++--- testutil/keeper/emissions.go | 2 ++ x/crosschain/module.go | 10 ++-------- x/emissions/keeper/keeper.go | 9 +++++++-- x/emissions/module.go | 11 ++++------- x/fungible/module.go | 10 ++-------- x/observer/keeper/keeper.go | 1 - 7 files changed, 21 insertions(+), 29 deletions(-) diff --git a/app/app.go b/app/app.go index d9aedce8cb..e0f4de6d7d 100644 --- a/app/app.go +++ b/app/app.go @@ -366,6 +366,7 @@ func New( app.BankKeeper, app.StakingKeeper, app.ZetaObserverKeeper, + app.AccountKeeper, ) // Create Ethermint keepers tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer)) @@ -474,10 +475,10 @@ func New( groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, interfaceRegistry), evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs), feemarket.NewAppModule(app.FeeMarketKeeper, feeSs), - crosschainmodule.NewAppModule(appCodec, app.ZetaCoreKeeper, app.StakingKeeper, app.AccountKeeper), + crosschainmodule.NewAppModule(appCodec, app.ZetaCoreKeeper), observermodule.NewAppModule(appCodec, *app.ZetaObserverKeeper), - fungibleModule.NewAppModule(appCodec, app.FungibleKeeper, app.AccountKeeper, app.BankKeeper), - emissionsModule.NewAppModule(appCodec, app.EmissionsKeeper, app.AccountKeeper), + fungibleModule.NewAppModule(appCodec, app.FungibleKeeper), + emissionsModule.NewAppModule(appCodec, app.EmissionsKeeper), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), ) diff --git a/testutil/keeper/emissions.go b/testutil/keeper/emissions.go index edcde7a75e..4e57ced16d 100644 --- a/testutil/keeper/emissions.go +++ b/testutil/keeper/emissions.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" @@ -49,6 +50,7 @@ func EmissionsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { bankkeeper.BaseKeeper{}, stakingkeeper.Keeper{}, observerkeeper.Keeper{}, + authkeeper.AccountKeeper{}, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/crosschain/module.go b/x/crosschain/module.go index 421f92c895..0f2089d4ea 100644 --- a/x/crosschain/module.go +++ b/x/crosschain/module.go @@ -105,22 +105,16 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper keeper.Keeper - stakingKeeper types.StakingKeeper - authKeeper types.AccountKeeper + keeper keeper.Keeper } func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, - stakingKeeper types.StakingKeeper, - authKeeper types.AccountKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, - stakingKeeper: stakingKeeper, - authKeeper: authKeeper, } } @@ -172,7 +166,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra InitGenesis(ctx, am.keeper, genState) // ensure account is created - am.authKeeper.GetModuleAccount(ctx, types.ModuleName) + am.keeper.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) return []abci.ValidatorUpdate{} } diff --git a/x/emissions/keeper/keeper.go b/x/emissions/keeper/keeper.go index fe9e4429e7..b0fe4d26ee 100644 --- a/x/emissions/keeper/keeper.go +++ b/x/emissions/keeper/keeper.go @@ -22,6 +22,7 @@ type ( bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper observerKeeper types.ObserverKeeper + authKeeper types.AccountKeeper } ) @@ -34,7 +35,7 @@ func NewKeeper( bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, observerKeeper types.ObserverKeeper, - + authKeeper types.AccountKeeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -42,7 +43,6 @@ func NewKeeper( } return &Keeper{ - cdc: cdc, storeKey: storeKey, memKey: memKey, @@ -51,6 +51,7 @@ func NewKeeper( bankKeeper: bankKeeper, stakingKeeper: stakingKeeper, observerKeeper: observerKeeper, + authKeeper: authKeeper, } } @@ -73,3 +74,7 @@ func (k Keeper) GetStakingKeeper() types.StakingKeeper { func (k Keeper) GetObserverKeeper() types.ObserverKeeper { return k.observerKeeper } + +func (k Keeper) GetAuthKeeper() types.AccountKeeper { + return k.authKeeper +} diff --git a/x/emissions/module.go b/x/emissions/module.go index a40c9743e9..7086c998fc 100644 --- a/x/emissions/module.go +++ b/x/emissions/module.go @@ -101,19 +101,16 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper emissionskeeper.Keeper - accountKeeper types.AccountKeeper + keeper emissionskeeper.Keeper } func NewAppModule( cdc codec.Codec, keeper emissionskeeper.Keeper, - accountKeeper types.AccountKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, - accountKeeper: accountKeeper, } } @@ -154,9 +151,9 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra InitGenesis(ctx, am.keeper, genState) - am.accountKeeper.GetModuleAccount(ctx, types.ModuleName) - am.accountKeeper.GetModuleAccount(ctx, types.UndistributedTssRewardsPool) - am.accountKeeper.GetModuleAccount(ctx, types.UndistributedObserverRewardsPool) + am.keeper.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + am.keeper.GetAuthKeeper().GetModuleAccount(ctx, types.UndistributedTssRewardsPool) + am.keeper.GetAuthKeeper().GetModuleAccount(ctx, types.UndistributedObserverRewardsPool) return []abci.ValidatorUpdate{} } diff --git a/x/fungible/module.go b/x/fungible/module.go index e66b28f1e8..5a88d9e11b 100644 --- a/x/fungible/module.go +++ b/x/fungible/module.go @@ -101,22 +101,16 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper keeper.Keeper - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper + keeper keeper.Keeper } func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, - accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, - accountKeeper: accountKeeper, - bankKeeper: bankKeeper, } } @@ -158,7 +152,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra InitGenesis(ctx, am.keeper, genState) // ensure fungible module account is set on genesis - if acc := am.accountKeeper.GetModuleAccount(ctx, types.ModuleName); acc == nil { + if acc := am.keeper.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName); acc == nil { // NOTE: shouldn't occur panic("the fungible module account has not been set") } diff --git a/x/observer/keeper/keeper.go b/x/observer/keeper/keeper.go index b8cb0378c3..c7a5f38e77 100644 --- a/x/observer/keeper/keeper.go +++ b/x/observer/keeper/keeper.go @@ -30,7 +30,6 @@ func NewKeeper( ps paramtypes.Subspace, stakingKeeper types.StakingKeeper, slashinKeeper types.SlashingKeeper, - ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() {