-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
219 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
package app | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" | ||
"github.com/cosmos/cosmos-sdk/x/upgrade" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts" | ||
icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller" | ||
icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper" | ||
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" | ||
icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host" | ||
icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" | ||
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" | ||
ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" | ||
ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" | ||
ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" | ||
ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" | ||
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" | ||
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" | ||
ibc "github.com/cosmos/ibc-go/v7/modules/core" | ||
ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" | ||
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" | ||
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" | ||
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" | ||
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" | ||
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" | ||
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" | ||
// this line is used by starport scaffolding # ibc/app/import | ||
) | ||
|
||
func (app *App) registerIBCModules() { | ||
// set up non depinject support modules store keys | ||
app.keys = sdk.NewKVStoreKeys( | ||
ibcexported.StoreKey, | ||
ibctransfertypes.StoreKey, | ||
ibcfeetypes.StoreKey, | ||
icahosttypes.StoreKey, | ||
icacontrollertypes.StoreKey, | ||
) | ||
app.MountKVStores(app.keys) | ||
|
||
// set params subspaces | ||
for _, m := range []string{ibctransfertypes.ModuleName, ibcexported.ModuleName, icahosttypes.SubModuleName, icacontrollertypes.SubModuleName} { | ||
app.ParamsKeeper.Subspace(m) | ||
} | ||
|
||
// add capability keeper and ScopeToModule for ibc module | ||
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) | ||
scopedIBCTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) | ||
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) | ||
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) | ||
|
||
// Create IBC keeper | ||
app.IBCKeeper = ibckeeper.NewKeeper( | ||
app.appCodec, app.GetKey(ibcexported.StoreKey), app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, | ||
) | ||
|
||
// Register the proposal types | ||
// Deprecated: Avoid adding new handlers, instead use the new proposal flow | ||
// by granting the governance module the right to execute the message. | ||
// See: https://docs.cosmos.network/main/modules/gov#proposal-messages | ||
govRouter := govv1beta1.NewRouter() | ||
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). | ||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). | ||
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) | ||
|
||
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( | ||
app.appCodec, app.GetKey(ibcfeetypes.StoreKey), | ||
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware | ||
app.IBCKeeper.ChannelKeeper, | ||
&app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, | ||
) | ||
|
||
// Create IBC transfer keeper | ||
app.IBCTransferKeeper = ibctransferkeeper.NewKeeper( | ||
app.appCodec, | ||
app.GetKey(ibctransfertypes.StoreKey), | ||
app.GetSubspace(ibctransfertypes.ModuleName), | ||
app.IBCKeeper.ChannelKeeper, | ||
app.IBCKeeper.ChannelKeeper, | ||
&app.IBCKeeper.PortKeeper, | ||
app.AccountKeeper, | ||
app.BankKeeper, | ||
scopedIBCTransferKeeper, | ||
) | ||
|
||
// Create interchain account keepers | ||
app.ICAHostKeeper = icahostkeeper.NewKeeper( | ||
app.appCodec, | ||
app.GetKey(icahosttypes.StoreKey), | ||
app.GetSubspace(icahosttypes.SubModuleName), | ||
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack | ||
app.IBCKeeper.ChannelKeeper, | ||
&app.IBCKeeper.PortKeeper, | ||
app.AccountKeeper, | ||
scopedICAHostKeeper, | ||
app.MsgServiceRouter(), | ||
) | ||
app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( | ||
app.appCodec, | ||
app.GetKey(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(), | ||
) | ||
app.GovKeeper.SetLegacyRouter(govRouter) | ||
|
||
// Create IBC modules with ibcfee middleware | ||
transferIBCModule := ibcfee.NewIBCMiddleware(ibctransfer.NewIBCModule(app.IBCTransferKeeper), app.IBCFeeKeeper) | ||
|
||
// integration point for custom authentication modules | ||
var noAuthzModule porttypes.IBCModule | ||
icaControllerIBCModule := ibcfee.NewIBCMiddleware( | ||
icacontroller.NewIBCMiddleware(noAuthzModule, 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(icacontrollertypes.SubModuleName, icaControllerIBCModule). | ||
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) | ||
|
||
// this line is used by starport scaffolding # ibc/app/module | ||
|
||
app.IBCKeeper.SetRouter(ibcRouter) | ||
|
||
// NOTE: Any module instantiated in the module manager that is later modified | ||
// must be passed by reference here. | ||
legacyModules := []module.AppModule{ | ||
ibc.NewAppModule(app.IBCKeeper), | ||
ibctransfer.NewAppModule(app.IBCTransferKeeper), | ||
ibcfee.NewAppModule(app.IBCFeeKeeper), | ||
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), | ||
} | ||
if err := app.RegisterModules(legacyModules...); err != nil { | ||
panic(err) | ||
} | ||
|
||
// TODO: do we need this? | ||
//cfg := app.Configurator() | ||
//for _, m := range legacyModules { | ||
// if s, ok := m.(module.HasServices); ok { | ||
// s.RegisterServices(cfg) | ||
// } | ||
//} | ||
|
||
// register additional types | ||
ibctm.AppModuleBasic{}.RegisterInterfaces(app.interfaceRegistry) | ||
solomachine.AppModuleBasic{}.RegisterInterfaces(app.interfaceRegistry) | ||
|
||
app.ScopedIBCKeeper = scopedIBCKeeper | ||
app.ScopedIBCTransferKeeper = scopedIBCTransferKeeper | ||
app.ScopedICAHostKeeper = scopedICAHostKeeper | ||
app.ScopedICAControllerKeeper = scopedICAControllerKeeper | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.