From 01634752ebc920f0b87438f0f72ec869b1b16242 Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Thu, 22 Dec 2022 20:13:54 +0000 Subject: [PATCH 1/3] Version v10.23.2 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5307cd4c..e1b928f90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.23.2] + ## [10.23.1] ### Fixed - Fix incorrectly displaying "New Contract" instead of the recipient address, on the header from the Confirmation page ([#16961](https://github.com/MetaMask/metamask-extension/pull/16961)) @@ -3340,7 +3342,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Uncategorized - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.23.1...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.23.2...HEAD +[10.23.2]: https://github.com/MetaMask/metamask-extension/compare/v10.23.1...v10.23.2 [10.23.1]: https://github.com/MetaMask/metamask-extension/compare/v10.23.0...v10.23.1 [10.23.0]: https://github.com/MetaMask/metamask-extension/compare/v10.22.3...v10.23.0 [10.22.3]: https://github.com/MetaMask/metamask-extension/compare/v10.22.2...v10.22.3 diff --git a/package.json b/package.json index 7cdef3b95..da038edc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "10.23.1", + "version": "10.23.2", "private": true, "repository": { "type": "git", From 784ad66d16a8f8a44de832f6fe61ab02650fba1b Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Thu, 22 Dec 2022 21:07:51 +0100 Subject: [PATCH 2/3] Improve `SignatureRequest` performance (#17052) * Improve SignatureRequestData performance * Memoize more selectors --- .../signature-request-data.js | 18 +++++++++++----- .../signature-request.component.js | 11 ++++++++-- .../decoding/address/address.component.js | 8 +++---- ui/selectors/selectors.js | 21 +++++++++++++++++++ 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/ui/components/app/signature-request/signature-request-data/signature-request-data.js b/ui/components/app/signature-request/signature-request-data/signature-request-data.js index 6685f1c56..0f099283b 100644 --- a/ui/components/app/signature-request/signature-request-data/signature-request-data.js +++ b/ui/components/app/signature-request/signature-request-data/signature-request-data.js @@ -1,7 +1,11 @@ -import React from 'react'; +import React, { memo } from 'react'; import { useSelector } from 'react-redux'; +import { isEqual } from 'lodash'; import PropTypes from 'prop-types'; -import { getMetaMaskIdentities, getAccountName } from '../../../../selectors'; +import { + getMemoizedMetaMaskIdentities, + getAccountName, +} from '../../../../selectors'; import Address from '../../transaction-decoding/components/decoding/address'; import { isValidHexAddress, @@ -16,15 +20,15 @@ import { TYPOGRAPHY, } from '../../../../helpers/constants/design-system'; -export default function SignatureRequestData({ data }) { - const identities = useSelector(getMetaMaskIdentities); +function SignatureRequestData({ data }) { + const identities = useSelector(getMemoizedMetaMaskIdentities); return ( {Object.entries(data).map(([label, value], i) => ( { + return isEqual(prevProps.data, nextProps.data); +}); diff --git a/ui/components/app/signature-request/signature-request.component.js b/ui/components/app/signature-request/signature-request.component.js index a76dfa8b0..d05d85f90 100644 --- a/ui/components/app/signature-request/signature-request.component.js +++ b/ui/components/app/signature-request/signature-request.component.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react'; +import { memoize } from 'lodash'; import PropTypes from 'prop-types'; import Identicon from '../../ui/identicon'; import LedgerInstructionField from '../ledger-instruction-field'; @@ -61,6 +62,12 @@ export default class SignatureRequest extends PureComponent { )}`; } + memoizedParseMessage = memoize((data) => { + const { message, domain = {}, primaryType, types } = JSON.parse(data); + const sanitizedMessage = sanitizeMessage(message, primaryType, types); + return { sanitizedMessage, domain }; + }); + render() { const { fromAccount, @@ -74,8 +81,8 @@ export default class SignatureRequest extends PureComponent { hardwareWalletRequiresConnection, } = this.props; const { address: fromAddress } = fromAccount; - const { message, domain = {}, primaryType, types } = JSON.parse(data); const { trackEvent } = this.context; + const { sanitizedMessage, domain } = this.memoizedParseMessage(data); const onSign = (event) => { sign(event); @@ -139,7 +146,7 @@ export default class SignatureRequest extends PureComponent { ) : null} this.setState({ hasScrolledMessage: true })} setMessageRootRef={this.setMessageRootRef.bind(this)} messageRootRef={this.messageRootRef} diff --git a/ui/components/app/transaction-decoding/components/decoding/address/address.component.js b/ui/components/app/transaction-decoding/components/decoding/address/address.component.js index ddb4d5cd7..9b576b5b3 100644 --- a/ui/components/app/transaction-decoding/components/decoding/address/address.component.js +++ b/ui/components/app/transaction-decoding/components/decoding/address/address.component.js @@ -6,8 +6,8 @@ import { shortenAddress } from '../../../../../../helpers/utils/util'; import Identicon from '../../../../../ui/identicon'; import { useI18nContext } from '../../../../../../hooks/useI18nContext'; import { - getMetadataContractName, - getAddressBook, + getMemoizedMetadataContractName, + getMemoizedAddressBook, } from '../../../../../../selectors'; import NicknamePopovers from '../../../../modals/nickname-popovers'; @@ -21,14 +21,14 @@ const Address = ({ const t = useI18nContext(); const [showNicknamePopovers, setShowNicknamePopovers] = useState(false); - const addressBook = useSelector(getAddressBook); + const addressBook = useSelector(getMemoizedAddressBook); const addressBookEntryObject = addressBook.find( (entry) => entry.address.toLowerCase() === checksummedRecipientAddress.toLowerCase(), ); const recipientNickname = addressBookEntryObject?.name; const recipientMetadataName = useSelector((state) => - getMetadataContractName(state, checksummedRecipientAddress), + getMemoizedMetadataContractName(state, checksummedRecipientAddress), ); const recipientToRender = addressOnly diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index b4ff5eb37..6c0789185 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -804,6 +804,27 @@ export function getShowWhatsNewPopup(state) { const createDeepEqualSelector = createSelectorCreator(defaultMemoize, isEqual); +export const getMemoizedMetaMaskIdentities = createDeepEqualSelector( + getMetaMaskIdentities, + (identities) => identities, +); + +export const getMemoizedAddressBook = createDeepEqualSelector( + getAddressBook, + (addressBook) => addressBook, +); + +export const getMemoizedMetadataContractName = createDeepEqualSelector( + getTokenList, + (_tokenList, address) => address, + (tokenList, address) => { + const entry = Object.values(tokenList).find((identity) => + isEqualCaseInsensitive(identity.address, toChecksumHexAddress(address)), + ); + return entry && entry.name !== '' ? entry.name : ''; + }, +); + export const getUnapprovedTransactions = (state) => state.metamask.unapprovedTxs; From 754c637052eb416802828ce4cc116992abc2ffaf Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Thu, 22 Dec 2022 16:50:47 -0330 Subject: [PATCH 3/3] Update changelog for v10.23.2 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1b928f90..30f18d6c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [10.23.2] +### Fixed +- Improve performance on signature request screens ([#17052](https://github.com/MetaMask/metamask-extension/pull/17052)) ## [10.23.1] ### Fixed