aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-08-24 02:15:56 +0800
committerDan Finlay <dan@danfinlay.com>2016-08-24 02:15:56 +0800
commite5ca83d2bf7e97131e20da0ad352a38c7f8a2f86 (patch)
treeebebf02bcae19123cd5e972b225d4beb78780a5e /app/scripts/background.js
parent49ab51d8251a403e242de179541fddaa0d76031e (diff)
downloadtangerine-wallet-browser-e5ca83d2bf7e97131e20da0ad352a38c7f8a2f86.tar
tangerine-wallet-browser-e5ca83d2bf7e97131e20da0ad352a38c7f8a2f86.tar.gz
tangerine-wallet-browser-e5ca83d2bf7e97131e20da0ad352a38c7f8a2f86.tar.bz2
tangerine-wallet-browser-e5ca83d2bf7e97131e20da0ad352a38c7f8a2f86.tar.lz
tangerine-wallet-browser-e5ca83d2bf7e97131e20da0ad352a38c7f8a2f86.tar.xz
tangerine-wallet-browser-e5ca83d2bf7e97131e20da0ad352a38c7f8a2f86.tar.zst
tangerine-wallet-browser-e5ca83d2bf7e97131e20da0ad352a38c7f8a2f86.zip
Emit updates to all listeners on pending tx updates
Previously the metamask controller only supported a single UI event listener, which wasn't useful for having a separate notification UI open at the same time. Also reduced the notification's complexity down to a single method, which is heavily re-used. Still has an outstanding bug where if the plugin ui dismisses the last tx, it does not close the notification popup.
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js38
1 files changed, 5 insertions, 33 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 79f8f9fd9..9a324047b 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -3,9 +3,7 @@ const extend = require('xtend')
const Dnode = require('dnode')
const eos = require('end-of-stream')
const PortStream = require('./lib/port-stream.js')
-const createUnlockRequestNotification = require('./lib/notifications.js').createUnlockRequestNotification
-const createTxNotification = require('./lib/notifications.js').createTxNotification
-const createMsgNotification = require('./lib/notifications.js').createMsgNotification
+const notification = require('./lib/notifications.js')
const messageManager = require('./lib/message-manager')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const MetamaskController = require('./metamask-controller')
@@ -26,41 +24,15 @@ const controller = new MetamaskController({
const idStore = controller.idStore
function unlockAccountMessage () {
- createUnlockRequestNotification({
- title: 'Account Unlock Request',
- })
+ notification.show()
}
function showUnconfirmedMessage (msgParams, msgId) {
- var controllerState = controller.getState()
-
- createMsgNotification({
- imageifyIdenticons: false,
- txData: {
- msgParams: msgParams,
- time: (new Date()).getTime(),
- },
- identities: controllerState.identities,
- accounts: controllerState.accounts,
- onConfirm: idStore.approveMessage.bind(idStore, msgId, noop),
- onCancel: idStore.cancelMessage.bind(idStore, msgId),
- })
+ notification.show()
}
function showUnconfirmedTx (txParams, txData, onTxDoneCb) {
- var controllerState = controller.getState()
-
- createTxNotification({
- imageifyIdenticons: false,
- txData: {
- txParams: txParams,
- time: (new Date()).getTime(),
- },
- identities: controllerState.identities,
- accounts: controllerState.accounts,
- onConfirm: idStore.approveTransaction.bind(idStore, txData.id, noop),
- onCancel: idStore.cancelTransaction.bind(idStore, txData.id),
- })
+ notification.show()
}
//
@@ -109,7 +81,7 @@ function setupControllerConnection (stream) {
dnode.on('remote', (remote) => {
// push updates to popup
controller.ethStore.on('update', controller.sendUpdate.bind(controller))
- controller.remote = remote
+ controller.listeners.push(remote)
idStore.on('update', controller.sendUpdate.bind(controller))
// teardown on disconnect