-
Notifications
You must be signed in to change notification settings - Fork 2
/
tx.go
52 lines (43 loc) · 1.47 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
package cli
import (
"github.com/spf13/cobra"
"github.com/hdac-io/friday/client"
"github.com/hdac-io/friday/client/context"
"github.com/hdac-io/friday/codec"
sdk "github.com/hdac-io/friday/types"
"github.com/hdac-io/friday/x/auth"
"github.com/hdac-io/friday/x/auth/client/utils"
"github.com/hdac-io/friday/x/slashing/types"
)
// GetTxCmd returns the transaction commands for this module
func GetTxCmd(cdc *codec.Codec) *cobra.Command {
slashingTxCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Slashing transactions subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
slashingTxCmd.AddCommand(client.PostCommands(
GetCmdUnjail(cdc),
)...)
return slashingTxCmd
}
// GetCmdUnjail implements the create unjail validator command.
func GetCmdUnjail(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "unjail",
Args: cobra.NoArgs,
Short: "unjail validator previously jailed for downtime",
Long: `unjail a jailed validator:
$ <appcli> tx slashing unjail --from mykey
`,
RunE: func(cmd *cobra.Command, args []string) error {
txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
cliCtx := context.NewCLIContext().WithCodec(cdc)
valAddr := cliCtx.GetFromAddress()
msg := types.NewMsgUnjail(sdk.ValAddress(valAddr))
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
},
}
}