Skip to content

feat: added block.time and block.number override in cast #10727

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

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Soubhik-10
Copy link
Contributor

closes #6062

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, one suggestion

Comment on lines 151 to 156

/// Override the time field of a block
///
/// Format: block:time
#[arg(long = "override-time", value_name = "BLOCK:TIME")]
pub time_overrides: Option<Vec<String>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can name this just block.time because block overrides arent't that complex, this can be a simple u64

Comment on lines 440 to 445
fn time_value_override(input: &str) -> Result<(&str, &str), eyre::Report> {
let (block_str, time_str) = input.split_once(':').ok_or_else(|| {
eyre::eyre!("Invalid override `{input}`. Expected format: <block>:<time>")
})?;
Ok((block_str, time_str))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this we can change to a single u64 arg on the cli

@Soubhik-10 Soubhik-10 requested a review from mattsse June 9, 2025 11:05
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

only thing is missing is another alloy release that unlocks a single call here

Comment on lines +381 to +386
// Early return if no override set - <https://github.com/foundry-rs/foundry/issues/10705>
if self.block_time.as_ref().is_none() {
return Ok(None);
}

let block_overrides = BlockOverrides::default();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works, we'll need to check this for any additional overrides field we will introduce

@mattsse
Copy link
Member

mattsse commented Jun 10, 2025

@Soubhik-10 while we're at it, let's also add a block.number override value?

@Soubhik-10
Copy link
Contributor Author

@Soubhik-10 while we're at it, let's also add a block.number override value?

Sure 🫡

@Soubhik-10 Soubhik-10 changed the title added time override feat: added block.time and block.number override in cast Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

feat(cast) Add --timestamp flag to cast call --block to override the timestamp of the block
3 participants