From f97a8ca5410331145cb742d40ebfe4a816dd3190 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Wed, 16 Feb 2022 17:46:25 +0200 Subject: [PATCH] fix(abigen): do not panic when run on non-cargo projects (#918) * fix(abigen): do not panic when run on non-cargo projects * chore: bump solidity test to 0.8.12 --- ethers-core/src/macros/ethers_crate.rs | 9 ++++++++- ethers-solc/src/compile/mod.rs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ethers-core/src/macros/ethers_crate.rs b/ethers-core/src/macros/ethers_crate.rs index 19ee9c14..72b125ea 100644 --- a/ethers-core/src/macros/ethers_crate.rs +++ b/ethers-core/src/macros/ethers_crate.rs @@ -43,7 +43,14 @@ pub fn ethers_providers_crate() -> Path { /// `cargo metadata` if a `Cargo.lock` file exists and delete it afterwards if /// it was created by `cargo metadata`. pub fn determine_ethers_crates() -> (&'static str, &'static str, &'static str) { - let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("No Manifest found"); + let manifest_dir = std::env::var("CARGO_MANIFEST_DIR"); + + // if there is no cargo manifest, default to `ethers::`-style imports. + let manifest_dir = if let Ok(manifest_dir) = manifest_dir { + manifest_dir + } else { + return ("ethers::core", "ethers::contract", "ethers::providers") + }; // check if the lock file exists, if it's missing we need to clean up afterward let lock_file = format!("{}/Cargo.lock", manifest_dir); diff --git a/ethers-solc/src/compile/mod.rs b/ethers-solc/src/compile/mod.rs index 0fb12ee8..11fd3ad0 100644 --- a/ethers-solc/src/compile/mod.rs +++ b/ethers-solc/src/compile/mod.rs @@ -728,7 +728,7 @@ mod tests { // update this test whenever there's a new sol // version. that's ok! good reminder to check the // patch notes. - (">=0.5.0", "0.8.11"), + (">=0.5.0", "0.8.12"), // range (">=0.4.0 <0.5.0", "0.4.26"), ]