diff options
author | Thomas <thomas.b.huang@gmail.com> | 2018-08-15 01:44:42 +0800 |
---|---|---|
committer | Thomas <thomas.b.huang@gmail.com> | 2018-08-15 01:44:42 +0800 |
commit | 96d789d2cffa91da9d65be0de75d2e864d309305 (patch) | |
tree | b3cea0eb6a4638244fd99bf64509c69b0b720a7a /app/scripts/lib | |
parent | 7918240833871648dea6f9787519ba20f1e51899 (diff) | |
parent | 742aa8bb11c1273151ad907171061d4c5e4d1dca (diff) | |
download | tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.gz tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.bz2 tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.lz tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.xz tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.zst tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.zip |
Merge branch 'develop' into network-remove-provider-engine
Override package-lock and fix merge conflicts
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/enums.js | 11 | ||||
-rw-r--r-- | app/scripts/lib/ipfsContent.js | 6 | ||||
-rw-r--r-- | app/scripts/lib/setupRaven.js | 4 | ||||
-rw-r--r-- | app/scripts/lib/util.js | 29 |
4 files changed, 45 insertions, 5 deletions
diff --git a/app/scripts/lib/enums.js b/app/scripts/lib/enums.js index 0a3afca47..c6d57a1bc 100644 --- a/app/scripts/lib/enums.js +++ b/app/scripts/lib/enums.js @@ -2,8 +2,19 @@ const ENVIRONMENT_TYPE_POPUP = 'popup' const ENVIRONMENT_TYPE_NOTIFICATION = 'notification' const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen' +const PLATFORM_BRAVE = 'Brave' +const PLATFORM_CHROME = 'Chrome' +const PLATFORM_EDGE = 'Edge' +const PLATFORM_FIREFOX = 'Firefox' +const PLATFORM_OPERA = 'Opera' + module.exports = { ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_FULLSCREEN, + PLATFORM_BRAVE, + PLATFORM_CHROME, + PLATFORM_EDGE, + PLATFORM_FIREFOX, + PLATFORM_OPERA, } diff --git a/app/scripts/lib/ipfsContent.js b/app/scripts/lib/ipfsContent.js index 5222151ea..5db63f47d 100644 --- a/app/scripts/lib/ipfsContent.js +++ b/app/scripts/lib/ipfsContent.js @@ -5,7 +5,7 @@ module.exports = function (provider) { function ipfsContent (details) { const name = details.url.substring(7, details.url.length - 1) let clearTime = null - extension.tabs.getSelected(null, tab => { + extension.tabs.query({active: true}, tab => { extension.tabs.update(tab.id, { url: 'loading.html' }) clearTime = setTimeout(() => { @@ -34,11 +34,11 @@ module.exports = function (provider) { return { cancel: true } } - extension.webRequest.onBeforeRequest.addListener(ipfsContent, {urls: ['*://*.eth/', '*://*.test/']}) + extension.webRequest.onErrorOccurred.addListener(ipfsContent, {urls: ['*://*.eth/', '*://*.test/']}) return { remove () { - extension.webRequest.onBeforeRequest.removeListener(ipfsContent) + extension.webRequest.onErrorOccurred.removeListener(ipfsContent) }, } } diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js index 9aa2dec0a..e6e511640 100644 --- a/app/scripts/lib/setupRaven.js +++ b/app/scripts/lib/setupRaven.js @@ -8,7 +8,7 @@ module.exports = setupRaven // Setup raven / sentry remote error reporting function setupRaven (opts) { - const { releaseVersion } = opts + const { release } = opts let ravenTarget // detect brave const isBrave = Boolean(window.chrome.ipcRenderer) @@ -22,7 +22,7 @@ function setupRaven (opts) { } const client = Raven.config(ravenTarget, { - releaseVersion, + release, transport: function (opts) { opts.data.extra.isBrave = isBrave const report = opts.data diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js index 2b3fe3d6e..ea13b26be 100644 --- a/app/scripts/lib/util.js +++ b/app/scripts/lib/util.js @@ -5,6 +5,11 @@ const { ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_FULLSCREEN, + PLATFORM_FIREFOX, + PLATFORM_OPERA, + PLATFORM_CHROME, + PLATFORM_EDGE, + PLATFORM_BRAVE, } = require('./enums') /** @@ -38,6 +43,29 @@ const getEnvironmentType = (url = window.location.href) => { } /** + * Returns the platform (browser) where the extension is running. + * + * @returns {string} the platform ENUM + * + */ +const getPlatform = _ => { + const ua = navigator.userAgent + if (ua.search('Firefox') !== -1) { + return PLATFORM_FIREFOX + } else { + if (window && window.chrome && window.chrome.ipcRenderer) { + return PLATFORM_BRAVE + } else if (ua.search('Edge') !== -1) { + return PLATFORM_EDGE + } else if (ua.search('OPR') !== -1) { + return PLATFORM_OPERA + } else { + return PLATFORM_CHROME + } + } +} + +/** * Checks whether a given balance of ETH, represented as a hex string, is sufficient to pay a value plus a gas fee * * @param {object} txParams Contains data about a transaction @@ -114,6 +142,7 @@ function removeListeners (listeners, emitter) { module.exports = { removeListeners, applyListeners, + getPlatform, getStack, getEnvironmentType, sufficientBalance, |