diff options
author | brunobar79 <brunobar79@gmail.com> | 2018-08-08 15:00:39 +0800 |
---|---|---|
committer | brunobar79 <brunobar79@gmail.com> | 2018-08-08 15:00:39 +0800 |
commit | c6b7e460b536a6fcff4e4328b1007f677720b585 (patch) | |
tree | 7107eeb7fc05507906e1096811d7920fae5ef0f4 /app/scripts/lib/util.js | |
parent | 2e0916d8ff17c89147005d22e8c100113aaf3360 (diff) | |
download | tangerine-wallet-browser-c6b7e460b536a6fcff4e4328b1007f677720b585.tar tangerine-wallet-browser-c6b7e460b536a6fcff4e4328b1007f677720b585.tar.gz tangerine-wallet-browser-c6b7e460b536a6fcff4e4328b1007f677720b585.tar.bz2 tangerine-wallet-browser-c6b7e460b536a6fcff4e4328b1007f677720b585.tar.lz tangerine-wallet-browser-c6b7e460b536a6fcff4e4328b1007f677720b585.tar.xz tangerine-wallet-browser-c6b7e460b536a6fcff4e4328b1007f677720b585.tar.zst tangerine-wallet-browser-c6b7e460b536a6fcff4e4328b1007f677720b585.zip |
code review changes
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 51e9036cc..d7423f2ad 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 @@ -100,6 +128,7 @@ function BnMultiplyByFraction (targetBN, numerator, denominator) { } module.exports = { + getPlatform, getStack, getEnvironmentType, sufficientBalance, |