Skip to content

Commit 5b55256

Browse files
committed
fix(aggregator-client): the crate was not fully wasm compatible
The `AggregatorClientBuilder::with_relay_endpoint` use reqwest proxy api which is not available on wasm platforms. This remove this method from the builder, it's doable since only the `mithril-signer` used it, no usage were made in the `mithril-client` library.
1 parent fdfb361 commit 5b55256

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/mithril-aggregator-client/src/builder.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Context;
2-
use reqwest::{Client, IntoUrl, Proxy, Url};
2+
use reqwest::{Client, IntoUrl, Url};
33
use slog::{Logger, o};
44
use std::collections::HashMap;
55
use std::sync::Arc;
@@ -16,6 +16,7 @@ pub struct AggregatorClientBuilder {
1616
api_version_provider: Option<Arc<APIVersionProvider>>,
1717
additional_headers: Option<HashMap<String, String>>,
1818
timeout_duration: Option<Duration>,
19+
#[cfg(not(target_family = "wasm"))]
1920
relay_endpoint: Option<String>,
2021
logger: Option<Logger>,
2122
}
@@ -30,6 +31,7 @@ impl AggregatorClientBuilder {
3031
api_version_provider: None,
3132
additional_headers: None,
3233
timeout_duration: None,
34+
#[cfg(not(target_family = "wasm"))]
3335
relay_endpoint: None,
3436
logger: None,
3537
}
@@ -63,6 +65,9 @@ impl AggregatorClientBuilder {
6365
}
6466

6567
/// Set the address of the relay
68+
///
69+
/// _Not available on wasm platforms_
70+
#[cfg(not(target_family = "wasm"))]
6671
pub fn with_relay_endpoint(mut self, relay_endpoint: Option<String>) -> Self {
6772
self.relay_endpoint = relay_endpoint;
6873
self
@@ -77,9 +82,15 @@ impl AggregatorClientBuilder {
7782
let logger = self.logger.unwrap_or_else(|| Logger::root(slog::Discard, o!()));
7883
let api_version_provider = self.api_version_provider.unwrap_or_default();
7984
let additional_headers = self.additional_headers.unwrap_or_default();
85+
#[cfg(not(target_family = "wasm"))]
8086
let mut client_builder = Client::builder();
87+
#[cfg(target_family = "wasm")]
88+
let client_builder = Client::builder();
8189

90+
#[cfg(not(target_family = "wasm"))]
8291
if let Some(relay_endpoint) = self.relay_endpoint {
92+
use reqwest::Proxy;
93+
8394
client_builder = client_builder
8495
.proxy(Proxy::all(relay_endpoint).with_context(|| "Relay proxy creation failed")?)
8596
}

0 commit comments

Comments
 (0)