Merge PR #5916: Migrate x/crisis tx command
This commit is contained in:
parent
e8a82f78ca
commit
e0c1774e20
|
@ -39,11 +39,8 @@ func NewSendTxCmd(m codec.Marshaler, txg tx.Generator, ar tx.AccountRetriever) *
|
|||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
inBuf := bufio.NewReader(cmd.InOrStdin())
|
||||
txf := tx.NewFactoryFromCLI(inBuf).
|
||||
WithTxGenerator(txg).
|
||||
WithAccountRetriever(ar)
|
||||
|
||||
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithMarshaler(m)
|
||||
txf := tx.NewFactoryFromCLI(inBuf).WithTxGenerator(txg).WithAccountRetriever(ar)
|
||||
|
||||
toAddr, err := sdk.AccAddressFromBech32(args[1])
|
||||
if err != nil {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// nolint
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
@ -9,6 +8,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
|
@ -16,6 +16,66 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/crisis/types"
|
||||
)
|
||||
|
||||
// NewTxCmd returns a root CLI command handler for all x/crisis transaction commands.
|
||||
func NewTxCmd(m codec.Marshaler, txg tx.Generator, ar tx.AccountRetriever) *cobra.Command {
|
||||
txCmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "Crisis transactions subcommands",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
txCmd.AddCommand(NewMsgVerifyInvariantTxCmd(m, txg, ar))
|
||||
|
||||
return txCmd
|
||||
}
|
||||
|
||||
// NewMsgVerifyInvariantTxCmd returns a CLI command handler for creating a
|
||||
// MsgVerifyInvariant transaction.
|
||||
func NewMsgVerifyInvariantTxCmd(m codec.Marshaler, txg tx.Generator, ar tx.AccountRetriever) *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())
|
||||
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithMarshaler(m)
|
||||
txf := tx.NewFactoryFromCLI(inBuf).WithTxGenerator(txg).WithAccountRetriever(ar)
|
||||
|
||||
senderAddr := cliCtx.GetFromAddress()
|
||||
moduleName, route := args[0], args[1]
|
||||
|
||||
msg := types.NewMsgVerifyInvariant(senderAddr, moduleName, route)
|
||||
return tx.GenerateOrBroadcastTx(cliCtx, txf, msg)
|
||||
},
|
||||
}
|
||||
|
||||
return flags.PostCommands(cmd)[0]
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Deprecated
|
||||
//
|
||||
// TODO: Remove once client-side Protobuf migration has been completed.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// command to replace a delegator's withdrawal address
|
||||
func GetCmdInvariantBroken(cdc *codec.Codec) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
|
@ -36,19 +96,3 @@ func GetCmdInvariantBroken(cdc *codec.Codec) *cobra.Command {
|
|||
}
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue