Skip to content

feat: add vm.getChain(chainAlias) #10226

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

Merged
merged 9 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/cheatcodes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ parking_lot.workspace = true
alloy-consensus = { workspace = true, features = ["k256"] }
alloy-network.workspace = true
alloy-rlp.workspace = true
alloy-chains.workspace = true

base64.workspace = true
dialoguer = "0.11"
Expand Down
66 changes: 66 additions & 0 deletions crates/cheatcodes/assets/cheatcodes.json

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

1 change: 1 addition & 0 deletions crates/cheatcodes/spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl Cheatcodes<'static> {
Vm::Wallet::STRUCT.clone(),
Vm::FfiResult::STRUCT.clone(),
Vm::ChainInfo::STRUCT.clone(),
Vm::Chain::STRUCT.clone(),
Vm::AccountAccess::STRUCT.clone(),
Vm::StorageAccess::STRUCT.clone(),
Vm::Gas::STRUCT.clone(),
Expand Down
20 changes: 20 additions & 0 deletions crates/cheatcodes/spec/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,18 @@ interface Vm {
uint256 chainId;
}

/// Information about a blockchain.
struct Chain {
/// The chain name.
string name;
/// The chain's Chain ID.
uint256 chainId;
/// The chain's alias. (i.e. what gets specified in `foundry.toml`).
string chainAlias;
/// A default RPC endpoint for this chain.
string rpcUrl;
}

/// The storage accessed during an `AccountAccess`.
struct StorageAccess {
/// The account whose storage was accessed.
Expand Down Expand Up @@ -967,6 +979,14 @@ interface Vm {
#[cheatcode(group = Testing, safety = Safe)]
function rpcUrlStructs() external view returns (Rpc[] memory urls);

/// Returns a Chain struct for specific alias
#[cheatcode(group = Testing, safety = Safe)]
function getChain(string calldata chainAlias) external view returns (Chain memory chain);

/// Returns a Chain struct for specific chainId
#[cheatcode(group = Testing, safety = Safe)]
function getChain(uint256 chainId) external view returns (Chain memory chain);

/// Suspends execution of the main thread for `duration` milliseconds.
#[cheatcode(group = Testing, safety = Safe)]
function sleep(uint256 duration) external;
Expand Down
Loading
Loading