mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Clean up
This commit is contained in:
parent
19302778ee
commit
29a602a89b
@ -24,7 +24,6 @@ class PreferencesController {
|
||||
}
|
||||
|
||||
getSelectedAddress (_address) {
|
||||
console.log('PREFERNCES: getSelectedAddress was called')
|
||||
return this.store.getState().selectedAddress
|
||||
}
|
||||
|
||||
|
@ -14,163 +14,8 @@ background.on('ready', (_) => {
|
||||
context: 'dapp',
|
||||
})
|
||||
pageStream.pipe(swStream).pipe(pageStream)
|
||||
console.log('********************WOOP*********************')
|
||||
|
||||
})
|
||||
|
||||
background.on('error', console.error)
|
||||
background.startWorker()
|
||||
|
||||
/*
|
||||
const urlUtil = require('url')
|
||||
const extend = require('xtend')
|
||||
const Dnode = require('dnode')
|
||||
const eos = require('end-of-stream')
|
||||
const ParentStream = require('iframe-stream').ParentStream
|
||||
const PortStream = require('../app/scripts/lib/port-stream.js')
|
||||
const notification = require('../app/scripts/lib/notifications.js')
|
||||
const messageManager = require('../app/scripts/lib/message-manager')
|
||||
const setupMultiplex = require('../app/scripts/lib/stream-utils.js').setupMultiplex
|
||||
const MetamaskController = require('../app/scripts/metamask-controller')
|
||||
const extension = require('../app/scripts/lib/extension')
|
||||
|
||||
const STORAGE_KEY = 'metamask-config'
|
||||
|
||||
|
||||
initializeZeroClient()
|
||||
|
||||
function initializeZeroClient() {
|
||||
|
||||
const controller = new MetamaskController({
|
||||
// User confirmation callbacks:
|
||||
showUnconfirmedMessage,
|
||||
unlockAccountMessage,
|
||||
showUnapprovedTx,
|
||||
// Persistence Methods:
|
||||
setData,
|
||||
loadData,
|
||||
})
|
||||
const idStore = controller.idStore
|
||||
|
||||
function unlockAccountMessage () {
|
||||
console.log('notif stub - unlockAccountMessage')
|
||||
}
|
||||
|
||||
function showUnconfirmedMessage (msgParams, msgId) {
|
||||
console.log('notif stub - showUnconfirmedMessage')
|
||||
}
|
||||
|
||||
function showUnapprovedTx (txParams, txData, onTxDoneCb) {
|
||||
console.log('notif stub - showUnapprovedTx')
|
||||
}
|
||||
|
||||
//
|
||||
// connect to other contexts
|
||||
//
|
||||
|
||||
var connectionStream = new ParentStream()
|
||||
|
||||
connectRemote(connectionStream, getParentHref())
|
||||
|
||||
function connectRemote (connectionStream, originDomain) {
|
||||
var isMetaMaskInternalProcess = (originDomain === '127.0.0.1:9001')
|
||||
if (isMetaMaskInternalProcess) {
|
||||
// communication with popup
|
||||
setupTrustedCommunication(connectionStream, 'MetaMask')
|
||||
} else {
|
||||
// communication with page
|
||||
setupUntrustedCommunication(connectionStream, originDomain)
|
||||
}
|
||||
}
|
||||
|
||||
function setupUntrustedCommunication (connectionStream, originDomain) {
|
||||
// setup multiplexing
|
||||
var mx = setupMultiplex(connectionStream)
|
||||
// connect features
|
||||
controller.setupProviderConnection(mx.createStream('provider'), originDomain)
|
||||
controller.setupPublicConfig(mx.createStream('publicConfig'))
|
||||
}
|
||||
|
||||
function setupTrustedCommunication (connectionStream, originDomain) {
|
||||
// setup multiplexing
|
||||
var mx = setupMultiplex(connectionStream)
|
||||
// connect features
|
||||
setupControllerConnection(mx.createStream('controller'))
|
||||
controller.setupProviderConnection(mx.createStream('provider'), originDomain)
|
||||
}
|
||||
|
||||
//
|
||||
// remote features
|
||||
//
|
||||
|
||||
function setupControllerConnection (stream) {
|
||||
controller.stream = stream
|
||||
var api = controller.getApi()
|
||||
var dnode = Dnode(api)
|
||||
stream.pipe(dnode).pipe(stream)
|
||||
dnode.on('remote', (remote) => {
|
||||
// push updates to popup
|
||||
controller.ethStore.on('update', controller.sendUpdate.bind(controller))
|
||||
controller.listeners.push(remote)
|
||||
idStore.on('update', controller.sendUpdate.bind(controller))
|
||||
|
||||
// teardown on disconnect
|
||||
eos(stream, () => {
|
||||
controller.ethStore.removeListener('update', controller.sendUpdate.bind(controller))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function loadData () {
|
||||
var oldData = getOldStyleData()
|
||||
var newData
|
||||
try {
|
||||
newData = JSON.parse(window.localStorage[STORAGE_KEY])
|
||||
} catch (e) {}
|
||||
|
||||
var data = extend({
|
||||
meta: {
|
||||
version: 0,
|
||||
},
|
||||
data: {
|
||||
config: {
|
||||
provider: {
|
||||
type: 'testnet',
|
||||
},
|
||||
},
|
||||
},
|
||||
}, oldData || null, newData || null)
|
||||
return data
|
||||
}
|
||||
|
||||
function getOldStyleData () {
|
||||
var config, wallet, seedWords
|
||||
|
||||
var result = {
|
||||
meta: { version: 0 },
|
||||
data: {},
|
||||
}
|
||||
|
||||
try {
|
||||
config = JSON.parse(window.localStorage['config'])
|
||||
result.data.config = config
|
||||
} catch (e) {}
|
||||
try {
|
||||
wallet = JSON.parse(window.localStorage['lightwallet'])
|
||||
result.data.wallet = wallet
|
||||
} catch (e) {}
|
||||
try {
|
||||
seedWords = window.localStorage['seedWords']
|
||||
result.data.seedWords = seedWords
|
||||
} catch (e) {}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function setData (data) {
|
||||
window.localStorage[STORAGE_KEY] = JSON.stringify(data)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@ 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')
|
||||
|
@ -5,7 +5,6 @@ module.exports = getProvider
|
||||
|
||||
|
||||
function getProvider(){
|
||||
|
||||
if (global.web3) {
|
||||
console.log('MetaMask ZeroClient - using environmental web3 provider')
|
||||
return global.web3.currentProvider
|
||||
@ -18,7 +17,6 @@ function getProvider(){
|
||||
})
|
||||
|
||||
var inpageProvider = new MetamaskInpageProvider(iframeStream)
|
||||
console.log('ABOUT TO RETURN INPAGE')
|
||||
return inpageProvider
|
||||
|
||||
}
|
||||
|
@ -19,13 +19,11 @@ const background = new SWcontroller({
|
||||
fileName: '/popup/sw-build.js',
|
||||
})
|
||||
background.on('ready', (readSw) => {
|
||||
// var inpageProvider = new MetamaskInpageProvider(SwStream(background.controller))
|
||||
// startPopup(inpageProvider)
|
||||
let swStream = SwStream({
|
||||
serviceWorker: background.controller,
|
||||
})
|
||||
startPopup()
|
||||
})
|
||||
startPopup(swStream)
|
||||
})
|
||||
background.on('message', (messageEvent) => {debugger})
|
||||
|
||||
background.startWorker()
|
||||
console.log('hello from /library/popup.js')
|
||||
|
@ -6,13 +6,12 @@ const SwGlobalListener = require('sw-stream/lib/sw-global-listener.js')
|
||||
const connectionListener = new SwGlobalListener(self)
|
||||
const setupMultiplex = require('../app/scripts/lib/stream-utils.js').setupMultiplex
|
||||
const PortStream = require('../app/scripts/lib/port-stream.js')
|
||||
// const notification = require('../app/scripts/lib/notifications.js')
|
||||
|
||||
const DbController = require('./controllers/index-db-controller')
|
||||
|
||||
const MetamaskController = require('../app/scripts/metamask-controller')
|
||||
const extension = {} //require('../app/scripts/lib/extension')
|
||||
// const LocalStorageStore = require('obs-store/lib/localStorage')
|
||||
|
||||
const storeTransform = require('obs-store/lib/transform')
|
||||
const Migrator = require('../app/scripts/lib/migrator/')
|
||||
const migrations = require('../app/scripts/migrations/')
|
||||
@ -80,9 +79,9 @@ function setupController (initState, client) {
|
||||
|
||||
const controller = new MetamaskController({
|
||||
// User confirmation callbacks:
|
||||
showUnconfirmedMessage: triggerUi,
|
||||
unlockAccountMessage: triggerUi,
|
||||
showUnapprovedTx: triggerUi,
|
||||
showUnconfirmedMessage: noop,
|
||||
unlockAccountMessage: noop,
|
||||
showUnapprovedTx: noop,
|
||||
// initial state
|
||||
initState,
|
||||
})
|
||||
@ -128,7 +127,7 @@ function setupController (initState, client) {
|
||||
popupIsOpen = true
|
||||
} else {
|
||||
// communication with page
|
||||
setupUntrustedCommunication(connectionStream, originDomain)
|
||||
setupUntrustedCommunication(connectionStream, context)
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,13 +151,4 @@ function setupController (initState, client) {
|
||||
return Promise.resolve()
|
||||
|
||||
}
|
||||
|
||||
// // //
|
||||
// // // Etc...
|
||||
// // //
|
||||
|
||||
// // // popup trigger
|
||||
|
||||
/*send a message to the client that has focus and tell it to open a window*/
|
||||
function triggerUi () {
|
||||
}
|
||||
function noop () {}
|
||||
|
Loading…
Reference in New Issue
Block a user