diff options
Diffstat (limited to 'app/scripts/lib/notifications.js')
-rw-r--r-- | app/scripts/lib/notifications.js | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js index 90edaea12..af2dc2054 100644 --- a/app/scripts/lib/notifications.js +++ b/app/scripts/lib/notifications.js @@ -10,13 +10,12 @@ module.exports = { setupListeners() -function setupListeners(){ - +function setupListeners () { // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236 if (!chrome.notifications) return console.error('Chrome notifications API missing...') // notification button press - chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex){ + chrome.notifications.onButtonClicked.addListener(function (notificationId, buttonIndex) { var handlers = notificationHandlers[notificationId] if (buttonIndex === 0) { handlers.confirm() @@ -27,14 +26,13 @@ function setupListeners(){ }) // notification teardown - chrome.notifications.onClosed.addListener(function(notificationId){ + chrome.notifications.onClosed.addListener(function (notificationId) { delete notificationHandlers[notificationId] }) - } // creation helper -function createUnlockRequestNotification(opts){ +function createUnlockRequestNotification (opts) { // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236 if (!chrome.notifications) return console.error('Chrome notifications API missing...') var message = 'An Ethereum app has requested a signature. Please unlock your account.' @@ -46,18 +44,17 @@ function createUnlockRequestNotification(opts){ title: opts.title, message: message, }) - } -function createTxNotification(opts){ +function createTxNotification (opts) { // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236 if (!chrome.notifications) return console.error('Chrome notifications API missing...') var message = [ - 'Submitted by '+opts.txParams.origin, - 'to: '+uiUtils.addressSummary(opts.txParams.to), - 'from: '+uiUtils.addressSummary(opts.txParams.from), - 'value: '+uiUtils.formatBalance(opts.txParams.value), - 'data: '+uiUtils.dataSize(opts.txParams.data), + 'Submitted by ' + opts.txParams.origin, + 'to: ' + uiUtils.addressSummary(opts.txParams.to), + 'from: ' + uiUtils.addressSummary(opts.txParams.from), + 'value: ' + uiUtils.formatBalance(opts.txParams.value), + 'data: ' + uiUtils.dataSize(opts.txParams.data), ].join('\n') var id = createId() @@ -69,9 +66,9 @@ function createTxNotification(opts){ message: message, buttons: [{ title: 'confirm', - },{ + }, { title: 'cancel', - }] + }], }) notificationHandlers[id] = { confirm: opts.confirm, @@ -79,13 +76,13 @@ function createTxNotification(opts){ } } -function createMsgNotification(opts){ +function createMsgNotification (opts) { // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236 if (!chrome.notifications) return console.error('Chrome notifications API missing...') var message = [ - 'Submitted by '+opts.msgParams.origin, - 'to be signed by: '+uiUtils.addressSummary(opts.msgParams.from), - 'message:\n'+opts.msgParams.data, + 'Submitted by ' + opts.msgParams.origin, + 'to be signed by: ' + uiUtils.addressSummary(opts.msgParams.from), + 'message:\n' + opts.msgParams.data, ].join('\n') var id = createId() @@ -97,12 +94,12 @@ function createMsgNotification(opts){ message: message, buttons: [{ title: 'confirm', - },{ + }, { title: 'cancel', - }] + }], }) notificationHandlers[id] = { confirm: opts.confirm, cancel: opts.cancel, } -}
\ No newline at end of file +} |