From c047aba5a3bdf4f750a1782f30b7ee1d13687f12 Mon Sep 17 00:00:00 2001 From: zerosnacks Date: Mon, 1 Apr 2024 15:40:58 +0000 Subject: [PATCH] use RootProvider in specific cases, keeping examples as is --- examples/providers/examples/ipc.rs | 5 +++-- examples/providers/examples/ws.rs | 5 +++-- examples/providers/examples/ws_with_auth.rs | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/providers/examples/ipc.rs b/examples/providers/examples/ipc.rs index 0301e583..d5dccbbd 100644 --- a/examples/providers/examples/ipc.rs +++ b/examples/providers/examples/ipc.rs @@ -1,6 +1,7 @@ //! Example of using the IPC provider to get the latest block number. -use alloy_provider::{Provider, ProviderBuilder}; +use alloy_network::Ethereum; +use alloy_provider::{Provider, RootProvider}; use alloy_rpc_client::RpcClient; use alloy_transport_ipc::IpcConnect; use eyre::Result; @@ -17,7 +18,7 @@ async fn main() -> Result<()> { let ipc_client = RpcClient::connect_pubsub(ipc).await?; // Create the provider. - let provider = ProviderBuilder::new().on_client(ipc_client); + let provider = RootProvider::<_, Ethereum>::new(ipc_client); let latest_block = provider.get_block_number().await?; diff --git a/examples/providers/examples/ws.rs b/examples/providers/examples/ws.rs index 11de14ce..2da07e91 100644 --- a/examples/providers/examples/ws.rs +++ b/examples/providers/examples/ws.rs @@ -1,7 +1,8 @@ //! Example of using the WS provider to subscribe to new blocks. // Temp Fix -use alloy_provider::{Provider, ProviderBuilder}; +use alloy_network::Ethereum; +use alloy_provider::{Provider, RootProvider}; use alloy_rpc_client::{RpcClient, WsConnect}; // use eyre::Result; @@ -19,7 +20,7 @@ async fn main() -> Result<()> { let rpc_client = RpcClient::connect_pubsub(ws_transport).await?; // Create the provider. - let provider = ProviderBuilder::new().on_client(rpc_client); + let provider = RootProvider::<_, Ethereum>::new(rpc_client); // Subscribe to new blocks. let sub = provider.subscribe_blocks().await?; diff --git a/examples/providers/examples/ws_with_auth.rs b/examples/providers/examples/ws_with_auth.rs index eeac35e4..29fe2c8c 100644 --- a/examples/providers/examples/ws_with_auth.rs +++ b/examples/providers/examples/ws_with_auth.rs @@ -1,7 +1,8 @@ //! Example of using the WS provider with auth to subscribe to new blocks. // Temp Fix -use alloy_provider::{Provider, ProviderBuilder}; +use alloy_network::Ethereum; +use alloy_provider::{Provider, RootProvider}; use alloy_rpc_client::{RpcClient, WsConnect}; use alloy_transport::Authorization; // @@ -26,8 +27,8 @@ async fn main() -> Result<()> { let rpc_client_bearer = RpcClient::connect_pubsub(ws_transport_bearer).await?; // Create the provider. - let provider_basic = ProviderBuilder::new().on_client(rpc_client_basic); - let provider_bearer = ProviderBuilder::new().on_client(rpc_client_bearer); + let provider_basic = RootProvider::<_, Ethereum>::new(rpc_client_basic); + let provider_bearer = RootProvider::<_, Ethereum>::new(rpc_client_bearer); // Subscribe to new blocks. let sub_basic = provider_basic.subscribe_blocks();