Skip to content

Commit

Permalink
feat(app): add interchain accounts for v0.46.0 (#2703)
Browse files Browse the repository at this point in the history
* update template for ica

* Update ignite/templates/app/stargate/app/app.go.plush

Co-authored-by: Lucas Btd <[email protected]>

Co-authored-by: Lucas Btd <[email protected]>
  • Loading branch information
Alex Johnson and lumtis authored Aug 10, 2022
1 parent 5da72db commit d1a6819
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions ignite/templates/app/stargate/app/app.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,18 @@ 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/v5/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/ibc-go/v5/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v5/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v5/modules/core"
ibcclient "github.com/cosmos/ibc-go/v5/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v5/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
ibcporttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v5/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v5/modules/core/keeper"
Expand Down Expand Up @@ -152,6 +159,7 @@ var (
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
ica.AppModuleBasic{},
vesting.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)
Expand All @@ -160,6 +168,7 @@ var (
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
icatypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
Expand Down Expand Up @@ -217,12 +226,14 @@ type App struct {
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper

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

// this line is used by starport scaffolding # stargate/app/keeperDeclaration

Expand Down Expand Up @@ -258,9 +269,9 @@ func New(

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey,
paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey,
ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -297,10 +308,11 @@ func New(
// grant capabilities for the ibc and ibc-transfer modules
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
// this line is used by starport scaffolding # stargate/app/scopedKeeper

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec,
keys[authtypes.StoreKey],
app.GetSubspace(authtypes.ModuleName),
Expand Down Expand Up @@ -423,11 +435,20 @@ app.AccountKeeper = authkeeper.NewAccountKeeper(
app.BankKeeper,
scopedTransferKeeper,
)
transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)

var (
transferModule = transfer.NewAppModule(app.TransferKeeper)
transferIBCModule = transfer.NewIBCModule(app.TransferKeeper)
)
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 All @@ -444,8 +465,8 @@ app.AccountKeeper = authkeeper.NewAccountKeeper(
AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))

AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
govConfig := govtypes.DefaultConfig()
app.GovKeeper = govkeeper.NewKeeper(
appCodec,
Expand All @@ -463,7 +484,8 @@ app.AccountKeeper = authkeeper.NewAccountKeeper(

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)

Expand Down Expand Up @@ -499,6 +521,7 @@ app.AccountKeeper = authkeeper.NewAccountKeeper(
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
icaModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand All @@ -521,6 +544,7 @@ app.AccountKeeper = authkeeper.NewAccountKeeper(
crisistypes.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
Expand All @@ -536,6 +560,7 @@ app.AccountKeeper = authkeeper.NewAccountKeeper(
stakingtypes.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand Down Expand Up @@ -571,6 +596,7 @@ app.AccountKeeper = authkeeper.NewAccountKeeper(
genutiltypes.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
Expand Down Expand Up @@ -806,6 +832,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down

0 comments on commit d1a6819

Please sign in to comment.