diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-18 20:06:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-18 20:06:08 +0800 |
commit | 3973dec9944a10c62ec6c3d15d973a00a6ea45a6 (patch) | |
tree | 73f1528a36b8fc8a0778e164b1579eb5865d944a /packages/web3-wrapper | |
parent | bef30e4209b26c8d4f443f8672e9acb9471c6a37 (diff) | |
parent | c8212f1d4d255120e5e683664b86f1830fb45ae6 (diff) | |
download | dexon-0x-contracts-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar dexon-0x-contracts-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.gz dexon-0x-contracts-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.bz2 dexon-0x-contracts-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.lz dexon-0x-contracts-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.xz dexon-0x-contracts-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.zst dexon-0x-contracts-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.zip |
Merge pull request #1517 from 0xProject/feature/bignumber-8.0
Bignumber 8.0
Diffstat (limited to 'packages/web3-wrapper')
-rw-r--r-- | packages/web3-wrapper/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/web3-wrapper/package.json | 2 | ||||
-rw-r--r-- | packages/web3-wrapper/src/utils.ts | 8 | ||||
-rw-r--r-- | packages/web3-wrapper/test/web3_wrapper_test.ts | 6 |
4 files changed, 15 insertions, 10 deletions
diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index b9d5a37b1..e05879ba8 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "4.0.0", + "changes": [ + { + "note": "Upgrade the bignumber.js to v8.0.2", + "pr": 1517 + } + ] + }, + { "timestamp": 1547561734, "version": "3.2.4", "changes": [ diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index ce9c41ae7..1ef7f91c6 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -41,7 +41,7 @@ "@types/lodash": "4.14.104", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", - "chai-bignumber": "^2.0.1", + "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", "ganache-core": "0xProject/ganache-core#monorepo-dep", "make-promises-safe": "^1.1.0", diff --git a/packages/web3-wrapper/src/utils.ts b/packages/web3-wrapper/src/utils.ts index c68587632..1aba3c75a 100644 --- a/packages/web3-wrapper/src/utils.ts +++ b/packages/web3-wrapper/src/utils.ts @@ -2,10 +2,6 @@ import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; export const utils = { - isBigNumber(value: any): boolean { - const isBigNumber = _.isObject(value) && value.isBigNumber; - return isBigNumber; - }, convertHexToNumber(value: string): number { const valueBigNumber = new BigNumber(value); const valueNumber = valueBigNumber.toNumber(); @@ -20,7 +16,7 @@ export const utils = { }, convertAmountToBigNumber(value: string | number | BigNumber): BigNumber { const num = value || 0; - const isBigNumber = utils.isBigNumber(num); + const isBigNumber = BigNumber.isBigNumber(num); if (isBigNumber) { return num as BigNumber; } @@ -37,7 +33,7 @@ export const utils = { const hexBase = 16; const valueHex = valueBigNumber.toString(hexBase); - return valueBigNumber.lessThan(0) ? `-0x${valueHex.substr(1)}` : `0x${valueHex}`; + return valueBigNumber.isLessThan(0) ? `-0x${valueHex.substr(1)}` : `0x${valueHex}`; }, numberToHex(value: number): string { if (!isFinite(value) && !utils.isHexStrict(value)) { diff --git a/packages/web3-wrapper/test/web3_wrapper_test.ts b/packages/web3-wrapper/test/web3_wrapper_test.ts index 935c67636..b6985c155 100644 --- a/packages/web3-wrapper/test/web3_wrapper_test.ts +++ b/packages/web3-wrapper/test/web3_wrapper_test.ts @@ -1,10 +1,10 @@ +import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; import { BlockParamLiteral, JSONRPCErrorCallback, JSONRPCRequestPayload, TransactionReceipt } from 'ethereum-types'; import * as Ganache from 'ganache-core'; import * as _ from 'lodash'; import 'mocha'; -import { utils } from '../src/utils'; import { Web3Wrapper } from '../src/web3_wrapper'; import { chaiSetup } from './utils/chai_setup'; @@ -118,7 +118,7 @@ describe('Web3Wrapper tests', () => { throw new Error('Expected block to exist'); } expect(blockIfExists.number).to.be.equal(0); - expect(utils.isBigNumber(blockIfExists.difficulty)).to.equal(true); + expect(BigNumber.isBigNumber(blockIfExists.difficulty)).to.equal(true); expect(_.isNumber(blockIfExists.gasLimit)).to.equal(true); }); it('gets block when supplied a block number', async () => { @@ -151,7 +151,7 @@ describe('Web3Wrapper tests', () => { const blockParamLiteral = BlockParamLiteral.Earliest; const block = await web3Wrapper.getBlockWithTransactionDataAsync(blockParamLiteral); expect(block.number).to.be.equal(0); - expect(utils.isBigNumber(block.difficulty)).to.equal(true); + expect(BigNumber.isBigNumber(block.difficulty)).to.equal(true); expect(_.isNumber(block.gasLimit)).to.equal(true); }); it('should throw if supplied invalid blockParam value', async () => { |