Comparing version 3.0.1 to 4.0.1
[ | ||
{ | ||
"version": "4.0.1", | ||
"changes": [ | ||
{ | ||
"note": "ABI Decode NULL as False", | ||
"pr": 1582 | ||
} | ||
], | ||
"timestamp": 1549373905 | ||
}, | ||
{ | ||
"version": "4.0.0", | ||
"changes": [ | ||
{ | ||
"note": "Upgrade the bignumber.js to v8.0.2", | ||
"pr": 1517 | ||
} | ||
] | ||
}, | ||
{ | ||
"timestamp": 1547561734, | ||
@@ -4,0 +23,0 @@ "version": "3.0.1", |
@@ -8,2 +8,10 @@ <!-- | ||
## v4.0.1 - _February 5, 2019_ | ||
* ABI Decode NULL as False (#1582) | ||
## v4.0.0 - _Invalid date_ | ||
* Upgrade the bignumber.js to v8.0.2 (#1517) | ||
## v3.0.1 - _January 15, 2019_ | ||
@@ -10,0 +18,0 @@ |
@@ -73,3 +73,3 @@ "use strict"; | ||
var baseHex = 16; | ||
value = address_utils_1.addressUtils.padZeros(new configured_bignumber_1.BigNumber(value).toString(baseHex)); | ||
value = address_utils_1.addressUtils.padZeros(new configured_bignumber_1.BigNumber(value.toLowerCase()).toString(baseHex)); | ||
} | ||
@@ -76,0 +76,0 @@ else if (param.type === ethereum_types_1.SolidityTypes.Uint256 || param.type === ethereum_types_1.SolidityTypes.Uint) { |
@@ -43,8 +43,9 @@ "use strict"; | ||
var valueHex = ethUtil.bufferToHex(valueBuf); | ||
var valueNumber = new configured_bignumber_1.BigNumber(valueHex, constants_1.constants.HEX_BASE); | ||
if (!(valueNumber.equals(0) || valueNumber.equals(1))) { | ||
// Hack @hysz: there are some cases where `false` is encoded as 0x instead of 0x0. | ||
var valueNumber = valueHex === '0x' ? new configured_bignumber_1.BigNumber(0) : new configured_bignumber_1.BigNumber(valueHex, constants_1.constants.HEX_BASE); | ||
if (!(valueNumber.isEqualTo(0) || valueNumber.isEqualTo(1))) { | ||
throw new Error("Failed to decode boolean. Expected 0x0 or 0x1, got " + valueHex); | ||
} | ||
/* tslint:disable boolean-naming */ | ||
var value = !valueNumber.equals(0); | ||
var value = !valueNumber.isEqualTo(0); | ||
/* tslint:enable boolean-naming */ | ||
@@ -51,0 +52,0 @@ return value; |
@@ -30,4 +30,4 @@ "use strict"; | ||
_this._width = IntDataType._decodeWidthFromType(dataItem.type); | ||
_this._minValue = new configured_bignumber_1.BigNumber(2).toPower(_this._width - 1).times(-1); | ||
_this._maxValue = new configured_bignumber_1.BigNumber(2).toPower(_this._width - 1).sub(1); | ||
_this._minValue = new configured_bignumber_1.BigNumber(2).exponentiatedBy(_this._width - 1).times(-1); | ||
_this._maxValue = new configured_bignumber_1.BigNumber(2).exponentiatedBy(_this._width - 1).minus(1); | ||
return _this; | ||
@@ -61,3 +61,3 @@ } | ||
}; | ||
IntDataType._MATCHER = RegExp('^int(8|16|24|32|40|48|56|64|72|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256){0,1}$'); | ||
IntDataType._MATCHER = RegExp('^int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256){0,1}$'); | ||
IntDataType._SIZE_KNOWN_AT_COMPILE_TIME = true; | ||
@@ -64,0 +64,0 @@ IntDataType._MAX_WIDTH = 256; |
@@ -30,3 +30,3 @@ "use strict"; | ||
_this._width = UIntDataType._decodeWidthFromType(dataItem.type); | ||
_this._maxValue = new configured_bignumber_1.BigNumber(2).toPower(_this._width).sub(1); | ||
_this._maxValue = new configured_bignumber_1.BigNumber(2).exponentiatedBy(_this._width).minus(1); | ||
return _this; | ||
@@ -33,0 +33,0 @@ } |
/// <reference types="node" /> | ||
import BigNumber from 'bignumber.js'; | ||
import { BigNumber } from '../../configured_bignumber'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Takes a numeric value and returns its ABI-encoded value |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bignumber_js_1 = require("bignumber.js"); | ||
var ethUtil = require("ethereumjs-util"); | ||
var _ = require("lodash"); | ||
var configured_bignumber_1 = require("../../configured_bignumber"); | ||
var constants_1 = require("../utils/constants"); | ||
function sanityCheckBigNumberRange(value_, minValue, maxValue) { | ||
var value = new bignumber_js_1.default(value_, 10); | ||
if (value.greaterThan(maxValue)) { | ||
var value = new configured_bignumber_1.BigNumber(value_, 10); | ||
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); | ||
} | ||
else if (value.isNaN()) { | ||
throw new Error("Tried to assign NaN value"); | ||
} | ||
} | ||
@@ -28,5 +31,5 @@ function bigNumberToPaddedBuffer(value) { | ||
function encodeNumericValue(value_) { | ||
var value = new bignumber_js_1.default(value_, 10); | ||
var value = new configured_bignumber_1.BigNumber(value_, 10); | ||
// Case 1/2: value is non-negative | ||
if (value.greaterThanOrEqualTo(0)) { | ||
if (value.isGreaterThanOrEqualTo(0)) { | ||
var encodedPositiveValue = bigNumberToPaddedBuffer(value); | ||
@@ -44,3 +47,3 @@ return encodedPositiveValue; | ||
}); | ||
var invertedValue = new bignumber_js_1.default(invertedValueBin, constants_1.constants.BIN_BASE); | ||
var invertedValue = new configured_bignumber_1.BigNumber(invertedValueBin, constants_1.constants.BIN_BASE); | ||
// Step 3/3: Add 1 to inverted value | ||
@@ -73,4 +76,4 @@ var negativeValue = invertedValue.plus(1); | ||
// Case 1/3: value is definitely non-negative because of numeric boundaries | ||
var value = new bignumber_js_1.default(valueHex, constants_1.constants.HEX_BASE); | ||
if (!minValue.lessThan(0)) { | ||
var value = new configured_bignumber_1.BigNumber(valueHex, constants_1.constants.HEX_BASE); | ||
if (!minValue.isLessThan(0)) { | ||
return value; | ||
@@ -90,3 +93,3 @@ } | ||
}); | ||
var invertedValue = new bignumber_js_1.default(invertedValueBin, constants_1.constants.BIN_BASE); | ||
var invertedValue = new configured_bignumber_1.BigNumber(invertedValueBin, constants_1.constants.BIN_BASE); | ||
// Step 2/3: Add 1 to inverted value | ||
@@ -93,0 +96,0 @@ // The result is the two's-complement representation of the input value. |
@@ -15,3 +15,3 @@ "use strict"; | ||
var ethers = require("ethers"); | ||
var _ = require("lodash"); | ||
var configured_bignumber_1 = require("./configured_bignumber"); | ||
exports.signTypedDataUtils = { | ||
@@ -130,3 +130,3 @@ /** | ||
_normalizeValue: function (type, value) { | ||
var normalizedValue = type === 'uint256' && _.isObject(value) && value.isBigNumber ? value.toString() : value; | ||
var normalizedValue = type === 'uint256' && configured_bignumber_1.BigNumber.isBigNumber(value) ? value.toString() : value; | ||
return normalizedValue; | ||
@@ -133,0 +133,0 @@ }, |
{ | ||
"name": "@0x/utils", | ||
"version": "3.0.1", | ||
"version": "4.0.1", | ||
"engines": { | ||
@@ -31,3 +31,3 @@ "node": ">=6.12" | ||
"devDependencies": { | ||
"@0x/tslint-config": "^2.0.2", | ||
"@0x/tslint-config": "^3.0.0", | ||
"@types/detect-node": "2.0.0", | ||
@@ -38,3 +38,3 @@ "@types/lodash": "4.14.104", | ||
"chai-as-promised": "^7.1.0", | ||
"chai-bignumber": "^2.0.1", | ||
"chai-bignumber": "^3.0.0", | ||
"dirty-chai": "^2.0.1", | ||
@@ -49,15 +49,15 @@ "make-promises-safe": "^1.1.0", | ||
"dependencies": { | ||
"@0x/types": "^1.5.2", | ||
"@0x/typescript-typings": "^3.0.8", | ||
"@0x/types": "^2.0.0", | ||
"@0x/typescript-typings": "^4.0.0", | ||
"@types/node": "*", | ||
"abortcontroller-polyfill": "^1.1.9", | ||
"bignumber.js": "~4.1.0", | ||
"chalk": "^2.4.1", | ||
"bignumber.js": "~8.0.2", | ||
"chalk": "^2.3.0", | ||
"detect-node": "2.0.3", | ||
"ethereum-types": "^1.1.6", | ||
"ethereum-types": "^2.0.0", | ||
"ethereumjs-util": "^5.1.1", | ||
"ethers": "~4.0.4", | ||
"isomorphic-fetch": "^2.2.1", | ||
"isomorphic-fetch": "2.2.1", | ||
"js-sha3": "^0.7.0", | ||
"lodash": "^4.17.5" | ||
"lodash": "^4.17.11" | ||
}, | ||
@@ -67,3 +67,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "f570f80674c22f69712c45e8e3c48e948b51f357" | ||
"gitHead": "7b583cecb29c24f561c8befa835ba9ef5a6918f6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
815937
11551
+ Added@0x/types@2.4.3(transitive)
+ Added@0x/typescript-typings@4.3.0(transitive)
+ Addedbignumber.js@8.0.2(transitive)
+ Addedethereum-types@2.1.6(transitive)
- Removed@0x/types@1.5.2(transitive)
- Removed@0x/typescript-typings@3.0.8(transitive)
- Removedbignumber.js@4.1.0(transitive)
- Removedethereum-types@1.1.6(transitive)
Updated@0x/types@^2.0.0
Updatedbignumber.js@~8.0.2
Updatedchalk@^2.3.0
Updatedethereum-types@^2.0.0
Updatedisomorphic-fetch@2.2.1
Updatedlodash@^4.17.11