-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove selectSelectedAddress in favour of selectSelectedInterna…
…lAccount (#9070) ## **Description** 1. What is the reason for the change? In an effort to make MetaMask multi chain we are migrating from an address based accounts to account id based account. In [this](#8759) previous PR we integrated the accounts controller which stores metadata like the account name, address and supported methods. This pr migrates all the use of `selectSelectedAddress` to use the accounts controller as the source of truth for the selected address. 2. What is the improvement/solution? - created `selectSelectedInternalAccount` which returns the entire account object for the currently selected address - created a `selectSelectedInternalAccountAddressAsChecksum` that returns just the selected address instead of the entire accounts object - deprecated `selectSelectedAddress` - removed all use of `selectSelectedAddress` in favour of `selectSelectedInternalAccountAddressAsChecksum` or `selectSelectedInternalAccount` - For screens that only use the address then we will use the `selectSelectedInternalAccountAddressAsChecksum` - If the screen is using more than just the address (the account name for example) then we will select the entire account with `selectSelectedInternalAccount` - modified all the screen tests to mock the accounts controller state - I created some test helpers to make mocking the accounts controller - `createMockInternalAccount` and `createMockUUIDFromAddress` in `app/selectors/accountsController.test.ts` ## **Related issues** Fixes: MetaMask/MetaMask-planning#2548 ## **Manual testing steps** #### Fresh install 1. Launch wallet 2. create a new account 4. once on the wallet view, add a new account 5. create a custom name for your account(s) 6. swipe away the app and re open 7. login 8. the selected account should be same one that was previously selected 9. all addresses should be in [checksum format](https://coincodex.com/article/2078/ethereum-address-checksum-explained/) 10. connect the portfolio dapp via the portfolio button on the home screen. 11. Click connect on the portfolio dapp 12. The first address in the address picker should be match the selected address on the wallet view and be in checksum format #### Upgrade path 1. Use an existing wallet that has multiple accounts created/imported 2. Ideally change the names of your accounts so that they have custom names 3. "upgrade" your wallet to this branch 4. the selected account should be the same as it was on the previous branch 5. all of the account data should remain the same (names and balances) ## **Screenshots/Recordings** ### **Before** N/A ### **After** https://github.com/MetaMask/metamask-mobile/assets/22918444/52938128-9fbc-48a8-a8bf-0a0f4d7b2b14 ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
- Loading branch information
1 parent
76299fb
commit 3adefb4
Showing
90 changed files
with
1,212 additions
and
837 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
66 changes: 65 additions & 1 deletion
66
app/components/UI/AccountApproval/__snapshots__/index.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
412 changes: 206 additions & 206 deletions
412
app/components/UI/AccountSelectorList/__snapshots__/AccountSelector.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
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.