Skip to content

Commit

Permalink
Cleanup app module inits
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Feb 13, 2024
1 parent beb1f9c commit a3d73df
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 29 deletions.
7 changes: 4 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ func New(
app.BankKeeper,
app.StakingKeeper,
app.ZetaObserverKeeper,
app.AccountKeeper,
)
// Create Ethermint keepers
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))
Expand Down Expand Up @@ -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),
)

Expand Down
2 changes: 2 additions & 0 deletions testutil/keeper/emissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down
10 changes: 2 additions & 8 deletions x/crosschain/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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{}
}
Expand Down
9 changes: 7 additions & 2 deletions x/emissions/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type (
bankKeeper types.BankKeeper
stakingKeeper types.StakingKeeper
observerKeeper types.ObserverKeeper
authKeeper types.AccountKeeper
}
)

Expand All @@ -34,15 +35,14 @@ 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() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}

return &Keeper{

cdc: cdc,
storeKey: storeKey,
memKey: memKey,
Expand All @@ -51,6 +51,7 @@ func NewKeeper(
bankKeeper: bankKeeper,
stakingKeeper: stakingKeeper,
observerKeeper: observerKeeper,
authKeeper: authKeeper,
}
}

Expand All @@ -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
}
11 changes: 4 additions & 7 deletions x/emissions/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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{}
}
Expand Down
10 changes: 2 additions & 8 deletions x/fungible/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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")
}
Expand Down
1 change: 0 additions & 1 deletion x/observer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit a3d73df

Please sign in to comment.