aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-08-08 15:00:39 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-08-08 15:00:39 +0800
commitc6b7e460b536a6fcff4e4328b1007f677720b585 (patch)
tree7107eeb7fc05507906e1096811d7920fae5ef0f4 /app/scripts
parent2e0916d8ff17c89147005d22e8c100113aaf3360 (diff)
downloadtangerine-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')
-rw-r--r--app/scripts/lib/enums.js11
-rw-r--r--app/scripts/lib/util.js29
2 files changed, 40 insertions, 0 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/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,