aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.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/metamask-controller.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/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 218f1f72a..81b232730 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -12,6 +12,7 @@ module.exports = class MetamaskController {
constructor (opts) {
this.opts = opts
+ this.listeners = []
this.configManager = new ConfigManager(opts)
this.idStore = new IdentityStore({
configManager: this.configManager,
@@ -112,9 +113,9 @@ module.exports = class MetamaskController {
}
sendUpdate () {
- if (this.remote) {
- this.remote.sendUpdate(this.getState())
- }
+ this.listeners.forEach((remote) => {
+ remote.sendUpdate(this.getState())
+ })
}
initializeProvider (opts) {
@@ -130,10 +131,17 @@ module.exports = class MetamaskController {
},
// tx signing
approveTransaction: this.newUnsignedTransaction.bind(this),
- signTransaction: idStore.signTransaction.bind(idStore),
+ signTransaction: (...args) => {
+ idStore.signTransaction(...args)
+ this.sendUpdate()
+ },
+
// msg signing
approveMessage: this.newUnsignedMessage.bind(this),
- signMessage: idStore.signMessage.bind(idStore),
+ signMessage: (...args) => {
+ idStore.signMessage(...args)
+ this.sendUpdate()
+ },
}
var provider = MetaMaskProvider(providerOpts)
@@ -193,6 +201,8 @@ module.exports = class MetamaskController {
// It's locked
if (!state.isUnlocked) {
+
+ // Allow the environment to define an unlock message.
this.opts.unlockAccountMessage()
idStore.addUnconfirmedTransaction(txParams, onTxDoneCb, noop)
@@ -200,6 +210,7 @@ module.exports = class MetamaskController {
} else {
idStore.addUnconfirmedTransaction(txParams, onTxDoneCb, (err, txData) => {
if (err) return onTxDoneCb(err)
+ this.sendUpdate()
this.opts.showUnconfirmedTx(txParams, txData, onTxDoneCb)
})
}
@@ -211,6 +222,7 @@ module.exports = class MetamaskController {
this.opts.unlockAccountMessage()
} else {
this.addUnconfirmedMessage(msgParams, cb)
+ this.sendUpdate()
}
}