From 88f138866d2fd1b70215ca186e1cc0df9300bd61 Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Thu, 27 Jun 2024 11:19:02 +0200 Subject: [PATCH] fix: catch err on parse abi --- app/scripts/metamask-controller.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index cd7f8e30984f..42815021f0ca 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -6381,7 +6381,6 @@ export default class MetamaskController extends EventEmitter { txReceiptLog.topics[0] === TRANSFER_SINFLE_LOG_TOPIC_HASH; const isERC721NftTransfer = txReceiptLog.topics && - txReceiptLog.topics.length === 2 && // Added this check because TOKEN_TRANSFER_LOG_TOPIC_HASH is the same for ERC20 and ERC721 txReceiptLog.topics[0] === TOKEN_TRANSFER_LOG_TOPIC_HASH; let isTransferToSelectedAddress; @@ -6419,14 +6418,18 @@ export default class MetamaskController extends EventEmitter { } else { iface = new Interface(abiERC721); } - const parsedLog = iface.parseLog({ - data: singleLog.data, - topics: singleLog.topics, - }); - allNftParsedLog.push({ - contract: singleLog.address, - ...parsedLog, - }); + try { + const parsedLog = iface.parseLog({ + data: singleLog.data, + topics: singleLog.topics, + }); + allNftParsedLog.push({ + contract: singleLog.address, + ...parsedLog, + }); + } catch (err) { + // ignore + } } }); // Filter known nfts and new Nfts