Skip to content

Commit

Permalink
refactor: refactor keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Mar 25, 2024
1 parent f63e897 commit dc95e98
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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],
Expand All @@ -566,26 +553,38 @@ 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
app.TransferKeeper = ibctransferkeeper.NewKeeper(
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,
app.BankKeeper,
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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dc95e98

Please sign in to comment.