-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add Accounts Controller #21437
Add Accounts Controller #21437
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
New and updated dependencies detected. Learn more about Socket for GitHub ↗︎
|
6edd2a6
to
593186a
Compare
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
@metamaskbot update-policies |
Policy update failed. You can review the logs or retry the policy update here |
@metamaskbot update-policies |
Policies updated |
@metamaskbot update-policies |
…ask/metamask-extension into feat/accounts-controller-2
Builds ready [1060e98]
Page Load Metrics (649 ± 271 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [9184101]
Page Load Metrics (279 ± 187 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [d9f20a9]
Page Load Metrics (465 ± 251 ms)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Tested commit d9f20a9 with Mac Sonoma 14.0 and primarily in chrome 117.0.5938.92 with some additional test on Firefox 119.0.1 and 120.0.0 Accounts tested: Signing, sending, deploying contracts, changing account names, removing individual accounts, forgetting devices, re-adding and signing some more all functioned as expected. Testing with throttled 3G network speeds was conducted. Migration testing confirms that user edited account names persist and migrated accounts can sign and send post-migration with no issue. |
Description
Currently, MetaMask faces tight coupling between its UI and the keyring-controller. The UI heavily relies on the keyring-controller's state while also amalgamating information from various sources, such as preferences and balances.
However, this approach presents some challenges. The keyring-controller must be aware of the UI's limitations, like the need for instant account list provision to avoid lag. Moreover, it takes on the responsibility of adding metadata to accounts, such as the associated keyring type, required for displaying account details.
To address these issues, the introduction of the accounts-controller comes into play as a new abstraction layer between the UI and the keyring-controller. This separation of responsibilities allows the keyring-controller to focus on two main tasks:
This PR introduces
@metamask/accounts-controller
and InternalAccounts to the background script. It is one of several PRs that will be switching the usage of identities to internal accounts.Changes:
getCaveatSpecifications
andgetPermissionSpecifications
usesgetInternalAccounts
instead ofgetIdentities
captureKeyringTypesWithMissingIdentities
uses theInternalAccount
model instead of anidentity
getAccount
now returns an InternalAccount, and uses the AccountsController'sgetSelectedAccount
selectedAccountChange
from the AccountsControllerselectedAddress
from the PreferencesControllerselectedAccountChange
from the AccountsControllerselectedAddress
from the PreferencesControllerselectedAccountChange
from the AccountsControlleronPreferencesStateChange
to subscribe toselectedAccountChange
from the AccountsControllergetSelectedAddress
togetSelectedAccount
setupControllerEventSubscriptions
to subscribe toselectedAccountChange
from the accounts controller and removes subscribing toselectedAddress
from the PreferencesControllersetAccountLabel
to use setAccountName from the AccountsControllercreateNewVaultAndKeychain
- awaits forupdateAccounts
and usessetSelectedAccount
from the AccountsControllerAdditions:
setSelectedInternalAccount
andsetAccountName
to the apiselectFirstIdentity
toselectFirstAccount
resetAccount
to use getSelectedAccountselectedAccountChange
to change accounts insetupControllerEventSubscription
Related issues
Resolves https://github.com/MetaMask/accounts-planning/issues/133
Manual testing steps
Screenshots/Recordings
No UI changes
Pre-merge author checklist
Pre-merge reviewer checklist