aboutsummaryrefslogtreecommitdiffstats
path: root/mascara/src
diff options
context:
space:
mode:
Diffstat (limited to 'mascara/src')
-rw-r--r--mascara/src/lib/setup-provider.js4
-rw-r--r--mascara/src/mascara.js15
-rw-r--r--mascara/src/proxy.js (renamed from mascara/src/dapp-connection.js)2
3 files changed, 14 insertions, 7 deletions
diff --git a/mascara/src/lib/setup-provider.js b/mascara/src/lib/setup-provider.js
index 4f2432ae4..62335b18d 100644
--- a/mascara/src/lib/setup-provider.js
+++ b/mascara/src/lib/setup-provider.js
@@ -4,14 +4,14 @@ const MetamaskInpageProvider = require('../../../app/scripts/lib/inpage-provider
module.exports = getProvider
-function getProvider(){
+function getProvider(opts){
if (global.web3) {
console.log('MetaMask ZeroClient - using environmental web3 provider')
return global.web3.currentProvider
}
console.log('MetaMask ZeroClient - injecting zero-client iframe!')
var iframeStream = setupIframe({
- zeroClientProvider: 'http://localhost:9001',
+ zeroClientProvider: opts.mascaraUrl,
sandboxAttributes: ['allow-scripts', 'allow-popups', 'allow-same-origin'],
container: document.body,
})
diff --git a/mascara/src/mascara.js b/mascara/src/mascara.js
index 759353c1b..f9bed7e52 100644
--- a/mascara/src/mascara.js
+++ b/mascara/src/mascara.js
@@ -1,15 +1,22 @@
const Web3 = require('web3')
const setupProvider = require('./lib/setup-provider.js')
+const MASACARA_DOMAIN = 'http://localhost:9001'
+
//
// setup web3
//
-var provider = setupProvider()
-hijackProvider(provider)
+
+var provider = setupProvider({
+ mascaraUrl: MASACARA_DOMAIN + '/proxy/',
+})
+instrumentForUserInteractionTriggers(provider)
+
var web3 = new Web3(provider)
web3.setProvider = function(){
console.log('MetaMask - overrode web3.setProvider')
}
+
//
//
// export web3
@@ -25,12 +32,12 @@ var shouldPop = false
window.addEventListener('click', function(){
if (!shouldPop) return
shouldPop = false
- window.open('http://localhost:9001/popup/popup.html', '', 'width=360 height=500')
+ window.open(MASACARA_DOMAIN, '', 'width=360 height=500')
console.log('opening window...')
})
-function hijackProvider(provider){
+function instrumentForUserInteractionTriggers(provider){
var _super = provider.sendAsync.bind(provider)
provider.sendAsync = function(payload, cb){
if (payload.method === 'eth_sendTransaction') {
diff --git a/mascara/src/dapp-connection.js b/mascara/src/proxy.js
index 30680c9d7..e580076c1 100644
--- a/mascara/src/dapp-connection.js
+++ b/mascara/src/proxy.js
@@ -4,7 +4,7 @@ const SwStream = require('sw-stream/lib/sw-stream.js')
const SetupUntrustedComunication = ('./lib/setup-untrusted-connection.js')
const background = new SWcontroller({
- fileName: '/popup/sw-build.js',
+ fileName: '/background.js',
})
const pageStream = new ParentStream()