Skip to content

Commit 3665ff5

Browse files
fix: Use the unused skip_extra_derives bind argument (#10099)
Co-authored-by: Yash Atreya <[email protected]>
1 parent a1bb657 commit 3665ff5

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

crates/forge/src/cmd/bind.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl BindArgs {
206206
/// Check that the existing bindings match the expected abigen output
207207
fn check_existing_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> {
208208
let mut bindings = self.get_solmacrogen(artifacts)?;
209-
bindings.generate_bindings()?;
209+
bindings.generate_bindings(!self.skip_extra_derives)?;
210210
sh_println!("Checking bindings for {} contracts", bindings.instances.len())?;
211211
bindings.check_consistency(
212212
&self.crate_name,
@@ -236,10 +236,15 @@ impl BindArgs {
236236
self.single_file,
237237
self.alloy_version.clone(),
238238
self.alloy_rev.clone(),
239+
!self.skip_extra_derives,
239240
)?;
240241
} else {
241242
trace!(single_file = self.single_file, "generating module");
242-
solmacrogen.write_to_module(bindings_root, self.single_file)?;
243+
solmacrogen.write_to_module(
244+
bindings_root,
245+
self.single_file,
246+
!self.skip_extra_derives,
247+
)?;
243248
}
244249

245250
Ok(())

crates/sol-macro-gen/src/sol_macro_gen.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ impl MultiSolMacroGen {
6767
Ok(())
6868
}
6969

70-
pub fn generate_bindings(&mut self) -> Result<()> {
70+
pub fn generate_bindings(&mut self, all_derives: bool) -> Result<()> {
7171
for instance in &mut self.instances {
72-
Self::generate_binding(instance).wrap_err_with(|| {
72+
Self::generate_binding(instance, all_derives).wrap_err_with(|| {
7373
format!(
7474
"failed to generate bindings for {}:{}",
7575
instance.path.display(),
@@ -81,15 +81,15 @@ impl MultiSolMacroGen {
8181
Ok(())
8282
}
8383

84-
fn generate_binding(instance: &mut SolMacroGen) -> Result<()> {
84+
fn generate_binding(instance: &mut SolMacroGen, all_derives: bool) -> Result<()> {
8585
let input = instance.get_sol_input()?.normalize_json()?;
8686

8787
let SolInput { attrs: _, path: _, kind } = input;
8888

8989
let tokens = match kind {
9090
SolInputKind::Sol(mut file) => {
9191
let sol_attr: syn::Attribute = syn::parse_quote! {
92-
#[sol(rpc, alloy_sol_types = alloy::sol_types, alloy_contract = alloy::contract)]
92+
#[sol(rpc, alloy_sol_types = alloy::sol_types, alloy_contract = alloy::contract, all_derives = #all_derives)]
9393
};
9494
file.attrs.push(sol_attr);
9595
expand(file).wrap_err("failed to expand")?
@@ -101,6 +101,7 @@ impl MultiSolMacroGen {
101101
Ok(())
102102
}
103103

104+
#[allow(clippy::too_many_arguments)]
104105
pub fn write_to_crate(
105106
&mut self,
106107
name: &str,
@@ -109,8 +110,9 @@ impl MultiSolMacroGen {
109110
single_file: bool,
110111
alloy_version: Option<String>,
111112
alloy_rev: Option<String>,
113+
all_derives: bool,
112114
) -> Result<()> {
113-
self.generate_bindings()?;
115+
self.generate_bindings(all_derives)?;
114116

115117
let src = bindings_path.join("src");
116118

@@ -172,8 +174,13 @@ edition = "2021"
172174
Ok(())
173175
}
174176

175-
pub fn write_to_module(&mut self, bindings_path: &Path, single_file: bool) -> Result<()> {
176-
self.generate_bindings()?;
177+
pub fn write_to_module(
178+
&mut self,
179+
bindings_path: &Path,
180+
single_file: bool,
181+
all_derives: bool,
182+
) -> Result<()> {
183+
self.generate_bindings(all_derives)?;
177184

178185
let _ = fs::create_dir_all(bindings_path);
179186

0 commit comments

Comments
 (0)