diff --git a/client/context.go b/client/context.go index 569aa45c1fde..786ce81fc8b7 100644 --- a/client/context.go +++ b/client/context.go @@ -5,16 +5,14 @@ import ( "io" "os" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/pkg/errors" - yaml "gopkg.in/yaml.v2" - tmlite "github.com/tendermint/tendermint/lite" rpcclient "github.com/tendermint/tendermint/rpc/client" rpchttp "github.com/tendermint/tendermint/rpc/client/http" + yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/client/flags/flags.go b/client/flags/flags.go index 30b12070c96f..0bc6c9c16c89 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -5,7 +5,6 @@ import ( "strconv" "github.com/spf13/cobra" - "github.com/spf13/viper" tmcli "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -83,12 +82,6 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) { cmd.SetErr(cmd.ErrOrStderr()) cmd.SetOut(cmd.OutOrStdout()) - - // TODO: REMOVE VIPER CALLS! - viper.BindPFlag(FlagTrustNode, cmd.Flags().Lookup(FlagTrustNode)) - viper.BindPFlag(FlagUseLedger, cmd.Flags().Lookup(FlagUseLedger)) - viper.BindPFlag(FlagNode, cmd.Flags().Lookup(FlagNode)) - viper.BindPFlag(FlagKeyringBackend, cmd.Flags().Lookup(FlagKeyringBackend)) } // AddTxFlagsToCmd adds common flags to a module tx command. @@ -118,12 +111,6 @@ func AddTxFlagsToCmd(cmd *cobra.Command) { cmd.SetErr(cmd.ErrOrStderr()) cmd.SetOut(cmd.OutOrStdout()) - - // TODO: REMOVE VIPER CALLS! - viper.BindPFlag(FlagTrustNode, cmd.Flags().Lookup(FlagTrustNode)) - viper.BindPFlag(FlagUseLedger, cmd.Flags().Lookup(FlagUseLedger)) - viper.BindPFlag(FlagNode, cmd.Flags().Lookup(FlagNode)) - viper.BindPFlag(FlagKeyringBackend, cmd.Flags().Lookup(FlagKeyringBackend)) } // AddPaginationFlagsToCmd adds common pagination flags to cmd diff --git a/server/README.md b/server/README.md new file mode 100644 index 000000000000..99ded0713b00 --- /dev/null +++ b/server/README.md @@ -0,0 +1,116 @@ +# Server + +The `server` package is responsible for providing the mechanisms necessary to +start an ABCI Tendermint application and providing the CLI framework necessary +to fully bootstrap an application. The package exposes two core commands, `StartCmd` +and `ExportCmd`. + +## Preliminary + +The root command of an application typically is constructed with three core +sub-commands, query commands, tx commands, and auxiliary commands such as genesis +utilities, and starting an application binary. + +It is vital that the root command of an application set the appropriate `PersistentPreRun(E)` +function so all child commands have access to the server and client contexts. +These contexts are set as their default values initially and maybe modified, +scoped to the command, in their respective `PersistentPreRun(E)` functions. Note, +the `client.Context` is typically pre-populated with "default" values that may be +useful for all commands to inherit and override if necessary. + +Example: + +```go +var ( + rootCmd = &cobra.Command{ + Use: "simd", + Short: "simulation app", + PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { + return err + } + + return server.InterceptConfigsPreRunHandler(cmd) + }, + } + + encodingConfig = simapp.MakeEncodingConfig() + initClientCtx = client.Context{}. + WithJSONMarshaler(encodingConfig.Marshaler). + WithTxConfig(encodingConfig.TxConfig). + WithCodec(encodingConfig.Amino). + WithInput(os.Stdin). + WithAccountRetriever(types.NewAccountRetriever(encodingConfig.Marshaler)). + WithBroadcastMode(flags.BroadcastBlock). + WithHomeDir(simapp.DefaultNodeHome) +) +``` + +The `SetCmdClientContextHandler` call reads persistent flags via `ReadPersistentCommandFlags` +which creates a `client.Context` and sets that on the root command's `Context`. + +The `InterceptConfigsPreRunHandler` call creates a viper literal, default `server.Context`, +and a logger and sets that on the root command's `Context`. The `server.Context` +will be modified and saved to disk via the internal `interceptConfigs` call, which +either reads or creates a Tendermint configuration based on the home path provided. +In addition, `interceptConfigs` also reads and loads the application configuration, +`app.toml`, and binds that to the `server.Context` viper literal. This is vital +so the application can get access to not only the CLI flags, but also to the +application configuration values provided by this file. + +## `StartCmd` + +The `StartCmd` accepts an `AppCreator` function which returns an `Application`. +The `AppCreator` is responsible for constructing the application based on the +options provided to it via `AppOptions`. The `AppOptions` interface type defines +a single method, `Get() interface{}`, and is implemented as a [viper](https://github.com/spf13/viper) +literal that exists in the `server.Context`. All the possible options an application +may use and provide to the construction process are defined by the `StartCmd` +and by the application's config file, `app.toml`. + +The application can either be started in-process or as an external process. The +former creates a Tendermint service and the latter creates a Tendermint Node. + +Under the hood, `StartCmd` will call `GetServerContextFromCmd`, which provides +the command access to a `server.Context`. This context provides access to the +viper literal, the Tendermint config and logger. This allows flags to be bound +the viper literal and passed to the application construction. + +Example: + +```go +func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts server.AppOptions) server.Application { + var cache sdk.MultiStorePersistentCache + + if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) { + cache = store.NewCommitKVStoreCacheManager() + } + + skipUpgradeHeights := make(map[int64]bool) + for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { + skipUpgradeHeights[int64(h)] = true + } + + pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts) + if err != nil { + panic(err) + } + + return simapp.NewSimApp( + logger, db, traceStore, true, skipUpgradeHeights, + cast.ToString(appOpts.Get(flags.FlagHome)), + cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), + baseapp.SetPruning(pruningOpts), + baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), + baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), + baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))), + baseapp.SetInterBlockCache(cache), + baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))), + ) +} +``` + +Note, some of the options provided are exposed via CLI flags in the start command +and some are also allowed to be set in the application's `app.toml`. It is recommend +to use the `cast` package for type safety guarantees and due to the limitations of +CLI flag types. diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 37c8a06430ff..c3260b1ff06d 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -39,6 +39,7 @@ var ( if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } + return server.InterceptConfigsPreRunHandler(cmd) }, } @@ -114,7 +115,7 @@ func queryCommand() *cobra.Command { authcmd.QueryTxCmd(), ) - simapp.ModuleBasics.AddQueryCommands(cmd, initClientCtx) + simapp.ModuleBasics.AddQueryCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd @@ -141,7 +142,7 @@ func txCommand() *cobra.Command { flags.LineBreak, ) - simapp.ModuleBasics.AddTxCommands(cmd, initClientCtx) + simapp.ModuleBasics.AddTxCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd diff --git a/tests/mocks/types_module_module.go b/tests/mocks/types_module_module.go index a56300ab453e..d9ec3980b9a9 100644 --- a/tests/mocks/types_module_module.go +++ b/tests/mocks/types_module_module.go @@ -107,31 +107,31 @@ func (mr *MockAppModuleBasicMockRecorder) RegisterRESTRoutes(arg0, arg1 interfac } // GetTxCmd mocks base method -func (m *MockAppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command { +func (m *MockAppModuleBasic) GetTxCmd() *cobra.Command { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTxCmd", clientCtx) + ret := m.ctrl.Call(m, "GetTxCmd") ret0, _ := ret[0].(*cobra.Command) return ret0 } // GetTxCmd indicates an expected call of GetTxCmd -func (mr *MockAppModuleBasicMockRecorder) GetTxCmd(clientCtx interface{}) *gomock.Call { +func (mr *MockAppModuleBasicMockRecorder) GetTxCmd() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTxCmd", reflect.TypeOf((*MockAppModuleBasic)(nil).GetTxCmd), clientCtx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTxCmd", reflect.TypeOf((*MockAppModuleBasic)(nil).GetTxCmd)) } // GetQueryCmd mocks base method -func (m *MockAppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { +func (m *MockAppModuleBasic) GetQueryCmd() *cobra.Command { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetQueryCmd", clientCtx) + ret := m.ctrl.Call(m, "GetQueryCmd") ret0, _ := ret[0].(*cobra.Command) return ret0 } // GetQueryCmd indicates an expected call of GetQueryCmd -func (mr *MockAppModuleBasicMockRecorder) GetQueryCmd(clientCtx interface{}) *gomock.Call { +func (mr *MockAppModuleBasicMockRecorder) GetQueryCmd() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetQueryCmd", reflect.TypeOf((*MockAppModuleBasic)(nil).GetQueryCmd), clientCtx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetQueryCmd", reflect.TypeOf((*MockAppModuleBasic)(nil).GetQueryCmd)) } // MockAppModuleGenesis is a mock of AppModuleGenesis interface @@ -224,31 +224,31 @@ func (mr *MockAppModuleGenesisMockRecorder) RegisterRESTRoutes(arg0, arg1 interf } // GetTxCmd mocks base method -func (m *MockAppModuleGenesis) GetTxCmd(clientCtx client.Context) *cobra.Command { +func (m *MockAppModuleGenesis) GetTxCmd() *cobra.Command { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTxCmd", clientCtx) + ret := m.ctrl.Call(m, "GetTxCmd") ret0, _ := ret[0].(*cobra.Command) return ret0 } // GetTxCmd indicates an expected call of GetTxCmd -func (mr *MockAppModuleGenesisMockRecorder) GetTxCmd(clientCtx interface{}) *gomock.Call { +func (mr *MockAppModuleGenesisMockRecorder) GetTxCmd() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTxCmd", reflect.TypeOf((*MockAppModuleGenesis)(nil).GetTxCmd), clientCtx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTxCmd", reflect.TypeOf((*MockAppModuleGenesis)(nil).GetTxCmd)) } // GetQueryCmd mocks base method -func (m *MockAppModuleGenesis) GetQueryCmd(clientCtx client.Context) *cobra.Command { +func (m *MockAppModuleGenesis) GetQueryCmd() *cobra.Command { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetQueryCmd", clientCtx) + ret := m.ctrl.Call(m, "GetQueryCmd") ret0, _ := ret[0].(*cobra.Command) return ret0 } // GetQueryCmd indicates an expected call of GetQueryCmd -func (mr *MockAppModuleGenesisMockRecorder) GetQueryCmd(clientCtx interface{}) *gomock.Call { +func (mr *MockAppModuleGenesisMockRecorder) GetQueryCmd() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetQueryCmd", reflect.TypeOf((*MockAppModuleGenesis)(nil).GetQueryCmd), clientCtx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetQueryCmd", reflect.TypeOf((*MockAppModuleGenesis)(nil).GetQueryCmd)) } // InitGenesis mocks base method @@ -369,31 +369,31 @@ func (mr *MockAppModuleMockRecorder) RegisterRESTRoutes(arg0, arg1 interface{}) } // GetTxCmd mocks base method -func (m *MockAppModule) GetTxCmd(clientCtx client.Context) *cobra.Command { +func (m *MockAppModule) GetTxCmd() *cobra.Command { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTxCmd", clientCtx) + ret := m.ctrl.Call(m, "GetTxCmd") ret0, _ := ret[0].(*cobra.Command) return ret0 } // GetTxCmd indicates an expected call of GetTxCmd -func (mr *MockAppModuleMockRecorder) GetTxCmd(clientCtx interface{}) *gomock.Call { +func (mr *MockAppModuleMockRecorder) GetTxCmd() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTxCmd", reflect.TypeOf((*MockAppModule)(nil).GetTxCmd), clientCtx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTxCmd", reflect.TypeOf((*MockAppModule)(nil).GetTxCmd)) } // GetQueryCmd mocks base method -func (m *MockAppModule) GetQueryCmd(clientCtx client.Context) *cobra.Command { +func (m *MockAppModule) GetQueryCmd() *cobra.Command { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetQueryCmd", clientCtx) + ret := m.ctrl.Call(m, "GetQueryCmd") ret0, _ := ret[0].(*cobra.Command) return ret0 } // GetQueryCmd indicates an expected call of GetQueryCmd -func (mr *MockAppModuleMockRecorder) GetQueryCmd(clientCtx interface{}) *gomock.Call { +func (mr *MockAppModuleMockRecorder) GetQueryCmd() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetQueryCmd", reflect.TypeOf((*MockAppModule)(nil).GetQueryCmd), clientCtx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetQueryCmd", reflect.TypeOf((*MockAppModule)(nil).GetQueryCmd)) } // InitGenesis mocks base method diff --git a/types/module/module.go b/types/module/module.go index 54aef9160b8b..a344f7d6b395 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -54,8 +54,8 @@ type AppModuleBasic interface { // client functionality RegisterRESTRoutes(client.Context, *mux.Router) - GetTxCmd(clientCtx client.Context) *cobra.Command - GetQueryCmd(clientCtx client.Context) *cobra.Command + GetTxCmd() *cobra.Command + GetQueryCmd() *cobra.Command } // BasicManager is a collection of AppModuleBasic @@ -109,9 +109,9 @@ func (bm BasicManager) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rou // // TODO: Remove clientCtx argument. // REF: https://github.com/cosmos/cosmos-sdk/issues/6571 -func (bm BasicManager) AddTxCommands(rootTxCmd *cobra.Command, ctx client.Context) { +func (bm BasicManager) AddTxCommands(rootTxCmd *cobra.Command) { for _, b := range bm { - if cmd := b.GetTxCmd(ctx); cmd != nil { + if cmd := b.GetTxCmd(); cmd != nil { rootTxCmd.AddCommand(cmd) } } @@ -121,9 +121,9 @@ func (bm BasicManager) AddTxCommands(rootTxCmd *cobra.Command, ctx client.Contex // // TODO: Remove clientCtx argument. // REF: https://github.com/cosmos/cosmos-sdk/issues/6571 -func (bm BasicManager) AddQueryCommands(rootQueryCmd *cobra.Command, clientCtx client.Context) { +func (bm BasicManager) AddQueryCommands(rootQueryCmd *cobra.Command) { for _, b := range bm { - if cmd := b.GetQueryCmd(clientCtx); cmd != nil { + if cmd := b.GetQueryCmd(); cmd != nil { rootQueryCmd.AddCommand(cmd) } } diff --git a/types/module/module_test.go b/types/module/module_test.go index 56c810c6b190..91ad8d8596d4 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -35,8 +35,8 @@ func TestBasicManager(t *testing.T) { mockAppModuleBasic1.EXPECT().ValidateGenesis(gomock.Eq(cdc), gomock.Eq(wantDefaultGenesis["mockAppModuleBasic1"])).Times(1).Return(errFoo) mockAppModuleBasic1.EXPECT().RegisterRESTRoutes(gomock.Eq(client.Context{}), gomock.Eq(&mux.Router{})).Times(1) mockAppModuleBasic1.EXPECT().RegisterCodec(gomock.Eq(cdc)).Times(1) - mockAppModuleBasic1.EXPECT().GetTxCmd(clientCtx).Times(1).Return(nil) - mockAppModuleBasic1.EXPECT().GetQueryCmd(clientCtx).Times(1).Return(nil) + mockAppModuleBasic1.EXPECT().GetTxCmd().Times(1).Return(nil) + mockAppModuleBasic1.EXPECT().GetQueryCmd().Times(1).Return(nil) mm := module.NewBasicManager(mockAppModuleBasic1) require.Equal(t, mm["mockAppModuleBasic1"], mockAppModuleBasic1) @@ -53,9 +53,9 @@ func TestBasicManager(t *testing.T) { mm.RegisterRESTRoutes(client.Context{}, &mux.Router{}) mockCmd := &cobra.Command{Use: "root"} - mm.AddTxCommands(mockCmd, clientCtx) + mm.AddTxCommands(mockCmd) - mm.AddQueryCommands(mockCmd, clientCtx) + mm.AddQueryCommands(mockCmd) // validate genesis returns nil require.Nil(t, module.NewBasicManager().ValidateGenesis(cdc, wantDefaultGenesis)) diff --git a/x/auth/module.go b/x/auth/module.go index bf1f212f0c5f..11076eb80388 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -66,12 +66,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout } // GetTxCmd returns the root tx command for the auth module. -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() } // GetQueryCmd returns the root query command for the auth module. -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/bank/module.go b/x/bank/module.go index ee6659e3411b..f15ea1585061 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -63,12 +63,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout } // GetTxCmd returns the root tx command for the bank module. -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.NewTxCmd() } // GetQueryCmd returns no root query command for the bank module. -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/capability/module.go b/x/capability/module.go index f2a36ac5476b..70f7159d46ef 100644 --- a/x/capability/module.go +++ b/x/capability/module.go @@ -67,10 +67,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessag func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} // GetTxCmd returns the capability module's root tx command. -func (a AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { return nil } +func (a AppModuleBasic) GetTxCmd() *cobra.Command { return nil } // GetQueryCmd returns the capability module's root query command. -func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { return nil } +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } // ---------------------------------------------------------------------------- // AppModule diff --git a/x/crisis/module.go b/x/crisis/module.go index b01bcfc94b01..975f2849cf79 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -57,12 +57,12 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessag func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} // GetTxCmd returns the root tx command for the crisis module. -func (b AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (b AppModuleBasic) GetTxCmd() *cobra.Command { return cli.NewTxCmd() } // GetQueryCmd returns no root query command for the crisis module. -func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { return nil } +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } // RegisterInterfaceTypes registers interfaces and implementations of the crisis // module. diff --git a/x/distribution/module.go b/x/distribution/module.go index 738bcfbf3861..475d0e46b3b5 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -69,12 +69,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx sdkclient.Context, rtr *mux.R } // GetTxCmd returns the root tx command for the distribution module. -func (AppModuleBasic) GetTxCmd(_ sdkclient.Context) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.NewTxCmd() } // GetQueryCmd returns the root query command for the distribution module. -func (AppModuleBasic) GetQueryCmd(_ sdkclient.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/evidence/module.go b/x/evidence/module.go index ef76f6ccc714..d2331dceab48 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -86,7 +86,7 @@ func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Ro } // GetTxCmd returns the evidence module's root tx command. -func (a AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (a AppModuleBasic) GetTxCmd() *cobra.Command { evidenceCLIHandlers := make([]*cobra.Command, len(a.evidenceHandlers)) for i, evidenceHandler := range a.evidenceHandlers { @@ -97,7 +97,7 @@ func (a AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { } // GetQueryCmd returns the evidence module's root query command. -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/genutil/module.go b/x/genutil/module.go index 105a4da55365..dfc2d000736d 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -52,10 +52,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessag func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} // GetTxCmd returns no root tx command for the genutil module. -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { return nil } +func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } // GetQueryCmd returns no root query command for the genutil module. -func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { return nil } +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } //____________________________________________________________________________ diff --git a/x/gov/module.go b/x/gov/module.go index 40e8ebf45cdc..ccc253317834 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -85,7 +85,7 @@ func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Ro } // GetTxCmd returns the root tx command for the gov module. -func (a AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (a AppModuleBasic) GetTxCmd() *cobra.Command { proposalCLIHandlers := make([]*cobra.Command, 0, len(a.proposalHandlers)) for _, proposalHandler := range a.proposalHandlers { proposalCLIHandlers = append(proposalCLIHandlers, proposalHandler.CLIHandler()) @@ -95,7 +95,7 @@ func (a AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { } // GetQueryCmd returns the root query command for the gov module. -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/ibc-transfer/module.go b/x/ibc-transfer/module.go index 6f53de7bec56..ce256d5d6807 100644 --- a/x/ibc-transfer/module.go +++ b/x/ibc-transfer/module.go @@ -71,12 +71,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout } // GetTxCmd implements AppModuleBasic interface -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.NewTxCmd() } // GetQueryCmd implements AppModuleBasic interface -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } diff --git a/x/ibc/module.go b/x/ibc/module.go index 5ba52fe570ee..b1920fe3a762 100644 --- a/x/ibc/module.go +++ b/x/ibc/module.go @@ -69,12 +69,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout } // GetTxCmd returns the root tx command for the ibc module. -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() } // GetQueryCmd returns no root query command for the ibc module. -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/mint/module.go b/x/mint/module.go index 013daeac70c2..ef805706062b 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -65,10 +65,10 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout } // GetTxCmd returns no root tx command for the mint module. -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { return nil } +func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } // GetQueryCmd returns the root query command for the mint module. -func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/params/module.go b/x/params/module.go index 6c0f8323f30c..0ed332c06fa9 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -54,10 +54,10 @@ func (AppModuleBasic) ValidateGenesis(_ codec.JSONMarshaler, _ json.RawMessage) func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} // GetTxCmd returns no root tx command for the params module. -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { return nil } +func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } // GetQueryCmd returns no root query command for the params module. -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.NewQueryCmd() } diff --git a/x/slashing/module.go b/x/slashing/module.go index 4972e43f3914..8fbf4e462ec0 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -70,12 +70,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout } // GetTxCmd returns the root tx command for the slashing module. -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.NewTxCmd() } // GetQueryCmd returns no root query command for the slashing module. -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/staking/module.go b/x/staking/module.go index 252ad1e529f4..bde3165f24fb 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -68,12 +68,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout } // GetTxCmd returns the root tx command for the staking module. -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.NewTxCmd() } // GetQueryCmd returns no root query command for the staking module. -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 7caa7b55b658..015d780bc7c0 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -53,12 +53,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, r *mux.Router } // GetQueryCmd returns the cli query commands for this module -func (AppModuleBasic) GetQueryCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } // GetTxCmd returns the transaction commands for this module -func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { +func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() }