Merge PR #6525: x/bank: Refactor CLI & Tests

This commit is contained in:
Alexander Bezobchuk
2020-06-30 16:59:21 -04:00
committed by GitHub
parent 56af94e6ab
commit d5049413ef
35 changed files with 665 additions and 561 deletions
+1 -7
View File
@@ -155,13 +155,7 @@ $ %s query txs --%s 'message.sender=cosmos1...&message.action=withdraw_delegator
return err
}
var output []byte
if clientCtx.Indent {
output, err = cdc.MarshalJSONIndent(txs, "", " ")
} else {
output, err = cdc.MarshalJSON(txs)
}
output, err := cdc.MarshalJSON(txs)
if err != nil {
return err
}
+5 -8
View File
@@ -128,18 +128,15 @@ func makeMultiSignCmd(clientCtx client.Context) func(cmd *cobra.Command, args []
newStdSig := types.StdSignature{Signature: sigBz, PubKey: multisigPub.Bytes()} //nolint:staticcheck
newTx := types.NewStdTx(stdTx.GetMsgs(), stdTx.Fee, []types.StdSignature{newStdSig}, stdTx.GetMemo()) //nolint:staticcheck
sigOnly := viper.GetBool(flagSigOnly)
var json []byte
switch {
case sigOnly && clientCtx.Indent:
json, err = cdc.MarshalJSONIndent(newTx.Signatures[0], "", " ")
case sigOnly && !clientCtx.Indent:
sigOnly := viper.GetBool(flagSigOnly)
if sigOnly {
json, err = cdc.MarshalJSON(newTx.Signatures[0])
case !sigOnly && clientCtx.Indent:
json, err = cdc.MarshalJSONIndent(newTx, "", " ")
default:
} else {
json, err = cdc.MarshalJSON(newTx)
}
if err != nil {
return err
}
+7 -20
View File
@@ -116,7 +116,7 @@ func makeSignBatchCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string)
return err
}
json, err := getSignatureJSON(cdc, stdTx, clientCtx.Indent, generateSignatureOnly)
json, err := getSignatureJSON(cdc, stdTx, generateSignatureOnly)
if err != nil {
return err
}
@@ -232,7 +232,7 @@ func makeSignCmd(clientCtx client.Context) func(cmd *cobra.Command, args []strin
return err
}
json, err := getSignatureJSON(clientCtx.Codec, newTx, clientCtx.Indent, generateSignatureOnly)
json, err := getSignatureJSON(clientCtx.Codec, newTx, generateSignatureOnly)
if err != nil {
return err
}
@@ -256,23 +256,10 @@ func makeSignCmd(clientCtx client.Context) func(cmd *cobra.Command, args []strin
}
}
func getSignatureJSON(cdc *codec.Codec, newTx types.StdTx, indent, generateSignatureOnly bool) ([]byte, error) {
switch generateSignatureOnly {
case true:
switch indent {
case true:
return cdc.MarshalJSONIndent(newTx.Signatures[0], "", " ")
default:
return cdc.MarshalJSON(newTx.Signatures[0])
}
default:
switch indent {
case true:
return cdc.MarshalJSONIndent(newTx, "", " ")
default:
return cdc.MarshalJSON(newTx)
}
func getSignatureJSON(cdc *codec.Codec, newTx types.StdTx, generateSignatureOnly bool) ([]byte, error) {
if generateSignatureOnly {
return cdc.MarshalJSON(newTx.Signatures[0])
}
return cdc.MarshalJSON(newTx)
}