Skip to content

Commit

Permalink
adds cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Nov 29, 2024
1 parent 06308cb commit 7cabc05
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion x/incentive/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cli

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"

"github.com/babylonlabs-io/babylon/x/incentive/types"
Expand All @@ -23,6 +23,7 @@ func GetTxCmd() *cobra.Command {

cmd.AddCommand(
NewWithdrawRewardCmd(),
NewSetWithdrawAddressCmd(),
)

return cmd
Expand Down Expand Up @@ -52,3 +53,34 @@ func NewWithdrawRewardCmd() *cobra.Command {

return cmd
}

func NewSetWithdrawAddressCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "set-withdraw-addr [withdraw-addr]",
Short: "change the default withdraw address for rewards",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

delAddr := clientCtx.GetFromAddress()
withdrawAddr, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
return err
}

msg := &types.MsgSetWithdrawAddress{
DelegatorAddress: delAddr.String(),
WithdrawAddress: string(withdrawAddr),
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

0 comments on commit 7cabc05

Please sign in to comment.