From 908273d46183e11af1a16fbc4c61c1da7bd8bbc4 Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Tue, 24 Oct 2023 21:17:30 -0300 Subject: [PATCH] fix: use `SafeUrl` as &str, jsonrpsee 0.20.0 fixed the issue - the previous issue with jsonrpsee correctly parsing the &str from SafeUrl seems to be solved on the latest 0.20.0 release, as per the discussion and CHANGELOG: https://github.com/paritytech/jsonrpsee/blob/v0.20.x/CHANGELOG.md#changed-2 and PR: https://github.com/paritytech/jsonrpsee/pull/1172 --- fedimint-core/src/api.rs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/fedimint-core/src/api.rs b/fedimint-core/src/api.rs index e7a0679a8b1..e27810d0e33 100644 --- a/fedimint-core/src/api.rs +++ b/fedimint-core/src/api.rs @@ -726,13 +726,13 @@ impl JsonRpcClient for WsClient { return WsClientBuilder::default() .use_webpki_rustls() .max_concurrent_requests(u16::MAX as usize) - .build(url_to_string_with_default_port(url)) // Hack for default ports, see fn docs + .build(url.as_str()) // Hack for default ports, see fn docs .await; #[cfg(target_family = "wasm")] WsClientBuilder::default() .max_concurrent_requests(u16::MAX as usize) - .build(url_to_string_with_default_port(url)) // Hack for default ports, see fn docs + .build(url.as_str()) // Hack for default ports, see fn docs .await } @@ -862,24 +862,6 @@ impl FederationPeer { } } -/// `jsonrpsee` converts the `SafeUrl` to a `&str` internally and then parses it -/// as an `Uri`. Unfortunately the underlying `Url` type swallows ports that it -/// considers default ports (e.g. 80 and 443 for HTTP(S)) which makes the `Uri` -/// parsing fail in these cases. This function works around this limitation in a -/// limited way (not fully standard compliant, but work for our use case). -/// -/// See -fn url_to_string_with_default_port(url: &SafeUrl) -> String { - format!( - "{}://{}:{}{}", - url.scheme(), - url.host().expect("Asserted on construction"), - url.port_or_known_default() - .expect("Asserted on construction"), - url.path() - ) -} - impl WsFederationApi {} /// The status of a server, including how it views its peers