-
Notifications
You must be signed in to change notification settings - Fork 52
/
tx_cancel_vest.go
47 lines (40 loc) · 1.14 KB
/
tx_cancel_vest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cli
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/elys-network/elys/x/commitment/types"
"github.com/spf13/cobra"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
func CmdCancelVest() *cobra.Command {
cmd := &cobra.Command{
Use: "cancel-vest [amount] [denom]",
Short: "Broadcast message cancel_vest",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argAmount, found := sdk.NewIntFromString(args[0])
if !found {
return errorsmod.Wrap(sdkerrors.ErrInvalidType, "cannot convert string to int")
}
argDenom := args[1]
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
msg := types.NewMsgCancelVest(
clientCtx.GetFromAddress().String(),
argAmount,
argDenom,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}