cosmos-sdk/x/slashing/client/cli/tx.go

51 lines
1.4 KiB
Go
Raw Normal View History

2018-05-31 18:02:10 -07:00
package cli
import (
"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"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
2018-05-31 18:02:10 -07:00
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/slashing/types"
2018-05-31 18:02:10 -07:00
)
// NewTxCmd returns a root CLI command handler for all x/slashing transaction commands.
func NewTxCmd(ctx context.CLIContext) *cobra.Command {
slashingTxCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Slashing transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
slashingTxCmd.AddCommand(NewUnjailTxCmd(ctx))
return slashingTxCmd
}
func NewUnjailTxCmd(ctx context.CLIContext) *cobra.Command {
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 {
cliCtx := ctx.InitWithInput(cmd.InOrStdin())
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
}
return tx.GenerateOrBroadcastTx(cliCtx, msg)
},
}
return flags.PostCommands(cmd)[0]
}