Skip to content

Commit 98ab45e

Browse files
authored
feat: support mesc (#8760)
1 parent 41198f3 commit 98ab45e

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ itertools = "0.13"
231231
jsonpath_lib = "0.3"
232232
k256 = "0.13"
233233
parking_lot = "0.12"
234+
mesc = "0.2.1"
234235
rand = "0.8"
235236
rustc-hash = "2.0"
236237
semver = "1"

crates/config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ globset = "0.4"
3131
glob = "0.3"
3232
Inflector = "0.11"
3333
number_prefix = "0.4"
34+
mesc.workspace = true
3435
regex = "1"
3536
reqwest.workspace = true
3637
semver = { workspace = true, features = ["serde"] }

crates/config/src/lib.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,9 +1075,18 @@ impl Config {
10751075

10761076
/// Resolves the given alias to a matching rpc url
10771077
///
1078-
/// Returns:
1079-
/// - the matching, resolved url of `rpc_endpoints` if `maybe_alias` is an alias
1080-
/// - None otherwise
1078+
/// # Returns
1079+
///
1080+
/// In order of resolution:
1081+
///
1082+
/// - the matching, resolved url of `rpc_endpoints` if `maybe_alias` is an alias
1083+
/// - a mesc resolved url if `maybe_alias` is a known alias in mesc
1084+
/// - `None` otherwise
1085+
///
1086+
/// # Note on mesc
1087+
///
1088+
/// The endpoint is queried for in mesc under the `foundry` profile, allowing users to customize
1089+
/// endpoints for Foundry specifically.
10811090
///
10821091
/// # Example
10831092
///
@@ -1093,7 +1102,15 @@ impl Config {
10931102
maybe_alias: &str,
10941103
) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>> {
10951104
let mut endpoints = self.rpc_endpoints.clone().resolved();
1096-
Some(endpoints.remove(maybe_alias)?.map(Cow::Owned))
1105+
if let Some(endpoint) = endpoints.remove(maybe_alias) {
1106+
return Some(endpoint.map(Cow::Owned))
1107+
}
1108+
1109+
if let Ok(Some(endpoint)) = mesc::get_endpoint_by_query(maybe_alias, Some("foundry")) {
1110+
return Some(Ok(Cow::Owned(endpoint.url)))
1111+
}
1112+
1113+
None
10971114
}
10981115

10991116
/// Returns the configured rpc, or the fallback url

0 commit comments

Comments
 (0)