From f7ad978474f42eb96f4f6c79376391504cf228c1 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 23 Jul 2018 21:27:51 -0400 Subject: camera working back and forth --- app/scripts/platforms/extension.js | 65 ++++++-------------------------------- 1 file changed, 10 insertions(+), 55 deletions(-) (limited to 'app/scripts/platforms') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 901c26cab..182df23b1 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -1,5 +1,4 @@ const extension = require('extensionizer') -const explorerLink = require('etherscan-link').createExplorerLink class ExtensionPlatform { @@ -18,11 +17,8 @@ class ExtensionPlatform { return extension.runtime.getManifest().version } - openExtensionInBrowser (route = null) { - let extensionURL = extension.runtime.getURL('home.html') - if (route) { - extensionURL += `#${route}` - } + openExtensionInBrowser () { + const extensionURL = extension.runtime.getURL('home.html') this.openWindow({ url: extensionURL }) } @@ -36,57 +32,16 @@ class ExtensionPlatform { } } - showTransactionNotification (txMeta) { - - const status = txMeta.status - if (status === 'confirmed') { - this._showConfirmedTransaction(txMeta) - } else if (status === 'failed') { - this._showFailedTransaction(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) - } - - _showNotification (title, message, url) { - extension.notifications.create( - url, - { - 'type': 'basic', - 'title': title, - 'iconUrl': extension.extension.getURL('../../images/icon-64.png'), - 'message': message, - }) + addMessageListener (cb) { + extension.runtime.onMessage.addListener(cb) } - _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 }) - } + sendMessage (message, query = {}) { + extension.tabs.query(query, tabs => { + const activeTab = tabs.filter(tab => tab.active)[0] + extension.tabs.sendMessage(activeTab.id, message) + console.log('QR-SCANNER: message sent to tab', message, activeTab) + }) } } -- cgit From d5929e5c42e230fc0a52337f86b5850e68516563 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 23 Jul 2018 22:10:57 -0400 Subject: added qr code scanner icon in send transaction --- app/scripts/platforms/extension.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/scripts/platforms') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 182df23b1..1cab0bedd 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -36,11 +36,10 @@ class ExtensionPlatform { extension.runtime.onMessage.addListener(cb) } - sendMessage (message, query = {}) { + sendMessageToActiveTab (message, query = {}) { extension.tabs.query(query, tabs => { const activeTab = tabs.filter(tab => tab.active)[0] extension.tabs.sendMessage(activeTab.id, message) - console.log('QR-SCANNER: message sent to tab', message, activeTab) }) } } -- cgit From 74fd6d1d1227d7a9e49623b73ee85985d79a1e46 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Tue, 24 Jul 2018 20:32:20 -0400 Subject: working without injection --- app/scripts/platforms/extension.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'app/scripts/platforms') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 1cab0bedd..452a51bd8 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -36,12 +36,6 @@ class ExtensionPlatform { extension.runtime.onMessage.addListener(cb) } - sendMessageToActiveTab (message, query = {}) { - extension.tabs.query(query, tabs => { - const activeTab = tabs.filter(tab => tab.active)[0] - extension.tabs.sendMessage(activeTab.id, message) - }) - } } module.exports = ExtensionPlatform -- cgit From d65d018ad0f78a0319f11942ada9ca0d85214db9 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Thu, 26 Jul 2018 21:11:58 -0400 Subject: restore platform/extension.js --- app/scripts/platforms/extension.js | 62 +++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) (limited to 'app/scripts/platforms') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 844670537..db0548efc 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 { @@ -23,8 +24,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 }) } @@ -38,10 +42,58 @@ class ExtensionPlatform { } } - addMessageListener (cb) { - extension.runtime.onMessage.addListener(cb) + showTransactionNotification (txMeta) { + + const status = txMeta.status + if (status === 'confirmed') { + this._showConfirmedTransaction(txMeta) + } else if (status === 'failed') { + this._showFailedTransaction(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) + } + + _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 +module.exports = ExtensionPlatform \ No newline at end of file -- cgit From bea1cf3f3c7527109b12b13427ea16f428b2790a Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Thu, 26 Jul 2018 21:15:16 -0400 Subject: clean up --- app/scripts/platforms/extension.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/platforms') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index db0548efc..0803164e8 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -96,4 +96,4 @@ class ExtensionPlatform { } } -module.exports = ExtensionPlatform \ No newline at end of file +module.exports = ExtensionPlatform -- cgit From edb154749d468299166e41e56d23beb781817cbc Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 30 Jul 2018 22:57:05 -0400 Subject: send to fullscreen if no permission from popup --- app/scripts/platforms/extension.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/scripts/platforms') diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 0803164e8..71b162dd0 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -24,8 +24,13 @@ class ExtensionPlatform { return extension.runtime.getManifest().version } - openExtensionInBrowser (route = null) { + openExtensionInBrowser (route = null, queryString = null) { let extensionURL = extension.runtime.getURL('home.html') + + if (queryString) { + extensionURL += `?${queryString}` + } + if (route) { extensionURL += `#${route}` } -- cgit