Skip to content

Commit ca138bd

Browse files
author
franco-gondi
committed
fix: eth app not supported on old models or eth app version
1 parent f30c50e commit ca138bd

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

ledger-bridge.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import TransportWebUSB from '@ledgerhq/hw-transport-webusb';
22
import TransportWebHID from '@ledgerhq/hw-transport-webhid';
33
import LedgerEth from '@ledgerhq/hw-app-eth';
44
import WebSocketTransport from '@ledgerhq/hw-transport-http/lib/WebSocketTransport';
5+
import { EthAppNftNotSupported } from "@ledgerhq/hw-app-eth/lib/errors";
56
import { SignTypedDataVersion, TypedDataUtils } from '@metamask/eth-sig-util';
67
import { TransportStatusError } from '@ledgerhq/errors';
78

@@ -245,11 +246,27 @@ export default class LedgerBridge {
245246
async signTransaction(replyAction, hdPath, tx, messageId) {
246247
try {
247248
await this.makeApp();
248-
const res = await this.app.clearSignTransaction(hdPath, tx, {
249+
const resolutionConfig = {
249250
nft: true,
250251
externalPlugins: true,
251252
erc20: true,
252-
});
253+
};
254+
let res;
255+
try {
256+
res = await this.app.clearSignTransaction(hdPath, tx, resolutionConfig)
257+
} catch(error) {
258+
if (error instanceof EthAppNftNotSupported) {
259+
console.log(
260+
"NFT clear signing not supported => fallback to blind signing"
261+
);
262+
res = await this.app.clearSignTransaction(hdPath, tx, {
263+
...resolutionConfig,
264+
nft: false,
265+
});
266+
} else {
267+
throw error;
268+
}
269+
}
253270
this.sendMessageToExtension({
254271
action: replyAction,
255272
success: true,

0 commit comments

Comments
 (0)