MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.03k stars 1.06k forks source link

feat: multiple accounts support in ledger #10109

Open dawnseeker8 opened 3 days ago

dawnseeker8 commented 3 days ago

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

github-actions[bot] commented 3 days ago

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.

codecov-commenter commented 2 days ago

Codecov Report

Attention: Patch coverage is 28.57143% with 90 lines in your changes missing coverage. Please review.

Project coverage is 49.44%. Comparing base (b013c71) to head (646cec4). Report is 122 commits behind head on main.

Files Patch % Lines
app/components/Views/LedgerSelectAccount/index.tsx 3.22% 60 Missing :warning:
...components/Views/AccountActions/AccountActions.tsx 22.22% 27 Missing and 1 partial :warning:
...nts/Views/ConnectHardware/SelectHardware/index.tsx 0.00% 1 Missing :warning:
app/components/hooks/Ledger/useLedgerBluetooth.ts 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #10109 +/- ## ========================================== + Coverage 47.24% 49.44% +2.19% ========================================== Files 1370 1427 +57 Lines 33304 34478 +1174 Branches 3586 3807 +221 ========================================== + Hits 15736 17046 +1310 + Misses 16607 16369 -238 - Partials 961 1063 +102 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 2 days ago

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 449fab396733ebcc44add614461ab41bd636381a Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/e6045017-3886-4834-8e99-f92887f5c3fb

[!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
sonarcloud[bot] commented 1 day ago

Quality Gate Failed Quality Gate failed

Failed conditions
27.5% Coverage on New Code (required ≥ 40%)

See analysis details on SonarCloud

github-actions[bot] commented 20 hours ago

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: a710a749883a7f214dd90844df577b4e7c2beaa2 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/b8ced53a-955f-4b81-966b-d96c60683205

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