From ca138bdefe7858d3408c5a9483b124095ecb967c Mon Sep 17 00:00:00 2001 From: franco-gondi Date: Thu, 7 Aug 2025 11:51:45 -0300 Subject: [PATCH] fix: eth app not supported on old models or eth app version --- ledger-bridge.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ledger-bridge.js b/ledger-bridge.js index 01e4167..285be8f 100644 --- a/ledger-bridge.js +++ b/ledger-bridge.js @@ -2,6 +2,7 @@ import TransportWebUSB from '@ledgerhq/hw-transport-webusb'; import TransportWebHID from '@ledgerhq/hw-transport-webhid'; import LedgerEth from '@ledgerhq/hw-app-eth'; import WebSocketTransport from '@ledgerhq/hw-transport-http/lib/WebSocketTransport'; +import { EthAppNftNotSupported } from "@ledgerhq/hw-app-eth/lib/errors"; import { SignTypedDataVersion, TypedDataUtils } from '@metamask/eth-sig-util'; import { TransportStatusError } from '@ledgerhq/errors'; @@ -245,11 +246,27 @@ export default class LedgerBridge { async signTransaction(replyAction, hdPath, tx, messageId) { try { await this.makeApp(); - const res = await this.app.clearSignTransaction(hdPath, tx, { + const resolutionConfig = { nft: true, externalPlugins: true, erc20: true, - }); + }; + let res; + try { + res = await this.app.clearSignTransaction(hdPath, tx, resolutionConfig) + } catch(error) { + if (error instanceof EthAppNftNotSupported) { + console.log( + "NFT clear signing not supported => fallback to blind signing" + ); + res = await this.app.clearSignTransaction(hdPath, tx, { + ...resolutionConfig, + nft: false, + }); + } else { + throw error; + } + } this.sendMessageToExtension({ action: replyAction, success: true,