From 317c3084df9d81d372c3326aa8db1e1e6f0255e3 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 2 Jul 2018 15:14:31 -0400 Subject: allow to open specific route in fullscreen mode --- app/scripts/platforms/extension.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/scripts/platforms/extension.js') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index f5cc255d1..f8dd767dc 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -17,8 +17,11 @@ class ExtensionPlatform { return extension.runtime.getManifest().version } - openExtensionInBrowser () { - const extensionURL = extension.runtime.getURL('home.html') + openExtensionInBrowser (route = null) { + let extensionURL = extension.runtime.getURL('home.html') + if (route) { + extensionURL += `#${route}` + } this.openWindow({ url: extensionURL }) } -- cgit From a3822b4680a295848f900616e3e154a1e1003a54 Mon Sep 17 00:00:00 2001 From: Csaba Solya Date: Fri, 20 Jul 2018 13:20:40 +0200 Subject: add notifications --- app/scripts/platforms/extension.js | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'app/scripts/platforms/extension.js') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index f5cc255d1..afcc9bbca 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -1,4 +1,5 @@ const extension = require('extensionizer') +const explorerLink = require('etherscan-link').createExplorerLink class ExtensionPlatform { @@ -31,6 +32,69 @@ class ExtensionPlatform { cb(e) } } + + showTransactionNotification (txMeta) { + + const status = txMeta.status + if (status === 'confirmed') { + this._showConfirmedTransaction(txMeta) + } else if (status === 'failed') { + this._showFailedTransaction(txMeta) + } else if (status === 'dropped') { + this._showDroppedTransaction(txMeta) + } + } + + _showConfirmedTransaction (txMeta) { + + this._subscribeToNotificationClicked() + + const url = explorerLink(txMeta.hash, parseInt(txMeta.metamaskNetworkId)) + const nonce = parseInt(txMeta.txParams.nonce, 16) + + const title = 'Confirmed transaction' + const message = `Transaction ${nonce} confirmed! View on EtherScan` + this._showNotification(title, message, url) + } + + _showFailedTransaction (txMeta) { + + const nonce = parseInt(txMeta.txParams.nonce, 16) + const title = 'Failed transaction' + const message = `Transaction ${nonce} failed! ${txMeta.err.message}` + this._showNotification(title, message) + } + + _showDroppedTransaction (txMeta) { + + const nonce = parseInt(txMeta.txParams.nonce, 16) + const title = 'Dropped transaction' + const message = `Transaction ${nonce} was dropped, because another transaction with that number was successfully processed.` + this._showNotification(title, message) + } + + _showNotification (title, message, url) { + extension.notifications.create( + url, + { + 'type': 'basic', + 'title': title, + 'iconUrl': extension.extension.getURL('../../images/icon-64.png'), + 'message': message, + }) + } + + _subscribeToNotificationClicked () { + if (!extension.notifications.onClicked.hasListener(this._viewOnEtherScan)) { + extension.notifications.onClicked.addListener(this._viewOnEtherScan) + } + } + + _viewOnEtherScan (txId) { + if (txId.startsWith('http://')) { + global.metamaskController.platform.openWindow({ url: txId }) + } + } } module.exports = ExtensionPlatform -- cgit From 72591d4f41aafa7556cbc37d613fcbe016444156 Mon Sep 17 00:00:00 2001 From: Csaba Solya Date: Fri, 20 Jul 2018 19:58:26 +0200 Subject: remove dropped handler --- app/scripts/platforms/extension.js | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'app/scripts/platforms/extension.js') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index afcc9bbca..60ecfeff4 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -40,8 +40,6 @@ class ExtensionPlatform { this._showConfirmedTransaction(txMeta) } else if (status === 'failed') { this._showFailedTransaction(txMeta) - } else if (status === 'dropped') { - this._showDroppedTransaction(txMeta) } } @@ -65,14 +63,6 @@ class ExtensionPlatform { this._showNotification(title, message) } - _showDroppedTransaction (txMeta) { - - const nonce = parseInt(txMeta.txParams.nonce, 16) - const title = 'Dropped transaction' - const message = `Transaction ${nonce} was dropped, because another transaction with that number was successfully processed.` - this._showNotification(title, message) - } - _showNotification (title, message, url) { extension.notifications.create( url, -- cgit