-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate(forge-bind
): to alloy
#7919
base: master
Are you sure you want to change the base?
Conversation
Proposing to make the utils method |
TODO:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DaniPopes is best equipped to give directions here, but I think this sounds reasonable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pedantic doc nits
pending @DaniPopes
@DaniPopes please drop your final review whenever possible |
crates/forge/bin/cmd/bind.rs
Outdated
@@ -158,9 +159,29 @@ impl BindArgs { | |||
.into() | |||
} | |||
|
|||
fn get_alloy_filter(&self) -> Filter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary? The filtering and file finding behavior should be the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so get_filter
returns ContractFilter
which is specific to ethers
. These methods just return the regex that is then used in a unified setting in get_json_files
to actually get the files.
@DaniPopes ptal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you run this on a few popular users (just search "forge bind" on github) and check if the output makes sense
|
||
let tokens = quote::quote! { | ||
#[derive(Debug)] | ||
#[sol(rpc)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing bytecode attributes
"#, | ||
instance.name.to_lowercase() | ||
); | ||
let contents = "//! This module was autogenerated by the alloy sol!.\n//! More information can be found here <https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html>.\n".to_string() + &instance.expansion.as_ref().unwrap().to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use format! and split to multiple lines like above
cargo_toml_contents.contains(alloy_contract_check); | ||
eyre::ensure!( | ||
toml_consistent, | ||
format!("The contents of Cargo.toml do not match the expected output of the newest `ethers::Abigen` version.\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this error message can be 2 lines
Motivation
Final part of alloy migration
Solution
In order to do this, we have to make use of parts of code that make up the
sol!
macro to create aSolMacroGen
type that is similar to theAbigen
type in ethers.We're reading the JSON abi files (the artifacts) and retrieving the
ABI
from it then converting that to a SolidityTokenStream
and ultimately convert that to aSolInput
that should be passed to the expander that is used by thesol!
macro here: https://github.com/alloy-rs/core/blob/85aecdf54c56da20f274a21f372d3d37b8c118ca/crates/sol-macro/src/lib.rs#L281.However the issue is that the
expand
module is private in thesol-macro
crate and cannot be made public since it's not a macro.@DaniPopes @mattsse I can move the
expand
module to a new cratesol-macro-expander
, make it public and use it in foundry??TODO
expand
public by moving to a new crate.