File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import TransportWebUSB from '@ledgerhq/hw-transport-webusb';
22import TransportWebHID from '@ledgerhq/hw-transport-webhid' ;
33import LedgerEth from '@ledgerhq/hw-app-eth' ;
44import WebSocketTransport from '@ledgerhq/hw-transport-http/lib/WebSocketTransport' ;
5+ import { EthAppNftNotSupported } from "@ledgerhq/hw-app-eth/lib/errors" ;
56import { SignTypedDataVersion , TypedDataUtils } from '@metamask/eth-sig-util' ;
67import { 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 ,
You can’t perform that action at this time.
0 commit comments