1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 11:01:41 +01:00
metamask-extension/library/lib/setup-provider.js

26 lines
689 B
JavaScript
Raw Normal View History

2016-08-26 20:08:23 +02:00
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://127.0.0.1:9001',
2016-08-26 20:08:23 +02:00
sandboxAttributes: ['allow-scripts', 'allow-popups', 'allow-same-origin'],
container: document.body,
2016-08-26 20:08:23 +02:00
})
var inpageProvider = new MetamaskInpageProvider(iframeStream)
return inpageProvider
}