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.
This commit is contained in:
parent
295f86ef89
commit
c76f325b14
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use crate::transports::{HttpRateLimitRetryPolicy, RetryClient};
|
use crate::transports::{Authorization, HttpRateLimitRetryPolicy, RetryClient};
|
||||||
|
|
||||||
#[cfg(feature = "celo")]
|
#[cfg(feature = "celo")]
|
||||||
use crate::CeloMiddleware;
|
use crate::CeloMiddleware;
|
||||||
|
@ -1286,6 +1286,15 @@ impl Provider<crate::Ws> {
|
||||||
Ok(Self::new(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
|
/// Direct connection to a websocket endpoint
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
pub async fn connect(url: &str) -> Result<Self, ProviderError> {
|
pub async fn connect(url: &str) -> Result<Self, ProviderError> {
|
||||||
|
|
Loading…
Reference in New Issue