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

56 lines
1.6 KiB
Go
Raw Normal View History

2018-05-31 18:02:10 -07:00
package cli
import (
"bufio"
"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/codec"
2018-05-31 18:02:10 -07:00
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/cosmos/cosmos-sdk/x/slashing/internal/types"
2018-05-31 18:02:10 -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,
RunE: client.ValidateCmd,
}
slashingTxCmd.AddCommand(client.PostCommands(
GetCmdUnjail(cdc),
)...)
return slashingTxCmd
}
2018-08-22 08:56:13 -07:00
// GetCmdUnjail implements the create unjail validator command.
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",
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:
$ <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 {
inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
2018-05-31 18:02:10 -07:00
valAddr := cliCtx.GetFromAddress()
2018-05-31 18:02:10 -07:00
msg := types.NewMsgUnjail(sdk.ValAddress(valAddr))
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
2018-05-31 18:02:10 -07:00
},
}
}