Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve withdraw-all-rewards UX #9781

Merged
merged 8 commits into from
Jul 28, 2021
12 changes: 10 additions & 2 deletions x/distribution/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ func NewWithdrawAllRewardsCmd() *cobra.Command {
Short: "withdraw all delegations rewards for a delegator",
Long: strings.TrimSpace(
fmt.Sprintf(`Withdraw all rewards for a single delegator.
Note that this command will not work if run using --%[2]s=%[3]s or --%[2]s=%[4]s and a chunk size greater than 0.
To make it work with those broadcast modes, you have to use --%[6]s=0, otherwise the broadcast mode %[5]s will be used instead.

Example:
$ %s tx distribution withdraw-all-rewards --from mykey
$ %[1]s tx distribution withdraw-all-rewards --from mykey
`,
version.AppName,
version.AppName, flags.FlagBroadcastMode, flags.BroadcastSync, flags.BroadcastAsync, flags.BroadcastBlock, FlagMaxMessagesPerTx,
),
),
Args: cobra.NoArgs,
Expand Down Expand Up @@ -167,6 +169,12 @@ $ %s tx distribution withdraw-all-rewards --from mykey
}

chunkSize, _ := cmd.Flags().GetInt(FlagMaxMessagesPerTx)
if clientCtx.BroadcastMode != flags.BroadcastBlock && chunkSize > 0 {
cmd.Println("Cannot use broadcast mode %s with chunk size that is not 0. Applying broadcast mode block",
clientCtx.BroadcastMode)
clientCtx.BroadcastMode = flags.BroadcastBlock
}

return newSplitAndApply(tx.GenerateOrBroadcastTxCLI, clientCtx, cmd.Flags(), msgs, chunkSize)
},
}
Expand Down