diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-01-10 06:19:33 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-01-10 06:19:33 +0800 |
commit | eb760aa33f0e158b3d26058aa1e9906a1f400a14 (patch) | |
tree | 864f5b616e9efb38b0282ab829871f794df0b0cd | |
parent | 262c34abac6a42edf7b6f3c463c9473740281296 (diff) | |
download | dexon-sol-tools-eb760aa33f0e158b3d26058aa1e9906a1f400a14.tar.gz dexon-sol-tools-eb760aa33f0e158b3d26058aa1e9906a1f400a14.tar.zst dexon-sol-tools-eb760aa33f0e158b3d26058aa1e9906a1f400a14.zip |
Prettier
-rw-r--r-- | packages/connect/src/http_client.ts | 41 | ||||
-rw-r--r-- | packages/connect/src/utils/relayer_response_json_parsers.ts | 13 | ||||
-rw-r--r-- | packages/connect/test/orderbook_channel_message_parsers_test.ts | 9 |
3 files changed, 19 insertions, 44 deletions
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts index d70e5ace4..5604a9607 100644 --- a/packages/connect/src/http_client.ts +++ b/packages/connect/src/http_client.ts @@ -48,11 +48,7 @@ export class HttpClient implements Client { const requestOpts = { params: request, }; - const responseJson = await this._requestAsync( - '/token_pairs', - HttpRequestType.Get, - requestOpts, - ); + const responseJson = await this._requestAsync('/token_pairs', HttpRequestType.Get, requestOpts); const tokenPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson); return tokenPairs; } @@ -68,11 +64,7 @@ export class HttpClient implements Client { const requestOpts = { params: request, }; - const responseJson = await this._requestAsync( - `/orders`, - HttpRequestType.Get, - requestOpts, - ); + const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, requestOpts); const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson); return orders; } @@ -83,10 +75,7 @@ export class HttpClient implements Client { */ public async getOrderAsync(orderHash: string): Promise<SignedOrder> { assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema); - const responseJson = await this._requestAsync( - `/order/${orderHash}`, - HttpRequestType.Get, - ); + const responseJson = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get); const order = relayerResponseJsonParsers.parseOrderJson(responseJson); return order; } @@ -100,11 +89,7 @@ export class HttpClient implements Client { const requestOpts = { params: request, }; - const responseJson = await this._requestAsync( - '/orderbook', - HttpRequestType.Get, - requestOpts, - ); + const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, requestOpts); const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson); return orderbook; } @@ -118,11 +103,7 @@ export class HttpClient implements Client { const requestOpts = { payload: request, }; - const responseJson = await this._requestAsync( - '/fees', - HttpRequestType.Post, - requestOpts, - ); + const responseJson = await this._requestAsync('/fees', HttpRequestType.Post, requestOpts); const fees = relayerResponseJsonParsers.parseFeesResponseJson(responseJson); return fees; } @@ -135,13 +116,13 @@ export class HttpClient implements Client { const requestOpts = { payload: signedOrder, }; - await this._requestAsync( - '/order', - HttpRequestType.Post, - requestOpts, - ); + await this._requestAsync('/order', HttpRequestType.Post, requestOpts); } - private async _requestAsync(path: string, requestType: HttpRequestType, requestOptions?: HttpRequestOptions): Promise<any> { + private async _requestAsync( + path: string, + requestType: HttpRequestType, + requestOptions?: HttpRequestOptions, + ): Promise<any> { const params = _.get(requestOptions, 'params'); const payload = _.get(requestOptions, 'payload'); let query = ''; diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 02d88f26d..668461bf4 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -1,15 +1,10 @@ -import {assert} from '@0xproject/assert'; -import {schemas} from '@0xproject/json-schemas'; +import { assert } from '@0xproject/assert'; +import { schemas } from '@0xproject/json-schemas'; import * as _ from 'lodash'; -import { - FeesResponse, - OrderbookResponse, - SignedOrder, - TokenPairsItem, -} from '../types'; +import { FeesResponse, OrderbookResponse, SignedOrder, TokenPairsItem } from '../types'; -import {typeConverters} from './type_converters'; +import { typeConverters } from './type_converters'; export const relayerResponseJsonParsers = { parseTokenPairsJson(json: any): TokenPairsItem[] { diff --git a/packages/connect/test/orderbook_channel_message_parsers_test.ts b/packages/connect/test/orderbook_channel_message_parsers_test.ts index cd7cdff12..3e1f44384 100644 --- a/packages/connect/test/orderbook_channel_message_parsers_test.ts +++ b/packages/connect/test/orderbook_channel_message_parsers_test.ts @@ -57,15 +57,14 @@ describe('orderbookChannelMessageParser', () => { expect(badCall).throws('Expected type to be of type string, encountered: 1'); }); it('throws when snapshot message has malformed payload', () => { - const badCall = () => - orderbookChannelMessageParser.parse(malformedSnapshotOrderbookChannelMessage); + const badCall = () => orderbookChannelMessageParser.parse(malformedSnapshotOrderbookChannelMessage); // tslint:disable-next-line:max-line-length - const errMsg = 'Validation errors: instance.payload requires property "bids", instance.payload requires property "asks"'; + const errMsg = + 'Validation errors: instance.payload requires property "bids", instance.payload requires property "asks"'; expect(badCall).throws(errMsg); }); it('throws when update message has malformed payload', () => { - const badCall = () => - orderbookChannelMessageParser.parse(malformedUpdateOrderbookChannelMessage); + const badCall = () => orderbookChannelMessageParser.parse(malformedUpdateOrderbookChannelMessage); expect(badCall).throws(/^Expected message to conform to schema/); }); it('throws when input message is not valid JSON', () => { |