From 1fd5e5928ce86579b92b03a7640ab37f55e02a05 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 3 Sep 2019 18:11:13 +0300 Subject: [PATCH] rpc: fix bad name spellings noted by golint pkg/rpc/neoScanBalanceGetter.go:54:56: method parameter assetIdUint should be assetIDUint pkg/rpc/neoScanBalanceGetter.go:62:3: var assetId should be assetID pkg/rpc/server_test.go:27:5: var testRpcCases should be testRPCCases pkg/rpc/txTypes.go:19:3: struct field assetId should be assetID pkg/rpc/txTypes.go:39:35: interface method parameter assetId should be assetID pkg/rpc/types.go:115:2: struct field TxId should be TxID Refs. #213. --- pkg/rpc/neoScanBalanceGetter.go | 6 +++--- pkg/rpc/rpc.go | 2 +- pkg/rpc/server_test.go | 10 +++++----- pkg/rpc/txBuilder.go | 2 +- pkg/rpc/txTypes.go | 6 +++--- pkg/rpc/types.go | 2 +- pkg/rpc/wrappers/asset_state.go | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/rpc/neoScanBalanceGetter.go b/pkg/rpc/neoScanBalanceGetter.go index 26f61415c..5e7b6150d 100644 --- a/pkg/rpc/neoScanBalanceGetter.go +++ b/pkg/rpc/neoScanBalanceGetter.go @@ -51,7 +51,7 @@ func filterSpecificAsset(asset string, balance []*Unspent, assetBalance *Unspent } // CalculateInputs creates input transactions for the specified amount of given asset belonging to specified address. -func (s NeoScanServer) CalculateInputs(address string, assetIdUint util.Uint256, cost util.Fixed8) ([]transaction.Input, util.Fixed8, error) { +func (s NeoScanServer) CalculateInputs(address string, assetIDUint util.Uint256, cost util.Fixed8) ([]transaction.Input, util.Fixed8, error) { var ( err error num, i uint16 @@ -59,12 +59,12 @@ func (s NeoScanServer) CalculateInputs(address string, assetIdUint util.Uint256, selected = util.Fixed8(0) us []*Unspent assetUnspent Unspent - assetId = GlobalAssets[assetIdUint.ReverseString()] + assetID = GlobalAssets[assetIDUint.ReverseString()] ) if us, err = s.GetBalance(address); err != nil { return nil, util.Fixed8(0), errs.Wrapf(err, "Cannot get balance for address %v", address) } - filterSpecificAsset(assetId, us, &assetUnspent) + filterSpecificAsset(assetID, us, &assetUnspent) sort.Sort(assetUnspent.Unspent) for _, us := range assetUnspent.Unspent { diff --git a/pkg/rpc/rpc.go b/pkg/rpc/rpc.go index 81ab1f186..b2cf38953 100644 --- a/pkg/rpc/rpc.go +++ b/pkg/rpc/rpc.go @@ -115,7 +115,7 @@ func (c *Client) SendToAddress(asset util.Uint256, address string, amount util.F rawTx *transaction.Transaction rawTxStr string txParams = ContractTxParams{ - assetId: asset, + assetID: asset, address: address, value: amount, wif: c.WIF(), diff --git a/pkg/rpc/server_test.go b/pkg/rpc/server_test.go index 03b18acd7..e719df3ae 100644 --- a/pkg/rpc/server_test.go +++ b/pkg/rpc/server_test.go @@ -24,18 +24,18 @@ type tc struct { expectedResult string } -var testRpcCases = []tc{ +var testRPCCases = []tc{ { rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"] }`, method: "getassetstate_1", - expectedResult: `{"jsonrpc":"2.0","result":{"assetId":"0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7","assetType":1,"name":"NEOGas","amount":"100000000","available":"0","precision":8,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"AWKECj9RD8rS8RPcpCgYVjk1DeYyHwxZm3","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`, + expectedResult: `{"jsonrpc":"2.0","result":{"assetID":"0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7","assetType":1,"name":"NEOGas","amount":"100000000","available":"0","precision":8,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"AWKECj9RD8rS8RPcpCgYVjk1DeYyHwxZm3","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`, }, { rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b"] }`, method: "getassetstate_2", - expectedResult: `{"jsonrpc":"2.0","result":{"assetId":"0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","assetType":0,"name":"NEO","amount":"100000000","available":"0","precision":0,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`, + expectedResult: `{"jsonrpc":"2.0","result":{"assetID":"0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","assetType":0,"name":"NEO","amount":"100000000","available":"0","precision":0,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`, }, { @@ -255,13 +255,13 @@ func TestHandler(t *testing.T) { // setup handler handler := http.HandlerFunc(rpcServer.requestHandler) - testRpcCases = append(testRpcCases, tc{ + testRPCCases = append(testRPCCases, tc{ rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getversion", "params": [] }`, method: "getversion", expectedResult: fmt.Sprintf(`{"jsonrpc":"2.0","result":{"port":20333,"nonce":%s,"useragent":"/NEO-GO:/"},"id":1}`, strconv.FormatUint(uint64(server.ID()), 10)), }) - for _, tc := range testRpcCases { + for _, tc := range testRPCCases { t.Run(fmt.Sprintf("method: %s, rpc call: %s", tc.method, tc.rpcCall), func(t *testing.T) { req := httptest.NewRequest("POST", "http://0.0.0.0:20333/", strings.NewReader(tc.rpcCall)) diff --git a/pkg/rpc/txBuilder.go b/pkg/rpc/txBuilder.go index df2e85689..401af25fd 100644 --- a/pkg/rpc/txBuilder.go +++ b/pkg/rpc/txBuilder.go @@ -22,7 +22,7 @@ func CreateRawContractTransaction(params ContractTxParams) (*transaction.Transac spent util.Fixed8 witness transaction.Witness - wif, assetID, address, amount, balancer = params.wif, params.assetId, params.address, params.value, params.balancer + wif, assetID, address, amount, balancer = params.wif, params.assetID, params.address, params.value, params.balancer ) if fromAddress, err = wif.PrivateKey.Address(); err != nil { diff --git a/pkg/rpc/txTypes.go b/pkg/rpc/txTypes.go index d15f96ae3..96ad082d5 100644 --- a/pkg/rpc/txTypes.go +++ b/pkg/rpc/txTypes.go @@ -16,7 +16,7 @@ type ( // includes parameters duplication `sendtoaddress` RPC call params // and also some utility data; ContractTxParams struct { - assetId util.Uint256 + assetID util.Uint256 address string value util.Fixed8 wif keys.WIF // a WIF to send the transaction @@ -30,12 +30,12 @@ type ( BalanceGetter interface { // parameters // address: base58-encoded address assets would be transferred from - // assetId: asset identifier + // assetID: asset identifier // amount: an asset amount to spend // return values // inputs: UTXO's for the preparing transaction // total: summarized asset amount from all the `inputs` // error: error would be considered in the caller function - CalculateInputs(address string, assetId util.Uint256, amount util.Fixed8) (inputs []transaction.Input, total util.Fixed8, err error) + CalculateInputs(address string, assetID util.Uint256, amount util.Fixed8) (inputs []transaction.Input, total util.Fixed8, err error) } ) diff --git a/pkg/rpc/types.go b/pkg/rpc/types.go index d56fa662b..28e6a8d3d 100644 --- a/pkg/rpc/types.go +++ b/pkg/rpc/types.go @@ -112,7 +112,7 @@ type TxResponse struct { // Vin represents JSON-serializable tx input. type Vin struct { - TxId string `json:"txid"` + TxID string `json:"txid"` Vout int `json:"vout"` } diff --git a/pkg/rpc/wrappers/asset_state.go b/pkg/rpc/wrappers/asset_state.go index f4e32e33b..c439af8d9 100644 --- a/pkg/rpc/wrappers/asset_state.go +++ b/pkg/rpc/wrappers/asset_state.go @@ -10,7 +10,7 @@ import ( // AssetState wrapper used for the representation of // core.AssetState on the RPC Server. type AssetState struct { - ID util.Uint256 `json:"assetId"` + ID util.Uint256 `json:"assetID"` AssetType transaction.AssetType `json:"assetType"` Name string `json:"name"` Amount util.Fixed8 `json:"amount"`