diff --git a/Cargo.toml b/Cargo.toml index 9b3e1272..39add3d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] version = "0.1.0" edition = "2021" -rust-version = "1.81" +rust-version = "1.83" authors = ["Alloy Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/alloy-rs/examples" @@ -95,7 +95,7 @@ significant_drop_tightening = "allow" needless_return = "allow" [workspace.dependencies] -alloy = { version = "0.14", features = [ +alloy = { version = "0.15", features = [ "eips", "full", "json-rpc", @@ -114,7 +114,7 @@ alloy = { version = "0.14", features = [ # async futures-util = "0.3" -tokio = "1.44" +tokio = "1.45" # misc eyre = "0.6" diff --git a/benches/benches/rlp.rs b/benches/benches/rlp.rs index 24d70f1c..709b8117 100644 --- a/benches/benches/rlp.rs +++ b/benches/benches/rlp.rs @@ -28,13 +28,13 @@ fn rlp(c: &mut Criterion) { g.bench_with_input("Alloy-Rlp/Encoding", &my_struct, |b, my_struct| { b.iter(|| { let mut out = Vec::new(); - let _ = my_struct.encode(&mut out); + my_struct.encode(&mut out); black_box(out); }) }); let mut encoded = Vec::new(); - let _ = my_struct.encode(&mut encoded); + my_struct.encode(&mut encoded); // Parity RLP decoding g.bench_with_input("Parity-Rlp/Decoding", &encoded, |b, encoded| { diff --git a/clippy.toml b/clippy.toml index 8c0bc009..f234c901 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.81" +msrv = "1.83" diff --git a/examples/advanced/Cargo.toml b/examples/advanced/Cargo.toml index 42ea215c..2f6b290a 100644 --- a/examples/advanced/Cargo.toml +++ b/examples/advanced/Cargo.toml @@ -14,16 +14,16 @@ workspace = true [dev-dependencies] alloy.workspace = true -# foundry-fork-db = "0.12" +# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db.git", rev = "cdbbe64" } -# # reth -# revm-primitives = { version = "17.0.0", default-features = false } -# revm = { version = "21.0.0", default-features = false } -# reth-db = { git = "https://github.com/paradigmxyz/reth", package = "reth-db", rev = "v1.3.8" } -# reth-provider = { git = "https://github.com/paradigmxyz/reth", package = "reth-provider", rev = "v1.3.8" } -# reth-node-types = { git = "https://github.com/paradigmxyz/reth", package = "reth-node-types", rev = "v1.3.8" } -# reth-chainspec = { git = "https://github.com/paradigmxyz/reth", package = "reth-chainspec", rev = "v1.3.8" } -# reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", package = "reth-node-ethereum", rev = "v1.3.8" } +# reth +# revm = { version = "22.0.1", default-features = false } +# revm-primitives = { version = "18.0.0", default-features = false } +# reth-db = { git = "https://github.com/paradigmxyz/reth", package = "reth-db", rev = "7029951" } +# reth-provider = { git = "https://github.com/paradigmxyz/reth", package = "reth-provider", rev = "7029951" } +# reth-node-types = { git = "https://github.com/paradigmxyz/reth", package = "reth-node-types", rev = "7029951" } +# reth-chainspec = { git = "https://github.com/paradigmxyz/reth", package = "reth-chainspec", rev = "7029951" } +# reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", package = "reth-node-ethereum", rev = "7029951" } eyre.workspace = true tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } diff --git a/examples/advanced/examples/any_network.rs b/examples/advanced/examples/any_network.rs index 2ed9023e..a0b351bc 100644 --- a/examples/advanced/examples/any_network.rs +++ b/examples/advanced/examples/any_network.rs @@ -48,7 +48,8 @@ async fn main() -> Result<()> { // Create a provider with the Arbitrum Sepolia network and the wallet. let rpc_url = "https://sepolia-rollup.arbitrum.io/rpc".parse()?; - let provider = ProviderBuilder::new().network::().wallet(signer).on_http(rpc_url); + let provider = + ProviderBuilder::new().network::().wallet(signer).connect_http(rpc_url); // Create a contract instance. let contract = Counter::new(COUNTER_CONTRACT_ADDRESS, &provider); @@ -62,8 +63,8 @@ async fn main() -> Result<()> { let l1_gas = arb_fields.gas_used_for_l1.to::(); let l1_block_number = arb_fields.l1_block_number.to::(); - println!("Gas used for L1: {}", l1_gas); - println!("L1 block number: {}", l1_block_number); + println!("Gas used for L1: {l1_gas}"); + println!("L1 block number: {l1_block_number}"); Ok(()) } diff --git a/examples/advanced/examples/decoding_json_abi.rs b/examples/advanced/examples/decoding_json_abi.rs index ab0b5acb..9a633880 100644 --- a/examples/advanced/examples/decoding_json_abi.rs +++ b/examples/advanced/examples/decoding_json_abi.rs @@ -23,7 +23,7 @@ fn main() -> Result<(), Box> { // Functions println!("Functions:"); for (name, functions) in &abi.functions { - println!("\n>> {}:", name); + println!("\n>> {name}:"); for function in functions { println!(" Inputs: {:?}", function.inputs); println!(" Outputs: {:?}", function.outputs); @@ -36,7 +36,7 @@ fn main() -> Result<(), Box> { // Events println!("Events:"); for (name, events) in &abi.events { - println!("\n>> {}:", name); + println!("\n>> {name}:"); for event in events { println!(" Inputs: {:?}", event.inputs); println!(" Anonymous: {}", event.anonymous); @@ -48,7 +48,7 @@ fn main() -> Result<(), Box> { // Errors println!("Errors:"); for (name, errors) in &abi.errors { - println!(">> {}:", name); + println!(">> {name}:"); for error in errors { println!(" Inputs: {:?}", error.inputs); } diff --git a/examples/advanced/examples/encoding_dyn_abi.rs b/examples/advanced/examples/encoding_dyn_abi.rs index 8215fb45..a527ac35 100644 --- a/examples/advanced/examples/encoding_dyn_abi.rs +++ b/examples/advanced/examples/encoding_dyn_abi.rs @@ -75,7 +75,7 @@ async fn main() -> Result<(), Box> { // Verify the signature let recovered_address = signature.recover_address_from_prehash(&eip712_hash)?; - println!("Recovered address: {}", recovered_address); + println!("Recovered address: {recovered_address}"); assert_eq!(recovered_address, wallet.address(), "Signature verification failed"); println!("Signature verified successfully!"); @@ -87,7 +87,7 @@ async fn main() -> Result<(), Box> { fn print_tuple(value: &DynSolValue, field_names: &[&str]) { if let DynSolValue::Tuple(values) = value { for (value, name) in values.iter().zip(field_names.iter()) { - println!(" {}: {:?}", name, value); + println!(" {name}: {value:?}"); } } } diff --git a/examples/advanced/examples/encoding_sol_static.rs b/examples/advanced/examples/encoding_sol_static.rs index 1c4be7cc..07987b05 100644 --- a/examples/advanced/examples/encoding_sol_static.rs +++ b/examples/advanced/examples/encoding_sol_static.rs @@ -44,7 +44,7 @@ fn main() -> Result<(), Box> { let encoded = hex::encode(swapExactTokensForTokensCall::abi_encode(&swap_data)); - println!("Encoded: 0x{}", encoded); + println!("Encoded: 0x{encoded}"); Ok(()) } diff --git a/examples/advanced/examples/foundry_fork_db.rs b/examples/advanced/examples/foundry_fork_db.rs index 714c69cb..8f5fa444 100644 --- a/examples/advanced/examples/foundry_fork_db.rs +++ b/examples/advanced/examples/foundry_fork_db.rs @@ -6,151 +6,154 @@ //! //! `foundry_fork_db` serves as the backend for Foundry's forking functionality in Anvil and Forge. -use std::sync::Arc; - -use alloy::{ - consensus::BlockHeader, - eips::BlockId, - network::{AnyNetwork, AnyRpcBlock, TransactionBuilder}, - node_bindings::Anvil, - primitives::U256, - providers::{Provider, ProviderBuilder}, - rpc::types::TransactionRequest, -}; -use eyre::Result; -use foundry_fork_db::{cache::BlockchainDbMeta, BlockchainDb, SharedBackend}; -use revm::{db::CacheDB, DatabaseRef, Evm}; -use revm_primitives::{BlobExcessGasAndPrice, BlockEnv, TxEnv}; - -#[tokio::main] -async fn main() -> Result<()> { - let anvil = Anvil::new().spawn(); - let provider = ProviderBuilder::new().network::().on_http(anvil.endpoint_url()); - - let block = provider.get_block(BlockId::latest()).await?.unwrap(); - - // The `BlockchainDbMeta` is used a identifier when the db is flushed to the disk. - // This aids in cases where the disk contains data from multiple forks. - let meta = BlockchainDbMeta::default() - .with_chain_id(31337) - .with_block(&block.inner) - .with_url(&anvil.endpoint()); - - let db = BlockchainDb::new(meta, None); - - // Spawn the backend with the db instance. - // `SharedBackend` is used to send request to the `BackendHandler` which is responsible for - // filling missing data in the db, and also deduplicate requests that are being sent to the - // RPC provider. - // - // For example, if we send two requests to get_full_block(0) simultaneously, the - // `BackendHandler` is smart enough to only send one request to the RPC provider, and queue the - // other request until the response is received. - // Once the response from RPC provider is received it relays the response to both the requests - // over their respective channels. - // - // The `SharedBackend` and `BackendHandler` communicate over an unbounded channel. - let shared = SharedBackend::spawn_backend(Arc::new(provider.clone()), db, None).await; - - let start_t = std::time::Instant::now(); - let block_rpc = shared.get_full_block(0).unwrap(); - let time_rpc = start_t.elapsed(); - - // `SharedBackend` is cloneable and holds the channel to the same `BackendHandler`. - #[allow(clippy::redundant_clone)] - let cloned_backend = shared.clone(); - - // Block gets cached in the db - let start_t = std::time::Instant::now(); - let block_cache = cloned_backend.get_full_block(0).unwrap(); - let time_cache = start_t.elapsed(); - - assert_eq!(block_rpc, block_cache); - - println!("-------get_full_block--------"); - // The backend handle falls back to the RPC provider if the block is not in the cache. - println!("1st request (via rpc): {:?}", time_rpc); - // The block is cached due to the previous request and can be fetched from db. - println!("2nd request (via fork db): {:?}\n", time_cache); - - let alice = anvil.addresses()[0]; - let bob = anvil.addresses()[1]; - - let basefee = block.header.base_fee_per_gas.unwrap(); - - let tx_req = TransactionRequest::default() - .with_from(alice) - .with_to(bob) - .with_value(U256::from(100)) - .with_max_fee_per_gas(basefee as u128) - .with_max_priority_fee_per_gas(basefee as u128 + 1) - .with_gas_limit(21000) - .with_nonce(0); - - let mut evm = configure_evm_env(block, shared.clone(), configure_tx_env(tx_req)); - - // Fetches accounts from the RPC - let start_t = std::time::Instant::now(); - let alice_bal = shared.basic_ref(alice)?.unwrap().balance; - let bob_bal = shared.basic_ref(bob)?.unwrap().balance; - let time_rpc = start_t.elapsed(); - - let res = evm.transact().unwrap(); - - let total_spent = U256::from(res.result.gas_used()) * U256::from(basefee) + U256::from(100); - - shared.data().do_commit(res.state); - - // Fetches accounts from the cache - let start_t = std::time::Instant::now(); - let alice_bal_after = shared.basic_ref(alice)?.unwrap().balance; - let bob_bal_after = shared.basic_ref(bob)?.unwrap().balance; - let time_cache = start_t.elapsed(); - - println!("-------get_account--------"); - println!("1st request (via rpc): {:?}", time_rpc); - println!("2nd request (via fork db): {:?}\n", time_cache); - - assert_eq!(alice_bal_after, alice_bal - total_spent); - assert_eq!(bob_bal_after, bob_bal + U256::from(100)); - - Ok(()) -} - -fn configure_evm_env( - block: AnyRpcBlock, - shared: SharedBackend, - tx_env: TxEnv, -) -> Evm<'static, (), CacheDB> { - let basefee = block.header.base_fee_per_gas().map(U256::from).unwrap_or_default(); - let block_env = BlockEnv { - number: U256::from(block.header.number()), - coinbase: block.header.beneficiary(), - timestamp: U256::from(block.header.timestamp()), - gas_limit: U256::from(block.header.gas_limit()), - basefee, - prevrandao: block.header.mix_hash(), - difficulty: block.header.difficulty(), - blob_excess_gas_and_price: Some(BlobExcessGasAndPrice::new( - block.header.excess_blob_gas().unwrap_or_default(), - false, - )), - }; - - let db = CacheDB::new(shared); - - let evm = Evm::builder().with_block_env(block_env).with_db(db).with_tx_env(tx_env).build(); - - evm -} - -fn configure_tx_env(tx_req: TransactionRequest) -> TxEnv { - TxEnv { - caller: tx_req.from.unwrap(), - transact_to: tx_req.to.unwrap(), - value: tx_req.value.unwrap(), - gas_price: U256::from(tx_req.max_fee_per_gas.unwrap()), - gas_limit: tx_req.gas.unwrap_or_default(), - ..Default::default() - } -} +// use std::sync::Arc; + +// use alloy::{ +// consensus::BlockHeader, +// eips::BlockId, +// network::{AnyNetwork, AnyRpcBlock, TransactionBuilder}, +// node_bindings::Anvil, +// primitives::U256, +// providers::{Provider, ProviderBuilder}, +// rpc::types::TransactionRequest, +// }; +// use eyre::Result; +// use foundry_fork_db::{cache::BlockchainDbMeta, BlockchainDb, SharedBackend}; +// use revm::{db::CacheDB, DatabaseRef, Evm}; +// use revm_primitives::{BlobExcessGasAndPrice, BlockEnv, TxEnv}; + +// #[tokio::main] +// async fn main() -> Result<()> { +// let anvil = Anvil::new().spawn(); +// let provider = +// ProviderBuilder::new().network::().connect_http(anvil.endpoint_url()); + +// let block = provider.get_block(BlockId::latest()).await?.unwrap(); + +// // The `BlockchainDbMeta` is used a identifier when the db is flushed to the disk. +// // This aids in cases where the disk contains data from multiple forks. +// let meta = BlockchainDbMeta::default() +// .with_chain_id(31337) +// .with_block(&block.inner) +// .with_url(&anvil.endpoint()); + +// let db = BlockchainDb::new(meta, None); + +// // Spawn the backend with the db instance. +// // `SharedBackend` is used to send request to the `BackendHandler` which is responsible for +// // filling missing data in the db, and also deduplicate requests that are being sent to the +// // RPC provider. +// // +// // For example, if we send two requests to get_full_block(0) simultaneously, the +// // `BackendHandler` is smart enough to only send one request to the RPC provider, and queue +// the // other request until the response is received. +// // Once the response from RPC provider is received it relays the response to both the +// requests // over their respective channels. +// // +// // The `SharedBackend` and `BackendHandler` communicate over an unbounded channel. +// let shared = SharedBackend::spawn_backend(Arc::new(provider.clone()), db, None).await; + +// let start_t = std::time::Instant::now(); +// let block_rpc = shared.get_full_block(0).unwrap(); +// let time_rpc = start_t.elapsed(); + +// // `SharedBackend` is cloneable and holds the channel to the same `BackendHandler`. +// #[allow(clippy::redundant_clone)] +// let cloned_backend = shared.clone(); + +// // Block gets cached in the db +// let start_t = std::time::Instant::now(); +// let block_cache = cloned_backend.get_full_block(0).unwrap(); +// let time_cache = start_t.elapsed(); + +// assert_eq!(block_rpc, block_cache); + +// println!("-------get_full_block--------"); +// // The backend handle falls back to the RPC provider if the block is not in the cache. +// println!("1st request (via rpc): {:?}", time_rpc); +// // The block is cached due to the previous request and can be fetched from db. +// println!("2nd request (via fork db): {:?}\n", time_cache); + +// let alice = anvil.addresses()[0]; +// let bob = anvil.addresses()[1]; + +// let basefee = block.header.base_fee_per_gas.unwrap(); + +// let tx_req = TransactionRequest::default() +// .with_from(alice) +// .with_to(bob) +// .with_value(U256::from(100)) +// .with_max_fee_per_gas(basefee as u128) +// .with_max_priority_fee_per_gas(basefee as u128 + 1) +// .with_gas_limit(21000) +// .with_nonce(0); + +// let mut evm = configure_evm_env(block, shared.clone(), configure_tx_env(tx_req)); + +// // Fetches accounts from the RPC +// let start_t = std::time::Instant::now(); +// let alice_bal = shared.basic_ref(alice)?.unwrap().balance; +// let bob_bal = shared.basic_ref(bob)?.unwrap().balance; +// let time_rpc = start_t.elapsed(); + +// let res = evm.transact().unwrap(); + +// let total_spent = U256::from(res.result.gas_used()) * U256::from(basefee) + U256::from(100); + +// shared.data().do_commit(res.state); + +// // Fetches accounts from the cache +// let start_t = std::time::Instant::now(); +// let alice_bal_after = shared.basic_ref(alice)?.unwrap().balance; +// let bob_bal_after = shared.basic_ref(bob)?.unwrap().balance; +// let time_cache = start_t.elapsed(); + +// println!("-------get_account--------"); +// println!("1st request (via rpc): {:?}", time_rpc); +// println!("2nd request (via fork db): {:?}\n", time_cache); + +// assert_eq!(alice_bal_after, alice_bal - total_spent); +// assert_eq!(bob_bal_after, bob_bal + U256::from(100)); + +// Ok(()) +// } + +// fn configure_evm_env( +// block: AnyRpcBlock, +// shared: SharedBackend, +// tx_env: TxEnv, +// ) -> Evm<'static, (), CacheDB> { +// let basefee = block.header.base_fee_per_gas().map(U256::from).unwrap_or_default(); +// let block_env = BlockEnv { +// number: U256::from(block.header.number()), +// coinbase: block.header.beneficiary(), +// timestamp: U256::from(block.header.timestamp()), +// gas_limit: U256::from(block.header.gas_limit()), +// basefee, +// prevrandao: block.header.mix_hash(), +// difficulty: block.header.difficulty(), +// blob_excess_gas_and_price: Some(BlobExcessGasAndPrice::new( +// block.header.excess_blob_gas().unwrap_or_default(), +// false, +// )), +// }; + +// let db = CacheDB::new(shared); + +// let evm = Evm::builder().with_block_env(block_env).with_db(db).with_tx_env(tx_env).build(); + +// evm +// } + +// fn configure_tx_env(tx_req: TransactionRequest) -> TxEnv { +// TxEnv { +// caller: tx_req.from.unwrap(), +// transact_to: tx_req.to.unwrap(), +// value: tx_req.value.unwrap(), +// gas_price: U256::from(tx_req.max_fee_per_gas.unwrap()), +// gas_limit: tx_req.gas.unwrap_or_default(), +// ..Default::default() +// } +// } + +const fn main() {} diff --git a/examples/advanced/examples/reth_db_layer.rs b/examples/advanced/examples/reth_db_layer.rs index 9945d263..c8f7cf5c 100644 --- a/examples/advanced/examples/reth_db_layer.rs +++ b/examples/advanced/examples/reth_db_layer.rs @@ -1,24 +1,24 @@ //! `RethDbLayer` implementation to be used with `RethDbProvider` to wrap the Provider trait over //! reth-db. -#![allow(dead_code)] -use std::path::PathBuf; +// #![allow(dead_code)] +// use std::path::PathBuf; -/// We use the tower-like layering functionality that has been baked into the alloy-provider to -/// intercept the requests and redirect to the `RethDbProvider`. -pub(crate) struct RethDbLayer { - db_path: PathBuf, -} +// /// We use the tower-like layering functionality that has been baked into the alloy-provider to +// /// intercept the requests and redirect to the `RethDbProvider`. +// pub(crate) struct RethDbLayer { +// db_path: PathBuf, +// } -/// Initialize the `RethDBLayer` with the path to the reth datadir. -impl RethDbLayer { - pub(crate) const fn new(db_path: PathBuf) -> Self { - Self { db_path } - } +// /// Initialize the `RethDBLayer` with the path to the reth datadir. +// impl RethDbLayer { +// pub(crate) const fn new(db_path: PathBuf) -> Self { +// Self { db_path } +// } - pub(crate) const fn db_path(&self) -> &PathBuf { - &self.db_path - } -} +// pub(crate) const fn db_path(&self) -> &PathBuf { +// &self.db_path +// } +// } const fn main() {} diff --git a/examples/advanced/examples/reth_db_provider.rs b/examples/advanced/examples/reth_db_provider.rs index b6f24dd1..73a20f08 100644 --- a/examples/advanced/examples/reth_db_provider.rs +++ b/examples/advanced/examples/reth_db_provider.rs @@ -11,214 +11,218 @@ //! //! Learn more about `ProviderCall` [here](https://github.com/alloy-rs/alloy/pull/788). -use std::{path::PathBuf, sync::Arc}; - -use alloy::{ - eips::{BlockId, BlockNumberOrTag}, - node_bindings::{utils::run_with_tempdir, Reth}, - primitives::{address, Address, U64}, - providers::{ - Provider, ProviderBuilder, ProviderCall, ProviderLayer, RootProvider, RpcWithBlock, - }, - rpc::client::NoParams, - transports::TransportErrorKind, -}; -use eyre::Result; - -use reth_chainspec::ChainSpecBuilder; -use reth_db::{open_db_read_only, DatabaseEnv}; -use reth_node_ethereum::EthereumNode; -use reth_node_types::NodeTypesWithDBAdapter; -use reth_provider::{ - providers::StaticFileProvider, BlockNumReader, DatabaseProviderFactory, ProviderError, - ProviderFactory, StateProvider, TryIntoHistoricalStateProvider, -}; -mod reth_db_layer; -use reth_db_layer::RethDbLayer; - -#[tokio::main] -async fn main() -> Result<()> { - run_with_tempdir("provider-call-reth-db", |data_dir| async move { - // Initializing reth with a tmp data directory. - // We use a tmp directory for the purposes of this example. - // This would actually use an existing reth datadir specified by `--datadir` when starting - // your reth node. - let reth = Reth::new() - .dev() - .disable_discovery() - .block_time("1s") - .data_dir(data_dir.clone()) - .spawn(); - - let db_path = data_dir.join("db"); - - // Initialize the provider with the reth-db layer. The reth-db layer intercepts the rpc - // requests and returns the results from the reth-db database. - // Any RPC method that is not implemented in the RethDbProvider gracefully falls back to the - // RPC provider specified in the `on_http` method. - let provider = - ProviderBuilder::new().layer(RethDbLayer::new(db_path)).on_http(reth.endpoint_url()); - - // Initialize the RPC provider to compare the time taken to fetch the results. - let rpc_provider = ProviderBuilder::new().on_http(reth.endpoint_url()); - - println!("--------get_block_number---------"); - - let start_t = std::time::Instant::now(); - let latest_block_db = provider.get_block_number().await.unwrap(); - println!("via reth-db: {:?}", start_t.elapsed()); - - let start_t = std::time::Instant::now(); - let latest_block_rpc = rpc_provider.get_block_number().await.unwrap(); - println!("via rpc: {:?}\n", start_t.elapsed()); - - assert_eq!(latest_block_db, latest_block_rpc); - - println!("------get_transaction_count------"); - - let alice = address!("14dC79964da2C08b23698B3D3cc7Ca32193d9955"); - - let start_t = std::time::Instant::now(); - let nonce_db = - provider.get_transaction_count(alice).block_id(BlockId::latest()).await.unwrap(); - println!("via reth-db: {:?}", start_t.elapsed()); - - let start_t = std::time::Instant::now(); - let nonce_rpc = - rpc_provider.get_transaction_count(alice).block_id(BlockId::latest()).await.unwrap(); - println!("via rpc: {:?}\n", start_t.elapsed()); - - assert_eq!(nonce_db, nonce_rpc); - }) - .await; - - Ok(()) -} - -/// Implement the `ProviderLayer` trait for the `RethDBLayer` struct. -impl

ProviderLayer

for RethDbLayer -where - P: Provider, -{ - type Provider = RethDbProvider

; - - fn layer(&self, inner: P) -> Self::Provider { - RethDbProvider::new(inner, self.db_path().clone()) - } -} - -/// A provider that overrides the vanilla `Provider` trait to get results from the reth-db. -/// -/// It holds the `reth_provider::ProviderFactory` that enables read-only access to the database -/// tables and static files. -#[derive(Clone, Debug)] -pub struct RethDbProvider

{ - inner: P, - db_path: PathBuf, - provider_factory: DbAccessor, -} - -impl

RethDbProvider

{ - /// Create a new `RethDbProvider` instance. - pub fn new(inner: P, db_path: PathBuf) -> Self { - let db = open_db_read_only(&db_path, Default::default()).unwrap(); - let chain_spec = ChainSpecBuilder::mainnet().build(); - let static_file_provider = - StaticFileProvider::read_only(db_path.join("static_files"), false).unwrap(); - - let provider_factory = - ProviderFactory::new(db.into(), chain_spec.into(), static_file_provider); - - let db_accessor: DbAccessor< - ProviderFactory>>, - > = DbAccessor::new(provider_factory); - Self { inner, db_path, provider_factory: db_accessor } - } - - const fn factory(&self) -> &DbAccessor { - &self.provider_factory - } - - /// Get the DB Path - pub fn db_path(&self) -> PathBuf { - self.db_path.clone() - } -} - -/// Implement the `Provider` trait for the `RethDbProvider` struct. -/// -/// This is where we override specific RPC methods to fetch from the reth-db. -impl

Provider for RethDbProvider

-where - P: Provider, -{ - fn root(&self) -> &RootProvider { - self.inner.root() - } - - /// Override the `get_block_number` method to fetch the latest block number from the reth-db. - fn get_block_number(&self) -> ProviderCall { - let provider = self.factory().provider().map_err(TransportErrorKind::custom).unwrap(); - - let best = provider.best_block_number().map_err(TransportErrorKind::custom); - - ProviderCall::ready(best) - } - - /// Override the `get_transaction_count` method to fetch the transaction count of an address. - /// - /// `RpcWithBlock` uses `ProviderCall` under the hood. - fn get_transaction_count(&self, address: Address) -> RpcWithBlock { - let this = self.factory().clone(); - RpcWithBlock::new_provider(move |block_id| { - let provider = this.provider_at(block_id).map_err(TransportErrorKind::custom).unwrap(); - - let maybe_acc = - provider.basic_account(&address).map_err(TransportErrorKind::custom).unwrap(); - - let nonce = maybe_acc.map(|acc| acc.nonce).unwrap_or_default(); - - ProviderCall::ready(Ok(nonce)) - }) - } -} - -/// A helper type to get the appropriate DB provider. -#[derive(Debug, Clone)] -struct DbAccessor>>> -where - DB: DatabaseProviderFactory, -{ - inner: DB, -} - -impl DbAccessor -where - DB: DatabaseProviderFactory, -{ - const fn new(inner: DB) -> Self { - Self { inner } - } - - fn provider(&self) -> Result { - self.inner.database_provider_ro() - } - - fn provider_at(&self, block_id: BlockId) -> Result, ProviderError> { - let provider = self.inner.database_provider_ro()?; - - let block_number = match block_id { - BlockId::Hash(hash) => { - if let Some(num) = provider.block_number(hash.into())? { - num - } else { - return Err(ProviderError::BlockHashNotFound(hash.into())); - } - } - BlockId::Number(BlockNumberOrTag::Number(num)) => num, - _ => provider.best_block_number()?, - }; - - provider.try_into_history_at_block(block_number) - } -} +// use std::{path::PathBuf, sync::Arc}; + +// use alloy::{ +// eips::{BlockId, BlockNumberOrTag}, +// node_bindings::{utils::run_with_tempdir, Reth}, +// primitives::{address, Address, U64}, +// providers::{ +// Provider, ProviderBuilder, ProviderCall, ProviderLayer, RootProvider, RpcWithBlock, +// }, +// rpc::client::NoParams, +// transports::TransportErrorKind, +// }; +// use eyre::Result; + +// use reth_chainspec::ChainSpecBuilder; +// use reth_db::{open_db_read_only, DatabaseEnv}; +// use reth_node_ethereum::EthereumNode; +// use reth_node_types::NodeTypesWithDBAdapter; +// use reth_provider::{ +// providers::StaticFileProvider, BlockNumReader, DatabaseProviderFactory, ProviderError, +// ProviderFactory, StateProvider, TryIntoHistoricalStateProvider, +// }; +// mod reth_db_layer; +// use reth_db_layer::RethDbLayer; + +// #[tokio::main] +// async fn main() -> Result<()> { +// run_with_tempdir("provider-call-reth-db", |data_dir| async move { +// // Initializing reth with a tmp data directory. +// // We use a tmp directory for the purposes of this example. +// // This would actually use an existing reth datadir specified by `--datadir` when +// starting // your reth node. +// let reth = Reth::new() +// .dev() +// .disable_discovery() +// .block_time("1s") +// .data_dir(data_dir.clone()) +// .spawn(); + +// let db_path = data_dir.join("db"); + +// // Initialize the provider with the reth-db layer. The reth-db layer intercepts the rpc +// // requests and returns the results from the reth-db database. +// // Any RPC method that is not implemented in the RethDbProvider gracefully falls back to +// the // RPC provider specified in the `connect_http` method. +// let provider = ProviderBuilder::new() +// .layer(RethDbLayer::new(db_path)) +// .connect_http(reth.endpoint_url()); + +// // Initialize the RPC provider to compare the time taken to fetch the results. +// let rpc_provider = ProviderBuilder::new().connect_http(reth.endpoint_url()); + +// println!("--------get_block_number---------"); + +// let start_t = std::time::Instant::now(); +// let latest_block_db = provider.get_block_number().await.unwrap(); +// println!("via reth-db: {:?}", start_t.elapsed()); + +// let start_t = std::time::Instant::now(); +// let latest_block_rpc = rpc_provider.get_block_number().await.unwrap(); +// println!("via rpc: {:?}\n", start_t.elapsed()); + +// assert_eq!(latest_block_db, latest_block_rpc); + +// println!("------get_transaction_count------"); + +// let alice = address!("14dC79964da2C08b23698B3D3cc7Ca32193d9955"); + +// let start_t = std::time::Instant::now(); +// let nonce_db = +// provider.get_transaction_count(alice).block_id(BlockId::latest()).await.unwrap(); +// println!("via reth-db: {:?}", start_t.elapsed()); + +// let start_t = std::time::Instant::now(); +// let nonce_rpc = +// rpc_provider.get_transaction_count(alice).block_id(BlockId::latest()).await.unwrap(); +// println!("via rpc: {:?}\n", start_t.elapsed()); + +// assert_eq!(nonce_db, nonce_rpc); +// }) +// .await; + +// Ok(()) +// } + +// /// Implement the `ProviderLayer` trait for the `RethDBLayer` struct. +// impl

ProviderLayer

for RethDbLayer +// where +// P: Provider, +// { +// type Provider = RethDbProvider

; + +// fn layer(&self, inner: P) -> Self::Provider { +// RethDbProvider::new(inner, self.db_path().clone()) +// } +// } + +// /// A provider that overrides the vanilla `Provider` trait to get results from the reth-db. +// /// +// /// It holds the `reth_provider::ProviderFactory` that enables read-only access to the database +// /// tables and static files. +// #[derive(Clone, Debug)] +// pub struct RethDbProvider

{ +// inner: P, +// db_path: PathBuf, +// provider_factory: DbAccessor, +// } + +// impl

RethDbProvider

{ +// /// Create a new `RethDbProvider` instance. +// pub fn new(inner: P, db_path: PathBuf) -> Self { +// let db = open_db_read_only(&db_path, Default::default()).unwrap(); +// let chain_spec = ChainSpecBuilder::mainnet().build(); +// let static_file_provider = +// StaticFileProvider::read_only(db_path.join("static_files"), false).unwrap(); + +// let provider_factory = +// ProviderFactory::new(db.into(), chain_spec.into(), static_file_provider); + +// let db_accessor: DbAccessor< +// ProviderFactory>>, +// > = DbAccessor::new(provider_factory); +// Self { inner, db_path, provider_factory: db_accessor } +// } + +// const fn factory(&self) -> &DbAccessor { +// &self.provider_factory +// } + +// /// Get the DB Path +// pub fn db_path(&self) -> PathBuf { +// self.db_path.clone() +// } +// } + +// /// Implement the `Provider` trait for the `RethDbProvider` struct. +// /// +// /// This is where we override specific RPC methods to fetch from the reth-db. +// impl

Provider for RethDbProvider

+// where +// P: Provider, +// { +// fn root(&self) -> &RootProvider { +// self.inner.root() +// } + +// /// Override the `get_block_number` method to fetch the latest block number from the reth-db. +// fn get_block_number(&self) -> ProviderCall { +// let provider = self.factory().provider().map_err(TransportErrorKind::custom).unwrap(); + +// let best = provider.best_block_number().map_err(TransportErrorKind::custom); + +// ProviderCall::ready(best) +// } + +// /// Override the `get_transaction_count` method to fetch the transaction count of an address. +// /// +// /// `RpcWithBlock` uses `ProviderCall` under the hood. +// fn get_transaction_count(&self, address: Address) -> RpcWithBlock { +// let this = self.factory().clone(); +// RpcWithBlock::new_provider(move |block_id| { +// let provider = +// this.provider_at(block_id).map_err(TransportErrorKind::custom).unwrap(); + +// let maybe_acc = +// provider.basic_account(&address).map_err(TransportErrorKind::custom).unwrap(); + +// let nonce = maybe_acc.map(|acc| acc.nonce).unwrap_or_default(); + +// ProviderCall::ready(Ok(nonce)) +// }) +// } +// } + +// /// A helper type to get the appropriate DB provider. +// #[derive(Debug, Clone)] +// struct DbAccessor>>> +// where +// DB: DatabaseProviderFactory, +// { +// inner: DB, +// } + +// impl DbAccessor +// where +// DB: DatabaseProviderFactory, +// { +// const fn new(inner: DB) -> Self { +// Self { inner } +// } + +// fn provider(&self) -> Result { +// self.inner.database_provider_ro() +// } + +// fn provider_at(&self, block_id: BlockId) -> Result, ProviderError> { +// let provider = self.inner.database_provider_ro()?; + +// let block_number = match block_id { +// BlockId::Hash(hash) => { +// if let Some(num) = provider.block_number(hash.into())? { +// num +// } else { +// return Err(ProviderError::BlockHashNotFound(hash.into())); +// } +// } +// BlockId::Number(BlockNumberOrTag::Number(num)) => num, +// _ => provider.best_block_number()?, +// }; + +// provider.try_into_history_at_block(block_number) +// } +// } + +const fn main() {} diff --git a/examples/comparison/examples/compare_new_heads.rs b/examples/comparison/examples/compare_new_heads.rs index 96f906b8..f08c27e8 100644 --- a/examples/comparison/examples/compare_new_heads.rs +++ b/examples/comparison/examples/compare_new_heads.rs @@ -34,7 +34,7 @@ async fn main() -> Result<()> { let provider = match ProviderBuilder::new().network::().connect(&url).await { Ok(provider) => provider, Err(e) => { - eprintln!("skipping {} at {} because of error: {}", name, url, e); + eprintln!("skipping {name} at {url} because of error: {e}"); continue; } }; @@ -42,7 +42,7 @@ async fn main() -> Result<()> { let mut stream = match provider.subscribe_blocks().await { Ok(stream) => stream.into_stream().take(10), Err(e) => { - eprintln!("skipping {} at {} because of error: {}", name, url, e); + eprintln!("skipping {name} at {url} because of error: {e}"); continue; } }; @@ -53,7 +53,7 @@ async fn main() -> Result<()> { let _p = provider; // keep provider alive while let Some(header) = stream.next().await { if let Err(e) = sx.send((name.clone(), header, Utc::now())) { - eprintln!("sending to channel failed: {}", e); + eprintln!("sending to channel failed: {e}"); } } })); diff --git a/examples/comparison/examples/compare_pending_txs.rs b/examples/comparison/examples/compare_pending_txs.rs index fd12fd66..b86d0b12 100644 --- a/examples/comparison/examples/compare_pending_txs.rs +++ b/examples/comparison/examples/compare_pending_txs.rs @@ -24,7 +24,7 @@ async fn main() -> Result<()> { let mut rpcs = vec![]; for (name, url) in tmp { if url.starts_with("http") { - eprintln!("skipping {} at {} because it is not a websocket/ipc endpoint", name, url); + eprintln!("skipping {name} at {url} because it is not a websocket/ipc endpoint"); continue; } rpcs.push((name, url)); @@ -41,7 +41,7 @@ async fn main() -> Result<()> { let provider = match ProviderBuilder::new().network::().connect(&url).await { Ok(provider) => provider, Err(e) => { - eprintln!("skipping {} at {} because of error: {}", name, url, e); + eprintln!("skipping {name} at {url} because of error: {e}"); continue; } }; @@ -49,7 +49,7 @@ async fn main() -> Result<()> { let mut stream = match provider.subscribe_pending_transactions().await { Ok(stream) => stream.into_stream().take(50), Err(e) => { - eprintln!("skipping {} at {} because of error: {}", name, url, e); + eprintln!("skipping {name} at {url} because of error: {e}"); continue; } }; @@ -60,7 +60,7 @@ async fn main() -> Result<()> { let _p = provider; // keep provider alive while let Some(tx_hash) = stream.next().await { if let Err(e) = sx.send((name.clone(), tx_hash, Utc::now())) { - eprintln!("sending to channel failed: {}", e); + eprintln!("sending to channel failed: {e}"); } } })); diff --git a/examples/contracts/examples/arb_profit_calc.rs b/examples/contracts/examples/arb_profit_calc.rs index 6b288114..3247f8ed 100644 --- a/examples/contracts/examples/arb_profit_calc.rs +++ b/examples/contracts/examples/arb_profit_calc.rs @@ -1,5 +1,6 @@ //! Simple arbitrage profit calculator for WETH/DAI pools -//! Reads the balaces of the Uniswap V2 and SushiSwap pools and calculates a basic arb opportunity. +//! Reads the balaces of the Uniswap V2 and `SushiSwap` pools and calculates a basic arb +//! opportunity. mod helpers; use crate::helpers::{get_amount_in, get_amount_out, get_sushi_pair, get_uniswap_pair}; diff --git a/examples/contracts/examples/deploy_and_link_library.rs b/examples/contracts/examples/deploy_and_link_library.rs index 042751f0..c430d49f 100644 --- a/examples/contracts/examples/deploy_and_link_library.rs +++ b/examples/contracts/examples/deploy_and_link_library.rs @@ -46,11 +46,11 @@ async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the library (instead of using existing ones) let lib_addr: Address = Comparators::deploy_builder(&provider).deploy().await?; - println!("Deployed Comparators library at: {}", lib_addr); + println!("Deployed Comparators library at: {lib_addr}"); // Link the Counter contract bytecode by replacing the library placeholder let counter_linked_bytecode = Bytes::from_hex( @@ -63,7 +63,7 @@ async fn main() -> Result<()> { .map(|req| req.with_deploy_code(counter_linked_bytecode)) .deploy() .await?; - println!("Deployed Counter contract at: {}", counter_addr); + println!("Deployed Counter contract at: {counter_addr}"); // Instantiate the deployed Counter contract let counter = Counter::new(counter_addr, &provider); diff --git a/examples/contracts/examples/deploy_from_artifact.rs b/examples/contracts/examples/deploy_from_artifact.rs index 21b74f88..3739344a 100644 --- a/examples/contracts/examples/deploy_from_artifact.rs +++ b/examples/contracts/examples/deploy_from_artifact.rs @@ -16,7 +16,7 @@ sol!( async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the `Counter` contract. let contract = Counter::deploy(&provider).await?; diff --git a/examples/contracts/examples/deploy_from_bytecode.rs b/examples/contracts/examples/deploy_from_bytecode.rs index 9bf8c6fb..0a2d10b5 100644 --- a/examples/contracts/examples/deploy_from_bytecode.rs +++ b/examples/contracts/examples/deploy_from_bytecode.rs @@ -34,7 +34,7 @@ sol! { async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the `Counter` contract from bytecode at runtime. let bytecode = hex::decode( diff --git a/examples/contracts/examples/deploy_from_contract.rs b/examples/contracts/examples/deploy_from_contract.rs index ee48bc36..7ea83810 100644 --- a/examples/contracts/examples/deploy_from_contract.rs +++ b/examples/contracts/examples/deploy_from_contract.rs @@ -26,7 +26,7 @@ sol! { async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the `Counter` contract. let contract = Counter::deploy(&provider).await?; diff --git a/examples/contracts/examples/helpers.rs b/examples/contracts/examples/helpers.rs index 237ab414..4c74ffde 100644 --- a/examples/contracts/examples/helpers.rs +++ b/examples/contracts/examples/helpers.rs @@ -1,4 +1,4 @@ -//! Helpers for the UniswapV2 and Sushiswap arb simulation. +//! Helpers for the `UniswapV2` and Sushiswap arb simulation. #![allow(missing_docs, dead_code)] use std::ops::{Add, Div, Mul, Sub}; @@ -143,4 +143,4 @@ pub(crate) async fn set_hash_storage_slot( Ok(()) } -fn main() {} +const fn main() {} diff --git a/examples/contracts/examples/interact_with_abi.rs b/examples/contracts/examples/interact_with_abi.rs index a9de7221..ed365393 100644 --- a/examples/contracts/examples/interact_with_abi.rs +++ b/examples/contracts/examples/interact_with_abi.rs @@ -17,7 +17,7 @@ async fn main() -> Result<()> { // Ensure `anvil` is available in $PATH. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc"; let provider = - ProviderBuilder::new().on_anvil_with_wallet_and_config(|anvil| anvil.fork(rpc_url))?; + ProviderBuilder::new().connect_anvil_with_wallet_and_config(|anvil| anvil.fork(rpc_url))?; // Create a contract instance. let contract = IWETH9::new(address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"), provider); diff --git a/examples/contracts/examples/interact_with_contract_instance.rs b/examples/contracts/examples/interact_with_contract_instance.rs index 43ba3f86..6545ff79 100644 --- a/examples/contracts/examples/interact_with_contract_instance.rs +++ b/examples/contracts/examples/interact_with_contract_instance.rs @@ -15,7 +15,7 @@ use eyre::Result; async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the `Counter` contract from bytecode at runtime. let bytecode = hex::decode( diff --git a/examples/contracts/examples/revert_decoding.rs b/examples/contracts/examples/revert_decoding.rs index c388130f..4d66b5c3 100644 --- a/examples/contracts/examples/revert_decoding.rs +++ b/examples/contracts/examples/revert_decoding.rs @@ -27,7 +27,7 @@ sol! { async fn main() -> Result<()> { // Setup an Anvil provider with a wallet. // Make sure `anvil` is in your $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the contract. let contract = ThrowsError::deploy(&provider).await?; @@ -38,12 +38,12 @@ async fn main() -> Result<()> { // Get the raw bytes of the revert data. let revert_data = err.as_revert_data().unwrap(); - println!("Decoding revert data: {:?}", revert_data); + println!("Decoding revert data: {revert_data:?}"); // Decode the revert data as a custom error. let decoded_err = err.as_decoded_error::().unwrap(); - println!("Decoded as: {:?}", decoded_err); + println!("Decoded as: {decoded_err:?}"); assert_eq!(decoded_err, SomeCustomError { a: U256::from(1) }); @@ -55,11 +55,11 @@ async fn main() -> Result<()> { // The above returns an enum with the errors as its variants. match decoded_err { ErrorsErrors::SomeCustomError(err) => { - println!("Decoded as: {:?}", err); + println!("Decoded as: {err:?}"); assert_eq!(err.a, U256::from(1)); } ErrorsErrors::AnotherError(err) => { - println!("Decoded as: {:?}", err); + println!("Decoded as: {err:?}"); assert_eq!(err.b, 0); } } diff --git a/examples/contracts/examples/simulation_uni_v2.rs b/examples/contracts/examples/simulation_uni_v2.rs index 90361994..ca64b1a5 100644 --- a/examples/contracts/examples/simulation_uni_v2.rs +++ b/examples/contracts/examples/simulation_uni_v2.rs @@ -1,5 +1,5 @@ -//! Simulates an arbitrage between Uniswap V2 and SushiSwap by forking anvil and using the -//! FlashBotsMultiCall contract. +//! Simulates an arbitrage between Uniswap V2 and `SushiSwap` by forking anvil and using the +//! `FlashBotsMultiCall` contract. use alloy::{ hex, network::TransactionBuilder, @@ -46,8 +46,9 @@ async fn main() -> Result<()> { let sushi_pair = get_sushi_pair(); let wallet_address: Address = anvil.addresses()[0]; - let provider = - ProviderBuilder::new().wallet(anvil.wallet().unwrap()).on_http(anvil.endpoint().parse()?); + let provider = ProviderBuilder::new() + .wallet(anvil.wallet().unwrap()) + .connect_http(anvil.endpoint().parse()?); let executor = FlashBotsMultiCall::deploy(provider.clone(), wallet_address).await?; let iweth = IERC20::new(WETH_ADDR, provider.clone()); @@ -126,7 +127,7 @@ async fn main() -> Result<()> { .await?; let balance_of = iweth.balanceOf(*executor.address()).call().await?; - println!("Before - WETH balance of executor {:?}", balance_of); + println!("Before - WETH balance of executor {balance_of:?}"); let weth_amount_in = get_amount_in( uniswap_pair.reserve0, @@ -172,7 +173,7 @@ async fn main() -> Result<()> { pending.get_receipt().await?; let balance_of = iweth.balanceOf(*executor.address()).call().await?; - println!("After - WETH balance of executor {:?}", balance_of); + println!("After - WETH balance of executor {balance_of:?}"); Ok(()) } diff --git a/examples/contracts/examples/unknown_return_types.rs b/examples/contracts/examples/unknown_return_types.rs index 88f39368..cddeed77 100644 --- a/examples/contracts/examples/unknown_return_types.rs +++ b/examples/contracts/examples/unknown_return_types.rs @@ -15,7 +15,7 @@ use eyre::Result; async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Get the first account from the wallet, Alice. let alice = provider.get_accounts().await?[0]; diff --git a/examples/fillers/Cargo.toml b/examples/fillers/Cargo.toml index 8ea8faa1..f1afbe14 100644 --- a/examples/fillers/Cargo.toml +++ b/examples/fillers/Cargo.toml @@ -18,4 +18,4 @@ alloy.workspace = true eyre.workspace = true serde_json.workspace = true tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } -reqwest = "0.12.10" +reqwest = "0.12.15" diff --git a/examples/fillers/examples/gas_filler.rs b/examples/fillers/examples/gas_filler.rs index f020acec..0c80f102 100644 --- a/examples/fillers/examples/gas_filler.rs +++ b/examples/fillers/examples/gas_filler.rs @@ -13,12 +13,15 @@ use eyre::Result; async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::default() + let provider = ProviderBuilder::new() + // You can disable the recommended fillers by calling the `disable_recommended_fillers()` + // and pick the fillers of your choice. + .disable_recommended_fillers() // Add the `GasFiller` to the provider. // It is generally recommended to use the recommended fillers which includes the GasFiller, // enabled by building the provider using ProviderBuilder::new(). .with_gas_estimation() - .on_anvil_with_wallet(); + .connect_anvil_with_wallet(); // Build an EIP-1559 type transaction to send 100 wei to Vitalik. let vitalik = address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045"); diff --git a/examples/fillers/examples/nonce_filler.rs b/examples/fillers/examples/nonce_filler.rs index a745e8e6..e6665b28 100644 --- a/examples/fillers/examples/nonce_filler.rs +++ b/examples/fillers/examples/nonce_filler.rs @@ -38,7 +38,7 @@ async fn main() -> Result<()> { // reorganizations. .with_cached_nonce_management() // .with_simple_nonce_management() - .on_anvil_with_wallet(); + .connect_anvil_with_wallet(); // Build an EIP-1559 type transaction to send 100 wei to Vitalik. let vitalik = address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045"); diff --git a/examples/fillers/examples/recommended_fillers.rs b/examples/fillers/examples/recommended_fillers.rs index cc8aa39e..f4e8c852 100644 --- a/examples/fillers/examples/recommended_fillers.rs +++ b/examples/fillers/examples/recommended_fillers.rs @@ -20,7 +20,7 @@ async fn main() -> Result<()> { // This is the recommended way to set up the provider. // One can disable the recommended fillers by calling the `disable_recommended_fillers()` // method or building the provider with `ProviderBuilder::default()`. - .on_anvil_with_wallet(); + .connect_anvil_with_wallet(); // Build an EIP-1559 type transaction to send 100 wei to Vitalik. // Notice that the `nonce` field is set by the `NonceFiller`. diff --git a/examples/fillers/examples/urgent_filler.rs b/examples/fillers/examples/urgent_filler.rs index 0cfbe9ce..370fb215 100644 --- a/examples/fillers/examples/urgent_filler.rs +++ b/examples/fillers/examples/urgent_filler.rs @@ -85,10 +85,7 @@ impl TxFiller for UrgentQueue { Ok(res) => res, Err(e) => { return Err(RpcError::Transport(TransportErrorKind::Custom(Box::new( - std::io::Error::new( - std::io::ErrorKind::Other, - format!("Failed to fetch gas price, {}", e), - ), + std::io::Error::other(format!("Failed to fetch gas price, {e}")), )))); } }; @@ -107,14 +104,15 @@ impl TxFiller for UrgentQueue { #[tokio::main] async fn main() -> Result<()> { // Instantiate the provider with the UrgentQueue filler - let provider = ProviderBuilder::new().filler(UrgentQueue::default()).on_anvil_with_wallet(); + let provider = + ProviderBuilder::new().filler(UrgentQueue::default()).connect_anvil_with_wallet(); let bob = Address::from([0x42; 20]); let tx = TransactionRequest::default().with_to(bob).with_value(U256::from(1)); let bob_balance_before = provider.get_balance(bob).await?; let res = provider.send_transaction(tx).await?.get_receipt().await?; let bob_balance_after = provider.get_balance(bob).await?; - println!("Balance before: {}\nBalance after: {}", bob_balance_before, bob_balance_after); + println!("Balance before: {bob_balance_before}\nBalance after: {bob_balance_after}"); let tx = provider.get_transaction_by_hash(res.transaction_hash).await?.unwrap(); println!("Max fee per gas: {:?}", tx.max_fee_per_gas()); diff --git a/examples/fillers/examples/wallet_filler.rs b/examples/fillers/examples/wallet_filler.rs index a200eec1..a9a55911 100644 --- a/examples/fillers/examples/wallet_filler.rs +++ b/examples/fillers/examples/wallet_filler.rs @@ -24,7 +24,7 @@ async fn main() -> Result<()> { let provider = ProviderBuilder::new() // Add the `WalletFiller` to the provider .wallet(signer) - .on_http(rpc_url); + .connect_http(rpc_url); // Build an EIP-1559 type transaction to send 100 wei to Vitalik. let vitalik = address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045"); diff --git a/examples/layers/examples/delay_layer.rs b/examples/layers/examples/delay_layer.rs index 00e59d07..de9830d9 100644 --- a/examples/layers/examples/delay_layer.rs +++ b/examples/layers/examples/delay_layer.rs @@ -33,7 +33,7 @@ pub struct DelayLayer { impl DelayLayer { /// Creates a new [`DelayLayer`] with the specified delay. - pub fn new(delay: Duration) -> Self { + pub const fn new(delay: Duration) -> Self { Self { delay } } } @@ -84,7 +84,7 @@ async fn main() -> Result<()> { .http(anvil.endpoint().parse()?); // Instatiate a provider with the RPC-client that uses the `DelayLayer`. - let provider = ProviderBuilder::new().wallet(signer).on_client(client); + let provider = ProviderBuilder::new().wallet(signer).connect_client(client); let bob = Address::from([0x42; 20]); let tx = TransactionRequest::default().with_to(bob).with_value(U256::from(1)); @@ -93,7 +93,7 @@ async fn main() -> Result<()> { let receipt = provider.send_transaction(tx).await?.get_receipt().await?; assert!(receipt.status(), "Transaction failed"); let bob_balance_after = provider.get_balance(bob).await?; - println!("Balance before: {}\nBalance after: {}", bob_balance_before, bob_balance_after); + println!("Balance before: {bob_balance_before}\nBalance after: {bob_balance_after}"); Ok(()) } diff --git a/examples/layers/examples/fallback_layer.rs b/examples/layers/examples/fallback_layer.rs index 06f78ccb..084ed4d4 100644 --- a/examples/layers/examples/fallback_layer.rs +++ b/examples/layers/examples/fallback_layer.rs @@ -31,7 +31,7 @@ async fn main() -> Result<()> { // Apply the FallbackLayer to the transports let transport = ServiceBuilder::new().layer(fallback_layer).service(transports); let client = RpcClient::builder().transport(transport, false); - let provider = ProviderBuilder::new().on_client(client); + let provider = ProviderBuilder::new().connect_client(client); // Get the latest block number using the provider with ranked transports. // This will also print the rankings of the transports to the console. diff --git a/examples/layers/examples/hyper_http_layer.rs b/examples/layers/examples/hyper_http_layer.rs index cd13c663..d1c81890 100644 --- a/examples/layers/examples/hyper_http_layer.rs +++ b/examples/layers/examples/hyper_http_layer.rs @@ -37,7 +37,7 @@ async fn main() -> Result<()> { // Create a new RPC client with the Hyper transport. let rpc_client = RpcClient::new(http, true); - let provider = ProviderBuilder::new().on_client(rpc_client); + let provider = ProviderBuilder::new().connect_client(rpc_client); let num = provider.get_block_number().await.unwrap(); @@ -93,7 +93,7 @@ where let header = req.headers_mut(); header.insert("x-alloy", "hyper".parse().unwrap()); - println!("Request: {:?}", req); + println!("Request: {req:?}"); let fut = self.inner.call(req); diff --git a/examples/layers/examples/logging_layer.rs b/examples/layers/examples/logging_layer.rs index 47e91e00..83e53935 100644 --- a/examples/layers/examples/logging_layer.rs +++ b/examples/layers/examples/logging_layer.rs @@ -78,7 +78,7 @@ async fn main() -> Result<()> { let client = ClientBuilder::default().layer(LoggingLayer).http(rpc_url); // Create a new provider with the client. - let provider = ProviderBuilder::new().on_client(client); + let provider = ProviderBuilder::new().connect_client(client); for _ in 0..10 { let _block_number = provider.get_block_number().into_future().await?; diff --git a/examples/layers/examples/retry_layer.rs b/examples/layers/examples/retry_layer.rs index 377c1e9b..92055143 100644 --- a/examples/layers/examples/retry_layer.rs +++ b/examples/layers/examples/retry_layer.rs @@ -28,7 +28,7 @@ async fn main() -> eyre::Result<()> { // have been reached. let client = RpcClient::builder().layer(retry_layer).http(anvil.endpoint_url()); - let provider = ProviderBuilder::new().on_client(client); + let provider = ProviderBuilder::new().connect_client(client); let latest_block = provider.get_block_number().await?; diff --git a/examples/node-bindings/examples/anvil_deploy_contract.rs b/examples/node-bindings/examples/anvil_deploy_contract.rs index ec666f6a..1eb7bc54 100644 --- a/examples/node-bindings/examples/anvil_deploy_contract.rs +++ b/examples/node-bindings/examples/anvil_deploy_contract.rs @@ -25,7 +25,7 @@ sol! { async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the `Counter` contract. let contract = Counter::deploy(&provider).await?; diff --git a/examples/node-bindings/examples/anvil_fork_instance.rs b/examples/node-bindings/examples/anvil_fork_instance.rs index 72b4dc02..20f16946 100644 --- a/examples/node-bindings/examples/anvil_fork_instance.rs +++ b/examples/node-bindings/examples/anvil_fork_instance.rs @@ -12,12 +12,12 @@ async fn main() -> Result<()> { // Ensure `anvil` is available in $PATH. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc"; let anvil = Anvil::new().fork(rpc_url).try_spawn()?; - let provider = ProviderBuilder::new().on_http(anvil.endpoint_url()); + let provider = ProviderBuilder::new().connect_http(anvil.endpoint_url()); // Get node info using the Anvil API. let info = provider.anvil_node_info().await?; - println!("Node info: {:#?}", info); + println!("Node info: {info:#?}"); assert_eq!(info.environment.chain_id, 1); assert_eq!(info.fork_config.fork_url, Some(rpc_url.to_string())); diff --git a/examples/node-bindings/examples/anvil_fork_provider.rs b/examples/node-bindings/examples/anvil_fork_provider.rs index 82c250be..bd344f0f 100644 --- a/examples/node-bindings/examples/anvil_fork_provider.rs +++ b/examples/node-bindings/examples/anvil_fork_provider.rs @@ -8,12 +8,12 @@ async fn main() -> Result<()> { // Spin up a forked Anvil node. // Ensure `anvil` is available in $PATH. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc"; - let provider = ProviderBuilder::new().on_anvil_with_config(|anvil| anvil.fork(rpc_url)); + let provider = ProviderBuilder::new().connect_anvil_with_config(|anvil| anvil.fork(rpc_url)); // Get node info using the Anvil API. let info = provider.anvil_node_info().await?; - println!("Node info: {:#?}", info); + println!("Node info: {info:#?}"); assert_eq!(info.environment.chain_id, 1); assert_eq!(info.fork_config.fork_url, Some(rpc_url.to_string())); diff --git a/examples/node-bindings/examples/anvil_local_instance.rs b/examples/node-bindings/examples/anvil_local_instance.rs index a8e3f7f4..19180d75 100644 --- a/examples/node-bindings/examples/anvil_local_instance.rs +++ b/examples/node-bindings/examples/anvil_local_instance.rs @@ -11,12 +11,12 @@ async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. let anvil = Anvil::new().block_time(1).chain_id(1337).try_spawn()?; - let provider = ProviderBuilder::new().on_http(anvil.endpoint_url()); + let provider = ProviderBuilder::new().connect_http(anvil.endpoint_url()); // Get node info using the Anvil API. let info = provider.anvil_node_info().await?; - println!("Node info: {:#?}", info); + println!("Node info: {info:#?}"); assert_eq!(info.environment.chain_id, 1337); assert_eq!(info.fork_config.fork_url, None); diff --git a/examples/node-bindings/examples/anvil_local_provider.rs b/examples/node-bindings/examples/anvil_local_provider.rs index b7ca6cf2..01892621 100644 --- a/examples/node-bindings/examples/anvil_local_provider.rs +++ b/examples/node-bindings/examples/anvil_local_provider.rs @@ -7,13 +7,13 @@ use eyre::Result; async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = - ProviderBuilder::new().on_anvil_with_config(|anvil| anvil.block_time(1).chain_id(1337)); + let provider = ProviderBuilder::new() + .connect_anvil_with_config(|anvil| anvil.block_time(1).chain_id(1337)); // Get node info using the Anvil API. let info = provider.anvil_node_info().await?; - println!("Node info: {:#?}", info); + println!("Node info: {info:#?}"); assert_eq!(info.environment.chain_id, 1337); assert_eq!(info.fork_config.fork_url, None); diff --git a/examples/node-bindings/examples/anvil_set_storage_at.rs b/examples/node-bindings/examples/anvil_set_storage_at.rs index 81fe3543..e2f54898 100644 --- a/examples/node-bindings/examples/anvil_set_storage_at.rs +++ b/examples/node-bindings/examples/anvil_set_storage_at.rs @@ -23,7 +23,7 @@ async fn main() -> Result<()> { // Spin up a forked Anvil node. // Ensure `anvil` is available in $PATH. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc"; - let provider = ProviderBuilder::new().on_anvil_with_config(|anvil| anvil.fork(rpc_url)); + let provider = ProviderBuilder::new().connect_anvil_with_config(|anvil| anvil.fork(rpc_url)); // Create an instance of the WETH contract. let iweth = IERC20::new(WETH_ADDR, provider.clone()); @@ -33,7 +33,7 @@ async fn main() -> Result<()> { // Get the WETH balance of the target account before mocking. let balance_before = iweth.balanceOf(account).call().await?; - println!("WETH balance before: {}", balance_before); + println!("WETH balance before: {balance_before}"); assert_eq!(balance_before, U256::ZERO); // Mock WETH balance using the Anvil API. @@ -43,7 +43,7 @@ async fn main() -> Result<()> { // Get the WETH balance of the target account after mocking. let balance_after = iweth.balanceOf(account).call().await?; - println!("WETH balance after: {}", balance_after); + println!("WETH balance after: {balance_after}"); assert_eq!(balance_after, mocked_balance); Ok(()) diff --git a/examples/node-bindings/examples/geth_local_instance.rs b/examples/node-bindings/examples/geth_local_instance.rs index 0b32d3b1..2e95d5ab 100644 --- a/examples/node-bindings/examples/geth_local_instance.rs +++ b/examples/node-bindings/examples/geth_local_instance.rs @@ -11,7 +11,7 @@ async fn main() -> Result<()> { // Spin up a local Geth node. // Ensure `geth` is available in $PATH. let geth = Geth::new().chain_id(1337).port(8545_u16).authrpc_port(8551).spawn(); - let provider = ProviderBuilder::new().on_http(geth.endpoint().parse()?); + let provider = ProviderBuilder::new().connect_http(geth.endpoint().parse()?); let chain_id = provider.get_chain_id().await?; diff --git a/examples/node-bindings/examples/reth_local_instance.rs b/examples/node-bindings/examples/reth_local_instance.rs index b60edb32..e92ce35a 100644 --- a/examples/node-bindings/examples/reth_local_instance.rs +++ b/examples/node-bindings/examples/reth_local_instance.rs @@ -11,7 +11,7 @@ async fn main() -> Result<()> { // Spin up a local Reth node. // Ensure `reth` is available in $PATH. let reth = Reth::new().dev().disable_discovery().instance(1).spawn(); - let provider = ProviderBuilder::new().on_http(reth.endpoint().parse()?); + let provider = ProviderBuilder::new().connect_http(reth.endpoint().parse()?); let chain_id = provider.get_chain_id().await?; diff --git a/examples/providers/examples/basic_provider.rs b/examples/providers/examples/basic_provider.rs index 278a5ced..061a2110 100644 --- a/examples/providers/examples/basic_provider.rs +++ b/examples/providers/examples/basic_provider.rs @@ -24,7 +24,7 @@ async fn main() -> Result<()> { .disable_recommended_fillers() // Add the signer to the provider for signing transactions .wallet(signer) - .on_http(anvil.endpoint().parse()?); + .connect_http(anvil.endpoint().parse()?); let bob = Address::from([0x42; 20]); let fees = provider.estimate_eip1559_fees().await?; @@ -46,7 +46,7 @@ async fn main() -> Result<()> { let receipt = provider.send_transaction(tx).await?.get_receipt().await?; assert!(receipt.status(), "Transaction failed"); let bob_balance_after = provider.get_balance(bob).await?; - println!("Balance before: {}\nBalance after: {}", bob_balance_before, bob_balance_after); + println!("Balance before: {bob_balance_before}\nBalance after: {bob_balance_after}"); Ok(()) } diff --git a/examples/providers/examples/builder.rs b/examples/providers/examples/builder.rs index 4f0340bb..bd1bbf5a 100644 --- a/examples/providers/examples/builder.rs +++ b/examples/providers/examples/builder.rs @@ -25,7 +25,7 @@ async fn main() -> Result<()> { // Set up the HTTP provider with the `reqwest` crate. let rpc_url = anvil.endpoint_url(); - let provider = ProviderBuilder::new().wallet(signer).on_http(rpc_url); + let provider = ProviderBuilder::new().wallet(signer).connect_http(rpc_url); // Create a transaction. let tx = TransactionRequest::default().with_to(bob).with_value(U256::from(100)); diff --git a/examples/providers/examples/dyn_provider.rs b/examples/providers/examples/dyn_provider.rs index 7034f9f0..770eb591 100644 --- a/examples/providers/examples/dyn_provider.rs +++ b/examples/providers/examples/dyn_provider.rs @@ -58,7 +58,7 @@ async fn main() -> eyre::Result<()> { let number = counter.number().call().await?; - println!("New number: {}", number); + println!("New number: {number}"); Ok(()) } diff --git a/examples/providers/examples/http.rs b/examples/providers/examples/http.rs index d632fba1..abe8c557 100644 --- a/examples/providers/examples/http.rs +++ b/examples/providers/examples/http.rs @@ -7,7 +7,7 @@ use eyre::Result; async fn main() -> Result<()> { // Create a provider with the HTTP transport using the `reqwest` crate. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc".parse()?; - let provider = ProviderBuilder::new().on_http(rpc_url); + let provider = ProviderBuilder::new().connect_http(rpc_url); // Get latest block number. let latest_block = provider.get_block_number().await?; diff --git a/examples/providers/examples/http_with_auth.rs b/examples/providers/examples/http_with_auth.rs index 30f066d3..28a0d8bd 100644 --- a/examples/providers/examples/http_with_auth.rs +++ b/examples/providers/examples/http_with_auth.rs @@ -29,7 +29,7 @@ async fn main() -> Result<()> { let rpc_client = RpcClient::new(http, false); // Create a provider with the HTTP transport. - let provider = ProviderBuilder::new().on_client(rpc_client); + let provider = ProviderBuilder::new().connect_client(rpc_client); // Get latest block number. let latest_block = provider.get_block_number().await?; diff --git a/examples/providers/examples/ipc.rs b/examples/providers/examples/ipc.rs index 9d2e99d8..4b0ac5be 100644 --- a/examples/providers/examples/ipc.rs +++ b/examples/providers/examples/ipc.rs @@ -10,7 +10,7 @@ async fn main() -> Result<()> { // Create the provider. let ipc = IpcConnect::new(ipc_path.to_string()); - let provider = ProviderBuilder::new().on_ipc(ipc).await?; + let provider = ProviderBuilder::new().connect_ipc(ipc).await?; let latest_block = provider.get_block_number().await?; diff --git a/examples/providers/examples/mocking.rs b/examples/providers/examples/mocking.rs index 9a6a880f..bc205f53 100644 --- a/examples/providers/examples/mocking.rs +++ b/examples/providers/examples/mocking.rs @@ -20,7 +20,7 @@ async fn main() -> eyre::Result<()> { // Initialize the provider with the `MockTransport` that intercepts incoming requests and uses // the `Asserter` to return the next response. // `Asserter` is cheaply cloneable as the underlying queue is wrapped in an `Arc`. - let provider = ProviderBuilder::new().on_mocked_client(asserter.clone()); + let provider = ProviderBuilder::new().connect_mocked_client(asserter.clone()); // Mock the response for a basic `get_block_number` request. let expected_bn = 1000; diff --git a/examples/providers/examples/multicall.rs b/examples/providers/examples/multicall.rs index 99c62283..f6032539 100644 --- a/examples/providers/examples/multicall.rs +++ b/examples/providers/examples/multicall.rs @@ -20,7 +20,7 @@ sol!( async fn main() -> eyre::Result<()> { // Create a new provider let provider = ProviderBuilder::new() - .on_anvil_with_wallet_and_config(|a| a.fork("https://reth-ethereum.ithaca.xyz/rpc"))?; + .connect_anvil_with_wallet_and_config(|a| a.fork("https://reth-ethereum.ithaca.xyz/rpc"))?; // Create a new instance of the IWETH9 contract. let weth = IWETH9Instance::new(address!("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"), &provider); @@ -42,8 +42,7 @@ async fn main() -> eyre::Result<()> { let (init_total_supply, alice_weth, alice_eth_bal) = multicall.aggregate().await?; println!( - "Initial total supply: {}, Alice's WETH balance: {}, Alice's ETH balance: {}", - init_total_supply, alice_weth, alice_eth_bal + "Initial total supply: {init_total_supply}, Alice's WETH balance: {alice_weth}, Alice's ETH balance: {alice_eth_bal}" ); // Simulate a transfer of WETH from Alice to Bob. @@ -89,7 +88,7 @@ async fn main() -> eyre::Result<()> { let alice_weth = alice_weth?; let bob_weth = bob_weth?; - println!("Alice's WETH balance: {}, Bob's WETH balance: {}", alice_weth, bob_weth); + println!("Alice's WETH balance: {alice_weth}, Bob's WETH balance: {bob_weth}"); Ok(()) } diff --git a/examples/providers/examples/multicall_batching.rs b/examples/providers/examples/multicall_batching.rs index f36d7f9a..99ffa89b 100644 --- a/examples/providers/examples/multicall_batching.rs +++ b/examples/providers/examples/multicall_batching.rs @@ -31,7 +31,7 @@ async fn main() -> Result<()> { .layer(CallBatchLayer::new().wait(Duration::from_secs(10))) // Can also use the shorthand `with_call_batching` on the build which set the delay to 1ms. // .with_call_batching() - .on_anvil_with_wallet_and_config(|a| a.fork("https://reth-ethereum.ithaca.xyz/rpc"))?; + .connect_anvil_with_wallet_and_config(|a| a.fork("https://reth-ethereum.ithaca.xyz/rpc"))?; // Create a new instance of the IWETH9 contract. let weth = @@ -63,9 +63,8 @@ async fn main() -> Result<()> { println!("Block Number: {block_number}"); println!( - "Alice's WETH balance: {}\nBob's WETH balance: {}\nTotal WETH supply: {}\nAlice's ETH - balance: {}", - alice_weth, bob_weth, total_supply, alice_eth + "Alice's WETH balance: {alice_weth}\nBob's WETH balance: {bob_weth}\nTotal WETH supply: {total_supply}\nAlice's ETH + balance: {alice_eth}" ); Ok(()) diff --git a/examples/providers/examples/wrapped_provider.rs b/examples/providers/examples/wrapped_provider.rs index f058b568..5f14035c 100644 --- a/examples/providers/examples/wrapped_provider.rs +++ b/examples/providers/examples/wrapped_provider.rs @@ -119,7 +119,7 @@ async fn main() -> Result<()> { let block_num = counter.provider().get_block_number().await?; - println!("Current block number: {}", block_num); + println!("Current block number: {block_num}"); Ok(()) } diff --git a/examples/providers/examples/ws.rs b/examples/providers/examples/ws.rs index dc2b6c38..a4b6585e 100644 --- a/examples/providers/examples/ws.rs +++ b/examples/providers/examples/ws.rs @@ -9,7 +9,7 @@ async fn main() -> Result<()> { // Create the provider. let rpc_url = "wss://eth-mainnet.g.alchemy.com/v2/your-api-key"; let ws = WsConnect::new(rpc_url); - let provider = ProviderBuilder::new().on_ws(ws).await?; + let provider = ProviderBuilder::new().connect_ws(ws).await?; // 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 378b0f7b..ae72f7e9 100644 --- a/examples/providers/examples/ws_with_auth.rs +++ b/examples/providers/examples/ws_with_auth.rs @@ -19,8 +19,8 @@ async fn main() -> Result<()> { let ws_bearer = WsConnect::new(rpc_url).with_auth(auth_bearer); // Create the provider. - let provider_basic = ProviderBuilder::new().on_ws(ws_basic).await?; - let provider_bearer = ProviderBuilder::new().on_ws(ws_bearer).await?; + let provider_basic = ProviderBuilder::new().connect_ws(ws_basic).await?; + let provider_bearer = ProviderBuilder::new().connect_ws(ws_bearer).await?; // Subscribe to new block headers. let sub_basic = provider_basic.subscribe_blocks(); diff --git a/examples/queries/examples/query_contract_storage.rs b/examples/queries/examples/query_contract_storage.rs index 580a05a2..b3f064a6 100644 --- a/examples/queries/examples/query_contract_storage.rs +++ b/examples/queries/examples/query_contract_storage.rs @@ -10,7 +10,7 @@ use eyre::Result; async fn main() -> Result<()> { // Create a provider. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc".parse()?; - let provider = ProviderBuilder::new().on_http(rpc_url); + let provider = ProviderBuilder::new().connect_http(rpc_url); // Get storage slot 0 from the Uniswap V3 USDC-ETH pool on Ethereum mainnet. let pool_address = address!("88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640"); diff --git a/examples/queries/examples/query_deployed_bytecode.rs b/examples/queries/examples/query_deployed_bytecode.rs index d35af32a..486880c3 100644 --- a/examples/queries/examples/query_deployed_bytecode.rs +++ b/examples/queries/examples/query_deployed_bytecode.rs @@ -10,7 +10,7 @@ use eyre::Result; async fn main() -> Result<()> { // Create a provider. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc".parse()?; - let provider = ProviderBuilder::new().on_http(rpc_url); + let provider = ProviderBuilder::new().connect_http(rpc_url); // Get the bytecode of the Uniswap V3 USDC-ETH pool on Ethereum mainnet. let pool_address = address!("88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640"); diff --git a/examples/queries/examples/query_logs.rs b/examples/queries/examples/query_logs.rs index e3076d45..5d203c54 100644 --- a/examples/queries/examples/query_logs.rs +++ b/examples/queries/examples/query_logs.rs @@ -11,7 +11,7 @@ use eyre::Result; async fn main() -> Result<()> { // Create a provider. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc".parse()?; - let provider = ProviderBuilder::new().on_http(rpc_url); + let provider = ProviderBuilder::new().connect_http(rpc_url); // Get logs from the latest block let latest_block = provider.get_block_number().await?; diff --git a/examples/sol-macro/examples/all_derives.rs b/examples/sol-macro/examples/all_derives.rs index eb7849c8..0e01fadf 100644 --- a/examples/sol-macro/examples/all_derives.rs +++ b/examples/sol-macro/examples/all_derives.rs @@ -26,7 +26,7 @@ fn main() { let mut foo_list = vec![foo.clone(), foo, foo_bar]; // `Debug` derived as well. - println!("Initial foo_list: {:?}", foo_list); + println!("Initial foo_list: {foo_list:?}"); // `PartialEq` is derived, enabling us to apply `.dedup()`. foo_list.dedup(); diff --git a/examples/sol-macro/examples/events_errors.rs b/examples/sol-macro/examples/events_errors.rs index f3cb3d33..7bcd68a0 100644 --- a/examples/sol-macro/examples/events_errors.rs +++ b/examples/sol-macro/examples/events_errors.rs @@ -46,7 +46,7 @@ sol!( async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the `Counter` contract. let contract = CounterWithError::deploy(provider.clone()).await?; diff --git a/examples/sol-macro/examples/extra_derives.rs b/examples/sol-macro/examples/extra_derives.rs index 2bd91d63..93af6212 100644 --- a/examples/sol-macro/examples/extra_derives.rs +++ b/examples/sol-macro/examples/extra_derives.rs @@ -19,8 +19,7 @@ sol!( ); fn main() -> eyre::Result<()> { - let mut color_struct = Colors::Color::default(); - color_struct.r = 255; + let color_struct = Colors::Color { r: 255, ..Default::default() }; // serde::Serialize is derived for types passed to the `sol!` macro. let json = serde_json::to_string_pretty(&color_struct)?; @@ -28,6 +27,6 @@ fn main() -> eyre::Result<()> { // serde::Deserialize is derived for all types in the abi. let deserialized: Colors::Color = serde_json::from_str(&json)?; - println!("{:?}", deserialized); + println!("{deserialized:?}"); Ok(()) } diff --git a/examples/subscriptions/examples/event_multiplexer.rs b/examples/subscriptions/examples/event_multiplexer.rs index 9b57ec79..8f1155a2 100644 --- a/examples/subscriptions/examples/event_multiplexer.rs +++ b/examples/subscriptions/examples/event_multiplexer.rs @@ -52,7 +52,7 @@ async fn main() -> Result<()> { // Create a provider. let ws = WsConnect::new(anvil.ws_endpoint()); - let provider = ProviderBuilder::new().wallet(pk).on_ws(ws).await?; + let provider = ProviderBuilder::new().wallet(pk).connect_ws(ws).await?; // Deploy the `EventExample` contract. let contract = EventMultiplexer::deploy(provider).await?; diff --git a/examples/subscriptions/examples/poll_logs.rs b/examples/subscriptions/examples/poll_logs.rs index a0bbf9da..14527c2c 100644 --- a/examples/subscriptions/examples/poll_logs.rs +++ b/examples/subscriptions/examples/poll_logs.rs @@ -41,7 +41,7 @@ async fn main() -> Result<()> { // Create a WebSocket provider. let ws = WsConnect::new(anvil.ws_endpoint()); - let provider = ProviderBuilder::new().wallet(pk).on_ws(ws).await?; + let provider = ProviderBuilder::new().wallet(pk).connect_ws(ws).await?; // Deploy the `Counter` contract. let contract = Counter::deploy(provider.clone()).await?; diff --git a/examples/subscriptions/examples/subscribe_all_logs.rs b/examples/subscriptions/examples/subscribe_all_logs.rs index 30e29f8d..c1ea226c 100644 --- a/examples/subscriptions/examples/subscribe_all_logs.rs +++ b/examples/subscriptions/examples/subscribe_all_logs.rs @@ -23,7 +23,7 @@ async fn main() -> Result<()> { // Create the provider. let rpc_url = "wss://eth-mainnet.g.alchemy.com/v2/your-api-key"; let ws = WsConnect::new(rpc_url); - let provider = ProviderBuilder::new().on_ws(ws).await?; + let provider = ProviderBuilder::new().connect_ws(ws).await?; // Create a filter to watch for all WETH9 events. let weth9_token_address = address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"); diff --git a/examples/subscriptions/examples/subscribe_blocks.rs b/examples/subscriptions/examples/subscribe_blocks.rs index 2d36e1c3..d4db2936 100644 --- a/examples/subscriptions/examples/subscribe_blocks.rs +++ b/examples/subscriptions/examples/subscribe_blocks.rs @@ -15,7 +15,7 @@ async fn main() -> Result<()> { // Create a provider. let ws = WsConnect::new(anvil.ws_endpoint()); - let provider = ProviderBuilder::new().on_ws(ws).await?; + let provider = ProviderBuilder::new().connect_ws(ws).await?; // Subscribe to block headers. let subscription = provider.subscribe_blocks().await?; diff --git a/examples/subscriptions/examples/subscribe_logs.rs b/examples/subscriptions/examples/subscribe_logs.rs index 7516dd2a..3ef08499 100644 --- a/examples/subscriptions/examples/subscribe_logs.rs +++ b/examples/subscriptions/examples/subscribe_logs.rs @@ -13,7 +13,7 @@ async fn main() -> Result<()> { // Create the provider. let rpc_url = "wss://eth-mainnet.g.alchemy.com/v2/your-api-key"; let ws = WsConnect::new(rpc_url); - let provider = ProviderBuilder::new().on_ws(ws).await?; + let provider = ProviderBuilder::new().connect_ws(ws).await?; // Create a filter to watch for UNI token transfers. let uniswap_token_address = address!("1f9840a85d5aF5bf1D1762F925BDADdC4201F984"); diff --git a/examples/subscriptions/examples/subscribe_pending_transactions.rs b/examples/subscriptions/examples/subscribe_pending_transactions.rs index d15e92d2..a72a4164 100644 --- a/examples/subscriptions/examples/subscribe_pending_transactions.rs +++ b/examples/subscriptions/examples/subscribe_pending_transactions.rs @@ -10,7 +10,7 @@ async fn main() -> Result<()> { // Create the provider. let rpc_url = "wss://eth-mainnet.g.alchemy.com/v2/your-api-key"; let ws = WsConnect::new(rpc_url); - let provider = ProviderBuilder::new().on_ws(ws).await?; + let provider = ProviderBuilder::new().connect_ws(ws).await?; // Subscribe to pending transactions. // Alteratively use `subscribe_full_pending_transactions` to get the full transaction details diff --git a/examples/transactions/examples/debug_trace_call_many.rs b/examples/transactions/examples/debug_trace_call_many.rs index d531bcda..278bb84f 100644 --- a/examples/transactions/examples/debug_trace_call_many.rs +++ b/examples/transactions/examples/debug_trace_call_many.rs @@ -16,7 +16,7 @@ async fn main() -> Result<()> { // Spin up a local Reth node. // Ensure `reth` is available in $PATH. let reth = Reth::new().dev().disable_discovery().instance(1).spawn(); - let provider = ProviderBuilder::new().on_http(reth.endpoint().parse()?); + let provider = ProviderBuilder::new().connect_http(reth.endpoint().parse()?); // Get users, these have allocated balances in the dev genesis block. let alice = address!("70997970C51812dc3A010C7d01b50e0d17dc79C8"); @@ -43,10 +43,10 @@ async fn main() -> Result<()> { // Print the trace results. match result { Ok(traces) => { - println!("Traces:\n{:?}", traces); + println!("Traces:\n{traces:?}"); } Err(err) => { - println!("Error tracing transactions: {:?}", err); + println!("Error tracing transactions: {err:?}"); } } diff --git a/examples/transactions/examples/decode_receipt_log.rs b/examples/transactions/examples/decode_receipt_log.rs index 04acfc2c..126f66d1 100644 --- a/examples/transactions/examples/decode_receipt_log.rs +++ b/examples/transactions/examples/decode_receipt_log.rs @@ -27,7 +27,7 @@ sol! { async fn main() -> eyre::Result<()> { // Create an AnvilProvider // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Deploy the `Counter` contract. let counter = Counter::deploy(&provider).await?; diff --git a/examples/transactions/examples/gas_price_usd.rs b/examples/transactions/examples/gas_price_usd.rs index b95d552e..34e80b60 100644 --- a/examples/transactions/examples/gas_price_usd.rs +++ b/examples/transactions/examples/gas_price_usd.rs @@ -27,7 +27,7 @@ async fn main() -> Result<()> { // Spin up a forked Anvil node. // Ensure `anvil` is available in $PATH. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc"; - let provider = ProviderBuilder::new().on_anvil_with_config(|anvil| anvil.fork(rpc_url)); + let provider = ProviderBuilder::new().connect_anvil_with_config(|anvil| anvil.fork(rpc_url)); // Create a call to get the latest answer from the Chainlink ETH/USD feed. let call = latestAnswerCall {}.abi_encode(); diff --git a/examples/transactions/examples/permit2_signature_transfer.rs b/examples/transactions/examples/permit2_signature_transfer.rs index 363f97eb..6c772df4 100644 --- a/examples/transactions/examples/permit2_signature_transfer.rs +++ b/examples/transactions/examples/permit2_signature_transfer.rs @@ -76,7 +76,7 @@ async fn main() -> Result<()> { // Create a provider with both signers pointing to anvil let rpc_url = anvil.endpoint_url(); - let provider = ProviderBuilder::new().wallet(wallet).on_http(rpc_url); + let provider = ProviderBuilder::new().wallet(wallet).connect_http(rpc_url); // Deploy the `ERC20Example` contract. let token = ERC20Example::deploy(provider.clone()).await?; @@ -97,7 +97,7 @@ async fn main() -> Result<()> { .await? .watch() .await?; - println!("Sent approval: {}", tx_hash); + println!("Sent approval: {tx_hash}"); // Create the EIP712 Domain and Permit let amount = U256::from(100); @@ -127,7 +127,7 @@ async fn main() -> Result<()> { .await? .watch() .await?; - println!("Sent permit transfer: {}", tx_hash); + println!("Sent permit transfer: {tx_hash}"); // Register the balances of Alice and Bob after the transfer. let alice_after_balance = token.balanceOf(alice.address()).call().await?; diff --git a/examples/transactions/examples/send_eip1559_transaction.rs b/examples/transactions/examples/send_eip1559_transaction.rs index cd2668af..cb33fcd8 100644 --- a/examples/transactions/examples/send_eip1559_transaction.rs +++ b/examples/transactions/examples/send_eip1559_transaction.rs @@ -12,7 +12,7 @@ use eyre::Result; async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil(); + let provider = ProviderBuilder::new().connect_anvil(); // Create two users, Alice and Bob. let accounts = provider.get_accounts().await?; diff --git a/examples/transactions/examples/send_eip4844_transaction.rs b/examples/transactions/examples/send_eip4844_transaction.rs index 33ee5799..09737946 100644 --- a/examples/transactions/examples/send_eip4844_transaction.rs +++ b/examples/transactions/examples/send_eip4844_transaction.rs @@ -14,7 +14,7 @@ async fn main() -> Result<()> { // Spin up a local Anvil node with the Cancun hardfork enabled. // Ensure `anvil` is available in $PATH. let provider = ProviderBuilder::new() - .on_anvil_with_wallet_and_config(|anvil| anvil.args(["--hardfork", "cancun"]))?; + .connect_anvil_with_wallet_and_config(|anvil| anvil.args(["--hardfork", "cancun"]))?; // Create two users, Alice and Bob. let accounts = provider.get_accounts().await?; diff --git a/examples/transactions/examples/send_eip7702_transaction.rs b/examples/transactions/examples/send_eip7702_transaction.rs index 309a580a..077fb2c4 100644 --- a/examples/transactions/examples/send_eip7702_transaction.rs +++ b/examples/transactions/examples/send_eip7702_transaction.rs @@ -45,7 +45,7 @@ async fn main() -> Result<()> { // Create a provider with the wallet for only Bob (not Alice). let rpc_url = anvil.endpoint_url(); - let provider = ProviderBuilder::new().wallet(bob.clone()).on_http(rpc_url); + let provider = ProviderBuilder::new().wallet(bob.clone()).connect_http(rpc_url); // Deploy the contract Alice will authorize. let contract = Log::deploy(&provider).await?; diff --git a/examples/transactions/examples/send_legacy_transaction.rs b/examples/transactions/examples/send_legacy_transaction.rs index 8be55dce..b9cc5164 100644 --- a/examples/transactions/examples/send_legacy_transaction.rs +++ b/examples/transactions/examples/send_legacy_transaction.rs @@ -12,7 +12,7 @@ use eyre::Result; async fn main() -> Result<()> { // // Spin up a local Anvil node. // // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil(); + let provider = ProviderBuilder::new().connect_anvil(); // Create two users, Alice and Bob. let accounts = provider.get_accounts().await?; diff --git a/examples/transactions/examples/send_private_transaction.rs b/examples/transactions/examples/send_private_transaction.rs index 07e7f1ff..727d50e2 100644 --- a/examples/transactions/examples/send_private_transaction.rs +++ b/examples/transactions/examples/send_private_transaction.rs @@ -33,7 +33,7 @@ async fn main() -> Result<()> { let flashbots_url = "https://rpc.flashbots.net".parse()?; // Create a provider. - let provider = ProviderBuilder::new().on_http(flashbots_url); + let provider = ProviderBuilder::new().connect_http(flashbots_url); // Create a signer from a random private key. let signer = PrivateKeySigner::random(); diff --git a/examples/transactions/examples/send_raw_transaction.rs b/examples/transactions/examples/send_raw_transaction.rs index e783c0b6..d5cf82e6 100644 --- a/examples/transactions/examples/send_raw_transaction.rs +++ b/examples/transactions/examples/send_raw_transaction.rs @@ -12,7 +12,7 @@ use eyre::Result; async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Create two users, Alice and Bob. let accounts = provider.get_accounts().await?; diff --git a/examples/transactions/examples/trace_call.rs b/examples/transactions/examples/trace_call.rs index 72d09b7a..8e9d0b10 100644 --- a/examples/transactions/examples/trace_call.rs +++ b/examples/transactions/examples/trace_call.rs @@ -12,7 +12,7 @@ use eyre::Result; async fn main() -> Result<()> { // Create a provider. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc".parse()?; - let provider = ProviderBuilder::new().on_http(rpc_url); + let provider = ProviderBuilder::new().connect_http(rpc_url); // Build a transaction to send 100 wei from Alice to Vitalik. let alice = address!("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266"); diff --git a/examples/transactions/examples/trace_call_many.rs b/examples/transactions/examples/trace_call_many.rs index 66ba47e3..a766d94c 100644 --- a/examples/transactions/examples/trace_call_many.rs +++ b/examples/transactions/examples/trace_call_many.rs @@ -14,7 +14,7 @@ async fn main() -> Result<()> { // Spin up a local Reth node. // Ensure `reth` is available in $PATH. let reth = Reth::new().dev().disable_discovery().instance(1).spawn(); - let provider = ProviderBuilder::new().on_http(reth.endpoint().parse()?); + let provider = ProviderBuilder::new().connect_http(reth.endpoint().parse()?); // Get users, these have allocated balances in the dev genesis block. let alice = address!("70997970C51812dc3A010C7d01b50e0d17dc79C8"); @@ -38,7 +38,7 @@ async fn main() -> Result<()> { // Print the trace results. for (index, trace_result) in result.iter().enumerate() { - println!("Trace result for transaction {}: {:?}", index, trace_result); + println!("Trace result for transaction {index}: {trace_result:?}"); } Ok(()) } diff --git a/examples/transactions/examples/trace_transaction.rs b/examples/transactions/examples/trace_transaction.rs index 5a102a60..5b542da0 100644 --- a/examples/transactions/examples/trace_transaction.rs +++ b/examples/transactions/examples/trace_transaction.rs @@ -15,7 +15,7 @@ async fn main() -> Result<()> { // Spin up a forked Anvil node. // Ensure `anvil` is available in $PATH. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc"; - let provider = ProviderBuilder::new().on_anvil_with_config(|anvil| anvil.fork(rpc_url)); + let provider = ProviderBuilder::new().connect_anvil_with_config(|anvil| anvil.fork(rpc_url)); // Hash of the tx we want to trace. let hash = b256!("97a02abf405d36939e5b232a5d4ef5206980c5a6661845436058f30600c52df7"); diff --git a/examples/transactions/examples/transfer_erc20.rs b/examples/transactions/examples/transfer_erc20.rs index 49793c87..f9de5f29 100644 --- a/examples/transactions/examples/transfer_erc20.rs +++ b/examples/transactions/examples/transfer_erc20.rs @@ -21,7 +21,7 @@ async fn main() -> Result<()> { // Ensure `anvil` is available in $PATH. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc"; let provider = - ProviderBuilder::new().on_anvil_with_wallet_and_config(|anvil| anvil.fork(rpc_url))?; + ProviderBuilder::new().connect_anvil_with_wallet_and_config(|anvil| anvil.fork(rpc_url))?; // Create two users, Alice and Bob. let accounts = provider.get_accounts().await?; diff --git a/examples/transactions/examples/transfer_eth.rs b/examples/transactions/examples/transfer_eth.rs index 497ed8aa..850ca035 100644 --- a/examples/transactions/examples/transfer_eth.rs +++ b/examples/transactions/examples/transfer_eth.rs @@ -12,7 +12,7 @@ use eyre::Result; async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil_with_wallet(); + let provider = ProviderBuilder::new().connect_anvil_with_wallet(); // Create two users, Alice and Bob. let accounts = provider.get_accounts().await?; diff --git a/examples/transactions/examples/with_access_list.rs b/examples/transactions/examples/with_access_list.rs index 7f4ed743..0e2ca26e 100644 --- a/examples/transactions/examples/with_access_list.rs +++ b/examples/transactions/examples/with_access_list.rs @@ -19,7 +19,7 @@ sol!( async fn main() -> Result<()> { // Spin up a local Anvil node. // Ensure `anvil` is available in $PATH. - let provider = ProviderBuilder::new().on_anvil(); + let provider = ProviderBuilder::new().connect_anvil(); // Create two users, Alice and Bob. let accounts = provider.get_accounts().await?; diff --git a/examples/wallets/Cargo.toml b/examples/wallets/Cargo.toml index 04914b7d..840ce69d 100644 --- a/examples/wallets/Cargo.toml +++ b/examples/wallets/Cargo.toml @@ -16,9 +16,9 @@ workspace = true alloy.workspace = true aws-config = { version = "1.6", default-features = false } -aws-sdk-kms = { version = "1.63", default-features = false } +aws-sdk-kms = { version = "1.68", default-features = false } eyre.workspace = true -gcloud-sdk = { version = "0.26", features = [ +gcloud-sdk = { version = "0.27", features = [ "google-cloud-kms-v1", "google-longrunning", ] } diff --git a/examples/wallets/examples/ethereum_wallet.rs b/examples/wallets/examples/ethereum_wallet.rs index 02a168d3..0e44b3b2 100644 --- a/examples/wallets/examples/ethereum_wallet.rs +++ b/examples/wallets/examples/ethereum_wallet.rs @@ -48,7 +48,7 @@ async fn main() -> eyre::Result<()> { wallet.register_signer(ledger); // Create a provider with the `WalletFiller`. - let provider = ProviderBuilder::new().wallet(wallet).on_http(anvil.endpoint_url()); + let provider = ProviderBuilder::new().wallet(wallet).connect_http(anvil.endpoint_url()); // Note that the `from` field hasn't been specified. // The wallet filler in the provider will set to it the default signer's address, which is diff --git a/examples/wallets/examples/keystore_signer.rs b/examples/wallets/examples/keystore_signer.rs index fdbd2218..872654e5 100644 --- a/examples/wallets/examples/keystore_signer.rs +++ b/examples/wallets/examples/keystore_signer.rs @@ -23,8 +23,9 @@ async fn main() -> Result<()> { let signer = LocalSigner::decrypt_keystore(keystore_file_path, password)?; // Create a provider with the wallet. - let provider = - ProviderBuilder::new().wallet(signer).on_anvil_with_config(|anvil| anvil.block_time(1)); + let provider = ProviderBuilder::new() + .wallet(signer) + .connect_anvil_with_config(|anvil| anvil.block_time(1)); // Build a transaction to send 100 wei from Alice to Vitalik. // The `from` field is automatically filled to the first signer's address (Alice). diff --git a/examples/wallets/examples/ledger_signer.rs b/examples/wallets/examples/ledger_signer.rs index d323f4c8..9a12bdda 100644 --- a/examples/wallets/examples/ledger_signer.rs +++ b/examples/wallets/examples/ledger_signer.rs @@ -16,7 +16,7 @@ async fn main() -> Result<()> { // Create a provider with the wallet. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc".parse()?; - let provider = ProviderBuilder::new().wallet(signer).on_http(rpc_url); + let provider = ProviderBuilder::new().wallet(signer).connect_http(rpc_url); // Build a transaction to send 100 wei from Alice to Vitalik. // The `from` field is automatically filled to the first signer's address (Alice). diff --git a/examples/wallets/examples/private_key_signer.rs b/examples/wallets/examples/private_key_signer.rs index b8ea78f9..93fbd18e 100644 --- a/examples/wallets/examples/private_key_signer.rs +++ b/examples/wallets/examples/private_key_signer.rs @@ -24,7 +24,7 @@ async fn main() -> Result<()> { // Create a provider with the wallet. let rpc_url = anvil.endpoint_url(); - let provider = ProviderBuilder::new().wallet(signer).on_http(rpc_url); + let provider = ProviderBuilder::new().wallet(signer).connect_http(rpc_url); // Build a transaction to send 100 wei from Alice to Vitalik. // The `from` field is automatically filled to the first signer's address (Alice). diff --git a/examples/wallets/examples/trezor_signer.rs b/examples/wallets/examples/trezor_signer.rs index 506ce137..e9515d09 100644 --- a/examples/wallets/examples/trezor_signer.rs +++ b/examples/wallets/examples/trezor_signer.rs @@ -16,7 +16,7 @@ async fn main() -> Result<()> { // Create a provider with the wallet. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc".parse()?; - let provider = ProviderBuilder::new().wallet(signer).on_http(rpc_url); + let provider = ProviderBuilder::new().wallet(signer).connect_http(rpc_url); // Build a transaction to send 100 wei from Alice to Vitalik. // The `from` field is automatically filled to the first signer's address (Alice). diff --git a/examples/wallets/examples/yubi_signer.rs b/examples/wallets/examples/yubi_signer.rs index 3d0fa583..b2e60a8d 100644 --- a/examples/wallets/examples/yubi_signer.rs +++ b/examples/wallets/examples/yubi_signer.rs @@ -25,7 +25,7 @@ async fn main() -> Result<()> { // Create a provider with the wallet. let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc".parse()?; - let provider = ProviderBuilder::new().wallet(signer).on_http(rpc_url); + let provider = ProviderBuilder::new().wallet(signer).connect_http(rpc_url); // Build a transaction to send 100 wei from Alice to Vitalik. // The `from` field is automatically filled to the first signer's address (Alice).