Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Fix: use cwd manifest #1869

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ethers-contract/ethers-contract-abigen/src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,15 @@ impl MultiBindingsInner {

/// parses the active Cargo.toml to get what version of ethers we are using
fn find_crate_version(&self) -> Result<String> {
let cargo_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.toml");
let cargo_dir = std::env::current_dir()?.join("Cargo.toml");
let data = std::fs::read_to_string(cargo_dir)?;
let toml = data.parse::<Value>()?;

let Some(ethers) = toml.get("dependencies")
.and_then (|v| v.get("ethers").or_else(|| v.get("ethers-contract")))
else { eyre::bail!("couldn't find ethers or ethers-contract dependency")};
let ethers = toml
.get("dependencies")
.and_then(|v| v.get("ethers").or_else(|| v.get("ethers-contract")))
.ok_or_else(|| eyre::eyre!("couldn't find ethers or ethers-contract dependency"))?;

if let Some(rev) = ethers.get("rev") {
Ok(format!("ethers = {{ git = \"https://github.com/gakonst/ethers-rs\", rev = {}, default-features = false, features = [\"abigen\"] }}", rev))
} else if let Some(version) = ethers.get("version") {
Expand Down