Make sure cmd uses encoding/json not wire.JSONBytes
This commit is contained in:
parent
7b39417b99
commit
935c74d970
|
@ -2,6 +2,7 @@ package commands
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
|
@ -133,7 +134,12 @@ func ibcRegisterTxCmd(cmd *cobra.Command, args []string) error {
|
|||
},
|
||||
}
|
||||
|
||||
fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx)))
|
||||
out, err := json.Marshal(ibcTx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("IBCTx:", string(out))
|
||||
|
||||
data := []byte(wire.BinaryBytes(struct {
|
||||
ibc.IBCTx `json:"unwrap"`
|
||||
|
@ -172,7 +178,11 @@ func ibcUpdateTxCmd(cmd *cobra.Command, args []string) error {
|
|||
Commit: *commit,
|
||||
}
|
||||
|
||||
fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx)))
|
||||
out, err := json.Marshal(ibcTx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("IBCTx:", string(out))
|
||||
|
||||
data := []byte(wire.BinaryBytes(struct {
|
||||
ibc.IBCTx `json:"unwrap"`
|
||||
|
@ -211,7 +221,11 @@ func ibcPacketCreateTxCmd(cmd *cobra.Command, args []string) error {
|
|||
},
|
||||
}
|
||||
|
||||
fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx)))
|
||||
out, err := json.Marshal(ibcTx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("IBCTx:", string(out))
|
||||
|
||||
data := []byte(wire.BinaryBytes(struct {
|
||||
ibc.IBCTx `json:"unwrap"`
|
||||
|
@ -253,7 +267,11 @@ func ibcPacketPostTxCmd(cmd *cobra.Command, args []string) error {
|
|||
Proof: proof,
|
||||
}
|
||||
|
||||
fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx)))
|
||||
out, err := json.Marshal(ibcTx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("IBCTx:", string(out))
|
||||
|
||||
data := []byte(wire.BinaryBytes(struct {
|
||||
ibc.IBCTx `json:"unwrap"`
|
||||
|
|
|
@ -2,6 +2,7 @@ package commands
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
|
@ -99,11 +100,16 @@ func queryCmd(cmd *cobra.Command, args []string) error {
|
|||
proof := resp.Proof
|
||||
height := resp.Height
|
||||
|
||||
fmt.Println(string(wire.JSONBytes(struct {
|
||||
out, err := json.Marshal(struct {
|
||||
Value []byte `json:"value"`
|
||||
Proof []byte `json:"proof"`
|
||||
Height uint64 `json:"height"`
|
||||
}{val, proof, height})))
|
||||
}{val, proof, height})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(string(out))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -126,7 +132,11 @@ func accountCmd(cmd *cobra.Command, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(wire.JSONBytes(acc)))
|
||||
out, err := json.Marshal(acc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(out))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -147,7 +157,7 @@ func blockCmd(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Println(string(wire.JSONBytes(struct {
|
||||
out, err := json.Marshal(struct {
|
||||
Hex BlockHex `json:"hex"`
|
||||
JSON BlockJSON `json:"json"`
|
||||
}{
|
||||
|
@ -159,7 +169,12 @@ func blockCmd(cmd *cobra.Command, args []string) error {
|
|||
Header: header,
|
||||
Commit: commit,
|
||||
},
|
||||
})))
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(string(out))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package commands
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
@ -141,8 +142,13 @@ func sendTxCmd(cmd *cobra.Command, args []string) error {
|
|||
signBytes := tx.SignBytes(chainIDFlag)
|
||||
tx.Inputs[0].Signature = privKey.Sign(signBytes)
|
||||
|
||||
out, err := json.Marshal(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Signed SendTx:")
|
||||
fmt.Println(string(wire.JSONBytes(tx)))
|
||||
fmt.Println(string(out))
|
||||
|
||||
// broadcast the transaction to tendermint
|
||||
data, log, err := broadcastTx(tx)
|
||||
|
@ -197,8 +203,13 @@ func AppTx(name string, data []byte) error {
|
|||
|
||||
tx.Input.Signature = privKey.Sign(tx.SignBytes(chainIDFlag))
|
||||
|
||||
out, err := json.Marshal(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Signed AppTx:")
|
||||
fmt.Println(string(wire.JSONBytes(tx)))
|
||||
fmt.Println(string(out))
|
||||
|
||||
data, log, err := broadcastTx(tx)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -45,7 +46,11 @@ func counterTxCmd(cmd *cobra.Command, args []string) error {
|
|||
Fee: countFee,
|
||||
}
|
||||
|
||||
fmt.Println("CounterTx:", string(wire.JSONBytes(counterTx)))
|
||||
out, err := json.Marshal(counterTx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("CounterTx:", string(out))
|
||||
|
||||
data := wire.BinaryBytes(counterTx)
|
||||
name := "counter"
|
||||
|
|
Loading…
Reference in New Issue