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/util.js | |
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/util.js')
-rw-r--r-- | app/scripts/lib/util.js | 29 |
1 files changed, 29 insertions, 0 deletions
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, |