From ce88086e080e05ed71c1ef4e31f2d0ce530af67f Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 14 Aug 2018 14:40:52 -0700 Subject: Update types to reflect v2 --- .../src/utils/relayer_response_json_parsers.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'packages/connect/src/utils/relayer_response_json_parsers.ts') diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index ccae8b115..55f787820 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -2,19 +2,19 @@ import { assert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; import { SignedOrder } from '@0xproject/types'; -import { FeesResponse, OrderbookResponse, TokenPairsItem } from '../types'; +import { OrderConfigResponse, OrderbookResponse, TokenPairsItem } from '../types'; import { typeConverters } from './type_converters'; export const relayerResponseJsonParsers = { parseTokenPairsJson(json: any): TokenPairsItem[] { - assert.doesConformToSchema('tokenPairs', json, schemas.relayerApiTokenPairsResponseSchema); - return json.map((tokenPair: any) => { - return typeConverters.convertStringsFieldsToBigNumbers(tokenPair, [ - 'tokenA.minAmount', - 'tokenA.maxAmount', - 'tokenB.minAmount', - 'tokenB.maxAmount', + assert.doesConformToSchema('assetDataPairs', json, schemas.relayerApiTokenPairsResponseSchema); + return json.map((assetDataPair: any) => { + return typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [ + 'assetDataA.minAmount', + 'assetDataA.maxAmount', + 'assetDataB.minAmount', + 'assetDataB.maxAmount', ]); }); }, @@ -30,8 +30,8 @@ export const relayerResponseJsonParsers = { assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrderBookResponseSchema); return typeConverters.convertOrderbookStringFieldsToBigNumber(json); }, - parseFeesResponseJson(json: any): FeesResponse { - assert.doesConformToSchema('fees', json, schemas.relayerApiFeesResponseSchema); + parseOrderConfigResponseJson(json: any): OrderConfigResponse { + assert.doesConformToSchema('fees', json, schemas.relayerApiOrderConfigResponseSchema); return typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']); }, }; -- cgit From 5c40c466f6e9f690afa86f23dd5ba240691dceb8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 14 Aug 2018 14:59:53 -0700 Subject: Update json-schemas, update HTTPClient types --- packages/connect/src/utils/relayer_response_json_parsers.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/connect/src/utils/relayer_response_json_parsers.ts') diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 55f787820..6463aefb0 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -2,13 +2,13 @@ import { assert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; import { SignedOrder } from '@0xproject/types'; -import { OrderConfigResponse, OrderbookResponse, TokenPairsItem } from '../types'; +import { AssetPairsItem, OrderbookResponse, OrderConfigResponse } from '../types'; import { typeConverters } from './type_converters'; export const relayerResponseJsonParsers = { - parseTokenPairsJson(json: any): TokenPairsItem[] { - assert.doesConformToSchema('assetDataPairs', json, schemas.relayerApiTokenPairsResponseSchema); + parseAssetDataPairsJson(json: any): AssetPairsItem[] { + assert.doesConformToSchema('assetDataPairs', json, schemas.relayerApiAssetDataPairsResponseSchema); return json.map((assetDataPair: any) => { return typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [ 'assetDataA.minAmount', @@ -27,7 +27,7 @@ export const relayerResponseJsonParsers = { return typeConverters.convertOrderStringFieldsToBigNumber(json); }, parseOrderbookResponseJson(json: any): OrderbookResponse { - assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrderBookResponseSchema); + assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrdersResponseSchema); return typeConverters.convertOrderbookStringFieldsToBigNumber(json); }, parseOrderConfigResponseJson(json: any): OrderConfigResponse { -- cgit From bb992f8a49b42a1cd50d5bcc868f6d69fcd1a7ae Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 14 Aug 2018 19:16:36 -0700 Subject: Update parsing code --- .../src/utils/relayer_response_json_parsers.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'packages/connect/src/utils/relayer_response_json_parsers.ts') diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 6463aefb0..9a17b23d3 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -1,14 +1,16 @@ import { assert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; -import { SignedOrder } from '@0xproject/types'; -import { AssetPairsItem, OrderbookResponse, OrderConfigResponse } from '../types'; +import { APIOrder, AssetPairsItem, AssetPairsResponse, OrderbookResponse, OrderConfigResponse, OrdersResponse } from '../types'; import { typeConverters } from './type_converters'; export const relayerResponseJsonParsers = { - parseAssetDataPairsJson(json: any): AssetPairsItem[] { + parseAssetDataPairsJson(json: any): AssetPairsResponse { assert.doesConformToSchema('assetDataPairs', json, schemas.relayerApiAssetDataPairsResponseSchema); + return { ...json, records: relayerResponseJsonParsers.parseAssetDataPairsJson(json.records) }; + }, + parseAssetPairsItemJson(json: any): AssetPairsItem[] { return json.map((assetDataPair: any) => { return typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [ 'assetDataA.minAmount', @@ -18,20 +20,20 @@ export const relayerResponseJsonParsers = { ]); }); }, - parseOrdersJson(json: any): SignedOrder[] { - assert.doesConformToSchema('orders', json, schemas.signedOrdersSchema); - return json.map((order: object) => typeConverters.convertOrderStringFieldsToBigNumber(order)); + parseOrdersJson(json: any): OrdersResponse { + assert.doesConformToSchema('relayerApiOrdersResponse', json, schemas.relayerApiOrdersResponseSchema); + return { ...json, records: json.records.map(relayerResponseJsonParsers.parseAPIOrderJson.bind(relayerResponseJsonParsers)) }; }, - parseOrderJson(json: any): SignedOrder { - assert.doesConformToSchema('order', json, schemas.signedOrderSchema); + parseAPIOrderJson(json: any): APIOrder { + assert.doesConformToSchema('relayerApiOrder', json, schemas.relayerApiOrderSchema); return typeConverters.convertOrderStringFieldsToBigNumber(json); }, parseOrderbookResponseJson(json: any): OrderbookResponse { - assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrdersResponseSchema); + assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrderbookResponseSchema); return typeConverters.convertOrderbookStringFieldsToBigNumber(json); }, parseOrderConfigResponseJson(json: any): OrderConfigResponse { - assert.doesConformToSchema('fees', json, schemas.relayerApiOrderConfigResponseSchema); + assert.doesConformToSchema('orderConfig', json, schemas.relayerApiOrderConfigResponseSchema); return typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']); }, }; -- cgit From c325d638c98a990f2d0e991f2e03287183ba292f Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 15 Aug 2018 17:18:19 -0700 Subject: getAssetPairsAsync tests passing --- packages/connect/src/utils/relayer_response_json_parsers.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'packages/connect/src/utils/relayer_response_json_parsers.ts') diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 9a17b23d3..37099384f 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -7,10 +7,10 @@ import { typeConverters } from './type_converters'; export const relayerResponseJsonParsers = { parseAssetDataPairsJson(json: any): AssetPairsResponse { - assert.doesConformToSchema('assetDataPairs', json, schemas.relayerApiAssetDataPairsResponseSchema); - return { ...json, records: relayerResponseJsonParsers.parseAssetDataPairsJson(json.records) }; + assert.doesConformToSchema('assetDataPairsResponse', json, schemas.relayerApiAssetDataPairsResponseSchema); + return { ...json, records: relayerResponseJsonParsers.parseAssetPairsItemsJson(json.records) }; }, - parseAssetPairsItemJson(json: any): AssetPairsItem[] { + parseAssetPairsItemsJson(json: any): AssetPairsItem[] { return json.map((assetDataPair: any) => { return typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [ 'assetDataA.minAmount', @@ -29,11 +29,11 @@ export const relayerResponseJsonParsers = { return typeConverters.convertOrderStringFieldsToBigNumber(json); }, parseOrderbookResponseJson(json: any): OrderbookResponse { - assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrderbookResponseSchema); + assert.doesConformToSchema('orderBookResponse', json, schemas.relayerApiOrderbookResponseSchema); return typeConverters.convertOrderbookStringFieldsToBigNumber(json); }, parseOrderConfigResponseJson(json: any): OrderConfigResponse { - assert.doesConformToSchema('orderConfig', json, schemas.relayerApiOrderConfigResponseSchema); + assert.doesConformToSchema('orderConfigResponse', json, schemas.relayerApiOrderConfigResponseSchema); return typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']); }, }; -- cgit From 1c87e5f69809954add5e76de520e8ef4f405c1c0 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 15 Aug 2018 17:31:39 -0700 Subject: Get orders async tests passing --- packages/connect/src/utils/relayer_response_json_parsers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/connect/src/utils/relayer_response_json_parsers.ts') diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 37099384f..2b2e1efe7 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -26,7 +26,7 @@ export const relayerResponseJsonParsers = { }, parseAPIOrderJson(json: any): APIOrder { assert.doesConformToSchema('relayerApiOrder', json, schemas.relayerApiOrderSchema); - return typeConverters.convertOrderStringFieldsToBigNumber(json); + return typeConverters.convertAPIOrderStringFieldsToBigNumber(json); }, parseOrderbookResponseJson(json: any): OrderbookResponse { assert.doesConformToSchema('orderBookResponse', json, schemas.relayerApiOrderbookResponseSchema); -- cgit From 075e3a41c876797907e3ad98f20940e32e8d0762 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 20 Aug 2018 11:42:29 -0700 Subject: Update websocket for SRA v2 --- packages/connect/src/utils/relayer_response_json_parsers.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'packages/connect/src/utils/relayer_response_json_parsers.ts') diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 2b2e1efe7..dff854dfb 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -22,7 +22,10 @@ export const relayerResponseJsonParsers = { }, parseOrdersJson(json: any): OrdersResponse { assert.doesConformToSchema('relayerApiOrdersResponse', json, schemas.relayerApiOrdersResponseSchema); - return { ...json, records: json.records.map(relayerResponseJsonParsers.parseAPIOrderJson.bind(relayerResponseJsonParsers)) }; + return { ...json, records: relayerResponseJsonParsers.parseAPIOrdersJson(json.records) }; + }, + parseAPIOrdersJson(json: any): APIOrder[] { + return json.map(relayerResponseJsonParsers.parseAPIOrderJson.bind(relayerResponseJsonParsers)); }, parseAPIOrderJson(json: any): APIOrder { assert.doesConformToSchema('relayerApiOrder', json, schemas.relayerApiOrderSchema); -- cgit From 44cc5e45cc3a3ed7db2691a287500e5d61a2d0c1 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 20 Aug 2018 11:53:49 -0700 Subject: Run prettier --- packages/connect/src/utils/relayer_response_json_parsers.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'packages/connect/src/utils/relayer_response_json_parsers.ts') diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index dff854dfb..ebd877b70 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -1,7 +1,14 @@ import { assert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; -import { APIOrder, AssetPairsItem, AssetPairsResponse, OrderbookResponse, OrderConfigResponse, OrdersResponse } from '../types'; +import { + APIOrder, + AssetPairsItem, + AssetPairsResponse, + OrderbookResponse, + OrderConfigResponse, + OrdersResponse, +} from '../types'; import { typeConverters } from './type_converters'; -- cgit