From 95f198550e419c598750a1717014dac6ca5091e9 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 5 Jul 2019 14:01:34 -0300 Subject: 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. --- app/scripts/lib/createStreamSink.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'app/scripts/lib') diff --git a/app/scripts/lib/createStreamSink.js b/app/scripts/lib/createStreamSink.js index b93dbc089..eb9d0bd1a 100644 --- a/app/scripts/lib/createStreamSink.js +++ b/app/scripts/lib/createStreamSink.js @@ -1,13 +1,6 @@ const WritableStream = require('readable-stream').Writable const promiseToCallback = require('promise-to-callback') -module.exports = createStreamSink - - -function createStreamSink (asyncWriteFn, _opts) { - return new AsyncWritableStream(asyncWriteFn, _opts) -} - class AsyncWritableStream extends WritableStream { constructor (asyncWriteFn, _opts) { @@ -22,3 +15,9 @@ class AsyncWritableStream extends WritableStream { } } + +function createStreamSink (asyncWriteFn, _opts) { + return new AsyncWritableStream(asyncWriteFn, _opts) +} + +module.exports = createStreamSink -- cgit v1.2.3 From e81aa6073d30d5a93fce9a2414203e8367ae16b9 Mon Sep 17 00:00:00 2001 From: Alessandro Ricottone Date: Tue, 23 Jul 2019 21:29:20 +0200 Subject: Resolve onion addresses (#6869) * Resolve onion address * npm i content-hash@latest --- app/scripts/lib/ens-ipfs/setup.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/scripts/lib') diff --git a/app/scripts/lib/ens-ipfs/setup.js b/app/scripts/lib/ens-ipfs/setup.js index 82679db5d..86f3e7d47 100644 --- a/app/scripts/lib/ens-ipfs/setup.js +++ b/app/scripts/lib/ens-ipfs/setup.js @@ -51,6 +51,8 @@ function setupEnsIpfsResolver ({ provider }) { } } else if (type === 'swarm-ns') { url = `https://swarm-gateways.net/bzz:/${hash}${path}${search || ''}` + } else if (type === 'onion' || type === 'onion3') { + url = `http://${hash}.onion${path}${search || ''}` } } catch (err) { console.warn(err) -- cgit v1.2.3 From 4d88e1cf862c3ae174780cd888d7703685db23e7 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Wed, 31 Jul 2019 17:47:11 -0230 Subject: Enable indent linting via ESLint (#6936) * Enable indent linting via ESLint * yarn run lint:fix --- app/scripts/lib/account-tracker.js | 18 +++++++++--------- app/scripts/lib/backend-metametrics.js | 10 +++++----- app/scripts/lib/message-manager.js | 2 +- app/scripts/lib/personal-message-manager.js | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'app/scripts/lib') diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js index 24c5ef7ee..1cbf867cb 100644 --- a/app/scripts/lib/account-tracker.js +++ b/app/scripts/lib/account-tracker.js @@ -183,23 +183,23 @@ class AccountTracker { switch (currentNetwork) { case MAINNET_CODE: - await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS) - break + await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS) + break case RINKEYBY_CODE: - await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_RINKEBY) - break + await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_RINKEBY) + break case ROPSTEN_CODE: - await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN) - break + await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN) + break case KOVAN_CODE: - await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_KOVAN) - break + await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_KOVAN) + break default: - await Promise.all(addresses.map(this._updateAccount.bind(this))) + await Promise.all(addresses.map(this._updateAccount.bind(this))) } } diff --git a/app/scripts/lib/backend-metametrics.js b/app/scripts/lib/backend-metametrics.js index e3c163c1a..ad7874ead 100644 --- a/app/scripts/lib/backend-metametrics.js +++ b/app/scripts/lib/backend-metametrics.js @@ -15,11 +15,11 @@ function backEndMetaMetricsEvent (metaMaskState, eventData) { const stateEventData = getMetaMetricState({ metamask: metaMaskState }) if (stateEventData.participateInMetaMetrics) { - sendMetaMetricsEvent({ - ...stateEventData, - ...eventData, - url: METAMETRICS_TRACKING_URL + '/backend', - }) + sendMetaMetricsEvent({ + ...stateEventData, + ...eventData, + url: METAMETRICS_TRACKING_URL + '/backend', + }) } } diff --git a/app/scripts/lib/message-manager.js b/app/scripts/lib/message-manager.js index ac41de523..898378389 100644 --- a/app/scripts/lib/message-manager.js +++ b/app/scripts/lib/message-manager.js @@ -61,7 +61,7 @@ module.exports = class MessageManager extends EventEmitter { */ getUnapprovedMsgs () { return this.messages.filter(msg => msg.status === 'unapproved') - .reduce((result, msg) => { result[msg.id] = msg; return result }, {}) + .reduce((result, msg) => { result[msg.id] = msg; return result }, {}) } /** diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js index 7c13e521a..b5e28be13 100644 --- a/app/scripts/lib/personal-message-manager.js +++ b/app/scripts/lib/personal-message-manager.js @@ -64,7 +64,7 @@ module.exports = class PersonalMessageManager extends EventEmitter { */ getUnapprovedMsgs () { return this.messages.filter(msg => msg.status === 'unapproved') - .reduce((result, msg) => { result[msg.id] = msg; return result }, {}) + .reduce((result, msg) => { result[msg.id] = msg; return result }, {}) } /** -- cgit v1.2.3