From bb562ea29cb473a5586ebd222eb1c978763d25d3 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Thu, 15 Dec 2022 13:03:59 -0330 Subject: [PATCH 1/4] =?UTF-8?q?Recipient=20name=20passed=20to=20confirm-pa?= =?UTF-8?q?ge-container=20component=20should=20be=20u=E2=80=A6=20(#16961)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Recipient name passed to confirm-page-container component should be used if pet name exists for the to address * Ensure recipient edit/add popup is shown for non-owned accounts * Ensure contract name is rendered if it exists for recipient address * Ensure that shortened address is last fallback after account, addressbook, token and ens names --- test/e2e/tests/send-eth.spec.js | 2 +- .../confirm-page-container-container.test.js | 4 ++-- .../confirm-page-container.component.js | 3 +++ .../confirm-page-container.container.js | 7 +++---- .../sender-to-recipient/sender-to-recipient.component.js | 8 +++++++- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/test/e2e/tests/send-eth.spec.js b/test/e2e/tests/send-eth.spec.js index b9500e22d..a50f21cfa 100644 --- a/test/e2e/tests/send-eth.spec.js +++ b/test/e2e/tests/send-eth.spec.js @@ -135,7 +135,7 @@ describe('Send ETH non-contract address with data that matches ERC20 transfer da await driver.clickElement({ text: 'Next', tag: 'button' }); - await driver.clickElement({ text: 'New contract' }); + await driver.clickElement({ text: '0xc42...cd28' }); const recipientAddress = await driver.findElements({ text: '0xc427D562164062a23a5cFf596A4a3208e72Acd28', diff --git a/ui/components/app/confirm-page-container/confirm-page-container-container.test.js b/ui/components/app/confirm-page-container/confirm-page-container-container.test.js index 7964f0645..2256f6e9c 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container-container.test.js +++ b/ui/components/app/confirm-page-container/confirm-page-container-container.test.js @@ -92,7 +92,7 @@ describe('Confirm Page Container Container Test', () => { expect(senderRecipient).toBeInTheDocument(); }); it('should render recipient as address', () => { - const recipientName = screen.queryByText('New contract'); + const recipientName = screen.queryByText(shortenAddress(props.toAddress)); expect(recipientName).toBeInTheDocument(); }); @@ -118,7 +118,7 @@ describe('Confirm Page Container Container Test', () => { describe('Contact/AddressBook name should appear in recipient header', () => { it('should not show add to address dialog if recipient is in contact list and should display contact name', () => { - const addressBookName = 'New contract'; + const addressBookName = 'test save name'; const addressBook = { '0x5': { diff --git a/ui/components/app/confirm-page-container/confirm-page-container.component.js b/ui/components/app/confirm-page-container/confirm-page-container.component.js index c43233232..5bf6f91ad 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container.component.js +++ b/ui/components/app/confirm-page-container/confirm-page-container.component.js @@ -68,6 +68,7 @@ export default class ConfirmPageContainer extends Component { toMetadataName: PropTypes.string, toEns: PropTypes.string, toNickname: PropTypes.string, + recipientIsOwnedAccount: PropTypes.bool, // Content contentComponent: PropTypes.node, errorKey: PropTypes.string, @@ -123,6 +124,7 @@ export default class ConfirmPageContainer extends Component { toMetadataName, toEns, toNickname, + recipientIsOwnedAccount, toAddress, disabled, errorKey, @@ -239,6 +241,7 @@ export default class ConfirmPageContainer extends Component { recipientAddress={toAddress} recipientEns={toEns} recipientNickname={toNickname} + recipientIsOwnedAccount={recipientIsOwnedAccount} /> )} diff --git a/ui/components/app/confirm-page-container/confirm-page-container.container.js b/ui/components/app/confirm-page-container/confirm-page-container.container.js index 0ce2790fc..f42ce50fc 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container.container.js +++ b/ui/components/app/confirm-page-container/confirm-page-container.container.js @@ -19,7 +19,8 @@ function mapStateToProps(state, ownProps) { const defaultToken = getSwapsDefaultToken(state); const accountBalance = defaultToken.string; const identities = getMetaMaskIdentities(state); - const toName = getAccountName(identities, to); + const ownedAccountName = getAccountName(identities, to); + const toName = ownedAccountName || contact?.name; const toMetadataName = getMetadataContractName(state, to); return { @@ -27,9 +28,7 @@ function mapStateToProps(state, ownProps) { contact, toName, toMetadataName, - isOwnedAccount: getAccountsWithLabels(state) - .map((accountWithLabel) => accountWithLabel.address) - .includes(to), + recipientIsOwnedAccount: Boolean(ownedAccountName), to, networkIdentifier, accountBalance, diff --git a/ui/components/ui/sender-to-recipient/sender-to-recipient.component.js b/ui/components/ui/sender-to-recipient/sender-to-recipient.component.js index 6aec343be..3254c9299 100644 --- a/ui/components/ui/sender-to-recipient/sender-to-recipient.component.js +++ b/ui/components/ui/sender-to-recipient/sender-to-recipient.component.js @@ -104,6 +104,7 @@ export function RecipientWithAddress({ recipientEns, recipientName, recipientMetadataName, + recipientIsOwnedAccount, }) { const t = useI18nContext(); const [showNicknamePopovers, setShowNicknamePopovers] = useState(false); @@ -127,7 +128,7 @@ export function RecipientWithAddress({
{ - if (recipientName) { + if (recipientIsOwnedAccount) { setAddressCopied(true); copyToClipboard(checksummedRecipientAddress); } else { @@ -163,6 +164,7 @@ export function RecipientWithAddress({ recipientNickname || recipientMetadataName || recipientEns || + shortenAddress(checksummedRecipientAddress) || t('newContract')}
@@ -185,6 +187,7 @@ RecipientWithAddress.propTypes = { recipientNickname: PropTypes.string, addressOnly: PropTypes.bool, onRecipientClick: PropTypes.func, + recipientIsOwnedAccount: PropTypes.bool, }; function Arrow({ variant }) { @@ -218,6 +221,7 @@ export default function SenderToRecipient({ recipientAddress, variant, warnUserOnAccountMismatch, + recipientIsOwnedAccount, }) { const t = useI18nContext(); const checksummedSenderAddress = toChecksumHexAddress(senderAddress); @@ -246,6 +250,7 @@ export default function SenderToRecipient({ recipientEns={recipientEns} recipientName={recipientName} recipientMetadataName={recipientMetadataName} + recipientIsOwnedAccount={recipientIsOwnedAccount} /> ) : (
@@ -275,4 +280,5 @@ SenderToRecipient.propTypes = { onRecipientClick: PropTypes.func, onSenderClick: PropTypes.func, warnUserOnAccountMismatch: PropTypes.bool, + recipientIsOwnedAccount: PropTypes.bool, }; From bc073a771c38c9c5cf7add0a7ce3d603e51f53c8 Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Thu, 15 Dec 2022 17:46:22 +0000 Subject: [PATCH 2/4] Version v10.23.1 --- CHANGELOG.md | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0446ee3e4..bcbcf3e12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.23.1] +### Uncategorized +- Recipient name passed to confirm-page-container component should be u… ([#16961](https://github.com/MetaMask/metamask-extension/pull/16961)) + ## [10.23.0] ### Added - Add Picker Network Component ([#16340](https://github.com/MetaMask/metamask-extension/pull/16340)) @@ -3336,7 +3340,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.0...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.23.1...HEAD +[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 [10.22.2]: https://github.com/MetaMask/metamask-extension/compare/v10.22.1...v10.22.2 diff --git a/package.json b/package.json index fddefab61..7cdef3b95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "10.23.0", + "version": "10.23.1", "private": true, "repository": { "type": "git", From 56b89e7c9ff681eeb04e25cd2c719ab345868eec Mon Sep 17 00:00:00 2001 From: seaona Date: Thu, 15 Dec 2022 19:07:27 +0100 Subject: [PATCH 3/4] Changelog entry for hotfix --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcbcf3e12..e5307cd4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [10.23.1] -### Uncategorized -- Recipient name passed to confirm-page-container component should be u… ([#16961](https://github.com/MetaMask/metamask-extension/pull/16961)) +### 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)) ## [10.23.0] ### Added From 9d6ab1bcb238bbc1c49261de2184a4f7f9b5986f Mon Sep 17 00:00:00 2001 From: seaona Date: Thu, 15 Dec 2022 20:20:58 +0100 Subject: [PATCH 4/4] Fix lint by removing un-used variable getAccountsWithLabels --- .../confirm-page-container/confirm-page-container.container.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/components/app/confirm-page-container/confirm-page-container.container.js b/ui/components/app/confirm-page-container/confirm-page-container.container.js index f42ce50fc..fb628fbb2 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container.container.js +++ b/ui/components/app/confirm-page-container/confirm-page-container.container.js @@ -1,6 +1,5 @@ import { connect } from 'react-redux'; import { - getAccountsWithLabels, getAddressBookEntry, getIsBuyableChain, getNetworkIdentifier,