diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-08-15 05:40:52 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-08-15 05:40:52 +0800 |
commit | ce88086e080e05ed71c1ef4e31f2d0ce530af67f (patch) | |
tree | f2022bb7bc42c9bc85cbef19c684b666e2d7f66f /packages/connect/src/utils | |
parent | c1cc92a46f9ebfa4408a5dc515f1e100fe3a7054 (diff) | |
download | dexon-0x-contracts-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.tar.gz dexon-0x-contracts-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.tar.zst dexon-0x-contracts-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.zip |
Update types to reflect v2
Diffstat (limited to 'packages/connect/src/utils')
3 files changed, 18 insertions, 18 deletions
diff --git a/packages/connect/src/utils/orderbook_channel_message_parser.ts b/packages/connect/src/utils/orderbook_channel_message_parser.ts index 593288078..ca739e587 100644 --- a/packages/connect/src/utils/orderbook_channel_message_parser.ts +++ b/packages/connect/src/utils/orderbook_channel_message_parser.ts @@ -2,12 +2,12 @@ import { assert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; import * as _ from 'lodash'; -import { OrderbookChannelMessage, OrderbookChannelMessageTypes } from '../types'; +import { OrdersChannelMessage, OrdersChannelMessageTypes } from '../types'; import { relayerResponseJsonParsers } from './relayer_response_json_parsers'; export const orderbookChannelMessageParser = { - parse(utf8Data: string): OrderbookChannelMessage { + parse(utf8Data: string): OrdersChannelMessage { // parse the message const messageObj = JSON.parse(utf8Data); // ensure we have a type parameter to switch on @@ -19,13 +19,13 @@ export const orderbookChannelMessageParser = { assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`); assert.isNumber('requestId', requestId); switch (type) { - case OrderbookChannelMessageTypes.Snapshot: { + case OrdersChannelMessageTypes.Snapshot: { assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema); const orderbookJson = messageObj.payload; const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(orderbookJson); return _.assign(messageObj, { payload: orderbook }); } - case OrderbookChannelMessageTypes.Update: { + case OrdersChannelMessageTypes.Update: { assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelUpdateSchema); const orderJson = messageObj.payload; const order = relayerResponseJsonParsers.parseOrderJson(orderJson); @@ -33,7 +33,7 @@ export const orderbookChannelMessageParser = { } default: { return { - type: OrderbookChannelMessageTypes.Unknown, + type: OrdersChannelMessageTypes.Unknown, requestId, payload: undefined, }; 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']); }, }; diff --git a/packages/connect/src/utils/type_converters.ts b/packages/connect/src/utils/type_converters.ts index 210d452b9..513f9b39f 100644 --- a/packages/connect/src/utils/type_converters.ts +++ b/packages/connect/src/utils/type_converters.ts @@ -12,11 +12,11 @@ export const typeConverters = { }, convertOrderStringFieldsToBigNumber(order: any): any { return typeConverters.convertStringsFieldsToBigNumbers(order, [ - 'makerTokenAmount', - 'takerTokenAmount', + 'makerAssetAmount', + 'takerAssetAmount', 'makerFee', 'takerFee', - 'expirationUnixTimestampSec', + 'expirationTimeSeconds', 'salt', ]); }, |