Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions ledger-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
Expand Down