From 745f2eb7e39a0f02fdb6a6eb9283e009bc49d5bd Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Thu, 8 Aug 2019 11:51:54 -0400 Subject: [PATCH] Merge PR #4872: Disable "withdraw-all-rewards" command when "--generate-only" is supplied --- .pending/bugfixes/cli/_4870-Disable-the-wi | 1 + x/distribution/client/cli/tx.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .pending/bugfixes/cli/_4870-Disable-the-wi diff --git a/.pending/bugfixes/cli/_4870-Disable-the-wi b/.pending/bugfixes/cli/_4870-Disable-the-wi new file mode 100644 index 0000000000..bd911069d0 --- /dev/null +++ b/.pending/bugfixes/cli/_4870-Disable-the-wi @@ -0,0 +1 @@ +#4870 Disable the `withdraw-all-rewards` command when `--generate-only` is supplied diff --git a/x/distribution/client/cli/tx.go b/x/distribution/client/cli/tx.go index 084306e01e..e35769cb26 100644 --- a/x/distribution/client/cli/tx.go +++ b/x/distribution/client/cli/tx.go @@ -138,11 +138,17 @@ $ %s tx distr withdraw-all-rewards --from mykey ), Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc)) cliCtx := context.NewCLIContext().WithCodec(cdc) delAddr := cliCtx.GetFromAddress() + + // 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) + } + msgs, err := common.WithdrawAllDelegatorRewards(cliCtx, queryRoute, delAddr) if err != nil { return err @@ -152,6 +158,7 @@ $ %s tx distr withdraw-all-rewards --from mykey return splitAndApply(utils.GenerateOrBroadcastMsgs, cliCtx, txBldr, msgs, chunkSize) }, } + cmd.Flags().Int(flagMaxMessagesPerTx, MaxMessagesPerTxDefault, "Limit the number of messages per tx (0 for unlimited)") return cmd }