Removed circular dependencies

This commit is contained in:
Fabian Vogelsteller 2015-02-20 09:49:42 +01:00
parent 188e9e5325
commit ce141d8ec3
5 changed files with 32 additions and 20 deletions

22
dist/ethereum.js vendored
View File

@ -1441,6 +1441,10 @@ module.exports = {
var c = require('./const'); var c = require('./const');
if ("build" !== 'build') {/*
var BigNumber = require('bignumber.js'); // jshint ignore:line
*/}
/// Finds first index of array element matching pattern /// Finds first index of array element matching pattern
/// @param array /// @param array
/// @param callback pattern /// @param callback pattern
@ -1551,6 +1555,11 @@ var toEth = function (str) {
return s + ' ' + units[unit]; return s + ' ' + units[unit];
}; };
var toDecimal = function (val) {
// remove 0x and place 0, if it's required
val = val.length > 2 ? val.substring(2) : "0";
return (new BigNumber(val, 16).toString(10));
};
/** /**
@ -1581,7 +1590,7 @@ var fromWei = function(number, unit) {
return number; return number;
if(typeof number === 'string' && number.indexOf('0x') === 0) if(typeof number === 'string' && number.indexOf('0x') === 0)
number = web3.toDecimal(number); number = toDecimal(number);
if(!(number instanceof BigNumber)) { if(!(number instanceof BigNumber)) {
isBigNumber = false; isBigNumber = false;
@ -1660,7 +1669,7 @@ var toWei = function(number, unit) {
return number; return number;
if(typeof number === 'string' && number.indexOf('0x') === 0) if(typeof number === 'string' && number.indexOf('0x') === 0)
number = web3.toDecimal(number); number = toDecimal(number);
if(!(number instanceof BigNumber)) { if(!(number instanceof BigNumber)) {
isBigNumber = false; isBigNumber = false;
@ -1731,6 +1740,7 @@ var isAddress = function(address) {
module.exports = { module.exports = {
findIndex: findIndex, findIndex: findIndex,
toDecimal: toDecimal,
toAscii: toAscii, toAscii: toAscii,
fromAscii: fromAscii, fromAscii: fromAscii,
extractDisplayName: extractDisplayName, extractDisplayName: extractDisplayName,
@ -1950,11 +1960,7 @@ var web3 = {
fromAscii: utils.fromAscii, fromAscii: utils.fromAscii,
/// @returns decimal representaton of hex value prefixed by 0x /// @returns decimal representaton of hex value prefixed by 0x
toDecimal: function (val) { toDecimal: utils.toDecimal,
// remove 0x and place 0, if it's required
val = val.length > 2 ? val.substring(2) : "0";
return (new BigNumber(val, 16).toString(10));
},
/// @returns hex representation (prefixed by 0x) of decimal value /// @returns hex representation (prefixed by 0x) of decimal value
fromDecimal: function (val) { fromDecimal: function (val) {
@ -1963,7 +1969,7 @@ var web3 = {
/// used to transform value/string to eth string /// used to transform value/string to eth string
toEth: utils.toEth, toEth: utils.toEth,
toWei: utils.toWei, toWei: utils.toWei,
fromWei: utils.fromWei, fromWei: utils.fromWei,
isAddress: utils.isAddress, isAddress: utils.isAddress,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -22,6 +22,10 @@
var c = require('./const'); var c = require('./const');
if (process.env.NODE_ENV !== 'build') {
var BigNumber = require('bignumber.js'); // jshint ignore:line
}
/// Finds first index of array element matching pattern /// Finds first index of array element matching pattern
/// @param array /// @param array
/// @param callback pattern /// @param callback pattern
@ -132,6 +136,11 @@ var toEth = function (str) {
return s + ' ' + units[unit]; return s + ' ' + units[unit];
}; };
var toDecimal = function (val) {
// remove 0x and place 0, if it's required
val = val.length > 2 ? val.substring(2) : "0";
return (new BigNumber(val, 16).toString(10));
};
/** /**
@ -162,7 +171,7 @@ var fromWei = function(number, unit) {
return number; return number;
if(typeof number === 'string' && number.indexOf('0x') === 0) if(typeof number === 'string' && number.indexOf('0x') === 0)
number = web3.toDecimal(number); number = toDecimal(number);
if(!(number instanceof BigNumber)) { if(!(number instanceof BigNumber)) {
isBigNumber = false; isBigNumber = false;
@ -241,7 +250,7 @@ var toWei = function(number, unit) {
return number; return number;
if(typeof number === 'string' && number.indexOf('0x') === 0) if(typeof number === 'string' && number.indexOf('0x') === 0)
number = web3.toDecimal(number); number = toDecimal(number);
if(!(number instanceof BigNumber)) { if(!(number instanceof BigNumber)) {
isBigNumber = false; isBigNumber = false;
@ -312,6 +321,7 @@ var isAddress = function(address) {
module.exports = { module.exports = {
findIndex: findIndex, findIndex: findIndex,
toDecimal: toDecimal,
toAscii: toAscii, toAscii: toAscii,
fromAscii: fromAscii, fromAscii: fromAscii,
extractDisplayName: extractDisplayName, extractDisplayName: extractDisplayName,

View File

@ -152,11 +152,7 @@ var web3 = {
fromAscii: utils.fromAscii, fromAscii: utils.fromAscii,
/// @returns decimal representaton of hex value prefixed by 0x /// @returns decimal representaton of hex value prefixed by 0x
toDecimal: function (val) { toDecimal: utils.toDecimal,
// remove 0x and place 0, if it's required
val = val.length > 2 ? val.substring(2) : "0";
return (new BigNumber(val, 16).toString(10));
},
/// @returns hex representation (prefixed by 0x) of decimal value /// @returns hex representation (prefixed by 0x) of decimal value
fromDecimal: function (val) { fromDecimal: function (val) {
@ -165,7 +161,7 @@ var web3 = {
/// used to transform value/string to eth string /// used to transform value/string to eth string
toEth: utils.toEth, toEth: utils.toEth,
toWei: utils.toWei, toWei: utils.toWei,
fromWei: utils.fromWei, fromWei: utils.fromWei,
isAddress: utils.isAddress, isAddress: utils.isAddress,