|
1 | 1 | // Adapted from https://github.com/tomusdrw/rust-web3/blob/master/src/types/log.rs
|
2 | 2 | use crate::{
|
3 |
| - types::{Address, BlockNumber, Bytes, H256, U256, U64}, |
| 3 | + types::{Address, BlockNumber, Bytes, H160, H256, U256, U64}, |
4 | 4 | utils::keccak256,
|
5 | 5 | };
|
6 | 6 | use serde::{
|
@@ -306,7 +306,31 @@ impl Filter {
|
306 | 306 | self.block_option = self.block_option.set_hash(hash.into());
|
307 | 307 | self
|
308 | 308 | }
|
309 |
| - |
| 309 | + /// Sets the inner filter object |
| 310 | + /// |
| 311 | + /// *NOTE:* ranges are always inclusive |
| 312 | + /// |
| 313 | + /// # Examples |
| 314 | + /// |
| 315 | + /// Match only a specific address `("0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF")` |
| 316 | + /// |
| 317 | + /// ```rust |
| 318 | + /// # use ethers_core::types::{Filter, Address}; |
| 319 | + /// # fn main() { |
| 320 | + /// let filter = Filter::new().address("0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::<Address>().unwrap()); |
| 321 | + /// # } |
| 322 | + /// ``` |
| 323 | + /// |
| 324 | + /// Match all addresses in array `(vec!["0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF", |
| 325 | + /// "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8"])` |
| 326 | + /// |
| 327 | + /// ```rust |
| 328 | + /// # use ethers_core::types::{Filter, Address, ValueOrArray}; |
| 329 | + /// # fn main() { |
| 330 | + /// let addresses = vec!["0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::<Address>().unwrap(),"0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8".parse::<Address>().unwrap()]; |
| 331 | + /// let filter = Filter::new().address(addresses); |
| 332 | + /// # } |
| 333 | + /// ``` |
310 | 334 | #[must_use]
|
311 | 335 | pub fn address<T: Into<ValueOrArray<Address>>>(mut self, address: T) -> Self {
|
312 | 336 | self.address = Some(address.into());
|
@@ -360,6 +384,18 @@ pub enum ValueOrArray<T> {
|
360 | 384 |
|
361 | 385 | // TODO: Implement more common types - or adjust this to work with all Tokenizable items
|
362 | 386 |
|
| 387 | +impl From<H160> for ValueOrArray<H160> { |
| 388 | + fn from(src: H160) -> Self { |
| 389 | + ValueOrArray::Value(src) |
| 390 | + } |
| 391 | +} |
| 392 | + |
| 393 | +impl From<Vec<H160>> for ValueOrArray<H160> { |
| 394 | + fn from(src: Vec<H160>) -> Self { |
| 395 | + ValueOrArray::Array(src) |
| 396 | + } |
| 397 | +} |
| 398 | + |
363 | 399 | impl From<H256> for ValueOrArray<H256> {
|
364 | 400 | fn from(src: H256) -> Self {
|
365 | 401 | ValueOrArray::Value(src)
|
|
0 commit comments