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

45 lines
1.2 KiB
Go
Raw Normal View History

2018-05-31 18:02:10 -07:00
package cli
import (
2018-08-06 11:11:30 -07:00
"os"
2018-05-31 18:02:10 -07:00
"github.com/cosmos/cosmos-sdk/client/context"
2018-08-06 11:11:30 -07:00
"github.com/cosmos/cosmos-sdk/client/utils"
2018-05-31 18:02:10 -07:00
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
2018-05-31 18:02:10 -07:00
"github.com/cosmos/cosmos-sdk/x/slashing"
2018-08-06 11:11:30 -07:00
"github.com/spf13/cobra"
2018-05-31 18:02:10 -07:00
)
2018-08-22 08:56:13 -07:00
// GetCmdUnjail implements the create unjail validator command.
func GetCmdUnjail(cdc *wire.Codec) *cobra.Command {
2018-05-31 18:02:10 -07:00
cmd := &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",
2018-05-31 18:02:10 -07:00
RunE: func(cmd *cobra.Command, args []string) error {
2018-09-07 10:15:49 -07:00
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
2018-08-06 11:11:30 -07:00
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
WithAccountDecoder(authcmd.GetAccountDecoder(cdc))
2018-05-31 18:02:10 -07:00
valAddr, err := cliCtx.GetFromAddress()
2018-05-31 18:02:10 -07:00
if err != nil {
return err
}
msg := slashing.NewMsgUnjail(sdk.ValAddress(valAddr))
if cliCtx.GenerateOnly {
2018-09-07 10:15:49 -07:00
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
}
2018-09-07 10:15:49 -07:00
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
2018-05-31 18:02:10 -07:00
},
}
2018-08-06 11:11:30 -07:00
2018-05-31 18:02:10 -07:00
return cmd
}