@@ -66,7 +66,9 @@ export default class TCAbciClient {
66
66
67
67
req . priority = 'high'
68
68
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
+ )
70
72
}
71
73
72
74
Socket ( ) {
@@ -228,14 +230,14 @@ export default class TCAbciClient {
228
230
method : 'POST' ,
229
231
body : JSON . stringify ( {
230
232
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 } : { } ) ,
239
241
} ) ,
240
242
} )
241
243
. then ( ( res ) => {
@@ -392,7 +394,7 @@ export default class TCAbciClient {
392
394
* @param {Response } response
393
395
* @return {Promise<*> }
394
396
*/
395
- async handleResponse ( response ) {
397
+ async handleRestResponse ( response ) {
396
398
if ( response . status >= 200 && response . status < 400 ) {
397
399
return response . json ( )
398
400
}
@@ -403,12 +405,10 @@ export default class TCAbciClient {
403
405
data = JSON . parse ( data )
404
406
405
407
return Promise . reject (
406
- new FetchError ( data . message ) . setCode ( response . status ) . setResponse ( data )
408
+ new FetchError ( data . message ) . setCode ( response . status ) . setResponse ( data ) ,
407
409
)
408
410
} catch ( e ) {
409
- return Promise . reject (
410
- new FetchError ( response . statusText )
411
- )
411
+ return Promise . reject ( new FetchError ( response . statusText ) )
412
412
}
413
413
}
414
414
0 commit comments