fix filtering event

pull/5370/head
yann300 1 year ago committed by Aniket
parent 2423e19c1a
commit 7657a5c6ee
  1. 12
      libs/remix-lib/src/execution/logsManager.ts
  2. 2
      libs/remix-simulator/src/VmProxy.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
}

@ -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

Loading…
Cancel
Save