Co-authored-by: Devon Bear <itsdevbear@berachain.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"cosmossdk.io/core/address"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
|
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
|
)
|
|
|
|
// NewTxCmd returns a root CLI command handler for all x/slashing transaction commands.
|
|
func NewTxCmd(ac address.Codec) *cobra.Command {
|
|
slashingTxCmd := &cobra.Command{
|
|
Use: types.ModuleName,
|
|
Short: "Slashing transaction subcommands",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: client.ValidateCmd,
|
|
}
|
|
|
|
slashingTxCmd.AddCommand(NewUnjailTxCmd(ac))
|
|
return slashingTxCmd
|
|
}
|
|
|
|
// NewUnjailTxCmd returns a CLI command handler for creating a MsgUnjail transaction.
|
|
func NewUnjailTxCmd(valAc address.Codec) *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, err := client.GetClientTxContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
valAddr, err := valAc.BytesToString(clientCtx.GetFromAddress())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
msg := types.NewMsgUnjail(valAddr)
|
|
|
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
|
},
|
|
}
|
|
|
|
flags.AddTxFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|