Skip to content

Commit 427c53f

Browse files
authored
uses actionable error message for common Ledger errors (#5448)
we've seen several errors occur commonly when the Ledger app is unavailable either because the device is locked or the app isn't open catches errors with these codes and displays an error message telling the user that the error may be due to a locked device or closed app
1 parent fed1546 commit 427c53f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

ironfish-cli/src/utils/ledger.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ export class LedgerDkg {
5757
this.logger.debug(`Ledger ResponseError returnCode: ${error.returnCode.toString(16)}`)
5858
if (error.returnCode === LedgerDeviceLockedError.returnCode) {
5959
throw new LedgerDeviceLockedError('Please unlock your Ledger device.')
60-
} else if (error.returnCode === LedgerAppNotOpenError.returnCode) {
61-
throw new LedgerAppNotOpenError(
62-
'Please open the Iron Fish app on your Ledger device.',
63-
)
60+
} else if (LedgerAppUnavailableError.returnCodes.includes(error.returnCode)) {
61+
throw new LedgerAppUnavailableError()
6462
}
6563

6664
throw new LedgerError(error.errorMessage)
@@ -440,8 +438,18 @@ export class LedgerDeviceLockedError extends LedgerError {
440438
static returnCode = 0x5515
441439
}
442440

443-
export class LedgerAppNotOpenError extends LedgerError {
444-
static returnCode = 0x6f00
441+
export class LedgerAppUnavailableError extends LedgerError {
442+
static returnCodes = [
443+
0x6d00, // Instruction not supported
444+
0xffff, // Unknown transport error
445+
0x6f00, // Technical error
446+
]
447+
448+
constructor() {
449+
super(
450+
`Unable to connect to Ironfish app on Ledger. Please check that the device is unlocked and the app is open.`,
451+
)
452+
}
445453
}
446454

447455
export async function sendTransactionWithLedger(

0 commit comments

Comments
 (0)