-
Notifications
You must be signed in to change notification settings - Fork 13
/
tx.go
54 lines (46 loc) · 1.74 KB
/
tx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// nolint
package cli
import (
"bufio"
"github.com/spf13/cobra"
"github.com/okx/okbchain/libs/cosmos-sdk/client"
"github.com/okx/okbchain/libs/cosmos-sdk/client/context"
"github.com/okx/okbchain/libs/cosmos-sdk/client/flags"
"github.com/okx/okbchain/libs/cosmos-sdk/codec"
sdk "github.com/okx/okbchain/libs/cosmos-sdk/types"
"github.com/okx/okbchain/libs/cosmos-sdk/x/auth"
"github.com/okx/okbchain/libs/cosmos-sdk/x/auth/client/utils"
"github.com/okx/okbchain/libs/cosmos-sdk/x/crisis/internal/types"
)
// command to replace a delegator's withdrawal address
func GetCmdInvariantBroken(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "invariant-broken [module-name] [invariant-route]",
Short: "submit proof that an invariant broken to halt the chain",
Args: cobra.ExactArgs(2),
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)
senderAddr := cliCtx.GetFromAddress()
moduleName, route := args[0], args[1]
msg := types.NewMsgVerifyInvariant(senderAddr, moduleName, route)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
},
}
return cmd
}
// GetTxCmd returns the transaction commands for this module
func GetTxCmd(cdc *codec.Codec) *cobra.Command {
txCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Crisis transactions subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
txCmd.AddCommand(flags.PostCommands(
GetCmdInvariantBroken(cdc),
)...)
return txCmd
}