1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

mascara - mascara lib - read mascara origin from env var

This commit is contained in:
kumavis 2017-04-05 10:27:04 -07:00
parent c1e14cd75b
commit a6c6ecf275

View File

@ -1,44 +1,41 @@
const Web3 = require('web3')
const setupProvider = require('./lib/setup-provider.js')
const MASACARA_DOMAIN = 'http://localhost:9001'
const MASCARA_ORIGIN = process.env.MASCARA_ORIGIN || 'http://localhost:9001'
console.log('MASCARA_ORIGIN:', MASCARA_ORIGIN)
//
// setup web3
//
var provider = setupProvider({
mascaraUrl: MASACARA_DOMAIN + '/proxy/',
const provider = setupProvider({
mascaraUrl: MASCARA_ORIGIN + '/proxy/',
})
instrumentForUserInteractionTriggers(provider)
var web3 = new Web3(provider)
web3.setProvider = function(){
console.log('MetaMask - overrode web3.setProvider')
}
//
//
// export web3
//
const web3 = new Web3(provider)
global.web3 = web3
//
// ui stuff
//
var shouldPop = false
window.addEventListener('click', function(){
let shouldPop = false
window.addEventListener('click', maybeTriggerPopup)
//
// util
//
function maybeTriggerPopup(){
if (!shouldPop) return
shouldPop = false
window.open(MASACARA_DOMAIN, '', 'width=360 height=500')
window.open(MASCARA_ORIGIN, '', 'width=360 height=500')
console.log('opening window...')
})
}
function instrumentForUserInteractionTriggers(provider){
var _super = provider.sendAsync.bind(provider)
const _super = provider.sendAsync.bind(provider)
provider.sendAsync = function(payload, cb){
if (payload.method === 'eth_sendTransaction') {
console.log('saw send')