From 1256170589899f755ce2892153503297a1ba887a Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Fri, 29 Jun 2018 01:09:27 +0200 Subject: [PATCH] json.Marshal => cdc.MarshalJSON --- baseapp/baseapp_test.go | 8 +++----- client/lcd/lcd_test.go | 2 +- client/tx/query.go | 3 +-- x/auth/stdtx.go | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index d2343c2ecff3..9d567c6bff20 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -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", @@ -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) } diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index 3e3ac6b6ee53..5d750cfddc94 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -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) } diff --git a/client/tx/query.go b/client/tx/query.go index a99729f955c2..e70ecea39922 100644 --- a/client/tx/query.go +++ b/client/tx/query.go @@ -2,7 +2,6 @@ package tx import ( "encoding/hex" - "encoding/json" "fmt" "net/http" "strconv" @@ -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) { diff --git a/x/auth/stdtx.go b/x/auth/stdtx.go index e429548a811d..f2809a5c7a0c 100644 --- a/x/auth/stdtx.go +++ b/x/auth/stdtx.go @@ -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,