Skip to content

Commit e980a8b

Browse files
authored
feat: Support polkadot EVM clients (#389)
1 parent 8e37542 commit e980a8b

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"network_type": "EVM",
3+
"slug": "polkadot_westend",
4+
"name": "Polkadot Westend",
5+
"rpc_urls": [
6+
{
7+
"type_": "rpc",
8+
"url": {
9+
"type": "plain",
10+
"value": "https://westend-asset-hub-eth-rpc.polkadot.io"
11+
},
12+
"weight": 100
13+
}
14+
],
15+
"chain_id": 420420421,
16+
"block_time_ms": 6000,
17+
"confirmation_blocks": 3,
18+
"cron_schedule": "0 */1 * * * *",
19+
"store_blocks": false
20+
}

src/services/blockchain/transports/http.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,20 @@ impl HttpTransportClient {
6868
.collect();
6969

7070
rpc_urls.sort_by(|a, b| b.weight.cmp(&a.weight));
71-
7271
// Create a retry policy with default settings
7372
// Shared config for endpoint manager and test connection
7473
let http_retry_config = RetryConfig::default();
75-
7674
// Create the base HTTP client
7775
let base_http_client = Arc::new(
7876
reqwest::ClientBuilder::new()
7977
.pool_idle_timeout(Duration::from_secs(90))
8078
.pool_max_idle_per_host(32)
8179
.timeout(Duration::from_secs(30))
8280
.connect_timeout(Duration::from_secs(20))
81+
.use_rustls_tls()
8382
.build()
8483
.context("Failed to create base HTTP client")?,
8584
);
86-
8785
// Create a retryable HTTP client with the base client and retry policy
8886
// Shared across:
8987
// - EndpointManager for handling endpoint rotation
@@ -93,13 +91,11 @@ impl HttpTransportClient {
9391
(*base_http_client).clone(),
9492
Some(TransientErrorRetryStrategy),
9593
);
96-
9794
for rpc_url in rpc_urls.iter() {
9895
let url = match Url::parse(rpc_url.url.as_ref()) {
9996
Ok(url) => url,
10097
Err(_) => continue,
10198
};
102-
10399
let test_request = if let Some(test_payload) = &test_connection_payload {
104100
serde_json::from_str(test_payload)
105101
.context("Failed to parse test payload as JSON")?
@@ -111,22 +107,19 @@ impl HttpTransportClient {
111107
"params": []
112108
})
113109
};
114-
115110
// Attempt to connect to the endpoint
116111
let request_result = retryable_client
117112
.post(url.clone())
118113
.json(&test_request)
119114
.send()
120115
.await;
121-
122116
match request_result {
123117
Ok(response) => {
124118
// Check if the response indicates an error status (4xx or 5xx)
125119
if !response.status().is_success() {
126120
// Skip this URL if we got an error status
127121
continue;
128122
}
129-
130123
// Create list of fallback URLs (all URLs except the current one)
131124
let fallback_urls: Vec<String> = rpc_urls
132125
.iter()

0 commit comments

Comments
 (0)