From c79471e9ad430fb254b22ff34c86e6a0b8a3ee3c Mon Sep 17 00:00:00 2001 From: durch Date: Mon, 1 Sep 2025 14:48:19 +0200 Subject: [PATCH] Assorted CI fixes --- common/http-api-client/src/fronted.rs | 6 ++-- common/http-api-client/src/tests.rs | 13 ++++---- common/wasm/client-core/src/helpers.rs | 23 +++++++------- .../client/src/lib.rs | 13 +++----- .../tests/src/lib.rs | 4 +-- .../tests/src/v0/network.rs | 3 +- contracts/ecash/src/contract/test.rs | 2 +- contracts/ecash/src/support/tests.rs | 4 +-- .../mixnet/src/delegations/transactions.rs | 2 +- contracts/performance/src/testing/mod.rs | 6 ++-- contracts/vesting/src/vesting/mod.rs | 2 +- nym-network-monitor/src/main.rs | 9 ++---- nym-wallet/Cargo.lock | 30 +++++++++++++++++++ nym-wallet/src-tauri/src/error.rs | 6 ---- .../src-tauri/src/operations/mixnet/bond.rs | 5 ++-- .../examples/custom_topology_provider.rs | 11 +++---- .../src/manager/local_client.rs | 11 +++---- .../validator-status-check/src/models.rs | 10 +++---- wasm/zknym-lib/src/error.rs | 4 +-- wasm/zknym-lib/src/vpn_api_client/client.rs | 20 ++++++------- wasm/zknym-lib/src/vpn_api_client/mod.rs | 5 ---- 21 files changed, 91 insertions(+), 98 deletions(-) diff --git a/common/http-api-client/src/fronted.rs b/common/http-api-client/src/fronted.rs index 5818649403..f41ce8f3cf 100644 --- a/common/http-api-client/src/fronted.rs +++ b/common/http-api-client/src/fronted.rs @@ -100,14 +100,14 @@ mod tests { // Some(vec!["https://cdn77.com"]), // ).unwrap(); // cdn77 - let client = ClientBuilder::new::<_, &str>(url1) + let client = ClientBuilder::new(url1) .expect("bad url") .with_fronting(FrontPolicy::Always) - .build::<&str>() + .build() .expect("failed to build client"); let response = client - .send_request::<_, (), &str, &str, &str>( + .send_request::<_, (), &str, &str>( reqwest::Method::GET, &["api", "v1", "network", "details"], NO_PARAMS, diff --git a/common/http-api-client/src/tests.rs b/common/http-api-client/src/tests.rs index e24d1c6710..98f6fec79f 100644 --- a/common/http-api-client/src/tests.rs +++ b/common/http-api-client/src/tests.rs @@ -95,10 +95,10 @@ async fn api_client_retry() -> Result<(), Box> { "http://example.com/".parse()?, ]) .with_retries(3) - .build::()?; + .build()?; let req = client.create_get_request(&["/"], NO_PARAMS).unwrap(); - let resp = client.send::(req).await?; + let resp = client.send(req).await?; assert_eq!(resp.status(), 200); @@ -111,10 +111,7 @@ async fn api_client_retry() -> Result<(), Box> { #[test] fn host_updating() { let url = Url::new("http://example.com", None).unwrap(); - let mut client = ClientBuilder::new::<_, &str>(url) - .unwrap() - .build::<&str>() - .unwrap(); + let mut client = ClientBuilder::new(url).unwrap().build().unwrap(); // check that the url is set correctly let current_url = client.current_url(); @@ -171,10 +168,10 @@ fn host_updating() { #[cfg(feature = "tunneling")] fn fronted_host_updating() { let url = Url::new("http://example.com", Some(vec!["http://front1.com"])).unwrap(); - let mut client = ClientBuilder::new::<_, &str>(url) + let mut client = ClientBuilder::new(url) .unwrap() .with_fronting(crate::fronted::FrontPolicy::Always) - .build::<&str>() + .build() .unwrap(); // check that the url is set correctly diff --git a/common/wasm/client-core/src/helpers.rs b/common/wasm/client-core/src/helpers.rs index 3b86e6663d..23aaee4cad 100644 --- a/common/wasm/client-core/src/helpers.rs +++ b/common/wasm/client-core/src/helpers.rs @@ -72,19 +72,16 @@ pub async fn current_network_topology_async( } }; - let api_client = nym_http_api_client::Client::builder::< - _, - nym_validator_client::models::RequestError, - >(url.clone()) - .map_err(|_err| WasmCoreError::MalformedUrl { - raw: nym_api_url.to_string(), - source: url::ParseError::EmptyHost, - })? - .build::() - .map_err(|_err| WasmCoreError::MalformedUrl { - raw: nym_api_url.to_string(), - source: url::ParseError::EmptyHost, - })?; + let api_client = nym_http_api_client::Client::builder(url.clone()) + .map_err(|_err| WasmCoreError::MalformedUrl { + raw: nym_api_url.to_string(), + source: url::ParseError::EmptyHost, + })? + .build() + .map_err(|_err| WasmCoreError::MalformedUrl { + raw: nym_api_url.to_string(), + source: url::ParseError::EmptyHost, + })?; let rewarded_set = api_client.get_current_rewarded_set().await?; let mixnodes_res = api_client .get_all_basic_active_mixing_assigned_nodes_with_metadata() diff --git a/common/wireguard-private-metadata/client/src/lib.rs b/common/wireguard-private-metadata/client/src/lib.rs index 3f683efe5e..fd02fb3847 100644 --- a/common/wireguard-private-metadata/client/src/lib.rs +++ b/common/wireguard-private-metadata/client/src/lib.rs @@ -7,16 +7,14 @@ use tracing::instrument; use nym_http_api_client::{ApiClient, Client, HttpClientError, NO_PARAMS}; use nym_wireguard_private_metadata_shared::{ - routes, Version, {ErrorResponse, Request, Response}, + routes, Version, {Request, Response}, }; -pub type WireguardMetadataApiClientError = HttpClientError; - #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait)] pub trait WireguardMetadataApiClient: ApiClient { #[instrument(level = "debug", skip(self))] - async fn version(&self) -> Result { + async fn version(&self) -> Result { let version: u64 = self .get_json( &[routes::V1_API_VERSION, routes::BANDWIDTH, routes::VERSION], @@ -30,7 +28,7 @@ pub trait WireguardMetadataApiClient: ApiClient { async fn available_bandwidth( &self, request_body: &Request, - ) -> Result { + ) -> Result { self.post_json( &[routes::V1_API_VERSION, routes::BANDWIDTH, routes::AVAILABLE], NO_PARAMS, @@ -40,10 +38,7 @@ pub trait WireguardMetadataApiClient: ApiClient { } #[instrument(level = "debug", skip(self, request_body))] - async fn topup_bandwidth( - &self, - request_body: &Request, - ) -> Result { + async fn topup_bandwidth(&self, request_body: &Request) -> Result { self.post_json( &[routes::V1_API_VERSION, routes::BANDWIDTH, routes::TOPUP], NO_PARAMS, diff --git a/common/wireguard-private-metadata/tests/src/lib.rs b/common/wireguard-private-metadata/tests/src/lib.rs index c1a981e484..1ae9ccdd93 100644 --- a/common/wireguard-private-metadata/tests/src/lib.rs +++ b/common/wireguard-private-metadata/tests/src/lib.rs @@ -13,7 +13,7 @@ mod tests { use nym_wireguard_private_metadata_server::{ AppState, PeerControllerTransceiver, RouterBuilder, }; - use nym_wireguard_private_metadata_shared::{latest, v0, v1, ErrorResponse}; + use nym_wireguard_private_metadata_shared::{latest, v0, v1}; use tokio::{net::TcpListener, sync::mpsc}; pub(crate) const VERIFIER_AVAILABLE_BANDWIDTH: i64 = 42; @@ -140,7 +140,7 @@ mod tests { .await .unwrap(); }); - Client::new_url::<_, ErrorResponse>(addr.to_string(), None).unwrap() + Client::new_url(addr.to_string(), None).unwrap() } #[tokio::test] diff --git a/common/wireguard-private-metadata/tests/src/v0/network.rs b/common/wireguard-private-metadata/tests/src/v0/network.rs index 6a847ecc36..0be32d66dc 100644 --- a/common/wireguard-private-metadata/tests/src/v0/network.rs +++ b/common/wireguard-private-metadata/tests/src/v0/network.rs @@ -15,7 +15,6 @@ pub(crate) mod test { use nym_http_api_common::{FormattedResponse, OutputParams}; use nym_wireguard::{peer_controller::PeerControlRequest, CONTROL_CHANNEL_SIZE}; use nym_wireguard_private_metadata_server::PeerControllerTransceiver; - use nym_wireguard_private_metadata_shared::ErrorResponse; use nym_wireguard_private_metadata_shared::{ v0 as latest, AxumErrorResponse, AxumResult, Construct, Extract, Request, Response, }; @@ -141,6 +140,6 @@ pub(crate) mod test { .await .unwrap(); }); - Client::new_url::<_, ErrorResponse>(addr.to_string(), None).unwrap() + Client::new_url(addr.to_string(), None).unwrap() } } diff --git a/contracts/ecash/src/contract/test.rs b/contracts/ecash/src/contract/test.rs index 09ece6dd4b..77f4dade4c 100644 --- a/contracts/ecash/src/contract/test.rs +++ b/contracts/ecash/src/contract/test.rs @@ -52,7 +52,7 @@ impl TestSetup { } } - pub fn query_ctx(&self) -> QueryCtx { + pub fn query_ctx(&self) -> QueryCtx<'_> { QueryCtx::from((self.deps.as_ref(), self.env.clone())) } } diff --git a/contracts/ecash/src/support/tests.rs b/contracts/ecash/src/support/tests.rs index fb3f3aa579..de31ea4e6d 100644 --- a/contracts/ecash/src/support/tests.rs +++ b/contracts/ecash/src/support/tests.rs @@ -73,13 +73,13 @@ impl TestSetupSimple { message_info(&admin, &[]) } - pub fn execute_ctx(&mut self, sender: MessageInfo) -> ExecCtx { + pub fn execute_ctx(&mut self, sender: MessageInfo) -> ExecCtx<'_> { let env = self.env.clone(); ExecCtx::from((self.deps.as_mut(), env, sender)) } #[allow(dead_code)] - pub fn query_ctx(&self) -> QueryCtx { + pub fn query_ctx(&self) -> QueryCtx<'_> { QueryCtx::from((self.deps.as_ref(), self.env.clone())) } diff --git a/contracts/mixnet/src/delegations/transactions.rs b/contracts/mixnet/src/delegations/transactions.rs index 4611f83c20..dff4d46b39 100644 --- a/contracts/mixnet/src/delegations/transactions.rs +++ b/contracts/mixnet/src/delegations/transactions.rs @@ -300,7 +300,7 @@ mod tests { let amount1 = coin(100_000_000, TEST_COIN_DENOM); - let sender1 = message_info(owner, &[amount1.clone()]); + let sender1 = message_info(owner, std::slice::from_ref(&amount1)); try_delegate_to_node(test.deps_mut(), env.clone(), sender1, mix_id).unwrap(); diff --git a/contracts/performance/src/testing/mod.rs b/contracts/performance/src/testing/mod.rs index 4f8e7cf4bd..614982acc3 100644 --- a/contracts/performance/src/testing/mod.rs +++ b/contracts/performance/src/testing/mod.rs @@ -131,7 +131,7 @@ impl PreInitContract { } } - pub(crate) fn deps(&self) -> Deps { + pub(crate) fn deps(&self) -> Deps<'_> { Deps { storage: &self.storage, api: &self.api, @@ -139,7 +139,7 @@ impl PreInitContract { } } - pub(crate) fn deps_mut(&mut self) -> DepsMut { + pub(crate) fn deps_mut(&mut self) -> DepsMut<'_> { DepsMut { storage: &mut self.storage, api: &self.api, @@ -147,7 +147,7 @@ impl PreInitContract { } } - pub(crate) fn querier(&self) -> QuerierWrapper { + pub(crate) fn querier(&self) -> QuerierWrapper<'_> { self.tester_builder.querier() } diff --git a/contracts/vesting/src/vesting/mod.rs b/contracts/vesting/src/vesting/mod.rs index 48e0f48dc3..8c37ed5eac 100644 --- a/contracts/vesting/src/vesting/mod.rs +++ b/contracts/vesting/src/vesting/mod.rs @@ -137,7 +137,7 @@ mod tests { let response = execute( deps.as_mut(), env.clone(), - message_info(&admin, &[amount.clone()]), + message_info(&admin, std::slice::from_ref(&amount)), msg, ); assert_eq!( diff --git a/nym-network-monitor/src/main.rs b/nym-network-monitor/src/main.rs index 545a37bbbe..4dc9980f00 100644 --- a/nym-network-monitor/src/main.rs +++ b/nym-network-monitor/src/main.rs @@ -163,12 +163,9 @@ async fn nym_topology_from_env() -> anyhow::Result { let api_url = std::env::var(NYM_API)?; info!("Generating topology from {api_url}"); - let client = nym_http_api_client::Client::builder::< - _, - nym_validator_client::models::RequestError, - >(api_url)? - .with_user_agent(UserAgent::from(bin_info!())) - .build::()?; + let client = nym_http_api_client::Client::builder(api_url)? + .with_user_agent(UserAgent::from(bin_info!())) + .build()?; let rewarded_set = client.get_current_rewarded_set().await?; diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index f4bff02a23..05bcd8c4d2 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -4213,6 +4213,8 @@ dependencies = [ "reqwest 0.12.15", "serde", "serde_json", + "serde_plain", + "serde_yaml", "thiserror 2.0.12", "tracing", "url", @@ -6297,6 +6299,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_plain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1fc6db65a611022b23a0dec6975d63fb80a302cb3388835ff02c097258d50" +dependencies = [ + "serde", +] + [[package]] name = "serde_repr" version = "0.1.20" @@ -6359,6 +6370,19 @@ dependencies = [ "syn 2.0.100", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.8.0", + "itoa 1.0.15", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "serdect" version = "0.2.0" @@ -7836,6 +7860,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "untrusted" version = "0.9.0" diff --git a/nym-wallet/src-tauri/src/error.rs b/nym-wallet/src-tauri/src/error.rs index 3e3123e088..4393ce43f7 100644 --- a/nym-wallet/src-tauri/src/error.rs +++ b/nym-wallet/src-tauri/src/error.rs @@ -2,7 +2,6 @@ use nym_contracts_common::signing::SigningAlgorithm; use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError; use nym_node_requests::api::client::NymNodeApiClientError; use nym_types::error::TypesError; -use nym_validator_client::nym_api::error::NymAPIError; use nym_validator_client::signing::direct_wallet::DirectSecp256k1HdWalletError; use nym_validator_client::{nyxd::error::NyxdError, ValidatorClientError}; use nym_wallet_types::network::Network; @@ -45,11 +44,6 @@ pub enum BackendError { source: eyre::Report, }, #[error(transparent)] - NymApiError { - #[from] - source: NymAPIError, - }, - #[error(transparent)] NymNodeApiError { #[from] source: NymNodeApiClientError, diff --git a/nym-wallet/src-tauri/src/operations/mixnet/bond.rs b/nym-wallet/src-tauri/src/operations/mixnet/bond.rs index 881b54aa3c..55a57ce88e 100644 --- a/nym-wallet/src-tauri/src/operations/mixnet/bond.rs +++ b/nym-wallet/src-tauri/src/operations/mixnet/bond.rs @@ -15,7 +15,6 @@ use nym_mixnet_contract_common::nym_node::{NodeConfigUpdate, StakeSaturationResp use nym_mixnet_contract_common::{MixNodeConfigUpdate, NodeId, NymNode}; use nym_node_requests::api::client::NymNodeApiClientExt; use nym_node_requests::api::v1::node::models::NodeDescription; -use nym_node_requests::api::ErrorResponse; use nym_types::currency::DecCoin; use nym_types::gateway::GatewayBond; use nym_types::mixnode::{MixNodeDetails, NodeCostParams}; @@ -586,12 +585,12 @@ pub async fn get_nym_node_description( port: u16, ) -> Result { Ok( - nym_node_requests::api::Client::builder::<_, ErrorResponse>(format!( + nym_node_requests::api::Client::builder(format!( "http://{host}:{port}" ))? .with_timeout(Duration::from_millis(1000)) .with_user_agent(format!("nym-wallet/{}", env!("CARGO_PKG_VERSION"))) - .build::()? + .build()? .get_description() .await?, ) diff --git a/sdk/rust/nym-sdk/examples/custom_topology_provider.rs b/sdk/rust/nym-sdk/examples/custom_topology_provider.rs index c3434aa117..6f6fe5b730 100644 --- a/sdk/rust/nym-sdk/examples/custom_topology_provider.rs +++ b/sdk/rust/nym-sdk/examples/custom_topology_provider.rs @@ -14,13 +14,10 @@ struct MyTopologyProvider { impl MyTopologyProvider { fn new(nym_api_url: Url) -> MyTopologyProvider { - let validator_client = nym_http_api_client::Client::builder::< - _, - nym_validator_client::models::RequestError, - >(nym_api_url) - .expect("Failed to create API client builder") - .build::() - .expect("Failed to build API client"); + let validator_client = nym_http_api_client::Client::builder(nym_api_url) + .expect("Failed to create API client builder") + .build() + .expect("Failed to build API client"); MyTopologyProvider { validator_client } } diff --git a/tools/internal/testnet-manager/src/manager/local_client.rs b/tools/internal/testnet-manager/src/manager/local_client.rs index 1d7084d35c..8004c658df 100644 --- a/tools/internal/testnet-manager/src/manager/local_client.rs +++ b/tools/internal/testnet-manager/src/manager/local_client.rs @@ -91,13 +91,10 @@ impl NetworkManager { "⌛waiting for any gateway to appear in the directory ({api_url})..." )); - let api_client = nym_http_api_client::Client::builder::< - _, - nym_validator_client::models::RequestError, - >(api_url.clone()) - .expect("Failed to create API client builder") - .build::() - .expect("Failed to build API client"); + let api_client = nym_http_api_client::Client::builder(api_url.clone()) + .expect("Failed to create API client builder") + .build() + .expect("Failed to build API client"); let wait_fut = async { let inner_fut = async { diff --git a/tools/internal/validator-status-check/src/models.rs b/tools/internal/validator-status-check/src/models.rs index 3c164e93eb..11534118d2 100644 --- a/tools/internal/validator-status-check/src/models.rs +++ b/tools/internal/validator-status-check/src/models.rs @@ -56,12 +56,10 @@ impl SignerStatus { } }; - nym_http_api_client::Client::builder::<_, nym_validator_client::models::RequestError>( - api_endpoint, - ) - .ok()? - .build::() - .ok() + nym_http_api_client::Client::builder(api_endpoint) + .ok()? + .build() + .ok() } pub(crate) async fn try_update_api_version(&mut self) { diff --git a/wasm/zknym-lib/src/error.rs b/wasm/zknym-lib/src/error.rs index f232daddf3..41cd2fdd4a 100644 --- a/wasm/zknym-lib/src/error.rs +++ b/wasm/zknym-lib/src/error.rs @@ -1,7 +1,7 @@ // Copyright 2024 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::vpn_api_client::NymVpnApiClientError; +use nym_http_api_client::HttpClientError; use thiserror::Error; use wasm_utils::wasm_error; @@ -16,7 +16,7 @@ pub enum ZkNymError { #[error("failed to contact the vpn api")] HttpClientFailure { #[from] - source: NymVpnApiClientError, + source: HttpClientError, }, #[error("the provided shares and issuers are not from the same epoch! {shares} and {issuers}")] InconsistentEpochId { shares: u64, issuers: u64 }, diff --git a/wasm/zknym-lib/src/vpn_api_client/client.rs b/wasm/zknym-lib/src/vpn_api_client/client.rs index e3a7f983b0..1692ef635a 100644 --- a/wasm/zknym-lib/src/vpn_api_client/client.rs +++ b/wasm/zknym-lib/src/vpn_api_client/client.rs @@ -1,14 +1,14 @@ // Copyright 2024 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 - -use super::NymVpnApiClientError; use crate::error::ZkNymError; use crate::vpn_api_client::types::{ AttributesResponse, MasterVerificationKeyResponse, PartialVerificationKeysResponse, }; use async_trait::async_trait; pub use nym_http_api_client::Client; -use nym_http_api_client::{parse_response, ApiClient, IntoUrl, PathSegments, NO_PARAMS}; +use nym_http_api_client::{ + parse_response, ApiClient, HttpClientError, IntoUrl, PathSegments, NO_PARAMS, +}; use serde::de::DeserializeOwned; #[allow(dead_code)] @@ -34,13 +34,11 @@ pub fn new_client( #[allow(dead_code)] #[async_trait(?Send)] pub trait NymVpnApiClient { - async fn simple_get(&self, path: PathSegments<'_>) -> Result + async fn simple_get(&self, path: PathSegments<'_>) -> Result where T: DeserializeOwned; - async fn get_prehashed_public_attributes( - &self, - ) -> Result { + async fn get_prehashed_public_attributes(&self) -> Result { self.simple_get(&[ "/api", "/v1", @@ -52,7 +50,7 @@ pub trait NymVpnApiClient { async fn get_partial_verification_keys( &self, - ) -> Result { + ) -> Result { self.simple_get(&[ "/api", "/v1", @@ -64,7 +62,7 @@ pub trait NymVpnApiClient { async fn get_master_verification_key( &self, - ) -> Result { + ) -> Result { self.simple_get(&[ "/api", "/v1", @@ -77,13 +75,13 @@ pub trait NymVpnApiClient { #[async_trait(?Send)] impl NymVpnApiClient for VpnApiClient { - async fn simple_get(&self, path: PathSegments<'_>) -> Result + async fn simple_get(&self, path: PathSegments<'_>) -> Result where T: DeserializeOwned, { let req = self .inner - .create_get_request(path, NO_PARAMS) + .create_get_request(path, NO_PARAMS)? .bearer_auth(&self.bearer_token) .send(); diff --git a/wasm/zknym-lib/src/vpn_api_client/mod.rs b/wasm/zknym-lib/src/vpn_api_client/mod.rs index 041e9f0bc1..366fa05443 100644 --- a/wasm/zknym-lib/src/vpn_api_client/mod.rs +++ b/wasm/zknym-lib/src/vpn_api_client/mod.rs @@ -1,12 +1,7 @@ // Copyright 2024 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::vpn_api_client::types::ErrorResponse; -use nym_http_api_client::HttpClientError; - #[cfg(test)] pub(crate) mod client; pub mod types; - -pub type NymVpnApiClientError = HttpClientError;