From e73b9714b4f65323d387d7bb70296bae84871d62 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 23 Nov 2023 11:58:01 +0100 Subject: [PATCH] fix: `v0.50` ibc genesis issue (#3767) * remove unused callers * register ibc into the basic module manager for the clint * add changelog --------- Co-authored-by: Pantani --- changelog.md | 1 + ignite/templates/app/files/app/app.go.plush | 11 +++++------ ignite/templates/app/files/app/ibc.go.plush | 14 +++++++++++++- .../cmd/{{binaryNamePrefix}}d/cmd/root.go.plush | 4 ++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index cc5032b2cc..d7f1dfbe1c 100644 --- a/changelog.md +++ b/changelog.md @@ -51,6 +51,7 @@ - [#3726](https://github.com/ignite/cli/pull/3726) Update TS client dependencies. Bump vue/react template versions - [#3728](https://github.com/ignite/cli/pull/3728) Fix wrong parser for proto package names - [#3729](https://github.com/ignite/cli/pull/3729) Fix broken generator due to caching /tmp include folders +- [#3767](https://github.com/ignite/cli/pull/3767) Fix `v0.50` ibc genesis issue ## [`v0.27.2`](https://github.com/ignite/cli/releases/tag/v0.27.2) diff --git a/ignite/templates/app/files/app/app.go.plush b/ignite/templates/app/files/app/app.go.plush index 194f2a58f8..cbcb43e814 100644 --- a/ignite/templates/app/files/app/app.go.plush +++ b/ignite/templates/app/files/app/app.go.plush @@ -177,15 +177,15 @@ func New( appConfig = depinject.Configs( AppConfig(), depinject.Supply( - // supply the application options + // Supply the application options appOpts, // Supply with IBC keeper getter for the IBC modules with App Wiring. // The IBC Keeper cannot be passed because it has not been initiated yet. // Passing the getter, the app IBC Keeper will always be accessible. - // This needs to be removed after IBC supported App Wiring. + // This needs to be removed after IBC supports App Wiring. app.GetIBCKeeper, app.GetCapabilityScopedKeeper, - // supply the logger + // Supply the logger logger, // ADVANCED CONFIGURATION @@ -323,7 +323,7 @@ func New( // However, when registering a module manually (i.e. that does not support app wiring), the module version map // must be set manually as follow. The upgrade module will de-duplicate the module version map. // - // app.SetInitChainer(func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { + // app.SetInitChainer(func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { // app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) // return app.App.InitChainer(ctx, req) // }) @@ -353,8 +353,7 @@ func (app *App) AppCodec() codec.Codec { // GetKey returns the KVStoreKey for the provided store key. func (app *App) GetKey(storeKey string) *storetypes.KVStoreKey { - sk := app.UnsafeFindStoreKey(storeKey) - kvStoreKey, ok := sk.(*storetypes.KVStoreKey) + kvStoreKey, ok := app.UnsafeFindStoreKey(storeKey).(*storetypes.KVStoreKey) if !ok { return nil } diff --git a/ignite/templates/app/files/app/ibc.go.plush b/ignite/templates/app/files/app/ibc.go.plush index 3682300472..2fa1ea3766 100644 --- a/ignite/templates/app/files/app/ibc.go.plush +++ b/ignite/templates/app/files/app/ibc.go.plush @@ -2,6 +2,7 @@ package app import ( storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/types/module" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -16,6 +17,7 @@ import ( icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host" icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper" icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper" ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" @@ -34,6 +36,7 @@ import ( // this line is used by starport scaffolding # ibc/app/import ) +// registerIBCModules register IBC keepers and non dependency inject modules. func (app *App) registerIBCModules() { // set up non depinject support modules store keys if err := app.RegisterStores( @@ -162,7 +165,7 @@ func (app *App) registerIBCModules() { app.ScopedICAHostKeeper = scopedICAHostKeeper app.ScopedICAControllerKeeper = scopedICAControllerKeeper - // register IBC modules + // register IBC modules if err := app.RegisterModules( ibc.NewAppModule(app.IBCKeeper), ibctransfer.NewAppModule(app.TransferKeeper), @@ -175,3 +178,12 @@ func (app *App) registerIBCModules() { panic(err) } } + +// AddIBCModuleManager adds the missing IBC modules into the module manager. +func AddIBCModuleManager(moduleManager module.BasicManager) { + moduleManager[ibcexported.ModuleName] = ibc.AppModule{} + moduleManager[ibctransfertypes.ModuleName] = ibctransfer.AppModule{} + moduleManager[ibcfeetypes.ModuleName] = ibcfee.AppModule{} + moduleManager[icatypes.ModuleName] = icamodule.AppModule{} + moduleManager[capabilitytypes.ModuleName] = capability.AppModule{} +} diff --git a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush index e60eba7ca8..9015b89c31 100644 --- a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush +++ b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush @@ -55,6 +55,10 @@ func NewRootCmd() *cobra.Command { ); err != nil { panic(err) } + // Since the IBC modules don't support dependency injection, we need to + // manually add the modules to the basic manager on the client side. + // This needs to be removed after IBC supports App Wiring. + app.AddIBCModuleManager(moduleBasicManager) rootCmd := &cobra.Command{ Use: app.Name + "d",