From fb3fb161c060b2bc5e3b8eab0a24c72f399cde97 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 6 Jul 2022 23:11:56 +0200 Subject: [PATCH] chore: make ethers-solc optional (#1463) * chore: make ethers-solc optional * chore: update CHANGELOG * add missing requirement * add abigen req --- CHANGELOG.md | 2 ++ Cargo.toml | 19 +++++++++++++------ scripts/examples.sh | 2 +- src/lib.rs | 2 ++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77a1009a..092dfb3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,6 +104,8 @@ ### Unreleased +- Make `ethers-solc` optional dependency of `ethers`, needs `ethers-solc` feature to activate + [#1463](https://github.com/gakonst/ethers-rs/pull/1463) - Add `rawMetadata:String` field to configurable contract output [#1365](https://github.com/gakonst/ethers-rs/pull/1365) - Use relative source paths and `solc --base-path` diff --git a/Cargo.toml b/Cargo.toml index 258c75bc..fa3a71eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,10 +76,9 @@ abigen = ["ethers-contract/abigen"] ### abigen without reqwest abigen-offline = ["ethers-contract/abigen-offline"] ## solc -solc-async = ["ethers-solc/async"] -solc-full = ["ethers-solc/full"] -solc-tests = ["ethers-solc/tests"] -solc-sha2-asm = ["ethers-solc/asm"] +solc-full = ["ethers-solc", "ethers-solc/full"] +solc-tests = ["ethers-solc", "ethers-solc/tests"] +solc-sha2-asm = ["ethers-solc", "ethers-solc/asm"] [dependencies] ethers-addressbook = { version = "^0.13.0", default-features = false, path = "./ethers-addressbook" } @@ -88,7 +87,7 @@ ethers-core = { version = "^0.13.0", default-features = false, path = "./ethers- ethers-providers = { version = "^0.13.0", default-features = false, path = "./ethers-providers" } ethers-signers = { version = "^0.13.0", default-features = false, path = "./ethers-signers" } ethers-middleware = { version = "^0.13.0", default-features = false, path = "./ethers-middleware" } -ethers-solc = { version = "^0.13.0", default-features = false, path = "./ethers-solc" } +ethers-solc = { version = "^0.13.0", default-features = false, path = "./ethers-solc", optional = true } ethers-etherscan = { version = "^0.13.0", default-features = false, path = "./ethers-etherscan" } [dev-dependencies] @@ -112,17 +111,25 @@ bytes = "1.1.0" opt-level = "s" +[[example]] +name = "abigen" +path = "examples/abigen.rs" +required-features = ["ethers-solc"] + [[example]] name = "contract_human_readable" path = "examples/contract_human_readable.rs" +required-features = ["ethers-solc"] [[example]] name = "contract_with_abi" path = "examples/contract_with_abi.rs" +required-features = ["ethers-solc"] [[example]] name = "contract_with_abi_and_bytecode" path = "examples/contract_with_abi_and_bytecode.rs" +required-features = ["ethers-solc"] [[example]] name = "ipc" @@ -137,7 +144,7 @@ required-features = ["ledger"] [[example]] name = "moonbeam_with_abi" path = "examples/moonbeam_with_abi.rs" -required-features = ["legacy"] +required-features = ["legacy", "ethers-solc"] [[example]] name = "trezor" diff --git a/scripts/examples.sh b/scripts/examples.sh index c9ff12ff..3092ed87 100755 --- a/scripts/examples.sh +++ b/scripts/examples.sh @@ -20,5 +20,5 @@ for file in examples/*.rs; do continue fi echo "running: $file" - cargo r -p ethers --example "$(basename "$name")" + cargo r -p ethers --example "$(basename "$name")" --features "ethers-solc" done diff --git a/src/lib.rs b/src/lib.rs index eaf276ca..ce0e9515 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -114,6 +114,7 @@ pub mod signers { pub use ethers_signers::*; } +#[cfg(feature = "ethers-solc")] #[doc = include_str!("../assets/SOLC_README.md")] pub mod solc { pub use ethers_solc::*; @@ -141,6 +142,7 @@ pub mod prelude { pub use super::signers::*; + #[cfg(feature = "ethers-solc")] pub use super::solc::*; pub use super::etherscan::*;