diff --git a/.changeset/entries/be9c9c9795f61af352d633a8b7d40882a765149a7c5ad7a7c5d666feb4809151.yaml b/.changeset/entries/be9c9c9795f61af352d633a8b7d40882a765149a7c5ad7a7c5d666feb4809151.yaml new file mode 100644 index 0000000000..c40accde6e --- /dev/null +++ b/.changeset/entries/be9c9c9795f61af352d633a8b7d40882a765149a7c5ad7a7c5d666feb4809151.yaml @@ -0,0 +1,6 @@ +type: feat +module: other +pull_request: 1082 +description: integrate interchain account module +backward_compatible: true +date: 2023-02-03T09:48:02.6497929Z diff --git a/app/app.go b/app/app.go index ecb9ddcad3..b7d404fa1b 100644 --- a/app/app.go +++ b/app/app.go @@ -115,6 +115,15 @@ import ( ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" + ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" + icacontroller "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller" + icacontrollerkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/keeper" + icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types" + icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" + "github.com/cosmos/cosmos-sdk/x/upgrade" upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" @@ -248,6 +257,7 @@ var ( ibc.AppModuleBasic{}, ibctransfer.AppModuleBasic{}, ibcfee.AppModuleBasic{}, + ica.AppModuleBasic{}, // Custom modules profiles.AppModuleBasic{}, @@ -271,6 +281,7 @@ var ( ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, wasm.ModuleName: {authtypes.Burner}, ibcfeetypes.ModuleName: nil, + icatypes.ModuleName: nil, } ) @@ -310,15 +321,19 @@ type DesmosApp struct { WasmKeeper wasm.Keeper // IBC modules - TransferKeeper ibctransferkeeper.Keeper - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - IBCFeeKeeper ibcfeekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + IBCFeeKeeper ibcfeekeeper.Keeper + ICAControllerKeeper icacontrollerkeeper.Keeper + ICAHostKeeper icahostkeeper.Keeper // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedIBCTransferKeeper capabilitykeeper.ScopedKeeper - ScopedProfilesKeeper capabilitykeeper.ScopedKeeper - ScopedWasmKeeper capabilitykeeper.ScopedKeeper + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedIBCTransferKeeper capabilitykeeper.ScopedKeeper + ScopedProfilesKeeper capabilitykeeper.ScopedKeeper + ScopedWasmKeeper capabilitykeeper.ScopedKeeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper // Custom modules FeesKeeper feeskeeper.Keeper @@ -376,6 +391,7 @@ func NewDesmosApp( // IBC modules ibcfeetypes.StoreKey, ibchost.StoreKey, ibctransfertypes.StoreKey, + icacontrollertypes.StoreKey, icahosttypes.StoreKey, // Custom modules profilestypes.StoreKey, relationshipstypes.StoreKey, subspacestypes.StoreKey, @@ -408,6 +424,8 @@ func NewDesmosApp( scopedIBCTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedProfilesKeeper := app.CapabilityKeeper.ScopeToModule(profilestypes.ModuleName) scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName) + scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) + scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) // seal capability keeper after scoping modules app.CapabilityKeeper.Seal() @@ -481,6 +499,28 @@ func NewDesmosApp( scopedIBCTransferKeeper, ) + // Create interchain account keepers + app.ICAHostKeeper = icahostkeeper.NewKeeper( + appCodec, + keys[icahosttypes.StoreKey], + app.GetSubspace(icahosttypes.SubModuleName), + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + app.AccountKeeper, + scopedICAHostKeeper, + app.MsgServiceRouter(), + ) + app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( + appCodec, + keys[icacontrollertypes.StoreKey], + app.GetSubspace(icacontrollertypes.SubModuleName), + app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + scopedICAControllerKeeper, + app.MsgServiceRouter(), + ) + // Create fees keeper app.FeesKeeper = feeskeeper.NewKeeper(app.appCodec, app.GetSubspace(feestypes.ModuleName)) @@ -626,11 +666,21 @@ func NewDesmosApp( profilesIBCModule := ibcfee.NewIBCMiddleware(profiles.NewIBCModule(app.appCodec, app.ProfileKeeper), app.IBCFeeKeeper) wasmIBCModule := ibcfee.NewIBCMiddleware(wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper), app.IBCFeeKeeper) - // Create static IBC router, add routes, then set and seal it + // TODO: After available ICA auth module released, replace nil the module + icaControllerIBCModule := ibcfee.NewIBCMiddleware( + icacontroller.NewIBCMiddleware(nil, app.ICAControllerKeeper), + app.IBCFeeKeeper) + + icaHostIBCModule := ibcfee.NewIBCMiddleware(icahost.NewIBCModule(app.ICAHostKeeper), app.IBCFeeKeeper) + + // Create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter(). AddRoute(ibctransfertypes.ModuleName, transferIBCModule). AddRoute(profilestypes.ModuleName, profilesIBCModule). - AddRoute(wasm.ModuleName, wasmIBCModule) + AddRoute(wasm.ModuleName, wasmIBCModule). + AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule). + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) + app.IBCKeeper.SetRouter(ibcRouter) /**** Module Options ****/ @@ -667,6 +717,7 @@ func NewDesmosApp( ibc.NewAppModule(app.IBCKeeper), ibctransfer.NewAppModule(app.TransferKeeper), ibcfee.NewAppModule(app.IBCFeeKeeper), + ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), // Custom modules fees.NewAppModule(app.appCodec, app.FeesKeeper), @@ -708,6 +759,7 @@ func NewDesmosApp( ibchost.ModuleName, ibctransfertypes.ModuleName, ibcfeetypes.ModuleName, + icatypes.ModuleName, // Custom modules feestypes.ModuleName, @@ -743,6 +795,7 @@ func NewDesmosApp( ibchost.ModuleName, ibctransfertypes.ModuleName, ibcfeetypes.ModuleName, + icatypes.ModuleName, // Custom modules feestypes.ModuleName, @@ -786,6 +839,7 @@ func NewDesmosApp( ibchost.ModuleName, ibctransfertypes.ModuleName, ibcfeetypes.ModuleName, + icatypes.ModuleName, // Custom modules feestypes.ModuleName, @@ -935,6 +989,8 @@ func NewDesmosApp( app.ScopedIBCTransferKeeper = scopedIBCTransferKeeper app.ScopedProfilesKeeper = scopedProfilesKeeper app.ScopedWasmKeeper = scopedWasmKeeper + app.ScopedICAHostKeeper = scopedICAHostKeeper + app.ScopedICAControllerKeeper = scopedICAControllerKeeper if loadLatest { if err := app.LoadLatestVersion(); err != nil { @@ -1165,6 +1221,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(icahosttypes.SubModuleName) + paramsKeeper.Subspace(icacontrollertypes.SubModuleName) paramsKeeper.Subspace(feestypes.ModuleName) paramsKeeper.Subspace(subspacestypes.ModuleName)