aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect
diff options
context:
space:
mode:
Diffstat (limited to 'packages/connect')
-rw-r--r--packages/connect/src/utils/relayer_response_json_parsers.ts2
-rw-r--r--packages/connect/src/utils/type_converters.ts7
-rw-r--r--packages/connect/test/http_client_test.ts2
3 files changed, 8 insertions, 3 deletions
diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts
index 37099384f..2b2e1efe7 100644
--- a/packages/connect/src/utils/relayer_response_json_parsers.ts
+++ b/packages/connect/src/utils/relayer_response_json_parsers.ts
@@ -26,7 +26,7 @@ export const relayerResponseJsonParsers = {
},
parseAPIOrderJson(json: any): APIOrder {
assert.doesConformToSchema('relayerApiOrder', json, schemas.relayerApiOrderSchema);
- return typeConverters.convertOrderStringFieldsToBigNumber(json);
+ return typeConverters.convertAPIOrderStringFieldsToBigNumber(json);
},
parseOrderbookResponseJson(json: any): OrderbookResponse {
assert.doesConformToSchema('orderBookResponse', json, schemas.relayerApiOrderbookResponseSchema);
diff --git a/packages/connect/src/utils/type_converters.ts b/packages/connect/src/utils/type_converters.ts
index c28cba0e1..4b211a0b2 100644
--- a/packages/connect/src/utils/type_converters.ts
+++ b/packages/connect/src/utils/type_converters.ts
@@ -36,7 +36,12 @@ export const typeConverters = {
convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any {
const result = _.assign({}, obj);
_.each(fields, field => {
- _.update(result, field, (value: string) => new BigNumber(value));
+ _.update(result, field, (value: string) => {
+ if (_.isUndefined(value)) {
+ throw new Error(`Could not find field '${field}' while converting string fields to BigNumber.`);
+ }
+ return new BigNumber(value);
+ });
});
return result;
},
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index 9cdcde71e..7a1781131 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -78,7 +78,7 @@ describe('HttpClient', () => {
page: 3,
perPage: 50,
};
- const urlWithQuery = `${url}?page=3&perPage=50&assetDataAddress=${assetDataAddress}`;
+ const urlWithQuery = `${url}?assetDataAddress=${assetDataAddress}&page=3&perPage=50`;
fetchMock.get(urlWithQuery, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync(ordersRequest);
expect(orders).to.be.deep.equal(ordersResponse);