Skip to content

Commit

Permalink
Merge branch 'develop' into web3-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed Aug 17, 2020
2 parents a45814e + a89b667 commit 0052263
Show file tree
Hide file tree
Showing 240 changed files with 1,777 additions and 1,258 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
69 changes: 69 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,34 @@ 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',
'import/unambiguous': '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-param-reassign': '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 +121,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 +151,38 @@ 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',
},
}, {
files: [
'.eslintrc.js',
'babel.config.js',
'nyc.config.js',
'stylelint.config.js',
'development/**/*.js',
'test/e2e/**/*.js',
'test/env.js',
'test/setup.js',
],
parserOptions: {
sourceType: 'script',
},
}],

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'),
},
],
}),
],
}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

## Current Develop Branch

## 8.0.8 Fri Aug 14 2020
- [#9211](https://github.com/MetaMask/metamask-extension/pull/9211): Fix Etherscan redirect on notification click
- [#9237](https://github.com/MetaMask/metamask-extension/pull/9237): Reduce volume of web3 usage metrics
- [#9227](https://github.com/MetaMask/metamask-extension/pull/9227): Permit all-caps addresses

## 8.0.7 Fri Aug 07 2020
- [#9065](https://github.com/MetaMask/metamask-extension/pull/9065): Change title of "Reveal Seed Words" page to "Reveal Seed Phrase"
- [#8974](https://github.com/MetaMask/metamask-extension/pull/8974): Add tooltip to copy button for contacts and seed phrase
- [#9063](https://github.com/MetaMask/metamask-extension/pull/9063): Fix broken UI upon failed password validation
- [#9075](https://github.com/MetaMask/metamask-extension/pull/9075): Fix shifted popup notification when browser is in fullscreen on macOS
- [#9085](https://github.com/MetaMask/metamask-extension/pull/9085): Support longer text in network dropdown
- [#8873](https://github.com/MetaMask/metamask-extension/pull/8873): Fix onboarding bug where user can be asked to verify seed phrase twice
- [#9104](https://github.com/MetaMask/metamask-extension/pull/9104): Replace "Email us" button with "Contact us" button
- [#9137](https://github.com/MetaMask/metamask-extension/pull/9137): Fix bug where `accountsChanged` events stop after a dapp connection is closed.
- [#9152](https://github.com/MetaMask/metamask-extension/pull/9152): Fix network name alignment
- [#9144](https://github.com/MetaMask/metamask-extension/pull/9144): Add web3 usage metrics and prepare for web3 removal

## 8.0.6 Wed Jul 22 2020
- [#9030](https://github.com/MetaMask/metamask-extension/pull/9030): Hide "delete" button when editing contact of wallet account
- [#9031](https://github.com/MetaMask/metamask-extension/pull/9031): Fix crash upon removing contact
Expand Down
2 changes: 1 addition & 1 deletion app/manifest/_base.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
"version": "8.0.6",
"version": "8.0.8",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "__MSG_appDescription__",
Expand Down
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
12 changes: 7 additions & 5 deletions app/scripts/controllers/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ 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(networks.networkList[type]?.chainId || network)
}

isNetworkLoading () {
Expand All @@ -111,7 +111,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 +121,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
Loading

0 comments on commit 0052263

Please sign in to comment.