Skip to content

Commit aeea980

Browse files
montelaidevccharly
andauthored
fix: update mapping (#466)
<!-- 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 --> This PR updates the ledger mappings to update descriptions of errors and map them to the correct code. ## 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] > **Low Risk** > Changes only adjust Ledger error-code mappings/messages and corresponding tests; impact is limited to how transport errors are classified and displayed to users. > > **Overview** > Updates Ledger status-code mappings to correctly treat `0x650f` and `0x6d00` as `DeviceStateEthAppClosed` (instead of connection/V4-only errors) and adds a new mapping for `0x6a83` to represent Ethereum app closed while the device is on Solana, with clearer user-facing messages. > > Refreshes unit tests in `hw-wallet-sdk` and the `keyring-eth-ledger-bridge` error handler to assert the new codes/messages, and documents the behavior in the `hw-wallet-sdk` changelog. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit b1e2788. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
1 parent c85296b commit aeea980

File tree

4 files changed

+48
-15
lines changed

4 files changed

+48
-15
lines changed

packages/hw-wallet-sdk/CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add error mapping for status code `0x6a83` indicating Ethereum app closed while on Solana ([#446](https://github.com/MetaMask/accounts/pull/446))
13+
14+
### Fixed
15+
16+
- Fix error mappings for status codes `0x650f` and `0x6d00` to map to `DeviceStateEthAppClosed` instead of incorrect error codes ([#466](https://github.com/MetaMask/accounts/pull/466))
17+
- `0x650f`: changed from `ConnectionClosed` to `DeviceStateEthAppClosed`.
18+
- `0x6d00`: changed from `DeviceStateOnlyV4Supported` to `DeviceStateEthAppClosed`.
19+
1020
## [0.4.0]
1121

1222
### Added

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,36 @@ describe('HARDWARE_ERROR_MAPPINGS', () => {
7575
expect(mapping.severity).toBe(Severity.Warning);
7676
});
7777
});
78-
describe('connection errors', () => {
79-
it('map 0x650f to connection issue', () => {
78+
describe('device state errors', () => {
79+
it('map 0x650f to eth app closed', () => {
8080
const mapping = getLedgerMapping('0x650f');
81-
expect(mapping.code).toBe(ErrorCode.ConnectionClosed);
82-
expect(mapping.category).toBe(Category.Connection);
81+
expect(mapping.code).toBe(ErrorCode.DeviceStateEthAppClosed);
82+
expect(mapping.category).toBe(Category.DeviceState);
8383
});
84-
});
8584

86-
describe('device state errors', () => {
8785
it('maps 0x6f00 to device unresponsive', () => {
8886
const mapping = getLedgerMapping('0x6f00');
8987
expect(mapping.code).toBe(ErrorCode.DeviceUnresponsive);
9088
expect(mapping.severity).toBe(Severity.Err);
9189
expect(mapping.category).toBe(Category.DeviceState);
9290
expect(mapping.userMessage).toContain('not responding');
9391
});
92+
93+
it('maps 0x6a83 to eth app closed (on solana)', () => {
94+
const mapping = getLedgerMapping('0x6a83');
95+
expect(mapping.code).toBe(ErrorCode.DeviceStateEthAppClosed);
96+
expect(mapping.severity).toBe(Severity.Err);
97+
expect(mapping.category).toBe(Category.DeviceState);
98+
expect(mapping.userMessage).toContain('solana');
99+
});
100+
101+
it('maps 0x6d00 to eth app closed (on bitcoin)', () => {
102+
const mapping = getLedgerMapping('0x6d00');
103+
expect(mapping.code).toBe(ErrorCode.DeviceStateEthAppClosed);
104+
expect(mapping.severity).toBe(Severity.Err);
105+
expect(mapping.category).toBe(Category.DeviceState);
106+
expect(mapping.userMessage).toContain('bitcoin');
107+
});
94108
});
95109

96110
it('has valid structure for all mappings', () => {

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ export const LEDGER_ERROR_MAPPINGS: Record<string, ErrorMapping> = {
7171
'Your device is blocked due to too many failed attempts. Please follow device recovery procedures.',
7272
},
7373
'0x650f': {
74-
code: ErrorCode.ConnectionClosed,
75-
message: 'App closed or connection issue',
74+
code: ErrorCode.DeviceStateEthAppClosed,
75+
message: 'Ethereum app closed',
7676
severity: Severity.Err,
77-
category: Category.Connection,
77+
category: Category.DeviceState,
7878
userMessage:
79-
'Connection lost or app closed. Please open the corresponding app on your Ledger device.',
79+
'Ethereum app is closed. Please open it on your Ledger device to continue.',
8080
},
8181
'0x5515': {
8282
code: ErrorCode.AuthenticationDeviceLocked,
@@ -100,12 +100,21 @@ export const LEDGER_ERROR_MAPPINGS: Record<string, ErrorMapping> = {
100100
category: Category.DeviceState,
101101
userMessage: 'Blind signing is not supported on this device.',
102102
},
103+
'0x6a83': {
104+
code: ErrorCode.DeviceStateEthAppClosed,
105+
message: 'Ethereum app closed',
106+
severity: Severity.Err,
107+
category: Category.DeviceState,
108+
userMessage:
109+
'Ethereum app is closed. Currently on solana. Please open it to continue.',
110+
},
103111
'0x6d00': {
104-
code: ErrorCode.DeviceStateOnlyV4Supported,
105-
message: 'Ledger Only V4 supported',
112+
code: ErrorCode.DeviceStateEthAppClosed,
113+
message: 'Ethereum app closed',
106114
severity: Severity.Err,
107115
category: Category.DeviceState,
108-
userMessage: 'Only V4 is supported on this device.',
116+
userMessage:
117+
'Ethereum app is closed. Currently on bitcoin. Please open it to continue.',
109118
},
110119
'0x6e00': {
111120
code: ErrorCode.DeviceStateEthAppClosed,

packages/keyring-eth-ledger-bridge/src/ledger-error-handler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ describe('handleLedgerTransportError', () => {
9191
tc: 'app closed',
9292
inputMessage: 'App closed',
9393
status: 0x650f,
94-
expectedCode: ErrorCodeEnum.ConnectionClosed,
95-
expectedMessage: 'Ledger: App closed or connection issue',
94+
expectedCode: ErrorCodeEnum.DeviceStateEthAppClosed,
95+
expectedMessage: 'Ledger: Ethereum app closed',
9696
},
9797
{
9898
tc: 'unknown status codes by preserving original message',

0 commit comments

Comments
 (0)