WIP: lost enital call from dapp to getAccounts

feature/default_network_editable
frankiebee 8 years ago
parent a20a237282
commit 84b3415b44
  1. 1
      app/scripts/controllers/preferences.js
  2. 1
      app/scripts/metamask-controller.js
  3. 12
      library/controller.js
  4. 9
      library/example/index.js
  5. 5
      library/index.js
  6. 4
      library/lib/setup-provider.js
  7. 5
      library/popup.js
  8. 1
      library/sw-core.js

@ -24,6 +24,7 @@ class PreferencesController {
}
getSelectedAddress (_address) {
console.log('PREFERNCES: getSelectedAddress was called')
return this.store.getState().selectedAddress
}

@ -165,6 +165,7 @@ module.exports = class MetamaskController extends EventEmitter {
rpcUrl: this.configManager.getCurrentRpcAddress(),
// account mgmt
getAccounts: (cb) => {
console.log('METAMASK CONTROLLER: getAccounts was called')
let selectedAddress = this.preferencesController.getSelectedAddress()
let result = selectedAddress ? [selectedAddress] : []
cb(null, result)

@ -6,17 +6,17 @@ const background = new SWcontroller({
fileName: '/popup/sw-build.js',
})
background.on('ready', (readSw) => {
background.on('ready', (_) => {
// var inpageProvider = new MetamaskInpageProvider(SwStream(background.controller))
let pageStream = new ParentStream()
let swStream = SwStream(background.controller)
pageStream.pipe(swStream).pipe(pageStream)
console.log('********************WOOP*********************')
})
background.on('error', console.error)
background.startWorker()
console.log('hello from controller')
/*
const urlUtil = require('url')
const extend = require('xtend')
@ -167,14 +167,6 @@ function initializeZeroClient() {
window.localStorage[STORAGE_KEY] = JSON.stringify(data)
}
function getParentHref(){
try {
var parentLocation = window.parent.location
return parentLocation.hostname + ':' + parentLocation.port
} catch (err) {
return 'unknown'
}
}
}

@ -1,4 +1,5 @@
window.addEventListener('load', web3Detect)
window.addEventListener('message', console.warn)
function web3Detect() {
if (global.web3) {
@ -12,18 +13,18 @@ function web3Detect() {
function startApp(){
console.log('app started')
var primaryAccount = null
var primaryAccount
console.log('getting main account...')
web3.eth.getAccounts(function(err, addresses){
if (err) throw err
web3.eth.getAccounts((err, addresses) => {
if (err) console.error(err)
console.log('set address', addresses[0])
debugger
primaryAccount = addresses[0]
})
document.querySelector('.action-button-1').addEventListener('click', function(){
console.log('saw click')
console.log('sending tx')
primaryAccount
web3.eth.sendTransaction({
from: primaryAccount,
to: primaryAccount,

@ -5,13 +5,12 @@ const setupProvider = require('./lib/setup-provider.js')
// setup web3
//
var provider = setupProvider()
hijackProvider(provider)
// hijackProvider(provider)
var web3 = new Web3(provider)
web3.setProvider = function(){
console.log('MetaMask - overrode web3.setProvider')
}
console.log('metamask lib hijacked provider')
//
//
// export web3
//

@ -10,15 +10,15 @@ function getProvider(){
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',
zeroClientProvider: 'http://localhost:9001',
sandboxAttributes: ['allow-scripts', 'allow-popups', 'allow-same-origin'],
container: document.body,
})
var inpageProvider = new MetamaskInpageProvider(iframeStream)
console.log('ABOUT TO RETURN INPAGE')
return inpageProvider
}

@ -13,11 +13,6 @@ injectCss(css)
var name = 'popup'
window.METAMASK_UI_TYPE = name
var iframeStream = setupIframe({
zeroClientProvider: 'http://localhost:9001',
sandboxAttributes: ['allow-scripts', 'allow-popups', 'allow-same-origin'],
container: document.body,
})
console.log('outside:open')
const background = new SWcontroller({

@ -116,6 +116,7 @@ function setupController (initState, client) {
need to write a service worker stream for this
*/
connectionListener.on('remote', (portStream, messageEvent) => {
console.log('REMOTE CONECTION FOUND***********')
connectRemote(portStream, messageEvent.origin)
})

Loading…
Cancel
Save