Skip to content

Commit

Permalink
json.Marshal => cdc.MarshalJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes committed Jun 28, 2018
1 parent 3b447d1 commit 1256170
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestSimulateTx(t *testing.T) {
require.Equal(t, result.Code, sdk.ABCICodeOK, result.Log)
require.Equal(t, int64(80), result.GasUsed)
counter--
encoded, err := json.Marshal(tx)
encoded, err := app.cdc.MarshalJSON(tx)
require.Nil(t, err)
query := abci.RequestQuery{
Path: "/app/simulate",
Expand Down Expand Up @@ -999,17 +999,15 @@ func copyVal(val abci.Validator) abci.Validator {
}

func toJSON(o interface{}) []byte {
bz, err := json.Marshal(o)
bz, err := wire.Cdc.MarshalJSON(o)
if err != nil {
panic(err)
}
// fmt.Println(">> toJSON:", string(bz))
return bz
}

func fromJSON(bz []byte, ptr interface{}) {
// fmt.Println(">> fromJSON:", string(bz))
err := json.Unmarshal(bz, ptr)
err := wire.Cdc.UnmarshalJSON(bz, ptr)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ func doSend(t *testing.T, port, seed, name, password string, addr sdk.Address) (
chainID := viper.GetString(client.FlagChainID)

// send
coinbz, err := json.Marshal(sdk.NewCoin("steak", 1))
coinbz, err := cdc.MarshalJSON(sdk.NewCoin("steak", 1))
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions client/tx/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tx

import (
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
"strconv"
Expand Down Expand Up @@ -72,7 +71,7 @@ func queryTx(cdc *wire.Codec, ctx context.CoreContext, hashHexStr string, trustN
return nil, err
}

return json.MarshalIndent(info, "", " ")
return wire.MarshalJSONIndent(cdc, info)
}

func formatTxResult(cdc *wire.Codec, res *ctypes.ResultTx) (txInfo, error) {
Expand Down
4 changes: 2 additions & 2 deletions x/auth/stdtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ func StdSignBytes(chainID string, accnum int64, sequence int64, fee StdFee, msgs
for _, msg := range msgs {
msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes()))
}
msgBytes, err := json.Marshal(msgsBytes)
msgBytes, err := msgCdc.MarshalJSON(msgsBytes)
if err != nil {
panic(err)
}

bz, err := json.Marshal(StdSignDoc{
bz, err := msgCdc.MarshalJSON(StdSignDoc{
ChainID: chainID,
AccountNumber: accnum,
Sequence: sequence,
Expand Down

0 comments on commit 1256170

Please sign in to comment.