diff options
Diffstat (limited to 'packages/utils')
-rw-r--r-- | packages/utils/package.json | 2 | ||||
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types/bool.ts | 4 | ||||
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types/int.ts | 4 | ||||
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types/uint.ts | 2 | ||||
-rw-r--r-- | packages/utils/src/abi_encoder/utils/math.ts | 8 |
5 files changed, 10 insertions, 10 deletions
diff --git a/packages/utils/package.json b/packages/utils/package.json index 315f5a08f..3b16550a5 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -48,7 +48,7 @@ "@0x/typescript-typings": "^3.0.8", "@types/node": "*", "abortcontroller-polyfill": "^1.1.9", - "bignumber.js": "~4.1.0", + "bignumber.js": "~8.0.2", "chalk": "^2.4.1", "detect-node": "2.0.3", "ethereum-types": "^1.1.6", diff --git a/packages/utils/src/abi_encoder/evm_data_types/bool.ts b/packages/utils/src/abi_encoder/evm_data_types/bool.ts index 7f91f34e6..23298bc88 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/bool.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/bool.ts @@ -37,11 +37,11 @@ export class BoolDataType extends AbstractBlobDataType { const valueBuf = calldata.popWord(); const valueHex = ethUtil.bufferToHex(valueBuf); const valueNumber = new BigNumber(valueHex, constants.HEX_BASE); - if (!(valueNumber.equals(0) || valueNumber.equals(1))) { + if (!(valueNumber.isEqualTo(0) || valueNumber.isEqualTo(1))) { throw new Error(`Failed to decode boolean. Expected 0x0 or 0x1, got ${valueHex}`); } /* tslint:disable boolean-naming */ - const value: boolean = !valueNumber.equals(0); + const value: boolean = !valueNumber.isEqualTo(0); /* tslint:enable boolean-naming */ return value; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/int.ts b/packages/utils/src/abi_encoder/evm_data_types/int.ts index 8d98e195b..b7e0d9f4e 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/int.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/int.ts @@ -38,8 +38,8 @@ export class IntDataType extends AbstractBlobDataType { throw new Error(`Tried to instantiate Int with bad input: ${dataItem}`); } this._width = IntDataType._decodeWidthFromType(dataItem.type); - this._minValue = new BigNumber(2).toPower(this._width - 1).times(-1); - this._maxValue = new BigNumber(2).toPower(this._width - 1).sub(1); + this._minValue = new BigNumber(2).exponentiatedBy(this._width - 1).times(-1); + this._maxValue = new BigNumber(2).exponentiatedBy(this._width - 1).minus(1); } public encodeValue(value: BigNumber | string | number): Buffer { diff --git a/packages/utils/src/abi_encoder/evm_data_types/uint.ts b/packages/utils/src/abi_encoder/evm_data_types/uint.ts index 8e382e8dc..a82aa789e 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts @@ -38,7 +38,7 @@ export class UIntDataType extends AbstractBlobDataType { throw new Error(`Tried to instantiate UInt with bad input: ${dataItem}`); } this._width = UIntDataType._decodeWidthFromType(dataItem.type); - this._maxValue = new BigNumber(2).toPower(this._width).sub(1); + this._maxValue = new BigNumber(2).exponentiatedBy(this._width).minus(1); } public encodeValue(value: BigNumber | string | number): Buffer { diff --git a/packages/utils/src/abi_encoder/utils/math.ts b/packages/utils/src/abi_encoder/utils/math.ts index d84983c5b..b2fa5fe7d 100644 --- a/packages/utils/src/abi_encoder/utils/math.ts +++ b/packages/utils/src/abi_encoder/utils/math.ts @@ -10,9 +10,9 @@ function sanityCheckBigNumberRange( maxValue: BigNumber, ): void { const value = new BigNumber(value_, 10); - if (value.greaterThan(maxValue)) { + if (value.isGreaterThan(maxValue)) { throw new Error(`Tried to assign value of ${value}, which exceeds max value of ${maxValue}`); - } else if (value.lessThan(minValue)) { + } else if (value.isLessThan(minValue)) { throw new Error(`Tried to assign value of ${value}, which exceeds min value of ${minValue}`); } } @@ -30,7 +30,7 @@ function bigNumberToPaddedBuffer(value: BigNumber): Buffer { export function encodeNumericValue(value_: BigNumber | string | number): Buffer { const value = new BigNumber(value_, 10); // Case 1/2: value is non-negative - if (value.greaterThanOrEqualTo(0)) { + if (value.isGreaterThanOrEqualTo(0)) { const encodedPositiveValue = bigNumberToPaddedBuffer(value); return encodedPositiveValue; } @@ -74,7 +74,7 @@ export function decodeNumericValue(encodedValue: Buffer, minValue: BigNumber): B const valueHex = ethUtil.bufferToHex(encodedValue); // Case 1/3: value is definitely non-negative because of numeric boundaries const value = new BigNumber(valueHex, constants.HEX_BASE); - if (!minValue.lessThan(0)) { + if (!minValue.isLessThan(0)) { return value; } // Case 2/3: value is non-negative because there is no leading 1 (encoded as two's-complement) |