Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Commit c76f325

Browse files
feat(provider): add option to create ws provider with auth (#1363)
Currently `Provider::<Ws>` only exposes `connect` from `Ws` module. This pull request exposes the `connect_with_auth` function added on 829.
1 parent 295f86e commit c76f325

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: ethers-providers/src/provider.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
};
99

1010
#[cfg(not(target_arch = "wasm32"))]
11-
use crate::transports::{HttpRateLimitRetryPolicy, RetryClient};
11+
use crate::transports::{Authorization, HttpRateLimitRetryPolicy, RetryClient};
1212

1313
#[cfg(feature = "celo")]
1414
use crate::CeloMiddleware;
@@ -1286,6 +1286,15 @@ impl Provider<crate::Ws> {
12861286
Ok(Self::new(ws))
12871287
}
12881288

1289+
#[cfg(not(target_arch = "wasm32"))]
1290+
pub async fn connect_with_auth(
1291+
url: impl tokio_tungstenite::tungstenite::client::IntoClientRequest + Unpin,
1292+
auth: Authorization,
1293+
) -> Result<Self, ProviderError> {
1294+
let ws = crate::Ws::connect_with_auth(url, auth).await?;
1295+
Ok(Self::new(ws))
1296+
}
1297+
12891298
/// Direct connection to a websocket endpoint
12901299
#[cfg(target_arch = "wasm32")]
12911300
pub async fn connect(url: &str) -> Result<Self, ProviderError> {

0 commit comments

Comments
 (0)