Merge PR #4872: Disable "withdraw-all-rewards" command when "--generate-only" is supplied
This commit is contained in:
parent
42c54f8d0c
commit
745f2eb7e3
1
.pending/bugfixes/cli/_4870-Disable-the-wi
Normal file
1
.pending/bugfixes/cli/_4870-Disable-the-wi
Normal file
@ -0,0 +1 @@
|
||||
#4870 Disable the `withdraw-all-rewards` command when `--generate-only` is supplied
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user