diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-04-05 02:27:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 02:27:45 +0800 |
commit | 5d967eeebb9f3cf4c2d3fcfe0b74cf6e8440c3cb (patch) | |
tree | 38c3fac654c41df24f01b6de3aa453d68b259c07 /mascara/src/lib/setup-provider.js | |
parent | 39181ed33f1b9829f82c44d2f21e2f3ab1d1c979 (diff) | |
parent | 4779999bfc7e03eedf3fd2702f7f448d751218f8 (diff) | |
download | tangerine-wallet-browser-5d967eeebb9f3cf4c2d3fcfe0b74cf6e8440c3cb.tar tangerine-wallet-browser-5d967eeebb9f3cf4c2d3fcfe0b74cf6e8440c3cb.tar.gz tangerine-wallet-browser-5d967eeebb9f3cf4c2d3fcfe0b74cf6e8440c3cb.tar.bz2 tangerine-wallet-browser-5d967eeebb9f3cf4c2d3fcfe0b74cf6e8440c3cb.tar.lz tangerine-wallet-browser-5d967eeebb9f3cf4c2d3fcfe0b74cf6e8440c3cb.tar.xz tangerine-wallet-browser-5d967eeebb9f3cf4c2d3fcfe0b74cf6e8440c3cb.tar.zst tangerine-wallet-browser-5d967eeebb9f3cf4c2d3fcfe0b74cf6e8440c3cb.zip |
Merge pull request #1307 from MetaMask/mascara
Proof of Concept: Mascara
Diffstat (limited to 'mascara/src/lib/setup-provider.js')
-rw-r--r-- | mascara/src/lib/setup-provider.js | 22 |
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 + +} |