aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-07-04 06:39:25 +0800
committerDan Finlay <dan@danfinlay.com>2017-07-04 06:39:25 +0800
commit5eb3d5d485b17b98b19443d8def2f03dec9b38ef (patch)
tree1b814f7706a9eb559824624b87937631ac3ca505 /app
parentd0d01552da8d0a6f58fb7c5be16947175ec90267 (diff)
downloadtangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.tar
tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.tar.gz
tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.tar.bz2
tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.tar.lz
tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.tar.xz
tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.tar.zst
tangerine-wallet-browser-5eb3d5d485b17b98b19443d8def2f03dec9b38ef.zip
Make folder for responsive UI
Diffstat (limited to 'app')
-rw-r--r--app/home.html (renamed from app/send-token.html)2
-rw-r--r--app/scripts/popup-core.js2
-rw-r--r--app/scripts/responsive-core.js54
-rw-r--r--app/scripts/responsive.js (renamed from app/scripts/send-token.js)2
4 files changed, 57 insertions, 3 deletions
diff --git a/app/send-token.html b/app/home.html
index 5f98e1072..b7b8adbeb 100644
--- a/app/send-token.html
+++ b/app/home.html
@@ -6,6 +6,6 @@
</head>
<body>
<div id="app-content"></div>
- <script src="./scripts/send-token.js" type="text/javascript" charset="utf-8"></script>
+ <script src="./scripts/responsive.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
diff --git a/app/scripts/popup-core.js b/app/scripts/popup-core.js
index f1eb394d7..156be795a 100644
--- a/app/scripts/popup-core.js
+++ b/app/scripts/popup-core.js
@@ -2,7 +2,7 @@ const EventEmitter = require('events').EventEmitter
const async = require('async')
const Dnode = require('dnode')
const EthQuery = require('eth-query')
-const launchMetamaskUi = require('../../ui')
+const launchMetamaskUi = require('../../ui/classic')
const StreamProvider = require('web3-stream-provider')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
diff --git a/app/scripts/responsive-core.js b/app/scripts/responsive-core.js
new file mode 100644
index 000000000..3760facfa
--- /dev/null
+++ b/app/scripts/responsive-core.js
@@ -0,0 +1,54 @@
+const EventEmitter = require('events').EventEmitter
+const async = require('async')
+const Dnode = require('dnode')
+const EthQuery = require('eth-query')
+const launchMetamaskUi = require('../../ui/responsive')
+const StreamProvider = require('web3-stream-provider')
+const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
+
+
+module.exports = initializePopup
+
+
+function initializePopup ({ container, connectionStream }, cb) {
+ // setup app
+ async.waterfall([
+ (cb) => connectToAccountManager(connectionStream, cb),
+ (accountManager, cb) => launchMetamaskUi({ container, accountManager }, cb),
+ ], cb)
+}
+
+function connectToAccountManager (connectionStream, cb) {
+ // setup communication with background
+ // setup multiplexing
+ var mx = setupMultiplex(connectionStream)
+ // connect features
+ setupControllerConnection(mx.createStream('controller'), cb)
+ setupWeb3Connection(mx.createStream('provider'))
+}
+
+function setupWeb3Connection (connectionStream) {
+ var providerStream = new StreamProvider()
+ providerStream.pipe(connectionStream).pipe(providerStream)
+ connectionStream.on('error', console.error.bind(console))
+ providerStream.on('error', console.error.bind(console))
+ global.ethereumProvider = providerStream
+ global.ethQuery = new EthQuery(providerStream)
+}
+
+function setupControllerConnection (connectionStream, cb) {
+ // this is a really sneaky way of adding EventEmitter api
+ // to a bi-directional dnode instance
+ var eventEmitter = new EventEmitter()
+ var accountManagerDnode = Dnode({
+ sendUpdate: function (state) {
+ eventEmitter.emit('update', state)
+ },
+ })
+ connectionStream.pipe(accountManagerDnode).pipe(connectionStream)
+ accountManagerDnode.once('remote', function (accountManager) {
+ // setup push events
+ accountManager.on = eventEmitter.on.bind(eventEmitter)
+ cb(null, accountManager)
+ })
+}
diff --git a/app/scripts/send-token.js b/app/scripts/responsive.js
index 9e6868884..512065309 100644
--- a/app/scripts/send-token.js
+++ b/app/scripts/responsive.js
@@ -1,4 +1,4 @@
-const startPopup = require('./popup-core')
+const startPopup = require('./responsive-core')
const PortStream = require('./lib/port-stream.js')
const ExtensionPlatform = require('./platforms/extension')
const extension = require('extensionizer')