-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx.go
53 lines (43 loc) · 1.41 KB
/
tx.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
48
49
50
51
52
53
package cli
import (
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/incubus-network/fanfury-sdk/v2/x/lsnative/slashing/types"
)
// NewTxCmd returns a root CLI command handler for all x/slashing transaction commands.
func NewTxCmd() *cobra.Command {
slashingTxCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Slashing transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
slashingTxCmd.AddCommand(NewUnjailTxCmd())
return slashingTxCmd
}
// NewUnjailTxCmd returns a CLI command handler for creating a MsgUnjail transaction.
func NewUnjailTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "unjail",
Args: cobra.NoArgs,
Short: "unjail validator previously jailed for downtime",
Long: `unjail a jailed validator:
$ <appd> tx slashing unjail --from mykey
`,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
valAddr := clientCtx.GetFromAddress()
msg := types.NewMsgUnjail(sdk.ValAddress(valAddr))
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}