Skip to content

Commit 95c9adc

Browse files
committed
style
1 parent 9ba7d51 commit 95c9adc

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

crates/config/src/fork_config.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,10 @@ use std::{collections::HashMap, ops::Deref};
1212
pub struct ForkConfigs(pub HashMap<String, ForkChainConfig>);
1313

1414
impl ForkConfigs {
15-
/// Resolve environment variables in all fork config fields
16-
fn resolve_env_vars(&mut self) -> Result<(), ExtractConfigError> {
17-
for (name, fork_config) in &mut self.0 {
18-
// Take temporary ownership of the config, so that it can be consumed.
19-
let config = std::mem::take(fork_config);
20-
21-
// Resolve the env vars and place it back into the map.
22-
*fork_config = config.resolved().map_err(|e| {
23-
let msg = if !e.var.is_empty() {
24-
format!("environment variable `{}` not found", e.var)
25-
} else {
26-
e.to_string()
27-
};
28-
ExtractConfigError::new(figment::Error::from(format!(
29-
"Failed to resolve fork config [forks.{name}]: {msg}"
30-
)))
31-
})?;
32-
}
33-
34-
Ok(())
15+
/// Normalize fork config chain keys and resolve environment variables in all configured fields.
16+
pub fn normalize_and_resolve(&mut self) -> Result<(), ExtractConfigError> {
17+
self.normalize_keys()?;
18+
self.resolve_env_vars()
3519
}
3620

3721
/// Normalize fork config chains, so that all have `alloy_chain::NamedChain` compatible names.
@@ -68,10 +52,25 @@ impl ForkConfigs {
6852
Ok(())
6953
}
7054

71-
/// Normalize fork config chains and resolve environment variables in all configured fields.
72-
pub fn normalize_and_resolve(&mut self) -> Result<(), ExtractConfigError> {
73-
self.resolve_env_vars()?;
74-
self.normalize_keys()?;
55+
/// Resolve environment variables in all fork config fields
56+
fn resolve_env_vars(&mut self) -> Result<(), ExtractConfigError> {
57+
for (name, fork_config) in &mut self.0 {
58+
// Take temporary ownership of the config, so that it can be consumed.
59+
let config = std::mem::take(fork_config);
60+
61+
// Resolve the env vars and place it back into the map.
62+
*fork_config = config.resolved().map_err(|e| {
63+
let msg = if !e.var.is_empty() {
64+
format!("environment variable `{}` not found", e.var)
65+
} else {
66+
e.to_string()
67+
};
68+
ExtractConfigError::new(figment::Error::from(format!(
69+
"Failed to resolve fork config [forks.{name}]: {msg}"
70+
)))
71+
})?;
72+
}
73+
7574
Ok(())
7675
}
7776
}

crates/forge/tests/cli/script.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,7 +3489,6 @@ forgetest_init!(can_derive_chain_id_access_fork_config, |prj, cmd| {
34893489
("addr".into(), "0xdeadbeef00000000000000000000000000000000".into()),
34903490
("bytes".into(), "0x00000000000f00".into()),
34913491
("str".into(), "bar".into()),
3492-
// Array configurations for testing new array cheatcodes
34933492
("bool_array".into(), vec![true, false, true].into()),
34943493
("int_array".into(), vec!["-100", "200", "-300"].into()),
34953494
("uint_array".into(), vec!["100", "200", "300"].into()),
@@ -3524,7 +3523,6 @@ forgetest_init!(can_derive_chain_id_access_fork_config, |prj, cmd| {
35243523
("addr".into(), "0x00000000000000000000000000000000deadbeef".into()),
35253524
("bytes".into(), "0x00f00000000000".into()),
35263525
("str".into(), "bazz".into()),
3527-
// Array configurations for testing new array cheatcodes
35283526
("bool_array".into(), vec![false, true, false].into()),
35293527
("int_array".into(), vec!["-400", "500", "-600"].into()),
35303528
("uint_array".into(), vec!["400", "500", "600"].into()),

0 commit comments

Comments
 (0)