aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-06 20:26:51 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-06 20:26:51 +0800
commitaf9242f4cc382a61bea9142ddbd0cec2e1edf08a (patch)
treee08dc7265e59f25057631916684b93b32ac80cd6 /lib
parent1954b878191e08db04188f0934b15ebe8c2c5a84 (diff)
downloaddexon-af9242f4cc382a61bea9142ddbd0cec2e1edf08a.tar
dexon-af9242f4cc382a61bea9142ddbd0cec2e1edf08a.tar.gz
dexon-af9242f4cc382a61bea9142ddbd0cec2e1edf08a.tar.bz2
dexon-af9242f4cc382a61bea9142ddbd0cec2e1edf08a.tar.lz
dexon-af9242f4cc382a61bea9142ddbd0cec2e1edf08a.tar.xz
dexon-af9242f4cc382a61bea9142ddbd0cec2e1edf08a.tar.zst
dexon-af9242f4cc382a61bea9142ddbd0cec2e1edf08a.zip
fixed gulp build
Diffstat (limited to 'lib')
-rw-r--r--lib/abi.js2
-rw-r--r--lib/autoprovider.js6
-rw-r--r--lib/contract.js7
-rw-r--r--lib/httprpc.js6
-rw-r--r--lib/main.js10
-rw-r--r--lib/websocket.js6
6 files changed, 17 insertions, 20 deletions
diff --git a/lib/abi.js b/lib/abi.js
index 2cff503d3..21607f140 100644
--- a/lib/abi.js
+++ b/lib/abi.js
@@ -46,7 +46,7 @@ var findMethodIndex = function (json, methodName) {
};
var padLeft = function (string, chars) {
- return Array(chars - string.length + 1).join("0") + string;
+ return new Array(chars - string.length + 1).join("0") + string;
};
var setupInputTypes = function () {
diff --git a/lib/autoprovider.js b/lib/autoprovider.js
index bfbc3ab6e..6311d92ff 100644
--- a/lib/autoprovider.js
+++ b/lib/autoprovider.js
@@ -27,12 +27,10 @@
* if it fails, it uses HttpRpcProvider
*/
-// TODO: work out which of the following two lines it is supposed to be...
-//if (process.env.NODE_ENV !== 'build') {
-if ("build" !== 'build') {/*
+if (process.env.NODE_ENV !== 'build') {
var WebSocket = require('ws'); // jshint ignore:line
var web3 = require('./main.js'); // jshint ignore:line
-*/}
+}
var AutoProvider = function (userOptions) {
if (web3.haveProvider()) {
diff --git a/lib/contract.js b/lib/contract.js
index 17b077484..7db2ac40e 100644
--- a/lib/contract.js
+++ b/lib/contract.js
@@ -20,11 +20,10 @@
* @date 2014
*/
-// TODO: work out which of the following two lines it is supposed to be...
-//if (process.env.NODE_ENV !== 'build') {
-if ("build" !== 'build') {/*
+if (process.env.NODE_ENV !== 'build') {
var web3 = require('./web3'); // jshint ignore:line
-*/}
+}
+
var abi = require('./abi');
var contract = function (address, desc) {
diff --git a/lib/httprpc.js b/lib/httprpc.js
index ee6b5c307..700ce4246 100644
--- a/lib/httprpc.js
+++ b/lib/httprpc.js
@@ -21,11 +21,9 @@
* @date 2014
*/
-// TODO: work out which of the following two lines it is supposed to be...
-//if (process.env.NODE_ENV !== 'build') {
-if ("build" !== "build") {/*
+if (process.env.NODE_ENV !== 'build') {
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
-*/}
+}
var HttpRpcProvider = function (host) {
this.handlers = [];
diff --git a/lib/main.js b/lib/main.js
index b6601132d..c9bcfe205 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -272,7 +272,7 @@ var web3 = {
},
toEth: function(str) {
- var val = typeof str === "string" ? str.indexOf('0x') == 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
+ var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
var unit = 0;
var units = [ 'wei', 'Kwei', 'Mwei', 'Gwei', 'szabo', 'finney', 'ether', 'grand', 'Mether', 'Gether', 'Tether', 'Pether', 'Eether', 'Zether', 'Yether', 'Nether', 'Dether', 'Vether', 'Uether' ];
while (val > 3000 && unit < units.length - 1)
@@ -281,10 +281,14 @@ var web3 = {
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[\.\,])/, function($0, $1, $2) { return $1 + ',' + $2; });
- if (o == s)
+ s = s.replace(/(\d)(\d\d\d[\.\,])/, replaceFunction);
+ if (o === s)
break;
}
return s + ' ' + units[unit];
diff --git a/lib/websocket.js b/lib/websocket.js
index 24a072531..d50aa1f48 100644
--- a/lib/websocket.js
+++ b/lib/websocket.js
@@ -22,11 +22,9 @@
* @date 2014
*/
-// TODO: work out which of the following two lines it is supposed to be...
-//if (process.env.NODE_ENV !== 'build') {
-if ("build" !== "build") {/*
+if (process.env.NODE_ENV !== 'build') {
var WebSocket = require('ws'); // jshint ignore:line
-*/}
+}
var WebSocketProvider = function(host) {
// onmessage handlers