From c9083dd7eeb7e8728b9070608fd6c62e36b316be Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Fri, 17 May 2024 05:01:23 +0900 Subject: [PATCH] fix: move keeper initializations above ibc stack setup --- app/app.go | 116 ++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/app/app.go b/app/app.go index 53e2fd97..d2592398 100644 --- a/app/app.go +++ b/app/app.go @@ -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 // //////////////////////////// @@ -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