From b95aadbdce68ea34f96650c2d17c6d141afb2198 Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev <46343690+pysel@users.noreply.github.com> Date: Mon, 21 Aug 2023 15:43:03 +0200 Subject: [PATCH] Implement appmodule.AppModule interface for ibc-go packages' modules (#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 --- modules/apps/27-interchain-accounts/module.go | 9 +++++++++ modules/apps/29-fee/module.go | 9 +++++++++ modules/apps/transfer/module.go | 9 +++++++++ modules/core/module.go | 9 +++++++++ testing/simapp/simd/cmd/root.go | 12 ++++-------- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/modules/apps/27-interchain-accounts/module.go b/modules/apps/27-interchain-accounts/module.go index 9303de77fbc..91d7706701c 100644 --- a/modules/apps/27-interchain-accounts/module.go +++ b/modules/apps/27-interchain-accounts/module.go @@ -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" @@ -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) ) @@ -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) {} diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index fdc7c5fe977..9639430817e 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -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" @@ -25,6 +27,7 @@ import ( var ( _ module.AppModule = (*AppModule)(nil) _ module.AppModuleBasic = (*AppModuleBasic)(nil) + _ appmodule.AppModule = (*AppModule)(nil) ) // AppModuleBasic is the 29-fee AppModuleBasic @@ -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) {} diff --git a/modules/apps/transfer/module.go b/modules/apps/transfer/module.go index 17721a818bb..52c54edfb3c 100644 --- a/modules/apps/transfer/module.go +++ b/modules/apps/transfer/module.go @@ -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" @@ -27,6 +29,7 @@ import ( var ( _ module.AppModule = (*AppModule)(nil) _ module.AppModuleBasic = (*AppModuleBasic)(nil) + _ appmodule.AppModule = (*AppModule)(nil) _ porttypes.IBCModule = (*IBCModule)(nil) ) @@ -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) diff --git a/modules/core/module.go b/modules/core/module.go index dc9f59c011f..8c671b4b850 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -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" @@ -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. @@ -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) {} diff --git a/testing/simapp/simd/cmd/root.go b/testing/simapp/simd/cmd/root.go index 5ac6a9f1cb0..0d7d39d60e9 100644 --- a/testing/simapp/simd/cmd/root.go +++ b/testing/simapp/simd/cmd/root.go @@ -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(), ) } @@ -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"}, @@ -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", @@ -262,8 +260,6 @@ func txCommand(basicManager module.BasicManager) *cobra.Command { authcmd.GetAuxToFeeCommand(), ) - basicManager.AddTxCommands(cmd) - return cmd }