-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(forge, cast): add RunArgs generate_local_signatures to enable trace with local contracts functions and events #7359
base: master
Are you sure you want to change the base?
Changes from all commits
19f0b13
093ea83
82e7c67
fa0d4de
e00d358
81f7c5f
d34f2a3
a2db0f8
92e298c
fe6bace
7fc1387
76f92a3
f5ce099
9ac0f3c
3ed58f6
e0f35f9
ebc10c8
7325872
54b7e83
cf40ea6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ use clap::Parser; | |
use eyre::{Result, WrapErr}; | ||
use foundry_cli::{ | ||
opts::RpcOpts, | ||
utils::{handle_traces, init_progress, TraceResult}, | ||
utils::{cache_local_signatures, handle_traces, init_progress, TraceResult}, | ||
}; | ||
use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; | ||
use foundry_common::{compile::ProjectCompiler, is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; | ||
use foundry_compilers::artifacts::EvmVersion; | ||
use foundry_config::{ | ||
figment::{ | ||
|
@@ -86,6 +86,13 @@ pub struct RunArgs { | |
/// Enables Alphanet features. | ||
#[arg(long)] | ||
pub alphanet: bool, | ||
|
||
/// If generate a file with the signatures of the functions and events of the project. | ||
/// The file will be saved in the foundry cache directory. | ||
/// | ||
/// default value: false | ||
#[arg(long, short = 'c', visible_alias = "cls")] | ||
pub cache_local_signatures: bool, | ||
} | ||
|
||
impl RunArgs { | ||
|
@@ -242,6 +249,18 @@ impl RunArgs { | |
} | ||
}; | ||
|
||
if self.cache_local_signatures { | ||
let project = config.project()?; | ||
let compiler = ProjectCompiler::new().quiet(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need to actually compile here, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to compile as it might be run on a clean project. though I think we can only request abi here, should speed things up if there are cached artifacts then compilation would just use them, so that's fine I believe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually users are more likely to trace their own project files and compile the whole project before deploying. But some one may dont want to run two command to generate signature cache with new file updates (may be an upgradable contract should try different events). If file not updated, compile will be complete fast. |
||
let output = compiler.compile(&project)?; | ||
if let Err(err) = cache_local_signatures(&output, Config::foundry_cache_dir().unwrap()) | ||
{ | ||
warn!(target: "cast::run", ?err, "failed to flush signature cache"); | ||
} else { | ||
trace!(target: "cast::run", "flushed signature cache") | ||
} | ||
} | ||
|
||
handle_traces( | ||
result, | ||
&config, | ||
|
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 should print that we're compiling to get the signatures