Merge PR #6525: x/bank: Refactor CLI & Tests
This commit is contained in:
+2
-8
@@ -78,7 +78,6 @@ the flag --nosort is set.
|
||||
cmd.Flags().Uint32(flagCoinType, sdk.GetConfig().GetCoinType(), "coin type number for HD derivation")
|
||||
cmd.Flags().Uint32(flagAccount, 0, "Account number for HD derivation")
|
||||
cmd.Flags().Uint32(flagIndex, 0, "Address index number for HD derivation")
|
||||
cmd.Flags().Bool(flags.FlagIndentResponse, false, "Add indent to JSON response")
|
||||
cmd.Flags().String(flagKeyAlgo, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for")
|
||||
|
||||
return cmd
|
||||
@@ -311,18 +310,13 @@ func printCreate(cmd *cobra.Command, info keyring.Info, showMnemonic bool, mnemo
|
||||
out.Mnemonic = mnemonic
|
||||
}
|
||||
|
||||
var jsonString []byte
|
||||
if viper.GetBool(flags.FlagIndentResponse) {
|
||||
jsonString, err = KeysCdc.MarshalJSONIndent(out, "", " ")
|
||||
} else {
|
||||
jsonString, err = KeysCdc.MarshalJSON(out)
|
||||
}
|
||||
|
||||
jsonString, err := KeysCdc.MarshalJSON(out)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PrintErrln(string(jsonString))
|
||||
|
||||
default:
|
||||
return fmt.Errorf("invalid output format %s", output)
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ func ListKeysCmd() *cobra.Command {
|
||||
along with their associated name and address.`,
|
||||
RunE: runListCmd,
|
||||
}
|
||||
cmd.Flags().Bool(flags.FlagIndentResponse, false, "Add indent to JSON response")
|
||||
|
||||
cmd.Flags().BoolP(flagListNames, "n", false, "List names only")
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/bech32"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@@ -85,7 +84,6 @@ hexadecimal into bech32 cosmos prefixed format and vice versa.
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: parseKey,
|
||||
}
|
||||
cmd.Flags().Bool(flags.FlagIndentResponse, false, "Indent JSON output")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -145,11 +143,7 @@ func displayParseKeyInfo(w io.Writer, stringer fmt.Stringer) {
|
||||
out, err = yaml.Marshal(&stringer)
|
||||
|
||||
case OutputFormatJSON:
|
||||
if viper.GetBool(flags.FlagIndentResponse) {
|
||||
out, err = KeysCdc.MarshalJSONIndent(stringer, "", " ")
|
||||
} else {
|
||||
out = KeysCdc.MustMarshalJSON(stringer)
|
||||
}
|
||||
out, err = KeysCdc.MarshalJSON(stringer)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -49,7 +49,6 @@ consisting of all the keys provided by name and multisig threshold.`,
|
||||
cmd.Flags().BoolP(FlagPublicKey, "p", false, "Output the public key only (overrides --output)")
|
||||
cmd.Flags().BoolP(FlagDevice, "d", false, "Output the address in a ledger device")
|
||||
cmd.Flags().Uint(flagMultiSigThreshold, 1, "K out of N required signatures")
|
||||
cmd.Flags().Bool(flags.FlagIndentResponse, false, "Add indent to JSON response")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
+3
-17
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/cli"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
cryptokeyring "github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
)
|
||||
|
||||
@@ -45,13 +44,7 @@ func printKeyInfo(w io.Writer, keyInfo cryptokeyring.Info, bechKeyOut bechKeyOut
|
||||
printTextInfos(w, []cryptokeyring.KeyOutput{ko})
|
||||
|
||||
case OutputFormatJSON:
|
||||
var out []byte
|
||||
var err error
|
||||
if viper.GetBool(flags.FlagIndentResponse) {
|
||||
out, err = KeysCdc.MarshalJSONIndent(ko, "", " ")
|
||||
} else {
|
||||
out, err = KeysCdc.MarshalJSON(ko)
|
||||
}
|
||||
out, err := KeysCdc.MarshalJSON(ko)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -71,18 +64,11 @@ func printInfos(w io.Writer, infos []cryptokeyring.Info) {
|
||||
printTextInfos(w, kos)
|
||||
|
||||
case OutputFormatJSON:
|
||||
var out []byte
|
||||
var err error
|
||||
|
||||
if viper.GetBool(flags.FlagIndentResponse) {
|
||||
out, err = KeysCdc.MarshalJSONIndent(kos, "", " ")
|
||||
} else {
|
||||
out, err = KeysCdc.MarshalJSON(kos)
|
||||
}
|
||||
|
||||
out, err := KeysCdc.MarshalJSON(kos)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user