feat: check for ledger error codes in the message and display a more …#21038
feat: check for ledger error codes in the message and display a more …#21038
Conversation
|
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. |
|
How about this for a new error message?
|
Codecov ReportAttention:
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. |
Builds ready [3fc2671]
Page Load Metrics (1037 ± 415 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
3fc2671 to
d93067d
Compare
Builds ready [d93067d]
Page Load Metrics (1670 ± 188 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
d93067d to
ce28643
Compare
danjm
left a comment
There was a problem hiding this comment.
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.
ce28643 to
fa81d31
Compare
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;
}
}; |
94a33c4 to
2f5850a
Compare
Builds ready [2f5850a]
Page Load Metrics (1331 ± 156 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
2f5850a to
b65eac8
Compare
Builds ready [b65eac8]
Page Load Metrics (1546 ± 157 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
b65eac8 to
64bfa71
Compare
Builds ready [64bfa71]
Page Load Metrics (1677 ± 114 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [75bd89f]
Page Load Metrics (904 ± 42 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
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
Connect a hardware walletpage, Click on Ledger and then continueScreenshots/Recordings
Before
After
Related issues
Resolves #17606
Pre-merge author checklist
Pre-merge reviewer checklist