github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/slashing/client/cli/tx.go (about) 1 package cli 2 3 import ( 4 "bufio" 5 6 "github.com/spf13/cobra" 7 8 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client" 9 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context" 10 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/flags" 11 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 12 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 13 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth" 14 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/client/utils" 15 "github.com/fibonacci-chain/fbc/x/slashing/internal/types" 16 ) 17 18 // GetTxCmd returns the transaction commands for this module 19 func GetTxCmd(cdc *codec.Codec) *cobra.Command { 20 slashingTxCmd := &cobra.Command{ 21 Use: types.ModuleName, 22 Short: "Slashing transactions subcommands", 23 DisableFlagParsing: true, 24 SuggestionsMinimumDistance: 2, 25 RunE: client.ValidateCmd, 26 } 27 28 slashingTxCmd.AddCommand(flags.PostCommands( 29 GetCmdUnjail(cdc), 30 )...) 31 32 return slashingTxCmd 33 } 34 35 // GetCmdUnjail implements the create unjail validator command. 36 func GetCmdUnjail(cdc *codec.Codec) *cobra.Command { 37 return &cobra.Command{ 38 Use: "unjail", 39 Args: cobra.NoArgs, 40 Short: "unjail validator previously jailed for downtime", 41 Long: `unjail a jailed validator: 42 43 $ <appcli> tx slashing unjail --from mykey 44 `, 45 RunE: func(cmd *cobra.Command, args []string) error { 46 inBuf := bufio.NewReader(cmd.InOrStdin()) 47 txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) 48 cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) 49 50 valAddr := cliCtx.GetFromAddress() 51 52 msg := types.NewMsgUnjail(sdk.ValAddress(valAddr)) 53 return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) 54 }, 55 } 56 }