17
17
import GenericApp , { ConstructorParams , LedgerError , Transport , processErrorResponse , processResponse } from '@zondax/ledger-js'
18
18
import { ResponsePayload } from '@zondax/ledger-js/dist/payload'
19
19
20
- import { P2_VALUES } from './consts'
20
+ import { ERROR_DESCRIPTION_OVERRIDE , P2_VALUES } from './consts'
21
21
import { deserializeDkgRound1 , deserializeDkgRound2 , deserializeGetIdentities , deserializeReviewTx } from './deserialize'
22
22
import { processGetIdentityResponse , processGetKeysResponse } from './helper'
23
23
import { serializeDkgGetCommitments , serializeDkgRound1 , serializeDkgRound2 , serializeDkgRound3Min , serializeDkgSign } from './serialize'
@@ -78,6 +78,7 @@ export default class IronfishApp extends GenericApp {
78
78
} ,
79
79
acceptedPathLengths : [ 3 ] ,
80
80
chunkSize : 250 ,
81
+ customAppErrorDescription : ERROR_DESCRIPTION_OVERRIDE ,
81
82
}
82
83
super ( transport , params )
83
84
}
@@ -87,7 +88,7 @@ export default class IronfishApp extends GenericApp {
87
88
const p1 = showInDevice ? this . P1_VALUES . SHOW_ADDRESS_IN_DEVICE : this . P1_VALUES . ONLY_RETRIEVE
88
89
89
90
const response = await this . transport . send ( this . CLA , this . INS . GET_KEYS , p1 , keyType , serializedPath , [ LedgerError . NoErrors ] )
90
- const payload = processResponse ( response )
91
+ const payload = processResponse ( response , this . CUSTOM_APP_ERROR_DESCRIPTION )
91
92
return processGetKeysResponse ( payload , keyType )
92
93
}
93
94
@@ -103,7 +104,7 @@ export default class IronfishApp extends GenericApp {
103
104
signature : result . readBytes ( result . length ( ) ) ,
104
105
}
105
106
} catch ( e ) {
106
- throw processErrorResponse ( e )
107
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
107
108
}
108
109
}
109
110
@@ -113,7 +114,7 @@ export default class IronfishApp extends GenericApp {
113
114
114
115
const p1 = showInDevice ? 1 : 0
115
116
const response = await this . transport . send ( this . CLA , this . INS . DKG_IDENTITY , p1 , 0 , req , [ LedgerError . NoErrors ] )
116
- const data = processResponse ( response )
117
+ const data = processResponse ( response , this . CUSTOM_APP_ERROR_DESCRIPTION )
117
118
return processGetIdentityResponse ( data )
118
119
}
119
120
@@ -130,7 +131,7 @@ export default class IronfishApp extends GenericApp {
130
131
let result = await this . getResult ( rawResponse )
131
132
return deserializeDkgRound1 ( result )
132
133
} catch ( e ) {
133
- throw processErrorResponse ( e )
134
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
134
135
}
135
136
}
136
137
@@ -147,7 +148,7 @@ export default class IronfishApp extends GenericApp {
147
148
let result = await this . getResult ( rawResponse )
148
149
return deserializeDkgRound2 ( result )
149
150
} catch ( e ) {
150
- throw processErrorResponse ( e )
151
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
151
152
}
152
153
}
153
154
@@ -167,7 +168,7 @@ export default class IronfishApp extends GenericApp {
167
168
await this . sendGenericChunk ( this . INS . DKG_ROUND_3_MIN , P2_VALUES . DEFAULT , 1 + i , chunks . length , chunks [ i ] )
168
169
}
169
170
} catch ( e ) {
170
- throw processErrorResponse ( e )
171
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
171
172
}
172
173
}
173
174
@@ -186,7 +187,7 @@ export default class IronfishApp extends GenericApp {
186
187
commitments : result ,
187
188
}
188
189
} catch ( e ) {
189
- throw processErrorResponse ( e )
190
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
190
191
}
191
192
}
192
193
@@ -205,56 +206,56 @@ export default class IronfishApp extends GenericApp {
205
206
signature : result ,
206
207
}
207
208
} catch ( e ) {
208
- throw processErrorResponse ( e )
209
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
209
210
}
210
211
}
211
212
212
213
async dkgGetPublicPackage ( ) : Promise < ResponseDkgGetPublicPackage > {
213
214
try {
214
215
let response = await this . transport . send ( this . CLA , this . INS . DKG_GET_PUBLIC_PACKAGE , 0 , 0 , Buffer . alloc ( 0 ) , [ LedgerError . NoErrors ] )
215
- let data = processResponse ( response )
216
+ let data = processResponse ( response , this . CUSTOM_APP_ERROR_DESCRIPTION )
216
217
217
218
let result = await this . getResult ( data )
218
219
219
220
return {
220
221
publicPackage : result ,
221
222
}
222
223
} catch ( e ) {
223
- throw processErrorResponse ( e )
224
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
224
225
}
225
226
}
226
227
227
228
async dkgBackupKeys ( ) : Promise < ResponseDkgBackupKeys > {
228
229
try {
229
230
let response = await this . transport . send ( this . CLA , this . INS . DKG_BACKUP_KEYS , 0 , 0 , Buffer . alloc ( 0 ) , [ LedgerError . NoErrors ] )
230
- let data = processResponse ( response )
231
+ let data = processResponse ( response , this . CUSTOM_APP_ERROR_DESCRIPTION )
231
232
232
233
let result = await this . getResult ( data )
233
234
234
235
return {
235
236
encryptedKeys : result ,
236
237
}
237
238
} catch ( e ) {
238
- throw processErrorResponse ( e )
239
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
239
240
}
240
241
}
241
242
242
243
async dkgGetIdentities ( ) : Promise < ResponseIdentities > {
243
244
try {
244
245
let response = await this . transport . send ( this . CLA , this . INS . DKG_IDENTITIES , 0 , 0 , Buffer . alloc ( 0 ) , [ LedgerError . NoErrors ] )
245
- let data = processResponse ( response )
246
+ let data = processResponse ( response , this . CUSTOM_APP_ERROR_DESCRIPTION )
246
247
247
248
let result = await this . getResult ( data )
248
249
return deserializeGetIdentities ( result )
249
250
} catch ( e ) {
250
- throw processErrorResponse ( e )
251
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
251
252
}
252
253
}
253
254
254
255
async dkgRetrieveKeys ( keyType : IronfishKeys , showInDevice ?: boolean ) : Promise < KeyResponse > {
255
256
const p1 = showInDevice ? 1 : 0
256
257
const response = await this . transport . send ( this . CLA , this . INS . DKG_GET_KEYS , p1 , keyType , Buffer . alloc ( 0 ) , [ LedgerError . NoErrors ] )
257
- const data = processResponse ( response )
258
+ const data = processResponse ( response , this . CUSTOM_APP_ERROR_DESCRIPTION )
258
259
return processGetKeysResponse ( data , keyType )
259
260
}
260
261
@@ -266,7 +267,7 @@ export default class IronfishApp extends GenericApp {
266
267
await this . sendGenericChunk ( this . INS . DKG_RESTORE_KEYS , P2_VALUES . DEFAULT , 1 + i , chunks . length , chunks [ i ] )
267
268
}
268
269
} catch ( e ) {
269
- throw processErrorResponse ( e )
270
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
270
271
}
271
272
}
272
273
@@ -283,7 +284,7 @@ export default class IronfishApp extends GenericApp {
283
284
let result = await this . getResult ( rawResponse )
284
285
return deserializeReviewTx ( result )
285
286
} catch ( e ) {
286
- throw processErrorResponse ( e )
287
+ throw processErrorResponse ( e , this . CUSTOM_APP_ERROR_DESCRIPTION )
287
288
}
288
289
}
289
290
@@ -293,7 +294,7 @@ export default class IronfishApp extends GenericApp {
293
294
let chunks = rawResponse . readBytes ( 1 ) . readUint8 ( )
294
295
for ( let i = 0 ; i < chunks ; i ++ ) {
295
296
let result = await this . transport . send ( this . CLA , this . INS . GET_RESULT , i , 0 , Buffer . alloc ( 0 ) )
296
- let response = processResponse ( result )
297
+ let response = processResponse ( result , this . CUSTOM_APP_ERROR_DESCRIPTION )
297
298
data = Buffer . concat ( [ data , response . getCompleteBuffer ( ) ] )
298
299
}
299
300
0 commit comments