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

Commit

Permalink
feat(ethers-contract-abigen): opt out of checking cargo.toml for cons…
Browse files Browse the repository at this point in the history
…istency (#1301)
  • Loading branch information
meetmangukiya authored May 23, 2022
1 parent 0656ffc commit 2f34fc9
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions ethers-contract/ethers-contract-abigen/src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl MultiBindings {
/// let gen = MultiAbigen::from_json_files(&abi_dir).unwrap();
/// let bindings = gen.build().unwrap();
/// bindings.ensure_consistent_crate(
/// "my-crate", "0.0.1", project_root.join("src/contracts"), false
/// "my-crate", "0.0.1", project_root.join("src/contracts"), false, true
/// ).expect("inconsistent bindings");
/// }
/// ```
Expand All @@ -442,8 +442,15 @@ impl MultiBindings {
version: impl AsRef<str>,
crate_path: impl AsRef<Path>,
single_file: bool,
check_cargo_toml: bool,
) -> Result<()> {
self.into_inner(single_file).ensure_consistent_crate(name, version, crate_path, single_file)
self.into_inner(single_file).ensure_consistent_crate(
name,
version,
crate_path,
single_file,
check_cargo_toml,
)
}

/// This ensures that the already generated bindings module matches the
Expand Down Expand Up @@ -668,12 +675,15 @@ serde_json = "1.0.79"
version: impl AsRef<str>,
crate_path: impl AsRef<Path>,
single_file: bool,
check_cargo_toml: bool,
) -> Result<()> {
let crate_path = crate_path.as_ref();

// additionally check the contents of the cargo
let cargo_contents = self.generate_cargo_toml(name, version)?;
check_file_in_dir(crate_path, "Cargo.toml", &cargo_contents)?;
if check_cargo_toml {
// additionally check the contents of the cargo
let cargo_contents = self.generate_cargo_toml(name, version)?;
check_file_in_dir(crate_path, "Cargo.toml", &cargo_contents)?;
}

self.ensure_consistent_bindings(crate_path.join("src"), true, single_file)?;
Ok(())
Expand Down Expand Up @@ -829,7 +839,7 @@ mod tests {
.clone()
.build()
.unwrap()
.ensure_consistent_crate(name, version, &mod_root, single_file)
.ensure_consistent_crate(name, version, &mod_root, single_file, true)
.expect("Inconsistent bindings");
})
}
Expand All @@ -853,7 +863,7 @@ mod tests {
.clone()
.build()
.unwrap()
.ensure_consistent_crate(name, version, &mod_root, single_file)
.ensure_consistent_crate(name, version, &mod_root, single_file, true)
.expect("Inconsistent bindings");
})
}
Expand Down Expand Up @@ -944,7 +954,7 @@ mod tests {
let result = cloned
.build()
.unwrap()
.ensure_consistent_crate(name, version, &mod_root, single_file)
.ensure_consistent_crate(name, version, &mod_root, single_file, true)
.is_err();

// ensure inconsistent bindings are detected
Expand Down Expand Up @@ -982,7 +992,7 @@ mod tests {
let result = cloned
.build()
.unwrap()
.ensure_consistent_crate(name, version, &mod_root, single_file)
.ensure_consistent_crate(name, version, &mod_root, single_file, true)
.is_err();

// ensure inconsistent bindings are detected
Expand Down

0 comments on commit 2f34fc9

Please sign in to comment.