From 7c98210ba9a1d036bb6b0fa65e8beed1b4c71b1e Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 4 Jan 2023 15:17:36 -0800 Subject: [PATCH] fix token id bug --- src/scraper.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/scraper.js b/src/scraper.js index 40e6c55..f412f5a 100644 --- a/src/scraper.js +++ b/src/scraper.js @@ -188,21 +188,25 @@ class Scrape extends Collection { logDescription.args.consideration.map((o) => { if (Number(o.amount) > 0) amountWei += Number(o.amount); }); + receipt.logs.filter( + l => l.logIndex === log.logIndex + 2 && l.topics[0].toLowerCase() === TRANSFER_TOPIC + ).map((t) => { + tokenId = BigInt(t.topics[3]); + }); } else if (logDescription.args.offer[0].token.toLowerCase() == WETH_ADDRESS.toLowerCase()) { // seller has accepted buyer bid sale = true; toAddress = logDescription.args.offerer.toLowerCase(); fromAddress = logDescription.args.recipient.toLowerCase(); amountWei = BigNumber.from(logDescription.args.offer[0].amount).toString(); + receipt.logs.filter( + l => l.logIndex === log.logIndex - 3 && l.topics[0].toLowerCase() === TRANSFER_TOPIC && l.address.toLowerCase() === this.contractAddress.toLowerCase() + ).map((t) => { + tokenId = BigInt(t.topics[3]); + }); } else { // unknown condition } - let rl = receipt.logs.filter( - l => l.logIndex === log.logIndex + 2 && l.topics[0].toLowerCase() === TRANSFER_TOPIC - ); - if (rl.length > 0) { - tokenId = BigInt(rl[0].topics[3]); - } } else if (log.topics[0].toLowerCase() === WYVERN_SALE_TOPIC.toLowerCase()) { // Handle Opensea/Wyvern sales let txEventType = TRANSFER_TOPIC.toLowerCase();