aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorMark Stacey <markjstacey@gmail.com>2019-07-06 01:01:34 +0800
committerGitHub <noreply@github.com>2019-07-06 01:01:34 +0800
commit95f198550e419c598750a1717014dac6ca5091e9 (patch)
tree50720fa452bf11b9f0ec720f84f70bd2231d38d2 /ui
parent0311f2d28c60fb82141dee471c19ad085930f8cc (diff)
downloadtangerine-wallet-browser-95f198550e419c598750a1717014dac6ca5091e9.tar.gz
tangerine-wallet-browser-95f198550e419c598750a1717014dac6ca5091e9.tar.zst
tangerine-wallet-browser-95f198550e419c598750a1717014dac6ca5091e9.zip
Declare variables before use (#6806)
While working on #6805, I noticed that many variables were being used before they were declared. Technically this worked fine in practice because we were using the `transform-es2015-block-scoping` Babel plugin, which transforms `let` and `const` to `var`, which is hoisted. However, after removing that Babel transformation, many things broke. All instances of variables or classes being used before declared have been fixed. The `no-use-before-define` eslint rule has been added to catch these cases going forward. The rule is disabled for function declarations for the moment, because those are always hoisted. We could disable that too if we want to, but it's purely stylistic and would require a lot more changes.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/helpers/utils/conversion-util.js14
-rw-r--r--ui/app/pages/routes/index.js24
-rw-r--r--ui/app/store/actions.js28
3 files changed, 33 insertions, 33 deletions
diff --git a/ui/app/helpers/utils/conversion-util.js b/ui/app/helpers/utils/conversion-util.js
index affddade7..46bcfe47b 100644
--- a/ui/app/helpers/utils/conversion-util.js
+++ b/ui/app/helpers/utils/conversion-util.js
@@ -37,13 +37,6 @@ const BIG_NUMBER_WEI_MULTIPLIER = new BigNumber('1000000000000000000')
const BIG_NUMBER_GWEI_MULTIPLIER = new BigNumber('1000000000')
const BIG_NUMBER_ETH_MULTIPLIER = new BigNumber('1')
-// Individual Setters
-const convert = R.invoker(1, 'times')
-const round = R.invoker(2, 'round')(R.__, BigNumber.ROUND_HALF_DOWN)
-const roundDown = R.invoker(2, 'round')(R.__, BigNumber.ROUND_DOWN)
-const invertConversionRate = conversionRate => () => new BigNumber(1.0).div(conversionRate)
-const decToBigNumberViaString = () => R.pipe(String, toBigNumber['dec'])
-
// Setter Maps
const toBigNumber = {
hex: n => new BigNumber(stripHexPrefix(n), 16),
@@ -66,6 +59,13 @@ const baseChange = {
BN: n => new BN(n.toString(16)),
}
+// Individual Setters
+const convert = R.invoker(1, 'times')
+const round = R.invoker(2, 'round')(R.__, BigNumber.ROUND_HALF_DOWN)
+const roundDown = R.invoker(2, 'round')(R.__, BigNumber.ROUND_DOWN)
+const invertConversionRate = conversionRate => () => new BigNumber(1.0).div(conversionRate)
+const decToBigNumberViaString = () => R.pipe(String, toBigNumber['dec'])
+
// Predicates
const fromAndToCurrencyPropsNotEqual = R.compose(
R.not,
diff --git a/ui/app/pages/routes/index.js b/ui/app/pages/routes/index.js
index afef0692e..c292fd9c7 100644
--- a/ui/app/pages/routes/index.js
+++ b/ui/app/pages/routes/index.js
@@ -183,18 +183,6 @@ class Routes extends Component {
this.getConnectingLabel(loadingMessage) : null
log.debug('Main ui render function')
- const sidebarOnOverlayClose = sidebarType === WALLET_VIEW_SIDEBAR
- ? () => {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Navigation',
- action: 'Wallet Sidebar',
- name: 'Closed Sidebare Via Overlay',
- },
- })
- }
- : null
-
const {
isOpen: sidebarIsOpen,
transitionName: sidebarTransitionName,
@@ -203,6 +191,18 @@ class Routes extends Component {
} = sidebar
const { transaction: sidebarTransaction } = props || {}
+ const sidebarOnOverlayClose = sidebarType === WALLET_VIEW_SIDEBAR
+ ? () => {
+ this.context.metricsEvent({
+ eventOpts: {
+ category: 'Navigation',
+ action: 'Wallet Sidebar',
+ name: 'Closed Sidebare Via Overlay',
+ },
+ })
+ }
+ : null
+
return (
<div
className="app"
diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js
index 389a47d46..c9e595421 100644
--- a/ui/app/store/actions.js
+++ b/ui/app/store/actions.js
@@ -1210,6 +1210,20 @@ function signTokenTx (tokenAddress, toAddress, amount, txData) {
}
}
+const updateMetamaskStateFromBackground = () => {
+ log.debug(`background.getState`)
+
+ return new Promise((resolve, reject) => {
+ background.getState((error, newState) => {
+ if (error) {
+ return reject(error)
+ }
+
+ resolve(newState)
+ })
+ })
+}
+
function updateTransaction (txData) {
log.info('actions: updateTx: ' + JSON.stringify(txData))
return dispatch => {
@@ -1618,20 +1632,6 @@ const backgroundSetLocked = () => {
})
}
-const updateMetamaskStateFromBackground = () => {
- log.debug(`background.getState`)
-
- return new Promise((resolve, reject) => {
- background.getState((error, newState) => {
- if (error) {
- return reject(error)
- }
-
- resolve(newState)
- })
- })
-}
-
function lockMetamask () {
log.debug(`background.setLocked`)