Skip to content

Commit

Permalink
feat(forge-bind): add_derives for serde in contract bindings (#5836)
Browse files Browse the repository at this point in the history
* feat: `add_derives` for serde

* fix: include dependencies for crate bindings

* serde 1.0

* smol touchup

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
Autoparallel and mattsse authored Oct 10, 2023
1 parent 846d326 commit deae4f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions crates/forge/bin/cmd/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl BindArgs {
"console[2]?",
"CommonBase",
"Components",
"[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Assertions|Storage(Safe)?)",
"[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Style|Invariant|Assertions|Storage(Safe)?)",
"[Vv]m.*",
])
.extend_names(["IMulticall3"])
Expand All @@ -131,7 +131,11 @@ impl BindArgs {
Some(path)
}
})
.map(Abigen::from_file)
.map(|x| {
Abigen::from_file(x)?
.add_derive("serde::Serialize")?
.add_derive("serde::Deserialize")
})
.collect::<Result<Vec<_>, _>>()?;
let multi = MultiAbigen::from_abigens(abigens).with_filter(self.get_filter());

Expand Down Expand Up @@ -168,7 +172,7 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin
let bindings = self.get_multi(&artifacts)?.build()?;
println!("Generating bindings for {} contracts", bindings.len());
if !self.module {
bindings.write_to_crate(
bindings.dependencies([r#"serde = "1""#]).write_to_crate(
&self.crate_name,
&self.crate_version,
self.bindings_root(&artifacts),
Expand Down

0 comments on commit deae4f1

Please sign in to comment.