aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect
diff options
context:
space:
mode:
authorF. Eugene Aumson <feuGeneA@users.noreply.github.com>2018-09-12 07:00:11 +0800
committerGitHub <noreply@github.com>2018-09-12 07:00:11 +0800
commitcbb5a425dfb45d1dfda3579548d6b3f70dfca166 (patch)
tree8751979ad70ed0eb61dfda5a954bb9e1bc3d5c3b /packages/connect
parent800dd5fb4f0ab21388440a46aef21cd0cf0801c3 (diff)
parent45b68832aa3eb5c09db33140468ab737114be9e3 (diff)
downloaddexon-sol-tools-cbb5a425dfb45d1dfda3579548d6b3f70dfca166.tar
dexon-sol-tools-cbb5a425dfb45d1dfda3579548d6b3f70dfca166.tar.gz
dexon-sol-tools-cbb5a425dfb45d1dfda3579548d6b3f70dfca166.tar.bz2
dexon-sol-tools-cbb5a425dfb45d1dfda3579548d6b3f70dfca166.tar.lz
dexon-sol-tools-cbb5a425dfb45d1dfda3579548d6b3f70dfca166.tar.xz
dexon-sol-tools-cbb5a425dfb45d1dfda3579548d6b3f70dfca166.tar.zst
dexon-sol-tools-cbb5a425dfb45d1dfda3579548d6b3f70dfca166.zip
Merge branch 'development' into sol-doc
Diffstat (limited to 'packages/connect')
-rw-r--r--packages/connect/CHANGELOG.json10
-rw-r--r--packages/connect/CHANGELOG.md4
-rw-r--r--packages/connect/package.json15
-rw-r--r--packages/connect/src/http_client.ts2
-rw-r--r--packages/connect/src/types.ts6
-rw-r--r--packages/connect/src/utils/relayer_response_json_parsers.ts5
-rw-r--r--packages/connect/src/utils/type_converters.ts26
-rw-r--r--packages/connect/test/http_client_test.ts13
8 files changed, 38 insertions, 43 deletions
diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json
index 8ccb6afe2..5b708c10d 100644
--- a/packages/connect/CHANGELOG.json
+++ b/packages/connect/CHANGELOG.json
@@ -1,5 +1,15 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Change `OrderConfigRequest` to use BigNumber instead of string for relevant fields.",
+ "pr": 1058
+ }
+ ],
+ "timestamp": 1536142250
+ },
+ {
"version": "2.0.0-rc.2",
"changes": [
{
diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md
index a83d31869..17888f36e 100644
--- a/packages/connect/CHANGELOG.md
+++ b/packages/connect/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.0 - _September 5, 2018_
+
+ * Change `OrderConfigRequest` to use BigNumber instead of string for relevant fields. (#1058)
+
## v2.0.0-rc.2 - _August 27, 2018_
* Dependencies updated
diff --git a/packages/connect/package.json b/packages/connect/package.json
index 543852350..cc31afef1 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/connect",
- "version": "2.0.0-rc.2",
+ "version": "2.0.0",
"engines": {
"node": ">=6.12"
},
@@ -43,11 +43,12 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": {
- "@0xproject/assert": "^1.0.7",
- "@0xproject/json-schemas": "^1.0.1-rc.6",
- "@0xproject/types": "^1.0.1-rc.6",
- "@0xproject/typescript-typings": "^1.0.5",
- "@0xproject/utils": "^1.0.7",
+ "@0xproject/assert": "^1.0.8",
+ "@0xproject/json-schemas": "^1.0.1",
+ "@0xproject/order-utils": "^1.0.1",
+ "@0xproject/types": "^1.0.1",
+ "@0xproject/typescript-typings": "^2.0.0",
+ "@0xproject/utils": "^1.0.8",
"lodash": "^4.17.5",
"query-string": "^5.0.1",
"sinon": "^4.0.0",
@@ -55,7 +56,7 @@
"websocket": "^1.0.25"
},
"devDependencies": {
- "@0xproject/tslint-config": "^1.0.6",
+ "@0xproject/tslint-config": "^1.0.7",
"@types/fetch-mock": "^6.0.3",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts
index b90c2c35f..87d5c30be 100644
--- a/packages/connect/src/http_client.ts
+++ b/packages/connect/src/http_client.ts
@@ -151,7 +151,7 @@ export class HttpClient implements Client {
params: requestOpts,
payload: request,
};
- const responseJson = await this._requestAsync('/order_config', HttpRequestType.Post, httpRequestOpts);
+ const responseJson = await this._requestAsync('/order_config', HttpRequestType.Get, httpRequestOpts);
const fees = relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson);
return fees;
}
diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts
index 06ae732a5..b76af081c 100644
--- a/packages/connect/src/types.ts
+++ b/packages/connect/src/types.ts
@@ -126,12 +126,12 @@ export interface PaginatedCollection<T> {
export interface OrderConfigRequest {
makerAddress: string;
takerAddress: string;
- makerAssetAmount: string;
- takerAssetAmount: string;
+ makerAssetAmount: BigNumber;
+ takerAssetAmount: BigNumber;
makerAssetData: string;
takerAssetData: string;
exchangeAddress: string;
- expirationTimeSeconds: string;
+ expirationTimeSeconds: BigNumber;
}
export interface OrderConfigResponse {
diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts
index ebd877b70..bc31f231d 100644
--- a/packages/connect/src/utils/relayer_response_json_parsers.ts
+++ b/packages/connect/src/utils/relayer_response_json_parsers.ts
@@ -1,5 +1,6 @@
import { assert } from '@0xproject/assert';
import { schemas } from '@0xproject/json-schemas';
+import { orderParsingUtils } from '@0xproject/order-utils';
import {
APIOrder,
@@ -19,7 +20,7 @@ export const relayerResponseJsonParsers = {
},
parseAssetPairsItemsJson(json: any): AssetPairsItem[] {
return json.map((assetDataPair: any) => {
- return typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [
+ return orderParsingUtils.convertStringsFieldsToBigNumbers(assetDataPair, [
'assetDataA.minAmount',
'assetDataA.maxAmount',
'assetDataB.minAmount',
@@ -44,6 +45,6 @@ export const relayerResponseJsonParsers = {
},
parseOrderConfigResponseJson(json: any): OrderConfigResponse {
assert.doesConformToSchema('orderConfigResponse', json, schemas.relayerApiOrderConfigResponseSchema);
- return typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);
+ return orderParsingUtils.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);
},
};
diff --git a/packages/connect/src/utils/type_converters.ts b/packages/connect/src/utils/type_converters.ts
index 4b211a0b2..d57ea00e5 100644
--- a/packages/connect/src/utils/type_converters.ts
+++ b/packages/connect/src/utils/type_converters.ts
@@ -1,4 +1,4 @@
-import { BigNumber } from '@0xproject/utils';
+import { orderParsingUtils } from '@0xproject/order-utils';
import * as _ from 'lodash';
import { APIOrder } from '../types';
@@ -21,28 +21,6 @@ export const typeConverters = {
};
},
convertAPIOrderStringFieldsToBigNumber(apiOrder: any): APIOrder {
- return { ...apiOrder, order: typeConverters.convertOrderStringFieldsToBigNumber(apiOrder.order) };
- },
- convertOrderStringFieldsToBigNumber(order: any): any {
- return typeConverters.convertStringsFieldsToBigNumbers(order, [
- 'makerAssetAmount',
- 'takerAssetAmount',
- 'makerFee',
- 'takerFee',
- 'expirationTimeSeconds',
- 'salt',
- ]);
- },
- convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any {
- const result = _.assign({}, obj);
- _.each(fields, field => {
- _.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;
+ return { ...apiOrder, order: orderParsingUtils.convertOrderStringFieldsToBigNumber(apiOrder.order) };
},
};
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index 5b564e97b..83b77021a 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -1,3 +1,4 @@
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import * as dirtyChai from 'dirty-chai';
@@ -138,21 +139,21 @@ describe('HttpClient', () => {
const request = {
makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- makerAssetAmount: '10000000000000000',
- takerAssetAmount: '20000000000000000',
- expirationTimeSeconds: '1532560590',
+ makerAssetAmount: new BigNumber('10000000000000000'),
+ takerAssetAmount: new BigNumber('20000000000000000'),
+ expirationTimeSeconds: new BigNumber('1532560590'),
makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
};
const url = `${relayUrl}/order_config`;
it('gets order config', async () => {
- fetchMock.post(url, orderConfigResponseJSON);
+ fetchMock.get(url, orderConfigResponseJSON);
const fees = await relayerClient.getOrderConfigAsync(request);
expect(fees).to.be.deep.equal(orderConfigResponse);
});
it('does not mutate input', async () => {
- fetchMock.post(url, orderConfigResponseJSON);
+ fetchMock.get(url, orderConfigResponseJSON);
const makerAssetAmountBefore = request.makerAssetAmount;
const takerAssetAmountBefore = request.takerAssetAmount;
const expirationTimeSecondsBefore = request.expirationTimeSeconds;
@@ -162,7 +163,7 @@ describe('HttpClient', () => {
expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds);
});
it('throws an error for invalid JSON response', async () => {
- fetchMock.post(url, { test: 'dummy' });
+ fetchMock.get(url, { test: 'dummy' });
expect(relayerClient.getOrderConfigAsync(request)).to.be.rejected();
});
});