From af9242f4cc382a61bea9142ddbd0cec2e1edf08a Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 6 Jan 2015 13:26:51 +0100 Subject: [PATCH 1/4] fixed gulp build --- dist/ethereum.js | 6 +++--- dist/ethereum.js.map | 4 ++-- dist/ethereum.min.js | 2 +- lib/abi.js | 2 +- lib/autoprovider.js | 6 ++---- lib/contract.js | 7 +++---- lib/httprpc.js | 6 ++---- lib/main.js | 10 +++++++--- lib/websocket.js | 6 ++---- 9 files changed, 23 insertions(+), 26 deletions(-) diff --git a/dist/ethereum.js b/dist/ethereum.js index b64c15b9e2..bce62075b0 100644 --- a/dist/ethereum.js +++ b/dist/ethereum.js @@ -1,5 +1,5 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;oi&&(code=hex.charCodeAt(i),0!==code);i+=2)str+=String.fromCharCode(parseInt(hex.substr(i,2),16));return str},toDecimal:function(val){return parseInt(val,16)},fromAscii:function(str,pad){pad=void 0===pad?32:pad;for(var hex=this.toHex(str);hex.length<2*pad;)hex+="00";return"0x"+hex},eth:{prototype:Object(),watch:function(params){return new Filter(params,ethWatch)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(params){return new Filter(params,shhWatch)}},on:function(event,id,cb){return void 0===web3._events[event]&&(web3._events[event]={}),web3._events[event][id]=cb,this},off:function(event,id){return void 0!==web3._events[event]&&delete web3._events[event][id],this},trigger:function(event,id,data){var cb,callbacks=web3._events[event];callbacks&&callbacks[id]&&(cb=callbacks[id])(data)}};setupMethods(web3.eth,ethMethods()),setupProperties(web3.eth,ethProperties()),setupMethods(web3.db,dbMethods()),setupMethods(web3.shh,shhMethods()),ethWatch={changed:"eth_changed"},setupMethods(ethWatch,ethWatchMethods()),shhWatch={changed:"shh_changed"},setupMethods(shhWatch,shhWatchMethods()),ProviderManager=function(){var self,poll;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,self=this,(poll=function(){self.provider&&self.provider.poll&&self.polls.forEach(function(data){data.data._id=self.id,self.id++,self.provider.poll(data.data,data.id)}),setTimeout(poll,12e3)})()},ProviderManager.prototype.send=function(data,cb){data._id=this.id,cb&&(web3._callbacks[data._id]=cb),data.args=data.args||[],this.id++,void 0!==this.provider?this.provider.send(data):(console.warn("provider is not set"),this.queued.push(data))},ProviderManager.prototype.set=function(provider){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=provider,this.ready=!0},ProviderManager.prototype.sendQueued=function(){for(var i=0;this.queued.length;i++)this.send(this.queued[i])},ProviderManager.prototype.installed=function(){return void 0!==this.provider},ProviderManager.prototype.startPolling=function(data,pollId){this.provider&&this.provider.poll&&this.polls.push({data:data,id:pollId})},ProviderManager.prototype.stopPolling=function(pollId){var i,poll;for(i=this.polls.length;i--;)poll=this.polls[i],poll.id===pollId&&this.polls.splice(i,1)},web3.provider=new ProviderManager,web3.setProvider=function(provider){provider.onmessage=messageHandler,web3.provider.set(provider),web3.provider.sendQueued()},web3.haveProvider=function(){return!!web3.provider.provider},Filter=function(options,impl){this.impl=impl,this.callbacks=[];var self=this;this.promise=impl.newFilter(options),this.promise.then(function(id){self.id=id,web3.on(impl.changed,id,self.trigger.bind(self)),web3.provider.startPolling({call:impl.changed,args:[id]},id)})},Filter.prototype.arrived=function(callback){this.changed(callback)},Filter.prototype.changed=function(callback){var self=this;this.promise.then(function(id){self.callbacks.push(callback)})},Filter.prototype.trigger=function(messages){for(var i=0;ii&&(code=hex.charCodeAt(i),0!==code);i+=2)str+=String.fromCharCode(parseInt(hex.substr(i,2),16));return str},fromAscii:function(str,pad){pad=void 0===pad?32:pad;for(var hex=this.toHex(str);hex.length<2*pad;)hex+="00";return"0x"+hex},toDecimal:function(val){return hexToDec(val.substring(2))},fromDecimal:function(val){return"0x"+decToHex(val)},toEth:function(str){for(var s,replaceFunction,o,val="string"==typeof str?0===str.indexOf("0x")?parseInt(str.substr(2),16):parseInt(str):str,unit=0,units=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];val>3e3&&uniti&&(code=hex.charCodeAt(i),0!==code);i+=2)str+=String.fromCharCode(parseInt(hex.substr(i,2),16));return str},toDecimal:function(val){return parseInt(val,16)},fromAscii:function(str,pad){pad=void 0===pad?32:pad;for(var hex=this.toHex(str);hex.length<2*pad;)hex+=\"00\";return\"0x\"+hex},eth:{prototype:Object(),watch:function(params){return new Filter(params,ethWatch)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(params){return new Filter(params,shhWatch)}},on:function(event,id,cb){return void 0===web3._events[event]&&(web3._events[event]={}),web3._events[event][id]=cb,this},off:function(event,id){return void 0!==web3._events[event]&&delete web3._events[event][id],this},trigger:function(event,id,data){var cb,callbacks=web3._events[event];callbacks&&callbacks[id]&&(cb=callbacks[id])(data)}};setupMethods(web3.eth,ethMethods()),setupProperties(web3.eth,ethProperties()),setupMethods(web3.db,dbMethods()),setupMethods(web3.shh,shhMethods()),ethWatch={changed:\"eth_changed\"},setupMethods(ethWatch,ethWatchMethods()),shhWatch={changed:\"shh_changed\"},setupMethods(shhWatch,shhWatchMethods()),ProviderManager=function(){var self,poll;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,self=this,(poll=function(){self.provider&&self.provider.poll&&self.polls.forEach(function(data){data.data._id=self.id,self.id++,self.provider.poll(data.data,data.id)}),setTimeout(poll,12e3)})()},ProviderManager.prototype.send=function(data,cb){data._id=this.id,cb&&(web3._callbacks[data._id]=cb),data.args=data.args||[],this.id++,void 0!==this.provider?this.provider.send(data):(console.warn(\"provider is not set\"),this.queued.push(data))},ProviderManager.prototype.set=function(provider){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=provider,this.ready=!0},ProviderManager.prototype.sendQueued=function(){for(var i=0;this.queued.length;i++)this.send(this.queued[i])},ProviderManager.prototype.installed=function(){return void 0!==this.provider},ProviderManager.prototype.startPolling=function(data,pollId){this.provider&&this.provider.poll&&this.polls.push({data:data,id:pollId})},ProviderManager.prototype.stopPolling=function(pollId){var i,poll;for(i=this.polls.length;i--;)poll=this.polls[i],poll.id===pollId&&this.polls.splice(i,1)},web3.provider=new ProviderManager,web3.setProvider=function(provider){provider.onmessage=messageHandler,web3.provider.set(provider),web3.provider.sendQueued()},web3.haveProvider=function(){return!!web3.provider.provider},Filter=function(options,impl){this.impl=impl,this.callbacks=[];var self=this;this.promise=impl.newFilter(options),this.promise.then(function(id){self.id=id,web3.on(impl.changed,id,self.trigger.bind(self)),web3.provider.startPolling({call:impl.changed,args:[id]},id)})},Filter.prototype.arrived=function(callback){this.changed(callback)},Filter.prototype.changed=function(callback){var self=this;this.promise.then(function(id){self.callbacks.push(callback)})},Filter.prototype.trigger=function(messages){for(var i=0;ii&&(code=hex.charCodeAt(i),0!==code);i+=2)str+=String.fromCharCode(parseInt(hex.substr(i,2),16));return str},fromAscii:function(str,pad){pad=void 0===pad?32:pad;for(var hex=this.toHex(str);hex.length<2*pad;)hex+=\"00\";return\"0x\"+hex},toDecimal:function(val){return hexToDec(val.substring(2))},fromDecimal:function(val){return\"0x\"+decToHex(val)},toEth:function(str){for(var s,replaceFunction,o,val=\"string\"==typeof str?0===str.indexOf(\"0x\")?parseInt(str.substr(2),16):parseInt(str):str,unit=0,units=[\"wei\",\"Kwei\",\"Mwei\",\"Gwei\",\"szabo\",\"finney\",\"ether\",\"grand\",\"Mether\",\"Gether\",\"Tether\",\"Pether\",\"Eether\",\"Zether\",\"Yether\",\"Nether\",\"Dether\",\"Vether\",\"Uether\"];val>3e3&&unitr&&(e=t.charCodeAt(r),0!==e);r+=2)n+=String.fromCharCode(parseInt(t.substr(r,2),16));return n},toDecimal:function(t){return parseInt(t,16)},fromAscii:function(t,e){e=void 0===e?32:e;for(var n=this.toHex(t);n.length<2*e;)n+="00";return"0x"+n},eth:{prototype:Object(),watch:function(t){return new a(t,o)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(t){return new a(t,i)}},on:function(t,e,n){return void 0===g._events[t]&&(g._events[t]={}),g._events[t][e]=n,this},off:function(t,e){return void 0!==g._events[t]&&delete g._events[t][e],this},trigger:function(t,e,n){var r,o=g._events[t];o&&o[e]&&(r=o[e])(n)}};f(g.eth,u()),v(g.eth,c()),f(g.db,l()),f(g.shh,h()),o={changed:"eth_changed"},f(o,p()),i={changed:"shh_changed"},f(i,d()),s=function(){var t,e;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,t=this,(e=function(){t.provider&&t.provider.poll&&t.polls.forEach(function(e){e.data._id=t.id,t.id++,t.provider.poll(e.data,e.id)}),setTimeout(e,12e3)})()},s.prototype.send=function(t,e){t._id=this.id,e&&(g._callbacks[t._id]=e),t.args=t.args||[],this.id++,void 0!==this.provider?this.provider.send(t):(console.warn("provider is not set"),this.queued.push(t))},s.prototype.set=function(t){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=t,this.ready=!0},s.prototype.sendQueued=function(){for(var t=0;this.queued.length;t++)this.send(this.queued[t])},s.prototype.installed=function(){return void 0!==this.provider},s.prototype.startPolling=function(t,e){this.provider&&this.provider.poll&&this.polls.push({data:t,id:e})},s.prototype.stopPolling=function(t){var e,n;for(e=this.polls.length;e--;)n=this.polls[e],n.id===t&&this.polls.splice(e,1)},g.provider=new s,g.setProvider=function(t){t.onmessage=r,g.provider.set(t),g.provider.sendQueued()},g.haveProvider=function(){return!!g.provider.provider},a=function(t,e){this.impl=e,this.callbacks=[];var n=this;this.promise=e.newFilter(t),this.promise.then(function(t){n.id=t,g.on(e.changed,t,n.trigger.bind(n)),g.provider.startPolling({call:e.changed,args:[t]},t)})},a.prototype.arrived=function(t){this.changed(t)},a.prototype.changed=function(t){var e=this;this.promise.then(function(){e.callbacks.push(t)})},a.prototype.trigger=function(t){for(var e=0;er&&(e=t.charCodeAt(r),0!==e);r+=2)n+=String.fromCharCode(parseInt(t.substr(r,2),16));return n},fromAscii:function(t,e){e=void 0===e?32:e;for(var n=this.toHex(t);n.length<2*e;)n+="00";return"0x"+n},toDecimal:function(t){return m(t.substring(2))},fromDecimal:function(t){return"0x"+b(t)},toEth:function(t){for(var e,n,r,o="string"==typeof t?0===t.indexOf("0x")?parseInt(t.substr(2),16):parseInt(t):t,i=0,s=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];o>3e3&&i 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 24a0725313..d50aa1f48f 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 From 8c1b26889ae90211e01ba2c364aa5d245d6f232f Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 6 Jan 2015 13:27:43 +0100 Subject: [PATCH 2/4] renamed example/index.html -> example/balance.html --- example/{index.html => balance.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename example/{index.html => balance.html} (100%) diff --git a/example/index.html b/example/balance.html similarity index 100% rename from example/index.html rename to example/balance.html From a2a77172a688b00e08191fe715c62335120b28ac Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 6 Jan 2015 13:32:04 +0100 Subject: [PATCH 3/4] bring back todos --- lib/autoprovider.js | 1 + lib/contract.js | 1 + lib/httprpc.js | 1 + lib/websocket.js | 1 + 4 files changed, 4 insertions(+) diff --git a/lib/autoprovider.js b/lib/autoprovider.js index 6311d92ff5..2f0a3e6279 100644 --- a/lib/autoprovider.js +++ b/lib/autoprovider.js @@ -27,6 +27,7 @@ * if it fails, it uses HttpRpcProvider */ +// TODO: is these line is supposed to be here? if (process.env.NODE_ENV !== 'build') { var WebSocket = require('ws'); // jshint ignore:line var web3 = require('./main.js'); // jshint ignore:line diff --git a/lib/contract.js b/lib/contract.js index 7db2ac40e3..b103390034 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -20,6 +20,7 @@ * @date 2014 */ +// TODO: is these line is supposed to be here? if (process.env.NODE_ENV !== 'build') { var web3 = require('./web3'); // jshint ignore:line } diff --git a/lib/httprpc.js b/lib/httprpc.js index 700ce42466..d315201f1c 100644 --- a/lib/httprpc.js +++ b/lib/httprpc.js @@ -21,6 +21,7 @@ * @date 2014 */ +// TODO: is these line is supposed to be here? if (process.env.NODE_ENV !== 'build') { var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line } diff --git a/lib/websocket.js b/lib/websocket.js index d50aa1f48f..ddb44aed5d 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -22,6 +22,7 @@ * @date 2014 */ +// TODO: is these line is supposed to be here? if (process.env.NODE_ENV !== 'build') { var WebSocket = require('ws'); // jshint ignore:line } From b6232cfdd1f23447d900728be0b142d05aca0009 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 6 Jan 2015 13:37:02 +0100 Subject: [PATCH 4/4] fixed tabs --- lib/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index c9bcfe205c..b240bdae27 100644 --- a/lib/main.js +++ b/lib/main.js @@ -281,9 +281,9 @@ 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; - }; + var replaceFunction = function($0, $1, $2) { + return $1 + ',' + $2; + }; while (true) { var o = s;