Merge PR #4872: Disable "withdraw-all-rewards" command when "--generate-only" is supplied

This commit is contained in:
Alexander Bezobchuk 2019-08-08 11:51:54 -04:00 committed by GitHub
parent 42c54f8d0c
commit 745f2eb7e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1 @@
#4870 Disable the `withdraw-all-rewards` command when `--generate-only` is supplied

View File

@ -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
}