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: decouple account selector from qr code connector #8093

Merged
merged 12 commits into from
Jan 25, 2024

Conversation

stanleyyconsensys
Copy link
Contributor

@stanleyyconsensys stanleyyconsensys commented Dec 14, 2023

Description

In order to enable multiple account select in ledger hardware wallet,
This PR is focus on decoupling the Account selector component from QR hardware wallet for reusable purpose

The changes should not impact to any UI / operations differences compare to existing QR hardware wallet account selector

For clean code purpose, the changes also decoupling the method toBlockExplorer from account selector component into a new hook useBlockExplorer

Logical flow
image

Related issues

issue : 109

Manual testing steps

  1. Go to main screen
  2. Tab current account to open account drawer
  3. Click add account or hardware account
  4. Choose add hardware account
  5. Choose QR based
  6. Scan Qr wallet
  7. Account selector should appear after scan success
  8. Account selector should able to perform select/un select account, unlock accounts, next page, prev pages operation as what it has to be in previous version

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • 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 properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

In order to enable account selector being reusable, we have to decouple the account selector from QR hardware wallet

the changes including decouple account selector & account detail components

in addtional
we also add:
An hook useBlockExplorer for generate the block explorer redirect method
An hook useAccountsBalance for generate the account balance mapping
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.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Dec 14, 2023
@stanleyyconsensys stanleyyconsensys added team-accounts Ledger Ledger hardware wallet related issue or development labels Dec 14, 2023
@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2023

Codecov Report

Attention: 45 lines in your changes are missing coverage. Please review.

Comparison is base (4f5b0ef) 40.32% compared to head (bb02b65) 40.38%.

Files Patch % Lines
...onents/UI/HardwareWallet/AccountSelector/index.tsx 3.70% 26 Missing ⚠️
app/components/Views/ConnectQRHardware/index.tsx 0.00% 10 Missing ⚠️
app/components/hooks/useBlockExplorer.ts 75.00% 2 Missing and 1 partial ⚠️
...onents/UI/HardwareWallet/AccountDetails/styles.tsx 33.33% 2 Missing ⚠️
...onents/UI/HardwareWallet/AccountSelector/hooks.tsx 84.61% 0 Missing and 2 partials ⚠️
...nents/UI/HardwareWallet/AccountSelector/styles.tsx 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8093      +/-   ##
==========================================
+ Coverage   40.32%   40.38%   +0.05%     
==========================================
  Files        1235     1239       +4     
  Lines       29948    29956       +8     
  Branches     2875     2874       -1     
==========================================
+ Hits        12078    12098      +20     
+ Misses      17175    17160      -15     
- Partials      695      698       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Akaryatrh
Akaryatrh previously approved these changes Dec 14, 2023
app/components/UI/HardwareWallet/AccountSelector/hooks.tsx Outdated Show resolved Hide resolved
Akaryatrh
Akaryatrh previously approved these changes Dec 14, 2023
@metamaskbot metamaskbot removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Dec 15, 2023
Copy link

sonarcloud bot commented Dec 15, 2023

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
6.7% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Akaryatrh
Akaryatrh previously approved these changes Dec 15, 2023
@stanleyyconsensys stanleyyconsensys marked this pull request as ready for review December 15, 2023 10:33
@stanleyyconsensys stanleyyconsensys requested a review from a team as a code owner December 15, 2023 10:33
Copy link
Contributor

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/d99f912b-acb1-4d28-b3d3-daa05736eafe
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

@vivek-consensys
Copy link
Contributor

E2E Manual Test:-

Screen_Recording_20231215_111019_MetaMask.mp4

@gantunesr
Copy link
Member

gantunesr commented Jan 23, 2024

I found a minor bug unrelated to this PR, it'd be good to open a ticket for it cc @angelcheung22

Edit: When you navigate to Etherscan from the "Connect QR Hardware Account" screen, it dismisses the previous screen to navigate to Etherscan. I think the desired behaviour is to be able to navigate back to the "Connect QR Hardware Account".

RPReplay_Final1705930225.mp4

Copy link
Member

@gantunesr gantunesr left a comment

Choose a reason for hiding this comment

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

The rest of the code looks good to me

dawnseeker8
dawnseeker8 previously approved these changes Jan 23, 2024
@angelcheung22
Copy link

I found a minor bug unrelated to this PR, it'd be good to open a ticket for it cc @angelcheung22

RPReplay_Final1705930225.mp4

Hey Gustavo, im confused about the bug that you are showing in the video. May I know whats the expected steps?

Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com>
@dawnseeker8 dawnseeker8 dismissed stale reviews from Akaryatrh and themself via 81705bb January 23, 2024 12:42
Copy link

sonarcloud bot commented Jan 24, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

6 New issues
0 Security Hotspots
33.3% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@dawnseeker8
Copy link
Contributor

i have implemented two unit tests for useBlockExplorer and hooks.tsx under hardwareWallet/AccountSelector/hooks.tsx based on @gantunesr comments in code review.
#8093

now This PR is ready to review again.

@dawnseeker8
Copy link
Contributor

Regarding the small bug @gantunesr report, i have tried with main branch and confirm that this is pre-existing bug in mobile. every etherscan link open in QR code import screen, if you click back in that screen, UI will go back to main screen.

@angelcheung22
Copy link

Regarding the small bug @gantunesr report, i have tried with main branch and confirm that this is pre-existing bug in mobile. every etherscan link open in QR code import screen, if you click back in that screen, UI will go back to main screen.

https://app.zenhub.com/workspaces/cet-metamask-hardware-wallets-6566ee6aedc46007d5a260bb/issues/zh/139 <-per discussion from last weekly with alex, this one can be low priority and add to backlog for future fixing. Added new ticket in zenhub

@gantunesr gantunesr removed their assignment Jan 25, 2024
@dawnseeker8 dawnseeker8 merged commit 1a44cb3 into main Jan 25, 2024
26 checks passed
@dawnseeker8 dawnseeker8 deleted the feat/decouple-account-selector branch January 25, 2024 12:42
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 2024
@metamaskbot metamaskbot added the release-7.16.0 Issue or pull request that will be included in release 7.16.0 label Jan 25, 2024
@angelcheung22 angelcheung22 added this to the Q1 2024 milestone Apr 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ledger Ledger hardware wallet related issue or development release-7.16.0 Issue or pull request that will be included in release 7.16.0 team-accounts team-hardware-wallets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants