1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/mascara/src/mascara.js

52 lines
970 B
JavaScript
Raw Normal View History

2016-08-26 20:08:23 +02:00
const Web3 = require('web3')
const setupProvider = require('./lib/setup-provider.js')
const MASACARA_DOMAIN = 'http://localhost:9001'
2016-08-26 20:08:23 +02:00
//
// setup web3
//
var provider = setupProvider({
mascaraUrl: MASACARA_DOMAIN + '/proxy/',
})
instrumentForUserInteractionTriggers(provider)
2016-08-26 20:08:23 +02:00
var web3 = new Web3(provider)
web3.setProvider = function(){
console.log('MetaMask - overrode web3.setProvider')
}
//
2016-08-26 20:08:23 +02:00
//
// export web3
//
global.web3 = web3
//
// ui stuff
//
var shouldPop = false
window.addEventListener('click', function(){
if (!shouldPop) return
shouldPop = false
window.open(MASACARA_DOMAIN, '', 'width=360 height=500')
2016-08-26 20:08:23 +02:00
console.log('opening window...')
})
function instrumentForUserInteractionTriggers(provider){
2016-08-26 20:08:23 +02:00
var _super = provider.sendAsync.bind(provider)
provider.sendAsync = function(payload, cb){
if (payload.method === 'eth_sendTransaction') {
console.log('saw send')
2016-08-26 20:08:23 +02:00
shouldPop = true
}
_super(payload, cb)
}
2016-10-26 22:43:26 +02:00
}