Skip to content

watchEvent not scoping as expected #4040

@raster21

Description

@raster21

Check existing issues

Viem Version

2.37.3

Current Behavior

onLogs is being fired on logs that are not within scope

Expected Behavior

onLogs should only be fired when logs match the event and address passed as arguments

Steps To Reproduce

const client = createPublicClient({
    chain: mainnet,
    transport: webSocket('wss://mainnet.infura.io/ws/v3/<API_KEY>')
  })
publicClient.watchEvent({
  address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
  event: parseAbiItem('event Transfer(address indexed from, address indexed to, uint256 value)'), 
  onLogs: logs => console.log(logs),
  strict: true
})

Example of log being incorrectly returned:

.
.
.
[
  {
    address: '0x1659bae57a43ba618646448beb7dcf970331657b',
    blockHash: '0x030985b8049ac0c6345a888986876ad7d2d3f1740fabaffb7e5c5756ed5d63b7',
    blockNumber: 23496757n,
    blockTimestamp: '0x68dfa9f7',
    data: '0x0000000000000000000000000000000000000000000000000f7aa7341d570800000000000000000000000000000000000000000359c382e0b66b6de27680e95c',
    logIndex: 1086,
    removed: false,
    topics: [
      '0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1'
    ],
    transactionHash: '0x44edd09b3dfd6439cbefb833a500d72d8732307321f6b616c2fa5a549c974677',
    transactionIndex: 155
  }
]

Link to Minimal Reproducible Example

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions