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: (137 commits)
  Use @metamask/[email protected] (#9275)
  Standardize scss import practices (#9183)
  Update ESLint shared config to v3 (#9274)
  Add lock icon to default networks (#9269)
  Adds toPrecisionWithoutTrailingZeros utility (#9270)
  Hide gas estimate on non-main network (#9189)
  Move the mascot component to its own directory (#9272)
  Use @metamask/[email protected] (#9266)
  Fix padding, alignment of actionable-message; add left aligned story
  Code cleanup and simplification for actionable-message component
  Adds actionable message component and stories
  Fix lint issues (#9265)
  Fix prefer-destructuring issues (#9263)
  colocate confirm-decrypt-message page styles (#9252)
  Tidy up Migrator tests (#9264)
  Adds pulse loader component (#9259)
  Fix import/order issues (#9239)
  Fix radix issues (#9247)
  New info tooltip component (#9180)
  Improve scss naming
  ...
  • Loading branch information
Gudahtt committed Aug 19, 2020
2 parents a920274 + 2b7a692 commit 0c72d0b
Show file tree
Hide file tree
Showing 690 changed files with 5,085 additions and 6,099 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
89 changes: 60 additions & 29 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,22 @@ module.exports = {
},

rules: {
/* TODO: Remove these when upgrading to `@metamask/eslint-config@2` */
'array-callback-return': 'error',
'callback-return': 'error',
'global-require': 'error',
'guard-for-in': 'error',
/* End v2 rules */
'arrow-parens': 'error',
'no-tabs': 'error',
'no-mixed-operators': 'error',
'import/default': 'error',
'import/export': 'error',
'import/named': 'error',
'import/namespace': 'error',
'import/newline-after-import': 'error',
'import/no-absolute-path': 'error',
'import/no-amd': 'error',
'import/no-anonymous-default-export': 'error',
'import/no-duplicates': 'error',
'import/no-dynamic-require': 'error',
'import/no-mutable-exports': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-named-default': 'error',
'import/no-self-import': 'error',
'import/no-unresolved': ['error', { 'commonjs': true }],
'import/no-unused-modules': 'error',
'import/no-useless-path-segments': ['error', { 'commonjs': true }],
'import/no-webpack-loader-syntax': 'error',
'default-param-last': 'off',
'require-atomic-updates': 'off',
'import/no-unassigned-import': 'off',
'prefer-destructuring': ['error', {
'VariableDeclarator': {
'array': false,
'object': true,
},
'AssignmentExpression': {
'array': false,
'object': false,
},
}, {
'enforceForRenamedProperties': false,
}],
'prefer-object-spread': 'error',
'react/no-unused-prop-types': 'error',
'react/no-unused-state': 'error',
'react/jsx-boolean-value': 'error',
Expand All @@ -80,7 +68,7 @@ module.exports = {
'react/jsx-no-duplicate-props': 'error',
'react/jsx-closing-bracket-location': 'error',
'react/jsx-first-prop-new-line': ['error', 'multiline'],
'react/jsx-max-props-per-line': ['error', { 'maximum': 1, 'when': 'multiline' } ],
'react/jsx-max-props-per-line': ['error', { 'maximum': 1, 'when': 'multiline' }],
'react/jsx-tag-spacing': ['error', {
'closingSlash': 'never',
'beforeSelfClosing': 'always',
Expand All @@ -95,11 +83,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 +113,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'),
},
],
}),
],
}
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
31 changes: 16 additions & 15 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @file The entry point for the web extension singleton process.
*/


// these need to run before anything else
/* eslint-disable import/first,import/order */
import './lib/freezeGlobals'
import setupFetchDebugging from './lib/setupFetchDebugging'
/* eslint-enable import/order */

setupFetchDebugging()

Expand All @@ -17,16 +17,16 @@ import pump from 'pump'
import debounce from 'debounce-stream'
import log from 'loglevel'
import extension from 'extensionizer'
import ReadOnlyNetworkStore from './lib/network-store'
import LocalStore from './lib/local-store'
import storeTransform from 'obs-store/lib/transform'
import asStream from 'obs-store/lib/asStream'
import ExtensionPlatform from './platforms/extension'
import Migrator from './lib/migrator'
import migrations from './migrations'
import PortStream from 'extension-port-stream'
import migrations from './migrations'
import Migrator from './lib/migrator'
import ExtensionPlatform from './platforms/extension'
import LocalStore from './lib/local-store'
import ReadOnlyNetworkStore from './lib/network-store'
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 All @@ -39,9 +39,10 @@ import {
ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN,
} from './lib/enums'
/* eslint-enable import/first */

// METAMASK_TEST_CONFIG is used in e2e tests to set the default network to localhost
const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_TEST_CONFIG)
const firstTimeState = { ...rawFirstTimeState, ...global.METAMASK_TEST_CONFIG }

log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')

Expand Down Expand Up @@ -327,7 +328,7 @@ function setupController (initState, initLangCode) {
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName]

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

if (isMetaMaskInternalProcess) {
Expand Down Expand Up @@ -406,11 +407,11 @@ function setupController (initState, initLangCode) {
function updateBadge () {
let label = ''
const unapprovedTxCount = controller.txController.getUnapprovedTxCount()
const unapprovedMsgCount = controller.messageManager.unapprovedMsgCount
const unapprovedPersonalMsgCount = controller.personalMessageManager.unapprovedPersonalMsgCount
const unapprovedDecryptMsgCount = controller.decryptMessageManager.unapprovedDecryptMsgCount
const unapprovedEncryptionPublicKeyMsgCount = controller.encryptionPublicKeyManager.unapprovedEncryptionPublicKeyMsgCount
const unapprovedTypedMessagesCount = controller.typedMessageManager.unapprovedTypedMessagesCount
const { unapprovedMsgCount } = controller.messageManager
const { unapprovedPersonalMsgCount } = controller.personalMessageManager
const { unapprovedDecryptMsgCount } = controller.decryptMessageManager
const { unapprovedEncryptionPublicKeyMsgCount } = controller.encryptionPublicKeyManager
const { unapprovedTypedMessagesCount } = controller.typedMessageManager
const pendingPermissionRequests = Object.keys(controller.permissionsController.permissions.state.permissionsRequests).length
const waitingForUnlockCount = controller.appStateController.waitingForUnlock.length
const count = unapprovedTxCount + unapprovedMsgCount + unapprovedPersonalMsgCount + unapprovedDecryptMsgCount + unapprovedEncryptionPublicKeyMsgCount +
Expand Down
19 changes: 9 additions & 10 deletions app/scripts/contentscript.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pump from 'pump'
import querystring from 'querystring'
import pump from 'pump'
import LocalMessageDuplexStream from 'post-message-stream'
import ObjectMultiplex from 'obj-multiplex'
import extension from 'extensionizer'
Expand All @@ -10,7 +10,7 @@ const fs = require('fs')
const path = require('path')

const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js'), 'utf8')
const inpageSuffix = '//# sourceURL=' + extension.runtime.getURL('inpage.js') + '\n'
const inpageSuffix = `//# sourceURL=${extension.runtime.getURL('inpage.js')}\n`
const inpageBundle = inpageContent + inpageSuffix

// Eventually this streaming injection could be replaced with:
Expand Down Expand Up @@ -115,7 +115,7 @@ function forwardTrafficBetweenMuxers (channelName, muxA, muxB) {
function logStreamDisconnectWarning (remoteLabel, err) {
let warningMsg = `MetamaskContentscript - lost connection to ${remoteLabel}`
if (err) {
warningMsg += '\n' + err.stack
warningMsg += `\n${err.stack}`
}
console.warn(warningMsg)
}
Expand All @@ -136,12 +136,11 @@ function shouldInjectProvider () {
* @returns {boolean} {@code true} - if the doctype is html or if none exists
*/
function doctypeCheck () {
const doctype = window.document.doctype
const { doctype } = window.document
if (doctype) {
return doctype.name === 'html'
} else {
return true
}
return true
}

/**
Expand All @@ -155,8 +154,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 +201,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 +227,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
17 changes: 7 additions & 10 deletions app/scripts/controllers/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,21 @@ const defaultState = {
* alert related state
*/
export default class AlertController {

/**
* @constructor
* @param {AlertControllerOptions} [opts] - Controller configuration parameters
*/
constructor (opts = {}) {
const { initState, preferencesStore } = opts
const state = Object.assign(
{},
defaultState,
initState,
{
unconnectedAccountAlertShownOrigins: {},
},
)
const state = {
...defaultState,
...initState,
unconnectedAccountAlertShownOrigins: {},
}
this.store = new ObservableStore(state)

const { selectedAddress } = preferencesStore.getState()
this.selectedAddress = selectedAddress
this.selectedAddress = preferencesStore.getState().selectedAddress

preferencesStore.subscribe(({ selectedAddress }) => {
const currentState = this.store.getState()
Expand Down
14 changes: 7 additions & 7 deletions app/scripts/controllers/app-state.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ObservableStore from 'obs-store'
import EventEmitter from 'events'
import ObservableStore from 'obs-store'

export default class AppStateController extends EventEmitter {

/**
* @constructor
* @param opts
Expand All @@ -15,16 +16,14 @@ export default class AppStateController extends EventEmitter {
showUnlockRequest,
preferencesStore,
} = opts
const { preferences } = preferencesStore.getState()

super()

this.onInactiveTimeout = onInactiveTimeout || (() => {})
this.store = new ObservableStore(Object.assign({
this.onInactiveTimeout = onInactiveTimeout || (() => undefined)
this.store = new ObservableStore({
timeoutMinutes: 0,
connectedStatusPopoverHasBeenShown: true,
defaultHomeActiveTabName: null,
}, initState))
defaultHomeActiveTabName: null, ...initState,
})
this.timer = null

this.isUnlocked = isUnlocked
Expand All @@ -40,6 +39,7 @@ export default class AppStateController extends EventEmitter {
}
})

const { preferences } = preferencesStore.getState()
this._setInactiveTimeout(preferences.autoLockTimeLimit)
}

Expand Down
Loading

0 comments on commit 0c72d0b

Please sign in to comment.