diff --git a/ethers-core/src/types/filter.rs b/ethers-core/src/types/filter.rs index 077b6045..04f750da 100644 --- a/ethers-core/src/types/filter.rs +++ b/ethers-core/src/types/filter.rs @@ -254,13 +254,21 @@ impl Filter { self } - /// given the event in string form, it hashes it and adds it to the topics to monitor + /// Given the event signature in string form, it hashes it and adds it to the topics to monitor #[must_use] pub fn event(self, event_name: &str) -> Self { let hash = H256::from(keccak256(event_name.as_bytes())); self.topic0(hash) } + /// Hashes all event signatures and sets them as array to topic0 + #[must_use] + pub fn events(self, events: impl IntoIterator>) -> Self { + let events = + events.into_iter().map(|e| H256::from(keccak256(e.as_ref()))).collect::>(); + self.topic0(events) + } + /// Sets topic0 (the event name for non-anonymous events) #[must_use] pub fn topic0>(mut self, topic: T) -> Self { @@ -544,6 +552,12 @@ impl From for Topic { } } +impl From> for ValueOrArray { + fn from(src: Vec) -> Self { + ValueOrArray::Array(src) + } +} + impl From> for Topic { fn from(src: ValueOrArray) -> Self { match src {