From 310d35c0444eae57797f68b9e52ebd535e668f2f Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 24 Jun 2020 10:34:10 -0300 Subject: [PATCH 1/8] Stop upper-casing exported private key (#8850) We were showing exported private keys in all upper case. This is atypical, and many other wallets (e.g. MyCrypto) expect private keys for imported accounts to be lower-cased. Our own account import is tolerant of either case. --- ui/app/css/itcss/components/modal.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/app/css/itcss/components/modal.scss b/ui/app/css/itcss/components/modal.scss index a0b74bc8a..f6f4ff093 100644 --- a/ui/app/css/itcss/components/modal.scss +++ b/ui/app/css/itcss/components/modal.scss @@ -216,7 +216,6 @@ overflow: hidden; resize: none; padding: 9px 13px 8px; - text-transform: uppercase; } .modal-close-x::after { From 1d2644423e736aae994b5d861b3007501f233f8b Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 24 Jun 2020 12:10:29 -0300 Subject: [PATCH 2/8] Replace removed 'copy-to-clipboard' icon (#8853) The 'copy-to-clipboard' icon was removed in #8190, and replaced with a new 'Copy' icon component. It was still being used in two places though, on the confirmation page for decryption and on the reveal seed phrase screen.. The new Copy icon is now used in these two places instead. It has been given a size of '17' to match the old icon size. --- .../export-text-container/export-text-container.component.js | 3 ++- .../confirm-decrypt-message.component.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/app/components/ui/export-text-container/export-text-container.component.js b/ui/app/components/ui/export-text-container/export-text-container.component.js index 61d15a99d..21a8179a2 100644 --- a/ui/app/components/ui/export-text-container/export-text-container.component.js +++ b/ui/app/components/ui/export-text-container/export-text-container.component.js @@ -2,6 +2,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import copyToClipboard from 'copy-to-clipboard' import { exportAsFile } from '../../../helpers/utils/util' +import Copy from '../icon/copy-icon.component' class ExportTextContainer extends Component { render () { @@ -20,7 +21,7 @@ class ExportTextContainer extends Component { className="export-text-container__button export-text-container__button--copy" onClick={() => copyToClipboard(text)} > - +
{t('copyToClipboard')}
diff --git a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js index 3f82c39c4..2abef2a9f 100644 --- a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js +++ b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js @@ -7,6 +7,7 @@ import AccountListItem from '../send/account-list-item/account-list-item.compone import Button from '../../components/ui/button' import Identicon from '../../components/ui/identicon' import Tooltip from '../../components/ui/tooltip-v2' +import Copy from '../../components/ui/icon/copy-icon.component' import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../app/scripts/lib/enums' import { getEnvironmentType } from '../../../../app/scripts/lib/util' @@ -273,7 +274,7 @@ export default class ConfirmDecryptMessage extends Component { > {t('decryptCopy')} - + ) From 828ec0530ada037daa08d6e4a47b4df483eef0cc Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 24 Jun 2020 16:38:53 -0300 Subject: [PATCH 3/8] Return after 'reject' in Promise constructor (#8857) There were three cases where execution unintentionally continued after an error was encountered. These cases likely are impossible to encounter in practice due to recent validation improvements in the `eth-json-rpc-middleware/wallet` module, but they were broken nonetheless. Execution inside the Promise constructor now halts immediately after `reject` is called. --- app/scripts/lib/decrypt-message-manager.js | 2 +- app/scripts/lib/encryption-public-key-manager.js | 2 +- app/scripts/lib/personal-message-manager.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/scripts/lib/decrypt-message-manager.js b/app/scripts/lib/decrypt-message-manager.js index 94f88d12d..6345dbf57 100644 --- a/app/scripts/lib/decrypt-message-manager.js +++ b/app/scripts/lib/decrypt-message-manager.js @@ -82,7 +82,7 @@ export default class DecryptMessageManager extends EventEmitter { addUnapprovedMessageAsync (msgParams, req) { return new Promise((resolve, reject) => { if (!msgParams.from) { - reject(new Error('MetaMask Decryption: from field is required.')) + return reject(new Error('MetaMask Decryption: from field is required.')) } const msgId = this.addUnapprovedMessage(msgParams, req) this.once(`${msgId}:finished`, (data) => { diff --git a/app/scripts/lib/encryption-public-key-manager.js b/app/scripts/lib/encryption-public-key-manager.js index f568c62db..92f09057c 100644 --- a/app/scripts/lib/encryption-public-key-manager.js +++ b/app/scripts/lib/encryption-public-key-manager.js @@ -79,7 +79,7 @@ export default class EncryptionPublicKeyManager extends EventEmitter { addUnapprovedMessageAsync (address, req) { return new Promise((resolve, reject) => { if (!address) { - reject(new Error('MetaMask Message: address field is required.')) + return reject(new Error('MetaMask Message: address field is required.')) } const msgId = this.addUnapprovedMessage(address, req) this.once(`${msgId}:finished`, (data) => { diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js index 1050abefd..7d603a583 100644 --- a/app/scripts/lib/personal-message-manager.js +++ b/app/scripts/lib/personal-message-manager.js @@ -85,7 +85,7 @@ export default class PersonalMessageManager extends EventEmitter { addUnapprovedMessageAsync (msgParams, req) { return new Promise((resolve, reject) => { if (!msgParams.from) { - reject(new Error('MetaMask Message Signature: from field is required.')) + return reject(new Error('MetaMask Message Signature: from field is required.')) } const msgId = this.addUnapprovedMessage(msgParams, req) this.once(`${msgId}:finished`, (data) => { From 3bd4528d9db1929c4a87974a9a09ac19cb2abe6f Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:16:51 -0700 Subject: [PATCH 4/8] Update test-dapp (#8856) * update test-dapp --- package.json | 2 +- yarn.lock | 22 ++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index bb21eeb8f..85bf25f0b 100644 --- a/package.json +++ b/package.json @@ -189,7 +189,7 @@ "@babel/register": "^7.5.5", "@metamask/eslint-config": "^1.1.0", "@metamask/forwarder": "^1.1.0", - "@metamask/test-dapp": "^1.0.1", + "@metamask/test-dapp": "^2.1.1", "@sentry/cli": "^1.49.0", "@storybook/addon-actions": "^5.3.14", "@storybook/addon-backgrounds": "^5.3.14", diff --git a/yarn.lock b/yarn.lock index a5e596ec8..3df600274 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1711,19 +1711,10 @@ pump "^3.0.0" safe-event-emitter "^1.0.1" -"@metamask/onboarding@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@metamask/onboarding/-/onboarding-0.2.1.tgz#76e864634d6436a486fcfa743f09a25b1934a11e" - integrity sha512-wSwgkIfVHM6IWja0xfNbK+wMFweOazNe1Z1RVqS0ZKG5v8vCPT93N5IQF2mKCDD+RnBpremE1VYslPPQxQz25g== - dependencies: - bowser "^2.5.4" - -"@metamask/test-dapp@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@metamask/test-dapp/-/test-dapp-1.0.1.tgz#67961a53640faca827422fd7bc467d5b2ceb0292" - integrity sha512-RANP75a5UpCXYydaxZQ6p+4A9UjEg6YC5XS6dGatohtIKbGvN3TAU0wPot3GKcxfn9BbnGKMzQ8DIxmkrEaqSg== - dependencies: - "@metamask/onboarding" "^0.2.1" +"@metamask/test-dapp@^2.1.1": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@metamask/test-dapp/-/test-dapp-2.1.1.tgz#c3b79f93c8a698b0904171c5143d0bca1307653a" + integrity sha512-ed0Ma9TLc+wkQYJK5TWslphp58JSi4Rer84LK2RxW1p4aS2LsGKS30pKMFUegj+g9g//7tyh+uFE87pXu4vPkA== "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" @@ -5451,11 +5442,6 @@ borc@^2.1.0: iso-url "~0.4.4" json-text-sequence "~0.1.0" -bowser@^2.5.4: - version "2.7.0" - resolved "https://registry.yarnpkg.com/bowser/-/bowser-2.7.0.tgz#96eab1fa07fab08c1ec4c75977a7c8ddf8e0fe1f" - integrity sha512-aIlMvstvu8x+34KEiOHD3AsBgdrzg6sxALYiukOWhFvGMbQI6TRP/iY0LMhUrHs56aD6P1G0Z7h45PUJaa5m9w== - boxen@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" From 242db437000e0111b894505af27604a57baae128 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:21:57 -0700 Subject: [PATCH 5/8] Update inpage provider, deprecation warnings (#8854) --- app/scripts/lib/auto-reload.js | 2 +- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/scripts/lib/auto-reload.js b/app/scripts/lib/auto-reload.js index ce13ef0ca..2f50e3e88 100644 --- a/app/scripts/lib/auto-reload.js +++ b/app/scripts/lib/auto-reload.js @@ -14,7 +14,7 @@ export default function setupDappAutoReload (web3, observable) { lastTimeUsed = Date.now() // show warning once on web3 access if (!hasBeenWarned && key !== 'currentProvider') { - console.warn(`MetaMask: We will soon stop injecting web3. For more information, see: https://medium.com/metamask/no-longer-injecting-web3-js-4a899ad6e59e`) + console.warn(`MetaMask: We will stop injecting web3 in Q4 2020.\nPlease see this article for more information: https://medium.com/metamask/no-longer-injecting-web3-js-4a899ad6e59e`) hasBeenWarned = true } // return value normally diff --git a/package.json b/package.json index 85bf25f0b..a3d50701c 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "@metamask/eth-ledger-bridge-keyring": "^0.2.6", "@metamask/eth-token-tracker": "^2.0.0", "@metamask/etherscan-link": "^1.1.0", - "@metamask/inpage-provider": "^5.0.0", + "@metamask/inpage-provider": "^5.2.0", "@popperjs/core": "^2.4.0", "@reduxjs/toolkit": "^1.3.2", "@sentry/browser": "^5.11.1", diff --git a/yarn.lock b/yarn.lock index 3df600274..1df0848f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1696,10 +1696,10 @@ resolved "https://registry.yarnpkg.com/@metamask/forwarder/-/forwarder-1.1.0.tgz#13829d8244bbf19ea658c0b20d21a77b67de0bdd" integrity sha512-Hggj4y0QIjDzKGTXzarhEPIQyFSB2bi2y6YLJNwaT4JmP30UB5Cj6gqoY0M4pj3QT57fzp0BUuGp7F/AUe28tw== -"@metamask/inpage-provider@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@metamask/inpage-provider/-/inpage-provider-5.0.0.tgz#f3961ceb02821255785fe20b1b676bfd944532d7" - integrity sha512-DjQy/hJPKwEhk+L/XPHfR6bSTWsGGXjHCQ3Q/LgieQX/Kv91yyMu+QUu+tWuVi0qX0dSRmaTnFNCF9FWNV1XgA== +"@metamask/inpage-provider@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@metamask/inpage-provider/-/inpage-provider-5.2.0.tgz#a288d473e7374b1b227ea70d888e258854378c28" + integrity sha512-KyMfHcu3LqgxqS2hsxUxfIDjBQRJwOwhK6wOxOtAIRQLz4+Rns0Xt5R/Nk//U/JEskrHnNadTBgWOFCp3YzgJQ== dependencies: eth-json-rpc-errors "^2.0.2" fast-deep-equal "^2.0.1" From 85c81a5cfea6df9cfd4eeccb20b80b5b3824e54d Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Wed, 24 Jun 2020 15:34:18 -0700 Subject: [PATCH 6/8] Align copy tooltip text and icon (#8861) Add style prop to ReactTippy to override the inline display to flex display and align items to center --- .../components/request-decrypt-message.scss | 18 +++++++++--------- .../confirm-decrypt-message.component.js | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ui/app/css/itcss/components/request-decrypt-message.scss b/ui/app/css/itcss/components/request-decrypt-message.scss index 66acefa0c..3d6ad7a61 100644 --- a/ui/app/css/itcss/components/request-decrypt-message.scss +++ b/ui/app/css/itcss/components/request-decrypt-message.scss @@ -173,12 +173,12 @@ padding: 5px; border-radius: 5px; position: relative; - + &-text { font-size: 0.7em; height: 115px; } - + &-cover { background-color: white; opacity: 0.75; @@ -187,7 +187,7 @@ width: 100%; top: 0px; } - + &-lock { position: absolute; height: 100%; @@ -202,12 +202,12 @@ top: calc(50% - 34px); border-radius: 3px; } - + &--pressed { display: none; } } - + &-lock-text { width: 200px; font-size: 0.75em; @@ -219,7 +219,7 @@ line-height: 1em; border-radius: 3px; } - + &-copy { justify-content: space-evenly; font-size: 0.75em; @@ -228,12 +228,12 @@ display: flex; cursor: pointer; } - + &-copy-text { margin-right: 10px; display: inline; } - + &-copy-tooltip { float: right; } @@ -258,7 +258,7 @@ margin-right: 1.2rem; } } - + &__visual { display: flex; flex-direction: row; diff --git a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js index 2abef2a9f..a95e6d4cd 100644 --- a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js +++ b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.component.js @@ -268,6 +268,7 @@ export default class ConfirmDecryptMessage extends Component { position="bottom" title={hasCopied ? t('copiedExclamation') : t('copyToClipboard')} wrapperClassName="request-decrypt-message__message-copy-tooltip" + style={{ display: 'flex', alignItems: 'center' }} >
Date: Wed, 24 Jun 2020 19:34:39 -0300 Subject: [PATCH 7/8] Fix mobile sync redirect (#8860) The mobile sync redirect was failing due to a typo in a prop. It would fail to redirect correctly in the event of a timeout, or after pressing 'Cancel'. --- ui/app/pages/mobile-sync/mobile-sync.container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/pages/mobile-sync/mobile-sync.container.js b/ui/app/pages/mobile-sync/mobile-sync.container.js index da83ba013..28c306b1b 100644 --- a/ui/app/pages/mobile-sync/mobile-sync.container.js +++ b/ui/app/pages/mobile-sync/mobile-sync.container.js @@ -19,7 +19,7 @@ const mapStateToProps = (state) => { } = state return { - mostRecentOverviewpage: getMostRecentOverviewPage(state), + mostRecentOverviewPage: getMostRecentOverviewPage(state), selectedAddress, } } From 83fbf6608bb6859f196f174823220cf7a4ca6bd4 Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Wed, 24 Jun 2020 17:41:30 -0500 Subject: [PATCH 8/8] Restore list item title attributes (#8858) --- .../app/asset-list-item/asset-list-item.js | 2 +- .../transaction-list-item.component.js | 2 +- .../ui/list-item/list-item.component.js | 2 +- .../ui/list-item/tests/list-item.test.js | 75 +++++++++++++++++++ 4 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 ui/app/components/ui/list-item/tests/list-item.test.js diff --git a/ui/app/components/app/asset-list-item/asset-list-item.js b/ui/app/components/app/asset-list-item/asset-list-item.js index 3737698d1..bacae2d3a 100644 --- a/ui/app/components/app/asset-list-item/asset-list-item.js +++ b/ui/app/components/app/asset-list-item/asset-list-item.js @@ -97,7 +97,7 @@ const AssetListItem = ({ data-testid={dataTestId} title={primary} titleIcon={titleIcon} - subtitle={

{secondary}

} + subtitle={

{secondary}

} onClick={onClick} icon={( - + {subtitle} diff --git a/ui/app/components/ui/list-item/list-item.component.js b/ui/app/components/ui/list-item/list-item.component.js index 7481d45db..11a722d7c 100644 --- a/ui/app/components/ui/list-item/list-item.component.js +++ b/ui/app/components/ui/list-item/list-item.component.js @@ -23,7 +23,7 @@ export default function ListItem ({ {icon}
)} -
+

{ title }

{titleIcon && (
diff --git a/ui/app/components/ui/list-item/tests/list-item.test.js b/ui/app/components/ui/list-item/tests/list-item.test.js new file mode 100644 index 000000000..fdd0c587c --- /dev/null +++ b/ui/app/components/ui/list-item/tests/list-item.test.js @@ -0,0 +1,75 @@ +import { shallow } from 'enzyme' +import React from 'react' +import ListItem from '../list-item.component' +import assert from 'assert' +import Sinon from 'sinon' +import Preloader from '../../icon/preloader/preloader-icon.component' +import Send from '../../icon/send-icon.component' + +const TITLE = 'Hello World' +const SUBTITLE =

I am a list item

+const CLASSNAME = 'list-item-test' +const RIGHT_CONTENT =

Content rendered to the right

+const CHILDREN = +const MID_CONTENT =

Content rendered in the middle

+ +describe('ListItem', function () { + let wrapper + let clickHandler + before(function () { + clickHandler = Sinon.fake() + wrapper = shallow( + } + titleIcon={} + onClick={clickHandler} + > + {CHILDREN} + + ) + }) + it('includes the data-testid', function () { + assert.equal(wrapper.props()['data-testid'], 'test-id') + }) + it(`renders "${TITLE}" title`, function () { + assert.equal(wrapper.find('.list-item__heading h2').text(), TITLE) + }) + it('adds html title to heading element', function () { + assert.equal(wrapper.find('.list-item__heading').props().title, TITLE) + }) + it(`renders "I am a list item" subtitle`, function () { + assert.equal(wrapper.find('.list-item__subheading').text(), 'I am a list item') + }) + it('attaches external className', function () { + assert(wrapper.props().className.includes(CLASSNAME)) + }) + it('renders content on the right side of the list item', function () { + assert.equal(wrapper.find('.list-item__right-content p').text(), 'Content rendered to the right') + }) + it('renders content in the middle of the list item', function () { + assert.equal(wrapper.find('.list-item__mid-content p').text(), 'Content rendered in the middle') + }) + it('renders list item actions', function () { + assert.equal(wrapper.find('.list-item__actions button').text(), 'I am a button') + }) + it('renders the title icon', function () { + assert(wrapper.find(Preloader)) + }) + it('renders the list item icon', function () { + assert(wrapper.find(Send)) + }) + it('handles click action and fires onClick', function () { + wrapper.simulate('click') + assert.equal(clickHandler.callCount, 1) + }) + + after(function () { + Sinon.restore() + }) +})