Skip to content

Commit c3d076c

Browse files
release(runway): cherry-pick fix: checksummed address copied cp-13.10.0 (#37939)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR fixes the issue where the address being copied is not being the checksummed version. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37939?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: Fix a bug that was not copying the checksummed address ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to the wallet 2. Hover over the network icon 3. Click a row 4. See that the copied value is the checksummed address ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** No visual change. <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Copies a checksummed EVM address from the multichain hovered list using normalizeSafeAddress, with tests updated to expect checksum format. > > - **Frontend** > - `multichain-hovered-address-rows-hovered-list.tsx`: use `normalizeSafeAddress` when invoking copy action so copied EVM addresses are checksummed; add import. > - **Tests** > - `multichain-hovered-address-rows-hovered-list.test.tsx`: update mock EVM address and copy expectations to checksummed value; remove outdated address normalization mock; adjust assertions accordingly. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit dad9aba. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Owen Craston <[email protected]>
1 parent b7ed985 commit c3d076c

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

ui/components/multichain-accounts/multichain-address-rows-hovered-list/multichain-hovered-address-rows-hovered-list.test.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ jest.mock('../../../hooks/useI18nContext', () => ({
6363
useI18nContext: () => (key: string) => key,
6464
}));
6565

66-
jest.mock('../../../../app/scripts/lib/multichain/address', () => ({
67-
normalizeSafeAddress: jest.fn((address: string) => address),
68-
}));
69-
7066
const mockHandleCopy = jest.fn();
7167
jest.mock('../../../hooks/useCopyToClipboard', () => ({
7268
useCopyToClipboard: () => [false, mockHandleCopy],
@@ -102,7 +98,7 @@ const WALLET_ID_MOCK = toAccountWalletId(
10298
const GROUP_ID_MOCK = `${WALLET_ID_MOCK}/0` as AccountGroupId;
10399
const SPECIAL_GROUP_ID = `${WALLET_ID_MOCK}/special-0` as AccountGroupId;
104100
const ACCOUNT_EVM_ID_MOCK =
105-
'entropy:01K437Z7EJ0VCMFDE9TQKRV60A:multichain-account:01K437Z7EJ0VCMFDE9TQKRV60A:eoa:0x1234567890123456789012345678901234567890';
101+
'entropy:01K437Z7EJ0VCMFDE9TQKRV60A:multichain-account:01K437Z7EJ0VCMFDE9TQKRV60A:eoa:0x4b42aed7d99fc7874a56e6003629c89210a31c34';
106102
const ACCOUNT_BITCOIN_ID_MOCK =
107103
'bitcoin:mainnet:4e445ed5a8c09d4d3be8e7fbf7dc3314';
108104
const ACCOUNT_SOLANA_ID_MOCK =
@@ -112,7 +108,7 @@ const ACCOUNT_TRON_ID_MOCK = 'tron:mainnet:6e445ed5a8c09d4d3be8e7fbf7dc3314';
112108
const INTERNAL_ACCOUNTS_MOCK: Record<string, InternalAccount> = {
113109
[ACCOUNT_EVM_ID_MOCK]: {
114110
id: ACCOUNT_EVM_ID_MOCK,
115-
address: '0x1234567890123456789012345678901234567890',
111+
address: '0x4b42aed7d99fc7874a56e6003629c89210a31c34',
116112
metadata: {
117113
name: 'EVM Account',
118114
importTime: Date.now(),
@@ -525,7 +521,7 @@ describe('MultichainHoveredAddressRowsList', () => {
525521
if (copyButton) {
526522
fireEvent.click(copyButton);
527523
expect(mockHandleCopy).toHaveBeenCalledWith(
528-
'0x1234567890123456789012345678901234567890',
524+
'0x4B42aED7d99fC7874A56E6003629c89210A31C34',
529525
);
530526
}
531527
});
@@ -644,7 +640,7 @@ describe('MultichainHoveredAddressRowsList', () => {
644640

645641
expect(mockHandleCopy).toHaveBeenCalledTimes(1);
646642
expect(mockHandleCopy).toHaveBeenCalledWith(
647-
'0x1234567890123456789012345678901234567890',
643+
'0x4B42aED7d99fC7874A56E6003629c89210A31C34',
648644
);
649645
});
650646

@@ -665,7 +661,7 @@ describe('MultichainHoveredAddressRowsList', () => {
665661

666662
expect(mockHandleCopy).toHaveBeenCalledTimes(1);
667663
expect(mockHandleCopy).toHaveBeenCalledWith(
668-
'0x1234567890123456789012345678901234567890',
664+
'0x4B42aED7d99fC7874A56E6003629c89210A31C34',
669665
);
670666
});
671667
});

ui/components/multichain-accounts/multichain-address-rows-hovered-list/multichain-hovered-address-rows-hovered-list.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import {
3636
import { MULTICHAIN_ACCOUNT_ADDRESS_LIST_PAGE_ROUTE } from '../../../helpers/constants/routes';
3737
import { selectBalanceForAllWallets } from '../../../selectors/assets';
3838
import { useFormatters } from '../../../hooks/useFormatters';
39+
// eslint-disable-next-line import/no-restricted-paths
40+
import { normalizeSafeAddress } from '../../../../app/scripts/lib/multichain/address';
3941
import { MultichainAggregatedAddressListRow } from './multichain-aggregated-list-row';
4042

4143
// Priority networks that should appear first (using CAIP chain IDs)
@@ -241,7 +243,7 @@ export const MultichainHoveredAddressRowsList = ({
241243
index: number,
242244
): React.JSX.Element => {
243245
const handleCopyClick = () => {
244-
handleCopy(item.account.address);
246+
handleCopy(normalizeSafeAddress(item.account.address));
245247
};
246248

247249
return (

0 commit comments

Comments
 (0)