From 0ab672bb6fef28258f370b268e6773c3f93ed68b Mon Sep 17 00:00:00 2001 From: Fabian Vogelsteller Date: Thu, 30 Mar 2017 18:43:41 +0200 Subject: [PATCH 01/13] added preloader isolation --- interface/client/templates/views/webview.html | 2 +- modules/ipc/ipcProviderBackend.js | 1 - modules/preloader/browser.js | 128 ++++++- modules/preloader/include/mistAPI.js | 1 + modules/preloader/injected/BigNumber.js | 9 + .../preloader/injected/EthereumProvider.js | 170 ++++++++++ modules/preloader/injected/EventEmitter3.js | 318 ++++++++++++++++++ modules/preloader/injected/mistAPI.js | 270 +++++++++++++++ modules/preloader/wallet.js | 4 +- 9 files changed, 884 insertions(+), 19 deletions(-) create mode 100644 modules/preloader/injected/BigNumber.js create mode 100644 modules/preloader/injected/EthereumProvider.js create mode 100644 modules/preloader/injected/EventEmitter3.js create mode 100644 modules/preloader/injected/mistAPI.js diff --git a/interface/client/templates/views/webview.html b/interface/client/templates/views/webview.html index a95faa40c..2f9aa6cb2 100644 --- a/interface/client/templates/views/webview.html +++ b/interface/client/templates/views/webview.html @@ -3,7 +3,7 @@ {{#if $eq _id "tests"}} {{else}} - + {{/if}} diff --git a/modules/ipc/ipcProviderBackend.js b/modules/ipc/ipcProviderBackend.js index ee9bb46d3..38ff40e6f 100644 --- a/modules/ipc/ipcProviderBackend.js +++ b/modules/ipc/ipcProviderBackend.js @@ -99,7 +99,6 @@ class IpcProviderBackend { log.debug(`Destroy socket connection due to event: ${ev}, id=${ownerId}`); socket.destroy().finally(() => { - if (!owner.isDestroyed()) { owner.send(`ipcProvider-${ev}`, JSON.stringify(data)); } }); diff --git a/modules/preloader/browser.js b/modules/preloader/browser.js index 86e1a3f75..54139db8f 100644 --- a/modules/preloader/browser.js +++ b/modules/preloader/browser.js @@ -2,12 +2,122 @@ @module preloader browser */ require('./include/common')('browser'); -require('./include/ethereumProvider.js'); -const { ipcRenderer } = require('electron'); +const { ipcRenderer, webFrame, remote } = require('electron'); const mist = require('./include/mistAPI.js'); require('./include/getFavicon.js'); require('./include/getMetaTags.js'); require('./include/setBasePath')('interface'); +const packageJson = require('./../../package.json'); +const fs = remote.require('fs'); +const path = remote.require('path'); + + +// Wait for post messages +window.addEventListener('message', function message(event) { + var data; + try { + data = JSON.parse(event.data); + } catch(e){ + data = event.data; + } + + + if (typeof data !== 'object') { + return; + } + + // EthereumProvider: connect + if (data.type === 'create') { + ipcRenderer.send('ipcProvider-create'); + + // EthereumProvider: write + } else if (data.type === 'write') { + // only accept valid JSON rpc requests + if(!Object.prototype.hasOwnProperty.call(data.message, 'method') || + !Object.prototype.hasOwnProperty.call(data.message, 'id') || + !Object.prototype.hasOwnProperty.call(data.message, 'params') || + !Object.prototype.hasOwnProperty.call(data.message, 'jsonrpc')) { + return; + } + + // make sure we only send allowed properties + ipcRenderer.send('ipcProvider-write', JSON.stringify({ + jsonrpc: data.message.jsonrpc, + id: data.message.id, + method: data.message.method, + params: data.message.params + })); + + // mistAPI + } else if (/^mistAPI_[a-z]/i.test(data.type)) { + + if (data.type === 'mistAPI_requestAccount') { + ipcRenderer.send(data.type, data.message); + } else { + ipcRenderer.sendToHost(data.type, data.message); + } + } + + +}); + +var postMessage = function(payload) { + if(typeof payload === 'object') { + payload = JSON.stringify(payload); + } + + window.postMessage(payload, (!location.origin || location.origin === "null" ) ? '*' : location.origin); +}; + +// custom Events +['uiAction_windowMessage', 'mistAPI_callMenuFunction'].forEach(function (type) { + ipcRenderer.on(type, function onIpcRenderer(e, result) { + + // this type needs special packaging + if(type === 'uiAction_windowMessage') { + result = { + type: arguments[1], + error: arguments[2], + value: arguments[3] + }; + } + + postMessage({ + type: type, + message: result + }); + }); +}); + +// add IPCbackend events +['data', 'error', 'end', 'timeout', 'connect'].forEach(function (type) { + ipcRenderer.on(`ipcProvider-`+ type, function onIpcRenderer(e, result) { + postMessage({ + type: type, + message: JSON.parse(result) + }); + }); +}); + + +// load ethereumProvider +const bignumber = fs.readFileSync(path.resolve('./modules/preloader/injected/BigNumber.js')).toString(); +const eventEmitter3 = fs.readFileSync(path.resolve('./modules/preloader/injected/EventEmitter3.js')).toString(); +let mistAPI = fs.readFileSync(path.resolve('./modules/preloader/injected/mistAPI.js')).toString(); +const ethereumProvider = fs.readFileSync(path.resolve('./modules/preloader/injected/EthereumProvider.js')).toString(); + +mistAPI = mistAPI.replace('__version__', packageJson.version) + .replace('__license__', packageJson.license) + .replace('__platform__', process.platform) + .replace('__solidityVersion__', String(packageJson.dependencies.solc).match(/\d+\.\d+\.\d+/)[0]); + +webFrame.executeJavaScript( + mistAPI + + bignumber + + eventEmitter3 + + ethereumProvider +); + // notifiy the tab to store the webview id ipcRenderer.sendToHost('setWebviewId'); @@ -15,18 +125,4 @@ ipcRenderer.sendToHost('setWebviewId'); // destroy the old socket ipcRenderer.send('ipcProvider-destroy'); -// Security -process.on('loaded', function () { - Object.freeze(window.JSON); - // Object.freeze(window.Function); - // Object.freeze(window.Function.prototype); - // Object.freeze(window.Array); - // Object.freeze(window.Array.prototype); -}); - - -window.mist = mist(); -// prevent overwriting the Dapps Web3 -delete global.Web3; -delete window.Web3; \ No newline at end of file diff --git a/modules/preloader/include/mistAPI.js b/modules/preloader/include/mistAPI.js index d931ac38a..a542a3c71 100644 --- a/modules/preloader/include/mistAPI.js +++ b/modules/preloader/include/mistAPI.js @@ -205,6 +205,7 @@ module.exports = () => { }); ipcRenderer.on('uiAction_windowMessage', (e, type, error, value) => { + console.log('uiAction_windowMessage',type, error, value); if (mist.callbacks[type]) { mist.callbacks[type].forEach((cb) => { cb(error, value); diff --git a/modules/preloader/injected/BigNumber.js b/modules/preloader/injected/BigNumber.js new file mode 100644 index 000000000..05b0e781e --- /dev/null +++ b/modules/preloader/injected/BigNumber.js @@ -0,0 +1,9 @@ + +(function () { + +/* bignumber.js v4.0.0 https://github.com/MikeMcl/bignumber.js/LICENCE */ +!function(e){"use strict";function n(e){function a(e,n){var t,r,i,o,u,s,l=this;if(!(l instanceof a))return z&&x(26,"constructor call without new",e),new a(e,n);if(null!=n&&V(n,2,64,C,"base")){if(n=0|n,s=e+"",10==n)return l=new a(e instanceof a?e:s),I(l,B+l.e+1,P);if((o="number"==typeof e)&&0*e!=0||!new RegExp("^-?"+(t="["+v.slice(0,n)+"]+")+"(?:\\."+t+")?$",37>n?"i":"").test(s))return U(l,s,o,n);o?(l.s=0>1/e?(s=s.slice(1),-1):1,z&&s.replace(/^0\.0*|\./,"").length>15&&x(C,w,e),o=!1):l.s=45===s.charCodeAt(0)?(s=s.slice(1),-1):1,s=A(s,10,n,l.s)}else{if(e instanceof a)return l.s=e.s,l.e=e.e,l.c=(e=e.c)?e.slice():e,void(C=0);if((o="number"==typeof e)&&0*e==0){if(l.s=0>1/e?(e=-e,-1):1,e===~~e){for(r=0,i=e;i>=10;i/=10,r++);return l.e=r,l.c=[e],void(C=0)}s=e+""}else{if(!h.test(s=e+""))return U(l,s,o);l.s=45===s.charCodeAt(0)?(s=s.slice(1),-1):1}}for((r=s.indexOf("."))>-1&&(s=s.replace(".","")),(i=s.search(/e/i))>0?(0>r&&(r=i),r+=+s.slice(i+1),s=s.substring(0,i)):0>r&&(r=s.length),i=0;48===s.charCodeAt(i);i++);for(u=s.length;48===s.charCodeAt(--u););if(s=s.slice(i,u+1))if(u=s.length,o&&z&&u>15&&(e>y||e!==p(e))&&x(C,w,l.s*e),r=r-i-1,r>G)l.c=l.e=null;else if($>r)l.c=[l.e=0];else{if(l.e=r,l.c=[],i=(r+1)%b,0>r&&(i+=b),u>i){for(i&&l.c.push(+s.slice(0,i)),u-=b;u>i;)l.c.push(+s.slice(i,i+=b));s=s.slice(i),i=b-s.length}else i-=u;for(;i--;s+="0");l.c.push(+s)}else l.c=[l.e=0];C=0}function A(e,n,t,i){var o,u,l,c,h,g,p,d=e.indexOf("."),m=B,w=P;for(37>t&&(e=e.toLowerCase()),d>=0&&(l=W,W=0,e=e.replace(".",""),p=new a(t),h=p.pow(e.length-d),W=l,p.c=s(f(r(h.c),h.e),10,n),p.e=p.c.length),g=s(e,t,n),u=l=g.length;0==g[--l];g.pop());if(!g[0])return"0";if(0>d?--u:(h.c=g,h.e=u,h.s=i,h=L(h,p,m,w,n),g=h.c,c=h.r,u=h.e),o=u+m+1,d=g[o],l=n/2,c=c||0>o||null!=g[o+1],c=4>w?(null!=d||c)&&(0==w||w==(h.s<0?3:2)):d>l||d==l&&(4==w||c||6==w&&1&g[o-1]||w==(h.s<0?8:7)),1>o||!g[0])e=c?f("1",-m):"0";else{if(g.length=o,c)for(--n;++g[--o]>n;)g[o]=0,o||(++u,g.unshift(1));for(l=g.length;!g[--l];);for(d=0,e="";l>=d;e+=v.charAt(g[d++]));e=f(e,u)}return e}function E(e,n,t,i){var o,u,s,c,h;if(t=null!=t&&V(t,0,8,i,m)?0|t:P,!e.c)return e.toString();if(o=e.c[0],s=e.e,null==n)h=r(e.c),h=19==i||24==i&&q>=s?l(h,s):f(h,s);else if(e=I(new a(e),n,t),u=e.e,h=r(e.c),c=h.length,19==i||24==i&&(u>=n||q>=u)){for(;n>c;h+="0",c++);h=l(h,u)}else if(n-=s,h=f(h,u),u+1>c){if(--n>0)for(h+=".";n--;h+="0");}else if(n+=u-c,n>0)for(u+1==c&&(h+=".");n--;h+="0");return e.s<0&&o?"-"+h:h}function D(e,n){var t,r,i=0;for(u(e[0])&&(e=e[0]),t=new a(e[0]);++ie||e>t||e!=c(e))&&x(r,(i||"decimal places")+(n>e||e>t?" out of range":" not an integer"),e),!0}function _(e,n,t){for(var r=1,i=n.length;!n[--i];n.pop());for(i=n[0];i>=10;i/=10,r++);return(t=r+t*b-1)>G?e.c=e.e=null:$>t?e.c=[e.e=0]:(e.e=t,e.c=n),e}function x(e,n,t){var r=new Error(["new BigNumber","cmp","config","div","divToInt","eq","gt","gte","lt","lte","minus","mod","plus","precision","random","round","shift","times","toDigits","toExponential","toFixed","toFormat","toFraction","pow","toPrecision","toString","BigNumber"][e]+"() "+n+": "+t);throw r.name="BigNumber Error",C=0,r}function I(e,n,t,r){var i,o,u,s,l,f,c,a=e.c,h=O;if(a){e:{for(i=1,s=a[0];s>=10;s/=10,i++);if(o=n-i,0>o)o+=b,u=n,l=a[f=0],c=l/h[i-u-1]%10|0;else if(f=g((o+1)/b),f>=a.length){if(!r)break e;for(;a.length<=f;a.push(0));l=c=0,i=1,o%=b,u=o-b+1}else{for(l=s=a[f],i=1;s>=10;s/=10,i++);o%=b,u=o-b+i,c=0>u?0:l/h[i-u-1]%10|0}if(r=r||0>n||null!=a[f+1]||(0>u?l:l%h[i-u-1]),r=4>t?(c||r)&&(0==t||t==(e.s<0?3:2)):c>5||5==c&&(4==t||r||6==t&&(o>0?u>0?l/h[i-u]:0:a[f-1])%10&1||t==(e.s<0?8:7)),1>n||!a[0])return a.length=0,r?(n-=e.e+1,a[0]=h[(b-n%b)%b],e.e=-n||0):a[0]=e.e=0,e;if(0==o?(a.length=f,s=1,f--):(a.length=f+1,s=h[b-o],a[f]=u>0?p(l/h[i-u]%h[u])*s:0),r)for(;;){if(0==f){for(o=1,u=a[0];u>=10;u/=10,o++);for(u=a[0]+=s,s=1;u>=10;u/=10,s++);o!=s&&(e.e++,a[0]==N&&(a[0]=1));break}if(a[f]+=s,a[f]!=N)break;a[f--]=0,s=1}for(o=a.length;0===a[--o];a.pop());}e.e>G?e.c=e.e=null:e.e<$&&(e.c=[e.e=0])}return e}var L,U,C=0,M=a.prototype,T=new a(1),B=20,P=4,q=-7,k=21,$=-1e7,G=1e7,z=!0,V=F,j=!1,H=1,W=0,J={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0};return a.another=n,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=a.set=function(){var e,n,t=0,r={},i=arguments,s=i[0],l=s&&"object"==typeof s?function(){return s.hasOwnProperty(n)?null!=(e=s[n]):void 0}:function(){return i.length>t?null!=(e=i[t++]):void 0};return l(n="DECIMAL_PLACES")&&V(e,0,S,2,n)&&(B=0|e),r[n]=B,l(n="ROUNDING_MODE")&&V(e,0,8,2,n)&&(P=0|e),r[n]=P,l(n="EXPONENTIAL_AT")&&(u(e)?V(e[0],-S,0,2,n)&&V(e[1],0,S,2,n)&&(q=0|e[0],k=0|e[1]):V(e,-S,S,2,n)&&(q=-(k=0|(0>e?-e:e)))),r[n]=[q,k],l(n="RANGE")&&(u(e)?V(e[0],-S,-1,2,n)&&V(e[1],1,S,2,n)&&($=0|e[0],G=0|e[1]):V(e,-S,S,2,n)&&(0|e?$=-(G=0|(0>e?-e:e)):z&&x(2,n+" cannot be zero",e))),r[n]=[$,G],l(n="ERRORS")&&(e===!!e||1===e||0===e?(C=0,V=(z=!!e)?F:o):z&&x(2,n+d,e)),r[n]=z,l(n="CRYPTO")&&(e===!0||e===!1||1===e||0===e?e?(e="undefined"==typeof crypto,!e&&crypto&&(crypto.getRandomValues||crypto.randomBytes)?j=!0:z?x(2,"crypto unavailable",e?void 0:crypto):j=!1):j=!1:z&&x(2,n+d,e)),r[n]=j,l(n="MODULO_MODE")&&V(e,0,9,2,n)&&(H=0|e),r[n]=H,l(n="POW_PRECISION")&&V(e,0,S,2,n)&&(W=0|e),r[n]=W,l(n="FORMAT")&&("object"==typeof e?J=e:z&&x(2,n+" not an object",e)),r[n]=J,r},a.max=function(){return D(arguments,M.lt)},a.min=function(){return D(arguments,M.gt)},a.random=function(){var e=9007199254740992,n=Math.random()*e&2097151?function(){return p(Math.random()*e)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(e){var t,r,i,o,u,s=0,l=[],f=new a(T);if(e=null!=e&&V(e,0,S,14)?0|e:B,o=g(e/b),j)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));o>s;)u=131072*t[s]+(t[s+1]>>>11),u>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[s]=r[0],t[s+1]=r[1]):(l.push(u%1e14),s+=2);s=o/2}else if(crypto.randomBytes){for(t=crypto.randomBytes(o*=7);o>s;)u=281474976710656*(31&t[s])+1099511627776*t[s+1]+4294967296*t[s+2]+16777216*t[s+3]+(t[s+4]<<16)+(t[s+5]<<8)+t[s+6],u>=9e15?crypto.randomBytes(7).copy(t,s):(l.push(u%1e14),s+=7);s=o/7}else j=!1,z&&x(14,"crypto unavailable",crypto);if(!j)for(;o>s;)u=n(),9e15>u&&(l[s++]=u%1e14);for(o=l[--s],e%=b,o&&e&&(u=O[b-e],l[s]=p(o/u)*u);0===l[s];l.pop(),s--);if(0>s)l=[i=0];else{for(i=-1;0===l[0];l.shift(),i-=b);for(s=1,u=l[0];u>=10;u/=10,s++);b>s&&(i-=b-s)}return f.e=i,f.c=l,f}}(),L=function(){function e(e,n,t){var r,i,o,u,s=0,l=e.length,f=n%R,c=n/R|0;for(e=e.slice();l--;)o=e[l]%R,u=e[l]/R|0,r=c*o+u*f,i=f*o+r%R*R+s,s=(i/t|0)+(r/R|0)+c*u,e[l]=i%t;return s&&e.unshift(s),e}function n(e,n,t,r){var i,o;if(t!=r)o=t>r?1:-1;else for(i=o=0;t>i;i++)if(e[i]!=n[i]){o=e[i]>n[i]?1:-1;break}return o}function r(e,n,t,r){for(var i=0;t--;)e[t]-=i,i=e[t]1;e.shift());}return function(i,o,u,s,l){var f,c,h,g,d,m,w,v,y,O,R,S,A,E,D,F,_,x=i.s==o.s?1:-1,L=i.c,U=o.c;if(!(L&&L[0]&&U&&U[0]))return new a(i.s&&o.s&&(L?!U||L[0]!=U[0]:U)?L&&0==L[0]||!U?0*x:x/0:NaN);for(v=new a(x),y=v.c=[],c=i.e-o.e,x=u+c+1,l||(l=N,c=t(i.e/b)-t(o.e/b),x=x/b|0),h=0;U[h]==(L[h]||0);h++);if(U[h]>(L[h]||0)&&c--,0>x)y.push(1),g=!0;else{for(E=L.length,F=U.length,h=0,x+=2,d=p(l/(U[0]+1)),d>1&&(U=e(U,d,l),L=e(L,d,l),F=U.length,E=L.length),A=F,O=L.slice(0,F),R=O.length;F>R;O[R++]=0);_=U.slice(),_.unshift(0),D=U[0],U[1]>=l/2&&D++;do{if(d=0,f=n(U,O,F,R),0>f){if(S=O[0],F!=R&&(S=S*l+(O[1]||0)),d=p(S/D),d>1)for(d>=l&&(d=l-1),m=e(U,d,l),w=m.length,R=O.length;1==n(m,O,w,R);)d--,r(m,w>F?_:U,w,l),w=m.length,f=1;else 0==d&&(f=d=1),m=U.slice(),w=m.length;if(R>w&&m.unshift(0),r(O,m,R,l),R=O.length,-1==f)for(;n(U,O,F,R)<1;)d++,r(O,R>F?_:U,R,l),R=O.length}else 0===f&&(d++,O=[0]);y[h++]=d,O[0]?O[R++]=L[A]||0:(O=[L[A]],R=1)}while((A++=10;x/=10,h++);I(v,u+(v.e=h+c*b-1)+1,s,g)}else v.e=c,v.r=+g;return v}}(),U=function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,n=/^([^.]+)\.$/,t=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(o,u,s,l){var f,c=s?u:u.replace(i,"");if(r.test(c))o.s=isNaN(c)?null:0>c?-1:1;else{if(!s&&(c=c.replace(e,function(e,n,t){return f="x"==(t=t.toLowerCase())?16:"b"==t?2:8,l&&l!=f?e:n}),l&&(f=l,c=c.replace(n,"$1").replace(t,"0.$1")),u!=c))return new a(c,f);z&&x(C,"not a"+(l?" base "+l:"")+" number",u),o.s=null}o.c=o.e=null,C=0}}(),M.absoluteValue=M.abs=function(){var e=new a(this);return e.s<0&&(e.s=1),e},M.ceil=function(){return I(new a(this),this.e+1,2)},M.comparedTo=M.cmp=function(e,n){return C=1,i(this,new a(e,n))},M.decimalPlaces=M.dp=function(){var e,n,r=this.c;if(!r)return null;if(e=((n=r.length-1)-t(this.e/b))*b,n=r[n])for(;n%10==0;n/=10,e--);return 0>e&&(e=0),e},M.dividedBy=M.div=function(e,n){return C=3,L(this,new a(e,n),B,P)},M.dividedToIntegerBy=M.divToInt=function(e,n){return C=4,L(this,new a(e,n),0,1)},M.equals=M.eq=function(e,n){return C=5,0===i(this,new a(e,n))},M.floor=function(){return I(new a(this),this.e+1,3)},M.greaterThan=M.gt=function(e,n){return C=6,i(this,new a(e,n))>0},M.greaterThanOrEqualTo=M.gte=function(e,n){return C=7,1===(n=i(this,new a(e,n)))||0===n},M.isFinite=function(){return!!this.c},M.isInteger=M.isInt=function(){return!!this.c&&t(this.e/b)>this.c.length-2},M.isNaN=function(){return!this.s},M.isNegative=M.isNeg=function(){return this.s<0},M.isZero=function(){return!!this.c&&0==this.c[0]},M.lessThan=M.lt=function(e,n){return C=8,i(this,new a(e,n))<0},M.lessThanOrEqualTo=M.lte=function(e,n){return C=9,-1===(n=i(this,new a(e,n)))||0===n},M.minus=M.sub=function(e,n){var r,i,o,u,s=this,l=s.s;if(C=10,e=new a(e,n),n=e.s,!l||!n)return new a(NaN);if(l!=n)return e.s=-n,s.plus(e);var f=s.e/b,c=e.e/b,h=s.c,g=e.c;if(!f||!c){if(!h||!g)return h?(e.s=-n,e):new a(g?s:NaN);if(!h[0]||!g[0])return g[0]?(e.s=-n,e):new a(h[0]?s:3==P?-0:0)}if(f=t(f),c=t(c),h=h.slice(),l=f-c){for((u=0>l)?(l=-l,o=h):(c=f,o=g),o.reverse(),n=l;n--;o.push(0));o.reverse()}else for(i=(u=(l=h.length)<(n=g.length))?l:n,l=n=0;i>n;n++)if(h[n]!=g[n]){u=h[n]0)for(;n--;h[r++]=0);for(n=N-1;i>l;){if(h[--i]0?(s=u,r=f):(o=-o,r=l),r.reverse();o--;r.push(0));r.reverse()}for(o=l.length,n=f.length,0>o-n&&(r=f,f=l,l=r,n=o),o=0;n;)o=(l[--n]=l[n]+f[n]+o)/N|0,l[n]=N===l[n]?0:l[n]%N;return o&&(l.unshift(o),++s),_(e,l,s)},M.precision=M.sd=function(e){var n,t,r=this,i=r.c;if(null!=e&&e!==!!e&&1!==e&&0!==e&&(z&&x(13,"argument"+d,e),e!=!!e&&(e=null)),!i)return null;if(t=i.length-1,n=t*b+1,t=i[t]){for(;t%10==0;t/=10,n--);for(t=i[0];t>=10;t/=10,n++);}return e&&r.e+1>n&&(n=r.e+1),n},M.round=function(e,n){var t=new a(this);return(null==e||V(e,0,S,15))&&I(t,~~e+this.e+1,null!=n&&V(n,0,8,15,m)?0|n:P),t},M.shift=function(e){var n=this;return V(e,-y,y,16,"argument")?n.times("1e"+c(e)):new a(n.c&&n.c[0]&&(-y>e||e>y)?n.s*(0>e?0:1/0):n)},M.squareRoot=M.sqrt=function(){var e,n,i,o,u,s=this,l=s.c,f=s.s,c=s.e,h=B+4,g=new a("0.5");if(1!==f||!l||!l[0])return new a(!f||0>f&&(!l||l[0])?NaN:l?s:1/0);if(f=Math.sqrt(+s),0==f||f==1/0?(n=r(l),(n.length+c)%2==0&&(n+="0"),f=Math.sqrt(n),c=t((c+1)/2)-(0>c||c%2),f==1/0?n="1e"+c:(n=f.toExponential(),n=n.slice(0,n.indexOf("e")+1)+c),i=new a(n)):i=new a(f+""),i.c[0])for(c=i.e,f=c+h,3>f&&(f=0);;)if(u=i,i=g.times(u.plus(L(s,u,h,1))),r(u.c).slice(0,f)===(n=r(i.c)).slice(0,f)){if(i.ef&&(m=O,O=S,S=m,o=f,f=g,g=o),o=f+g,m=[];o--;m.push(0));for(w=N,v=R,o=g;--o>=0;){for(r=0,p=S[o]%v,d=S[o]/v|0,s=f,u=o+s;u>o;)c=O[--s]%v,h=O[s]/v|0,l=d*c+h*p,c=p*c+l%v*v+m[u]+r,r=(c/w|0)+(l/v|0)+d*h,m[u--]=c%w;m[u]=r}return r?++i:m.shift(),_(e,m,i)},M.toDigits=function(e,n){var t=new a(this);return e=null!=e&&V(e,1,S,18,"precision")?0|e:null,n=null!=n&&V(n,0,8,18,m)?0|n:P,e?I(t,e,n):t},M.toExponential=function(e,n){return E(this,null!=e&&V(e,0,S,19)?~~e+1:null,n,19)},M.toFixed=function(e,n){return E(this,null!=e&&V(e,0,S,20)?~~e+this.e+1:null,n,20)},M.toFormat=function(e,n){var t=E(this,null!=e&&V(e,0,S,21)?~~e+this.e+1:null,n,21);if(this.c){var r,i=t.split("."),o=+J.groupSize,u=+J.secondaryGroupSize,s=J.groupSeparator,l=i[0],f=i[1],c=this.s<0,a=c?l.slice(1):l,h=a.length;if(u&&(r=o,o=u,u=r,h-=r),o>0&&h>0){for(r=h%o||o,l=a.substr(0,r);h>r;r+=o)l+=s+a.substr(r,o);u>0&&(l+=s+a.slice(r)),c&&(l="-"+l)}t=f?l+J.decimalSeparator+((u=+J.fractionGroupSize)?f.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+J.fractionGroupSeparator):f):l}return t},M.toFraction=function(e){var n,t,i,o,u,s,l,f,c,h=z,g=this,p=g.c,d=new a(T),m=t=new a(T),w=l=new a(T);if(null!=e&&(z=!1,s=new a(e),z=h,(!(h=s.isInt())||s.lt(T))&&(z&&x(22,"max denominator "+(h?"out of range":"not an integer"),e),e=!h&&s.c&&I(s,s.e+1,1).gte(T)?s:null)),!p)return g.toString();for(c=r(p),o=d.e=c.length-g.e-1,d.c[0]=O[(u=o%b)<0?b+u:u],e=!e||s.cmp(d)>0?o>0?d:m:s,u=G,G=1/0,s=new a(c),l.c[0]=0;f=L(s,d,0,1),i=t.plus(f.times(w)),1!=i.cmp(e);)t=w,w=i,m=l.plus(f.times(i=m)),l=i,d=s.minus(f.times(i=d)),s=i;return i=L(e.minus(t),w,0,1),l=l.plus(i.times(m)),t=t.plus(i.times(w)),l.s=m.s=g.s,o*=2,n=L(m,w,o,P).minus(g).abs().cmp(L(l,t,o,P).minus(g).abs())<1?[m.toString(),w.toString()]:[l.toString(),t.toString()],G=u,n},M.toNumber=function(){return+this},M.toPower=M.pow=function(e,n){var t,r,i,o=p(0>e?-e:+e),u=this;if(null!=n&&(C=23,n=new a(n)),!V(e,-y,y,23,"exponent")&&(!isFinite(e)||o>y&&(e/=0)||parseFloat(e)!=e&&!(e=NaN))||0==e)return t=Math.pow(+u,e),new a(n?t%n:t);for(n?e>1&&u.gt(T)&&u.isInt()&&n.gt(T)&&n.isInt()?u=u.mod(n):(i=n,n=null):W&&(t=g(W/b+2)),r=new a(T);;){if(o%2){if(r=r.times(u),!r.c)break;t?r.c.length>t&&(r.c.length=t):n&&(r=r.mod(n))}if(o=p(o/2),!o)break;u=u.times(u),t?u.c&&u.c.length>t&&(u.c.length=t):n&&(u=u.mod(n))}return n?r:(0>e&&(r=T.div(r)),i?r.mod(i):t?I(r,W,P):r)},M.toPrecision=function(e,n){return E(this,null!=e&&V(e,1,S,24,"precision")?0|e:null,n,24)},M.toString=function(e){var n,t=this,i=t.s,o=t.e;return null===o?i?(n="Infinity",0>i&&(n="-"+n)):n="NaN":(n=r(t.c),n=null!=e&&V(e,2,64,25,"base")?A(f(n,o),0|e,10,i):q>=o||o>=k?l(n,o):f(n,o),0>i&&t.c[0]&&(n="-"+n)),n},M.truncated=M.trunc=function(){return I(new a(this),this.e+1,1)},M.valueOf=M.toJSON=function(){var e,n=this,t=n.e;return null===t?n.toString():(e=r(n.c),e=q>=t||t>=k?l(e,t):f(e,t),n.s<0?"-"+e:e)},M.isBigNumber=!0,null!=e&&a.config(e),a}function t(e){var n=0|e;return e>0||e===n?n:n-1}function r(e){for(var n,t,r=1,i=e.length,o=e[0]+"";i>r;){for(n=e[r++]+"",t=b-n.length;t--;n="0"+n);o+=n}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function i(e,n){var t,r,i=e.c,o=n.c,u=e.s,s=n.s,l=e.e,f=n.e;if(!u||!s)return null;if(t=i&&!i[0],r=o&&!o[0],t||r)return t?r?0:-s:u;if(u!=s)return u;if(t=0>u,r=l==f,!i||!o)return r?0:!i^t?1:-1;if(!r)return l>f^t?1:-1;for(s=(l=i.length)<(f=o.length)?l:f,u=0;s>u;u++)if(i[u]!=o[u])return i[u]>o[u]^t?1:-1;return l==f?0:l>f^t?1:-1}function o(e,n,t){return(e=c(e))>=n&&t>=e}function u(e){return"[object Array]"==Object.prototype.toString.call(e)}function s(e,n,t){for(var r,i,o=[0],u=0,s=e.length;s>u;){for(i=o.length;i--;o[i]*=n);for(o[r=0]+=v.indexOf(e.charAt(u++));rt-1&&(null==o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/t|0,o[r]%=t)}return o.reverse()}function l(e,n){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(0>n?"e":"e+")+n}function f(e,n){var t,r;if(0>n){for(r="0.";++n;r+="0");e=r+e}else if(t=e.length,++n>t){for(r="0",n-=t;--n;r+="0");e+=r}else t>n&&(e=e.slice(0,n)+"."+e.slice(n));return e}function c(e){return e=parseFloat(e),0>e?g(e):p(e)}var a,h=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,g=Math.ceil,p=Math.floor,d=" not a boolean or binary digit",m="rounding mode",w="number type has more than 15 significant digits",v="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",N=1e14,b=14,y=9007199254740991,O=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],R=1e7,S=1e9;a=n(),a["default"]=a.BigNumber=a,"function"==typeof define&&define.amd?define(function(){return a}):"undefined"!=typeof module&&module.exports?module.exports=a:(e||(e="undefined"!=typeof self?self:Function("return this")()),e.BigNumber=a)}(this); +//# sourceMappingURL=bignumber.js.map + + window.BigNumber = BigNumber; +})(); diff --git a/modules/preloader/injected/EthereumProvider.js b/modules/preloader/injected/EthereumProvider.js new file mode 100644 index 000000000..58b5710af --- /dev/null +++ b/modules/preloader/injected/EthereumProvider.js @@ -0,0 +1,170 @@ + +(function () { + var EventEmitter = window.EventEmitter; + + var postMessage = function(payload) { + if(typeof payload === 'object') { + payload = JSON.stringify(payload); + } + + window.postMessage(payload, (!location.origin || location.origin === "null" ) ? '*' : location.origin); + }; + + // on events are: "connect", "data", "error", "end", "timeout" + // "data" will get notifications + + function EthereumProvider() { + var _this = this; + // Call constructor of superclass to initialize superclass-derived members. + EventEmitter.call(this); + + this.responseCallbacks = {}; + + // fire the connect + this.connect(); + this._reconnectCheck(); + + + + // Wait for response messages + window.addEventListener('message', function(event) { + var data; + try { + data = JSON.parse(event.data); + } catch(e){ + data = event.data; + } + + + if(typeof data !== 'object' || (data.message && !Object.prototype.hasOwnProperty.call(data.message, 'jsonrpc'))) { + return; + } + + if (data.type === 'data') { + + var id = null; + var result = data.message; + + // get the id which matches the returned id + if(typeof result === 'object' && result.forEach && isFinite(result.length)) { + result.forEach(function(load){ + if(_this.responseCallbacks[load.id]) + id = load.id; + }); + } else { + id = result.id; + } + + // notification + if(!id && result.method && result.method.indexOf('_subscription') !== -1) { + _this.listeners('data').forEach(function(callback){ + if(typeof callback === 'function') + callback(null, result); + }); + + // fire the callback + } else if(_this.responseCallbacks[id]) { + _this.responseCallbacks[id](null, result); + delete _this.responseCallbacks[id]; + } + + // make all other events listenable + } else if(data.type) { + _this.listeners(data.type).forEach(function(callback){ + if(typeof callback === 'function') + callback(null, data.message); + }); + } + }); + } + + EthereumProvider.prototype = Object.create(EventEmitter.prototype); + EthereumProvider.prototype.constructor = EthereumProvider; + + /** + Get the adds a callback to the responseCallbacks object, + which will be called if a response matching the response Id will arrive. + + @method _addResponseCallback + */ + EthereumProvider.prototype._addResponseCallback = function(payload, callback) { + var id = payload.id || payload[0].id; + var method = payload.method || payload[0].method; + + if (typeof callback !== 'function') { + throw new Error('No callback given, sync calls are not possible anymore in Mist. Please use only async calls.'); + } + + this.responseCallbacks[id] = callback; + this.responseCallbacks[id].method = method; + }; + + + /** + Will watch for connection drops and tries to reconnect. + + @method _reconnectCheck + */ + EthereumProvider.prototype._reconnectCheck = function() { + var _this = this; + var reconnectIntervalId; + + this.on('end', function () { + reconnectIntervalId = setInterval(function () { + _this.connect(); + }, 500); + }); + + this.on('connect', function () { + clearInterval(reconnectIntervalId); + }); + }; + + + + /** + Will try to make a connection + + @method connect + */ + EthereumProvider.prototype.connect = function(payload, callback) { + postMessage({ + type: 'create' + }); + }; + + /** + Sends the request + + @method send + @param {Object} payload example: {id: 1, jsonrpc: '2.0', 'method': 'eth_someMethod', params: []} + @param {Function} callback the callback to call + */ + EthereumProvider.prototype.send = function send(payload, callback) { + + this._addResponseCallback(payload, callback); + postMessage({ + type: 'write', + message: payload + }, this.origin); + }; + + + + + delete window.EventEmitter; + window.ethereumProvider = new EthereumProvider(); + + + // For backwards compatibility of web3.currentProvider; + EthereumProvider.prototype.sendSync = function () { + return {jsonrpc: '2.0', error: {"code": -32603, message: 'Sync calls are not supported in Mist.'}}; + }; + EthereumProvider.prototype.sendAsync = EthereumProvider.prototype.send; + EthereumProvider.prototype.isConnected = function () { + return true; + }; + window.web3 = { + currentProvider: new EthereumProvider() + }; +})(); diff --git a/modules/preloader/injected/EventEmitter3.js b/modules/preloader/injected/EventEmitter3.js new file mode 100644 index 000000000..f6f3792ab --- /dev/null +++ b/modules/preloader/injected/EventEmitter3.js @@ -0,0 +1,318 @@ + +(function () { + + 'use strict'; + + var has = Object.prototype.hasOwnProperty + , prefix = '~'; + + /** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @api private + */ + function Events() {} + + // + // We try to not inherit from `Object.prototype`. In some engines creating an + // instance in this way is faster than calling `Object.create(null)` directly. + // If `Object.create(null)` is not supported we prefix the event names with a + // character to make sure that the built-in object properties are not + // overridden or used as an attack vector. + // + if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) prefix = false; + } + + /** + * Representation of a single event listener. + * + * @param {Function} fn The listener function. + * @param {Mixed} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @api private + */ + function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; + } + + /** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @api public + */ + function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; + } + + /** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @api public + */ + EventEmitter.prototype.eventNames = function eventNames() { + var names = [] + , events + , name; + + if (this._eventsCount === 0) return names; + + for (name in (events = this._events)) { + if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; + }; + + /** + * Return the listeners registered for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Boolean} exists Only check if there are listeners. + * @returns {Array|Boolean} + * @api public + */ + EventEmitter.prototype.listeners = function listeners(event, exists) { + var evt = prefix ? prefix + event : event + , available = this._events[evt]; + + if (exists) return !!available; + if (!available) return []; + if (available.fn) return [available.fn]; + + for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) { + ee[i] = available[i].fn; + } + + return ee; + }; + + /** + * Calls each of the listeners registered for a given event. + * + * @param {String|Symbol} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. + * @api public + */ + EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return false; + + var listeners = this._events[evt] + , len = arguments.length + , args + , i; + + if (listeners.fn) { + if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); + + switch (len) { + case 1: return listeners.fn.call(listeners.context), true; + case 2: return listeners.fn.call(listeners.context, a1), true; + case 3: return listeners.fn.call(listeners.context, a1, a2), true; + case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + + for (i = 1, args = new Array(len -1); i < len; i++) { + args[i - 1] = arguments[i]; + } + + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length + , j; + + for (i = 0; i < length; i++) { + if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); + + switch (len) { + case 1: listeners[i].fn.call(listeners[i].context); break; + case 2: listeners[i].fn.call(listeners[i].context, a1); break; + case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; + case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; + default: + if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { + args[j - 1] = arguments[j]; + } + + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + + return true; + }; + + /** + * Add a listener for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn The listener function. + * @param {Mixed} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @api public + */ + EventEmitter.prototype.on = function on(event, fn, context) { + var listener = new EE(fn, context || this) + , evt = prefix ? prefix + event : event; + + if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; + else if (!this._events[evt].fn) this._events[evt].push(listener); + else this._events[evt] = [this._events[evt], listener]; + + return this; + }; + + /** + * Add a one-time listener for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn The listener function. + * @param {Mixed} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @api public + */ + EventEmitter.prototype.once = function once(event, fn, context) { + var listener = new EE(fn, context || this, true) + , evt = prefix ? prefix + event : event; + + if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; + else if (!this._events[evt].fn) this._events[evt].push(listener); + else this._events[evt] = [this._events[evt], listener]; + + return this; + }; + + /** + * Remove the listeners of a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {Mixed} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @api public + */ + EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return this; + if (!fn) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn + && (!once || listeners.once) + && (!context || listeners.context === context) + ) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if ( + listeners[i].fn !== fn + || (once && !listeners[i].once) + || (context && listeners[i].context !== context) + ) { + events.push(listeners[i]); + } + } + + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; + else if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + + return this; + }; + + /** + * Remove all listeners, or those of the specified event. + * + * @param {String|Symbol} [event] The event name. + * @returns {EventEmitter} `this`. + * @api public + */ + EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + } else { + this._events = new Events(); + this._eventsCount = 0; + } + + return this; + }; + + // + // Alias methods names because people roll like that. + // + EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + EventEmitter.prototype.addListener = EventEmitter.prototype.on; + + // + // This function doesn't apply anymore. + // + EventEmitter.prototype.setMaxListeners = function setMaxListeners() { + return this; + }; + + // + // Expose the prefix. + // + EventEmitter.prefixed = prefix; + + // + // Allow `EventEmitter` to be imported as module namespace. + // + EventEmitter.EventEmitter = EventEmitter; + + // + // Expose the module. + // + if ('undefined' !== typeof module) { + module.exports = EventEmitter; + } + + + window.EventEmitter = EventEmitter; +})(); diff --git a/modules/preloader/injected/mistAPI.js b/modules/preloader/injected/mistAPI.js new file mode 100644 index 000000000..2b960f005 --- /dev/null +++ b/modules/preloader/injected/mistAPI.js @@ -0,0 +1,270 @@ +/** + @module MistAPI + */ + +(function () { + 'use strict'; + + var postMessage = function(payload) { + if(typeof payload === 'object') { + payload = JSON.stringify(payload); + } + + window.postMessage(payload, (!location.origin || location.origin === "null" ) ? '*' : location.origin); + }; + + var queue = []; + + const prefix = 'entry_'; + const MIST_SUBMENU_LIMIT = 100; + + // todo: error handling + const filterAdd = function(options) { + if (!(options instanceof Object)) { return false; } + + return ['name'].every(e => e in options); + }; + + // filterId the id to only contain a-z A-Z 0-9 + const filterId = function(str) { + const filteredStr = String(str); + let newStr = ''; + if (filteredStr) { + for (let i = 0; i < filteredStr.length; i += 1) { + if (/[a-zA-Z0-9_-]/.test(filteredStr.charAt(i))) { + newStr += filteredStr.charAt(i); + } + } + } + return newStr; + }; + + /** + Mist API + + Provides an API for all dapps, which specifically targets features from the Mist browser + + @class mist + @constructor + */ + const mist = { + callbacks: {}, + version: '__version__', + license: '__license__', + platform: '__platform__', + requestAccount(callback) { + if (callback) { + if (!this.callbacks.connectAccount) { + this.callbacks.connectAccount = []; + } + this.callbacks.connectAccount.push(callback); + } + + postMessage({ + type: 'mistAPI_requestAccount' + }); + }, + solidity: { + version: '__solidityVersion__', + }, + sounds: { + bip: function playSound() { + postMessage({ + type: 'mistAPI_sound', + message: 'file://'+ __dirname +'/../../../sounds/bip.mp3' + }); + }, + bloop: function playSound() { + postMessage({ + type: 'mistAPI_sound', + message: 'file://'+ __dirname +'/../../../sounds/bloop.mp3' + }); + }, + invite: function playSound() { + postMessage({ + type: 'mistAPI_sound', + message: 'file://'+ __dirname +'/../../../sounds/invite.mp3' + }); + }, + }, + menu: { + entries: {}, + /** + Sets the badge text for the apps menu button + + Example + + mist.menu.setBadge('Some Text') + + @method setBadge + @param {String} text + */ + setBadge(text) { + postMessage({ + type: 'mistAPI_setBadge', + message: text + }); + }, + /** + Adds/Updates a menu entry + + Example + + mist.menu.add('tkrzU', { + name: 'My Meny Entry', + badge: 50, + position: 1, + selected: true + }, function(){ + // Router.go('/chat/1245'); + }) + + @method add + @param {String} id The id of the menu, has to be the same accross page reloads. + @param {Object} options The menu options like {badge: 23, name: 'My Entry'} + @param {Function} callback Change the callback to be called when the menu is pressed. + */ + add(id, options, callback) { + const args = Array.prototype.slice.call(arguments); + callback = (typeof args[args.length - 1] === 'function') ? args.pop() : null; + options = (typeof args[args.length - 1] === 'object') ? args.pop() : null; + id = (typeof args[args.length - 1] === 'string') || isFinite(args[args.length - 1]) ? args.pop() : null; + + if (!filterAdd(options)) { return false; } + + const filteredId = prefix + filterId(id); + + // restricting to 100 menu entries + if (!(filteredId in this.entries) && + Object.keys(this.entries).length >= MIST_SUBMENU_LIMIT) { + return false; + } + + const entry = { + id: filteredId || 'mist_defaultId', + position: options.position, + selected: !!options.selected, + name: options.name, + badge: options.badge, + }; + + queue.push({ + action: 'addMenu', + entry, + }); + + if (callback) { + entry.callback = callback; + } + + this.entries[filteredId] = entry; + return true; + }, + /** + Updates a menu entry from the mist sidebar. + + @method update + @param {String} id The id of the menu, has to be the same accross page reloads. + @param {Object} options The menu options like {badge: 23, name: 'My Entry'} + @param {Function} callback Change the callback to be called when the menu is pressed. + */ + update() { + this.add.apply(this, arguments); + }, + /** + Removes a menu entry from the mist sidebar. + + @method remove + @param {String} id + @param {String} id The id of the menu, has to be the same accross page reloads. + @param {Object} options The menu options like {badge: 23, name: 'My Entry'} + @param {Function} callback Change the callback to be called when the menu is pressed. + */ + remove(id) { + const filteredId = prefix + filterId(id); + + delete this.entries[filteredId]; + + queue.push({ + action: 'removeMenu', + filteredId, + }); + }, + /** + Marks a menu entry as selected + + @method select + @param {String} id + */ + select(id) { + const filteredId = prefix + filterId(id); + queue.push({ action: 'selectMenu', id: filteredId }); + + for (const e in this.entries) { + if ({}.hasOwnProperty.call(this.entries, e)) { + this.entries[e].selected = (e === filteredId); + } + } + }, + /** + Removes all menu entries. + + @method clear + */ + clear() { + this.entries = {}; + queue.push({ action: 'clearMenu' }); + }, + }, + }; + + + // Wait for response messages + window.addEventListener('message', function(event) { + var data; + try { + data = JSON.parse(event.data); + } catch(e){ + data = event.data; + } + + if(typeof data !== 'object') { + return; + } + + if (data.type === 'mistAPI_callMenuFunction') { + var id = data.message; + + if (mist.menu.entries[id] && mist.menu.entries[id].callback) { + mist.menu.entries[id].callback(); + } + + } else if (data.type === 'uiAction_windowMessage') { + var params = data.message; + + if (mist.callbacks[params.type]) { + mist.callbacks[params.type].forEach(function(cb) { + cb(params.error, params.value); + }); + delete mist.callbacks[params.type]; + } + } + }); + + + // work up queue every 500ms + setInterval(function() { + if (queue.length > 0) { + + postMessage({ + type: 'mistAPI_menuChanges', + message: queue + }); + + queue = []; + } + }, 500); + + + window.mist = mist; +})(); diff --git a/modules/preloader/wallet.js b/modules/preloader/wallet.js index 9b6d61529..8783cd6ea 100644 --- a/modules/preloader/wallet.js +++ b/modules/preloader/wallet.js @@ -2,6 +2,8 @@ @module preloader wallet */ +const { webFrame } = require('electron'); + require('./dapps.js'); -window.mistMode = 'mist'; +webFrame.executeJavaScript("window.mistMode = 'mist';"); From ed2c7cf1d15f3827848ad6dd3e1353bef7ea9649 Mon Sep 17 00:00:00 2001 From: Fabian Vogelsteller Date: Thu, 30 Mar 2017 19:13:31 +0200 Subject: [PATCH 02/13] updated readme --- README.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 499df02b8..7ce25a264 100644 --- a/README.md +++ b/README.md @@ -35,14 +35,14 @@ To run mist in development you need: - [Node.js](https://nodejs.org) `v6.x` (use the prefered installation method for your OS) - [Meteor](https://www.meteor.com/install) javascript app framework - [Yarn](https://yarnpkg.com/) package manager -- [Electron](http://electron.atom.io/) `v1.3.13` cross platform desktop app framework +- [Electron](http://electron.atom.io/) `v1.6.2` cross platform desktop app framework - [Gulp](http://gulpjs.com/) build and automation system Install the later ones via: $ curl https://install.meteor.com/ | sh $ curl -o- -L https://yarnpkg.com/install.sh | bash - $ yarn global add electron@1.3.13 + $ yarn global add electron@1.6.2 $ yarn global add gulp ### Initialisation diff --git a/package.json b/package.json index c89456414..00211a9c3 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "co-mocha": "^1.2.0", "del": "^2.2.2", "ecstatic": "^2.1.0", - "electron": "1.3.13", + "electron": "1.6.2", "electron-builder": "^12.2.2", "eslint": "^3.14.1", "eslint-config-airbnb-base": "^11.0.1", From eaa6f1e33f658bc5a9f8eca4cea7844b5c6ce3f5 Mon Sep 17 00:00:00 2001 From: Luca Zeug Date: Fri, 31 Mar 2017 17:44:25 +0200 Subject: [PATCH 03/13] added updated 'yarn.lock' file --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 49e1e4676..6f6ab57fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1057,9 +1057,9 @@ electron-window-state: jsonfile "^2.2.3" mkdirp "^0.5.1" -electron@1.3.13: - version "1.3.13" - resolved "https://registry.yarnpkg.com/electron/-/electron-1.3.13.tgz#a927783bfe3a689eb832a713ef515d31c8a2e406" +electron@1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/electron/-/electron-1.6.2.tgz#b0ccd7703f86d09c4d2a7273455c3f993f158994" dependencies: electron-download "^3.0.1" extract-zip "^1.0.3" From 15f4a409723bbbfd868be7fcf0d6517894ef1bfd Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Thu, 13 Apr 2017 16:20:27 -0300 Subject: [PATCH 04/13] Updating packages --- modules/preloader/browser.js | 2 - package.json | 2 +- yarn.lock | 381 ++++++----------------------------- 3 files changed, 58 insertions(+), 327 deletions(-) diff --git a/modules/preloader/browser.js b/modules/preloader/browser.js index 54139db8f..7c6a84c40 100644 --- a/modules/preloader/browser.js +++ b/modules/preloader/browser.js @@ -124,5 +124,3 @@ ipcRenderer.sendToHost('setWebviewId'); // destroy the old socket ipcRenderer.send('ipcProvider-destroy'); - - diff --git a/package.json b/package.json index bba22ccfe..cae08aa41 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "run-sequence": "^1.2.1", "semver-compare": "^1.0.0", "shelljs": "^0.7.6", - "spectron": "3.3.0", + "spectron": "3.6.1", "xml2js": "^0.4.17" } } diff --git a/yarn.lock b/yarn.lock index e7a647fc6..045e3c7d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -225,7 +225,7 @@ babel-runtime@^5.8.25: dependencies: core-js "^1.0.0" -babel-runtime@^6.22.0, babel-runtime@^6.9.2: +babel-runtime@^6.9.2: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.22.0.tgz#1cf8b4ac67c77a4ddb0db2ae1f74de52ac4ca611" dependencies: @@ -360,15 +360,6 @@ buffer-shims@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" -buffer-to-vinyl@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/buffer-to-vinyl/-/buffer-to-vinyl-1.1.0.tgz#00f15faee3ab7a1dda2cde6d9121bffdd07b2262" - dependencies: - file-type "^3.1.0" - readable-stream "^2.0.2" - uuid "^2.0.1" - vinyl "^1.0.0" - buffer-xor@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" @@ -560,12 +551,6 @@ commander@2.9.0, commander@^2.9.0: dependencies: graceful-readlink ">= 1.0.0" -commander@~2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.8.1.tgz#06be367febfda0c330aa1e2a072d3dc9762425d4" - dependencies: - graceful-readlink ">= 1.0.0" - compare-version@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/compare-version/-/compare-version-0.1.2.tgz#0162ec2d9351f5ddd59a9202cba935366a725080" @@ -617,10 +602,6 @@ contains-path@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" -convert-source-map@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.3.0.tgz#e9f3e9c6e2728efc2676696a70eb382f73106a67" - core-js@^1.0.0: version "1.2.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" @@ -751,66 +732,6 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" -decompress-tar@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/decompress-tar/-/decompress-tar-3.1.0.tgz#217c789f9b94450efaadc5c5e537978fc333c466" - dependencies: - is-tar "^1.0.0" - object-assign "^2.0.0" - strip-dirs "^1.0.0" - tar-stream "^1.1.1" - through2 "^0.6.1" - vinyl "^0.4.3" - -decompress-tarbz2@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/decompress-tarbz2/-/decompress-tarbz2-3.1.0.tgz#8b23935681355f9f189d87256a0f8bdd96d9666d" - dependencies: - is-bzip2 "^1.0.0" - object-assign "^2.0.0" - seek-bzip "^1.0.3" - strip-dirs "^1.0.0" - tar-stream "^1.1.1" - through2 "^0.6.1" - vinyl "^0.4.3" - -decompress-targz@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/decompress-targz/-/decompress-targz-3.1.0.tgz#b2c13df98166268991b715d6447f642e9696f5a0" - dependencies: - is-gzip "^1.0.0" - object-assign "^2.0.0" - strip-dirs "^1.0.0" - tar-stream "^1.1.1" - through2 "^0.6.1" - vinyl "^0.4.3" - -decompress-unzip@^3.0.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/decompress-unzip/-/decompress-unzip-3.4.0.tgz#61475b4152066bbe3fee12f9d629d15fe6478eeb" - dependencies: - is-zip "^1.0.0" - read-all-stream "^3.0.0" - stat-mode "^0.2.0" - strip-dirs "^1.0.0" - through2 "^2.0.0" - vinyl "^1.0.0" - yauzl "^2.2.1" - -decompress@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/decompress/-/decompress-3.0.0.tgz#af1dd50d06e3bfc432461d37de11b38c0d991bed" - dependencies: - buffer-to-vinyl "^1.0.0" - concat-stream "^1.4.6" - decompress-tar "^3.0.0" - decompress-tarbz2 "^3.0.0" - decompress-targz "^3.0.0" - decompress-unzip "^3.0.0" - stream-combiner2 "^1.1.1" - vinyl-assign "^1.0.1" - vinyl-fs "^2.2.0" - deep-eql@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2" @@ -900,7 +821,7 @@ duplexer2@0.0.2: dependencies: readable-stream "~1.1.9" -duplexer2@^0.1.4, duplexer2@~0.1.0: +duplexer2@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" dependencies: @@ -910,15 +831,6 @@ duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" -duplexify@^3.2.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.5.0.tgz#1aa773002e1578457e9d9d4a50b0ccaaebcbd604" - dependencies: - end-of-stream "1.0.0" - inherits "^2.0.1" - readable-stream "^2.0.0" - stream-shift "^1.0.0" - ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" @@ -998,13 +910,12 @@ electron-builder@^12.2.2: uuid-1345 "^0.99.6" yargs "^6.6.0" -electron-chromedriver@~1.3.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/electron-chromedriver/-/electron-chromedriver-1.3.2.tgz#4cb41d8cba675a5eaf4c9aebce8dc405e1347f92" +electron-chromedriver@~1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/electron-chromedriver/-/electron-chromedriver-1.6.0.tgz#6eabdaa5cf9c75e43501e2593b528e8cfd97d7c7" dependencies: - decompress "^3.0.0" - mkdirp "^0.5.1" - request "^2.65.0" + electron-download "^3.1.0" + extract-zip "^1.6.0" electron-download-tf@3.1.0: version "3.1.0" @@ -1033,6 +944,20 @@ electron-download@^3.0.1: semver "^5.3.0" sumchecker "^1.2.0" +electron-download@^3.1.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/electron-download/-/electron-download-3.3.0.tgz#2cfd54d6966c019c4d49ad65fbe65cc9cdef68c8" + dependencies: + debug "^2.2.0" + fs-extra "^0.30.0" + home-path "^1.0.1" + minimist "^1.2.0" + nugget "^2.0.0" + path-exists "^2.1.0" + rc "^1.1.2" + semver "^5.3.0" + sumchecker "^1.2.0" + electron-macos-sign@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/electron-macos-sign/-/electron-macos-sign-1.5.0.tgz#fe3a8acb755b5f568f1fe144e9e66cee44019448" @@ -1043,6 +968,14 @@ electron-macos-sign@~1.5.0: isbinaryfile "^3.0.2" plist "^2.0.1" +electron-version@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/electron-version/-/electron-version-1.1.0.tgz#14899e16c4ff49a13720ae151a6469cb159f2e22" + dependencies: + bl "^1.0.0" + once "^1.3.2" + semver "^5.0.3" + electron-window-state: version "4.0.1" resolved "https://registry.yarnpkg.com/electron-window-state/-/electron-window-state-4.0.1.tgz#8f3ccd96b6288aa78e903eb40c6a363874ee0830" @@ -1067,12 +1000,6 @@ elliptic@^6.2.3: hash.js "^1.0.0" inherits "^2.0.1" -end-of-stream@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.0.0.tgz#d4596e702734a93e40e9af864319eabd99ff2f0e" - dependencies: - once "~1.3.0" - end-of-stream@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.1.0.tgz#e9353258baa9108965efc41cb0ef8ade2f3cfb07" @@ -1350,12 +1277,6 @@ expand-tilde@^1.2.1, expand-tilde@^1.2.2: dependencies: os-homedir "^1.0.1" -extend-shallow@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" - dependencies: - is-extendable "^0.1.0" - extend@^3.0.0, extend@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" @@ -1383,6 +1304,15 @@ extract-zip@^1.0.3: mkdirp "0.5.0" yauzl "2.4.1" +extract-zip@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.0.tgz#7f400c9607ea866ecab7aa6d54fb978eeb11621a" + dependencies: + concat-stream "1.5.0" + debug "0.7.4" + mkdirp "0.5.0" + yauzl "2.4.1" + extsprintf@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" @@ -1418,10 +1348,6 @@ file-entry-cache@^2.0.0: flat-cache "^1.2.1" object-assign "^4.0.1" -file-type@^3.1.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" - filename-regex@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" @@ -1644,13 +1570,6 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob-parent@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.0.1.tgz#60021327cc963ddc3b5f085764f500479ecd82ff" - dependencies: - is-glob "^3.1.0" - path-dirname "^1.0.0" - glob-stream@^3.1.5: version "3.1.18" resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" @@ -1662,19 +1581,6 @@ glob-stream@^3.1.5: through2 "^0.6.1" unique-stream "^1.0.0" -glob-stream@^5.3.2: - version "5.3.5" - resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-5.3.5.tgz#a55665a9a8ccdc41915a87c701e32d4e016fad22" - dependencies: - extend "^3.0.0" - glob "^5.0.3" - glob-parent "^3.0.0" - micromatch "^2.3.7" - ordered-read-streams "^0.3.0" - through2 "^0.6.0" - to-absolute-glob "^0.1.1" - unique-stream "^2.0.2" - glob-watcher@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" @@ -1707,7 +1613,7 @@ glob@^4.3.1: minimatch "^2.0.1" once "^1.3.0" -glob@^5.0.15, glob@^5.0.3: +glob@^5.0.15: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: @@ -1812,7 +1718,7 @@ graceful-fs@^3.0.0, graceful-fs@~3.0.2: dependencies: natives "^1.1.0" -graceful-fs@^4.0.0, graceful-fs@^4.1.0, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@^4.1.0, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.9" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.9.tgz#baacba37d19d11f9d146d3578bc99958c3787e29" @@ -1828,16 +1734,6 @@ growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" -gulp-sourcemaps@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/gulp-sourcemaps/-/gulp-sourcemaps-1.6.0.tgz#b86ff349d801ceb56e1d9e7dc7bbcb4b7dee600c" - dependencies: - convert-source-map "^1.1.1" - graceful-fs "^4.1.2" - strip-bom "^2.0.0" - through2 "^2.0.0" - vinyl "^1.0.0" - gulp-spawn-mocha@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/gulp-spawn-mocha/-/gulp-spawn-mocha-3.1.0.tgz#b11e3b8e3b3d3ed1c88de5624de42a9e780c27c3" @@ -2059,12 +1955,6 @@ invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" -is-absolute@^0.1.5: - version "0.1.7" - resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-0.1.7.tgz#847491119fccb5fb436217cc737f7faad50f603f" - dependencies: - is-relative "^0.1.0" - is-absolute@^0.2.3: version "0.2.6" resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-0.2.6.tgz#20de69f3db942ef2d87b9c2da36f172235b1b5eb" @@ -2086,10 +1976,6 @@ is-builtin-module@^1.0.0: dependencies: builtin-modules "^1.0.0" -is-bzip2@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-bzip2/-/is-bzip2-1.0.0.tgz#5ee58eaa5a2e9c80e21407bedf23ae5ac091b3fc" - is-ci@^1.0.10: version "1.0.10" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e" @@ -2106,7 +1992,7 @@ is-equal-shallow@^0.1.3: dependencies: is-primitive "^2.0.0" -is-extendable@^0.1.0, is-extendable@^0.1.1: +is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -2114,10 +2000,6 @@ is-extglob@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" -is-extglob@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.0.tgz#33411a482b046bf95e6b0cb27ee2711af4cf15ad" - is-finite@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" @@ -2144,16 +2026,6 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" -is-glob@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" - dependencies: - is-extglob "^2.1.0" - -is-gzip@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-gzip/-/is-gzip-1.0.0.tgz#6ca8b07b99c77998025900e555ced8ed80879a83" - is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: version "2.15.0" resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz#936edda3ca3c211fd98f3b2d3e08da43f7b2915b" @@ -2163,10 +2035,6 @@ is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: jsonpointer "^4.0.0" xtend "^4.0.0" -is-natural-number@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-2.1.1.tgz#7d4c5728377ef386c3e194a9911bf57c6dc335e7" - is-npm@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" @@ -2217,10 +2085,6 @@ is-redirect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" -is-relative@^0.1.0: - version "0.1.3" - resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-0.1.3.tgz#905fee8ae86f45b3ec614bc3c15c869df0876e82" - is-relative@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-0.2.1.tgz#d27f4c7d516d175fb610db84bbeef23c3bc97aa5" @@ -2237,14 +2101,10 @@ is-retry-allowed@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" -is-stream@^1.0.0, is-stream@^1.0.1: +is-stream@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" -is-tar@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-tar/-/is-tar-1.0.0.tgz#2f6b2e1792c1f5bb36519acaa9d65c0d26fe853d" - is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -2259,18 +2119,10 @@ is-utf8@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" -is-valid-glob@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-0.3.0.tgz#d4b55c69f51886f9b65c70d6c2622d37e29f48fe" - is-windows@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-0.2.0.tgz#de1aa6d63ea29dd248737b69f1ff8b8002d2108c" -is-zip@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-zip/-/is-zip-1.0.0.tgz#47b0a8ff4d38a76431ccfd99a8e15a4c86ba2325" - isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" @@ -2550,10 +2402,6 @@ lodash.isempty@^4.2.1, lodash.isempty@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e" -lodash.isequal@^4.0.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.4.0.tgz#6295768e98e14dc15ce8d362ef6340db82852031" - lodash.isplainobject@^4.0.4: version "4.0.6" resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" @@ -2911,15 +2759,11 @@ oauth-sign@~0.8.1: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" -object-assign@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-2.1.1.tgz#43c36e5d569ff8e4816c4efa8be02d26967c18aa" - object-assign@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" -object-assign@^4.0.0, object-assign@^4.0.1, object-assign@^4.1.0: +object-assign@^4.0.1, object-assign@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" @@ -2940,7 +2784,7 @@ oboe@^2.1.3: dependencies: http-https "^1.0.0" -once@1.x, once@^1.3.0: +once@1.x, once@^1.3.0, once@^1.3.2: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: @@ -2986,13 +2830,6 @@ ordered-read-streams@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" -ordered-read-streams@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.3.0.tgz#7137e69b3298bb342247a1bbee3881c80e2fd78b" - dependencies: - is-stream "^1.0.1" - readable-stream "^2.0.1" - os-homedir@^1.0.0, os-homedir@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" @@ -3064,10 +2901,6 @@ parse-json@^2.1.0, parse-json@^2.2.0: dependencies: error-ex "^1.2.0" -path-dirname@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" - path-exists@^2.0.0, path-exists@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" @@ -3273,7 +3106,7 @@ readable-stream@^1.1.7, readable-stream@~1.1.9: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5: +readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5: version "2.1.5" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" dependencies: @@ -3537,12 +3370,6 @@ secp256k1@^3.0.1: elliptic "^6.2.3" nan "^2.2.1" -seek-bzip@^1.0.3: - version "1.0.5" - resolved "https://registry.yarnpkg.com/seek-bzip/-/seek-bzip-1.0.5.tgz#cfe917cb3d274bcffac792758af53173eb1fabdc" - dependencies: - commander "~2.8.1" - semver-compare@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" @@ -3707,13 +3534,15 @@ spdx-license-ids@^1.0.2: version "1.2.2" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" -spectron@3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/spectron/-/spectron-3.3.0.tgz#b4f0b9fa00771715aa04aa31b336f1bd763d660f" +spectron@3.6.1: + version "3.6.1" + resolved "https://registry.yarnpkg.com/spectron/-/spectron-3.6.1.tgz#42edfcc74eab15176b5a3fb6ac1e1f705dc98ac9" dependencies: dev-null "^0.1.1" - electron-chromedriver "~1.3.0" + electron-chromedriver "~1.6.0" + electron-version "^1.1.0" request "^2.65.0" + semver "^5.3.0" split "^1.0.0" webdriverio "^4.0.4" @@ -3746,25 +3575,14 @@ sshpk@^1.7.0: jsbn "~0.1.0" tweetnacl "~0.14.0" -stat-mode@^0.2.0, stat-mode@^0.2.2: +stat-mode@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/stat-mode/-/stat-mode-0.2.2.tgz#e6c80b623123d7d80cf132ce538f346289072502" -stream-combiner2@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/stream-combiner2/-/stream-combiner2-1.1.1.tgz#fb4d8a1420ea362764e21ad4780397bebcb41cbe" - dependencies: - duplexer2 "~0.1.0" - readable-stream "^2.0.2" - stream-consume@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.0.tgz#a41ead1a6d6081ceb79f65b061901b6d8f3d1d0f" -stream-shift@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" - streamroller@^0.2.1: version "0.2.2" resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-0.2.2.tgz#a13420e04169e573db068f5920ee23d881abfe33" @@ -3806,13 +3624,6 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" -strip-bom-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-bom-stream/-/strip-bom-stream-1.0.0.tgz#e7144398577d51a6bed0fa1994fa05f43fd988ee" - dependencies: - first-chunk-stream "^1.0.0" - strip-bom "^2.0.0" - strip-bom@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" @@ -3830,17 +3641,6 @@ strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" -strip-dirs@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/strip-dirs/-/strip-dirs-1.1.1.tgz#960bbd1287844f3975a4558aa103a8255e2456a0" - dependencies: - chalk "^1.0.0" - get-stdin "^4.0.1" - is-absolute "^0.1.5" - is-natural-number "^2.0.0" - minimist "^1.1.0" - sum-up "^1.0.1" - strip-indent@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" @@ -3855,12 +3655,6 @@ strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" -sum-up@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sum-up/-/sum-up-1.0.3.tgz#1c661f667057f63bcb7875aa1438bc162525156e" - dependencies: - chalk "^1.0.0" - sumchecker@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/sumchecker/-/sumchecker-1.2.0.tgz#8c79282f6b5d74e7fbcfb49505e50d096c63f38d" @@ -3889,7 +3683,7 @@ table@^3.7.8: slice-ansi "0.0.4" string-width "^2.0.0" -tar-stream@^1.1.1, tar-stream@^1.5.0: +tar-stream@^1.5.0: version "1.5.2" resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.5.2.tgz#fbc6c6e83c1a19d4cb48c7d96171fc248effc7bf" dependencies: @@ -3906,21 +3700,14 @@ throttleit@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-0.0.2.tgz#cfedf88e60c00dd9697b61fdd2a8343a9b680eaf" -through2-filter@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-2.0.0.tgz#60bc55a0dacb76085db1f9dae99ab43f83d622ec" - dependencies: - through2 "~2.0.0" - xtend "~4.0.0" - -through2@^0.6.0, through2@^0.6.1: +through2@^0.6.1: version "0.6.5" resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" dependencies: readable-stream ">=1.0.33-1 <1.1.0-0" xtend ">=4.0.0 <4.1.0-0" -through2@^2.0.0, through2@~2.0.0: +through2@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.1.tgz#384e75314d49f32de12eebb8136b8eb6b5d59da9" dependencies: @@ -3968,12 +3755,6 @@ tmp@0.0.29, tmp@^0.0.29: dependencies: os-tmpdir "~1.0.1" -to-absolute-glob@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-0.1.1.tgz#1cdfa472a9ef50c239ee66999b662ca0eb39937f" - dependencies: - extend-shallow "^2.0.1" - tough-cookie@~2.3.0: version "2.3.2" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" @@ -4057,13 +3838,6 @@ unique-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" -unique-stream@^2.0.2: - version "2.2.1" - resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-2.2.1.tgz#5aa003cfbe94c5ff866c4e7d668bb1c4dbadb369" - dependencies: - json-stable-stringify "^1.0.0" - through2-filter "^2.0.0" - unzip-response@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-1.0.2.tgz#b984f0877fc0a89c2c773cc1ef7b5b232b5b06fe" @@ -4152,10 +3926,6 @@ v8flags@^2.0.2: dependencies: user-home "^1.1.1" -vali-date@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/vali-date/-/vali-date-1.0.0.tgz#1b904a59609fb328ef078138420934f6b86709a6" - validate-npm-package-license@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" @@ -4173,13 +3943,6 @@ verror@1.3.6: dependencies: extsprintf "1.0.2" -vinyl-assign@^1.0.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/vinyl-assign/-/vinyl-assign-1.2.1.tgz#4d198891b5515911d771a8cd9c5480a46a074a45" - dependencies: - object-assign "^4.0.1" - readable-stream "^2.0.0" - vinyl-fs@^0.3.0: version "0.3.14" resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-0.3.14.tgz#9a6851ce1cac1c1cea5fe86c0931d620c2cfa9e6" @@ -4193,29 +3956,7 @@ vinyl-fs@^0.3.0: through2 "^0.6.1" vinyl "^0.4.0" -vinyl-fs@^2.2.0: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-2.4.4.tgz#be6ff3270cb55dfd7d3063640de81f25d7532239" - dependencies: - duplexify "^3.2.0" - glob-stream "^5.3.2" - graceful-fs "^4.0.0" - gulp-sourcemaps "1.6.0" - is-valid-glob "^0.3.0" - lazystream "^1.0.0" - lodash.isequal "^4.0.0" - merge-stream "^1.0.0" - mkdirp "^0.5.0" - object-assign "^4.0.0" - readable-stream "^2.0.4" - strip-bom "^2.0.0" - strip-bom-stream "^1.0.0" - through2 "^2.0.0" - through2-filter "^2.0.0" - vali-date "^1.0.0" - vinyl "^1.0.0" - -vinyl@^0.4.0, vinyl@^0.4.3: +vinyl@^0.4.0: version "0.4.6" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" dependencies: @@ -4230,14 +3971,6 @@ vinyl@^0.5.0: clone-stats "^0.0.1" replace-ext "0.0.1" -vinyl@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-1.2.0.tgz#5c88036cf565e5df05558bfc911f8656df218884" - dependencies: - clone "^1.0.0" - clone-stats "^0.0.1" - replace-ext "0.0.1" - wdio-dot-reporter@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/wdio-dot-reporter/-/wdio-dot-reporter-0.0.6.tgz#153b3e1c5d76777190d893480ffa6f37833740f1" @@ -4455,7 +4188,7 @@ yargs@~3.10.0: decamelize "^1.0.0" window-size "0.1.0" -yauzl@2.4.1, yauzl@^2.2.1: +yauzl@2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" dependencies: From 40b664a2422ad16e66cf8bfb7da760b289db4431 Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Mon, 17 Apr 2017 17:51:03 -0300 Subject: [PATCH 05/13] Changing params on test setup --- package.json | 4 ++-- tests/_base.js | 1 - yarn.lock | 24 +++++++----------------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 411b025a0..a5e52383a 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "co-mocha": "^1.2.0", "del": "^2.2.2", "ecstatic": "^2.1.0", - "electron": "1.6.2", + "electron": "1.3.13", "electron-builder": "^12.2.2", "eslint": "^3.19.0", "eslint-config-airbnb-base": "^11.1.3", @@ -64,7 +64,7 @@ "run-sequence": "^1.2.1", "semver-compare": "^1.0.0", "shelljs": "^0.7.7", - "spectron": "3.6.1", + "spectron": "3.6.0", "xml2js": "^0.4.17" } } diff --git a/tests/_base.js b/tests/_base.js index a224fce53..710b8fba2 100644 --- a/tests/_base.js +++ b/tests/_base.js @@ -106,7 +106,6 @@ exports.mocha = (_module, options) => { quitTimeout: 10000, path: appPath, args: [ - '--mode', options.app, '--loglevel', 'debug', '--logfile', logFilePath, '--node-datadir', this.geth.dataDir, diff --git a/yarn.lock b/yarn.lock index 9f51a9110..6219e1381 100644 --- a/yarn.lock +++ b/yarn.lock @@ -991,14 +991,6 @@ electron-macos-sign@~1.5.0: isbinaryfile "^3.0.2" plist "^2.0.1" -electron-version@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/electron-version/-/electron-version-1.1.0.tgz#14899e16c4ff49a13720ae151a6469cb159f2e22" - dependencies: - bl "^1.0.0" - once "^1.3.2" - semver "^5.0.3" - electron-window-state@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/electron-window-state/-/electron-window-state-4.1.1.tgz#6b34fdc31b38514dfec8b7c8f7b5d4addb67632d" @@ -1007,9 +999,9 @@ electron-window-state@^4.0.1: jsonfile "^2.2.3" mkdirp "^0.5.1" -electron@1.6.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/electron/-/electron-1.6.2.tgz#b0ccd7703f86d09c4d2a7273455c3f993f158994" +electron@1.3.13: + version "1.3.13" + resolved "https://registry.yarnpkg.com/electron/-/electron-1.3.13.tgz#a927783bfe3a689eb832a713ef515d31c8a2e406" dependencies: electron-download "^3.0.1" extract-zip "^1.0.3" @@ -2899,7 +2891,7 @@ oboe@^2.1.3: dependencies: http-https "^1.0.0" -once@1.x, once@^1.3.0, once@^1.3.1, once@^1.3.2, once@^1.4.0: +once@1.x, once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: @@ -3706,15 +3698,13 @@ spdx-license-ids@^1.0.2: version "1.2.2" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" -spectron@3.6.1: - version "3.6.1" - resolved "https://registry.yarnpkg.com/spectron/-/spectron-3.6.1.tgz#42edfcc74eab15176b5a3fb6ac1e1f705dc98ac9" +spectron@3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/spectron/-/spectron-3.6.0.tgz#ed231301524ef7658e41f947b59455a4bc0c2d1a" dependencies: dev-null "^0.1.1" electron-chromedriver "~1.6.0" - electron-version "^1.1.0" request "^2.65.0" - semver "^5.3.0" split "^1.0.0" webdriverio "^4.0.4" From c435b44371b5ff121d29523d974ab53c5fe65e6d Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Mon, 17 Apr 2017 18:57:16 -0300 Subject: [PATCH 06/13] Electron + Spectron version match --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a5e52383a..1dd809ad8 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "co-mocha": "^1.2.0", "del": "^2.2.2", "ecstatic": "^2.1.0", - "electron": "1.3.13", + "electron": "1.6.2", "electron-builder": "^12.2.2", "eslint": "^3.19.0", "eslint-config-airbnb-base": "^11.1.3", diff --git a/yarn.lock b/yarn.lock index 6219e1381..9cddfd253 100644 --- a/yarn.lock +++ b/yarn.lock @@ -999,9 +999,9 @@ electron-window-state@^4.0.1: jsonfile "^2.2.3" mkdirp "^0.5.1" -electron@1.3.13: - version "1.3.13" - resolved "https://registry.yarnpkg.com/electron/-/electron-1.3.13.tgz#a927783bfe3a689eb832a713ef515d31c8a2e406" +electron@1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/electron/-/electron-1.6.2.tgz#b0ccd7703f86d09c4d2a7273455c3f993f158994" dependencies: electron-download "^3.0.1" extract-zip "^1.0.3" From 5d7c5b879304c56fe4c9835736612c0628199955 Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Mon, 17 Apr 2017 21:33:40 -0300 Subject: [PATCH 07/13] Improving test logging --- tests/_base.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/_base.js b/tests/_base.js index 710b8fba2..7d7720776 100644 --- a/tests/_base.js +++ b/tests/_base.js @@ -68,8 +68,13 @@ exports.mocha = (_module, options) => { this.assert = chai.assert; this.expect = chai.expect; - const logFilePath = path.join(__dirname, 'mist.log'); - shell.rm('-rf', logFilePath); + const mistLogFile = path.join(__dirname, 'mist.log'); + const webdriverLogFile = path.join(__dirname, 'webdriver.log'); + const chromeLogFile = path.join(__dirname, 'chrome.log'); + + _.each([mistLogFile, webdriverLogFile, chromeLogFile], (e) => { + shell.rm('-f', e); + }); this.geth = yield startGeth(); @@ -107,10 +112,12 @@ exports.mocha = (_module, options) => { path: appPath, args: [ '--loglevel', 'debug', - '--logfile', logFilePath, + '--logfile', mistLogFile, '--node-datadir', this.geth.dataDir, '--rpc', ipcProviderPath, ], + webdriverLogPath: webdriverLogFile, + chromeDriverLogPath: chromeLogFile, }); yield this.app.start(); @@ -123,10 +130,8 @@ exports.mocha = (_module, options) => { ).listen(serverPort); this.fixtureBaseUrl = `http://localhost:${serverPort}/`; - this.client = this.app.client; yield this.client.waitUntilWindowLoaded(); - // console.log(this.app.chromeDriver.logLines); /* Utility methods @@ -189,7 +194,6 @@ exports.mocha = (_module, options) => { }, * after () { - console.log('After tests triggered'); if (this.app && this.app.isRunning()) { console.log('Stopping app...'); yield this.app.stop(); From d0083812fbb2db17365290b47ff35e6348dbbec1 Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Mon, 17 Apr 2017 21:34:58 -0300 Subject: [PATCH 08/13] Removing waitUntilWindowLoaded in favor of better window handling made by us --- tests/_base.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/_base.js b/tests/_base.js index 7d7720776..8ed2525df 100644 --- a/tests/_base.js +++ b/tests/_base.js @@ -131,7 +131,6 @@ exports.mocha = (_module, options) => { this.fixtureBaseUrl = `http://localhost:${serverPort}/`; this.client = this.app.client; - yield this.client.waitUntilWindowLoaded(); /* Utility methods From f90d7d41c42dedcd8029f073cffb7004d8c58c15 Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Mon, 17 Apr 2017 22:12:20 -0300 Subject: [PATCH 09/13] Ignoring test log files --- tests/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/.gitignore diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..c0b39b6ae --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,3 @@ +mist.log +webdriver.log +chrome.log From 537c92db01aff0e7bb87c7b6184bdb49957e2b42 Mon Sep 17 00:00:00 2001 From: Fabian Vogelsteller Date: Wed, 28 Jun 2017 17:51:17 +0200 Subject: [PATCH 10/13] deactivated ethereumProvider for now --- README.md | 4 +-- ...reumProvider.js => web3CurrentProvider.js} | 4 +-- .../preloader/injected/EthereumProvider.js | 33 +++++++++++-------- modules/preloader/mistUI.js | 2 +- modules/preloader/popupWindows.js | 2 +- modules/preloader/splashScreen.js | 2 +- 6 files changed, 26 insertions(+), 21 deletions(-) rename modules/preloader/include/{ethereumProvider.js => web3CurrentProvider.js} (85%) diff --git a/README.md b/README.md index b35f72f7c..a89c38fca 100644 --- a/README.md +++ b/README.md @@ -41,14 +41,14 @@ To run mist in development you need: - [Node.js](https://nodejs.org) `v6.x` (use the prefered installation method for your OS) - [Meteor](https://www.meteor.com/install) javascript app framework - [Yarn](https://yarnpkg.com/) package manager -- [Electron](http://electron.atom.io/) `v1.6.2` cross platform desktop app framework +- [Electron](http://electron.atom.io/) `v1.6.11` cross platform desktop app framework - [Gulp](http://gulpjs.com/) build and automation system Install the latter ones via: $ curl https://install.meteor.com/ | sh $ curl -o- -L https://yarnpkg.com/install.sh | bash - $ yarn global add electron@1.6.2 + $ yarn global add electron@1.6.11 $ yarn global add gulp ### Initialisation diff --git a/modules/preloader/include/ethereumProvider.js b/modules/preloader/include/web3CurrentProvider.js similarity index 85% rename from modules/preloader/include/ethereumProvider.js rename to modules/preloader/include/web3CurrentProvider.js index b41c02dd7..dfa412e0e 100644 --- a/modules/preloader/include/ethereumProvider.js +++ b/modules/preloader/include/web3CurrentProvider.js @@ -10,7 +10,7 @@ const LegacyWeb3IpcProvider = require('./legacyWeb3IpcProvider.js'); // SET ETHEREUM PROVIDER -window.ethereumProvider = new Web3.providers.IpcProvider('', ipcProviderWrapper); +// window.ethereumProvider = new Web3.providers.IpcProvider('', ipcProviderWrapper); // LEGACY @@ -20,4 +20,4 @@ window.web3 = { }; // for now still add this too: WILL BE REMOVED with web3 1.0 -window.web3 = new Web3(new Web3.providers.IpcProvider('', ipcProviderWrapper)); \ No newline at end of file +window.web3 = new Web3(new Web3.providers.IpcProvider('', ipcProviderWrapper)); diff --git a/modules/preloader/injected/EthereumProvider.js b/modules/preloader/injected/EthereumProvider.js index 58b5710af..826ed66be 100644 --- a/modules/preloader/injected/EthereumProvider.js +++ b/modules/preloader/injected/EthereumProvider.js @@ -21,7 +21,7 @@ this.responseCallbacks = {}; // fire the connect - this.connect(); + this._connect(); this._reconnectCheck(); @@ -57,12 +57,13 @@ // notification if(!id && result.method && result.method.indexOf('_subscription') !== -1) { - _this.listeners('data').forEach(function(callback){ - if(typeof callback === 'function') - callback(null, result); - }); + // _this.listeners('data').forEach(function(callback){ + // if(typeof callback === 'function') + // callback(null, result); + // }); + _this.emit('data', result); - // fire the callback + // fire the callback } else if(_this.responseCallbacks[id]) { _this.responseCallbacks[id](null, result); delete _this.responseCallbacks[id]; @@ -70,10 +71,12 @@ // make all other events listenable } else if(data.type) { - _this.listeners(data.type).forEach(function(callback){ - if(typeof callback === 'function') - callback(null, data.message); - }); + // _this.listeners(data.type).forEach(function(callback){ + // if(typeof callback === 'function') + // callback(null, data.message); + // }); + // TODO check if secure + _this.emit('data.type', data.message); } }); } @@ -111,7 +114,7 @@ this.on('end', function () { reconnectIntervalId = setInterval(function () { - _this.connect(); + _this._connect(); }, 500); }); @@ -127,7 +130,7 @@ @method connect */ - EthereumProvider.prototype.connect = function(payload, callback) { + EthereumProvider.prototype._connect = function(payload, callback) { postMessage({ type: 'create' }); @@ -140,6 +143,7 @@ @param {Object} payload example: {id: 1, jsonrpc: '2.0', 'method': 'eth_someMethod', params: []} @param {Function} callback the callback to call */ + // TODO transform to: send(method, params, callback) EthereumProvider.prototype.send = function send(payload, callback) { this._addResponseCallback(payload, callback); @@ -153,12 +157,13 @@ delete window.EventEmitter; - window.ethereumProvider = new EthereumProvider(); + // TODO set real ethereum provider + // window.ethereum = new EthereumProvider(); // For backwards compatibility of web3.currentProvider; EthereumProvider.prototype.sendSync = function () { - return {jsonrpc: '2.0', error: {"code": -32603, message: 'Sync calls are not supported in Mist.'}}; + return {jsonrpc: '2.0', error: {"code": -32603, message: 'Sync calls are not anymore supported in Mist :\\'}}; }; EthereumProvider.prototype.sendAsync = EthereumProvider.prototype.send; EthereumProvider.prototype.isConnected = function () { diff --git a/modules/preloader/mistUI.js b/modules/preloader/mistUI.js index 707357386..e44e297b0 100644 --- a/modules/preloader/mistUI.js +++ b/modules/preloader/mistUI.js @@ -3,7 +3,7 @@ */ require('./include/common')('mist'); -require('./include/ethereumProvider.js'); +require('./include/web3CurrentProvider.js'); const { ipcRenderer, remote, webFrame } = require('electron'); // eslint-disable-line import/newline-after-import const { Menu, MenuItem } = remote; const dbSync = require('../dbSync.js'); diff --git a/modules/preloader/popupWindows.js b/modules/preloader/popupWindows.js index 4f049e473..31f874e57 100644 --- a/modules/preloader/popupWindows.js +++ b/modules/preloader/popupWindows.js @@ -3,7 +3,7 @@ */ require('./popupWindowsNoWeb3.js'); -require('./include/ethereumProvider.js'); +require('./include/web3CurrentProvider.js'); const Q = require('bluebird'); const web3Admin = require('../web3Admin.js'); const https = require('https'); diff --git a/modules/preloader/splashScreen.js b/modules/preloader/splashScreen.js index d1f7df23e..c98ec3749 100644 --- a/modules/preloader/splashScreen.js +++ b/modules/preloader/splashScreen.js @@ -1,5 +1,5 @@ require('./include/common')('splashscreen'); -require('./include/ethereumProvider.js'); +require('./include/web3CurrentProvider.js'); const mist = require('./include/mistAPI.js'); const { ipcRenderer, remote, webFrame } = require('electron'); From aed9f69a704c6b711659e40a30843dc2a7987ad8 Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Thu, 29 Jun 2017 17:10:15 -0300 Subject: [PATCH 11/13] Removing useragent override from webview tag (see PR #2612) --- interface/client/templates/views/webview.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/client/templates/views/webview.html b/interface/client/templates/views/webview.html index 269fc80e1..98f278e49 100644 --- a/interface/client/templates/views/webview.html +++ b/interface/client/templates/views/webview.html @@ -3,7 +3,7 @@ {{#if $eq _id "tests"}} {{else}} - + {{/if}} From 44b7bb92feee2ba20da23f7bd553d15fdd9c18f5 Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Thu, 29 Jun 2017 17:45:45 -0300 Subject: [PATCH 12/13] Adding globals to ignore list --- .eslintrc.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.eslintrc.yml b/.eslintrc.yml index 44e26c075..18dace5e9 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -42,3 +42,6 @@ globals: # don't warn about missing declarations Tabs: true Tracker: true _: true + window: true + location: true + From 62021dccdb867cc186d3b1a619d6e3f499888c42 Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Tue, 4 Jul 2017 17:06:05 -0300 Subject: [PATCH 13/13] Downgrading to electron 1.4.15 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a89c38fca..e99a81efb 100644 --- a/README.md +++ b/README.md @@ -41,14 +41,14 @@ To run mist in development you need: - [Node.js](https://nodejs.org) `v6.x` (use the prefered installation method for your OS) - [Meteor](https://www.meteor.com/install) javascript app framework - [Yarn](https://yarnpkg.com/) package manager -- [Electron](http://electron.atom.io/) `v1.6.11` cross platform desktop app framework +- [Electron](http://electron.atom.io/) `v1.4.15` cross platform desktop app framework - [Gulp](http://gulpjs.com/) build and automation system Install the latter ones via: $ curl https://install.meteor.com/ | sh $ curl -o- -L https://yarnpkg.com/install.sh | bash - $ yarn global add electron@1.6.11 + $ yarn global add electron@1.4.15 $ yarn global add gulp ### Initialisation