From 910c24e7dae069bcb642eae3996b5e30d187a857 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Tue, 21 Oct 2025 18:12:38 +0200 Subject: [PATCH] Actually commit the recommended changes --- .../client-core/src/client/base_client/mod.rs | 46 +++++++++++-------- sdk/rust/nym-sdk/src/mixnet/client.rs | 8 +++- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/common/client-core/src/client/base_client/mod.rs b/common/client-core/src/client/base_client/mod.rs index e2b6f250a7..35e0b384e8 100644 --- a/common/client-core/src/client/base_client/mod.rs +++ b/common/client-core/src/client/base_client/mod.rs @@ -217,8 +217,8 @@ pub struct BaseClientBuilder { client_store: S, dkg_query_client: Option, - // Optional network details for domain fronting support - network_details: Option, + // Optional API URLs for domain fronting support + nym_api_urls: Option>, wait_for_gateway: bool, custom_topology_provider: Option>, @@ -249,7 +249,7 @@ where config: base_config, client_store, dkg_query_client, - network_details: None, + nym_api_urls: None, wait_for_gateway: false, custom_topology_provider: None, custom_gateway_transceiver: None, @@ -272,16 +272,26 @@ where self } - /// Set network details for domain fronting support. + /// Set Nym API URLs for domain fronting support. /// - /// When provided, the client will use network details (which include front_hosts) + /// When provided, the client will use these API URLs (which include front_hosts) /// to construct HTTP clients with domain fronting enabled. #[must_use] - pub fn with_network_details(mut self, network_details: NymNetworkDetails) -> Self { - self.network_details = Some(network_details); + pub fn with_nym_api_urls(mut self, nym_api_urls: Vec) -> Self { + self.nym_api_urls = Some(nym_api_urls); self } + /// Set network details for domain fronting support (deprecated). + /// + /// Use `with_nym_api_urls()` instead to explicitly pass the API URLs. + #[must_use] + #[deprecated(note = "use explicit Self::with_nym_api_urls instead")] + pub fn with_network_details(self, network_details: NymNetworkDetails) -> Self { + let nym_api_urls = network_details.nym_api_urls.unwrap_or_default(); + self.with_nym_api_urls(nym_api_urls) + } + #[must_use] pub fn with_forget_me(mut self, forget_me: &ForgetMe) -> Self { self.config.debug.forget_me = *forget_me; @@ -882,25 +892,25 @@ where } fn construct_nym_api_client( - network_details: Option<&NymNetworkDetails>, + nym_api_urls: Option<&Vec>, config: &Config, user_agent: Option, ) -> Result { tracing::debug!( - "construct_nym_api_client called with network_details: {}", - network_details.is_some() + "construct_nym_api_client called with nym_api_urls: {}", + nym_api_urls.is_some() ); - // If network details are provided, use new_with_fronted_urls() which handles domain fronting - if let Some(network_details) = network_details { + // If API URLs are provided, use new_with_fronted_urls() which handles domain fronting + if let Some(nym_api_urls) = nym_api_urls { tracing::info!( - "Building nym-api client from network details (with domain fronting support)" + "Building nym-api client from provided URLs (with domain fronting support)" ); - let urls = network_details.nym_api_urls.clone().unwrap_or_default(); - let mut builder = nym_http_api_client::ClientBuilder::new_with_fronted_urls(urls) - .map_err(ClientCoreError::from)? - .with_retries(DEFAULT_NYM_API_RETRIES); + let mut builder = + nym_http_api_client::ClientBuilder::new_with_fronted_urls(nym_api_urls.clone()) + .map_err(ClientCoreError::from)? + .with_retries(DEFAULT_NYM_API_RETRIES); if let Some(user_agent) = user_agent { builder = builder.with_user_agent(user_agent); @@ -1008,7 +1018,7 @@ where .map(|client| BandwidthController::new(credential_store, client)); let nym_api_client = Self::construct_nym_api_client( - self.network_details.as_ref(), + self.nym_api_urls.as_ref(), &self.config, self.user_agent.clone(), )?; diff --git a/sdk/rust/nym-sdk/src/mixnet/client.rs b/sdk/rust/nym-sdk/src/mixnet/client.rs index beee26cd67..a9e12b0fe5 100644 --- a/sdk/rust/nym-sdk/src/mixnet/client.rs +++ b/sdk/rust/nym-sdk/src/mixnet/client.rs @@ -707,7 +707,7 @@ where .as_base_client_config(nyxd_endpoints, nym_api_endpoints.clone()); tracing::debug!( - "SDK: Passing network_details to BaseClientBuilder (has {} nym_api_urls)", + "SDK: Passing nym_api_urls to BaseClientBuilder (has {} nym_api_urls)", self.config .network_details .nym_api_urls @@ -718,12 +718,16 @@ where let mut base_builder: BaseClientBuilder<_, _> = BaseClientBuilder::new(base_config, self.storage, self.dkg_query_client) - .with_network_details(self.config.network_details.clone()) .with_wait_for_gateway(self.wait_for_gateway) .with_forget_me(&self.forget_me) .with_remember_me(&self.remember_me) .with_derivation_material(self.derivation_material); + // Add nym_api_urls if available in network_details + if let Some(nym_api_urls) = self.config.network_details.nym_api_urls.clone() { + base_builder = base_builder.with_nym_api_urls(nym_api_urls); + } + if let Some(user_agent) = self.user_agent { base_builder = base_builder.with_user_agent(user_agent); }