diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-09-05 08:25:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-05 08:25:51 +0800 |
commit | 561e52577892c10817d7d2d9365be7e541a8d2d7 (patch) | |
tree | 535d07a06a61ef50ae6805d4ac51e0e9ca466f6d /packages/connect | |
parent | 447f16fc4f2910b5a69f1c2f0b4122c295898b2f (diff) | |
parent | 69eb820d0dbca63a6725d99d2d547506e60068ce (diff) | |
download | dexon-sol-tools-561e52577892c10817d7d2d9365be7e541a8d2d7.tar dexon-sol-tools-561e52577892c10817d7d2d9365be7e541a8d2d7.tar.gz dexon-sol-tools-561e52577892c10817d7d2d9365be7e541a8d2d7.tar.bz2 dexon-sol-tools-561e52577892c10817d7d2d9365be7e541a8d2d7.tar.lz dexon-sol-tools-561e52577892c10817d7d2d9365be7e541a8d2d7.tar.xz dexon-sol-tools-561e52577892c10817d7d2d9365be7e541a8d2d7.tar.zst dexon-sol-tools-561e52577892c10817d7d2d9365be7e541a8d2d7.zip |
Merge pull request #1058 from 0xProject/fix/connect/use-big-number-in-requests
[connect] Use BigNumber instead of string where appropriate in OrderConfigRequest
Diffstat (limited to 'packages/connect')
-rw-r--r-- | packages/connect/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/connect/src/http_client.ts | 2 | ||||
-rw-r--r-- | packages/connect/src/types.ts | 6 | ||||
-rw-r--r-- | packages/connect/test/http_client_test.ts | 13 |
4 files changed, 20 insertions, 10 deletions
diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json index 8ccb6afe2..cecafc6f7 100644 --- a/packages/connect/CHANGELOG.json +++ b/packages/connect/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "2.0.0-rc.3", + "changes": [ + { + "note": "Change `OrderConfigRequest` to use BigNumber instead of string for relevant fields.", + "pr": 1058 + } + ] + }, + { "version": "2.0.0-rc.2", "changes": [ { 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/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(); }); }); |