2018-05-31 18:02:10 -07:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2019-11-14 06:17:21 -08:00
|
|
|
"bufio"
|
|
|
|
|
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"
|
2018-09-13 11:17:32 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2018-05-31 18:02:10 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2019-06-05 16:26:17 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
2020-01-24 08:40:56 -08:00
|
|
|
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
2020-02-19 16:04:13 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
2018-05-31 18:02:10 -07:00
|
|
|
)
|
|
|
|
|
2019-06-05 16:26:17 -07:00
|
|
|
// 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,
|
2019-06-15 05:34:11 -07:00
|
|
|
RunE: client.ValidateCmd,
|
2019-06-05 16:26:17 -07:00
|
|
|
}
|
|
|
|
|
2019-12-23 08:05:47 -08:00
|
|
|
slashingTxCmd.AddCommand(flags.PostCommands(
|
2019-06-05 16:26:17 -07:00
|
|
|
GetCmdUnjail(cdc),
|
|
|
|
)...)
|
|
|
|
|
|
|
|
return slashingTxCmd
|
|
|
|
}
|
|
|
|
|
2018-08-22 08:56:13 -07:00
|
|
|
// GetCmdUnjail implements the create unjail validator command.
|
2018-09-13 11:17:32 -07:00
|
|
|
func GetCmdUnjail(cdc *codec.Codec) *cobra.Command {
|
2019-02-06 16:15:37 -08:00
|
|
|
return &cobra.Command{
|
2018-08-22 08:56:13 -07:00
|
|
|
Use: "unjail",
|
2018-08-28 09:59:42 -07:00
|
|
|
Args: cobra.NoArgs,
|
2018-08-22 08:56:13 -07:00
|
|
|
Short: "unjail validator previously jailed for downtime",
|
2019-02-06 16:15:37 -08:00
|
|
|
Long: `unjail a jailed validator:
|
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
$ <appcli> tx slashing unjail --from mykey
|
2019-02-06 16:15:37 -08:00
|
|
|
`,
|
2018-05-31 18:02:10 -07:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2019-11-14 06:17:21 -08:00
|
|
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
2020-01-24 08:40:56 -08:00
|
|
|
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
|
2019-11-14 06:17:21 -08:00
|
|
|
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
|
2018-05-31 18:02:10 -07:00
|
|
|
|
2019-01-29 11:22:47 -08:00
|
|
|
valAddr := cliCtx.GetFromAddress()
|
2018-05-31 18:02:10 -07:00
|
|
|
|
2019-06-05 16:26:17 -07:00
|
|
|
msg := types.NewMsgUnjail(sdk.ValAddress(valAddr))
|
2020-01-24 08:40:56 -08:00
|
|
|
return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
|
2018-05-31 18:02:10 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|