background - prepare state for notifcations

feature/default_network_editable
kumavis 8 years ago
parent 621e28f6a2
commit c82d7585b8
  1. 30
      app/scripts/background.js
  2. 40
      app/scripts/lib/notifications.js

@ -30,21 +30,37 @@ function unlockAccountMessage () {
}
function showUnconfirmedMessage (msgParams, msgId) {
var controllerState = controller.getState()
createMsgNotification({
title: 'New Unsigned Message',
msgParams: msgParams,
confirm: idStore.approveMessage.bind(idStore, msgId, noop),
cancel: idStore.cancelMessage.bind(idStore, msgId),
imageifyIdenticons: false,
txData: {
msgParams: opts.msgParams,
time: (new Date()).getTime(),
},
identities: controllerState.identities,
accounts: controllerState.accounts,
onConfirm: idStore.approveMessage.bind(idStore, msgId, noop),
onCancel: idStore.cancelMessage.bind(idStore, msgId),
})
}
function showUnconfirmedTx (txParams, txData, onTxDoneCb) {
var controllerState = controller.getState()
createTxNotification({
title: 'New Unsigned Transaction',
imageifyIdenticons: false,
txData: {
txParams: txParams,
confirm: idStore.approveTransaction.bind(idStore, txData.id, noop),
cancel: idStore.cancelTransaction.bind(idStore, txData.id),
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),
})
}
//

@ -53,62 +53,30 @@ function createUnlockRequestNotification (opts) {
})
}
function createTxNotification (opts) {
function createTxNotification (state) {
// guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236
if (!chrome.notifications) return console.error('Chrome notifications API missing...')
var state = {
title: 'New Unsigned Transaction',
imageifyIdenticons: false,
txData: {
txParams: opts.txParams,
time: (new Date()).getTime(),
},
identities: {
},
accounts: {
},
onConfirm: opts.confirm,
onCancel: opts.cancel,
}
renderTxNotificationSVG(state, function(err, notificationSvgSource){
if (err) throw err
showNotification(extend(state, {
title: 'New Unsigned Transaction',
imageUrl: toSvgUri(notificationSvgSource),
}))
})
}
function createMsgNotification (opts) {
function createMsgNotification (state) {
// guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236
if (!chrome.notifications) return console.error('Chrome notifications API missing...')
var state = {
title: 'New Unsigned Message',
imageifyIdenticons: false,
txData: {
msgParams: opts.msgParams,
time: (new Date()).getTime(),
},
identities: {
},
accounts: {
},
onConfirm: opts.confirm,
onCancel: opts.cancel,
}
renderMsgNotificationSVG(state, function(err, notificationSvgSource){
if (err) throw err
showNotification(extend(state, {
title: 'New Unsigned Message',
imageUrl: toSvgUri(notificationSvgSource),
}))

Loading…
Cancel
Save