aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 7cb25d8bf..854b679da 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -23,7 +23,7 @@ const controller = new MetamaskController({
loadData,
})
const keyringController = controller.keyringController
-
+const txManager = controller.txManager
function triggerUi () {
if (!popupIsOpen) notification.show()
}
@@ -97,12 +97,11 @@ function setupControllerConnection (stream) {
// plugin badge text
//
-keyringController.on('update', updateBadge)
+txManager.on('update', updateBadge)
function updateBadge () {
var label = ''
- var unconfTxs = controller.configManager.unconfirmedTxs()
- var unconfTxLen = Object.keys(unconfTxs).length
+ var unconfTxLen = controller.txManager.unConftxCount
var unconfMsgs = messageManager.unconfirmedMsgs()
var unconfMsgLen = Object.keys(unconfMsgs).length
var count = unconfTxLen + unconfMsgLen
@@ -113,6 +112,25 @@ function updateBadge () {
extension.browserAction.setBadgeBackgroundColor({ color: '#506F8B' })
}
+// txManger :: tx approvals and rejection cb's
+
+txManager.on('signed', function (txId) {
+ var approvalCb = this._unconfTxCbs[txId]
+
+ approvalCb(null, true)
+ // clean up
+ delete this._unconfTxCbs[txId]
+})
+
+txManager.on('rejected', function (txId) {
+ var approvalCb = this._unconfTxCbs[txId]
+ approvalCb(null, false)
+ // clean up
+ delete this._unconfTxCbs[txId]
+})
+
+// data :: setters/getters
+
function loadData () {
var oldData = getOldStyleData()
var newData