Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(templates): add all ibc commands #3858

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- [#3827](https://github.com/ignite/cli/pull/3827) Change ignite apps to be able to run in any directory
- [#3831](https://github.com/ignite/cli/pull/3831) Correct ignite app gRPC server stop memory issue
- [#3825](https://github.com/ignite/cli/pull/3825) Fix a minor Keplr type-checking bug in TS client
- [#3836](https://github.com/ignite/cli/pull/3836) Add missing IBC commands for scaffolded chain
- [#3836](https://github.com/ignite/cli/pull/3836), [#3858](https://github.com/ignite/cli/pull/3858) Add missing IBC commands for scaffolded chain
- [#3833](https://github.com/ignite/cli/pull/3833) Improve Cosmos SDK detection to support SDK forks
- [#3849](https://github.com/ignite/cli/pull/3849) Add missing `tx.go` file by default and enable cli if autocli does not exist
- [#3851](https://github.com/ignite/cli/pull/3851) Add missing ibc interfaces to chain client
Expand Down
35 changes: 24 additions & 11 deletions ignite/templates/app/files/app/ibc.go.plush
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package app

import (
"cosmossdk.io/core/appmodule"
storetypes "cosmossdk.io/store/types"
cdctypes "github.com/cosmos/cosmos-sdk/codec/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"
Expand Down Expand Up @@ -180,14 +180,27 @@ func (app *App) registerIBCModules() {
}
}

// RegisterIBC adds the missing IBC modules and interfaces into the module manager.
func RegisterIBC(moduleManager module.BasicManager, registry cdctypes.InterfaceRegistry) {
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{}
// Since the IBC modules don't support dependency injection, we need to
// manually register the modules on the client side.
// This needs to be removed after IBC supports App Wiring.
func RegisterIBC(registry cdctypes.InterfaceRegistry) map[string]appmodule.AppModule {
modules := map[string]appmodule.AppModule{
ibcexported.ModuleName: ibc.AppModule{},
ibctransfertypes.ModuleName: ibctransfer.AppModule{},
ibcfeetypes.ModuleName: ibcfee.AppModule{},
icatypes.ModuleName: icamodule.AppModule{},
capabilitytypes.ModuleName: capability.AppModule{},
ibctm.ModuleName: ibctm.AppModule{},
solomachine.ModuleName: solomachine.AppModule{},
}

ibctm.AppModuleBasic{}.RegisterInterfaces(registry)
solomachine.AppModuleBasic{}.RegisterInterfaces(registry)
}
for _, module := range modules {
if mod, ok := module.(interface {
RegisterInterfaces(registry cdctypes.InterfaceRegistry)
}); ok {
mod.RegisterInterfaces(registry)
}
}

return modules
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
ibccmd "github.com/cosmos/ibc-go/v8/modules/core/client/cli"
"github.com/spf13/cobra"
"github.com/spf13/viper"

Expand Down Expand Up @@ -88,7 +87,6 @@ func queryCommand() *cobra.Command {
server.QueryBlocksCmd(),
authcmd.QueryTxCmd(),
server.QueryBlockResultsCmd(),
ibccmd.GetQueryCmd(),
)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")

Expand All @@ -115,7 +113,6 @@ func txCommand() *cobra.Command {
authcmd.GetEncodeCommand(),
authcmd.GetDecodeCommand(),
authcmd.GetSimulateCmd(),
ibccmd.GetTxCmd(),
)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ 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.RegisterIBC(moduleBasicManager, clientCtx.InterfaceRegistry)

rootCmd := &cobra.Command{
Use: app.Name + "d",
Expand Down Expand Up @@ -108,6 +104,13 @@ func NewRootCmd() *cobra.Command {
},
}

// Since the IBC modules don't support dependency injection, we need to
// manually register the modules on the client side.
// This needs to be removed after IBC supports App Wiring.
ibcModules := app.RegisterIBC(clientCtx.InterfaceRegistry)
for name, module := range ibcModules {
autoCliOpts.Modules[name] = module
}
initRootCmd(rootCmd, clientCtx.TxConfig, clientCtx.InterfaceRegistry, clientCtx.Codec, moduleBasicManager)

overwriteFlagDefaults(rootCmd, map[string]string{
Expand Down
Loading