Skip to content

Commit

Permalink
fead: initial ICA integration
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjoon-lee committed Feb 4, 2023
1 parent f9221e3 commit fb53438
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
Expand Down Expand Up @@ -202,6 +207,7 @@ var (
feegrantmodule.AppModuleBasic{},
authzmodule.AppModuleBasic{},
datadeal.AppModuleBasic{},
ica.AppModuleBasic{},
)

// module account permissions
Expand All @@ -213,10 +219,9 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
// TODO: ICA
// icatypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
burntypes.ModuleName: {authtypes.Burner},
icatypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
burntypes.ModuleName: {authtypes.Burner},
}
)

Expand Down Expand Up @@ -264,16 +269,15 @@ type App struct {
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
// TODO: ICA
// icaControllerKeeper icacontrollerkeeper.Keeper
// icaHostKeeper icahostkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
scopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

Expand Down Expand Up @@ -329,6 +333,7 @@ func New(
wasm.StoreKey,
feegrant.StoreKey,
datadealtypes.StoreKey,
icahosttypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand All @@ -354,6 +359,7 @@ func New(

// grant capabilities for the ibc and ibc-transfer modules
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName)

Expand Down Expand Up @@ -419,30 +425,18 @@ func New(
transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)

// TODO: enable ICA something like this

// icaModule := ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper)

// // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do
// // not replicate if you do not need to test core IBC or light clients.
// mockModule := ibcmock.NewAppModule(&app.ibcKeeper.PortKeeper)
// mockIBCModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp(ibcmock.ModuleName, scopedIBCMockKeeper))

// app.icaControllerKeeper = icacontrollerkeeper.NewKeeper(
// appCodec, keys[icacontrollertypes.StoreKey], app.getSubspace(icacontrollertypes.SubModuleName),
// app.ibcKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee
// app.ibcKeeper.ChannelKeeper, &app.ibcKeeper.PortKeeper,
// scopedicaControllerKeeper, app.MsgServiceRouter(),
// )

// // initialize ICA module with mock module as the authentication module on the controller side
// icaAuthModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp("", scopedICAMockKeeper))
// app.icaAuthModule = icaAuthModule

// icaControllerIBCModule := icacontroller.NewIBCModule(app.icaControllerKeeper, icaAuthModule)
// icaHostIBCModule := icahost.NewIBCModule(app.icaHostKeeper)

///////////////////////////////////////////////////////////////////////////////////////////////////////////
app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
keys[icahosttypes.StoreKey],
app.GetSubspace(icahosttypes.SubModuleName),
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
scopedICAHostKeeper,
app.MsgServiceRouter(),
)
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
Expand Down Expand Up @@ -525,11 +519,7 @@ func New(
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
ibcRouter.AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.wasmKeeper, app.IBCKeeper.ChannelKeeper))
// FIXME: these are for ICA later
// AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
// AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
// AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerIBCModule). // ica with mock auth module stack route to ica (top level of middleware stack)
// AddRoute(ibcmock.ModuleName, mockIBCModule)
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)

// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)
Expand Down Expand Up @@ -565,6 +555,7 @@ func New(
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
icaModule,
aol.NewAppModule(appCodec, app.aolKeeper),
did.NewAppModule(appCodec, app.didKeeper),
burn.NewAppModule(appCodec, app.burnKeeper),
Expand All @@ -591,6 +582,8 @@ func New(
govtypes.ModuleName,
paramstypes.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
authtypes.ModuleName,
aoltypes.ModuleName,
didtypes.ModuleName,
Expand Down Expand Up @@ -623,6 +616,8 @@ func New(
capabilitytypes.ModuleName,
slashingtypes.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
aoltypes.ModuleName,
oracletypes.ModuleName,
wasm.ModuleName,
Expand Down Expand Up @@ -651,6 +646,8 @@ func New(
evidencetypes.ModuleName,
feegrant.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
aoltypes.ModuleName,
didtypes.ModuleName,
burntypes.ModuleName,
Expand Down Expand Up @@ -722,6 +719,7 @@ func New(
}

app.ScopedIBCKeeper = scopedIBCKeeper
app.scopedICAHostKeeper = scopedICAHostKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedWasmKeeper = scopedWasmKeeper

Expand Down Expand Up @@ -885,6 +883,8 @@ func initParamsKeeper(appCodec codec.Codec, legacyAmino *codec.LegacyAmino, key,
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(aoltypes.ModuleName)
paramsKeeper.Subspace(didtypes.ModuleName)
paramsKeeper.Subspace(burntypes.ModuleName)
Expand Down

0 comments on commit fb53438

Please sign in to comment.