From dc273736be41defe94ea715658ec97419f9a394b Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 9 Jul 2020 15:36:13 +0300 Subject: [PATCH] rpc: adjust `getnep5balances` RPC-call JSON fields names Part of #1130 --- pkg/rpc/client/rpc_test.go | 4 ++-- pkg/rpc/response/result/nep5.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 3a58b9bc8..a024f048c 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -377,7 +377,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ } return c.GetNEP5Balances(hash) }, - serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"balance":[{"asset_hash":"a48b6e1291ba24211ad11bb90ae2a10bf1fcd5a8","amount":"50000000000","last_updated_block":251604}],"address":"AY6eqWjsUFCzsVELG7yG72XDukKvC34p2w"}}`, + serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"balance":[{"assethash":"a48b6e1291ba24211ad11bb90ae2a10bf1fcd5a8","amount":"50000000000","lastupdatedblock":251604}],"address":"AY6eqWjsUFCzsVELG7yG72XDukKvC34p2w"}}`, result: func(c *Client) interface{} { hash, err := util.Uint160DecodeStringLE("a48b6e1291ba24211ad11bb90ae2a10bf1fcd5a8") if err != nil { @@ -400,7 +400,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ invoke: func(c *Client) (interface{}, error) { return c.GetNEP5Transfers("AbHgdBaWEnHkCiLtDZXjhvhaAK2cwFh5pF") }, - serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"sent":[],"received":[{"timestamp":1555651816,"asset_hash":"600c4f5200db36177e3e8a09e9f18e2fc7d12a0f","transfer_address":"AYwgBNMepiv5ocGcyNT4mA8zPLTQ8pDBis","amount":"1000000","block_index":436036,"transfer_notify_index":0,"tx_hash":"df7683ece554ecfb85cf41492c5f143215dd43ef9ec61181a28f922da06aba58"}],"address":"AbHgdBaWEnHkCiLtDZXjhvhaAK2cwFh5pF"}}`, + serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"sent":[],"received":[{"timestamp":1555651816,"assethash":"600c4f5200db36177e3e8a09e9f18e2fc7d12a0f","transfer_address":"AYwgBNMepiv5ocGcyNT4mA8zPLTQ8pDBis","amount":"1000000","block_index":436036,"transfer_notify_index":0,"tx_hash":"df7683ece554ecfb85cf41492c5f143215dd43ef9ec61181a28f922da06aba58"}],"address":"AbHgdBaWEnHkCiLtDZXjhvhaAK2cwFh5pF"}}`, result: func(c *Client) interface{} { assetHash, err := util.Uint160DecodeStringLE("600c4f5200db36177e3e8a09e9f18e2fc7d12a0f") if err != nil { diff --git a/pkg/rpc/response/result/nep5.go b/pkg/rpc/response/result/nep5.go index fb906192b..c12844359 100644 --- a/pkg/rpc/response/result/nep5.go +++ b/pkg/rpc/response/result/nep5.go @@ -14,16 +14,16 @@ type NEP5Balances struct { // NEP5Balance represents balance for the single token contract. type NEP5Balance struct { - Asset util.Uint160 `json:"asset_hash"` + Asset util.Uint160 `json:"assethash"` Amount string `json:"amount"` - LastUpdated uint32 `json:"last_updated_block"` + LastUpdated uint32 `json:"lastupdatedblock"` } // nep5Balance is an auxilliary struct for proper Asset marshaling. type nep5Balance struct { - Asset string `json:"asset_hash"` + Asset string `json:"assethash"` Amount string `json:"amount"` - LastUpdated uint32 `json:"last_updated_block"` + LastUpdated uint32 `json:"lastupdatedblock"` } // NEP5Transfers is a result for the getnep5transfers RPC. @@ -36,7 +36,7 @@ type NEP5Transfers struct { // NEP5Transfer represents single NEP5 transfer event. type NEP5Transfer struct { Timestamp uint64 `json:"timestamp"` - Asset util.Uint160 `json:"asset_hash"` + Asset util.Uint160 `json:"assethash"` Address string `json:"transfer_address,omitempty"` Amount string `json:"amount"` Index uint32 `json:"block_index"`