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