2018-05-31 18:02:10 -07:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2019-06-05 16:26:17 -07:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
2018-05-31 18:02:10 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
2019-12-23 08:05:47 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
2020-03-27 08:51:53 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
2018-05-31 18:02:10 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-02-19 16:04:13 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
2018-05-31 18:02:10 -07:00
|
|
|
)
|
|
|
|
|
2020-03-27 08:51:53 -07:00
|
|
|
// NewTxCmd returns a root CLI command handler for all x/slashing transaction commands.
|
2020-05-21 14:29:34 -07:00
|
|
|
func NewTxCmd(ctx context.CLIContext) *cobra.Command {
|
2020-03-27 08:51:53 -07:00
|
|
|
slashingTxCmd := &cobra.Command{
|
|
|
|
Use: types.ModuleName,
|
2020-04-03 13:06:37 -07:00
|
|
|
Short: "Slashing transaction subcommands",
|
2020-03-27 08:51:53 -07:00
|
|
|
DisableFlagParsing: true,
|
|
|
|
SuggestionsMinimumDistance: 2,
|
|
|
|
RunE: client.ValidateCmd,
|
|
|
|
}
|
|
|
|
|
2020-05-21 14:29:34 -07:00
|
|
|
slashingTxCmd.AddCommand(NewUnjailTxCmd(ctx))
|
2020-03-27 08:51:53 -07:00
|
|
|
return slashingTxCmd
|
|
|
|
}
|
|
|
|
|
2020-05-21 14:29:34 -07:00
|
|
|
func NewUnjailTxCmd(ctx context.CLIContext) *cobra.Command {
|
2020-03-27 08:51:53 -07:00
|
|
|
cmd := &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 {
|
2020-05-21 14:29:34 -07:00
|
|
|
cliCtx := ctx.InitWithInput(cmd.InOrStdin())
|
2020-03-27 08:51:53 -07:00
|
|
|
|
|
|
|
valAddr := cliCtx.GetFromAddress()
|
|
|
|
msg := types.NewMsgUnjail(sdk.ValAddress(valAddr))
|
2020-04-09 07:00:10 -07:00
|
|
|
if err := msg.ValidateBasic(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-21 14:29:34 -07:00
|
|
|
return tx.GenerateOrBroadcastTx(cliCtx, msg)
|
2020-03-27 08:51:53 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
return flags.PostCommands(cmd)[0]
|
|
|
|
}
|