diff options
author | Chen Wei <chenwei@byzantine-lab.io> | 2019-07-18 14:14:50 +0800 |
---|---|---|
committer | Chen Wei <chenwei@byzantine-lab.io> | 2019-07-18 14:14:50 +0800 |
commit | 72099b5836825e4423a52734e521663ba939238f (patch) | |
tree | dfc9e266c4ccb5d361ab4c8ce3f606432dc5bb9f | |
parent | 107553f77c32b89792d42ab7d174eade56d1b63c (diff) | |
download | tangerine-wallet-browser-72099b5836825e4423a52734e521663ba939238f.tar tangerine-wallet-browser-72099b5836825e4423a52734e521663ba939238f.tar.gz tangerine-wallet-browser-72099b5836825e4423a52734e521663ba939238f.tar.bz2 tangerine-wallet-browser-72099b5836825e4423a52734e521663ba939238f.tar.lz tangerine-wallet-browser-72099b5836825e4423a52734e521663ba939238f.tar.xz tangerine-wallet-browser-72099b5836825e4423a52734e521663ba939238f.tar.zst tangerine-wallet-browser-72099b5836825e4423a52734e521663ba939238f.zip |
1. rename stream target name 2. do not expose web3
-rw-r--r-- | app/scripts/contentscript.js | 6 | ||||
-rw-r--r-- | app/scripts/inpage.js | 18 | ||||
-rw-r--r-- | app/scripts/lib/auto-reload.js | 24 |
3 files changed, 24 insertions, 24 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 9268eef99..aa9f51d0e 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -37,7 +37,7 @@ function injectScript (content) { scriptTag.setAttribute('async', false) scriptTag.textContent = content container.insertBefore(scriptTag, container.children[0]) - container.removeChild(scriptTag) + // container.removeChild(scriptTag) } catch (e) { console.error('MetaMask script injection failed', e) } @@ -60,8 +60,8 @@ async function start () { async function setupStreams () { // the transport-specific streams for communication between inpage and background const pageStream = new LocalMessageDuplexStream({ - name: 'contentscript', - target: 'inpage', + name: 'contentscript_tangerine', + target: 'inpage_tangerine', }) const extensionPort = extension.runtime.connect({ name: 'contentscript' }) const extensionStream = new PortStream(extensionPort) diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index 4ab361469..705741cf1 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -19,8 +19,8 @@ log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn') // setup background connection const metamaskStream = new LocalMessageDuplexStream({ - name: 'inpage', - target: 'contentscript', + name: 'inpage_tangerine', + target: 'contentscript_tangerine', }) // compose the inpage provider @@ -115,13 +115,13 @@ window.tangerine = createStandardProvider(proxiedInpageProvider) // setup web3 // -if (typeof window.web3 !== 'undefined') { - throw new Error(`MetaMask detected another web3. - MetaMask will not work reliably with another web3 extension. - This usually happens if you have two MetaMasks installed, - or MetaMask and another web3 extension. Please remove one - and try again.`) -} +// if (typeof window.web3 !== 'undefined') { +// throw new Error(`MetaMask detected another web3. +// MetaMask will not work reliably with another web3 extension. +// This usually happens if you have two MetaMasks installed, +// or MetaMask and another web3 extension. Please remove one +// and try again.`) +// } const web3 = new Web3(proxiedInpageProvider) web3.setProvider = function () { diff --git a/app/scripts/lib/auto-reload.js b/app/scripts/lib/auto-reload.js index 667176dd7..62f5486ee 100644 --- a/app/scripts/lib/auto-reload.js +++ b/app/scripts/lib/auto-reload.js @@ -6,18 +6,18 @@ function setupDappAutoReload (web3, observable) { let lastTimeUsed let lastSeenNetwork - global.web3 = new Proxy(web3, { - get: (_web3, key) => { - // get the time of use - lastTimeUsed = Date.now() - // return value normally - return _web3[key] - }, - set: (_web3, key, value) => { - // set value normally - _web3[key] = value - }, - }) + // global.web3 = new Proxy(web3, { + // get: (_web3, key) => { + // // get the time of use + // lastTimeUsed = Date.now() + // // return value normally + // return _web3[key] + // }, + // set: (_web3, key, value) => { + // // set value normally + // _web3[key] = value + // }, + // }) observable.subscribe(function (state) { // if the auto refresh on network change is false do not |