feat(ethers-contract-abigen): opt out of checking cargo.toml for consistency (#1301)
This commit is contained in:
parent
0656ffcec3
commit
2f34fc9705
|
@ -432,7 +432,7 @@ impl MultiBindings {
|
||||||
/// let gen = MultiAbigen::from_json_files(&abi_dir).unwrap();
|
/// let gen = MultiAbigen::from_json_files(&abi_dir).unwrap();
|
||||||
/// let bindings = gen.build().unwrap();
|
/// let bindings = gen.build().unwrap();
|
||||||
/// bindings.ensure_consistent_crate(
|
/// 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");
|
/// ).expect("inconsistent bindings");
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -442,8 +442,15 @@ impl MultiBindings {
|
||||||
version: impl AsRef<str>,
|
version: impl AsRef<str>,
|
||||||
crate_path: impl AsRef<Path>,
|
crate_path: impl AsRef<Path>,
|
||||||
single_file: bool,
|
single_file: bool,
|
||||||
|
check_cargo_toml: bool,
|
||||||
) -> Result<()> {
|
) -> 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
|
/// This ensures that the already generated bindings module matches the
|
||||||
|
@ -668,12 +675,15 @@ serde_json = "1.0.79"
|
||||||
version: impl AsRef<str>,
|
version: impl AsRef<str>,
|
||||||
crate_path: impl AsRef<Path>,
|
crate_path: impl AsRef<Path>,
|
||||||
single_file: bool,
|
single_file: bool,
|
||||||
|
check_cargo_toml: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let crate_path = crate_path.as_ref();
|
let crate_path = crate_path.as_ref();
|
||||||
|
|
||||||
// additionally check the contents of the cargo
|
if check_cargo_toml {
|
||||||
let cargo_contents = self.generate_cargo_toml(name, version)?;
|
// additionally check the contents of the cargo
|
||||||
check_file_in_dir(crate_path, "Cargo.toml", &cargo_contents)?;
|
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)?;
|
self.ensure_consistent_bindings(crate_path.join("src"), true, single_file)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -829,7 +839,7 @@ mod tests {
|
||||||
.clone()
|
.clone()
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.ensure_consistent_crate(name, version, &mod_root, single_file)
|
.ensure_consistent_crate(name, version, &mod_root, single_file, true)
|
||||||
.expect("Inconsistent bindings");
|
.expect("Inconsistent bindings");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -853,7 +863,7 @@ mod tests {
|
||||||
.clone()
|
.clone()
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.ensure_consistent_crate(name, version, &mod_root, single_file)
|
.ensure_consistent_crate(name, version, &mod_root, single_file, true)
|
||||||
.expect("Inconsistent bindings");
|
.expect("Inconsistent bindings");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -944,7 +954,7 @@ mod tests {
|
||||||
let result = cloned
|
let result = cloned
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.ensure_consistent_crate(name, version, &mod_root, single_file)
|
.ensure_consistent_crate(name, version, &mod_root, single_file, true)
|
||||||
.is_err();
|
.is_err();
|
||||||
|
|
||||||
// ensure inconsistent bindings are detected
|
// ensure inconsistent bindings are detected
|
||||||
|
@ -982,7 +992,7 @@ mod tests {
|
||||||
let result = cloned
|
let result = cloned
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.ensure_consistent_crate(name, version, &mod_root, single_file)
|
.ensure_consistent_crate(name, version, &mod_root, single_file, true)
|
||||||
.is_err();
|
.is_err();
|
||||||
|
|
||||||
// ensure inconsistent bindings are detected
|
// ensure inconsistent bindings are detected
|
||||||
|
|
Loading…
Reference in New Issue