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) {
|
||||
/*jshint maxcomplexity:7 */
|
||||
var padding = c.ETH_PADDING * 2;
|
||||
if (value instanceof BigNumber || typeof value === 'number') {
|
||||
if (utils.isBigNumber(value) || typeof value === 'number') {
|
||||
if (typeof value === 'number')
|
||||
value = new BigNumber(value);
|
||||
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 = value.toString(16);
|
||||
}
|
||||
else if (value.indexOf('0x') === 0)
|
||||
value = value.substr(2);
|
||||
else if (typeof value === 'string')
|
||||
value = formatInputInt(new BigNumber(value));
|
||||
else if (typeof value === 'string') {
|
||||
if (value.indexOf('0x') === 0) {
|
||||
value = value.substr(2);
|
||||
} else {
|
||||
value = formatInputInt(new BigNumber(value));
|
||||
}
|
||||
}
|
||||
else
|
||||
value = (+value).toString(16);
|
||||
return padLeft(value, padding);
|
||||
|
@ -1958,6 +1961,11 @@ var isAddress = function(address) {
|
|||
return /^\w+$/.test(address);
|
||||
};
|
||||
|
||||
var isBigNumber = function (value) {
|
||||
return value instanceof BigNumber ||
|
||||
(value && value.constructor && value.constructor.name === 'BigNumber');
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
findIndex: findIndex,
|
||||
|
@ -1972,7 +1980,8 @@ module.exports = {
|
|||
toEth: toEth,
|
||||
toWei: toWei,
|
||||
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
|
||||
files: [
|
||||
'node_modules/bignumber.js/bignumber.js',
|
||||
'test/*.js',
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ var padLeft = function (string, chars, sign) {
|
|||
var formatInputInt = function (value) {
|
||||
/*jshint maxcomplexity:7 */
|
||||
var padding = c.ETH_PADDING * 2;
|
||||
if (value instanceof BigNumber || typeof value === 'number') {
|
||||
if (utils.isBigNumber(value) || typeof value === 'number') {
|
||||
if (typeof value === 'number')
|
||||
value = new BigNumber(value);
|
||||
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 = value.toString(16);
|
||||
}
|
||||
else if (value.indexOf('0x') === 0)
|
||||
value = value.substr(2);
|
||||
else if (typeof value === 'string')
|
||||
value = formatInputInt(new BigNumber(value));
|
||||
else if (typeof value === 'string') {
|
||||
if (value.indexOf('0x') === 0) {
|
||||
value = value.substr(2);
|
||||
} else {
|
||||
value = formatInputInt(new BigNumber(value));
|
||||
}
|
||||
}
|
||||
else
|
||||
value = (+value).toString(16);
|
||||
return padLeft(value, padding);
|
||||
|
|
|
@ -287,6 +287,11 @@ var isAddress = function(address) {
|
|||
return /^\w+$/.test(address);
|
||||
};
|
||||
|
||||
var isBigNumber = function (value) {
|
||||
return value instanceof BigNumber ||
|
||||
(value && value.constructor && value.constructor.name === 'BigNumber');
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
findIndex: findIndex,
|
||||
|
@ -301,6 +306,7 @@ module.exports = {
|
|||
toEth: toEth,
|
||||
toWei: toWei,
|
||||
fromWei: fromWei,
|
||||
isAddress: isAddress
|
||||
isAddress: isAddress,
|
||||
isBigNumber: isBigNumber
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue