2
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
4
import { Assert , createRootLogger , Logger } from '@ironfish/sdk'
5
- import { StatusCodes as LedgerStatusCodes , TransportStatusError } from '@ledgerhq/errors'
5
+ import { StatusCodes , TransportStatusError } from '@ledgerhq/errors'
6
6
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'
7
7
import IronfishApp , {
8
8
KeyResponse ,
@@ -12,6 +12,11 @@ import IronfishApp, {
12
12
} from '@zondax/ledger-ironfish'
13
13
import { ResponseError , Transport } from '@zondax/ledger-js'
14
14
15
+ export const IronfishLedgerStatusCodes = {
16
+ ...StatusCodes ,
17
+ COMMAND_NOT_ALLOWED : 0x6986 ,
18
+ }
19
+
15
20
export class Ledger {
16
21
app : IronfishApp | undefined
17
22
logger : Logger
@@ -41,7 +46,7 @@ export class Ledger {
41
46
if (
42
47
error instanceof ResponseError &&
43
48
error . message . includes ( 'Attempt to read beyond buffer length' ) &&
44
- error . returnCode === LedgerStatusCodes . TECHNICAL_PROBLEM
49
+ error . returnCode === IronfishLedgerStatusCodes . TECHNICAL_PROBLEM
45
50
) {
46
51
// Catch this error and swollow it until the SDK fix merges to fix
47
52
// this
@@ -56,7 +61,7 @@ export class Ledger {
56
61
} catch ( error ) {
57
62
if (
58
63
error instanceof ResponseError &&
59
- error . returnCode === LedgerStatusCodes . INS_NOT_SUPPORTED
64
+ error . returnCode === IronfishLedgerStatusCodes . INS_NOT_SUPPORTED
60
65
) {
61
66
throw new LedgerAppLocked ( )
62
67
}
@@ -77,16 +82,16 @@ export class Ledger {
77
82
}
78
83
79
84
if ( error instanceof ResponseError ) {
80
- if ( error . returnCode === LedgerStatusCodes . LOCKED_DEVICE ) {
85
+ if ( error . returnCode === IronfishLedgerStatusCodes . LOCKED_DEVICE ) {
81
86
throw new LedgerDeviceLockedError ( )
82
- } else if ( error . returnCode === LedgerStatusCodes . CLA_NOT_SUPPORTED ) {
87
+ } else if ( error . returnCode === IronfishLedgerStatusCodes . CLA_NOT_SUPPORTED ) {
83
88
throw new LedgerClaNotSupportedError ( )
84
- } else if ( error . returnCode === LedgerStatusCodes . GP_AUTH_FAILED ) {
89
+ } else if ( error . returnCode === IronfishLedgerStatusCodes . GP_AUTH_FAILED ) {
85
90
throw new LedgerGPAuthFailed ( )
86
91
} else if (
87
92
[
88
- LedgerStatusCodes . INS_NOT_SUPPORTED ,
89
- LedgerStatusCodes . TECHNICAL_PROBLEM ,
93
+ IronfishLedgerStatusCodes . INS_NOT_SUPPORTED ,
94
+ IronfishLedgerStatusCodes . TECHNICAL_PROBLEM ,
90
95
0xffff , // Unknown transport error
91
96
0x6e01 , // App not open
92
97
] . includes ( error . returnCode )
0 commit comments