From 88b8ef114551b69ad37b39ef7bed048c7241cc41 Mon Sep 17 00:00:00 2001
From: Charly Chevalier
Date: Mon, 16 Sep 2024 17:14:20 +0200
Subject: [PATCH 1/6] fix(cherry-pick): resolve path-to-regexp to v1.9.0 to
resolve GHSA-9wv6-86v2-598j (#27113) (#27159)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## **Description**
This permanently fixes https://github.com/advisories/GHSA-9wv6-86v2-598j
by resolving that package to a recently released version that does not
having breaking changes and where the security vulnerability is
resolved.
[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27159?quickstart=1)
## **Related issues**
Fixes:
- https://github.com/advisories/GHSA-9wv6-86v2-598j
## **Manual testing steps**
N/A
## **Screenshots/Recordings**
### **Before**
### **After**
## **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/develop/.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/develop/.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.
Co-authored-by: Dan J Miller
Co-authored-by: MetaMask Bot
---
.yarnrc.yml | 10 ----------
lavamoat/browserify/beta/policy.json | 6 +++---
lavamoat/browserify/flask/policy.json | 6 +++---
lavamoat/browserify/main/policy.json | 6 +++---
lavamoat/browserify/mmi/policy.json | 6 +++---
package.json | 3 ++-
yarn.lock | 22 ++++------------------
7 files changed, 18 insertions(+), 41 deletions(-)
diff --git a/.yarnrc.yml b/.yarnrc.yml
index 5d4aa7cd4e73..252333917781 100644
--- a/.yarnrc.yml
+++ b/.yarnrc.yml
@@ -43,16 +43,6 @@ npmAuditIgnoreAdvisories:
# not appear to be used.
- 1092461
- # Issue: path-to-regexp outputs backtracking regular expressions
- # URL: https://github.com/advisories/GHSA-9wv6-86v2-598j
- # path-to-regexp is used in react-router v5.1.2, which we use. However, the
- # vulnerability in path-to-regexp could only be exploited within react-router
- # if malicious properties were passed to react-router components or methods
- # explicitly from our code. As such, this vulneratibility cannot be exploited
- # by an external / malicious actor. Meanwhile, once we update to v6+,
- # path-to-regexp will no longer be used.
- - 1099518
-
# Temp fix for https://github.com/MetaMask/metamask-extension/pull/16920 for the sake of 11.7.1 hotfix
# This will be removed in this ticket https://github.com/MetaMask/metamask-extension/issues/22299
- 'ts-custom-error (deprecation)'
diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json
index eb3caba43c21..605c88c89ea1 100644
--- a/lavamoat/browserify/beta/policy.json
+++ b/lavamoat/browserify/beta/policy.json
@@ -5552,7 +5552,7 @@
"react-router-dom>react-router>mini-create-react-context": true,
"react-router-dom>tiny-invariant": true,
"react-router-dom>tiny-warning": true,
- "sinon>nise>path-to-regexp": true
+ "serve-handler>path-to-regexp": true
}
},
"react-router-dom>react-router>history": {
@@ -5702,9 +5702,9 @@
"process": true
}
},
- "sinon>nise>path-to-regexp": {
+ "serve-handler>path-to-regexp": {
"packages": {
- "sinon>nise>path-to-regexp>isarray": true
+ "serve-handler>path-to-regexp>isarray": true
}
},
"stream-browserify": {
diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json
index eb3caba43c21..605c88c89ea1 100644
--- a/lavamoat/browserify/flask/policy.json
+++ b/lavamoat/browserify/flask/policy.json
@@ -5552,7 +5552,7 @@
"react-router-dom>react-router>mini-create-react-context": true,
"react-router-dom>tiny-invariant": true,
"react-router-dom>tiny-warning": true,
- "sinon>nise>path-to-regexp": true
+ "serve-handler>path-to-regexp": true
}
},
"react-router-dom>react-router>history": {
@@ -5702,9 +5702,9 @@
"process": true
}
},
- "sinon>nise>path-to-regexp": {
+ "serve-handler>path-to-regexp": {
"packages": {
- "sinon>nise>path-to-regexp>isarray": true
+ "serve-handler>path-to-regexp>isarray": true
}
},
"stream-browserify": {
diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json
index eb3caba43c21..605c88c89ea1 100644
--- a/lavamoat/browserify/main/policy.json
+++ b/lavamoat/browserify/main/policy.json
@@ -5552,7 +5552,7 @@
"react-router-dom>react-router>mini-create-react-context": true,
"react-router-dom>tiny-invariant": true,
"react-router-dom>tiny-warning": true,
- "sinon>nise>path-to-regexp": true
+ "serve-handler>path-to-regexp": true
}
},
"react-router-dom>react-router>history": {
@@ -5702,9 +5702,9 @@
"process": true
}
},
- "sinon>nise>path-to-regexp": {
+ "serve-handler>path-to-regexp": {
"packages": {
- "sinon>nise>path-to-regexp>isarray": true
+ "serve-handler>path-to-regexp>isarray": true
}
},
"stream-browserify": {
diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json
index 465b5dcf621b..96ba8b467983 100644
--- a/lavamoat/browserify/mmi/policy.json
+++ b/lavamoat/browserify/mmi/policy.json
@@ -5620,7 +5620,7 @@
"react-router-dom>react-router>mini-create-react-context": true,
"react-router-dom>tiny-invariant": true,
"react-router-dom>tiny-warning": true,
- "sinon>nise>path-to-regexp": true
+ "serve-handler>path-to-regexp": true
}
},
"react-router-dom>react-router>history": {
@@ -5770,9 +5770,9 @@
"process": true
}
},
- "sinon>nise>path-to-regexp": {
+ "serve-handler>path-to-regexp": {
"packages": {
- "sinon>nise>path-to-regexp>isarray": true
+ "serve-handler>path-to-regexp>isarray": true
}
},
"stream-browserify": {
diff --git a/package.json b/package.json
index be00bf7c6c65..c95b55be0b83 100644
--- a/package.json
+++ b/package.json
@@ -265,7 +265,8 @@
"@metamask/snaps-controllers@npm:^9.4.0": "patch:@metamask/snaps-controllers@npm%3A9.4.0#~/.yarn/patches/@metamask-snaps-controllers-npm-9.4.0-7c3abbbea6.patch",
"@metamask/nonce-tracker@npm:^5.0.0": "patch:@metamask/nonce-tracker@npm%3A5.0.0#~/.yarn/patches/@metamask-nonce-tracker-npm-5.0.0-d81478218e.patch",
"@metamask/keyring-controller@npm:^17.1.0": "patch:@metamask/keyring-controller@npm%3A17.1.1#~/.yarn/patches/@metamask-keyring-controller-npm-17.1.1-098cb41930.patch",
- "@trezor/connect-web@npm:^9.1.11": "patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch"
+ "@trezor/connect-web@npm:^9.1.11": "patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch",
+ "path-to-regexp": "1.9.0"
},
"dependencies": {
"@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch",
diff --git a/yarn.lock b/yarn.lock
index d0660f4d3233..c67922eaa24d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -28708,26 +28708,12 @@ __metadata:
languageName: node
linkType: hard
-"path-to-regexp@npm:0.1.7":
- version: 0.1.7
- resolution: "path-to-regexp@npm:0.1.7"
- checksum: 10/701c99e1f08e3400bea4d701cf6f03517474bb1b608da71c78b1eb261415b645c5670dfae49808c89e12cea2dccd113b069f040a80de012da0400191c6dbd1c8
- languageName: node
- linkType: hard
-
-"path-to-regexp@npm:2.2.1":
- version: 2.2.1
- resolution: "path-to-regexp@npm:2.2.1"
- checksum: 10/1a7125f8c1b5904d556a29722333219df4aa779039e903efe2fbfe0cc3ae9246672846fc8ad285664020b70e434347e0bc9af691fd7d61df8eaa7b018dcd56fb
- languageName: node
- linkType: hard
-
-"path-to-regexp@npm:^1.7.0":
- version: 1.7.0
- resolution: "path-to-regexp@npm:1.7.0"
+"path-to-regexp@npm:1.9.0":
+ version: 1.9.0
+ resolution: "path-to-regexp@npm:1.9.0"
dependencies:
isarray: "npm:0.0.1"
- checksum: 10/7e1275a34fcfed7ba9d0d82ea7149f0c87d8c941c9b34109ab455cceb783b6387ce9275deeb6519eb0f880777a44bcb387cd579d3bb0cfbf4e7fe93c0e3b1a69
+ checksum: 10/67f0f4823f7aab356523d93a83f9f8222bdd119fa0b27a8f8b587e8e6c9825294bb4ccd16ae619def111ff3fe5d15ff8f658cdd3b0d58b9c882de6fd15bc1b76
languageName: node
linkType: hard
From dac872f3b751fbd46a53bd80af6018f26f6893ff Mon Sep 17 00:00:00 2001
From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com>
Date: Mon, 16 Sep 2024 15:03:26 -0300
Subject: [PATCH 2/6] fix: remove repeated account option (#27116)
---
.../account-list-menu/account-list-menu.tsx | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/ui/components/multichain/account-list-menu/account-list-menu.tsx b/ui/components/multichain/account-list-menu/account-list-menu.tsx
index 2afbe6f1fcbc..653e6700c0a8 100644
--- a/ui/components/multichain/account-list-menu/account-list-menu.tsx
+++ b/ui/components/multichain/account-list-menu/account-list-menu.tsx
@@ -420,25 +420,6 @@ export const AccountListMenu = ({
) : null
///: END:ONLY_INCLUDE_IF
}
- {
- ///: BEGIN:ONLY_INCLUDE_IF(build-flask)
- bitcoinTestnetSupportEnabled ? (
-
- {
- setActionMode(ACTION_MODES.ADD_BITCOIN_TESTNET);
- }}
- data-testid="multichain-account-menu-popover-add-account-testnet"
- >
- {t('addNewBitcoinTestnetAccount')}
-
-
- ) : null
- ///: END:ONLY_INCLUDE_IF
- }
Date: Mon, 16 Sep 2024 20:48:29 +0200
Subject: [PATCH 3/6] fix (cherry-pick): typo (#27010) (#27029)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## **Description**
This PR fixes a typo for two properties that were updated in a recent
change to the Segment schema.
[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27010?quickstart=1)
## **Related issues**
[Fixes:](https://github.com/Consensys/segment-schema/pull/211)
## **Manual testing steps**
N/A
## **Screenshots/Recordings**
N/A
### **Before**
N/A
### **After**
N/A
## **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/develop/.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/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.
## **Description**
[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27029?quickstart=1)
## **Related issues**
Fixes:
## **Manual testing steps**
1. Go to this page...
2.
3.
## **Screenshots/Recordings**
### **Before**
### **After**
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.
---
.../notifications-settings-per-account.tsx | 2 +-
.../notifications-settings/notifications-settings-types.tsx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/pages/notifications-settings/notifications-settings-per-account.tsx b/ui/pages/notifications-settings/notifications-settings-per-account.tsx
index e73d6807feff..4e5afa6cb5f1 100644
--- a/ui/pages/notifications-settings/notifications-settings-per-account.tsx
+++ b/ui/pages/notifications-settings/notifications-settings-per-account.tsx
@@ -74,7 +74,7 @@ export const NotificationsSettingsPerAccount = ({
category: MetaMetricsEventCategory.NotificationSettings,
event: MetaMetricsEventName.NotificationsSettingsUpdated,
properties: {
- setting_type: 'account_notifications',
+ settings_type: 'account_notifications',
old_value: isEnabled,
new_value: !isEnabled,
},
diff --git a/ui/pages/notifications-settings/notifications-settings-types.tsx b/ui/pages/notifications-settings/notifications-settings-types.tsx
index 5b6b58763214..ba2516644e3b 100644
--- a/ui/pages/notifications-settings/notifications-settings-types.tsx
+++ b/ui/pages/notifications-settings/notifications-settings-types.tsx
@@ -58,7 +58,7 @@ export function NotificationsSettingsTypes({
category: MetaMetricsEventCategory.NotificationSettings,
event: MetaMetricsEventName.NotificationsSettingsUpdated,
properties: {
- setting_type: 'product_announcements',
+ settings_type: 'product_announcements',
old_value: featureAnnouncementsEnabled,
new_value: !featureAnnouncementsEnabled,
},
From bcd40f6a91e3195ed89640cbb0542775f338dbfd Mon Sep 17 00:00:00 2001
From: Matteo Scurati
Date: Mon, 16 Sep 2024 20:49:03 +0200
Subject: [PATCH 4/6] fix: (cherry-pick) check if the notifications started
flow is running (#27038) (#27056)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## **Description**
This PR adds a check to the modal for enabling notifications. If the
enabling process is in progress, closing the modal does not trigger the
“dismissed” event.
[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27038?quickstart=1)
## **Related issues**
N/A
## **Manual testing steps**
N/A
## **Screenshots/Recordings**
N/A
### **Before**
N/A
### **After**
N/A
## **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/develop/.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/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [x] 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.
---
.../turn-on-metamask-notifications.tsx | 27 +++++++++++--------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/ui/components/app/modals/turn-on-metamask-notifications/turn-on-metamask-notifications.tsx b/ui/components/app/modals/turn-on-metamask-notifications/turn-on-metamask-notifications.tsx
index e63e0a019b2f..de3da35fa841 100644
--- a/ui/components/app/modals/turn-on-metamask-notifications/turn-on-metamask-notifications.tsx
+++ b/ui/components/app/modals/turn-on-metamask-notifications/turn-on-metamask-notifications.tsx
@@ -51,14 +51,14 @@ export default function TurnOnMetamaskNotifications() {
);
const isProfileSyncingEnabled = useSelector(selectIsProfileSyncingEnabled);
- const [buttonState, setButtonState] = useState(
+ const [isLoading, setIsLoading] = useState(
isUpdatingMetamaskNotifications,
);
const { createNotifications, error } = useCreateNotifications();
const handleTurnOnNotifications = async () => {
- setButtonState(true);
+ setIsLoading(true);
await createNotifications();
trackEvent({
category: MetaMetricsEventCategory.NotificationsActivationFlow,
@@ -72,13 +72,18 @@ export default function TurnOnMetamaskNotifications() {
const handleHideModal = () => {
hideModal();
- trackEvent({
- category: MetaMetricsEventCategory.NotificationsActivationFlow,
- event: MetaMetricsEventName.NotificationsActivated,
- properties: {
- is_profile_syncing_enabled: isProfileSyncingEnabled,
- action_type: 'dismissed',
- },
+ setIsLoading((prevLoadingState) => {
+ if (!prevLoadingState) {
+ trackEvent({
+ category: MetaMetricsEventCategory.NotificationsActivationFlow,
+ event: MetaMetricsEventName.NotificationsActivated,
+ properties: {
+ is_profile_syncing_enabled: isProfileSyncingEnabled,
+ action_type: 'dismissed',
+ },
+ });
+ }
+ return prevLoadingState;
});
};
@@ -149,8 +154,8 @@ export default function TurnOnMetamaskNotifications() {
}}
submitButtonProps={{
children: t('turnOnMetamaskNotificationsButton'),
- loading: buttonState,
- disabled: buttonState,
+ loading: isLoading,
+ disabled: isLoading,
'data-testid': 'turn-on-notifications-button',
}}
/>
From 02de2abf2529e27cfcfd62ae7e88a7d1310b0aae Mon Sep 17 00:00:00 2001
From: David Walsh
Date: Mon, 16 Sep 2024 13:53:54 -0500
Subject: [PATCH 5/6] fix (cherry-pick): Don't show AccountListMenu back button
by default (#27152)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## **Description**
A recent change
(https://github.com/MetaMask/metamask-extension/pull/26271) made it such
that the "<" (back button) in the `AccountListMenu` component always
shows. We do *not* want this when the `AccountListMenu` first opens, so
this PR ensures that.
[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26940?quickstart=1)
## **Related issues**
Fixes:
## **Manual testing steps**
1. Open the `AccountListMenu`
2. Don't see the `<`
3. Click the "Add account" button
4. See the `<`
5. Click the `<`, go back to main menu
## **Screenshots/Recordings**
### **Before**
### **After**
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.
---
.../component-library/modal-header/modal-header.types.ts | 2 +-
.../multichain/account-list-menu/account-list-menu.test.tsx | 1 +
.../multichain/account-list-menu/account-list-menu.tsx | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ui/components/component-library/modal-header/modal-header.types.ts b/ui/components/component-library/modal-header/modal-header.types.ts
index e169c8e5709a..8b09318bf622 100644
--- a/ui/components/component-library/modal-header/modal-header.types.ts
+++ b/ui/components/component-library/modal-header/modal-header.types.ts
@@ -17,7 +17,7 @@ export interface ModalHeaderProps extends HeaderBaseStyleUtilityProps {
* The onClick handler for the back `ButtonIcon`
* When passed this will allow for the back `ButtonIcon` to show
*/
- onBack?: () => void;
+ onBack?: () => void | undefined;
/**
* The props to pass to the back `ButtonIcon`
*/
diff --git a/ui/components/multichain/account-list-menu/account-list-menu.test.tsx b/ui/components/multichain/account-list-menu/account-list-menu.test.tsx
index 60e1ca8aa99f..c55116bd2d93 100644
--- a/ui/components/multichain/account-list-menu/account-list-menu.test.tsx
+++ b/ui/components/multichain/account-list-menu/account-list-menu.test.tsx
@@ -117,6 +117,7 @@ describe('AccountListMenu', () => {
expect(getByPlaceholderText('Search accounts')).toBeInTheDocument();
expect(getByText('Add account or hardware wallet')).toBeInTheDocument();
+ expect(document.querySelector('[aria-label="Back"]')).toStrictEqual(null);
});
it('displays accounts for list and filters by search', () => {
diff --git a/ui/components/multichain/account-list-menu/account-list-menu.tsx b/ui/components/multichain/account-list-menu/account-list-menu.tsx
index 653e6700c0a8..f74d1c12a524 100644
--- a/ui/components/multichain/account-list-menu/account-list-menu.tsx
+++ b/ui/components/multichain/account-list-menu/account-list-menu.tsx
@@ -265,7 +265,7 @@ export const AccountListMenu = ({
);
// eslint-disable-next-line no-empty-function
- let onBack = () => {};
+ let onBack;
if (actionMode !== ACTION_MODES.LIST) {
if (actionMode === ACTION_MODES.MENU) {
onBack = () => setActionMode(ACTION_MODES.LIST);
From ad728f79983a014fc37e16734d2e31cffeb1d4fe Mon Sep 17 00:00:00 2001
From: Ariella Vu <20778143+digiwand@users.noreply.github.com>
Date: Tue, 17 Sep 2024 02:55:49 +0800
Subject: [PATCH 6/6] fix: cherry-pick V12.3.0 fix: PermitTransferFrom or
PermitBatchTransferFrom crashes MM when value for Name address has not been
loaded (#27168)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## **Description**
cherry-picks https://github.com/MetaMask/metamask-extension/pull/26791
into V12.3.0
no conflicts
[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27168?quickstart=1)
## **Related issues**
Fixes: https://github.com/MetaMask/metamask-extension/issues/26593
## **Manual testing steps**
1. Go to this page...
2.
3.
## **Screenshots/Recordings**
### **Before**
### **After**
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.
---
.../app/name/__snapshots__/name.test.tsx.snap | 18 ++
.../__snapshots__/name-details.test.tsx.snap | 182 ++++++++++++++++++
.../name/name-details/name-details.test.tsx | 13 ++
.../app/name/name-details/name-details.tsx | 4 +
ui/components/app/name/name.test.tsx | 14 ++
ui/components/app/name/name.tsx | 4 +
6 files changed, 235 insertions(+)
diff --git a/ui/components/app/name/__snapshots__/name.test.tsx.snap b/ui/components/app/name/__snapshots__/name.test.tsx.snap
index c3dd86968b31..ee4899a0c866 100644
--- a/ui/components/app/name/__snapshots__/name.test.tsx.snap
+++ b/ui/components/app/name/__snapshots__/name.test.tsx.snap
@@ -79,3 +79,21 @@ exports[`Name renders address with saved name 1`] = `
`;
+
+exports[`Name renders when no address value is passed 1`] = `
+
+`;
diff --git a/ui/components/app/name/name-details/__snapshots__/name-details.test.tsx.snap b/ui/components/app/name/name-details/__snapshots__/name-details.test.tsx.snap
index 6ba786d17e2e..4cc537529b14 100644
--- a/ui/components/app/name/name-details/__snapshots__/name-details.test.tsx.snap
+++ b/ui/components/app/name/name-details/__snapshots__/name-details.test.tsx.snap
@@ -259,6 +259,188 @@ exports[`NameDetails renders proposed names 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ If you know this address, give it a nickname to recognize it in the future.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{
useDispatchMock.mockReturnValue(jest.fn());
});
+ it('renders when no address value is passed', () => {
+ const { baseElement } = renderWithProvider(
+ undefined}
+ />,
+ store,
+ );
+
+ expect(baseElement).toMatchSnapshot();
+ });
+
it('renders with no saved name', () => {
const { baseElement } = renderWithProvider(
& {
};
function formatValue(value: string, type: NameType): string {
+ if (!value.length) {
+ return value;
+ }
+
switch (type) {
case NameType.ETHEREUM_ADDRESS:
return toChecksumAddress(value);
diff --git a/ui/components/app/name/name.test.tsx b/ui/components/app/name/name.test.tsx
index b56c62e5fc2a..a1c8ab8990b7 100644
--- a/ui/components/app/name/name.test.tsx
+++ b/ui/components/app/name/name.test.tsx
@@ -38,6 +38,20 @@ describe('Name', () => {
jest.resetAllMocks();
});
+ it('renders when no address value is passed', () => {
+ useDisplayNameMock.mockReturnValue({
+ name: null,
+ hasPetname: false,
+ });
+
+ const { container } = renderWithProvider(
+ ,
+ store,
+ );
+
+ expect(container).toMatchSnapshot();
+ });
+
it('renders address with no saved name', () => {
useDisplayNameMock.mockReturnValue({
name: null,
diff --git a/ui/components/app/name/name.tsx b/ui/components/app/name/name.tsx
index a5accdc5306e..7311eece2db3 100644
--- a/ui/components/app/name/name.tsx
+++ b/ui/components/app/name/name.tsx
@@ -41,6 +41,10 @@ export type NameProps = {
};
function formatValue(value: string, type: NameType): string {
+ if (!value.length) {
+ return value;
+ }
+
switch (type) {
case NameType.ETHEREUM_ADDRESS:
return shortenAddress(toChecksumAddress(value));