@@ -12,26 +12,10 @@ use std::{collections::HashMap, ops::Deref};
1212pub struct ForkConfigs ( pub HashMap < String , ForkChainConfig > ) ;
1313
1414impl 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}
0 commit comments