Feature request: Expand event filters to support multiple events #287
Replies: 3 comments 1 reply
-
What about a separate function, like Design-wise, I'm not sure what the viem team prefers. |
Beta Was this translation helpful? Give feedback.
-
+1 on this |
Beta Was this translation helpful? Give feedback.
-
Do we have any updates on this? Is it possible to get more complex filtering using viem? For example, in ethers, we can do something like the code below using event filters.
How can we achieve the same thing using viem? |
Beta Was this translation helpful? Give feedback.
-
Today, the event filter methods (
watchEvent
,createEventFilter
,getFilterLogs
,getLogs
) support only one kind of topic set: one event signature, (optional) indexed argument values.There is another potentially useful kind of event filter - one that specifies many event signatures and no indexed argument values. For example, this could be used to filter for every ERC20
Transfer
andApproval
event on the network, regardless of contract address. The topic set sent to the RPC provider in this case looks like[ [TransferSigHash, ApprovalSigHash] ]
.I can think of two ways Viem could add support for this:
topics
option to every public client method that builds an event filter.topics
would be mutually exclusive with the currentevent
/args
options.(pseudotype)
events
option to explicitly support the multiple events, no arguments pattern.I think it would be reasonable to also add these options to the Contract Instance event filter methods (
createContractEventFilter
,watchContractEvent
).cc @holic
Beta Was this translation helpful? Give feedback.
All reactions