From 31cf71fb62f391537125e103b1ec535302590ef2 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 13 Nov 2020 12:28:31 +0300 Subject: [PATCH] rpc: use default Uint160 marshaller for result.NEP5Balance.Asset To match C# behaviour we should marshal asset hash with `0x` prefix. --- pkg/rpc/response/result/nep5.go | 35 --------------------------------- 1 file changed, 35 deletions(-) diff --git a/pkg/rpc/response/result/nep5.go b/pkg/rpc/response/result/nep5.go index fea5fa07a..63e995f25 100644 --- a/pkg/rpc/response/result/nep5.go +++ b/pkg/rpc/response/result/nep5.go @@ -1,8 +1,6 @@ package result import ( - "encoding/json" - "github.com/nspcc-dev/neo-go/pkg/util" ) @@ -19,13 +17,6 @@ type NEP5Balance struct { LastUpdated uint32 `json:"lastupdatedblock"` } -// nep5Balance is an auxiliary struct for proper Asset marshaling. -type nep5Balance struct { - Asset string `json:"assethash"` - Amount string `json:"amount"` - LastUpdated uint32 `json:"lastupdatedblock"` -} - // NEP5Transfers is a result for the getnep5transfers RPC. type NEP5Transfers struct { Sent []NEP5Transfer `json:"sent"` @@ -43,29 +34,3 @@ type NEP5Transfer struct { NotifyIndex uint32 `json:"transfernotifyindex"` TxHash util.Uint256 `json:"txhash"` } - -// MarshalJSON implements json.Marshaler interface. -func (b *NEP5Balance) MarshalJSON() ([]byte, error) { - s := &nep5Balance{ - Asset: b.Asset.StringLE(), - Amount: b.Amount, - LastUpdated: b.LastUpdated, - } - return json.Marshal(s) -} - -// UnmarshalJSON implements json.Unmarshaler interface. -func (b *NEP5Balance) UnmarshalJSON(data []byte) error { - s := new(nep5Balance) - if err := json.Unmarshal(data, s); err != nil { - return err - } - asset, err := util.Uint160DecodeStringLE(s.Asset) - if err != nil { - return err - } - b.Amount = s.Amount - b.Asset = asset - b.LastUpdated = s.LastUpdated - return nil -}