From 7657a5c6ee3fab275662c89d22f445744518a84b Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 25 Sep 2023 23:37:15 +0200 Subject: [PATCH] fix filtering event --- libs/remix-lib/src/execution/logsManager.ts | 12 +++++++----- libs/remix-simulator/src/VmProxy.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/remix-lib/src/execution/logsManager.ts b/libs/remix-lib/src/execution/logsManager.ts index 70e4ed9d41..ad623c39db 100644 --- a/libs/remix-lib/src/execution/logsManager.ts +++ b/libs/remix-lib/src/execution/logsManager.ts @@ -1,5 +1,6 @@ import { eachOf } from 'async' import { randomBytes } from 'crypto' +import { toChecksumAddress } from '@ethereumjs/util' export class LogsManager { notificationCallbacks @@ -22,8 +23,8 @@ export class LogsManager { web3.eth.getTransactionReceipt(txHash, (_error, receipt) => { for (const log of receipt.logs) { - this.oldLogs.push({ type: 'block', blockNumber, block, tx, log, txNumber: i }) - const subscriptions = this.getSubscriptionsFor({ type: 'block', blockNumber, block, tx, log }) + this.oldLogs.push({ type: 'block', blockNumber, block, tx, log, txNumber: i, receipt }) + const subscriptions = this.getSubscriptionsFor({ type: 'block', blockNumber, block, tx, log, receipt}) for (const subscriptionId of subscriptions) { const result = { @@ -57,13 +58,14 @@ export class LogsManager { if (queryType === 'logs') { const fromBlock = queryFilter.fromBlock || '0x0' const toBlock = queryFilter.toBlock || this.oldLogs.length ? this.oldLogs[this.oldLogs.length - 1].blockNumber : '0x0' - if ((queryFilter.address === (changeEvent.tx.to || '').toString()) || queryFilter.address === (changeEvent.tx.getSenderAddress().toString())) { - if ((parseInt(toBlock) >= parseInt(changeEvent.blockNumber)) && (parseInt(fromBlock) <= parseInt(changeEvent.blockNumber))) { + const targetAddress = toChecksumAddress(queryFilter.address) + if ((parseInt(toBlock) >= parseInt(changeEvent.blockNumber)) && (parseInt(fromBlock) <= parseInt(changeEvent.blockNumber))) { + if (changeEvent.log && changeEvent.log.address === targetAddress) { return true } } + return false } - return false } diff --git a/libs/remix-simulator/src/VmProxy.ts b/libs/remix-simulator/src/VmProxy.ts index a0005f8fa2..90d7ebfbf7 100644 --- a/libs/remix-simulator/src/VmProxy.ts +++ b/libs/remix-simulator/src/VmProxy.ts @@ -182,7 +182,7 @@ export class VmProxy { topics.push('0x') } logs.push({ - address: '0x' + log[0].toString('hex'), + address: toChecksumAddress('0x' + log[0].toString('hex')), data: '0x' + log[2].toString('hex'), topics: topics, rawVMResponse: log