diff --git a/Cargo.lock b/Cargo.lock index d82cf66ac6d5..de7128f57bbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f12f8177eddf9275fa9ae5fd73b50cee062f9b1eb95ef435f28354c79ba386" +checksum = "4df496257fe2fae392687ef30207325c50c68520108a94798b0c6cc1a6102f70" dependencies = [ "num_enum", "serde", diff --git a/Cargo.toml b/Cargo.toml index f04f0f55671a..398936a74955 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,7 +148,7 @@ alloy-json-abi = "0.5.0" alloy-sol-types = "0.5.0" syn-solidity = "0.5.0" -alloy-chains = "0.1.4" +alloy-chains = "0.1.5" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 01e0f3b92450..1af928b7cced 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -194,7 +194,9 @@ impl EtherscanConfig { Ok(ResolvedEtherscanConfig { api_url, browser_url: None, key, chain: None }) } (None, None) => { - let msg = alias.map(|a| format!(" for Etherscan config `{a}`")).unwrap_or_default(); + let msg = alias + .map(|a| format!(" for Etherscan config with unknown alias `{a}`")) + .unwrap_or_default(); Err(EtherscanConfigError::MissingUrlOrChain(msg)) } } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 5175775315d5..e2725d6a6c13 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -3089,6 +3089,33 @@ mod tests { }) } + #[test] + fn test_resolve_rpc_aliases() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [profile.default] + [etherscan] + arbitrum_alias = { key = "${TEST_RESOLVE_RPC_ALIAS_ARBISCAN}" } + [rpc_endpoints] + arbitrum_alias = "https://arb-mainnet.g.alchemy.com/v2/${TEST_RESOLVE_RPC_ALIAS_ARB_ONE}" + "#, + )?; + + jail.set_env("TEST_RESOLVE_RPC_ALIAS_ARB_ONE", "123455"); + jail.set_env("TEST_RESOLVE_RPC_ALIAS_ARBISCAN", "123455"); + + let config = Config::load(); + + let config = config.get_etherscan_config_with_chain(Some(NamedChain::Arbitrum.into())); + assert!(config.is_err()); + assert_eq!(config.unwrap_err().to_string(), "At least one of `url` or `chain` must be present for Etherscan config with unknown alias `arbitrum_alias`"); + + Ok(()) + }); + } + #[test] fn test_resolve_endpoints() { figment::Jail::expect_with(|jail| {