Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(templates): app.go hooks #3031

Merged
merged 5 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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
Expand Down
38 changes: 26 additions & 12 deletions ignite/templates/app/stargate/app/app.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func New(
app.BlockedModuleAccountAddrs(),
)

stakingKeeper := stakingkeeper.NewKeeper(
app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec,
keys[stakingtypes.StoreKey],
app.AccountKeeper,
Expand All @@ -356,7 +356,7 @@ func New(
appCodec,
keys[minttypes.StoreKey],
app.GetSubspace(minttypes.ModuleName),
&stakingKeeper,
&app.StakingKeeper,
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
Expand All @@ -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),
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -490,14 +484,16 @@ func New(
app.GetSubspace(govtypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
&stakingKeeper,
&app.StakingKeeper,
govRouter,
app.MsgServiceRouter(),
govConfig,
)

// this line is used by starport scaffolding # stargate/app/keeperDefinition

/**** IBC Routing ****/

// Sealing prevents other modules from creating scoped sub-keepers
app.CapabilityKeeper.Seal()

Expand All @@ -508,7 +504,25 @@ 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

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
// we prefer to be more strict in what arguments the modules expect.
Expand Down