Skip to content

Commit

Permalink
fix: move keeper initializations above ibc stack setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hallazzang committed May 16, 2024
1 parent 2560a36 commit c9083dd
Showing 1 changed file with 58 additions and 58 deletions.
116 changes: 58 additions & 58 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,64 @@ func NewMilkApp(
ibcwasmhooks.NewWasmHooks(appCodec, ac, app.WasmKeeper),
)

app.InterchainQueryKeeper = icqkeeper.NewKeeper(appCodec, keys[icqtypes.StoreKey], app.IBCKeeper)

app.ICACallbacksKeeper = *icacallbackskeeper.NewKeeper(
appCodec,
keys[icacallbackstypes.StoreKey],
keys[icacallbackstypes.MemStoreKey],
app.GetSubspace(icacallbackstypes.ModuleName),
*app.IBCKeeper,
)

app.RecordsKeeper = *recordskeeper.NewKeeper(
appCodec,
keys[recordstypes.StoreKey],
keys[recordstypes.MemStoreKey],
app.GetSubspace(recordstypes.ModuleName),
app.AccountKeeper,
*app.TransferKeeper,
*app.IBCKeeper,
app.ICACallbacksKeeper,
)

app.StakeIBCKeeper = stakeibckeeper.NewKeeper(
appCodec,
keys[stakeibctypes.StoreKey],
keys[stakeibctypes.MemStoreKey],
app.GetSubspace(stakeibctypes.ModuleName),
authorityAddr,
app.AccountKeeper,
app.BankKeeper,
*app.ICAControllerKeeper,
*app.IBCKeeper,
app.InterchainQueryKeeper,
app.RecordsKeeper,
app.ICACallbacksKeeper,
app.RateLimitKeeper,
)

epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey])
app.EpochsKeeper = *epochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
app.StakeIBCKeeper.Hooks(),
),
)

// Register ICQ callbacks
err = app.InterchainQueryKeeper.SetCallbackHandler(stakeibctypes.ModuleName, app.StakeIBCKeeper.ICQCallbackHandler())
if err != nil {
panic(err)
}

// Register IBC callbacks
if err := app.ICACallbacksKeeper.SetICACallbacks(
app.StakeIBCKeeper.Callbacks(),
app.RecordsKeeper.Callbacks(),
); err != nil {
panic(err)
}

////////////////////////////
// Transfer configuration //
////////////////////////////
Expand Down Expand Up @@ -803,64 +861,6 @@ func NewMilkApp(

app.BankKeeper.SetHooks(app.TokenFactoryKeeper.Hooks())

app.InterchainQueryKeeper = icqkeeper.NewKeeper(appCodec, keys[icqtypes.StoreKey], app.IBCKeeper)

app.ICACallbacksKeeper = *icacallbackskeeper.NewKeeper(
appCodec,
keys[icacallbackstypes.StoreKey],
keys[icacallbackstypes.MemStoreKey],
app.GetSubspace(icacallbackstypes.ModuleName),
*app.IBCKeeper,
)

app.RecordsKeeper = *recordskeeper.NewKeeper(
appCodec,
keys[recordstypes.StoreKey],
keys[recordstypes.MemStoreKey],
app.GetSubspace(recordstypes.ModuleName),
app.AccountKeeper,
*app.TransferKeeper,
*app.IBCKeeper,
app.ICACallbacksKeeper,
)

app.StakeIBCKeeper = stakeibckeeper.NewKeeper(
appCodec,
keys[stakeibctypes.StoreKey],
keys[stakeibctypes.MemStoreKey],
app.GetSubspace(stakeibctypes.ModuleName),
authorityAddr,
app.AccountKeeper,
app.BankKeeper,
*app.ICAControllerKeeper,
*app.IBCKeeper,
app.InterchainQueryKeeper,
app.RecordsKeeper,
app.ICACallbacksKeeper,
app.RateLimitKeeper,
)

epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey])
app.EpochsKeeper = *epochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
app.StakeIBCKeeper.Hooks(),
),
)

// Register ICQ callbacks
err = app.InterchainQueryKeeper.SetCallbackHandler(stakeibctypes.ModuleName, app.StakeIBCKeeper.ICQCallbackHandler())
if err != nil {
panic(err)
}

// Register IBC callbacks
if err := app.ICACallbacksKeeper.SetICACallbacks(
app.StakeIBCKeeper.Callbacks(),
app.RecordsKeeper.Callbacks(),
); err != nil {
panic(err)
}

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
Expand Down

0 comments on commit c9083dd

Please sign in to comment.