From dc95e9858b2d796f3409aa8ad625a414ad6653b1 Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Mon, 25 Mar 2024 11:46:07 +0700 Subject: [PATCH] refactor: refactor keeper --- app/app.go | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/app/app.go b/app/app.go index 338eebd4..2a8eaca6 100644 --- a/app/app.go +++ b/app/app.go @@ -399,7 +399,6 @@ func NewMigalooApp( scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName) - app.CapabilityKeeper.Seal() // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( @@ -538,18 +537,6 @@ func NewMigalooApp( AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(app.AllianceKeeper)). AddRoute(feeburnmoduletypes.RouterKey, feeburnmodule.NewFeeBurnProposalHandler(app.FeeBurnKeeper)) - // RouterKeeper must be created before TransferKeeper - app.PacketForwardKeeper = packetforwardkeeper.NewKeeper( - appCodec, - app.keys[packetforwardtypes.StoreKey], - app.TransferKeeper, - app.IBCKeeper.ChannelKeeper, - app.DistrKeeper, - app.BankKeeper, - app.IBCKeeper.ChannelKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - // Configure the hooks keeper hooksKeeper := ibchookskeeper.NewKeeper( app.keys[ibchookstypes.StoreKey], @@ -566,10 +553,13 @@ func NewMigalooApp( // IBC Fee Module keeper app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( - appCodec, keys[ibcfeetypes.StoreKey], - app.HooksICS4Wrapper, // may be replaced with IBC middleware + appCodec, + keys[ibcfeetypes.StoreKey], + app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, + &app.IBCKeeper.PortKeeper, + app.AccountKeeper, + app.BankKeeper, ) // Create Transfer Keepers @@ -577,7 +567,7 @@ func NewMigalooApp( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware + app.HooksICS4Wrapper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, @@ -585,7 +575,16 @@ func NewMigalooApp( scopedTransferKeeper, ) - app.PacketForwardKeeper.SetTransferKeeper(app.TransferKeeper) + app.PacketForwardKeeper = packetforwardkeeper.NewKeeper( + appCodec, + app.keys[packetforwardtypes.StoreKey], + app.TransferKeeper, // Will be zero-value here. Reference is set later on with SetTransferKeeper. + app.IBCKeeper.ChannelKeeper, + app.DistrKeeper, + app.BankKeeper, + app.IBCKeeper.ChannelKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) // ICA Host keeper app.ICAHostKeeper = icahostkeeper.NewKeeper( @@ -634,7 +633,7 @@ func NewMigalooApp( app.BankKeeper, app.StakingKeeper, distrkeeper.NewQuerier(app.DistrKeeper), - app.IBCKeeper.ChannelKeeper, // ISC4 Wrapper: fee IBC middleware + app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.ScopedWasmKeeper, @@ -973,6 +972,8 @@ func NewMigalooApp( if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil { tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) } + + app.CapabilityKeeper.Seal() } return app