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 | |
parent | c1cc92a46f9ebfa4408a5dc515f1e100fe3a7054 (diff) | |
download | dexon-sol-tools-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.tar dexon-sol-tools-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.tar.gz dexon-sol-tools-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.tar.bz2 dexon-sol-tools-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.tar.lz dexon-sol-tools-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.tar.xz dexon-sol-tools-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.tar.zst dexon-sol-tools-ce88086e080e05ed71c1ef4e31f2d0ce530af67f.zip |
Update types to reflect v2
Diffstat (limited to 'packages/connect')
26 files changed, 186 insertions, 210 deletions
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts index 1b51ee429..b2e15775e 100644 --- a/packages/connect/src/http_client.ts +++ b/packages/connect/src/http_client.ts @@ -9,8 +9,8 @@ import { schemas as clientSchemas } from './schemas/schemas'; import { AssetPairsRequestOpts, Client, - FeesRequest, - FeesResponse, + OrderConfigRequest, + OrderConfigResponse, HttpRequestOptions, HttpRequestType, OrderbookRequest, @@ -65,8 +65,8 @@ export class HttpClient implements Client { this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes } /** - * Retrieve token pair info from the API - * @param requestOpts Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 } + * Retrieve assetData pair info from the API + * @param requestOpts Options specifying assetData information to retrieve and page information, defaults to { page: 1, perPage: 100 } * @return The resulting TokenPairsItems that match the request */ public async getAssetPairsAsync(requestOpts?: AssetPairsRequestOpts & PagedRequestOpts): Promise<TokenPairsItem[]> { @@ -77,9 +77,9 @@ export class HttpClient implements Client { const httpRequestOpts = { params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS), }; - const responseJson = await this._requestAsync('/token_pairs', HttpRequestType.Get, httpRequestOpts); - const tokenPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson); - return tokenPairs; + const responseJson = await this._requestAsync('/assetData_pairs', HttpRequestType.Get, httpRequestOpts); + const assetDataPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson); + return assetDataPairs; } /** * Retrieve orders from the API @@ -132,16 +132,16 @@ export class HttpClient implements Client { } /** * Retrieve fee information from the API - * @param request A FeesRequest instance describing the specific fees to retrieve - * @return The resulting FeesResponse that matches the request + * @param request A OrderConfigRequest instance describing the specific fees to retrieve + * @return The resulting OrderConfigResponse that matches the request */ - public async getOrderConfigAsync(request: FeesRequest): Promise<FeesResponse> { + public async getOrderConfigAsync(request: OrderConfigRequest): Promise<OrderConfigResponse> { assert.doesConformToSchema('request', request, clientSchemas.feesRequestSchema); const httpRequestOpts = { payload: request, }; const responseJson = await this._requestAsync('/fees', HttpRequestType.Post, httpRequestOpts); - const fees = relayerResponseJsonParsers.parseFeesResponseJson(responseJson); + const fees = relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson); return fees; } /** diff --git a/packages/connect/src/index.ts b/packages/connect/src/index.ts index a4fc39425..e57967714 100644 --- a/packages/connect/src/index.ts +++ b/packages/connect/src/index.ts @@ -2,8 +2,8 @@ export { HttpClient } from './http_client'; export { orderbookChannelFactory } from './orderbook_channel_factory'; export { Client, - FeesRequest, - FeesResponse, + OrderConfigRequest, + OrderConfigResponse, OrderbookChannel, OrderbookChannelHandler, OrderbookChannelSubscriptionOpts, @@ -13,7 +13,7 @@ export { PagedRequestOpts, TokenPairsItem, AssetPairsRequestOpts, - TokenTradeInfo, + Asset, } from './types'; export { Order, SignedOrder } from '@0xproject/types'; diff --git a/packages/connect/src/schemas/fees_request_schema.ts b/packages/connect/src/schemas/fees_request_schema.ts index ff3d7b9d3..e41e49e09 100644 --- a/packages/connect/src/schemas/fees_request_schema.ts +++ b/packages/connect/src/schemas/fees_request_schema.ts @@ -1,26 +1,26 @@ export const feesRequestSchema = { - id: '/FeesRequest', + id: '/OrderConfigRequest', type: 'object', properties: { - exchangeContractAddress: { $ref: '/Address' }, + exchangeAddress: { $ref: '/Address' }, maker: { $ref: '/Address' }, taker: { $ref: '/Address' }, makerTokenAddress: { $ref: '/Address' }, takerTokenAddress: { $ref: '/Address' }, - makerTokenAmount: { $ref: '/Number' }, - takerTokenAmount: { $ref: '/Number' }, - expirationUnixTimestampSec: { $ref: '/Number' }, + makerAssetAmount: { $ref: '/Number' }, + takerAssetAmount: { $ref: '/Number' }, + expirationTimeSeconds: { $ref: '/Number' }, salt: { $ref: '/Number' }, }, required: [ - 'exchangeContractAddress', + 'exchangeAddress', 'maker', 'taker', 'makerTokenAddress', 'takerTokenAddress', - 'makerTokenAmount', - 'takerTokenAmount', - 'expirationUnixTimestampSec', + 'makerAssetAmount', + 'takerAssetAmount', + 'expirationTimeSeconds', 'salt', ], }; diff --git a/packages/connect/src/schemas/orderbook_request_schema.ts b/packages/connect/src/schemas/orderbook_request_schema.ts index 5f3463242..cc75ada5c 100644 --- a/packages/connect/src/schemas/orderbook_request_schema.ts +++ b/packages/connect/src/schemas/orderbook_request_schema.ts @@ -2,8 +2,8 @@ export const orderBookRequestSchema = { id: '/OrderBookRequest', type: 'object', properties: { - baseTokenAddress: { $ref: '/Address' }, - quoteTokenAddress: { $ref: '/Address' }, + baseAssetData: { $ref: '/Address' }, + quoteAssetData: { $ref: '/Address' }, }, - required: ['baseTokenAddress', 'quoteTokenAddress'], + required: ['baseAssetData', 'quoteAssetData'], }; diff --git a/packages/connect/src/schemas/orders_request_opts_schema.ts b/packages/connect/src/schemas/orders_request_opts_schema.ts index 5facbc959..1a9f74f7f 100644 --- a/packages/connect/src/schemas/orders_request_opts_schema.ts +++ b/packages/connect/src/schemas/orders_request_opts_schema.ts @@ -2,12 +2,12 @@ export const ordersRequestOptsSchema = { id: '/OrdersRequestOpts', type: 'object', properties: { - exchangeContractAddress: { $ref: '/Address' }, + exchangeAddress: { $ref: '/Address' }, tokenAddress: { $ref: '/Address' }, makerTokenAddress: { $ref: '/Address' }, takerTokenAddress: { $ref: '/Address' }, - tokenA: { $ref: '/Address' }, - tokenB: { $ref: '/Address' }, + assetDataA: { $ref: '/Address' }, + assetDataB: { $ref: '/Address' }, maker: { $ref: '/Address' }, taker: { $ref: '/Address' }, trader: { $ref: '/Address' }, diff --git a/packages/connect/src/schemas/token_pairs_request_opts_schema.ts b/packages/connect/src/schemas/token_pairs_request_opts_schema.ts index dffd063d0..bf1caa20d 100644 --- a/packages/connect/src/schemas/token_pairs_request_opts_schema.ts +++ b/packages/connect/src/schemas/token_pairs_request_opts_schema.ts @@ -2,7 +2,7 @@ export const AssetPairsRequestOptsSchema = { id: '/AssetPairsRequestOpts', type: 'object', properties: { - tokenA: { $ref: '/Address' }, - tokenB: { $ref: '/Address' }, + assetDataA: { $ref: '/Address' }, + assetDataB: { $ref: '/Address' }, }, }; diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts index ca56d251b..0f2242329 100644 --- a/packages/connect/src/types.ts +++ b/packages/connect/src/types.ts @@ -2,11 +2,12 @@ import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; export interface Client { - getAssetPairsAsync: (requestOpts?: AssetPairsRequestOpts & PagedRequestOpts) => Promise<TokenPairsItem[]>; - getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<SignedOrder[]>; - getOrderAsync: (orderHash: string) => Promise<SignedOrder>; + getAssetPairsAsync: (requestOpts?: AssetPairsRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<TokenPairsItem>>; + getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<APIOrder>>; + getOrderAsync: (orderHash: string) => Promise<APIOrder>; getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>; - getOrderConfigAsync: (request: FeesRequest) => Promise<FeesResponse>; + getOrderConfigAsync: (request: OrderConfigRequest) => Promise<OrderConfigResponse>; + getFeeRecipients: () => Promise<PaginatedCollection<string>>; submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>; } @@ -16,58 +17,45 @@ export interface OrderbookChannel { } /** - * baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price - * quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price + * baseAssetData: The address of assetData designated as the baseToken in the currency pair calculation of price + * quoteAssetData: The address of assetData designated as the quoteToken in the currency pair calculation of price * snapshot: If true, a snapshot of the orderbook will be sent before the updates to the orderbook * limit: Maximum number of bids and asks in orderbook snapshot */ export interface OrderbookChannelSubscriptionOpts { - baseTokenAddress: string; - quoteTokenAddress: string; + baseAssetData: string; + quoteAssetData: string; snapshot: boolean; limit: number; } export interface OrderbookChannelHandler { - onSnapshot: ( - channel: OrderbookChannel, - subscriptionOpts: OrderbookChannelSubscriptionOpts, - snapshot: OrderbookResponse, - ) => void; onUpdate: ( channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts, - order: SignedOrder, + order: APIOrder, ) => void; onError: (channel: OrderbookChannel, err: Error, subscriptionOpts?: OrderbookChannelSubscriptionOpts) => void; onClose: (channel: OrderbookChannel) => void; } -export type OrderbookChannelMessage = - | SnapshotOrderbookChannelMessage - | UpdateOrderbookChannelMessage - | UnknownOrderbookChannelMessage; +export type OrdersChannelMessage = + | UpdateOrdersChannelMessage + | UnknownOrdersChannelMessage; -export enum OrderbookChannelMessageTypes { - Snapshot = 'snapshot', +export enum OrdersChannelMessageTypes { Update = 'update', Unknown = 'unknown', } -export interface SnapshotOrderbookChannelMessage { - type: OrderbookChannelMessageTypes.Snapshot; - requestId: number; - payload: OrderbookResponse; -} - -export interface UpdateOrderbookChannelMessage { - type: OrderbookChannelMessageTypes.Update; +export interface UpdateOrdersChannelMessage { + type: OrdersChannelMessageTypes.Update; requestId: number; - payload: SignedOrder; + payload: APIOrder; } -export interface UnknownOrderbookChannelMessage { - type: OrderbookChannelMessageTypes.Unknown; +export interface UnknownOrdersChannelMessage { + type: OrdersChannelMessageTypes.Unknown; requestId: number; payload: undefined; } @@ -83,25 +71,30 @@ export enum WebsocketClientEventType { ConnectFailed = 'connectFailed', } +export interface APIOrder { + order: SignedOrder; + metaData: object; +} + export interface AssetPairsRequestOpts { - tokenA?: string; - tokenB?: string; + assetDataA?: string; + assetDataB?: string; } export interface TokenPairsItem { - tokenA: TokenTradeInfo; - tokenB: TokenTradeInfo; + assetDataA: Asset; + assetDataB: Asset; } -export interface TokenTradeInfo { - address: string; +export interface Asset { + assetData: string; minAmount: BigNumber; maxAmount: BigNumber; precision: number; } export interface OrdersRequestOpts { - exchangeContractAddress?: string; + exchangeAddress?: string; tokenAddress?: string; makerTokenAddress?: string; takerTokenAddress?: string; @@ -112,35 +105,35 @@ export interface OrdersRequestOpts { } export interface OrderbookRequest { - baseTokenAddress: string; - quoteTokenAddress: string; + baseAssetData: string; + quoteAssetData: string; } export interface OrderbookResponse { - bids: SignedOrder[]; - asks: SignedOrder[]; + bids: PaginatedCollection<APIOrder>; + asks: PaginatedCollection<APIOrder>; } -export interface PaginatedCollectionResponse<T> { +export interface PaginatedCollection<T> { total: number; page: number; perPage: number; records: T[]; } -export interface FeesRequest { - exchangeContractAddress: string; +export interface OrderConfigRequest { + exchangeAddress: string; maker: string; taker: string; makerTokenAddress: string; takerTokenAddress: string; - makerTokenAmount: BigNumber; - takerTokenAmount: BigNumber; - expirationUnixTimestampSec: BigNumber; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + expirationTimeSeconds: BigNumber; salt: BigNumber; } -export interface FeesResponse { +export interface OrderConfigResponse { feeRecipient: string; makerFee: BigNumber; takerFee: BigNumber; 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', ]); }, diff --git a/packages/connect/src/ws_orderbook_channel.ts b/packages/connect/src/ws_orderbook_channel.ts index fa9f5e37f..d09fd375d 100644 --- a/packages/connect/src/ws_orderbook_channel.ts +++ b/packages/connect/src/ws_orderbook_channel.ts @@ -4,8 +4,8 @@ import * as WebSocket from 'websocket'; import { OrderbookChannel, OrderbookChannelHandler, - OrderbookChannelMessageTypes, OrderbookChannelSubscriptionOpts, + OrdersChannelMessageTypes, } from './types'; import { assert } from './utils/assert'; import { orderbookChannelMessageParser } from './utils/orderbook_channel_message_parser'; @@ -44,7 +44,7 @@ export class WebSocketOrderbookChannel implements OrderbookChannel { /** * Subscribe to orderbook snapshots and updates from the websocket * @param subscriptionOpts An OrderbookChannelSubscriptionOpts instance describing which - * token pair to subscribe to + * assetData pair to subscribe to */ public subscribe(subscriptionOpts: OrderbookChannelSubscriptionOpts): void { assert.isOrderbookChannelSubscriptionOpts('subscriptionOpts', subscriptionOpts); @@ -82,11 +82,11 @@ export class WebSocketOrderbookChannel implements OrderbookChannel { return; } switch (parserResult.type) { - case OrderbookChannelMessageTypes.Snapshot: { + case OrdersChannelMessageTypes.Snapshot: { this._handler.onSnapshot(this, subscriptionOpts, parserResult.payload); break; } - case OrderbookChannelMessageTypes.Update: { + case OrdersChannelMessageTypes.Update: { this._handler.onUpdate(this, subscriptionOpts, parserResult.payload); break; } diff --git a/packages/connect/test/fixtures/standard_relayer_api/fees.ts b/packages/connect/test/fixtures/standard_relayer_api/fees.ts index fecbaacff..7a526b491 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/fees.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/fees.ts @@ -1,8 +1,8 @@ import { BigNumber } from '@0xproject/utils'; -import { FeesResponse } from '../../../src/types'; +import { OrderConfigResponse } from '../../../src/types'; -export const feesResponse: FeesResponse = { +export const feesResponse: OrderConfigResponse = { feeRecipient: '0x323b5d4c32345ced77393b3530b1eed0f346429d', makerFee: new BigNumber('10000000000000000'), takerFee: new BigNumber('30000000000000000'), diff --git a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json index e84954b0d..23e4fb327 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json +++ b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json @@ -3,14 +3,14 @@ "taker": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32", "makerFee": "100000000000000", "takerFee": "200000000000000", - "makerTokenAmount": "10000000000000000", - "takerTokenAmount": "20000000000000000", + "makerAssetAmount": "10000000000000000", + "takerAssetAmount": "20000000000000000", "makerTokenAddress": "0x323b5d4c32345ced77393b3530b1eed0f346429d", "takerTokenAddress": "0xef7fff64389b814a946f3e92105513705ca6b990", "salt": "256", "feeRecipient": "0xb046140686d052fff581f63f8136cce132e857da", - "exchangeContractAddress": "0x12459c951127e0c374ff9105dda097662a027093", - "expirationUnixTimestampSec": "42", + "exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093", + "expirationTimeSeconds": "42", "ecSignature": { "v": 27, "r": "0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33", diff --git a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts index 5a03a2ff6..68446c83a 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts @@ -5,14 +5,14 @@ export const orderResponse = { taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerFee: new BigNumber('100000000000000'), takerFee: new BigNumber('200000000000000'), - makerTokenAmount: new BigNumber('10000000000000000'), - takerTokenAmount: new BigNumber('20000000000000000'), + makerAssetAmount: new BigNumber('10000000000000000'), + takerAssetAmount: new BigNumber('20000000000000000'), makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', salt: new BigNumber('256'), feeRecipient: '0xb046140686d052fff581f63f8136cce132e857da', - exchangeContractAddress: '0x12459c951127e0c374ff9105dda097662a027093', - expirationUnixTimestampSec: new BigNumber('42'), + exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', + expirationTimeSeconds: new BigNumber('42'), ecSignature: { v: 27, r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', diff --git a/packages/connect/test/fixtures/standard_relayer_api/orderbook.json b/packages/connect/test/fixtures/standard_relayer_api/orderbook.json index 825be34c2..2dec4b0fe 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/orderbook.json +++ b/packages/connect/test/fixtures/standard_relayer_api/orderbook.json @@ -5,14 +5,14 @@ "taker": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32", "makerFee": "100000000000000", "takerFee": "200000000000000", - "makerTokenAmount": "10000000000000000", - "takerTokenAmount": "20000000000000000", + "makerAssetAmount": "10000000000000000", + "takerAssetAmount": "20000000000000000", "makerTokenAddress": "0x323b5d4c32345ced77393b3530b1eed0f346429d", "takerTokenAddress": "0xef7fff64389b814a946f3e92105513705ca6b990", "salt": "256", "feeRecipient": "0xb046140686d052fff581f63f8136cce132e857da", - "exchangeContractAddress": "0x12459c951127e0c374ff9105dda097662a027093", - "expirationUnixTimestampSec": "42", + "exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093", + "expirationTimeSeconds": "42", "ecSignature": { "v": 27, "r": "0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33", @@ -26,14 +26,14 @@ "taker": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32", "makerFee": "100000000000000", "takerFee": "200000000000000", - "makerTokenAmount": "10000000000000000", - "takerTokenAmount": "20000000000000000", + "makerAssetAmount": "10000000000000000", + "takerAssetAmount": "20000000000000000", "makerTokenAddress": "0x323b5d4c32345ced77393b3530b1eed0f346429d", "takerTokenAddress": "0xef7fff64389b814a946f3e92105513705ca6b990", "salt": "256", "feeRecipient": "0xb046140686d052fff581f63f8136cce132e857da", - "exchangeContractAddress": "0x12459c951127e0c374ff9105dda097662a027093", - "expirationUnixTimestampSec": "42", + "exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093", + "expirationTimeSeconds": "42", "ecSignature": { "v": 27, "r": "0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33", diff --git a/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts b/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts index 6684ac2e5..9f80988ce 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts @@ -7,14 +7,14 @@ export const orderbookResponse = { taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerFee: new BigNumber('100000000000000'), takerFee: new BigNumber('200000000000000'), - makerTokenAmount: new BigNumber('10000000000000000'), - takerTokenAmount: new BigNumber('20000000000000000'), + makerAssetAmount: new BigNumber('10000000000000000'), + takerAssetAmount: new BigNumber('20000000000000000'), makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', salt: new BigNumber('256'), feeRecipient: '0xb046140686d052fff581f63f8136cce132e857da', - exchangeContractAddress: '0x12459c951127e0c374ff9105dda097662a027093', - expirationUnixTimestampSec: new BigNumber('42'), + exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', + expirationTimeSeconds: new BigNumber('42'), ecSignature: { v: 27, r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', @@ -28,14 +28,14 @@ export const orderbookResponse = { taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerFee: new BigNumber('100000000000000'), takerFee: new BigNumber('200000000000000'), - makerTokenAmount: new BigNumber('10000000000000000'), - takerTokenAmount: new BigNumber('20000000000000000'), + makerAssetAmount: new BigNumber('10000000000000000'), + takerAssetAmount: new BigNumber('20000000000000000'), makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', salt: new BigNumber('256'), feeRecipient: '0xb046140686d052fff581f63f8136cce132e857da', - exchangeContractAddress: '0x12459c951127e0c374ff9105dda097662a027093', - expirationUnixTimestampSec: new BigNumber('42'), + exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', + expirationTimeSeconds: new BigNumber('42'), ecSignature: { v: 27, r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', diff --git a/packages/connect/test/fixtures/standard_relayer_api/orders.json b/packages/connect/test/fixtures/standard_relayer_api/orders.json index cfa780dc4..929dde4a8 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/orders.json +++ b/packages/connect/test/fixtures/standard_relayer_api/orders.json @@ -4,14 +4,14 @@ "taker": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32", "makerFee": "100000000000000", "takerFee": "200000000000000", - "makerTokenAmount": "10000000000000000", - "takerTokenAmount": "20000000000000000", + "makerAssetAmount": "10000000000000000", + "takerAssetAmount": "20000000000000000", "makerTokenAddress": "0x323b5d4c32345ced77393b3530b1eed0f346429d", "takerTokenAddress": "0xef7fff64389b814a946f3e92105513705ca6b990", "salt": "256", "feeRecipient": "0x9e56625509c2f60af937f23b7b532600390e8c8b", - "exchangeContractAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b", - "expirationUnixTimestampSec": "42", + "exchangeAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b", + "expirationTimeSeconds": "42", "ecSignature": { "v": 27, "r": "0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33", diff --git a/packages/connect/test/fixtures/standard_relayer_api/orders.ts b/packages/connect/test/fixtures/standard_relayer_api/orders.ts index 5044777bd..6d32fd3f3 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/orders.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/orders.ts @@ -6,14 +6,14 @@ export const ordersResponse = [ taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerFee: new BigNumber('100000000000000'), takerFee: new BigNumber('200000000000000'), - makerTokenAmount: new BigNumber('10000000000000000'), - takerTokenAmount: new BigNumber('20000000000000000'), + makerAssetAmount: new BigNumber('10000000000000000'), + takerAssetAmount: new BigNumber('20000000000000000'), makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', salt: new BigNumber('256'), feeRecipient: '0x9e56625509c2f60af937f23b7b532600390e8c8b', - exchangeContractAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b', - expirationUnixTimestampSec: new BigNumber('42'), + exchangeAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b', + expirationTimeSeconds: new BigNumber('42'), ecSignature: { v: 27, r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', diff --git a/packages/connect/test/fixtures/standard_relayer_api/snapshot_orderbook_channel_message.ts b/packages/connect/test/fixtures/standard_relayer_api/snapshot_orderbook_channel_message.ts deleted file mode 100644 index 1d7e67055..000000000 --- a/packages/connect/test/fixtures/standard_relayer_api/snapshot_orderbook_channel_message.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as orderbookJSON from './orderbook.json'; - -const orderbookJsonString = JSON.stringify(orderbookJSON); - -export const snapshotOrderbookChannelMessage = `{ - "type": "snapshot", - "channel": "orderbook", - "requestId": 1, - "payload": ${orderbookJsonString} -}`; - -export const malformedSnapshotOrderbookChannelMessage = `{ - "type": "snapshot", - "channel": "orderbook", - "requestId": 1, - "payload": {} -}`; diff --git a/packages/connect/test/fixtures/standard_relayer_api/token_pairs.json b/packages/connect/test/fixtures/standard_relayer_api/token_pairs.json index 90f57a974..2d9610e3d 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/token_pairs.json +++ b/packages/connect/test/fixtures/standard_relayer_api/token_pairs.json @@ -1,12 +1,12 @@ [ { - "tokenA": { + "assetDataA": { "address": "0x323b5d4c32345ced77393b3530b1eed0f346429d", "minAmount": "0", "maxAmount": "10000000000000000000", "precision": 5 }, - "tokenB": { + "assetDataB": { "address": "0xef7fff64389b814a946f3e92105513705ca6b990", "minAmount": "0", "maxAmount": "50000000000000000000", diff --git a/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts b/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts index f48b1e877..1225ac4fc 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts @@ -2,15 +2,15 @@ import { BigNumber } from '@0xproject/utils'; import { TokenPairsItem } from '../../../src/types'; -export const tokenPairsResponse: TokenPairsItem[] = [ +export const assetDataPairsResponse: TokenPairsItem[] = [ { - tokenA: { + assetDataA: { address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', minAmount: new BigNumber(0), maxAmount: new BigNumber('10000000000000000000'), precision: 5, }, - tokenB: { + assetDataB: { address: '0xef7fff64389b814a946f3e92105513705ca6b990', minAmount: new BigNumber(0), maxAmount: new BigNumber('50000000000000000000'), diff --git a/packages/connect/test/fixtures/standard_relayer_api/unknown_orderbook_channel_message.ts b/packages/connect/test/fixtures/standard_relayer_api/unknown_orderbook_channel_message.ts index cbedff60e..c0e924a4b 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/unknown_orderbook_channel_message.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/unknown_orderbook_channel_message.ts @@ -2,7 +2,7 @@ import * as orderResponseJSON from './order/0xabc67323774bdbd24d94f977fa9ac94a50 const orderJSONString = JSON.stringify(orderResponseJSON); -export const unknownOrderbookChannelMessage = `{ +export const unknownOrdersChannelMessage = `{ "type": "superGoodUpdate", "channel": "orderbook", "requestId": 1, diff --git a/packages/connect/test/fixtures/standard_relayer_api/update_orderbook_channel_message.ts b/packages/connect/test/fixtures/standard_relayer_api/update_orderbook_channel_message.ts index 0e2c7523b..daab20368 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/update_orderbook_channel_message.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/update_orderbook_channel_message.ts @@ -2,14 +2,14 @@ import * as orderResponseJSON from './order/0xabc67323774bdbd24d94f977fa9ac94a50 const orderJSONString = JSON.stringify(orderResponseJSON); -export const updateOrderbookChannelMessage = `{ +export const updateOrdersChannelMessage = `{ "type": "update", "channel": "orderbook", "requestId": 1, "payload": ${orderJSONString} }`; -export const malformedUpdateOrderbookChannelMessage = `{ +export const malformedUpdateOrdersChannelMessage = `{ "type": "update", "channel": "orderbook", "requestId": 1, diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts index 38327b090..ea5717327 100644 --- a/packages/connect/test/http_client_test.ts +++ b/packages/connect/test/http_client_test.ts @@ -15,8 +15,8 @@ import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook'; import * as orderbookJSON from './fixtures/standard_relayer_api/orderbook.json'; import { ordersResponse } from './fixtures/standard_relayer_api/orders'; import * as ordersResponseJSON from './fixtures/standard_relayer_api/orders.json'; -import { tokenPairsResponse } from './fixtures/standard_relayer_api/token_pairs'; -import * as tokenPairsResponseJSON from './fixtures/standard_relayer_api/token_pairs.json'; +import { assetDataPairsResponse } from './fixtures/standard_relayer_api/assetData_pairs'; +import * as assetDataPairsResponseJSON from './fixtures/standard_relayer_api/assetData_pairs.json'; chai.config.includeStack = true; chai.use(dirtyChai); @@ -39,24 +39,24 @@ describe('HttpClient', () => { }); }); describe('#getAssetPairsAsync', () => { - const url = `${relayUrl}/token_pairs`; - it('gets token pairs with default options when none are provided', async () => { + const url = `${relayUrl}/assetData_pairs`; + it('gets assetData pairs with default options when none are provided', async () => { const urlWithQuery = `${url}?page=1&per_page=100`; - fetchMock.get(urlWithQuery, tokenPairsResponseJSON); - const tokenPairs = await relayerClient.getAssetPairsAsync(); - expect(tokenPairs).to.be.deep.equal(tokenPairsResponse); + fetchMock.get(urlWithQuery, assetDataPairsResponseJSON); + const assetDataPairs = await relayerClient.getAssetPairsAsync(); + expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse); }); - it('gets token pairs with specified request options', async () => { - const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d'; + it('gets assetData pairs with specified request options', async () => { + const assetDataAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d'; const AssetPairsRequestOpts = { - tokenA: tokenAddress, + assetDataA: assetDataAddress, page: 3, perPage: 50, }; - const urlWithQuery = `${url}?page=3&per_page=50&tokenA=${tokenAddress}`; - fetchMock.get(urlWithQuery, tokenPairsResponseJSON); - const tokenPairs = await relayerClient.getAssetPairsAsync(AssetPairsRequestOpts); - expect(tokenPairs).to.be.deep.equal(tokenPairsResponse); + const urlWithQuery = `${url}?page=3&per_page=50&assetDataA=${assetDataAddress}`; + fetchMock.get(urlWithQuery, assetDataPairsResponseJSON); + const assetDataPairs = await relayerClient.getAssetPairsAsync(AssetPairsRequestOpts); + expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse); }); it('throws an error for invalid JSON response', async () => { fetchMock.get(url, { test: 'dummy' }); @@ -72,13 +72,13 @@ describe('HttpClient', () => { expect(orders).to.be.deep.equal(ordersResponse); }); it('gets orders with specified request options', async () => { - const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d'; + const assetDataAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d'; const ordersRequest = { - tokenAddress, + assetDataAddress, page: 3, perPage: 50, }; - const urlWithQuery = `${url}?page=3&per_page=50&tokenAddress=${tokenAddress}`; + const urlWithQuery = `${url}?page=3&per_page=50&assetDataAddress=${assetDataAddress}`; fetchMock.get(urlWithQuery, ordersResponseJSON); const orders = await relayerClient.getOrdersAsync(ordersRequest); expect(orders).to.be.deep.equal(ordersResponse); @@ -103,22 +103,22 @@ describe('HttpClient', () => { }); describe('#getOrderBookAsync', () => { const request = { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', + baseAssetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteAssetData: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', }; const url = `${relayUrl}/orderbook`; it('gets orderbook with default page options when none are provided', async () => { - const urlWithQuery = `${url}?baseTokenAddress=${ - request.baseTokenAddress - }&page=1&per_page=100"eTokenAddress=${request.quoteTokenAddress}`; + const urlWithQuery = `${url}?baseAssetData=${ + request.baseAssetData + }&page=1&per_page=100"eAssetData=${request.quoteAssetData}`; fetchMock.get(urlWithQuery, orderbookJSON); const orderbook = await relayerClient.getOrderbookAsync(request); expect(orderbook).to.be.deep.equal(orderbookResponse); }); it('gets orderbook with specified page options', async () => { - const urlWithQuery = `${url}?baseTokenAddress=${ - request.baseTokenAddress - }&page=3&per_page=50"eTokenAddress=${request.quoteTokenAddress}`; + const urlWithQuery = `${url}?baseAssetData=${ + request.baseAssetData + }&page=3&per_page=50"eAssetData=${request.quoteAssetData}`; fetchMock.get(urlWithQuery, orderbookJSON); const pagedRequestOptions = { page: 3, @@ -134,15 +134,15 @@ describe('HttpClient', () => { }); describe('#getOrderConfigAsync', () => { const request = { - exchangeContractAddress: '0x12459c951127e0c374ff9105dda097662a027093', + exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', maker: '0x9e56625509c2f60af937f23b7b532600390e8c8b', taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: new BigNumber('10000000000000000000'), - takerTokenAmount: new BigNumber('30000000000000000000'), + makerAssetAmount: new BigNumber('10000000000000000000'), + takerAssetAmount: new BigNumber('30000000000000000000'), salt: new BigNumber('256'), - expirationUnixTimestampSec: new BigNumber('42'), + expirationTimeSeconds: new BigNumber('42'), }; const url = `${relayUrl}/fees`; it('gets fees', async () => { @@ -152,15 +152,15 @@ describe('HttpClient', () => { }); it('does not mutate input', async () => { fetchMock.post(url, feesResponseJSON); - const makerTokenAmountBefore = new BigNumber(request.makerTokenAmount); - const takerTokenAmountBefore = new BigNumber(request.takerTokenAmount); + const makerAssetAmountBefore = new BigNumber(request.makerAssetAmount); + const takerAssetAmountBefore = new BigNumber(request.takerAssetAmount); const saltBefore = new BigNumber(request.salt); - const expirationUnixTimestampSecBefore = new BigNumber(request.expirationUnixTimestampSec); + const expirationTimeSecondsBefore = new BigNumber(request.expirationTimeSeconds); await relayerClient.getOrderConfigAsync(request); - expect(makerTokenAmountBefore).to.be.deep.equal(request.makerTokenAmount); - expect(takerTokenAmountBefore).to.be.deep.equal(request.takerTokenAmount); + expect(makerAssetAmountBefore).to.be.deep.equal(request.makerAssetAmount); + expect(takerAssetAmountBefore).to.be.deep.equal(request.takerAssetAmount); expect(saltBefore).to.be.deep.equal(request.salt); - expect(expirationUnixTimestampSecBefore).to.be.deep.equal(request.expirationUnixTimestampSec); + expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds); }); it('throws an error for invalid JSON response', async () => { fetchMock.post(url, { test: 'dummy' }); diff --git a/packages/connect/test/orderbook_channel_message_parsers_test.ts b/packages/connect/test/orderbook_channel_message_parsers_test.ts index 3e1f44384..ce881e627 100644 --- a/packages/connect/test/orderbook_channel_message_parsers_test.ts +++ b/packages/connect/test/orderbook_channel_message_parsers_test.ts @@ -7,13 +7,13 @@ import { orderbookChannelMessageParser } from '../src/utils/orderbook_channel_me import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f'; import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook'; import { - malformedSnapshotOrderbookChannelMessage, - snapshotOrderbookChannelMessage, + malformedSnapshotOrdersChannelMessage, + snapshotOrdersChannelMessage, } from './fixtures/standard_relayer_api/snapshot_orderbook_channel_message'; -import { unknownOrderbookChannelMessage } from './fixtures/standard_relayer_api/unknown_orderbook_channel_message'; +import { unknownOrdersChannelMessage } from './fixtures/standard_relayer_api/unknown_orderbook_channel_message'; import { - malformedUpdateOrderbookChannelMessage, - updateOrderbookChannelMessage, + malformedUpdateOrdersChannelMessage, + updateOrdersChannelMessage, } from './fixtures/standard_relayer_api/update_orderbook_channel_message'; chai.config.includeStack = true; @@ -23,17 +23,17 @@ const expect = chai.expect; describe('orderbookChannelMessageParser', () => { describe('#parser', () => { it('parses snapshot messages', () => { - const snapshotMessage = orderbookChannelMessageParser.parse(snapshotOrderbookChannelMessage); + const snapshotMessage = orderbookChannelMessageParser.parse(snapshotOrdersChannelMessage); expect(snapshotMessage.type).to.be.equal('snapshot'); expect(snapshotMessage.payload).to.be.deep.equal(orderbookResponse); }); it('parses update messages', () => { - const updateMessage = orderbookChannelMessageParser.parse(updateOrderbookChannelMessage); + const updateMessage = orderbookChannelMessageParser.parse(updateOrdersChannelMessage); expect(updateMessage.type).to.be.equal('update'); expect(updateMessage.payload).to.be.deep.equal(orderResponse); }); it('returns unknown message for messages with unsupported types', () => { - const unknownMessage = orderbookChannelMessageParser.parse(unknownOrderbookChannelMessage); + const unknownMessage = orderbookChannelMessageParser.parse(unknownOrdersChannelMessage); expect(unknownMessage.type).to.be.equal('unknown'); expect(unknownMessage.payload).to.be.undefined(); }); @@ -57,20 +57,20 @@ 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(malformedSnapshotOrdersChannelMessage); // tslint:disable-next-line:max-line-length 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(malformedUpdateOrdersChannelMessage); expect(badCall).throws(/^Expected message to conform to schema/); }); it('throws when input message is not valid JSON', () => { const nonJsonString = 'h93b{sdfs9fsd f'; const badCall = () => orderbookChannelMessageParser.parse(nonJsonString); - expect(badCall).throws('Unexpected token h in JSON at position 0'); + expect(badCall).throws('Unexpected assetData h in JSON at position 0'); }); }); }); diff --git a/packages/connect/test/ws_orderbook_channel_test.ts b/packages/connect/test/ws_orderbook_channel_test.ts index 5a63cbdcc..b5682af36 100644 --- a/packages/connect/test/ws_orderbook_channel_test.ts +++ b/packages/connect/test/ws_orderbook_channel_test.ts @@ -32,8 +32,8 @@ describe('WebSocketOrderbookChannel', () => { Sinon.stub(openClient, 'send').callsFake(_.noop.bind(_)); const openOrderbookChannel = new WebSocketOrderbookChannel(openClient, emptyOrderbookChannelHandler); const subscriptionOpts = { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', + baseAssetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteAssetData: '0xef7fff64389b814a946f3e92105513705ca6b990', snapshot: true, limit: 100, }; @@ -41,7 +41,7 @@ describe('WebSocketOrderbookChannel', () => { it('throws when subscriptionOpts does not conform to schema', () => { const badSubscribeCall = openOrderbookChannel.subscribe.bind(openOrderbookChannel, {}); expect(badSubscribeCall).throws( - 'Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseTokenAddress", instance requires property "quoteTokenAddress"', + 'Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseAssetData", instance requires property "quoteAssetData"', ); }); it('does not throw when inputs are of correct types', () => { |