Skip to content

Commit e74206c

Browse files
authored
feat: add DeviceUnresponsive error code and mapping (#442)
<!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? Are there any issues or other links reviewers should consult to understand this pull request better? For instance: * Fixes #12345 * See: #67890 --> ## Examples <!-- Are there any examples of this change being used in another repository? When considering changes to the MetaMask module template, it's strongly preferred that the change be experimented with in another repository first. This gives reviewers a better sense of how the change works, making it less likely the change will need to be reverted or adjusted later. --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds support for unresponsive device handling in the hardware wallet SDK. > > - Introduces `ErrorCode.DeviceUnresponsive` (3006) in `hardware-errors-enums.ts` > - Maps Ledger status `0x6f00` to `DeviceUnresponsive` in `hardware-error-mappings.ts` with user guidance > - Extends tests in `hardware-error-mappings.test.ts` to validate the new mapping and structure > - Updates `CHANGELOG.md` under Unreleased > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 949735a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 94ddd72 commit e74206c

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

packages/hw-wallet-sdk/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `DeviceUnresponsive` error code and Ledger mapping for unresponsive device state ([#442](https://github.com/MetaMask/accounts/pull/442))
13+
1014
## [0.1.0]
1115

1216
### Added

packages/hw-wallet-sdk/src/hardware-error-mappings.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ describe('HARDWARE_ERROR_MAPPINGS', () => {
7575
});
7676
});
7777

78+
describe('device state errors', () => {
79+
it('maps 0x6f00 to device unresponsive', () => {
80+
const mapping = errorMappings['0x6f00'];
81+
expect(mapping.code).toBe(ErrorCode.DeviceUnresponsive);
82+
expect(mapping.severity).toBe(Severity.Err);
83+
expect(mapping.category).toBe(Category.DeviceState);
84+
expect(mapping.userMessage).toContain('not responding');
85+
});
86+
});
87+
7888
it('has valid structure for all mappings', () => {
7989
Object.entries(errorMappings).forEach(([_, mapping]) => {
8090
expect(mapping).toHaveProperty('code');

packages/hw-wallet-sdk/src/hardware-error-mappings.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ export const LEDGER_ERROR_MAPPINGS = {
113113
category: Category.DeviceState,
114114
userMessage: 'Ethereum app is out of date. Please update it to continue.',
115115
},
116+
'0x6f00': {
117+
code: ErrorCode.DeviceUnresponsive,
118+
message: 'Device unresponsive',
119+
severity: Severity.Err,
120+
category: Category.DeviceState,
121+
userMessage:
122+
'Your device is not responding. Please disconnect and reconnect your device.',
123+
},
116124
};
117125

118126
export const BLE_ERROR_MAPPINGS = {

packages/hw-wallet-sdk/src/hardware-errors-enums.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export enum ErrorCode {
2525
DeviceDisconnected = 3003,
2626
DeviceUsedElsewhere = 3004,
2727
DeviceCallInProgress = 3005,
28+
DeviceUnresponsive = 3006,
2829
DeviceNotFound = 3010,
2930
DeviceMultipleConnected = 3011,
3031
DeviceMissingCapability = 3020,

0 commit comments

Comments
 (0)