aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/src/utils
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-08-15 05:59:53 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-08-15 07:06:09 +0800
commit5c40c466f6e9f690afa86f23dd5ba240691dceb8 (patch)
treec7eda62370f6dff4f4fd253dc1484705ea6f3cb9 /packages/connect/src/utils
parentce88086e080e05ed71c1ef4e31f2d0ce530af67f (diff)
downloaddexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.gz
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.bz2
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.lz
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.xz
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.zst
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.zip
Update json-schemas, update HTTPClient types
Diffstat (limited to 'packages/connect/src/utils')
-rw-r--r--packages/connect/src/utils/orderbook_channel_message_parser.ts10
-rw-r--r--packages/connect/src/utils/relayer_response_json_parsers.ts8
2 files changed, 6 insertions, 12 deletions
diff --git a/packages/connect/src/utils/orderbook_channel_message_parser.ts b/packages/connect/src/utils/orderbook_channel_message_parser.ts
index ca739e587..986209c54 100644
--- a/packages/connect/src/utils/orderbook_channel_message_parser.ts
+++ b/packages/connect/src/utils/orderbook_channel_message_parser.ts
@@ -6,7 +6,7 @@ import { OrdersChannelMessage, OrdersChannelMessageTypes } from '../types';
import { relayerResponseJsonParsers } from './relayer_response_json_parsers';
-export const orderbookChannelMessageParser = {
+export const ordersChannelMessageParser = {
parse(utf8Data: string): OrdersChannelMessage {
// parse the message
const messageObj = JSON.parse(utf8Data);
@@ -19,14 +19,8 @@ export const orderbookChannelMessageParser = {
assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`);
assert.isNumber('requestId', requestId);
switch (type) {
- case OrdersChannelMessageTypes.Snapshot: {
- assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema);
- const orderbookJson = messageObj.payload;
- const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(orderbookJson);
- return _.assign(messageObj, { payload: orderbook });
- }
case OrdersChannelMessageTypes.Update: {
- assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelUpdateSchema);
+ assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrdersChannelUpdateSchema);
const orderJson = messageObj.payload;
const order = relayerResponseJsonParsers.parseOrderJson(orderJson);
return _.assign(messageObj, { payload: order });
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 {