From c76f325b147770edc62c6cf8af7f5baa09a102ff Mon Sep 17 00:00:00 2001 From: Resende <17102689+ZePedroResende@users.noreply.github.com> Date: Thu, 9 Jun 2022 08:45:33 +0100 Subject: [PATCH] feat(provider): add option to create ws provider with auth (#1363) Currently `Provider::` only exposes `connect` from `Ws` module. This pull request exposes the `connect_with_auth` function added on 829. --- ethers-providers/src/provider.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ethers-providers/src/provider.rs b/ethers-providers/src/provider.rs index 4709e89f..a8b4f22f 100644 --- a/ethers-providers/src/provider.rs +++ b/ethers-providers/src/provider.rs @@ -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 { 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 { + 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 {