From c87578a05f6cf58cff8e7ad89995220349596928 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Tue, 1 Nov 2022 11:25:36 -0400 Subject: [PATCH 1/4] move hook logic --- ignite/templates/app/stargate/app/app.go.plush | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ignite/templates/app/stargate/app/app.go.plush b/ignite/templates/app/stargate/app/app.go.plush index d49fb6e709..eabf1f10d8 100644 --- a/ignite/templates/app/stargate/app/app.go.plush +++ b/ignite/templates/app/stargate/app/app.go.plush @@ -414,12 +414,6 @@ func New( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // register the staking hooks - // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - app.StakingKeeper = *stakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), - ) - // ... other modules keepers // Create IBC Keeper @@ -508,7 +502,17 @@ func New( // this line is used by starport scaffolding # ibc/app/router app.IBCKeeper.SetRouter(ibcRouter) - /**** Module Options ****/ + /**** Module Hooks ****/ + + // register hooks after all modules have been initialized + + // register the staking hooks + // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks + app.StakingKeeper = *stakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), + ) + + /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. From 16d1d164d11bb02204b2ac03bc388110ca91055f Mon Sep 17 00:00:00 2001 From: aljo242 Date: Tue, 1 Nov 2022 11:29:35 -0400 Subject: [PATCH 2/4] move --- .../templates/app/stargate/app/app.go.plush | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ignite/templates/app/stargate/app/app.go.plush b/ignite/templates/app/stargate/app/app.go.plush index eabf1f10d8..29c5d46885 100644 --- a/ignite/templates/app/stargate/app/app.go.plush +++ b/ignite/templates/app/stargate/app/app.go.plush @@ -492,16 +492,6 @@ func New( // this line is used by starport scaffolding # stargate/app/keeperDefinition - // Sealing prevents other modules from creating scoped sub-keepers - app.CapabilityKeeper.Seal() - - // Create static IBC router, add transfer route, then set and seal it - ibcRouter := ibcporttypes.NewRouter() - ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - AddRoute(ibctransfertypes.ModuleName, transferIBCModule) - // this line is used by starport scaffolding # ibc/app/router - app.IBCKeeper.SetRouter(ibcRouter) - /**** Module Hooks ****/ // register hooks after all modules have been initialized @@ -512,6 +502,18 @@ func New( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), ) + /**** IBC Routing ****/ + + // Sealing prevents other modules from creating scoped sub-keepers + app.CapabilityKeeper.Seal() + + // Create static IBC router, add transfer route, then set and seal it + ibcRouter := ibcporttypes.NewRouter() + ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). + AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + // this line is used by starport scaffolding # ibc/app/router + app.IBCKeeper.SetRouter(ibcRouter) + /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment From 3dd933f64803c0d07ab84c8797551d6a16d73d83 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Tue, 1 Nov 2022 11:51:33 -0400 Subject: [PATCH 3/4] fix hooks section --- .../templates/app/stargate/app/app.go.plush | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/ignite/templates/app/stargate/app/app.go.plush b/ignite/templates/app/stargate/app/app.go.plush index 29c5d46885..10c33cb4eb 100644 --- a/ignite/templates/app/stargate/app/app.go.plush +++ b/ignite/templates/app/stargate/app/app.go.plush @@ -344,7 +344,7 @@ func New( app.BlockedModuleAccountAddrs(), ) - stakingKeeper := stakingkeeper.NewKeeper( + app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, @@ -356,7 +356,7 @@ func New( appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), - &stakingKeeper, + &app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, @@ -368,14 +368,14 @@ func New( app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, + &app.StakingKeeper, authtypes.FeeCollectorName, ) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, keys[slashingtypes.StoreKey], - &stakingKeeper, + &app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), ) @@ -484,7 +484,7 @@ func New( app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, + &app.StakingKeeper, govRouter, app.MsgServiceRouter(), govConfig, @@ -492,16 +492,6 @@ func New( // this line is used by starport scaffolding # stargate/app/keeperDefinition - /**** Module Hooks ****/ - - // register hooks after all modules have been initialized - - // register the staking hooks - // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - app.StakingKeeper = *stakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), - ) - /**** IBC Routing ****/ // Sealing prevents other modules from creating scoped sub-keepers @@ -514,6 +504,24 @@ func New( // this line is used by starport scaffolding # ibc/app/router app.IBCKeeper.SetRouter(ibcRouter) + /**** Module Hooks ****/ + + // register hooks after all modules have been initialized + + app.StakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks( + // insert staking hooks receivers here + app.DistrKeeper.Hooks(), + app.SlashingKeeper.Hooks(), + ), + ) + + app.GovKeeper.SetHooks( + govtypes.NewMultiGovHooks( + // insert governance hooks receivers here + ), + ) + /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment From fae3a4ae01bee93503cd4db1e2ede33cabdf531c Mon Sep 17 00:00:00 2001 From: aljo242 Date: Tue, 1 Nov 2022 11:59:39 -0400 Subject: [PATCH 4/4] changelog --- changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index 400ef45de3..578bc00d9f 100644 --- a/changelog.md +++ b/changelog.md @@ -18,6 +18,11 @@ - [#2991](https://github.com/ignite/cli/pull/2991) Hide `ignite scaffold flutter` command and remove functionality. - [#2944](https://github.com/ignite/cli/pull/2944) Add a new event "update" status option to `pkg/cliui`. +### Fixes + +- [#3031](https://github.com/ignite/cli/pull/3031) Move keeper hooks to after all keepers initialized in `app.go` +template. + ## [`v0.25.1`](https://github.com/ignite/cli/releases/tag/v0.25.1) ### Changes