aboutsummaryrefslogtreecommitdiffstats
path: root/mascara/src/lib/setup-provider.js
diff options
context:
space:
mode:
Diffstat (limited to 'mascara/src/lib/setup-provider.js')
-rw-r--r--mascara/src/lib/setup-provider.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/mascara/src/lib/setup-provider.js b/mascara/src/lib/setup-provider.js
new file mode 100644
index 000000000..4f2432ae4
--- /dev/null
+++ b/mascara/src/lib/setup-provider.js
@@ -0,0 +1,22 @@
+const setupIframe = require('./setup-iframe.js')
+const MetamaskInpageProvider = require('../../../app/scripts/lib/inpage-provider.js')
+
+module.exports = getProvider
+
+
+function getProvider(){
+ 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',
+ sandboxAttributes: ['allow-scripts', 'allow-popups', 'allow-same-origin'],
+ container: document.body,
+ })
+
+ var inpageProvider = new MetamaskInpageProvider(iframeStream)
+ return inpageProvider
+
+}