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

feat: multiple accounts support in ledger #10109

Merged
merged 99 commits into from
Jul 16, 2024

Conversation

dawnseeker8
Copy link
Contributor

@dawnseeker8 dawnseeker8 commented Jun 25, 2024

Description

This PR will enable the multiple accounts supports for ledger devices.
Following changes has been made in this PR:

  1. use @metamask/eth-ledger-keyring-bridge@4.0.0 to replace old @consensys/ledgerhq-metamask-keyring@0.0.9
  2. add LedgerSelectAccount component to allow user select multiple accounts from ledger devices. (screen is similiar to QR code select account screen)
  3. add remove accounts for all hardware wallet accounts in AccountActions.tsx file.
  4. add some metric logging for remove accounts and connect accounts
  5. modify the engine.ts code and ledger.ts to allow intialise the new ledger keyring and its middleware and transport object.
  6. Modify the BlockingActionModel to support onAnimationCompleted event so that we can have better smooth model animation than before. (very lagging animation when some heavy operations like import multiple accounts happened in the background)

Related issues

Fixes:

Manual testing steps

Connect Multiple Ledger accounts

  1. Launch wallet
  2. Create a new account
  3. Once on the wallet view, add a new account or hardware wallet
  4. Add hardware wallet
  5. Ledger
  6. Once device is found, click Continue
  7. Tick the selected Ledger accounts to be imported
  8. Click Unlock

Forget Multiple Ledger accounts

  1. Use an existing wallet that has multiple Ledger accounts imported
  2. Once on the wallet view, add a new account or hardware wallet
  3. Add hardware wallet
  4. Ledger
  5. Once device is found, click 'Continue'
  6. Click 'Forget this device' button
  7. User will be returned to account list with all Ledger accounts removed

Forget Individual Ledger Account

  1. Use an existing wallet that has multiple Ledger accounts imported
  2. Once on the wallet view, click on the three dots beside the Address section
  3. Click 'Remove hardware account'
  4. Click 'Remove'
  5. User will be returned to account list with the individual Ledger account removed

Forget Individual QR Code Wallet Account

  1. Use an existing wallet that has multiple QR Code accounts imported
  2. Once on the wallet view, click on the three dots beside the Address section
  3. Click 'Remove hardware account'
  4. Click 'Remove'
  5. User will be returned to account list with the individual QR Code account removed

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.

…the library with local change.

1. modify the Engine.ts to use new library
2. modify Ledger.ts to use new library

will expect some errors during build, will fix this error and unit tests in next commit.
# Conflicts:
#	ios/MetaMask.xcodeproj/project.pbxproj
# Conflicts:
#	ios/MetaMask.xcodeproj/project.pbxproj
…the need of release of library. also fix some issue of missing deviceId in library cause the bluetooth unable to connect.
… Still need to refactory the code to remove unused functions.
… Still need to refactory the code to remove unused functions.
…ksum not match.

also improve the unit tests for ledger.ts to cover all functions.
# Conflicts:
#	app/components/Nav/App/index.js
#	app/core/Engine.ts
#	ios/MetaMask.xcodeproj/project.pbxproj
#	package.json
#	yarn.lock
# Conflicts:
#	app/core/Engine.ts
#	app/core/Ledger/Ledger.test.ts
#	app/core/Ledger/Ledger.ts
#	patches/@MetaMask+keyring-controller+9.0.0.patch
#	yarn.lock
…ocken code.

Enhance in BlockingActionModal with smooth animation to provide better user friendly interaction.

add code to remove single accounts in actions.

Still need to fix unit tests, however because MM mobile team will upgrade keyringController to 15, will start to fix unit tests after rerbase.
# Conflicts:
#	app/components/Views/ConnectHardware/SelectHardware/index.tsx
#	app/components/Views/LedgerAccountInfo/index.tsx
#	app/core/Ledger/Ledger.test.ts
#	app/core/Ledger/Ledger.ts
#	package.json
#	patches/@MetaMask+keyring-controller+13.0.0.patch
#	yarn.lock
This version will be first version which ledger work after keyring controller 16 upgrade.
@dawnseeker8
Copy link
Contributor Author

LGTM! I just left one final comment that was not resolved yet in the previous reviews

hi, @gantunesr i have done the change to AccountSelector component to make onCheck (toggleAccount) optional.

@dawnseeker8 dawnseeker8 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 16, 2024
Copy link
Contributor

github-actions bot commented Jul 16, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: c1a24b2
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/83827214-d37b-4d3d-bf90-a0119c1a913c

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

gantunesr
gantunesr previously approved these changes Jul 16, 2024
@dawnseeker8 dawnseeker8 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 16, 2024
Copy link
Contributor

github-actions bot commented Jul 16, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 90d86ab
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/942d85f4-ec3c-4bab-936f-333db0f572cd

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

@vivek-consensys
Copy link
Contributor

vivek-consensys commented Jul 16, 2024

Flows tested on iPhone 13/iOS 17.5.1 and Samsung S21/Android 14 and screen recordings attached below:-

Connect Multiple Ledger accounts

Private Zenhub Video

Forget Multiple Ledger accounts

Private Zenhub Video

Forget Individual Ledger Account

Private Zenhub Video

Forget Individual QR Code Wallet Account

Private Zenhub Video

@vivek-consensys vivek-consensys added the QA Passed A successful QA run through has been done label Jul 16, 2024
@dawnseeker8 dawnseeker8 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 16, 2024
@dawnseeker8
Copy link
Contributor Author

…t` component to include a close icon, which will minic how the `ConnectQRHardware` component structure. hide the navigation header for `ledger Connect` screen.
@dawnseeker8 dawnseeker8 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Jul 16, 2024
Copy link
Contributor

github-actions bot commented Jul 16, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: df0bd74
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/219562a6-6f21-4700-afbc-3a0502159d3e

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 Jul 16, 2024

Copy link
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

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

LGTM!

@dawnseeker8
Copy link
Contributor Author

@dawnseeker8 dawnseeker8 merged commit 38cf842 into main Jul 16, 2024
37 of 38 checks passed
@dawnseeker8 dawnseeker8 deleted the feat/ledger-multiple-accounts-support-rebase branch July 16, 2024 13:59
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2024
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jul 16, 2024
@metamaskbot metamaskbot added the release-7.28.0 Issue or pull request that will be included in release 7.28.0 label Jul 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
hardware-ledger QA Passed A successful QA run through has been done release-7.28.0 Issue or pull request that will be included in release 7.28.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-accounts team-hardware-wallets
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants