Skip to content

Conversation

montelaidev
Copy link
Contributor

Description

This pr adds more user friendly error messages instead of just error codes when a user encounters ledger connection issues.

Resolves #17606

Manual testing steps

  1. Go to Add hardware wallet
  2. On the ledger device, unlock it.
  3. On the Connect a hardware wallet page, Click on Ledger and then continue
  4. Do not click connect when the webhid connection window pops up.
  5. On the ledger device, lock the device
  6. On the browser, click on the nano and then continue
  7. See the new error

Screenshots/Recordings

Before

ledger-error-2

After

ledger-error

Related issues

Resolves #17606

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained:
    • What problem this PR is solving.
    • How this problem was solved.
    • How reviewers can test my changes.
  • I’ve indicated what issue this PR is linked to: Fixes #???
  • I’ve included tests if applicable.
  • I’ve documented any added code.
  • I’ve applied the right labels on the PR (see labeling guidelines).
  • 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.

@montelaidev montelaidev added the team-accounts-framework Accounts Framework team label Sep 26, 2023
@montelaidev montelaidev requested a review from a team as a code owner September 26, 2023 07:08
@github-actions
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.

@montelaidev montelaidev added the needs-content Needs content / copy support. label Sep 26, 2023
@coreyjanssen
Copy link
Contributor

How about this for a new error message?

Your Ledger is locked. Unlock it then try again.

@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

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

Comparison is base (722d8fe) 68.13% compared to head (75bd89f) 68.11%.

Files Patch % Lines
ui/pages/create-account/connect-hardware/index.js 23.53% 13 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #21038      +/-   ##
===========================================
- Coverage    68.13%   68.11%   -0.02%     
===========================================
  Files         1087     1087              
  Lines        42665    42682      +17     
  Branches     11349    11355       +6     
===========================================
+ Hits         29066    29070       +4     
- Misses       13599    13612      +13     

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

@metamaskbot
Copy link
Collaborator

Builds ready [3fc2671]
Page Load Metrics (1037 ± 415 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint84130105136
domContentLoaded7712693147
load8822071037863415
domInteractive7712593147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 261 Bytes (0.00%)
  • common: 397 Bytes (0.01%)

@AlexJupiter AlexJupiter added team-hardware-wallets-deprecated DEPRECATED: please use "team-accounts-framework" instead and removed team-accounts-framework Accounts Framework team labels Nov 29, 2023
@Akaryatrh Akaryatrh removed the needs-content Needs content / copy support. label Jan 11, 2024
@Akaryatrh Akaryatrh force-pushed the fix/17606/vague-ledger-errors branch from 3fc2671 to d93067d Compare January 15, 2024 09:27
@metamaskbot
Copy link
Collaborator

Builds ready [d93067d]
Page Load Metrics (1670 ± 188 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1043071885828
domContentLoaded11181545426
load99523591670391188
domInteractive11181545426
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 261 Bytes (0.00%)
  • common: 397 Bytes (0.01%)

@Akaryatrh Akaryatrh force-pushed the fix/17606/vague-ledger-errors branch from d93067d to ce28643 Compare January 15, 2024 14:49
Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

This is a great improvement.

The only issue I have with this PR is that it is not compatible with our script to detect if translation strings are still used. See metamask-extension/development/verify-locale-strings.js, and in particular this code:

const strictSearchRegex =
    /\bt\(\s*'(\w+)'\s*\)|\btranslationKey:\s*'(\w+)'/gu;
  // match "t(`...`)" because constructing message keys from template strings
  // prevents this script from finding the messages, and then inappropriately
  // deletes them

We use that to detect whether there are missing translation keys. So we need the exact string, and not a variable containing the string, to be passed to the t method.

To address this, you could create a function that you pass this.context.t and the ledgerErrorCode, and within that function it passes the exact string to t(), and then it returns the translated string.

@Akaryatrh Akaryatrh force-pushed the fix/17606/vague-ledger-errors branch from ce28643 to fa81d31 Compare January 17, 2024 12:35
@Akaryatrh
Copy link
Contributor

To address this, you could create a function that you pass this.context.t and the ledgerErrorCode, and within that function it passes the exact string to t(), and then it returns the translated string.

hey @danjm, is it what you had in mind?

const getErrorMessage = (errorCode, t) => {
  switch (errorCode) {
    case '0x650f':
      return t('ledgerErrorConnectionIssue');
    case '0x5515':
      return t('ledgerErrorDevicedLocked');
    case '0x6501':
      return t('ledgerErrorEthAppNotOpen');
    case '0x6a80':
      return t('ledgerErrorTransactionDataNotPadded');
    default:
      return errorCode;
  }
};

@Akaryatrh Akaryatrh force-pushed the fix/17606/vague-ledger-errors branch from 94a33c4 to 2f5850a Compare January 22, 2024 13:06
@Akaryatrh Akaryatrh requested a review from danjm January 22, 2024 13:15
@metamaskbot
Copy link
Collaborator

Builds ready [2f5850a]
Page Load Metrics (1331 ± 156 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint983252157235
domContentLoaded13201947737
load88918021331326156
domInteractive13201947637
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 497 Bytes (0.01%)
  • common: 397 Bytes (0.01%)

@Akaryatrh Akaryatrh force-pushed the fix/17606/vague-ledger-errors branch from 2f5850a to b65eac8 Compare January 23, 2024 09:03
@metamaskbot
Copy link
Collaborator

Builds ready [b65eac8]
Page Load Metrics (1546 ± 157 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint10545526810048
domContentLoaded142221008641
load110120171546326157
domInteractive142221008641
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 497 Bytes (0.01%)
  • common: 397 Bytes (0.01%)

@Akaryatrh Akaryatrh force-pushed the fix/17606/vague-ledger-errors branch from b65eac8 to 64bfa71 Compare January 23, 2024 09:49
@metamaskbot
Copy link
Collaborator

Builds ready [64bfa71]
Page Load Metrics (1677 ± 114 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1173682027435
domContentLoaded12195485125
load110720051677238114
domInteractive12195485124
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 497 Bytes (0.01%)
  • common: 397 Bytes (0.01%)

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.

lgtm!

@metamaskbot
Copy link
Collaborator

Builds ready [75bd89f]
Page Load Metrics (904 ± 42 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint951921272412
domContentLoaded11511995
load79011049048742
domInteractive11511995
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 497 Bytes (0.01%)
  • common: 397 Bytes (0.01%)

@Akaryatrh Akaryatrh merged commit fd7ed3c into develop Jan 24, 2024
@Akaryatrh Akaryatrh deleted the fix/17606/vague-ledger-errors branch January 24, 2024 16:02
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
@metamaskbot metamaskbot added the release-11.10.0 Issue or pull request that will be included in release 11.10.0 label Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-11.10.0 Issue or pull request that will be included in release 11.10.0 team-hardware-wallets-deprecated DEPRECATED: please use "team-accounts-framework" instead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Vague Error Message when Connecting to Locked Ledger

7 participants