Skip to content
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

fix(cli): handle id and named chain_id's correctly #9480

Merged
merged 3 commits into from
Dec 4, 2024
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
19 changes: 19 additions & 0 deletions crates/cast/tests/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1955,3 +1955,22 @@ Transaction successfully executed.

"#]]);
});

// https://github.com/foundry-rs/foundry/issues/9476
forgetest_async!(cast_call_custom_chain_id, |_prj, cmd| {
let chain_id = 55555u64;
let (_api, handle) = anvil::spawn(NodeConfig::test().with_chain_id(Some(chain_id))).await;

let http_endpoint = handle.http_endpoint();

cmd.cast_fuse()
.args([
"call",
"5FbDB2315678afecb367f032d93F642f64180aa3",
"--rpc-url",
&http_endpoint,
"--chain",
&chain_id.to_string(),
])
.assert_success();
});
7 changes: 6 additions & 1 deletion crates/cli/src/opts/ethereum.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::opts::ChainValueParser;
use alloy_chains::ChainKind;
use clap::Parser;
use eyre::Result;
use foundry_config::{
Expand Down Expand Up @@ -154,7 +155,11 @@ impl EtherscanOpts {
dict.insert("etherscan_api_key".into(), key.into());
}
if let Some(chain) = self.chain {
dict.insert("chain_id".into(), chain.to_string().into());
if let ChainKind::Id(id) = chain.kind() {
dict.insert("chain_id".into(), (*id).into());
} else {
dict.insert("chain_id".into(), chain.to_string().into());
}
}
dict
}
Expand Down
Loading