Skip to content

Commit 8f82ac4

Browse files
authored
refactor: use withKeyring method (#25435) (#27025)
<!-- 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? --> This PR cherry-picks def6b15 into `develop`, after being reverted at 821c3bd. The reason the original commit was reverted is explained in #26840. _From the original PR (#25435):_ With `@metamask/keyring-controller` v16 a new method is available which simplify safe direct keyring interactions which are not available through KeyringController. Through `withKeyring` it's possible to lock KeyringController's main mutex and select a specific keyring to interact with while KeyringController will be unusable concurrently. `withKeyring` also takes care of persisting keyrings and updating the controller state at the end of the operation, which makes it possible to use it in substitution of `getKeyringsByType` and `persistAllKeyrings`. Currently, most of the direct keyring interactions in the extension are made for hardware devices and snaps. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27025?quickstart=1) ## **Related issues** Fixes: #26840 Fixes: #24276 ## **Manual testing steps** _As for the original PR (#25435):_ Affected workflows may include: - Lock - Unlock - Add account - Remove account - Connect hardware wallet - All hardware wallet interactions ## **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/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.
1 parent e659f4f commit 8f82ac4

File tree

2 files changed

+219
-183
lines changed

2 files changed

+219
-183
lines changed

0 commit comments

Comments
 (0)