mirror of https://github.com/status-im/web3.js.git
fixed karma test
This commit is contained in:
parent
75e92c8048
commit
0b9d450a4d
|
@ -972,7 +972,7 @@ var padLeft = function (string, chars, sign) {
|
||||||
var formatInputInt = function (value) {
|
var formatInputInt = function (value) {
|
||||||
/*jshint maxcomplexity:7 */
|
/*jshint maxcomplexity:7 */
|
||||||
var padding = c.ETH_PADDING * 2;
|
var padding = c.ETH_PADDING * 2;
|
||||||
if (value instanceof BigNumber || typeof value === 'number') {
|
if (utils.isBigNumber(value) || typeof value === 'number') {
|
||||||
if (typeof value === 'number')
|
if (typeof value === 'number')
|
||||||
value = new BigNumber(value);
|
value = new BigNumber(value);
|
||||||
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
|
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
|
||||||
|
@ -982,10 +982,13 @@ var formatInputInt = function (value) {
|
||||||
value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
|
value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
|
||||||
value = value.toString(16);
|
value = value.toString(16);
|
||||||
}
|
}
|
||||||
else if (value.indexOf('0x') === 0)
|
else if (typeof value === 'string') {
|
||||||
|
if (value.indexOf('0x') === 0) {
|
||||||
value = value.substr(2);
|
value = value.substr(2);
|
||||||
else if (typeof value === 'string')
|
} else {
|
||||||
value = formatInputInt(new BigNumber(value));
|
value = formatInputInt(new BigNumber(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
value = (+value).toString(16);
|
value = (+value).toString(16);
|
||||||
return padLeft(value, padding);
|
return padLeft(value, padding);
|
||||||
|
@ -1958,6 +1961,11 @@ var isAddress = function(address) {
|
||||||
return /^\w+$/.test(address);
|
return /^\w+$/.test(address);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var isBigNumber = function (value) {
|
||||||
|
return value instanceof BigNumber ||
|
||||||
|
(value && value.constructor && value.constructor.name === 'BigNumber');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findIndex: findIndex,
|
findIndex: findIndex,
|
||||||
|
@ -1972,7 +1980,8 @@ module.exports = {
|
||||||
toEth: toEth,
|
toEth: toEth,
|
||||||
toWei: toWei,
|
toWei: toWei,
|
||||||
fromWei: fromWei,
|
fromWei: fromWei,
|
||||||
isAddress: isAddress
|
isAddress: isAddress,
|
||||||
|
isBigNumber: isBigNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -22,8 +22,8 @@ module.exports = function (config) {
|
||||||
|
|
||||||
// list of files / patterns to load in the browser
|
// list of files / patterns to load in the browser
|
||||||
files: [
|
files: [
|
||||||
|
'node_modules/bignumber.js/bignumber.js',
|
||||||
'test/*.js',
|
'test/*.js',
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ var padLeft = function (string, chars, sign) {
|
||||||
var formatInputInt = function (value) {
|
var formatInputInt = function (value) {
|
||||||
/*jshint maxcomplexity:7 */
|
/*jshint maxcomplexity:7 */
|
||||||
var padding = c.ETH_PADDING * 2;
|
var padding = c.ETH_PADDING * 2;
|
||||||
if (value instanceof BigNumber || typeof value === 'number') {
|
if (utils.isBigNumber(value) || typeof value === 'number') {
|
||||||
if (typeof value === 'number')
|
if (typeof value === 'number')
|
||||||
value = new BigNumber(value);
|
value = new BigNumber(value);
|
||||||
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
|
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
|
||||||
|
@ -52,10 +52,13 @@ var formatInputInt = function (value) {
|
||||||
value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
|
value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
|
||||||
value = value.toString(16);
|
value = value.toString(16);
|
||||||
}
|
}
|
||||||
else if (value.indexOf('0x') === 0)
|
else if (typeof value === 'string') {
|
||||||
|
if (value.indexOf('0x') === 0) {
|
||||||
value = value.substr(2);
|
value = value.substr(2);
|
||||||
else if (typeof value === 'string')
|
} else {
|
||||||
value = formatInputInt(new BigNumber(value));
|
value = formatInputInt(new BigNumber(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
value = (+value).toString(16);
|
value = (+value).toString(16);
|
||||||
return padLeft(value, padding);
|
return padLeft(value, padding);
|
||||||
|
|
|
@ -287,6 +287,11 @@ var isAddress = function(address) {
|
||||||
return /^\w+$/.test(address);
|
return /^\w+$/.test(address);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var isBigNumber = function (value) {
|
||||||
|
return value instanceof BigNumber ||
|
||||||
|
(value && value.constructor && value.constructor.name === 'BigNumber');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findIndex: findIndex,
|
findIndex: findIndex,
|
||||||
|
@ -301,6 +306,7 @@ module.exports = {
|
||||||
toEth: toEth,
|
toEth: toEth,
|
||||||
toWei: toWei,
|
toWei: toWei,
|
||||||
fromWei: fromWei,
|
fromWei: fromWei,
|
||||||
isAddress: isAddress
|
isAddress: isAddress,
|
||||||
|
isBigNumber: isBigNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue