Merge PR #6595: Single Binary & Command Refactor
This commit is contained in:
@@ -8,24 +8,22 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
)
|
||||
|
||||
func Cmd(cdc *codec.Codec) *cobra.Command {
|
||||
func Cmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "debug",
|
||||
Short: "Tool for helping with debugging your application",
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmd.AddCommand(PubkeyCmd(cdc))
|
||||
cmd.AddCommand(PubkeyCmd())
|
||||
cmd.AddCommand(AddrCmd())
|
||||
cmd.AddCommand(RawBytesCmd())
|
||||
|
||||
@@ -68,7 +66,7 @@ func getPubKeyFromString(pkstr string) (crypto.PubKey, error) {
|
||||
return nil, fmt.Errorf("pubkey '%s' invalid; expected hex, base64, or bech32", pubKey)
|
||||
}
|
||||
|
||||
func PubkeyCmd(cdc *codec.Codec) *cobra.Command {
|
||||
func PubkeyCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "pubkey [pubkey]",
|
||||
Short: "Decode a ED25519 pubkey from hex, base64, or bech32",
|
||||
@@ -77,9 +75,11 @@ func PubkeyCmd(cdc *codec.Codec) *cobra.Command {
|
||||
Example:
|
||||
$ %s debug pubkey TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz
|
||||
$ %s debug pubkey cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
|
||||
`, version.ClientName, version.ClientName),
|
||||
`, version.AppName, version.AppName),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
pk, err := getPubKeyFromString(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -90,7 +90,7 @@ $ %s debug pubkey cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
|
||||
return fmt.Errorf("invalid pubkey type; expected ED25519")
|
||||
}
|
||||
|
||||
pubKeyJSONBytes, err := cdc.MarshalJSON(edPK)
|
||||
pubKeyJSONBytes, err := clientCtx.JSONMarshaler.MarshalJSON(edPK)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func AddrCmd() *cobra.Command {
|
||||
|
||||
Example:
|
||||
$ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
|
||||
`, version.ClientName),
|
||||
`, version.AppName),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -171,7 +171,7 @@ func RawBytesCmd() *cobra.Command {
|
||||
|
||||
Example:
|
||||
$ %s debug raw-bytes [72 101 108 108 111 44 32 112 108 97 121 103 114 111 117 110 100]
|
||||
`, version.ClientName),
|
||||
`, version.AppName),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
stringBytes := args[0]
|
||||
|
||||
Reference in New Issue
Block a user