diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bcb6ee207f5..e7b2bd071eb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ logic has been implemented for v0.38 target version. Applications can migrate vi ### API Breaking Changes +* (client) [\#5442](https://github.com/cosmos/cosmos-sdk/pull/5442) Remove client/alias.go as it's not necessary and +components can be imported directly from the packages. * (store) [\#4748](https://github.com/cosmos/cosmos-sdk/pull/4748) The `CommitMultiStore` interface now requires a `SetInterBlockCache` method. Applications that do not wish to support this can simply have this method perform a no-op. diff --git a/client/alias.go b/client/alias.go deleted file mode 100644 index eed043c54401..000000000000 --- a/client/alias.go +++ /dev/null @@ -1,129 +0,0 @@ -// nolint -// autogenerated code using github.com/rigelrozanski/multitool -// aliases generated for the following subdirectories: -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/context -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/flags -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/keys -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/lcd -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/rest -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/rpc -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/tx -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/utils -// ALIASGEN: github.com/cosmos/cosmos-sdk/client/input -package client - -import ( - "github.com/cosmos/cosmos-sdk/client/context" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/input" - "github.com/cosmos/cosmos-sdk/client/keys" - "github.com/cosmos/cosmos-sdk/client/lcd" - "github.com/cosmos/cosmos-sdk/client/rpc" -) - -const ( - DefaultGasAdjustment = flags.DefaultGasAdjustment - DefaultGasLimit = flags.DefaultGasLimit - DefaultKeyringBackend = flags.DefaultKeyringBackend - GasFlagAuto = flags.GasFlagAuto - BroadcastBlock = flags.BroadcastBlock - BroadcastSync = flags.BroadcastSync - BroadcastAsync = flags.BroadcastAsync - FlagHome = flags.FlagHome - FlagUseLedger = flags.FlagUseLedger - FlagChainID = flags.FlagChainID - FlagNode = flags.FlagNode - FlagHeight = flags.FlagHeight - FlagGasAdjustment = flags.FlagGasAdjustment - FlagTrustNode = flags.FlagTrustNode - FlagFrom = flags.FlagFrom - FlagName = flags.FlagName - FlagAccountNumber = flags.FlagAccountNumber - FlagSequence = flags.FlagSequence - FlagMemo = flags.FlagMemo - FlagFees = flags.FlagFees - FlagGasPrices = flags.FlagGasPrices - FlagBroadcastMode = flags.FlagBroadcastMode - FlagDryRun = flags.FlagDryRun - FlagGenerateOnly = flags.FlagGenerateOnly - FlagIndentResponse = flags.FlagIndentResponse - FlagKeyringBackend = flags.FlagKeyringBackend - FlagListenAddr = flags.FlagListenAddr - FlagMaxOpenConnections = flags.FlagMaxOpenConnections - FlagRPCReadTimeout = flags.FlagRPCReadTimeout - FlagRPCWriteTimeout = flags.FlagRPCWriteTimeout - FlagOutputDocument = flags.FlagOutputDocument - FlagSkipConfirmation = flags.FlagSkipConfirmation - KeyringBackendFile = flags.KeyringBackendFile - KeyringBackendOS = flags.KeyringBackendOS - KeyringBackendTest = flags.KeyringBackendTest - DefaultKeyPass = keys.DefaultKeyPass - FlagAddress = keys.FlagAddress - FlagPublicKey = keys.FlagPublicKey - FlagBechPrefix = keys.FlagBechPrefix - FlagDevice = keys.FlagDevice - OutputFormatText = keys.OutputFormatText - OutputFormatJSON = keys.OutputFormatJSON - MinPassLength = input.MinPassLength -) - -var ( - // functions aliases - NewCLIContextWithFrom = context.NewCLIContextWithFrom - NewCLIContextWithInput = context.NewCLIContextWithInput - NewCLIContextWithInputAndFrom = context.NewCLIContextWithInputAndFrom - NewCLIContext = context.NewCLIContext - GetFromFields = context.GetFromFields - ErrInvalidAccount = context.ErrInvalidAccount - ErrVerifyCommit = context.ErrVerifyCommit - GetCommands = flags.GetCommands - PostCommands = flags.PostCommands - RegisterRestServerFlags = flags.RegisterRestServerFlags - ParseGas = flags.ParseGas - NewCompletionCmd = flags.NewCompletionCmd - MarshalJSON = keys.MarshalJSON - UnmarshalJSON = keys.UnmarshalJSON - Commands = keys.Commands - NewAddNewKey = keys.NewAddNewKey - NewRecoverKey = keys.NewRecoverKey - NewUpdateKeyReq = keys.NewUpdateKeyReq - NewDeleteKeyReq = keys.NewDeleteKeyReq - NewKeyringFromDir = keys.NewKeyringFromDir - NewKeyringFromHomeFlag = keys.NewKeyringFromHomeFlag - NewInMemoryKeyBase = keys.NewInMemoryKeyBase - NewRestServer = lcd.NewRestServer - ServeCommand = lcd.ServeCommand - BlockCommand = rpc.BlockCommand - GetChainHeight = rpc.GetChainHeight - BlockRequestHandlerFn = rpc.BlockRequestHandlerFn - LatestBlockRequestHandlerFn = rpc.LatestBlockRequestHandlerFn - RegisterRPCRoutes = rpc.RegisterRPCRoutes - StatusCommand = rpc.StatusCommand - NodeInfoRequestHandlerFn = rpc.NodeInfoRequestHandlerFn - NodeSyncingRequestHandlerFn = rpc.NodeSyncingRequestHandlerFn - ValidatorCommand = rpc.ValidatorCommand - GetValidators = rpc.GetValidators - ValidatorSetRequestHandlerFn = rpc.ValidatorSetRequestHandlerFn - LatestValidatorSetRequestHandlerFn = rpc.LatestValidatorSetRequestHandlerFn - GetPassword = input.GetPassword - GetCheckPassword = input.GetCheckPassword - GetConfirmation = input.GetConfirmation - GetString = input.GetString - PrintPrefixed = input.PrintPrefixed - - // variable aliases - LineBreak = flags.LineBreak - GasFlagVar = flags.GasFlagVar -) - -type ( - CLIContext = context.CLIContext - GasSetting = flags.GasSetting - AddNewKey = keys.AddNewKey - RecoverKey = keys.RecoverKey - UpdateKeyReq = keys.UpdateKeyReq - DeleteKeyReq = keys.DeleteKeyReq - RestServer = lcd.RestServer - ValidatorOutput = rpc.ValidatorOutput - ResultValidatorsOutput = rpc.ResultValidatorsOutput -) diff --git a/client/routes.go b/client/routes.go index ded91ca897b0..9eac8fa0d828 100644 --- a/client/routes.go +++ b/client/routes.go @@ -4,9 +4,10 @@ import ( "github.com/gorilla/mux" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/rpc" ) // Register routes func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) { - RegisterRPCRoutes(cliCtx, r) + rpc.RegisterRPCRoutes(cliCtx, r) } diff --git a/x/auth/client/cli/decode.go b/x/auth/client/cli/decode.go index 370f4fe72d7f..b27bbaa1c4ee 100644 --- a/x/auth/client/cli/decode.go +++ b/x/auth/client/cli/decode.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/cobra" "github.com/tendermint/go-amino" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -43,7 +43,7 @@ func GetDecodeCommand(codec *amino.Codec) *cobra.Command { }, } - return client.PostCommands(cmd)[0] + return flags.PostCommands(cmd)[0] } // GetDecodeTxCmd - returns the command to decode a tx from hex or base64 diff --git a/x/auth/client/utils/tx.go b/x/auth/client/utils/tx.go index 265d9031bc43..7bdde2306518 100644 --- a/x/auth/client/utils/tx.go +++ b/x/auth/client/utils/tx.go @@ -10,10 +10,10 @@ import ( "github.com/pkg/errors" "github.com/spf13/viper" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" + "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -94,7 +94,7 @@ func CompleteAndBroadcastTxCLI(txBldr authtypes.TxBuilder, cliCtx context.CLICon } // build and sign the transaction - txBytes, err := txBldr.BuildAndSign(fromName, client.DefaultKeyPass, msgs) + txBytes, err := txBldr.BuildAndSign(fromName, keys.DefaultKeyPass, msgs) if err != nil { return err } @@ -192,7 +192,7 @@ func SignStdTx( } } - return txBldr.SignStdTx(name, client.DefaultKeyPass, stdTx, appendSig) + return txBldr.SignStdTx(name, keys.DefaultKeyPass, stdTx, appendSig) } // SignStdTxWithSignerAddress attaches a signature to a StdTx and returns a copy of a it. @@ -214,7 +214,7 @@ func SignStdTxWithSignerAddress(txBldr authtypes.TxBuilder, cliCtx context.CLICo } } - return txBldr.SignStdTx(name, client.DefaultKeyPass, stdTx, false) + return txBldr.SignStdTx(name, keys.DefaultKeyPass, stdTx, false) } // Read and decode a StdTx from the given filename. Can pass "-" to read from stdin. diff --git a/x/bank/client/cli/tx.go b/x/bank/client/cli/tx.go index 71e1392b968a..58bce19eba6f 100644 --- a/x/bank/client/cli/tx.go +++ b/x/bank/client/cli/tx.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -57,7 +58,7 @@ func SendTxCmd(cdc *codec.Codec) *cobra.Command { }, } - cmd = client.PostCommands(cmd)[0] + cmd = flags.PostCommands(cmd)[0] return cmd } diff --git a/x/crisis/client/cli/tx.go b/x/crisis/client/cli/tx.go index cdea9206fbe6..e2df844db639 100644 --- a/x/crisis/client/cli/tx.go +++ b/x/crisis/client/cli/tx.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -46,7 +47,7 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command { RunE: client.ValidateCmd, } - txCmd.AddCommand(client.PostCommands( + txCmd.AddCommand(flags.PostCommands( GetCmdInvariantBroken(cdc), )...) return txCmd diff --git a/x/distribution/client/cli/query.go b/x/distribution/client/cli/query.go index 6b8457a3d730..dff8e5e06a5d 100644 --- a/x/distribution/client/cli/query.go +++ b/x/distribution/client/cli/query.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -26,7 +27,7 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { RunE: client.ValidateCmd, } - distQueryCmd.AddCommand(client.GetCommands( + distQueryCmd.AddCommand(flags.GetCommands( GetCmdQueryParams(queryRoute, cdc), GetCmdQueryValidatorOutstandingRewards(queryRoute, cdc), GetCmdQueryValidatorCommission(queryRoute, cdc), diff --git a/x/distribution/client/cli/tx.go b/x/distribution/client/cli/tx.go index 281373267fa5..6eaee60992b6 100644 --- a/x/distribution/client/cli/tx.go +++ b/x/distribution/client/cli/tx.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -43,7 +44,7 @@ func GetTxCmd(storeKey string, cdc *codec.Codec) *cobra.Command { RunE: client.ValidateCmd, } - distTxCmd.AddCommand(client.PostCommands( + distTxCmd.AddCommand(flags.PostCommands( GetCmdWithdrawRewards(cdc), GetCmdSetWithdrawAddr(cdc), GetCmdWithdrawAllRewards(cdc, storeKey), @@ -150,7 +151,7 @@ $ %s tx distribution withdraw-all-rewards --from mykey // The transaction cannot be generated offline since it requires a query // to get all the validators. if cliCtx.GenerateOnly { - return fmt.Errorf("command disabled with the provided flag: %s", client.FlagGenerateOnly) + return fmt.Errorf("command disabled with the provided flag: %s", flags.FlagGenerateOnly) } msgs, err := common.WithdrawAllDelegatorRewards(cliCtx, queryRoute, delAddr) diff --git a/x/evidence/client/cli/query.go b/x/evidence/client/cli/query.go index 4c5eb13abaf1..b4a1dffd0af5 100644 --- a/x/evidence/client/cli/query.go +++ b/x/evidence/client/cli/query.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/evidence/exported" @@ -46,9 +47,9 @@ $ %s query %s --page=2 --limit=50 cmd.Flags().Int(flagPage, 1, "pagination page of evidence to to query for") cmd.Flags().Int(flagLimit, 100, "pagination limit of evidence to query for") - cmd.AddCommand(client.GetCommands(QueryParamsCmd(cdc))...) + cmd.AddCommand(flags.GetCommands(QueryParamsCmd(cdc))...) - return client.GetCommands(cmd)[0] + return flags.GetCommands(cmd)[0] } // QueryParamsCmd returns the command handler for evidence parameter querying. diff --git a/x/evidence/client/cli/tx.go b/x/evidence/client/cli/tx.go index 7cf6c5f6eadb..b97b56c0a23d 100644 --- a/x/evidence/client/cli/tx.go +++ b/x/evidence/client/cli/tx.go @@ -2,6 +2,7 @@ package cli import ( "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/x/evidence/internal/types" @@ -24,7 +25,7 @@ func GetTxCmd(storeKey string, cdc *codec.Codec, childCmds []*cobra.Command) *co submitEvidenceCmd := SubmitEvidenceCmd(cdc) for _, childCmd := range childCmds { - submitEvidenceCmd.AddCommand(client.PostCommands(childCmd)[0]) + submitEvidenceCmd.AddCommand(flags.PostCommands(childCmd)[0]) } // TODO: Add tx commands. diff --git a/x/genutil/client/cli/collect.go b/x/genutil/client/cli/collect.go index fe1c864eca9f..bc38ab74d287 100644 --- a/x/genutil/client/cli/collect.go +++ b/x/genutil/client/cli/collect.go @@ -10,7 +10,7 @@ import ( "github.com/tendermint/tendermint/libs/cli" tmtypes "github.com/tendermint/tendermint/types" - "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -29,7 +29,7 @@ func CollectGenTxsCmd(ctx *server.Context, cdc *codec.Codec, RunE: func(_ *cobra.Command, _ []string) error { config := ctx.Config config.SetRoot(viper.GetString(cli.HomeFlag)) - name := viper.GetString(client.FlagName) + name := viper.GetString(flags.FlagName) nodeID, valPubKey, err := genutil.InitializeNodeValidatorFiles(config) if err != nil { return errors.Wrap(err, "failed to initialize node validator files") diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index ebfdded23a96..aae33d6b8b7c 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -21,9 +21,9 @@ import ( "github.com/tendermint/tendermint/libs/common" tmtypes "github.com/tendermint/tendermint/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/codec" kbkeys "github.com/cosmos/cosmos-sdk/crypto/keys" "github.com/cosmos/cosmos-sdk/server" @@ -64,7 +64,7 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm RunE: func(cmd *cobra.Command, args []string) error { config := ctx.Config - config.SetRoot(viper.GetString(client.FlagHome)) + config.SetRoot(viper.GetString(flags.FlagHome)) nodeID, valPubKey, err := genutil.InitializeNodeValidatorFiles(ctx.Config) if err != nil { return errors.Wrap(err, "failed to initialize node validator files") @@ -97,19 +97,19 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm } inBuf := bufio.NewReader(cmd.InOrStdin()) - kb, err := client.NewKeyringFromDir(viper.GetString(flagClientHome), inBuf) + kb, err := keys.NewKeyringFromDir(viper.GetString(flagClientHome), inBuf) if err != nil { return errors.Wrap(err, "failed to initialize keybase") } - name := viper.GetString(client.FlagName) + name := viper.GetString(flags.FlagName) key, err := kb.Get(name) if err != nil { return errors.Wrap(err, "failed to read from keybase") } // Set flags for creating gentx - viper.Set(client.FlagHome, viper.GetString(flagClientHome)) + viper.Set(flags.FlagHome, viper.GetString(flagClientHome)) smbh.PrepareFlagsForTxCreateValidator(config, nodeID, genDoc.ChainID, valPubKey) // Fetch the amount of coins staked @@ -125,14 +125,14 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm } txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) - cliCtx := client.NewCLIContextWithInput(inBuf).WithCodec(cdc) + cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) // Set the generate-only flag here after the CLI context has // been created. This allows the from name/key to be correctly populated. // // TODO: Consider removing the manual setting of generate-only in // favor of a 'gentx' flag in the create-validator command. - viper.Set(client.FlagGenerateOnly, true) + viper.Set(flags.FlagGenerateOnly, true) // create a 'create-validator' message txBldr, msg, err := smbh.BuildCreateValidatorMsg(cliCtx, txBldr) @@ -166,7 +166,7 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm } // Fetch output file name - outputDocument := viper.GetString(client.FlagOutputDocument) + outputDocument := viper.GetString(flags.FlagOutputDocument) if outputDocument == "" { outputDocument, err = makeOutputFilepath(config.RootDir, nodeID) if err != nil { @@ -184,16 +184,16 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm }, } - cmd.Flags().String(client.FlagHome, defaultNodeHome, "node's home directory") + cmd.Flags().String(flags.FlagHome, defaultNodeHome, "node's home directory") cmd.Flags().String(flagClientHome, defaultCLIHome, "client's home directory") - cmd.Flags().String(client.FlagName, "", "name of private key with which to sign the gentx") - cmd.Flags().String(client.FlagOutputDocument, "", + cmd.Flags().String(flags.FlagName, "", "name of private key with which to sign the gentx") + cmd.Flags().String(flags.FlagOutputDocument, "", "write the genesis transaction JSON document to the given file instead of the default location") cmd.Flags().AddFlagSet(fsCreateValidator) - cmd.Flags().String(client.FlagKeyringBackend, client.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") + cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") viper.BindPFlag(flags.FlagKeyringBackend, cmd.Flags().Lookup(flags.FlagKeyringBackend)) - cmd.MarkFlagRequired(client.FlagName) + cmd.MarkFlagRequired(flags.FlagName) return cmd } diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index aed60d17f839..c611556ae8f1 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -14,7 +14,7 @@ import ( "github.com/tendermint/tendermint/libs/common" "github.com/tendermint/tendermint/types" - "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" @@ -70,7 +70,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, config := ctx.Config config.SetRoot(viper.GetString(cli.HomeFlag)) - chainID := viper.GetString(client.FlagChainID) + chainID := viper.GetString(flags.FlagChainID) if chainID == "" { chainID = fmt.Sprintf("test-chain-%v", common.RandStr(6)) } @@ -119,7 +119,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, cmd.Flags().String(cli.HomeFlag, defaultNodeHome, "node's home directory") cmd.Flags().BoolP(flagOverwrite, "o", false, "overwrite the genesis.json file") - cmd.Flags().String(client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") + cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") return cmd } diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index 540e57cfb5f2..6ab1ef208abe 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -14,7 +14,7 @@ import ( "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/mock" @@ -126,7 +126,7 @@ func TestInitNodeValidatorFiles(t *testing.T) { home, cleanup := tests.NewTestCaseDir(t) defer cleanup() viper.Set(cli.HomeFlag, home) - viper.Set(client.FlagName, "moniker") + viper.Set(flags.FlagName, "moniker") cfg, err := tcmd.ParseConfig() require.Nil(t, err) nodeID, valPubKey, err := genutil.InitializeNodeValidatorFiles(cfg) diff --git a/x/genutil/client/cli/migrate_test.go b/x/genutil/client/cli/migrate_test.go index fca36a4dfc28..423629efcb13 100644 --- a/x/genutil/client/cli/migrate_test.go +++ b/x/genutil/client/cli/migrate_test.go @@ -12,7 +12,7 @@ import ( "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/tests" ) @@ -39,7 +39,7 @@ func TestGetMigrationCallback(t *testing.T) { func TestMigrateGenesis(t *testing.T) { home, cleanup := tests.NewTestCaseDir(t) viper.Set(cli.HomeFlag, home) - viper.Set(client.FlagName, "moniker") + viper.Set(flags.FlagName, "moniker") logger := log.NewNopLogger() cfg, err := tcmd.ParseConfig() require.Nil(t, err) diff --git a/x/gov/client/cli/query.go b/x/gov/client/cli/query.go index 69f89e7a7d05..332fe0d89cd3 100644 --- a/x/gov/client/cli/query.go +++ b/x/gov/client/cli/query.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -29,7 +30,7 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { RunE: client.ValidateCmd, } - govQueryCmd.AddCommand(client.GetCommands( + govQueryCmd.AddCommand(flags.GetCommands( GetCmdQueryProposal(queryRoute, cdc), GetCmdQueryProposals(queryRoute, cdc), GetCmdQueryVote(queryRoute, cdc), diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index 4bd49a610e95..8c6c1109c9d4 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -66,10 +67,10 @@ func GetTxCmd(storeKey string, cdc *codec.Codec, pcmds []*cobra.Command) *cobra. cmdSubmitProp := GetCmdSubmitProposal(cdc) for _, pcmd := range pcmds { - cmdSubmitProp.AddCommand(client.PostCommands(pcmd)[0]) + cmdSubmitProp.AddCommand(flags.PostCommands(pcmd)[0]) } - govTxCmd.AddCommand(client.PostCommands( + govTxCmd.AddCommand(flags.PostCommands( GetCmdDeposit(cdc), GetCmdVote(cdc), cmdSubmitProp, diff --git a/x/mint/client/cli/query.go b/x/mint/client/cli/query.go index 3350706362f3..ec37cde40cf6 100644 --- a/x/mint/client/cli/query.go +++ b/x/mint/client/cli/query.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/mint/internal/types" @@ -23,7 +24,7 @@ func GetQueryCmd(cdc *codec.Codec) *cobra.Command { } mintingQueryCmd.AddCommand( - client.GetCommands( + flags.GetCommands( GetCmdQueryParams(cdc), GetCmdQueryInflation(cdc), GetCmdQueryAnnualProvisions(cdc), diff --git a/x/slashing/client/cli/query.go b/x/slashing/client/cli/query.go index 836d2bcb1f3d..a5b0cd1be524 100644 --- a/x/slashing/client/cli/query.go +++ b/x/slashing/client/cli/query.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -26,7 +27,7 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { } slashingQueryCmd.AddCommand( - client.GetCommands( + flags.GetCommands( GetCmdQuerySigningInfo(queryRoute, cdc), GetCmdQueryParams(cdc), )..., diff --git a/x/slashing/client/cli/tx.go b/x/slashing/client/cli/tx.go index e6bb0b44e9b8..5aa262568d54 100644 --- a/x/slashing/client/cli/tx.go +++ b/x/slashing/client/cli/tx.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -24,7 +25,7 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command { RunE: client.ValidateCmd, } - slashingTxCmd.AddCommand(client.PostCommands( + slashingTxCmd.AddCommand(flags.PostCommands( GetCmdUnjail(cdc), )...) diff --git a/x/staking/client/cli/query.go b/x/staking/client/cli/query.go index 632237c1d915..14a60c49bc04 100644 --- a/x/staking/client/cli/query.go +++ b/x/staking/client/cli/query.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -24,7 +25,7 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } - stakingQueryCmd.AddCommand(client.GetCommands( + stakingQueryCmd.AddCommand(flags.GetCommands( GetCmdQueryDelegation(queryRoute, cdc), GetCmdQueryDelegations(queryRoute, cdc), GetCmdQueryUnbondingDelegation(queryRoute, cdc), diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go index 5898a25933f1..34ed0abce3c7 100644 --- a/x/staking/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -33,7 +34,7 @@ func GetTxCmd(storeKey string, cdc *codec.Codec) *cobra.Command { RunE: client.ValidateCmd, } - stakingTxCmd.AddCommand(client.PostCommands( + stakingTxCmd.AddCommand(flags.PostCommands( GetCmdCreateValidator(cdc), GetCmdEditValidator(cdc), GetCmdDelegate(cdc), @@ -69,10 +70,10 @@ func GetCmdCreateValidator(cdc *codec.Codec) *cobra.Command { cmd.Flags().AddFlagSet(FsCommissionCreate) cmd.Flags().AddFlagSet(FsMinSelfDelegation) - cmd.Flags().String(FlagIP, "", fmt.Sprintf("The node's public IP. It takes effect only when used in combination with --%s", client.FlagGenerateOnly)) + cmd.Flags().String(FlagIP, "", fmt.Sprintf("The node's public IP. It takes effect only when used in combination with --%s", flags.FlagGenerateOnly)) cmd.Flags().String(FlagNodeID, "", "The node's ID") - cmd.MarkFlagRequired(client.FlagFrom) + cmd.MarkFlagRequired(flags.FlagFrom) cmd.MarkFlagRequired(FlagAmount) cmd.MarkFlagRequired(FlagPubKey) cmd.MarkFlagRequired(FlagMoniker) @@ -309,8 +310,8 @@ func PrepareFlagsForTxCreateValidator( details := viper.GetString(FlagDetails) identity := viper.GetString(FlagIdentity) - viper.Set(client.FlagChainID, chainID) - viper.Set(client.FlagFrom, viper.GetString(client.FlagName)) + viper.Set(flags.FlagChainID, chainID) + viper.Set(flags.FlagFrom, viper.GetString(flags.FlagName)) viper.Set(FlagNodeID, nodeID) viper.Set(FlagIP, ip) viper.Set(FlagPubKey, sdk.MustBech32ifyConsPub(valPubKey)) @@ -321,7 +322,7 @@ func PrepareFlagsForTxCreateValidator( viper.Set(FlagIdentity, identity) if config.Moniker == "" { - viper.Set(FlagMoniker, viper.GetString(client.FlagName)) + viper.Set(FlagMoniker, viper.GetString(flags.FlagName)) } if viper.GetString(FlagAmount) == "" { viper.Set(FlagAmount, defaultAmount) @@ -384,7 +385,7 @@ func BuildCreateValidatorMsg(cliCtx context.CLIContext, txBldr auth.TxBuilder) ( sdk.ValAddress(valAddr), pk, amount, description, commissionRates, minSelfDelegation, ) - if viper.GetBool(client.FlagGenerateOnly) { + if viper.GetBool(flags.FlagGenerateOnly) { ip := viper.GetString(FlagIP) nodeID := viper.GetString(FlagNodeID) if nodeID != "" && ip != "" { diff --git a/x/supply/client/cli/query.go b/x/supply/client/cli/query.go index 009f2f7df983..26c4a77cd506 100644 --- a/x/supply/client/cli/query.go +++ b/x/supply/client/cli/query.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -25,7 +26,7 @@ func GetQueryCmd(cdc *codec.Codec) *cobra.Command { RunE: client.ValidateCmd, } - supplyQueryCmd.AddCommand(client.GetCommands( + supplyQueryCmd.AddCommand(flags.GetCommands( GetCmdQueryTotalSupply(cdc), )...) diff --git a/x/upgrade/module.go b/x/upgrade/module.go index a365cd1a36c2..129cc904bf10 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -6,8 +6,8 @@ import ( "github.com/gorilla/mux" "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -52,7 +52,7 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { Use: "upgrade", Short: "Querying commands for the upgrade module", } - queryCmd.AddCommand(client.GetCommands( + queryCmd.AddCommand(flags.GetCommands( cli.GetPlanCmd(StoreKey, cdc), cli.GetAppliedHeightCmd(StoreKey, cdc), )...) @@ -66,7 +66,7 @@ func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { Use: "upgrade", Short: "Upgrade transaction subcommands", } - txCmd.AddCommand(client.PostCommands()...) + txCmd.AddCommand(flags.PostCommands()...) return txCmd }