diff --git a/CHANGELOG.md b/CHANGELOG.md index 13570658..5def5468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Unreleased -- Fix RLP decoding of `from` field for `Eip1559TransactionRequest` and +- Fix RLP decoding of `from` field for `Eip1559TransactionRequest` and `Eip2930TransactionRequest`, remove `Eip1559TransactionRequest` `sighash` method [1180](https://github.com/gakonst/ethers-rs/pull/1180) - Fix RLP encoding of absent access list in `Transaction` [1137](https://github.com/gakonst/ethers-rs/pull/1137) @@ -62,6 +62,7 @@ [#996](https://github.com/gakonst/ethers-rs/pull/996) - Add `TransactionReceipt::to` and `TransactionReceipt::from` [#1184](https://github.com/gakonst/ethers-rs/pull/1184) +- Add `From` and From> traits to `ValueOrArray` [#1199](https://github.com/gakonst/ethers-rs/pull/1200) ## ethers-contract-abigen diff --git a/ethers-core/src/types/log.rs b/ethers-core/src/types/log.rs index 3815f158..89758434 100644 --- a/ethers-core/src/types/log.rs +++ b/ethers-core/src/types/log.rs @@ -1,6 +1,6 @@ // Adapted from https://github.com/tomusdrw/rust-web3/blob/master/src/types/log.rs use crate::{ - types::{Address, BlockNumber, Bytes, H256, U256, U64}, + types::{Address, BlockNumber, Bytes, H160, H256, U256, U64}, utils::keccak256, }; use serde::{ @@ -306,7 +306,31 @@ impl Filter { self.block_option = self.block_option.set_hash(hash.into()); self } - + /// Sets the inner filter object + /// + /// *NOTE:* ranges are always inclusive + /// + /// # Examples + /// + /// Match only a specific address `("0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF")` + /// + /// ```rust + /// # use ethers_core::types::{Filter, Address}; + /// # fn main() { + /// let filter = Filter::new().address("0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::
().unwrap()); + /// # } + /// ``` + /// + /// Match all addresses in array `(vec!["0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF", + /// "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8"])` + /// + /// ```rust + /// # use ethers_core::types::{Filter, Address, ValueOrArray}; + /// # fn main() { + /// let addresses = vec!["0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::
().unwrap(),"0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8".parse::
().unwrap()]; + /// let filter = Filter::new().address(addresses); + /// # } + /// ``` #[must_use] pub fn address>>(mut self, address: T) -> Self { self.address = Some(address.into()); @@ -360,6 +384,18 @@ pub enum ValueOrArray { // TODO: Implement more common types - or adjust this to work with all Tokenizable items +impl From for ValueOrArray { + fn from(src: H160) -> Self { + ValueOrArray::Value(src) + } +} + +impl From> for ValueOrArray { + fn from(src: Vec) -> Self { + ValueOrArray::Array(src) + } +} + impl From for ValueOrArray { fn from(src: H256) -> Self { ValueOrArray::Value(src)