From 77bc08de9a4177fb68901cd41f1944c7cb96655b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:46:38 +0100 Subject: [PATCH] feats --- ethers-middleware/tests/it/gas_oracle.rs | 15 ++++++++------- ethers/Cargo.toml | 14 +++++++++----- ethers/src/lib.rs | 16 ++++++++++------ examples/middleware/Cargo.toml | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ethers-middleware/tests/it/gas_oracle.rs b/ethers-middleware/tests/it/gas_oracle.rs index 5abb5ca9ca..b810d1f401 100644 --- a/ethers-middleware/tests/it/gas_oracle.rs +++ b/ethers-middleware/tests/it/gas_oracle.rs @@ -1,12 +1,8 @@ use async_trait::async_trait; -use ethers_core::{ - types::*, - utils::{parse_ether, Anvil}, -}; -use ethers_etherscan::Client; +use ethers_core::{types::*, utils::Anvil}; use ethers_middleware::gas_oracle::{ - BlockNative, Etherchain, Etherscan, GasCategory, GasNow, GasOracle, GasOracleError, - GasOracleMiddleware, Polygon, ProviderOracle, Result, + BlockNative, Etherchain, GasNow, GasOracle, GasOracleError, GasOracleMiddleware, Polygon, + ProviderOracle, Result, }; use ethers_providers::{Http, Middleware, Provider}; @@ -89,8 +85,13 @@ async fn etherchain() { assert!(gas_price > U256::zero()); } +#[cfg(feature = "etherscan")] #[tokio::test] async fn etherscan() { + use ethers_core::utils::parse_ether; + use ethers_etherscan::Client; + use ethers_middleware::gas_oracle::{Etherscan, GasCategory}; + let chain = Chain::Mainnet; let etherscan_client = Client::new_from_opt_env(chain).unwrap(); diff --git a/ethers/Cargo.toml b/ethers/Cargo.toml index 54e23980da..00b91f1c17 100644 --- a/ethers/Cargo.toml +++ b/ethers/Cargo.toml @@ -23,7 +23,7 @@ rustdoc-args = ["--cfg", "docsrs"] all-features = true [features] -default = ["abigen", "rustls"] +default = ["abigen", "rustls", "etherscan"] # workspace-wide features legacy = ["ethers-core/legacy", "ethers-contract/legacy"] @@ -46,14 +46,14 @@ optimism = [ rustls = [ "ethers-contract/rustls", - "ethers-etherscan/rustls", + "ethers-etherscan?/rustls", "ethers-middleware/rustls", "ethers-providers/rustls", "ethers-solc?/rustls", ] openssl = [ "ethers-contract/openssl", - "ethers-etherscan/openssl", + "ethers-etherscan?/openssl", "ethers-middleware/openssl", "ethers-providers/openssl", "ethers-solc?/openssl", @@ -75,23 +75,27 @@ yubi = ["ethers-signers/yubi"] abigen = ["ethers-contract/abigen"] abigen-online = ["ethers-contract/abigen-online"] +# ethers-etherscan +etherscan = ["dep:ethers-etherscan", "ethers-middleware/etherscan"] + # ethers-solc -ethers-solc = ["dep:ethers-solc", "ethers-etherscan/ethers-solc"] +solc = ["dep:ethers-solc", "ethers-etherscan/ethers-solc"] solc-full = ["ethers-solc?/full"] solc-tests = ["ethers-solc?/tests"] # Deprecated abigen-offline = ["abigen"] eip712 = [] +ethers-solc = ["solc"] solc-sha2-asm = [] [dependencies] ethers-addressbook.workspace = true ethers-contract = { workspace = true, features = ["providers"] } ethers-core.workspace = true -ethers-etherscan.workspace = true ethers-middleware.workspace = true ethers-providers.workspace = true ethers-signers.workspace = true +ethers-etherscan = { workspace = true, optional = true } ethers-solc = { workspace = true, optional = true } diff --git a/ethers/src/lib.rs b/ethers/src/lib.rs index 2bda5b85c1..9d14f714c9 100644 --- a/ethers/src/lib.rs +++ b/ethers/src/lib.rs @@ -96,14 +96,17 @@ pub use ethers_contract as contract; #[doc(inline)] pub use ethers_core as core; #[doc(inline)] -pub use ethers_etherscan as etherscan; -#[doc(inline)] pub use ethers_middleware as middleware; #[doc(inline)] pub use ethers_providers as providers; #[doc(inline)] pub use ethers_signers as signers; -#[cfg(feature = "ethers-solc")] + +#[cfg(feature = "etherscan")] +#[doc(inline)] +pub use ethers_etherscan as etherscan; + +#[cfg(feature = "solc")] #[doc(inline)] pub use ethers_solc as solc; @@ -120,15 +123,16 @@ pub mod prelude { pub use super::core::{types::*, *}; - pub use super::etherscan::*; - pub use super::middleware::*; pub use super::providers::*; pub use super::signers::*; - #[cfg(feature = "ethers-solc")] + #[cfg(feature = "etherscan")] + pub use super::etherscan::*; + + #[cfg(feature = "solc")] pub use super::solc::*; } diff --git a/examples/middleware/Cargo.toml b/examples/middleware/Cargo.toml index 6ca79c6444..5faeb2391e 100644 --- a/examples/middleware/Cargo.toml +++ b/examples/middleware/Cargo.toml @@ -9,7 +9,7 @@ rust-version.workspace = true edition.workspace = true [dev-dependencies] -ethers = { workspace = true, features = ["rustls"] } +ethers = { workspace = true, features = ["rustls", "etherscan"] } serde.workspace = true serde_json.workspace = true tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }