Skip to content

Commit

Permalink
use RootProvider in specific cases, keeping examples as is
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks committed Apr 1, 2024
1 parent dd94da7 commit c047aba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions examples/providers/examples/ipc.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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?;

Expand Down
5 changes: 3 additions & 2 deletions examples/providers/examples/ws.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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?;
Expand Down
7 changes: 4 additions & 3 deletions examples/providers/examples/ws_with_auth.rs
Original file line number Diff line number Diff line change
@@ -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;
//
Expand All @@ -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();
Expand Down

0 comments on commit c047aba

Please sign in to comment.