aboutsummaryrefslogtreecommitdiffstats
path: root/lib/web3.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/web3.js')
-rw-r--r--lib/web3.js52
1 files changed, 1 insertions, 51 deletions
diff --git a/lib/web3.js b/lib/web3.js
index c3126afc4..e868e9412 100644
--- a/lib/web3.js
+++ b/lib/web3.js
@@ -29,28 +29,6 @@ if (process.env.NODE_ENV !== 'build') {
var utils = require('./utils');
-var ETH_UNITS = [
- 'wei',
- 'Kwei',
- 'Mwei',
- 'Gwei',
- 'szabo',
- 'finney',
- 'ether',
- 'grand',
- 'Mether',
- 'Gether',
- 'Tether',
- 'Pether',
- 'Eether',
- 'Zether',
- 'Yether',
- 'Nether',
- 'Dether',
- 'Vether',
- 'Uether'
-];
-
/// @returns an array of objects describing web3 api methods
var web3Methods = function () {
return [
@@ -213,29 +191,7 @@ var web3 = {
},
/// used to transform value/string to eth string
- /// TODO: use BigNumber.js to parse int
- toEth: function(str) {
- var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
- var unit = 0;
- var units = ETH_UNITS;
- while (val > 3000 && unit < units.length - 1)
- {
- val /= 1000;
- unit++;
- }
- var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);
- var replaceFunction = function($0, $1, $2) {
- return $1 + ',' + $2;
- };
-
- while (true) {
- var o = s;
- s = s.replace(/(\d)(\d\d\d[\.\,])/, replaceFunction);
- if (o === s)
- break;
- }
- return s + ' ' + units[unit];
- },
+ toEth: utils.toEth,
/// eth object prototype
eth: {
@@ -271,11 +227,6 @@ var web3 = {
return new web3.filter(filter, shhWatch);
}
},
-
- /// @returns true if provider is installed
- haveProvider: function() {
- return !!web3.provider.provider;
- }
};
/// setups all api methods
@@ -298,7 +249,6 @@ var shhWatch = {
setupMethods(shhWatch, shhWatchMethods());
web3.setProvider = function(provider) {
- //provider.onmessage = messageHandler; // there will be no async calls, to remove
web3.provider.set(provider);
};