diff --git a/examples/advanced/examples/reth_db_layer.rs b/examples/advanced/examples/reth_db_layer.rs index 74fa1fc8..9945d263 100644 --- a/examples/advanced/examples/reth_db_layer.rs +++ b/examples/advanced/examples/reth_db_layer.rs @@ -1,5 +1,6 @@ //! `RethDbLayer` implementation to be used with `RethDbProvider` to wrap the Provider trait over //! reth-db. + #![allow(dead_code)] use std::path::PathBuf; diff --git a/examples/advanced/examples/reth_db_provider.rs b/examples/advanced/examples/reth_db_provider.rs index 6a9a9dbd..c74a9daa 100644 --- a/examples/advanced/examples/reth_db_provider.rs +++ b/examples/advanced/examples/reth_db_provider.rs @@ -10,6 +10,7 @@ //! their own implementation of the `Provider` trait and fetch results from any source. //! //! Learn more about `ProviderCall` [here](https://github.com/alloy-rs/alloy/pull/788). + use std::{marker::PhantomData, path::PathBuf, sync::Arc}; use alloy::{ diff --git a/examples/big-numbers/examples/comparison_equivalence.rs b/examples/big-numbers/examples/comparison_equivalence.rs index 34b05663..e125206b 100644 --- a/examples/big-numbers/examples/comparison_equivalence.rs +++ b/examples/big-numbers/examples/comparison_equivalence.rs @@ -1,10 +1,11 @@ //! Example of comparison and equivalence of `U256` instances. use alloy::primitives::U256; +use eyre::Result; /// `U256` implements traits in `std::cmp`, that means `U256` instances /// can be easily compared using standard Rust operators. -fn main() { +fn main() -> Result<()> { // a == b let a = U256::from(100_u32); let b = U256::from(100_u32); @@ -33,4 +34,6 @@ fn main() { // a == 0 let a = U256::ZERO; assert!(a.is_zero()); + + Ok(()) } diff --git a/examples/big-numbers/examples/create_instances.rs b/examples/big-numbers/examples/create_instances.rs index 9afdfe7f..aad5a010 100644 --- a/examples/big-numbers/examples/create_instances.rs +++ b/examples/big-numbers/examples/create_instances.rs @@ -1,11 +1,12 @@ //! Example of creating instances of `U256` from strings and numbers. +use std::str::FromStr; + use alloy::primitives::{ utils::{parse_units, ParseUnits}, U256, }; use eyre::Result; -use std::str::FromStr; fn main() -> Result<()> { // From strings diff --git a/examples/big-numbers/examples/math_operations.rs b/examples/big-numbers/examples/math_operations.rs index 50177bfc..2ea075ae 100644 --- a/examples/big-numbers/examples/math_operations.rs +++ b/examples/big-numbers/examples/math_operations.rs @@ -1,8 +1,9 @@ //! Example of performing arithmetic operations with `U256`. +use std::ops::{Div, Mul}; + use alloy::primitives::{utils::format_units, U256}; use eyre::Result; -use std::ops::{Div, Mul}; /// `U256` implements traits in `std::ops`, that means it supports arithmetic operations /// using standard Rust operators `+`, `-`. `*`, `/`, `%`, along with additional utilities to diff --git a/examples/comparison/examples/compare_new_heads.rs b/examples/comparison/examples/compare_new_heads.rs index c5c61ae4..4f189403 100644 --- a/examples/comparison/examples/compare_new_heads.rs +++ b/examples/comparison/examples/compare_new_heads.rs @@ -1,5 +1,7 @@ //! Example of comparing new block headers from multiple providers. +use std::{collections::HashMap, sync::Arc}; + use alloy::{ network::AnyNetwork, providers::{Provider, ProviderBuilder}, @@ -8,7 +10,6 @@ use chrono::Utc; use clap::Parser; use eyre::Result; use futures_util::StreamExt; -use std::{collections::HashMap, sync::Arc}; use tokio::sync::mpsc; #[derive(Debug, Parser)] diff --git a/examples/layers/examples/logging_layer.rs b/examples/layers/examples/logging_layer.rs index 98a37866..47e91e00 100644 --- a/examples/layers/examples/logging_layer.rs +++ b/examples/layers/examples/logging_layer.rs @@ -1,6 +1,13 @@ //! This examples demonstrates how to implement your own custom transport layer. //! As a demonstration we implement a simple request / response logging layer. +use std::{ + fmt::Debug, + future::{Future, IntoFuture}, + pin::Pin, + task::{Context, Poll}, +}; + use alloy::{ node_bindings::Anvil, providers::{Provider, ProviderBuilder}, @@ -11,12 +18,6 @@ use alloy::{ transports::TransportError, }; use eyre::Result; -use std::{ - fmt::Debug, - future::{Future, IntoFuture}, - pin::Pin, - task::{Context, Poll}, -}; use tower::{Layer, Service}; struct LoggingLayer; diff --git a/examples/primitives/examples/hashing_functions.rs b/examples/primitives/examples/hashing_functions.rs index d8218828..cad389ca 100644 --- a/examples/primitives/examples/hashing_functions.rs +++ b/examples/primitives/examples/hashing_functions.rs @@ -1,7 +1,7 @@ //! Example of basic usage of hashing functions. use alloy::primitives::{eip191_hash_message, keccak256}; -use eyre::{Ok, Result}; +use eyre::Result; fn main() -> Result<()> { // [`Keccak-256`]: https://en.wikipedia.org/wiki/SHA-3 diff --git a/examples/providers/examples/batch_rpc.rs b/examples/providers/examples/batch_rpc.rs index 260f2b35..e405888a 100644 --- a/examples/providers/examples/batch_rpc.rs +++ b/examples/providers/examples/batch_rpc.rs @@ -9,6 +9,8 @@ use eyre::Result; #[tokio::main] async fn main() -> Result<()> { + // Spin up a local Anvil node. + // Ensure `anvil` is available in $PATH. let anvil = Anvil::new().spawn(); // Swap this out with a RPC_URL provider that supports JSON-RPC batch requests. e.g. https://eth.merkle.io @@ -28,7 +30,6 @@ async fn main() -> Result<()> { batch.add_call("eth_gasPrice", &())?.map_resp(|resp: U128| resp.to::()); let vitalik = address!("d8da6bf26964af9d7eed9e03e53415d37aa96045"); - let vitalik_nonce_fut = batch .add_call("eth_getTransactionCount", &(vitalik, "latest"))? // Vitalik's nonce at BlockId::Latest .map_resp(|resp: U128| resp.to::()); diff --git a/examples/subscriptions/examples/event_multiplexer.rs b/examples/subscriptions/examples/event_multiplexer.rs index 9cfc2caa..9116a404 100644 --- a/examples/subscriptions/examples/event_multiplexer.rs +++ b/examples/subscriptions/examples/event_multiplexer.rs @@ -1,5 +1,7 @@ //! Example of multiplexing the watching of event logs. +use std::str::FromStr; + use alloy::{ node_bindings::Anvil, primitives::I256, @@ -9,7 +11,6 @@ use alloy::{ }; use eyre::Result; use futures_util::StreamExt; -use std::str::FromStr; // Codegen from embedded Solidity code and precompiled bytecode. // solc v0.8.26; solc EventMultiplexer.sol --via-ir --optimize --bin diff --git a/examples/transactions/examples/trace_call_many.rs b/examples/transactions/examples/trace_call_many.rs index 862f581f..66ba47e3 100644 --- a/examples/transactions/examples/trace_call_many.rs +++ b/examples/transactions/examples/trace_call_many.rs @@ -7,8 +7,7 @@ use alloy::{ providers::{ext::TraceApi, ProviderBuilder}, rpc::types::{trace::parity::TraceType, TransactionRequest}, }; - -use eyre::{Ok, Result}; +use eyre::Result; #[tokio::main] async fn main() -> Result<()> { diff --git a/examples/wallets/examples/create_keystore.rs b/examples/wallets/examples/create_keystore.rs index 03f2be0b..c2ef692b 100644 --- a/examples/wallets/examples/create_keystore.rs +++ b/examples/wallets/examples/create_keystore.rs @@ -1,9 +1,10 @@ //! Example of creating a keystore file from a private key and password, and then reading it back. +use std::fs::read_to_string; + use alloy::{primitives::hex, signers::local::LocalSigner}; use eyre::Result; use rand::thread_rng; -use std::fs::read_to_string; use tempfile::tempdir; #[tokio::main] diff --git a/examples/wallets/examples/gcp_signer.rs b/examples/wallets/examples/gcp_signer.rs index 2c6d3420..77f20e65 100644 --- a/examples/wallets/examples/gcp_signer.rs +++ b/examples/wallets/examples/gcp_signer.rs @@ -4,7 +4,7 @@ use alloy::signers::{ gcp::{GcpKeyRingRef, GcpSigner, KeySpecifier}, Signer, }; -use eyre::{Ok, Result}; +use eyre::Result; use gcloud_sdk::{ google::cloud::kms::v1::key_management_service_client::KeyManagementServiceClient, GoogleApi, }; diff --git a/examples/wallets/examples/keystore_signer.rs b/examples/wallets/examples/keystore_signer.rs index 239a8ac5..5a7a05ad 100644 --- a/examples/wallets/examples/keystore_signer.rs +++ b/examples/wallets/examples/keystore_signer.rs @@ -1,5 +1,7 @@ //! Example of using a keystore wallet to sign and send a transaction. +use std::path::PathBuf; + use alloy::{ network::{EthereumWallet, TransactionBuilder}, primitives::{address, U256}, @@ -8,7 +10,6 @@ use alloy::{ signers::local::LocalSigner, }; use eyre::Result; -use std::{env, path::PathBuf}; #[tokio::main] async fn main() -> Result<()> { @@ -18,7 +19,7 @@ async fn main() -> Result<()> { // Set up signer using Alice's keystore file. // The private key belongs to Alice, the first default Anvil account. let keystore_file_path = - PathBuf::from(env::var("CARGO_MANIFEST_DIR")?).join("examples/keystore/alice.json"); + PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?).join("examples/keystore/alice.json"); let signer = LocalSigner::decrypt_keystore(keystore_file_path, password)?; let wallet = EthereumWallet::from(signer); diff --git a/examples/wallets/examples/verify_message.rs b/examples/wallets/examples/verify_message.rs index f00a83d2..f523cbed 100644 --- a/examples/wallets/examples/verify_message.rs +++ b/examples/wallets/examples/verify_message.rs @@ -1,7 +1,7 @@ //! Example of verifying that a message was signed by the provided address. use alloy::signers::{local::PrivateKeySigner, SignerSync}; -use eyre::{Ok, Result}; +use eyre::Result; #[tokio::main] async fn main() -> Result<()> {