Skip to content
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

fix: cherry pick Duplicate accounts fix (#9943) #9963

Merged
merged 3 commits into from
Jun 13, 2024

Conversation

owencraston
Copy link
Contributor

This PR addresses the issue of duplicate accounts showing up in the wallet. This bug was introduced when the accounts controller was integrated but was only visible to users in this
PR
when we started rendering account information in the accounts list. The is that when we ran migration 036.ts, we simply added the all of the identities from the preferences controller into the AccountsController. However the accounts controller also consumes addresses from the KeyringController and those addresses are in lowercase. The result would be two accounts with the same address, one in checksum format and one in lowercase format. This would result in duplicates when rendering the UI.

This PR addresses this issue in two ways...

  1. for users who are using <= v7.19.0
  • I have patched migration 36 to ensure that the addresses that are added are lowercase.
  1. For users who have are using version >= 7.20.0 and are already effected by this bug
  • I have created a new migration to deduplicate the accounts in the accounts controller and ensure that we are only storing lowercase addresses in state.

Fixes: #9823

  1. Install 7.18.0 and import a wallet with multiple addresses already
  2. Install 7.24.0 and upgrade app.
  3. EXPECTED: You should see duplicate accounts when you open the accounts list. If you had 5 accounts previously there will be should now be 10.
  4. Install the current branch QA build and upgrade.
  5. EXPECT: The duplicate accounts should be removed (back to 5 accounts from 10)
  6. EXPECT: The previously selected address should still be selected
  7. EXPECT: The account names should be in tact and in chronological order if they are the default account name.

this occurs for users who have not upgraded from 7.19.0 yet

  1. Install 7.18.0 and import a wallet with multiple addresses already
  2. Install the current branch QA build and upgrade.
  3. EXPECT: All of the account should appear in the accounts list without duplicates
  4. EXPECT: The previously selected address should be the same
  5. EXPECT: The account names should be the same

7.18.0

After Upgrading to 7.24.0

Upgrading to this branch

  • I’ve followed MetaMask Contributor Docs and MetaMask Mobile Coding
    Standards
    .

  • 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 format if applicable

  • I’ve applied the right labels on the PR (see labeling guidelines). 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.

Description

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

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

This PR addresses the issue of duplicate accounts showing up in the
wallet. This bug was introduced when [the accounts controller was
integrated](#8759) but
was only visible to users in [this
PR](#9733) when we
started rendering account information in the accounts list. The is that
when we ran migration `036.ts`, we simply added the all of the
identities from the preferences controller into the AccountsController.
However the accounts controller also consumes addresses from the
KeyringController and those addresses are in lowercase. The result would
be two accounts with the same address, one in checksum format and one in
lowercase format. This would result in duplicates when rendering the UI.

This PR addresses this issue in two ways...
1. for users who are using <= v7.19.0
- I have patched migration 36 to ensure that the addresses that are
added are lowercase.
2. For users who have are using version >= 7.20.0 and are already
effected by this bug
- I have created a new migration to deduplicate the accounts in the
accounts controller and ensure that we are only storing lowercase
addresses in state.

Fixes: #9823

- [Current
branch](https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c68d80ea-dbaa-4e81-9018-fe9757cab397)
-
[7.18.0](https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/011ac0b3-b1d8-4e53-9595-ea0f739d4d10)
-
[7.24.0](https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/a5c54c50-8382-45ad-b203-687b66273c4e)

1. Install
[7.18.0](https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/011ac0b3-b1d8-4e53-9595-ea0f739d4d10)
and import a wallet with multiple addresses already
2. Install
[7.24.0](https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/a5c54c50-8382-45ad-b203-687b66273c4e)
and upgrade app.
3. EXPECTED: You should see duplicate accounts when you open the
accounts list. If you had 5 accounts previously there will be should now
be 10.
4. Install [the current branch QA
build](https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c68d80ea-dbaa-4e81-9018-fe9757cab397)
and upgrade.
5. EXPECT: The duplicate accounts should be removed (back to 5 accounts
from 10)
6. EXPECT: The previously selected address should still be selected
7. EXPECT: The account names should be in tact and in chronological
order if they are the default account name.

this occurs for users who have not upgraded from 7.19.0 yet
1. Install
[7.18.0](https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/011ac0b3-b1d8-4e53-9595-ea0f739d4d10)
and import a wallet with multiple addresses already
2. Install [the current branch QA
build](https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c68d80ea-dbaa-4e81-9018-fe9757cab397)
and upgrade.
3. EXPECT: All of the account should appear in the accounts list without
duplicates
4. EXPECT: The previously selected address should be the same
5. EXPECT: The account names should be the same

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

7.18.0

<img
src="https://github.com/MetaMask/metamask-mobile/assets/22918444/3ee9b1f3-f042-414b-9ce4-82cad7d791cf"
width="200" height="400">

After Upgrading to 7.24.0

<img
src="https://github.com/MetaMask/metamask-mobile/assets/22918444/47b5ff3d-d2d0-4373-b8a0-ae0007b19b7b"
width="200" height="400">

Upgrading to this branch

<img
src="https://github.com/MetaMask/metamask-mobile/assets/22918444/9ed8d80a-ef3c-40a6-9152-e661a1ecdd25"
width="200" height="400">

- [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
- [ ] 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.

- [x] 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.
@owencraston owencraston requested a review from a team as a code owner June 12, 2024 23:10
Copy link
Contributor

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.

@owencraston owencraston changed the title fix: Duplicate accounts (#9943) fix: Duplicate accounts (#9943) Jun 12, 2024
@owencraston owencraston changed the title fix: Duplicate accounts (#9943) fix: cherry pick Duplicate accounts fix (#9943) Jun 12, 2024
@sethkfman sethkfman added Run Smoke E2E Triggers smoke e2e on Bitrise team-accounts labels Jun 12, 2024
Copy link
Contributor

github-actions bot commented Jun 12, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 0b07555
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/0075ea1f-e8ad-4981-b6c9-7d426a1d458f

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Copy link

sonarcloud bot commented Jun 13, 2024

Copy link
Contributor

@sethkfman sethkfman left a comment

Choose a reason for hiding this comment

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

LGTM

@sethkfman sethkfman merged commit 9d467b3 into release/7.24.1 Jun 13, 2024
27 of 28 checks passed
@sethkfman sethkfman deleted the chore/cherry-pick-9943 branch June 13, 2024 02:53
@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2024
@metamaskbot metamaskbot added the release-7.24.3 Issue or pull request that will be included in release 7.24.3 label Jun 19, 2024
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-7.24.3 on PR, as PR was cherry-picked in branch 7.24.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.24.3 Issue or pull request that will be included in release 7.24.3 Run Smoke E2E Triggers smoke e2e on Bitrise team-accounts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants