Skip to content

Commit

Permalink
Implement appmodule.AppModule interface for ibc-go packages' modules (#…
Browse files Browse the repository at this point in the history
…4332)

* implement for ica

* implement for fee

* implement for transfer

* implement for core

* remove usage of basic manager in commands

* remove basic managers from tx/q cmds arguments

* Fix linting issues.

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
  • Loading branch information
pysel and DimitrisJim authored Aug 21, 2023
1 parent ab0675d commit b95aadb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
9 changes: 9 additions & 0 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/core/appmodule"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -34,6 +36,7 @@ var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
_ module.AppModuleSimulation = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)

_ porttypes.IBCModule = (*host.IBCModule)(nil)
)
Expand All @@ -46,6 +49,12 @@ func (AppModuleBasic) Name() string {
return types.ModuleName
}

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModule) IsOnePerModuleType() {}

// IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsAppModule() {}

// RegisterLegacyAminoCodec implements AppModuleBasic.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}

Expand Down
9 changes: 9 additions & 0 deletions modules/apps/29-fee/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/core/appmodule"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -25,6 +27,7 @@ import (
var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
)

// AppModuleBasic is the 29-fee AppModuleBasic
Expand All @@ -35,6 +38,12 @@ func (AppModuleBasic) Name() string {
return types.ModuleName
}

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModule) IsOnePerModuleType() {}

// IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsAppModule() {}

// RegisterLegacyAminoCodec implements AppModuleBasic interface
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}

Expand Down
9 changes: 9 additions & 0 deletions modules/apps/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/core/appmodule"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -27,6 +29,7 @@ import (
var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ porttypes.IBCModule = (*IBCModule)(nil)
)

Expand All @@ -38,6 +41,12 @@ func (AppModuleBasic) Name() string {
return types.ModuleName
}

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModule) IsOnePerModuleType() {}

// IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsAppModule() {}

// RegisterLegacyAminoCodec implements AppModuleBasic interface
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
Expand Down
9 changes: 9 additions & 0 deletions modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/core/appmodule"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -34,6 +36,7 @@ var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
_ module.AppModuleSimulation = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
)

// AppModuleBasic defines the basic application module used by the ibc module.
Expand All @@ -44,6 +47,12 @@ func (AppModuleBasic) Name() string {
return exported.ModuleName
}

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModule) IsOnePerModuleType() {}

// IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsAppModule() {}

// RegisterLegacyAminoCodec does nothing. IBC does not support amino.
func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {}

Expand Down
12 changes: 4 additions & 8 deletions testing/simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, b
rootCmd.AddCommand(
rpc.StatusCommand(),
genesisCommand(encodingConfig, basicManager),
txCommand(basicManager),
queryCommand(basicManager),
txCommand(),
queryCommand(),
keys.Commands(),
)
}
Expand All @@ -217,7 +217,7 @@ func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
}

func queryCommand(basicManager module.BasicManager) *cobra.Command {
func queryCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "query",
Aliases: []string{"q"},
Expand All @@ -236,12 +236,10 @@ func queryCommand(basicManager module.BasicManager) *cobra.Command {
authcmd.GetSimulateCmd(),
)

basicManager.AddQueryCommands(cmd)

return cmd
}

func txCommand(basicManager module.BasicManager) *cobra.Command {
func txCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "tx",
Short: "Transactions subcommands",
Expand All @@ -262,8 +260,6 @@ func txCommand(basicManager module.BasicManager) *cobra.Command {
authcmd.GetAuxToFeeCommand(),
)

basicManager.AddTxCommands(cmd)

return cmd
}

Expand Down

0 comments on commit b95aadb

Please sign in to comment.