Skip to content

Commit 5e022ba

Browse files
authored
fix(cli): failed to convert address field in withdraw-validator-commission (#25485)
1 parent 9c4af5a commit 5e022ba

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
7676
* (x/epochs) [#25087](https://github.com/cosmos/cosmos-sdk/pull/25087) Remove redundant error check in BeginBlocker.
7777
* [GHSA-p22h-3m2v-cmgh](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-p22h-3m2v-cmgh) Fix x/distribution can halt when historical rewards overflow.
7878
* (x/staking) [#25258](https://github.com/cosmos/cosmos-sdk/pull/25258) Add delegator address to redelegate event.
79+
* (cli) [#25485](https://github.com/cosmos/cosmos-sdk/pull/25485) Avoid failed to convert address field in `withdraw-validator-commission` cmd.
7980

8081
### Deprecated
8182

x/distribution/client/cli/tx.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func NewTxCmd(valAc, ac address.Codec) *cobra.Command {
4343
NewSetWithdrawAddrCmd(ac),
4444
NewFundCommunityPoolCmd(ac),
4545
NewDepositValidatorRewardsPoolCmd(valAc, ac),
46+
NewWithdrawValidatorCommissionCmd(valAc, ac),
4647
)
4748

4849
return distTxCmd
@@ -304,3 +305,30 @@ func NewDepositValidatorRewardsPoolCmd(valCodec, ac address.Codec) *cobra.Comman
304305

305306
return cmd
306307
}
308+
309+
// NewWithdrawValidatorCommissionCmd returns a CLI command handler for creating a MsgWithdrawValidatorCommission transaction.
310+
func NewWithdrawValidatorCommissionCmd(valCodec, ac address.Codec) *cobra.Command {
311+
cmd := &cobra.Command{
312+
Use: "withdraw-validator-commission [validator-addr]",
313+
Short: "Withdraw commissions from a validator address (must be a validator operator)",
314+
Args: cobra.ExactArgs(1),
315+
RunE: func(cmd *cobra.Command, args []string) error {
316+
clientCtx, err := client.GetClientTxContext(cmd)
317+
if err != nil {
318+
return err
319+
}
320+
_, err = ac.BytesToString(clientCtx.GetFromAddress())
321+
if err != nil {
322+
return err
323+
}
324+
_, err = valCodec.StringToBytes(args[0])
325+
if err != nil {
326+
return err
327+
}
328+
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), types.NewMsgWithdrawValidatorCommission(args[0]))
329+
},
330+
}
331+
332+
flags.AddTxFlagsToCmd(cmd)
333+
return cmd
334+
}

0 commit comments

Comments
 (0)