58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
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/cosmos/cosmos-sdk/x/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
|
|
}
|
|
|
|
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 := client.GetClientContextFromCmd(cmd)
|
|
clientCtx, err := client.ReadTxCommandFlags(clientCtx, cmd.Flags())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
valAddr := clientCtx.GetFromAddress()
|
|
|
|
msg := types.NewMsgUnjail(sdk.ValAddress(valAddr))
|
|
if err := msg.ValidateBasic(); err != nil {
|
|
return err
|
|
}
|
|
|
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
|
},
|
|
}
|
|
|
|
flags.AddTxFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|