Skip to content

Commit bb2b83e

Browse files
authored
Merge pull request #72 from Zondax/fix/statusList
Remove statusList from sendGenericChunk (let it default to 0x9000)
1 parent 65e429a commit bb2b83e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@
5252
"eslint-plugin-promise": "^7.1.0",
5353
"eslint-plugin-tsdoc": "^0.3.0",
5454
"eslint-plugin-unused-imports": "^4.0.0",
55+
"jest": "^30.0.5",
5556
"prettier": "^3.3.2",
5657
"sort-package-json": "^2.10.1",
57-
"ts-jest": "^29.1.4",
58+
"ts-jest": "^29.4.0",
5859
"ts-node": "^10.9.2",
5960
"typescript": "^5.4.5"
6061
},

src/app.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,19 @@ export default class BaseApp {
126126

127127
const statusList = [LedgerError.NoErrors, LedgerError.DataIsInvalid, LedgerError.BadKeyHandle]
128128

129-
const responseBuffer = await this.transport.send(this.CLA, ins, payloadType, p2, chunk, statusList)
130-
const response = processResponse(responseBuffer, this.CUSTOM_APP_ERROR_DESCRIPTION)
129+
let responseBuffer
131130

132-
return response
131+
try {
132+
responseBuffer = await this.transport.send(this.CLA, ins, payloadType, p2, chunk, statusList)
133+
} catch (e) {
134+
// In case transport.send send throws an Error, we still want our custom ResponseError
135+
let statusCode: number = (e as any).statusCode || (e as any).returnCode
136+
const buffer = Buffer.alloc(2)
137+
buffer.writeUInt16BE(statusCode, 0)
138+
return processResponse(buffer, this.CUSTOM_APP_ERROR_DESCRIPTION)
139+
}
140+
141+
return processResponse(responseBuffer, this.CUSTOM_APP_ERROR_DESCRIPTION)
133142
}
134143

135144
/**

0 commit comments

Comments
 (0)