github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/crisis/client/cli/tx.go (about) 1 // nolint 2 package cli 3 4 import ( 5 "bufio" 6 7 "github.com/spf13/cobra" 8 9 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client" 10 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context" 11 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/flags" 12 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 13 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 14 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth" 15 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/client/utils" 16 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/crisis/internal/types" 17 ) 18 19 // command to replace a delegator's withdrawal address 20 func GetCmdInvariantBroken(cdc *codec.Codec) *cobra.Command { 21 cmd := &cobra.Command{ 22 Use: "invariant-broken [module-name] [invariant-route]", 23 Short: "submit proof that an invariant broken to halt the chain", 24 Args: cobra.ExactArgs(2), 25 RunE: func(cmd *cobra.Command, args []string) error { 26 27 inBuf := bufio.NewReader(cmd.InOrStdin()) 28 txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) 29 cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) 30 31 senderAddr := cliCtx.GetFromAddress() 32 moduleName, route := args[0], args[1] 33 msg := types.NewMsgVerifyInvariant(senderAddr, moduleName, route) 34 return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) 35 }, 36 } 37 return cmd 38 } 39 40 // GetTxCmd returns the transaction commands for this module 41 func GetTxCmd(cdc *codec.Codec) *cobra.Command { 42 txCmd := &cobra.Command{ 43 Use: types.ModuleName, 44 Short: "Crisis transactions subcommands", 45 DisableFlagParsing: true, 46 SuggestionsMinimumDistance: 2, 47 RunE: client.ValidateCmd, 48 } 49 50 txCmd.AddCommand(flags.PostCommands( 51 GetCmdInvariantBroken(cdc), 52 )...) 53 return txCmd 54 }