Skip to content

perf(keyring-controller): do not fire unnecessary :stageChange in withKeyring #5732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 5, 2025

Conversation

ccharly
Copy link
Contributor

@ccharly ccharly commented Apr 30, 2025

Explanation

We were always calling #updateVault when using withKeyring even when the keyring was not mutated.

This PR now compare the states after the operation execution and see if the keyring got updated or not and decide to call #updateVault only if needed.

Testing PR:

References

N/A

Changelog

N/A

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@ccharly ccharly force-pushed the perf/with-keyring branch from ba27fd6 to f603e07 Compare April 30, 2025 11:53
@ccharly
Copy link
Contributor Author

ccharly commented Apr 30, 2025

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "27.0.0-preview-f603e07",
  "@metamask-previews/address-book-controller": "6.0.3-preview-f603e07",
  "@metamask-previews/announcement-controller": "7.0.3-preview-f603e07",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-f603e07",
  "@metamask-previews/approval-controller": "7.1.3-preview-f603e07",
  "@metamask-previews/assets-controllers": "60.0.0-preview-f603e07",
  "@metamask-previews/base-controller": "8.0.1-preview-f603e07",
  "@metamask-previews/bridge-controller": "19.0.0-preview-f603e07",
  "@metamask-previews/bridge-status-controller": "16.0.0-preview-f603e07",
  "@metamask-previews/build-utils": "3.0.3-preview-f603e07",
  "@metamask-previews/chain-agnostic-permission": "0.5.0-preview-f603e07",
  "@metamask-previews/composable-controller": "11.0.0-preview-f603e07",
  "@metamask-previews/controller-utils": "11.7.0-preview-f603e07",
  "@metamask-previews/delegation-controller": "0.1.0-preview-f603e07",
  "@metamask-previews/earn-controller": "0.12.0-preview-f603e07",
  "@metamask-previews/eip1193-permission-middleware": "0.1.0-preview-f603e07",
  "@metamask-previews/ens-controller": "16.0.0-preview-f603e07",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-f603e07",
  "@metamask-previews/gas-fee-controller": "23.0.0-preview-f603e07",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-f603e07",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-f603e07",
  "@metamask-previews/keyring-controller": "21.0.4-preview-f603e07",
  "@metamask-previews/logging-controller": "6.0.4-preview-f603e07",
  "@metamask-previews/message-manager": "12.0.1-preview-f603e07",
  "@metamask-previews/multichain": "4.0.0-preview-f603e07",
  "@metamask-previews/multichain-api-middleware": "0.2.0-preview-f603e07",
  "@metamask-previews/multichain-network-controller": "0.5.1-preview-f603e07",
  "@metamask-previews/multichain-transactions-controller": "0.9.0-preview-f603e07",
  "@metamask-previews/name-controller": "8.0.3-preview-f603e07",
  "@metamask-previews/network-controller": "23.3.0-preview-f603e07",
  "@metamask-previews/notification-services-controller": "6.0.0-preview-f603e07",
  "@metamask-previews/permission-controller": "11.0.6-preview-f603e07",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-f603e07",
  "@metamask-previews/phishing-controller": "12.5.0-preview-f603e07",
  "@metamask-previews/polling-controller": "13.0.0-preview-f603e07",
  "@metamask-previews/preferences-controller": "17.0.0-preview-f603e07",
  "@metamask-previews/profile-sync-controller": "12.0.0-preview-f603e07",
  "@metamask-previews/queued-request-controller": "10.0.0-preview-f603e07",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-f603e07",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-f603e07",
  "@metamask-previews/sample-controllers": "0.1.0-preview-f603e07",
  "@metamask-previews/selected-network-controller": "22.0.0-preview-f603e07",
  "@metamask-previews/signature-controller": "27.1.0-preview-f603e07",
  "@metamask-previews/token-search-discovery-controller": "3.1.0-preview-f603e07",
  "@metamask-previews/transaction-controller": "54.3.0-preview-f603e07",
  "@metamask-previews/user-operation-controller": "33.0.0-preview-f603e07"
}

@ccharly ccharly marked this pull request as ready for review April 30, 2025 14:13
@ccharly ccharly requested review from a team as code owners April 30, 2025 14:13
this.#assertIsUnlocked();
return this.#persistOrRollback(async () => true);
return this.#withRollback(async () => {
this.#assertIsUnlocked();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I suggested to place the assertion after acquiring the mutex on purpose: I think we should change all the other ones as well (in another PR)
#5757

mikesposito
mikesposito previously approved these changes May 5, 2025
Copy link
Member

@mikesposito mikesposito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ccharly
Copy link
Contributor Author

ccharly commented May 5, 2025

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented May 5, 2025

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "27.0.0-preview-b84ab30f",
  "@metamask-previews/address-book-controller": "6.0.3-preview-b84ab30f",
  "@metamask-previews/announcement-controller": "7.0.3-preview-b84ab30f",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-b84ab30f",
  "@metamask-previews/approval-controller": "7.1.3-preview-b84ab30f",
  "@metamask-previews/assets-controllers": "60.0.0-preview-b84ab30f",
  "@metamask-previews/base-controller": "8.0.1-preview-b84ab30f",
  "@metamask-previews/bridge-controller": "19.0.0-preview-b84ab30f",
  "@metamask-previews/bridge-status-controller": "16.0.0-preview-b84ab30f",
  "@metamask-previews/build-utils": "3.0.3-preview-b84ab30f",
  "@metamask-previews/chain-agnostic-permission": "0.5.0-preview-b84ab30f",
  "@metamask-previews/composable-controller": "11.0.0-preview-b84ab30f",
  "@metamask-previews/controller-utils": "11.7.0-preview-b84ab30f",
  "@metamask-previews/delegation-controller": "0.1.0-preview-b84ab30f",
  "@metamask-previews/earn-controller": "0.12.0-preview-b84ab30f",
  "@metamask-previews/eip1193-permission-middleware": "0.1.0-preview-b84ab30f",
  "@metamask-previews/ens-controller": "16.0.0-preview-b84ab30f",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-b84ab30f",
  "@metamask-previews/gas-fee-controller": "23.0.0-preview-b84ab30f",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-b84ab30f",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-b84ab30f",
  "@metamask-previews/keyring-controller": "21.0.4-preview-b84ab30f",
  "@metamask-previews/logging-controller": "6.0.4-preview-b84ab30f",
  "@metamask-previews/message-manager": "12.0.1-preview-b84ab30f",
  "@metamask-previews/multichain": "4.0.0-preview-b84ab30f",
  "@metamask-previews/multichain-api-middleware": "0.2.0-preview-b84ab30f",
  "@metamask-previews/multichain-network-controller": "0.5.1-preview-b84ab30f",
  "@metamask-previews/multichain-transactions-controller": "0.9.0-preview-b84ab30f",
  "@metamask-previews/name-controller": "8.0.3-preview-b84ab30f",
  "@metamask-previews/network-controller": "23.3.0-preview-b84ab30f",
  "@metamask-previews/notification-services-controller": "6.0.0-preview-b84ab30f",
  "@metamask-previews/permission-controller": "11.0.6-preview-b84ab30f",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-b84ab30f",
  "@metamask-previews/phishing-controller": "12.5.0-preview-b84ab30f",
  "@metamask-previews/polling-controller": "13.0.0-preview-b84ab30f",
  "@metamask-previews/preferences-controller": "17.0.0-preview-b84ab30f",
  "@metamask-previews/profile-sync-controller": "12.0.0-preview-b84ab30f",
  "@metamask-previews/queued-request-controller": "10.0.0-preview-b84ab30f",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-b84ab30f",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-b84ab30f",
  "@metamask-previews/sample-controllers": "0.1.0-preview-b84ab30f",
  "@metamask-previews/selected-network-controller": "22.0.0-preview-b84ab30f",
  "@metamask-previews/signature-controller": "27.1.0-preview-b84ab30f",
  "@metamask-previews/token-search-discovery-controller": "3.1.0-preview-b84ab30f",
  "@metamask-previews/transaction-controller": "54.3.0-preview-b84ab30f",
  "@metamask-previews/user-operation-controller": "33.0.0-preview-b84ab30f"
}

@ccharly ccharly enabled auto-merge (squash) May 5, 2025 18:06
@ccharly ccharly disabled auto-merge May 5, 2025 18:06
@ccharly
Copy link
Contributor Author

ccharly commented May 5, 2025

@ccharly ccharly merged commit a5465bb into main May 5, 2025
202 checks passed
@ccharly ccharly deleted the perf/with-keyring branch May 5, 2025 19:15
github-merge-queue bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request May 7, 2025
## **Description**

> [!CAUTION]
> Requires this PR to be merged first:
> - [x] #14913

Upgrade controllers to use the new accounts perf improvements, notably:
- MetaMask/core#5735
- MetaMask/core#5732
- MetaMask/core#5714

## **Related issues**

N/A

## **Manual testing steps**

1. Create a Solana account
2. It should run faster

## **Screenshots/Recordings**

### **Before**

### **After**

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/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.
github-merge-queue bot pushed a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
DDDDDanica pushed a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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.
-->

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

Fixes: #32935

1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

<!-- [screenshots/recordings] -->

<!-- [screenshots/recordings] -->

- [ ] 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).
- [ ] 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/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

- [ ] 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: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
runway-github bot added a commit to MetaMask/metamask-extension that referenced this pull request May 15, 2025
<!--
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**

<!--
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?
-->

Updating `@metamask/keyring-controller` to `^22.0.0`:

```markdown
## [22.0.0]

### Changed

- **BREAKING** `keyringsMetadata` has been removed from the controller state ([#5725](MetaMask/core#5725))
  - The metadata is now stored in each keyring object in the `state.keyrings` array.
  - When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
### Fixed
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](MetaMask/core#5775))

## [21.0.6]

### Changed

- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](MetaMask/core#5732))

```

and `@metamask/accounts-controller` to `^29.0.0`:

```markdown
## [29.0.0]

### Changed

- **BREAKING:** bump `@metamask/keyring-controller` peer dependency to `^22.0.0` ([#5802](MetaMask/core#5802))

## [28.0.0]

### Added
- Add new `setAccountNameAndSelectAccount` action ([#5714](MetaMask/core#5714))
- Add `entropySource` and `derivationPath` to EVM HD account options ([#5618](MetaMask/core#5618))
### Changed
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](MetaMask/core#5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.0` to `^21.0.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/base-controller` from `^8.0.0` to `^8.0.1` ([#5722](MetaMask/core#5722))
- Bump `@metamask/snaps-sdk` from `^6.17.1` to `^6.22.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/snaps-utils` from `^8.10.0` to `^9.2.0` ([#5639](MetaMask/core#5639))
- Bump `@metamask/eth-snap-keyring` from `^12.0.0` to `^12.1.1` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-api` from `^17.2.0` to `^17.4.0` ([#5565](MetaMask/core#5565))
- Bump `@metamask/keyring-internal-api` from `^6.0.0` to `^6.0.1` ([#5565](MetaMask/core#5565))
### Fixed
- Do not fire events during `update` blocks ([#5555](MetaMask/core#5555))
- Prevent unnecessary state updates when updating `InternalAccount.metadata.snap` ([#5735](MetaMask/core#5735))
```

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32621?quickstart=1)

## **Related issues**

Fixes: #32935

## **Manual testing steps**

### 1. Add duplicate to the wallet state
1.1. Switch to the `v11.7.3` branch, build locally, and install the
extension from `chrome://extensions`
1.2. Onboard with an SRP of which we know the second account (`child
guilt hollow arrive average popular nasty soon summer like scheme diary
pill country rapid`)
1.3. Import an account that is part of the mnemonic (
`0x80842b7e3cfb1118e86a427cdec418e3b4179ef5bbbfd71c02a76349831c8a8b`
which is the account at index 2 of the above SRP)
1.4. Add a new account on the main HD
1.5. Switch to `Version-v12.17.1` branch, and refresh the extension in
`chrome://extensions`
1.6. Unlock the wallet, you should see duplicates in your accounts list
and you won't be able to add new accounts

### 2. Test the fix
2.1. Switch to this branch, build locally, and refresh the extension in
`chrome://extensions`
2.2 Unlock the wallet, you shouldn't see duplicate accounts anymore, and
you should be able to add new accounts

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/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.

---------

Co-authored-by: Mark Stacey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: performance degradation during account creation
4 participants