diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-03-31 02:28:22 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-03-31 02:28:22 +0800 |
commit | 29a602a89b176e7af3f15297c2f586a4ece0a726 (patch) | |
tree | b60329ec0f1ab4f41d0463f5f7c38729ba6f4ec6 | |
parent | 19302778ee0dd0535867cde29d4a5ce56d573dec (diff) | |
download | tangerine-wallet-browser-29a602a89b176e7af3f15297c2f586a4ece0a726.tar tangerine-wallet-browser-29a602a89b176e7af3f15297c2f586a4ece0a726.tar.gz tangerine-wallet-browser-29a602a89b176e7af3f15297c2f586a4ece0a726.tar.bz2 tangerine-wallet-browser-29a602a89b176e7af3f15297c2f586a4ece0a726.tar.lz tangerine-wallet-browser-29a602a89b176e7af3f15297c2f586a4ece0a726.tar.xz tangerine-wallet-browser-29a602a89b176e7af3f15297c2f586a4ece0a726.tar.zst tangerine-wallet-browser-29a602a89b176e7af3f15297c2f586a4ece0a726.zip |
Clean up
-rw-r--r-- | app/scripts/controllers/preferences.js | 1 | ||||
-rw-r--r-- | library/controller.js | 157 | ||||
-rw-r--r-- | library/index.js | 2 | ||||
-rw-r--r-- | library/lib/setup-provider.js | 2 | ||||
-rw-r--r-- | library/popup.js | 8 | ||||
-rw-r--r-- | library/sw-core.js | 22 |
6 files changed, 11 insertions, 181 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index dbd5aeaaa..c7f675a41 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -24,7 +24,6 @@ class PreferencesController { } getSelectedAddress (_address) { - console.log('PREFERNCES: getSelectedAddress was called') return this.store.getState().selectedAddress } diff --git a/library/controller.js b/library/controller.js index d4a76d316..1e9bc84d2 100644 --- a/library/controller.js +++ b/library/controller.js @@ -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) - } - - -} - -*/ diff --git a/library/index.js b/library/index.js index 3503d15cc..759353c1b 100644 --- a/library/index.js +++ b/library/index.js @@ -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') diff --git a/library/lib/setup-provider.js b/library/lib/setup-provider.js index a99fc1c68..1b53e7f54 100644 --- a/library/lib/setup-provider.js +++ b/library/lib/setup-provider.js @@ -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 } diff --git a/library/popup.js b/library/popup.js index 0c297d9a2..f294e5c69 100644 --- a/library/popup.js +++ b/library/popup.js @@ -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') diff --git a/library/sw-core.js b/library/sw-core.js index 9f399cccf..d39bfdbfb 100644 --- a/library/sw-core.js +++ b/library/sw-core.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 () {} |