@@ -4,6 +4,13 @@ import (
44 "path/filepath"
55 "strings"
66
7+ ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
8+ icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
9+ icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
10+ icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host"
11+ icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
12+ icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
13+
714 wasmdapp "github.com/CosmWasm/wasmd/app"
815 "github.com/CosmWasm/wasmd/x/wasm"
916 wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
@@ -76,6 +83,7 @@ import (
7683 // ---------------------------------------------------------------
7784 // IBC imports
7885
86+ icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper"
7987 ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee"
8088 ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper"
8189 ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
@@ -151,11 +159,15 @@ type AppKeepers struct {
151159 ibcKeeper * ibckeeper.Keeper
152160 ibcFeeKeeper ibcfeekeeper.Keeper
153161 /* ibcTransferKeeper is for cross-chain fungible token transfers. */
154- ibcTransferKeeper ibctransferkeeper.Keeper
162+ ibcTransferKeeper ibctransferkeeper.Keeper
163+ icaControllerKeeper icacontrollerkeeper.Keeper
164+ icaHostKeeper icahostkeeper.Keeper
155165
156166 // make scoped keepers public for test purposes
157- ScopedIBCKeeper capabilitykeeper.ScopedKeeper
158- ScopedTransferKeeper capabilitykeeper.ScopedKeeper
167+ ScopedIBCKeeper capabilitykeeper.ScopedKeeper
168+ ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
169+ ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
170+ ScopedTransferKeeper capabilitykeeper.ScopedKeeper
159171
160172 // make IBC modules public for test purposes
161173 // these modules are never directly routed to by the IBC Router
@@ -201,6 +213,8 @@ func initStoreKeys() (
201213 ibctransfertypes .StoreKey ,
202214 ibcfeetypes .StoreKey ,
203215 ibcexported .StoreKey ,
216+ icahosttypes .StoreKey ,
217+ icacontrollertypes .StoreKey ,
204218
205219 // nibiru x/ keys
206220 oracletypes .StoreKey ,
@@ -247,6 +261,8 @@ func (app *NibiruApp) InitKeepers(
247261 memKeys [capabilitytypes .MemStoreKey ],
248262 )
249263 app .ScopedIBCKeeper = app .capabilityKeeper .ScopeToModule (ibcexported .ModuleName )
264+ app .ScopedICAControllerKeeper = app .capabilityKeeper .ScopeToModule (icacontrollertypes .SubModuleName )
265+ app .ScopedICAHostKeeper = app .capabilityKeeper .ScopeToModule (icahosttypes .SubModuleName )
250266 // scopedFeeMockKeeper := app.capabilityKeeper.ScopeToModule(MockFeePort)
251267 app .ScopedTransferKeeper = app .capabilityKeeper .ScopeToModule (ibctransfertypes .ModuleName )
252268
@@ -401,6 +417,28 @@ func (app *NibiruApp) InitKeepers(
401417 app .ScopedTransferKeeper ,
402418 )
403419
420+ app .icaControllerKeeper = icacontrollerkeeper .NewKeeper (
421+ appCodec , keys [icacontrollertypes .StoreKey ],
422+ app .GetSubspace (icacontrollertypes .SubModuleName ),
423+ app .ibcFeeKeeper ,
424+ app .ibcKeeper .ChannelKeeper ,
425+ & app .ibcKeeper .PortKeeper ,
426+ app .ScopedICAControllerKeeper ,
427+ app .MsgServiceRouter (),
428+ )
429+
430+ app .icaHostKeeper = icahostkeeper .NewKeeper (
431+ appCodec ,
432+ keys [icahosttypes .StoreKey ],
433+ app .GetSubspace (icahosttypes .SubModuleName ),
434+ app .ibcFeeKeeper ,
435+ app .ibcKeeper .ChannelKeeper ,
436+ & app .ibcKeeper .PortKeeper ,
437+ app .AccountKeeper ,
438+ app .ScopedICAHostKeeper ,
439+ app .MsgServiceRouter (),
440+ )
441+
404442 app .ScopedWasmKeeper = app .capabilityKeeper .ScopeToModule (wasmtypes .ModuleName )
405443
406444 wasmDir := filepath .Join (homePath , "data" )
@@ -491,8 +529,11 @@ func (app *NibiruApp) InitKeepers(
491529 transferStack = ibctransfer .NewIBCModule (app .ibcTransferKeeper )
492530 transferStack = ibcfee .NewIBCMiddleware (transferStack , app .ibcFeeKeeper )
493531
532+ // Create the second stack for ICA
533+ icaHostIBCModule := icahost .NewIBCModule (app .icaHostKeeper )
534+
494535 // Add transfer stack to IBC Router
495- ibcRouter .AddRoute (ibctransfertypes .ModuleName , transferStack )
536+ ibcRouter .AddRoute (icahosttypes . SubModuleName , icaHostIBCModule ). AddRoute ( ibctransfertypes .ModuleName , transferStack )
496537
497538 // Create Mock IBC Fee module stack for testing
498539 // SendPacket, since it is originating from the application to core IBC:
@@ -579,6 +620,7 @@ func (app *NibiruApp) initAppModules(
579620 ibc .NewAppModule (app .ibcKeeper ),
580621 ibctransfer .NewAppModule (app .ibcTransferKeeper ),
581622 ibcfee .NewAppModule (app .ibcFeeKeeper ),
623+ ica .NewAppModule (& app .icaControllerKeeper , & app .icaHostKeeper ),
582624
583625 // wasm
584626 wasm .NewAppModule (
@@ -647,6 +689,7 @@ func orderedModuleNames() []string {
647689 ibctransfertypes .ModuleName ,
648690 ibcexported .ModuleName ,
649691 ibcfeetypes .ModuleName ,
692+ icatypes .ModuleName ,
650693
651694 // --------------------------------------------------------------------
652695 // CosmWasm
@@ -749,6 +792,7 @@ func ModuleBasicManager() module.BasicManager {
749792 ibc.AppModuleBasic {},
750793 ibctransfer.AppModuleBasic {},
751794 ibctm.AppModuleBasic {},
795+ ica.AppModuleBasic {},
752796 // native x/
753797 oracle.AppModuleBasic {},
754798 epochs.AppModuleBasic {},
@@ -773,6 +817,7 @@ func ModuleAccPerms() map[string][]string {
773817 oracletypes .ModuleName : {},
774818 ibctransfertypes .ModuleName : {authtypes .Minter , authtypes .Burner },
775819 ibcfeetypes .ModuleName : {},
820+ icatypes .ModuleName : {},
776821
777822 epochstypes .ModuleName : {},
778823 sudotypes .ModuleName : {},
@@ -802,6 +847,8 @@ func initParamsKeeper(
802847 paramsKeeper .Subspace (ibctransfertypes .ModuleName )
803848 paramsKeeper .Subspace (ibcexported .ModuleName )
804849 paramsKeeper .Subspace (ibcfeetypes .ModuleName )
850+ paramsKeeper .Subspace (icacontrollertypes .SubModuleName )
851+ paramsKeeper .Subspace (icahosttypes .SubModuleName )
805852 // wasm params keepers
806853 paramsKeeper .Subspace (wasmtypes .ModuleName )
807854 paramsKeeper .Subspace (devgastypes .ModuleName )
0 commit comments