Skip to content

Commit ccae004

Browse files
authored
Merge pull request #74 from TransferChain/development
Development
2 parents d71999a + 66cfd33 commit ccae004

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

client.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export default class TCAbciClient {
6666

6767
req.priority = 'high'
6868

69-
return fetch(this.readNodeAddress + uri, req).then((response) => this.handleResponse(response))
69+
return fetch(this.readNodeAddress + uri, req).then((response) =>
70+
this.handleRestResponse(response),
71+
)
7072
}
7173

7274
Socket() {
@@ -228,14 +230,14 @@ export default class TCAbciClient {
228230
method: 'POST',
229231
body: JSON.stringify({
230232
height: `${heightOperator} ${height}`,
231-
recipient_addrs: recipientAddrs,
232-
sender_addrs: senderAddrs,
233-
hashes: hashes,
234-
limit,
235-
offset,
236-
order_field: orderField,
237-
order_by: orderBy,
238-
...(types ? { types: types } : { typ: typ }),
233+
...(recipientAddrs ? { recipient_addrs: recipientAddrs } : {}),
234+
...(senderAddrs ? { sender_addrs: senderAddrs } : {}),
235+
...(hashes ? { hashes: hashes } : {}),
236+
...(limit ? { limit: limit } : {}),
237+
...(offset ? { offset: offset } : {}),
238+
...(orderField ? { order_field: orderField } : {}),
239+
...(orderBy ? { order_by: orderBy } : {}),
240+
...(types ? { types: types } : typ ? { typ: typ } : {}),
239241
}),
240242
})
241243
.then((res) => {
@@ -392,7 +394,7 @@ export default class TCAbciClient {
392394
* @param {Response} response
393395
* @return {Promise<*>}
394396
*/
395-
async handleResponse(response) {
397+
async handleRestResponse(response) {
396398
if (response.status >= 200 && response.status < 400) {
397399
return response.json()
398400
}
@@ -403,12 +405,10 @@ export default class TCAbciClient {
403405
data = JSON.parse(data)
404406

405407
return Promise.reject(
406-
new FetchError(data.message).setCode(response.status).setResponse(data)
408+
new FetchError(data.message).setCode(response.status).setResponse(data),
407409
)
408410
} catch (e) {
409-
return Promise.reject(
410-
new FetchError(response.statusText)
411-
)
411+
return Promise.reject(new FetchError(response.statusText))
412412
}
413413
}
414414

client_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ describe('TCAbciClient TESTS', () => {
183183
limit: 1,
184184
offset: 0,
185185
orderBy: 'ASC',
186+
types: ['storage'],
186187
})
187188
.then((data) => {
188189
unitJS.value(data.txs).hasLength(1)

0 commit comments

Comments
 (0)