-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## **Description** Testing the new `scopes` added on the `KeyringAccount`. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29195?quickstart=1) ## **Related issues** Requires this PR to be merged first: - [x] #28861 Related to: - MetaMask/accounts#101 - MetaMask/core#5066 - MetaMask/snap-bitcoin-wallet#364 ## **Manual testing steps** - Use a previous stable version ```console git checkout Version-v12.10.0 # Or use a release build ``` - Run it: ```console yarn yarn start:flask ``` - Create a bunch of accounts (EVM, non-EVM (Solana/Bitcoin), hardware-wallet, Snap EVM accounts like the SSK) ![Screenshot 2025-01-16 at 17 11 55](https://github.com/user-attachments/assets/815303e6-2682-4c6b-9969-8f4a8c11e0d7) - Save your extension logs (Settings > Advanced) - Now disable your extension (chrome://extensions) - Stops your `yarn start:flask` - Now, update your extension by going back to this PR (or by using the latest RC if you're validating an RC version) ```console git checkout feat/keyring-account-scopes ``` - Re-run it: ```console yarn yarn start:flask ``` - Re-enable your extension (chrome://extensions) - Open up your console logs (looking at the `service worker`) - You should now see some migrations running like: ![Screenshot 2025-01-16 at 17 14 03](https://github.com/user-attachments/assets/35c08ba9-83f4-4827-aac5-97b9ee055732) - You should also see some other migrations from the Snap keyring this like so: ![Screenshot 2025-01-16 at 18 52 48](https://github.com/user-attachments/assets/5c74700c-18a4-4452-8a47-77d1434c96ad) - Save your extension logs again (Settings > Advanced, and use a different filename) - Now, compare your 2 `.json` files ## **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/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: Howard Braham <[email protected]> Co-authored-by: MetaMask Bot <[email protected]>
- Loading branch information
1 parent
b5d2bf9
commit 20994e9
Showing
23 changed files
with
276 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { EthAccountType } from '@metamask/keyring-api'; | ||
import { InternalAccount } from '@metamask/keyring-internal-api'; | ||
import type { InternalAccount } from '@metamask/keyring-internal-api'; | ||
import { sha256FromString } from 'ethereumjs-util'; | ||
import { v4 as uuid } from 'uuid'; | ||
import { cloneDeep } from 'lodash'; | ||
|
@@ -10,12 +10,16 @@ type VersionedData = { | |
data: Record<string, unknown>; | ||
}; | ||
|
||
type Identity = { | ||
export type Identity = { | ||
name: string; | ||
address: string; | ||
lastSelected?: number; | ||
}; | ||
|
||
// The `InternalAccount` has been updated with `@metamask/[email protected]`, so we | ||
// omit the new field to re-use the original type for that migration. | ||
export type InternalAccountV1 = Omit<InternalAccount, 'scopes'>; | ||
|
||
export const version = 105; | ||
|
||
/** | ||
|
@@ -51,11 +55,11 @@ function findInternalAccountByAddress( | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
state: Record<string, any>, | ||
address: string, | ||
): InternalAccount | undefined { | ||
return Object.values<InternalAccount>( | ||
): InternalAccountV1 | undefined { | ||
return Object.values<InternalAccountV1>( | ||
state.AccountsController.internalAccounts.accounts, | ||
).find( | ||
(account: InternalAccount) => | ||
(account: InternalAccountV1) => | ||
account.address.toLowerCase() === address.toLowerCase(), | ||
); | ||
} | ||
|
@@ -84,7 +88,7 @@ function createInternalAccountsForAccountsController( | |
return; | ||
} | ||
|
||
const accounts: Record<string, InternalAccount> = {}; | ||
const accounts: Record<string, InternalAccountV1> = {}; | ||
|
||
Object.values(identities).forEach((identity) => { | ||
const expectedId = uuid({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.