From 7aa120e630fcc7910114ba825c015a602a3b9403 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 6 Jul 2016 20:20:40 -0700 Subject: [PATCH 1/3] web3 injection - use web3 dist for faster injection --- app/scripts/contentscript.js | 10 ++++++++-- app/scripts/inpage.js | 4 +--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index f4f064163..44cac3b0a 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -1,14 +1,13 @@ const LocalMessageDuplexStream = require('./lib/local-message-stream.js') const PortStream = require('./lib/port-stream.js') const ObjectMultiplex = require('./lib/obj-multiplex') -// const urlUtil = require('url') if (shouldInjectWeb3()) { setupInjection() + setTimeout(setupStreams, 200) } function setupInjection(){ - // inject in-page script var scriptTag = document.createElement('script') scriptTag.src = chrome.extension.getURL('scripts/inpage.js') @@ -16,6 +15,13 @@ function setupInjection(){ var container = document.head || document.documentElement // append as first child container.insertBefore(scriptTag, container.children[0]) +} + +function setupStreams(){ + + const LocalMessageDuplexStream = require('./lib/local-message-stream.js') + const PortStream = require('./lib/port-stream.js') + const ObjectMultiplex = require('./lib/obj-multiplex') // setup communication to page and plugin var pageStream = new LocalMessageDuplexStream({ diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index e6f4078c8..40dce54f1 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -1,12 +1,10 @@ cleanContextForImports() -const Web3 = require('web3') +require('web3/dist/web3.min.js') const LocalMessageDuplexStream = require('./lib/local-message-stream.js') const setupDappAutoReload = require('./lib/auto-reload.js') const MetamaskInpageProvider = require('./lib/inpage-provider.js') restoreContextAfterImports() -// remove from window -delete window.Web3 // // setup plugin communication From ec5adf014e98d4495067be39660c01f975212640 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 6 Jul 2016 20:22:20 -0700 Subject: [PATCH 2/3] changelog - add web3 min dist --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cb788a0d..547573eb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix formatting of ETH balance - Fix formatting of account details. +- Use web3 minified dist for faster inject times ## 2.5.0 2016-06-29 From 5c4c902c94f03f50c0169e35cb0fea81df5193e6 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 6 Jul 2016 20:32:36 -0700 Subject: [PATCH 3/3] appease the linting gods --- app/scripts/contentscript.js | 4 ---- app/scripts/inpage.js | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 44cac3b0a..8b46f603c 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -19,10 +19,6 @@ function setupInjection(){ function setupStreams(){ - const LocalMessageDuplexStream = require('./lib/local-message-stream.js') - const PortStream = require('./lib/port-stream.js') - const ObjectMultiplex = require('./lib/obj-multiplex') - // setup communication to page and plugin var pageStream = new LocalMessageDuplexStream({ name: 'contentscript', diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index 40dce54f1..f5e54cd7b 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -1,3 +1,4 @@ +/*global Web3*/ cleanContextForImports() require('web3/dist/web3.min.js') const LocalMessageDuplexStream = require('./lib/local-message-stream.js')