Skip to content

Commit

Permalink
fix: ICA controller wiring (#2884)
Browse files Browse the repository at this point in the history
Fix #2867
  • Loading branch information
tbruyelle authored Oct 5, 2022
1 parent d780486 commit b08039f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

### Fixes

- Fix ICA controller wiring.
- Change vuex generation to use a default TS client path.
- Fix cli action org in templates.
- Seal the capability keeper in the `app.go` template
Expand Down
36 changes: 24 additions & 12 deletions ignite/templates/app/stargate/app/app.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ import (
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"
icacontrollerkeeper "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
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"
Expand Down Expand Up @@ -231,9 +233,9 @@ type App struct {
GroupKeeper groupkeeper.Keeper

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

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

Expand All @@ -242,7 +244,7 @@ type App struct {

// sm is the simulation manager
sm *module.SimulationManager
configurator module.Configurator
configurator module.Configurator
}

// New returns a reference to an initialized blockchain app
Expand Down Expand Up @@ -272,6 +274,7 @@ func New(
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,
icacontrollertypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -307,12 +310,13 @@ func New(

// grant capabilities for the ibc and ibc-transfer modules
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
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 @@ -415,7 +419,7 @@ func New(
// ... other modules keepers

// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec, keys[ibchost.StoreKey],
app.GetSubspace(ibchost.ModuleName),
app.StakingKeeper,
Expand All @@ -435,8 +439,8 @@ func New(
app.BankKeeper,
scopedTransferKeeper,
)
transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)
transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec, keys[icahosttypes.StoreKey],
Expand All @@ -447,7 +451,14 @@ func New(
scopedICAHostKeeper,
app.MsgServiceRouter(),
)
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
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(),
)
icaModule := ica.NewAppModule(&icaControllerKeeper, &app.ICAHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
Expand Down Expand Up @@ -488,15 +499,15 @@ func New(
// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))

// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
Expand Down Expand Up @@ -533,7 +544,7 @@ func New(
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
app.mm.SetOrderBeginBlockers(
// upgrades should be run first
// upgrades should be run first
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
minttypes.ModuleName,
Expand Down Expand Up @@ -835,6 +846,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

Expand Down

0 comments on commit b08039f

Please sign in to comment.