aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/platforms
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-24 09:27:51 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-24 09:27:51 +0800
commitf7ad978474f42eb96f4f6c79376391504cf228c1 (patch)
treebe472127595385f8c8558213a58b7d1a470ad760 /app/scripts/platforms
parent02091486094dcc818096ce13a22cdc140a2e8347 (diff)
downloadtangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.tar.gz
tangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.tar.zst
tangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.zip
camera working back and forth
Diffstat (limited to 'app/scripts/platforms')
-rw-r--r--app/scripts/platforms/extension.js65
1 files changed, 10 insertions, 55 deletions
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)
+ })
}
}