From 5be154ea2035810462ff0e7051e537870bfc1afb Mon Sep 17 00:00:00 2001
From: kumavis <aaron@kumavis.me>
Date: Mon, 28 May 2018 14:29:31 -0700
Subject: controllers - transactions - merge @frankiebee's work with mine

---
 app/scripts/lib/util.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

(limited to 'app/scripts/lib/util.js')

diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js
index 431d1e59..7ceb9da3 100644
--- a/app/scripts/lib/util.js
+++ b/app/scripts/lib/util.js
@@ -99,7 +99,21 @@ function BnMultiplyByFraction (targetBN, numerator, denominator) {
   return targetBN.mul(numBN).div(denomBN)
 }
 
+function applyListeners (listeners, emitter) {
+  Object.keys(listeners).forEach((key) => {
+    emitter.on(key, listeners[key])
+  })
+}
+
+function removeListeners (listeners, emitter) {
+  Object.keys(listeners).forEach((key) => {
+    emitter.removeListener(key, listeners[key])
+  })
+}
+
 module.exports = {
+  removeListeners,
+  applyListeners,
   getStack,
   getEnvironmentType,
   sufficientBalance,
-- 
cgit 


From c6b7e460b536a6fcff4e4328b1007f677720b585 Mon Sep 17 00:00:00 2001
From: brunobar79 <brunobar79@gmail.com>
Date: Wed, 8 Aug 2018 03:00:39 -0400
Subject: code review changes

---
 app/scripts/lib/util.js | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

(limited to 'app/scripts/lib/util.js')

diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js
index 51e9036c..d7423f2a 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')
 
 /**
@@ -37,6 +42,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
  *
@@ -100,6 +128,7 @@ function BnMultiplyByFraction (targetBN, numerator, denominator) {
 }
 
 module.exports = {
+  getPlatform,
   getStack,
   getEnvironmentType,
   sufficientBalance,
-- 
cgit