Skip to content

Commit 61a8e6f

Browse files
authored
feat: EventFilter Should Accept Multiple Event Signatures (#100)
1 parent 0f3869f commit 61a8e6f

File tree

9 files changed

+446
-147
lines changed

9 files changed

+446
-147
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,25 @@ Once configured, connect using either `connect_ws::<Ethereum>(ws_url)` or `conne
104104

105105
### Defining Event Filters
106106

107-
Create an `EventFilter` for each contract/event pair you want to track. The filter specifies the contract address where events originated, and the event signature (from `SolEvent::SIGNATURE`).
108-
109-
Both `contract_address` and `event` fields are optional, allowing for flexible event tracking.
107+
Create an `EventFilter` for each event stream you wish to process. The filter specifies the contract address where events originated, and event signatures (tip: you can use the value stored in `SolEvent::SIGNATURE`).
110108

111109
```rust
112-
// Track a specific event from a specific contract
110+
// Track a SPECIFIC event from a SPECIFIC contract
113111
let specific_filter = EventFilter::new()
114112
.with_contract_address(*counter_contract.address())
115113
.with_event(Counter::CountIncreased::SIGNATURE);
116114

117-
// Track ALL events from a specific contract
115+
// Track a multiple events from a SPECIFIC contract
116+
let specific_filter = EventFilter::new()
117+
.with_contract_address(*counter_contract.address())
118+
.with_event(Counter::CountIncreased::SIGNATURE)
119+
.with_event(Counter::CountDecreased::SIGNATURE);
120+
121+
// Track a SPECIFIC event from a ALL contracts
122+
let specific_filter = EventFilter::new()
123+
.with_event(Counter::CountIncreased::SIGNATURE);
124+
125+
// Track ALL events from a SPECIFIC contract
118126
let all_contract_events_filter = EventFilter::new()
119127
.with_contract_address(*counter_contract.address());
120128

@@ -124,14 +132,7 @@ let all_events_filter = EventFilter::new();
124132

125133
Register multiple filters by invoking `create_event_stream` repeatedly.
126134

127-
Event filters enable several powerful use cases:
128-
129-
- **Track all events from a specific contract**: Set `contract_address` but leave `event` as `None`
130-
- **Track all events across all contracts**: Set both `contract_address` and `event` as `None`
131-
- **Track specific events from specific contracts**: Set both fields (traditional usage)
132-
- **Mixed filtering**: Use multiple filters with different optional field combinations
133-
134-
This flexibility allows you to build sophisticated event monitoring systems that can track events at different granularities depending on your application's needs.
135+
The flexibility provided by `EventFilter` allows you to build sophisticated event monitoring systems that can track events at different granularities depending on your application's needs.
135136

136137
### Scanning Modes
137138

0 commit comments

Comments
 (0)