aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/connect/package.json2
-rw-r--r--packages/connect/src/http_client.ts2
-rw-r--r--packages/connect/src/schemas/asset_pairs_request_opts_schema.ts4
-rw-r--r--packages/connect/src/utils/relayer_response_json_parsers.ts10
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts1
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json1
-rw-r--r--packages/connect/test/http_client_test.ts22
7 files changed, 20 insertions, 22 deletions
diff --git a/packages/connect/package.json b/packages/connect/package.json
index 336cb85fc..de262a5c2 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -51,7 +51,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": {
- "@0xproject/assert": "^0.2.14",
+ "@0xproject/assert": "^1.0.5",
"@0xproject/json-schemas": "^1.0.1-rc.4",
"@0xproject/types": "^1.0.1-rc.4",
"@0xproject/typescript-typings": "^1.0.4",
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts
index e8b82f0b2..35d7ee77e 100644
--- a/packages/connect/src/http_client.ts
+++ b/packages/connect/src/http_client.ts
@@ -70,7 +70,7 @@ export class HttpClient implements Client {
const httpRequestOpts = {
params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
};
- const responseJson = await this._requestAsync('/assetData_pairs', HttpRequestType.Get, httpRequestOpts);
+ const responseJson = await this._requestAsync('/asset_pairs', HttpRequestType.Get, httpRequestOpts);
const assetDataPairs = relayerResponseJsonParsers.parseAssetDataPairsJson(responseJson);
return assetDataPairs;
}
diff --git a/packages/connect/src/schemas/asset_pairs_request_opts_schema.ts b/packages/connect/src/schemas/asset_pairs_request_opts_schema.ts
index f224503cc..a9e3942a4 100644
--- a/packages/connect/src/schemas/asset_pairs_request_opts_schema.ts
+++ b/packages/connect/src/schemas/asset_pairs_request_opts_schema.ts
@@ -2,7 +2,7 @@ export const assetPairsRequestOptsSchema = {
id: '/AssetPairsRequestOpts',
type: 'object',
properties: {
- assetDataA: { $ref: '/Address' },
- assetDataB: { $ref: '/Address' },
+ assetDataA: { $ref: '/hexSchema' },
+ assetDataB: { $ref: '/hexSchema' },
},
};
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']);
},
};
diff --git a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
index 9da2703df..a95bd25dd 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
+++ b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
@@ -1,4 +1,3 @@
-
import { FeeRecipientsResponse } from '../../../src/types';
export const feeRecipientsResponse: FeeRecipientsResponse = {
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 4a2ab6914..8d2cdd8ed 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json
+++ b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json
@@ -17,4 +17,3 @@
},
"metaData": {}
}
-
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index fc5d01706..9cdcde71e 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -26,7 +26,7 @@ const expect = chai.expect;
describe('HttpClient', () => {
const relayUrl = 'https://example.com';
const relayerClient = new HttpClient(relayUrl);
- afterEach(() => {
+ beforeEach(() => {
fetchMock.restore();
});
describe('#constructor', () => {
@@ -41,21 +41,21 @@ describe('HttpClient', () => {
describe('#getAssetPairsAsync', () => {
const url = `${relayUrl}/asset_pairs`;
it('gets assetData pairs with default options when none are provided', async () => {
- const urlWithQuery = `${url}?page=1&per_page=100`;
+ const urlWithQuery = `${url}?page=1&perPage=100`;
fetchMock.get(urlWithQuery, assetDataPairsResponseJSON);
const assetDataPairs = await relayerClient.getAssetPairsAsync();
expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse);
});
it('gets assetData pairs with specified request options', async () => {
- const assetDataAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
- const AssetPairsRequestOpts = {
- assetDataA: assetDataAddress,
+ const assetData = '0xf47261b04c32345ced77393b3530b1eed0f346429d';
+ const assetPairsRequestOpts = {
+ assetDataA: assetData,
page: 3,
perPage: 50,
};
- const urlWithQuery = `${url}?page=3&per_page=50&assetDataA=${assetDataAddress}`;
+ const urlWithQuery = `${url}?assetDataA=${assetData}&page=3&perPage=50`;
fetchMock.get(urlWithQuery, assetDataPairsResponseJSON);
- const assetDataPairs = await relayerClient.getAssetPairsAsync(AssetPairsRequestOpts);
+ const assetDataPairs = await relayerClient.getAssetPairsAsync(assetPairsRequestOpts);
expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse);
});
it('throws an error for invalid JSON response', async () => {
@@ -66,7 +66,7 @@ describe('HttpClient', () => {
describe('#getOrdersAsync', () => {
const url = `${relayUrl}/orders`;
it('gets orders with default options when none are provided', async () => {
- const urlWithQuery = `${url}?page=1&per_page=100`;
+ const urlWithQuery = `${url}?page=1&perPage=100`;
fetchMock.get(urlWithQuery, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync();
expect(orders).to.be.deep.equal(ordersResponse);
@@ -78,7 +78,7 @@ describe('HttpClient', () => {
page: 3,
perPage: 50,
};
- const urlWithQuery = `${url}?page=3&per_page=50&assetDataAddress=${assetDataAddress}`;
+ const urlWithQuery = `${url}?page=3&perPage=50&assetDataAddress=${assetDataAddress}`;
fetchMock.get(urlWithQuery, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync(ordersRequest);
expect(orders).to.be.deep.equal(ordersResponse);
@@ -110,7 +110,7 @@ describe('HttpClient', () => {
it('gets orderbook with default page options when none are provided', async () => {
const urlWithQuery = `${url}?baseAssetData=${
request.baseAssetData
- }&page=1&per_page=100&quoteAssetData=${request.quoteAssetData}`;
+ }&page=1&perPage=100&quoteAssetData=${request.quoteAssetData}`;
fetchMock.get(urlWithQuery, orderbookJSON);
const orderbook = await relayerClient.getOrderbookAsync(request);
expect(orderbook).to.be.deep.equal(orderbookResponse);
@@ -118,7 +118,7 @@ describe('HttpClient', () => {
it('gets orderbook with specified page options', async () => {
const urlWithQuery = `${url}?baseAssetData=${
request.baseAssetData
- }&page=3&per_page=50&quoteAssetData=${request.quoteAssetData}`;
+ }&page=3&perPage=50&quoteAssetData=${request.quoteAssetData}`;
fetchMock.get(urlWithQuery, orderbookJSON);
const pagedRequestOptions = {
page: 3,