@@ -96,22 +96,21 @@ import (
9696 ibcporttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"
9797 ibchost "github.com/cosmos/ibc-go/v5/modules/core/24-host"
9898 ibckeeper "github.com/cosmos/ibc-go/v5/modules/core/keeper"
99+ "github.com/ignite/cli/ignite/pkg/openapiconsole"
99100 "github.com/spf13/cast"
100101 abci "github.com/tendermint/tendermint/abci/types"
101102 tmjson "github.com/tendermint/tendermint/libs/json"
102103 "github.com/tendermint/tendermint/libs/log"
103104 tmos "github.com/tendermint/tendermint/libs/os"
104105 dbm "github.com/tendermint/tm-db"
105106
106- "github.com/ignite/cli/ignite/pkg/cosmoscmd"
107- "github.com/ignite/cli/ignite/pkg/openapiconsole"
108-
109- "github.com/ignite/example/docs"
110-
111107 examplemodule "github.com/ignite/example/x/example"
112108 examplemodulekeeper "github.com/ignite/example/x/example/keeper"
113109 examplemoduletypes "github.com/ignite/example/x/example/types"
114110 // this line is used by starport scaffolding # stargate/app/moduleImport
111+
112+ appparams "github.com/ignite/example/app/params"
113+ "github.com/ignite/example/docs"
115114)
116115
117116const (
@@ -185,7 +184,6 @@ var (
185184)
186185
187186var (
188- _ cosmoscmd.App = (* App )(nil )
189187 _ servertypes.Application = (* App )(nil )
190188 _ simapp.App = (* App )(nil )
191189)
@@ -261,15 +259,21 @@ func New(
261259 skipUpgradeHeights map [int64 ]bool ,
262260 homePath string ,
263261 invCheckPeriod uint ,
264- encodingConfig cosmoscmd .EncodingConfig ,
262+ encodingConfig appparams .EncodingConfig ,
265263 appOpts servertypes.AppOptions ,
266264 baseAppOptions ... func (* baseapp.BaseApp ),
267- ) cosmoscmd. App {
265+ ) * App {
268266 appCodec := encodingConfig .Marshaler
269267 cdc := encodingConfig .Amino
270268 interfaceRegistry := encodingConfig .InterfaceRegistry
271269
272- bApp := baseapp .NewBaseApp (Name , logger , db , encodingConfig .TxConfig .TxDecoder (), baseAppOptions ... )
270+ bApp := baseapp .NewBaseApp (
271+ Name ,
272+ logger ,
273+ db ,
274+ encodingConfig .TxConfig .TxDecoder (),
275+ baseAppOptions ... ,
276+ )
273277 bApp .SetCommitMultiStoreTracer (traceStore )
274278 bApp .SetVersion (version .Version )
275279 bApp .SetInterfaceRegistry (interfaceRegistry )
@@ -346,7 +350,7 @@ func New(
346350 app .BlockedModuleAccountAddrs (),
347351 )
348352
349- stakingKeeper : = stakingkeeper .NewKeeper (
353+ app . StakingKeeper = stakingkeeper .NewKeeper (
350354 appCodec ,
351355 keys [stakingtypes .StoreKey ],
352356 app .AccountKeeper ,
@@ -358,7 +362,7 @@ func New(
358362 appCodec ,
359363 keys [minttypes .StoreKey ],
360364 app .GetSubspace (minttypes .ModuleName ),
361- & stakingKeeper ,
365+ & app . StakingKeeper ,
362366 app .AccountKeeper ,
363367 app .BankKeeper ,
364368 authtypes .FeeCollectorName ,
@@ -370,14 +374,14 @@ func New(
370374 app .GetSubspace (distrtypes .ModuleName ),
371375 app .AccountKeeper ,
372376 app .BankKeeper ,
373- & stakingKeeper ,
377+ & app . StakingKeeper ,
374378 authtypes .FeeCollectorName ,
375379 )
376380
377381 app .SlashingKeeper = slashingkeeper .NewKeeper (
378382 appCodec ,
379383 keys [slashingtypes .StoreKey ],
380- & stakingKeeper ,
384+ & app . StakingKeeper ,
381385 app .GetSubspace (slashingtypes .ModuleName ),
382386 )
383387
@@ -416,12 +420,6 @@ func New(
416420 authtypes .NewModuleAddress (govtypes .ModuleName ).String (),
417421 )
418422
419- // register the staking hooks
420- // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
421- app .StakingKeeper = * stakingKeeper .SetHooks (
422- stakingtypes .NewMultiStakingHooks (app .DistrKeeper .Hooks (), app .SlashingKeeper .Hooks ()),
423- )
424-
425423 // ... other modules keepers
426424
427425 // Create IBC Keeper
@@ -492,7 +490,7 @@ func New(
492490 app .GetSubspace (govtypes .ModuleName ),
493491 app .AccountKeeper ,
494492 app .BankKeeper ,
495- & stakingKeeper ,
493+ & app . StakingKeeper ,
496494 govRouter ,
497495 app .MsgServiceRouter (),
498496 govConfig ,
@@ -508,6 +506,8 @@ func New(
508506
509507 // this line is used by starport scaffolding # stargate/app/keeperDefinition
510508
509+ /**** IBC Routing ****/
510+
511511 // Sealing prevents other modules from creating scoped sub-keepers
512512 app .CapabilityKeeper .Seal ()
513513
@@ -518,7 +518,25 @@ func New(
518518 // this line is used by starport scaffolding # ibc/app/router
519519 app .IBCKeeper .SetRouter (ibcRouter )
520520
521- /**** Module Options ****/
521+ /**** Module Hooks ****/
522+
523+ // register hooks after all modules have been initialized
524+
525+ app .StakingKeeper .SetHooks (
526+ stakingtypes .NewMultiStakingHooks (
527+ // insert staking hooks receivers here
528+ app .DistrKeeper .Hooks (),
529+ app .SlashingKeeper .Hooks (),
530+ ),
531+ )
532+
533+ app .GovKeeper .SetHooks (
534+ govtypes .NewMultiGovHooks (
535+ // insert governance hooks receivers here
536+ ),
537+ )
538+
539+ /**** Module Options ****/
522540
523541 // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
524542 // we prefer to be more strict in what arguments the modules expect.
@@ -690,7 +708,7 @@ func New(
690708 },
691709 )
692710 if err != nil {
693- panic (fmt .Errorf ("failed to create AnteHandler: %s " , err ))
711+ panic (fmt .Errorf ("failed to create AnteHandler: %w " , err ))
694712 }
695713
696714 app .SetAnteHandler (anteHandler )
@@ -714,9 +732,6 @@ func New(
714732// Name returns the name of the App
715733func (app * App ) Name () string { return app .BaseApp .Name () }
716734
717- // GetBaseApp returns the base app of the application
718- func (app App ) GetBaseApp () * baseapp.BaseApp { return app .BaseApp }
719-
720735// BeginBlocker application updates every begin block
721736func (app * App ) BeginBlocker (ctx sdk.Context , req abci.RequestBeginBlock ) abci.ResponseBeginBlock {
722737 return app .mm .BeginBlock (ctx , req )
0 commit comments