feat(provider): add option to create ws provider with auth
Currently `Provider::<Ws>` only exposes `connect` from `Ws` module.
This pull request exposes the `connect_with_auth` function added on 829.
@@ -8,7 +8,7 @@ use crate::{
};
#[cfg(not(target_arch = "wasm32"))]
-use crate::transports::{HttpRateLimitRetryPolicy, RetryClient};
+use crate::transports::{Authorization, HttpRateLimitRetryPolicy, RetryClient};
#[cfg(feature = "celo")]
use crate::CeloMiddleware;
@@ -1286,6 +1286,15 @@ impl Provider<crate::Ws> {
Ok(Self::new(ws))
}
+ #[cfg(not(target_arch = "wasm32"))]
+ pub async fn connect_with_auth(
+ url: impl tokio_tungstenite::tungstenite::client::IntoClientRequest + Unpin,
+ auth: Authorization,
+ ) -> Result<Self, ProviderError> {
+ let ws = crate::Ws::connect_with_auth(url, auth).await?;
+ Ok(Self::new(ws))
+ }
+
/// Direct connection to a websocket endpoint
#[cfg(target_arch = "wasm32")]
pub async fn connect(url: &str) -> Result<Self, ProviderError> {
