Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/hw-wallet-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add error mapping for status code `0x6a83` indicating Ethereum app closed while on Solana ([#446](https://github.com/MetaMask/accounts/pull/446))

### Fixed

- 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))
- `0x650f`: changed from `ConnectionClosed` to `DeviceStateEthAppClosed`.
- `0x6d00`: changed from `DeviceStateOnlyV4Supported` to `DeviceStateEthAppClosed`.

## [0.4.0]

### Added
Expand Down
26 changes: 20 additions & 6 deletions packages/hw-wallet-sdk/src/hardware-error-mappings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,36 @@ describe('HARDWARE_ERROR_MAPPINGS', () => {
expect(mapping.severity).toBe(Severity.Warning);
});
});
describe('connection errors', () => {
it('map 0x650f to connection issue', () => {
describe('device state errors', () => {
it('map 0x650f to eth app closed', () => {
const mapping = getLedgerMapping('0x650f');
expect(mapping.code).toBe(ErrorCode.ConnectionClosed);
expect(mapping.category).toBe(Category.Connection);
expect(mapping.code).toBe(ErrorCode.DeviceStateEthAppClosed);
expect(mapping.category).toBe(Category.DeviceState);
});
});

describe('device state errors', () => {
it('maps 0x6f00 to device unresponsive', () => {
const mapping = getLedgerMapping('0x6f00');
expect(mapping.code).toBe(ErrorCode.DeviceUnresponsive);
expect(mapping.severity).toBe(Severity.Err);
expect(mapping.category).toBe(Category.DeviceState);
expect(mapping.userMessage).toContain('not responding');
});

it('maps 0x6a83 to eth app closed (on solana)', () => {
const mapping = getLedgerMapping('0x6a83');
expect(mapping.code).toBe(ErrorCode.DeviceStateEthAppClosed);
expect(mapping.severity).toBe(Severity.Err);
expect(mapping.category).toBe(Category.DeviceState);
expect(mapping.userMessage).toContain('solana');
});

it('maps 0x6d00 to eth app closed (on bitcoin)', () => {
const mapping = getLedgerMapping('0x6d00');
expect(mapping.code).toBe(ErrorCode.DeviceStateEthAppClosed);
expect(mapping.severity).toBe(Severity.Err);
expect(mapping.category).toBe(Category.DeviceState);
expect(mapping.userMessage).toContain('bitcoin');
});
});

it('has valid structure for all mappings', () => {
Expand Down
23 changes: 16 additions & 7 deletions packages/hw-wallet-sdk/src/hardware-error-mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ export const LEDGER_ERROR_MAPPINGS: Record<string, ErrorMapping> = {
'Your device is blocked due to too many failed attempts. Please follow device recovery procedures.',
},
'0x650f': {
code: ErrorCode.ConnectionClosed,
message: 'App closed or connection issue',
code: ErrorCode.DeviceStateEthAppClosed,
message: 'Ethereum app closed',
severity: Severity.Err,
category: Category.Connection,
category: Category.DeviceState,
userMessage:
'Connection lost or app closed. Please open the corresponding app on your Ledger device.',
'Ethereum app is closed. Please open it on your Ledger device to continue.',
},
'0x5515': {
code: ErrorCode.AuthenticationDeviceLocked,
Expand All @@ -100,12 +100,21 @@ export const LEDGER_ERROR_MAPPINGS: Record<string, ErrorMapping> = {
category: Category.DeviceState,
userMessage: 'Blind signing is not supported on this device.',
},
'0x6a83': {
code: ErrorCode.DeviceStateEthAppClosed,
message: 'Ethereum app closed',
severity: Severity.Err,
category: Category.DeviceState,
userMessage:
'Ethereum app is closed. Currently on solana. Please open it to continue.',
},
'0x6d00': {
code: ErrorCode.DeviceStateOnlyV4Supported,
message: 'Ledger Only V4 supported',
code: ErrorCode.DeviceStateEthAppClosed,
message: 'Ethereum app closed',
severity: Severity.Err,
category: Category.DeviceState,
userMessage: 'Only V4 is supported on this device.',
userMessage:
'Ethereum app is closed. Currently on bitcoin. Please open it to continue.',
},
'0x6e00': {
code: ErrorCode.DeviceStateEthAppClosed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ describe('handleLedgerTransportError', () => {
tc: 'app closed',
inputMessage: 'App closed',
status: 0x650f,
expectedCode: ErrorCodeEnum.ConnectionClosed,
expectedMessage: 'Ledger: App closed or connection issue',
expectedCode: ErrorCodeEnum.DeviceStateEthAppClosed,
expectedMessage: 'Ledger: Ethereum app closed',
},
{
tc: 'unknown status codes by preserving original message',
Expand Down
Loading