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: Issue 26751 QR barcode scanner #27002

Merged
merged 9 commits into from
Sep 12, 2024
Merged

fix: Issue 26751 QR barcode scanner #27002

merged 9 commits into from
Sep 12, 2024

Conversation

ejwessel
Copy link
Contributor

@ejwessel ejwessel commented Sep 9, 2024

Description

QR scanning broke some time ago. This PR fixes scanning QR codes when provided a QR code from either mobile or from extension by extracting just the address.

Instead of using various splits and conditionals, I use regex capture groups to extract the address.

Open in GitHub Codespaces

Related issues

Fixes:
#26751
#21766

Manual testing steps

  1. select 'send'
  2. select the scan button in the destination address to field
  3. either select a QR code provided by the mobile app or provided by extension that contains a valid ethereum address
  4. validate that the address populates and no error is shown.

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.

@ejwessel ejwessel requested a review from a team as a code owner September 9, 2024 22:01
Copy link
Contributor

github-actions bot commented Sep 9, 2024

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.

@ejwessel ejwessel changed the title Fix issue 26751 QR barcode scanner fix: Issue 26751 QR barcode scanner Sep 9, 2024
@@ -30,8 +30,8 @@ const parseContent = (content) => {
// Ethereum address links - fox ex. ethereum:0x.....1111
if (content.split('ethereum:').length > 1) {
type = 'address';
values = { address: content.split('ethereum:')[1] };

// uses regex capture groups to match and extract address while ignoring everythign else
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: everythign -> everything

values = { address: content.split('ethereum:')[1] };

// uses regex capture groups to match and extract address while ignoring everythign else
values = { address: content.match(/.*:(0x[0-9a-fA-F]{40})(?:@.*)?/)[1] }
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate pointing this out but should we have this regex in a function so we can add a test? Also, is there a product consideration here? i.e. if the string ends in 0x89, and the user is on Mainnet, should something happen?

Copy link
Contributor Author

@ejwessel ejwessel Sep 9, 2024

Choose a reason for hiding this comment

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

+1 on test. though it is in parseContent, but I can make a test for this.

. if the string ends in 0x89, and the user is on Mainnet, should something happen?

perhaps, though I feel that's outside the scope of the bug.

@gauthierpetetin gauthierpetetin linked an issue Sep 10, 2024 that may be closed by this pull request
@ejwessel ejwessel requested a review from jclancy93 September 10, 2024 15:32
jclancy93
jclancy93 previously approved these changes Sep 10, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [7cc5c26]
Page Load Metrics (1757 ± 110 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint35726261695382183
domContentLoaded148626021737226109
load149426151757228110
domInteractive127931189
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 540 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [3e0d03f]
Page Load Metrics (1622 ± 78 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14502014162416981
domContentLoaded14392008160716479
load14462013162216378
domInteractive16126412612
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 540 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

darkwing
darkwing previously approved these changes Sep 11, 2024
Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

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

Works as expected! Thank you for adding tests!

yarn.lock Outdated Show resolved Hide resolved
darkwing
darkwing previously approved these changes Sep 11, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [4f7f808]
Page Load Metrics (1805 ± 94 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint17423261597598287
domContentLoaded13922298178319594
load13952304180519594
domInteractive125732147
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 548 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

Copy link

@metamaskbot
Copy link
Collaborator

Builds ready [d73dca0]
Page Load Metrics (1959 ± 140 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint27822811665566272
domContentLoaded159029531931289139
load163829561959292140
domInteractive14142432914
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 548 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

@ejwessel ejwessel merged commit 042dc15 into develop Sep 12, 2024
77 of 78 checks passed
@ejwessel ejwessel deleted the fix-issue-26751 branch September 12, 2024 16:58
@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 12, 2024
@metamaskbot metamaskbot added release-12.5.0 Issue or pull request that will be included in release 12.5.0 and removed release-12.6.0 Issue or pull request that will be included in release 12.6.0 labels Sep 29, 2024
@metamaskbot
Copy link
Collaborator

Missing release label release-12.5.0 on PR. Adding release label release-12.5.0 on PR and removing other release labels(release-12.6.0), as PR was added to branch 12.5.0 when release was cut.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.5.0 Issue or pull request that will be included in release 12.5.0 team-bridge
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Bug]: Send barcode scanner does not work
6 participants