aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/base-contract/src/index.ts2
-rw-r--r--packages/order-utils/src/crypto.ts3
-rw-r--r--packages/utils/src/sign_typed_data_utils.ts5
-rw-r--r--packages/web3-wrapper/src/utils.ts6
-rw-r--r--packages/web3-wrapper/test/web3_wrapper_test.ts5
5 files changed, 10 insertions, 11 deletions
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index c2b7b943b..101228c52 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -43,7 +43,7 @@ export class BaseContract {
return type === 'address' ? value.toLowerCase() : value;
}
protected static _bigNumberToString(_type: string, value: any): any {
- return _.isObject(value) && value.isBigNumber ? value.toString() : value;
+ return BigNumber.isBigNumber(value) ? value.toString() : value;
}
protected static _lookupConstructorAbi(abi: ContractAbi): ConstructorAbi {
const constructorAbiIfExists = _.find(
diff --git a/packages/order-utils/src/crypto.ts b/packages/order-utils/src/crypto.ts
index 0f1504a72..8b835ff48 100644
--- a/packages/order-utils/src/crypto.ts
+++ b/packages/order-utils/src/crypto.ts
@@ -1,3 +1,4 @@
+import { BigNumber } from '@0x/utils';
import BN = require('bn.js');
import ABI = require('ethereumjs-abi');
import ethUtil = require('ethereumjs-util');
@@ -24,7 +25,7 @@ export const crypto = {
const isNumber = _.isFinite(arg);
if (isNumber) {
argTypes.push('uint8');
- } else if (arg.isBigNumber) {
+ } else if (BigNumber.isBigNumber(arg)) {
argTypes.push('uint256');
const base = 10;
args[i] = new BN(arg.toString(base), base);
diff --git a/packages/utils/src/sign_typed_data_utils.ts b/packages/utils/src/sign_typed_data_utils.ts
index 6963b9084..adb66622d 100644
--- a/packages/utils/src/sign_typed_data_utils.ts
+++ b/packages/utils/src/sign_typed_data_utils.ts
@@ -1,8 +1,9 @@
+import { EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Types } from '@0x/types';
import * as ethUtil from 'ethereumjs-util';
import * as ethers from 'ethers';
import * as _ from 'lodash';
-import { EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Types } from '@0x/types';
+import { BigNumber } from './configured_bignumber';
export const signTypedDataUtils = {
/**
@@ -70,7 +71,7 @@ export const signTypedDataUtils = {
return ethers.utils.defaultAbiCoder.encode(encodedTypes, encodedValues);
},
_normalizeValue(type: string, value: any): EIP712ObjectValue {
- const normalizedValue = type === 'uint256' && _.isObject(value) && value.isBigNumber ? value.toString() : value;
+ const normalizedValue = type === 'uint256' && BigNumber.isBigNumber(value) ? value.toString() : value;
return normalizedValue;
},
_typeHash(primaryType: string, types: EIP712Types): Buffer {
diff --git a/packages/web3-wrapper/src/utils.ts b/packages/web3-wrapper/src/utils.ts
index 1b67518b1..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;
}
diff --git a/packages/web3-wrapper/test/web3_wrapper_test.ts b/packages/web3-wrapper/test/web3_wrapper_test.ts
index 935c67636..e8732bcbe 100644
--- a/packages/web3-wrapper/test/web3_wrapper_test.ts
+++ b/packages/web3-wrapper/test/web3_wrapper_test.ts
@@ -1,3 +1,4 @@
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { BlockParamLiteral, JSONRPCErrorCallback, JSONRPCRequestPayload, TransactionReceipt } from 'ethereum-types';
import * as Ganache from 'ganache-core';
@@ -118,7 +119,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 +152,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 () => {