aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-08-18 04:58:55 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-08-18 04:58:55 +0800
commitf2d1d953553adfa59f0a39bf2cf98817fae0a4ff (patch)
tree572db33638e055725132756d24a866ec1a22e1d9 /packages/connect
parent48ec78d3aaa5dcef8544d17f26ef8ea8b31661e5 (diff)
downloaddexon-sol-tools-f2d1d953553adfa59f0a39bf2cf98817fae0a4ff.tar
dexon-sol-tools-f2d1d953553adfa59f0a39bf2cf98817fae0a4ff.tar.gz
dexon-sol-tools-f2d1d953553adfa59f0a39bf2cf98817fae0a4ff.tar.bz2
dexon-sol-tools-f2d1d953553adfa59f0a39bf2cf98817fae0a4ff.tar.lz
dexon-sol-tools-f2d1d953553adfa59f0a39bf2cf98817fae0a4ff.tar.xz
dexon-sol-tools-f2d1d953553adfa59f0a39bf2cf98817fae0a4ff.tar.zst
dexon-sol-tools-f2d1d953553adfa59f0a39bf2cf98817fae0a4ff.zip
Remove default query parameters
Diffstat (limited to 'packages/connect')
-rw-r--r--packages/connect/src/http_client.ts21
-rw-r--r--packages/connect/src/schemas/request_opts_schema.ts7
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json2
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts2
-rw-r--r--packages/connect/test/http_client_test.ts31
5 files changed, 34 insertions, 29 deletions
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts
index 8f7825253..4fdcfc338 100644
--- a/packages/connect/src/http_client.ts
+++ b/packages/connect/src/http_client.ts
@@ -26,13 +26,6 @@ import {
import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
const TRAILING_SLASHES_REGEX = /\/+$/;
-const DEFAULT_PAGED_REQUEST_OPTS: PagedRequestOpts = {
- page: 1,
- perPage: 100,
-};
-const DEFAULT_REQUEST_OPTS: RequestOpts = {
- networkId: 1,
-};
/**
* This class includes all the functionality related to interacting with a set of HTTP endpoints
@@ -73,7 +66,7 @@ export class HttpClient implements Client {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
}
const httpRequestOpts = {
- params: _.defaults({}, requestOpts, DEFAULT_REQUEST_OPTS, DEFAULT_PAGED_REQUEST_OPTS),
+ params: requestOpts,
};
const responseJson = await this._requestAsync('/asset_pairs', HttpRequestType.Get, httpRequestOpts);
const assetDataPairs = relayerResponseJsonParsers.parseAssetDataPairsJson(responseJson);
@@ -91,7 +84,7 @@ export class HttpClient implements Client {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
}
const httpRequestOpts = {
- params: _.defaults({}, requestOpts, DEFAULT_REQUEST_OPTS, DEFAULT_PAGED_REQUEST_OPTS),
+ params: requestOpts,
};
const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, httpRequestOpts);
const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
@@ -108,7 +101,7 @@ export class HttpClient implements Client {
}
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const httpRequestOpts = {
- params: _.defaults({}, requestOpts, DEFAULT_REQUEST_OPTS),
+ params: requestOpts,
};
const responseJson = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get, httpRequestOpts);
const order = relayerResponseJsonParsers.parseAPIOrderJson(responseJson);
@@ -130,7 +123,7 @@ export class HttpClient implements Client {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
}
const httpRequestOpts = {
- params: _.defaults({}, request, requestOpts, DEFAULT_REQUEST_OPTS, DEFAULT_PAGED_REQUEST_OPTS),
+ params: _.defaults({}, request, requestOpts),
};
const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, httpRequestOpts);
const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
@@ -147,7 +140,7 @@ export class HttpClient implements Client {
}
assert.doesConformToSchema('request', request, clientSchemas.orderConfigRequestSchema);
const httpRequestOpts = {
- params: _.defaults({}, requestOpts, DEFAULT_REQUEST_OPTS),
+ params: requestOpts,
payload: request,
};
const responseJson = await this._requestAsync('/order_config', HttpRequestType.Post, httpRequestOpts);
@@ -163,7 +156,7 @@ export class HttpClient implements Client {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
}
const httpRequestOpts = {
- params: _.defaults({}, requestOpts, DEFAULT_REQUEST_OPTS, DEFAULT_PAGED_REQUEST_OPTS),
+ params: requestOpts,
};
const feeRecipients = await this._requestAsync('/fee_recipients', HttpRequestType.Get, httpRequestOpts);
assert.doesConformToSchema('feeRecipients', feeRecipients, schemas.relayerApiFeeRecipientsResponseSchema);
@@ -176,7 +169,7 @@ export class HttpClient implements Client {
public async submitOrderAsync(signedOrder: SignedOrder, requestOpts?: RequestOpts): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
const httpRequestOpts = {
- params: _.defaults({}, requestOpts, DEFAULT_REQUEST_OPTS),
+ params: requestOpts,
payload: signedOrder,
};
await this._requestAsync('/order', HttpRequestType.Post, httpRequestOpts);
diff --git a/packages/connect/src/schemas/request_opts_schema.ts b/packages/connect/src/schemas/request_opts_schema.ts
new file mode 100644
index 000000000..a51e98069
--- /dev/null
+++ b/packages/connect/src/schemas/request_opts_schema.ts
@@ -0,0 +1,7 @@
+export const requestOptsSchema = {
+ id: '/RequestOpts',
+ type: 'object',
+ properties: {
+ networkId: { type: 'number' },
+ },
+};
diff --git a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json
index 1ea3dcc0e..47ce42412 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json
+++ b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json
@@ -3,7 +3,7 @@
"page": 1,
"perPage": 10,
"records": [
- "0x6eC92694ea172ebC430C30fa31De87620967A082",
+ "0x6ec92694ea172ebc430c30fa31de87620967a082",
"0x9e56625509c2f60af937f23b7b532600390e8c8b",
"0xa2b31dacf30a9c50ca473337c01d8a201ae33e32"
]
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 a95bd25dd..e17ffe7a8 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
+++ b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
@@ -5,7 +5,7 @@ export const feeRecipientsResponse: FeeRecipientsResponse = {
page: 1,
perPage: 10,
records: [
- '0x6eC92694ea172ebC430C30fa31De87620967A082',
+ '0x6ec92694ea172ebc430c30fa31de87620967a082',
'0x9e56625509c2f60af937f23b7b532600390e8c8b',
'0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
],
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index cdff00a61..1c40cb10f 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -43,8 +43,7 @@ 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&perPage=100`;
- fetchMock.get(urlWithQuery, assetDataPairsResponseJSON);
+ fetchMock.get(url, assetDataPairsResponseJSON);
const assetDataPairs = await relayerClient.getAssetPairsAsync();
expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse);
});
@@ -54,8 +53,9 @@ describe('HttpClient', () => {
assetDataA: assetData,
page: 3,
perPage: 50,
+ networkdId: 42,
};
- const urlWithQuery = `${url}?assetDataA=${assetData}&page=3&perPage=50`;
+ const urlWithQuery = `${url}?assetDataA=${assetData}&networkdId=42&page=3&perPage=50`;
fetchMock.get(urlWithQuery, assetDataPairsResponseJSON);
const assetDataPairs = await relayerClient.getAssetPairsAsync(assetPairsRequestOpts);
expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse);
@@ -68,8 +68,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&perPage=100`;
- fetchMock.get(urlWithQuery, ordersResponseJSON);
+ fetchMock.get(url, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync();
expect(orders).to.be.deep.equal(ordersResponse);
});
@@ -79,8 +78,9 @@ describe('HttpClient', () => {
assetDataAddress,
page: 3,
perPage: 50,
+ networkdId: 42,
};
- const urlWithQuery = `${url}?assetDataAddress=${assetDataAddress}&page=3&perPage=50`;
+ const urlWithQuery = `${url}?assetDataAddress=${assetDataAddress}&networkdId=42&page=3&perPage=50`;
fetchMock.get(urlWithQuery, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync(ordersRequest);
expect(orders).to.be.deep.equal(ordersResponse);
@@ -112,7 +112,7 @@ describe('HttpClient', () => {
it('gets orderbook with default page options when none are provided', async () => {
const urlWithQuery = `${url}?baseAssetData=${
request.baseAssetData
- }&page=1&perPage=100&quoteAssetData=${request.quoteAssetData}`;
+ }&quoteAssetData=${request.quoteAssetData}`;
fetchMock.get(urlWithQuery, orderbookJSON);
const orderbook = await relayerClient.getOrderbookAsync(request);
expect(orderbook).to.be.deep.equal(orderbookResponse);
@@ -120,11 +120,12 @@ describe('HttpClient', () => {
it('gets orderbook with specified page options', async () => {
const urlWithQuery = `${url}?baseAssetData=${
request.baseAssetData
- }&page=3&perPage=50&quoteAssetData=${request.quoteAssetData}`;
+ }&networkId=42&page=3&perPage=50&quoteAssetData=${request.quoteAssetData}`;
fetchMock.get(urlWithQuery, orderbookJSON);
const pagedRequestOptions = {
page: 3,
perPage: 50,
+ networkId: 42,
};
const orderbook = await relayerClient.getOrderbookAsync(request, pagedRequestOptions);
expect(orderbook).to.be.deep.equal(orderbookResponse);
@@ -146,7 +147,7 @@ describe('HttpClient', () => {
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
};
const url = `${relayUrl}/order_config`;
- it('gets fees', async () => {
+ it('gets order config', async () => {
fetchMock.post(url, orderConfigResponseJSON);
const fees = await relayerClient.getOrderConfigAsync(request);
expect(fees).to.be.deep.equal(orderConfigResponse);
@@ -168,17 +169,18 @@ describe('HttpClient', () => {
});
describe('#getFeeRecipientsAsync', () => {
const url = `${relayUrl}/fee_recipients`;
- it('gets orderbook with default page options when none are provided', async () => {
+ it('gets fee recipients with default page options when none are provided', async () => {
fetchMock.get(url, feeRecipientsResponseJSON);
const feeRecipients = await relayerClient.getFeeRecipientsAsync();
expect(feeRecipients).to.be.deep.equal(feeRecipientsResponse);
});
- it('gets orderbook with specified page options', async () => {
- const urlWithQuery = `${url}?&page=3&perPage=50`;
- fetchMock.get(url, feeRecipientsResponseJSON);
+ it('gets fee reciipient with specified page options', async () => {
+ const urlWithQuery = `${url}?networkId=42&page=3&perPage=50`;
+ fetchMock.get(urlWithQuery, feeRecipientsResponseJSON);
const pagedRequestOptions = {
page: 3,
perPage: 50,
+ networkId: 42,
};
const feeRecipients = await relayerClient.getFeeRecipientsAsync(pagedRequestOptions);
expect(feeRecipients).to.be.deep.equal(feeRecipientsResponse);
@@ -189,3 +191,6 @@ describe('HttpClient', () => {
});
});
});
+
+// https://example.com/fee_recipients?networkId=42&page=3&perPage=50
+// https://example.com/fee_recipients?networkId=42&page=3&perPage=50 \ No newline at end of file