Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into sync-master
Browse files Browse the repository at this point in the history
* origin/develop: (107 commits)
  Clear Account Details in AppState (#9238)
  Permit all-caps addresses (#9227)
  Send web3 usage metrics once per origin/property (#9237)
  Fix import/no-extraneous-dependencies issues (#9232)
  Remove unused buyEth fn from bg (#9236)
  Fix max-statements-per-line issues (#9218)
  Consolidate ESLint config files (#9231)
  Delete page-container.component.test.js (#9229)
  Tidy up getAccountLink (#9223)
  Tidy ConnectHardwareForm#checkIfUnlocked (#9224)
  Fix require-unicode-regexp issues (#9212)
  Fix no-negated-condition issues (#9222)
  Fix no-empty-function issues (#9216)
  Fix import/extensions issues (#9217)
  Dedupe glob-parent versions (#9220)
  Fix no-template-curly-in-string issues (#9221)
  Fix no-process-exit issues (#9219)
  Fix prefer-rest-params issues (#9215)
  Fix no-prototype-builtins issues (#9213)
  Fix no-nested-ternary issues (#9214)
  ...
  • Loading branch information
Gudahtt committed Aug 14, 2020
2 parents eab1add + 87e5281 commit 52fd72f
Show file tree
Hide file tree
Showing 326 changed files with 2,501 additions and 3,525 deletions.
7 changes: 1 addition & 6 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
node_modules/**
dist/**
builds/**
test-builds/**
test-*/**
docs/**
coverage/

app/scripts/lib/extension-instance.js
app/scripts/chromereload.js
app/vendor/**

ui/lib/blockies.js

package-lock.json
53 changes: 53 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,32 @@ module.exports = {
/* TODO: Remove these when upgrading to `@metamask/eslint-config@2` */
'array-callback-return': 'error',
'callback-return': 'error',
'consistent-return': 'error',
'global-require': 'error',
'guard-for-in': 'error',
'implicit-arrow-linebreak': 'error',
'import/extensions': ['error', 'never', { 'json': 'always' }],
'import/no-extraneous-dependencies': 'error',
'max-statements-per-line': ['error', { 'max': 1 }],
'no-case-declarations': 'error',
'no-constant-condition': 'error',
'no-dupe-else-if': 'error',
'no-empty': 'error',
'no-empty-function': 'error',
'no-eq-null': 'error',
'no-global-assign': 'error',
'no-loop-func': 'error',
'no-negated-condition': 'error',
'no-nested-ternary': 'error',
'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }],
'no-process-exit': 'error',
'no-prototype-builtins': 'error',
'no-template-curly-in-string': 'error',
'no-useless-catch': 'error',
'no-useless-concat': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'require-unicode-regexp': 'error',
/* End v2 rules */
'arrow-parens': 'error',
'no-tabs': 'error',
Expand Down Expand Up @@ -95,11 +119,22 @@ module.exports = {
'logical': 'parens-new-line',
'prop': 'parens-new-line',
}],

'no-invalid-this': 'off',
'babel/no-invalid-this': 'error',

'babel/semi': ['error', 'never'],
'mocha/no-setup-in-describe': 'off',
},

overrides: [{
files: [
'test/e2e/**/*.js',
],
rules: {
'mocha/no-hooks-for-single-case': 'off',
},
}, {
files: [
'app/scripts/migrations/*.js',
'*.stories.js',
Expand All @@ -114,6 +149,24 @@ module.exports = {
rules: {
'global-require': 'off',
},
}, {
files: [
'test/**/*-test.js',
'test/**/*.spec.js',
],
rules: {
// Mocha will re-assign `this` in a test context
'babel/no-invalid-this': 'off',
},
}, {
files: [
'development/**/*.js',
'test/e2e/benchmark.js',
'test/helper.js',
],
rules: {
'no-process-exit': 'off',
},
}],

settings: {
Expand Down
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
stories: ['../ui/app/components/**/*.stories.js'],
stories: ['../ui/app/**/*.stories.js'],
addons: [
'@storybook/addon-knobs',
'@storybook/addon-actions',
Expand Down
14 changes: 8 additions & 6 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ module.exports = {
],
},
plugins: [
new CopyWebpackPlugin([
{
from: path.join('node_modules', '@fortawesome', 'fontawesome-free', 'webfonts'),
to: path.join('fonts', 'fontawesome'),
},
]),
new CopyWebpackPlugin({
patterns: [
{
from: path.join('node_modules', '@fortawesome', 'fontawesome-free', 'webfonts'),
to: path.join('fonts', 'fontawesome'),
},
],
}),
],
}
Binary file added app/fonts/Euclid/EuclidCircularB-Bold-WebXL.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion app/scripts/account-import-strategies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const accountImporter = {
importAccount (strategy, args) {
try {
const importer = this.strategies[strategy]
const privateKeyHex = importer.apply(null, args)
const privateKeyHex = importer(...args)
return Promise.resolve(privateKeyHex)
} catch (e) {
return Promise.reject(e)
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Migrator from './lib/migrator'
import migrations from './migrations'
import PortStream from 'extension-port-stream'
import createStreamSink from './lib/createStreamSink'
import NotificationManager from './lib/notification-manager.js'
import NotificationManager from './lib/notification-manager'
import MetamaskController from './metamask-controller'
import rawFirstTimeState from './first-time-state'
import setupSentry from './lib/setupSentry'
Expand Down Expand Up @@ -327,7 +327,7 @@ function setupController (initState, initLangCode) {
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName]

if (metamaskBlockedPorts.includes(remotePort.name)) {
return false
return
}

if (isMetaMaskInternalProcess) {
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ function doctypeCheck () {
*/
function suffixCheck () {
const prohibitedTypes = [
/\.xml$/,
/\.pdf$/,
/\.xml$/u,
/\.pdf$/u,
]
const currentUrl = window.location.pathname
for (let i = 0; i < prohibitedTypes.length; i++) {
Expand Down Expand Up @@ -202,7 +202,7 @@ function blockedDomainCheck () {
let currentRegex
for (let i = 0; i < blockedDomains.length; i++) {
const blockedDomain = blockedDomains[i].replace('.', '\\.')
currentRegex = new RegExp(`(?:https?:\\/\\/)(?:(?!${blockedDomain}).)*$`)
currentRegex = new RegExp(`(?:https?:\\/\\/)(?:(?!${blockedDomain}).)*$`, 'u')
if (!currentRegex.test(currentUrl)) {
return true
}
Expand All @@ -228,7 +228,7 @@ function redirectToPhishingWarning () {
async function domIsReady () {
// already loaded
if (['interactive', 'complete'].includes(document.readyState)) {
return
return undefined
}
// wait for load
return new Promise((resolve) => window.addEventListener('DOMContentLoaded', resolve, { once: true }))
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/app-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class AppStateController extends EventEmitter {

super()

this.onInactiveTimeout = onInactiveTimeout || (() => {})
this.onInactiveTimeout = onInactiveTimeout || (() => undefined)
this.store = new ObservableStore(Object.assign({
timeoutMinutes: 0,
connectedStatusPopoverHasBeenShown: true,
Expand Down
12 changes: 8 additions & 4 deletions app/scripts/controllers/network/middleware/pending.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export function createPendingNonceMiddleware ({ getPendingNonce }) {
return createAsyncMiddleware(async (req, res, next) => {
const { method, params } = req
if (method !== 'eth_getTransactionCount') {
return next()
next()
return
}
const [param, blockRef] = params
if (blockRef !== 'pending') {
return next()
next()
return
}
res.result = await getPendingNonce(param)
})
Expand All @@ -19,12 +21,14 @@ export function createPendingTxMiddleware ({ getPendingTransactionByHash }) {
return createAsyncMiddleware(async (req, res, next) => {
const { method, params } = req
if (method !== 'eth_getTransactionByHash') {
return next()
next()
return
}
const [hash] = params
const txMeta = getPendingTransactionByHash(hash)
if (!txMeta) {
return next()
next()
return
}
res.result = formatTxMetaForRpcResult(txMeta)
})
Expand Down
11 changes: 7 additions & 4 deletions app/scripts/controllers/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ export default class NetworkController extends EventEmitter {

setNetworkState (network, type) {
if (network === 'loading') {
return this.networkStore.putState(network)
this.networkStore.putState(network)
return
}

// type must be defined
if (!type) {
return
}
network = networks.networkList[type]?.chainId || network
return this.networkStore.putState(network)
this.networkStore.putState(network)
}

isNetworkLoading () {
Expand All @@ -111,7 +112,8 @@ export default class NetworkController extends EventEmitter {
lookupNetwork () {
// Prevent firing when provider is not defined.
if (!this._provider) {
return log.warn('NetworkController - lookupNetwork aborted due to missing provider')
log.warn('NetworkController - lookupNetwork aborted due to missing provider')
return
}
const { type } = this.providerStore.getState()
const ethQuery = new EthQuery(this._provider)
Expand All @@ -120,7 +122,8 @@ export default class NetworkController extends EventEmitter {
const currentNetwork = this.getNetworkState()
if (initialNetwork === currentNetwork) {
if (err) {
return this.setNetworkState('loading')
this.setNetworkState('loading')
return
}
log.info('web3.getNetwork returned ' + network)
this.setNetworkState(network, type)
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/controllers/permissions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class PermissionsController {
const req = { method: 'eth_accounts' }
const res = {}
this.permissions.providerMiddlewareFunction(
{ origin }, req, res, () => {}, _end,
{ origin }, req, res, () => undefined, _end,
)

function _end () {
Expand Down Expand Up @@ -187,7 +187,7 @@ export class PermissionsController {
const res = {}

this.permissions.providerMiddlewareFunction(
domain, req, res, () => {}, _end,
domain, req, res, () => undefined, _end,
)

function _end (_err) {
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/controllers/permissions/permissionsLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export default class PermissionsLogController {
requestedMethods = [ 'eth_accounts' ]
} else {
// no-op
return next()
next()
return
}

// call next with a return handler for capturing the response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ export default function createPermissionsMethodMiddleware ({
// Intercepting eth_accounts requests for backwards compatibility:
// The getAccounts call below wraps the rpc-cap middleware, and returns
// an empty array in case of errors (such as 4100:unauthorized)
case 'eth_accounts':
case 'eth_accounts': {

res.result = await getAccounts()
return
}

case 'eth_requestAccounts':
case 'eth_requestAccounts': {

if (isProcessingRequestAccounts) {
res.error = ethErrors.rpc.resourceUnavailable(
Expand Down Expand Up @@ -73,19 +74,21 @@ export default function createPermissionsMethodMiddleware ({
}

return
}

// custom method for getting metadata from the requesting domain,
// sent automatically by the inpage provider when it's initialized
case 'wallet_sendDomainMetadata':
case 'wallet_sendDomainMetadata': {

if (typeof req.domainMetadata?.name === 'string') {
addDomainMetadata(req.origin, req.domainMetadata)
}
res.result = true
return
}

// register return handler to send accountsChanged notification
case 'wallet_requestPermissions':
case 'wallet_requestPermissions': {

if ('eth_accounts' in req.params?.[0]) {

Expand All @@ -101,6 +104,7 @@ export default function createPermissionsMethodMiddleware ({
}
}
break
}

default:
break
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default class PreferencesController {
) {
const { type, options } = req.params
switch (type) {
case 'ERC20':
case 'ERC20': {
const result = await this._handleWatchAssetERC20(options)
if (result instanceof Error) {
end(result)
Expand All @@ -207,6 +207,7 @@ export default class PreferencesController {
end()
}
return
}
default:
end(new Error(`Asset of type ${type} not supported`))
return
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/threebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class ThreeBoxController {
const threeBoxConfig = await Box.getConfig(this.address)
backupExists = threeBoxConfig.spaces && threeBoxConfig.spaces.metamask
} catch (e) {
if (e.message.match(/^Error: Invalid response \(404\)/)) {
if (e.message.match(/^Error: Invalid response \(404\)/u)) {
backupExists = false
} else {
throw e
Expand Down
Loading

0 comments on commit 52fd72f

Please sign in to comment.