diff --git a/examples/wallets/Cargo.toml b/examples/wallets/Cargo.toml index f5ee9c26..6839cda9 100644 --- a/examples/wallets/Cargo.toml +++ b/examples/wallets/Cargo.toml @@ -24,7 +24,7 @@ alloy-signer-wallet = { workspace = true, features = ["mnemonic", "yubihsm"] } alloy-sol-types.workspace = true alloy-transport-http.workspace = true -rand.workspace = true +eyre.workspace = true reqwest.workspace = true serde.workspace = true tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } diff --git a/examples/wallets/examples/ledger_signer.rs b/examples/wallets/examples/ledger_signer.rs index ca7b2be3..a25aa495 100644 --- a/examples/wallets/examples/ledger_signer.rs +++ b/examples/wallets/examples/ledger_signer.rs @@ -7,15 +7,18 @@ use alloy_rpc_client::RpcClient; use alloy_rpc_types::request::TransactionRequest; use alloy_signer_ledger::{HDPath, LedgerSigner}; use alloy_transport_http::Http; +use eyre::Result; use reqwest::Client; #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<()> { // Instantiate the application by acquiring a lock on the Ledger device. let signer = LedgerSigner::new(HDPath::LedgerLive(0), Some(1)).await?; // Create a provider with the signer and the network. let http = Http::::new("http://localhost:8545".parse()?); + + // Initialize the provider. let provider = ProviderBuilder::new() .signer(EthereumSigner::from(signer)) .provider(RootProvider::new(RpcClient::new(http, true))); @@ -32,7 +35,7 @@ async fn main() -> Result<(), Box> { // Broadcast the transaction and wait for the receipt. let receipt = provider.send_transaction(tx).await?.with_confirmations(3).get_receipt().await?; - println!("Send transaction: {:?}", receipt.transaction_hash.unwrap()); + println!("Send transaction: {:?}", receipt.transaction_hash.unwrap_or_default()); Ok(()) } diff --git a/examples/wallets/examples/mnemonic_signer.rs b/examples/wallets/examples/mnemonic_signer.rs index f11214f1..079323b6 100644 --- a/examples/wallets/examples/mnemonic_signer.rs +++ b/examples/wallets/examples/mnemonic_signer.rs @@ -1,9 +1,10 @@ //! Example of using `MnemonicBuilder` to access a wallet from a mnemonic phrase. use alloy_signer_wallet::{coins_bip39::English, MnemonicBuilder}; +use eyre::Result; #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<()> { let phrase = "work man father plunge mystery proud hollow address reunion sauce theory bonus"; let index = 0u32; let password = "TREZOR123"; diff --git a/examples/wallets/examples/private_key_signer.rs b/examples/wallets/examples/private_key_signer.rs index 73e03872..4454d560 100644 --- a/examples/wallets/examples/private_key_signer.rs +++ b/examples/wallets/examples/private_key_signer.rs @@ -8,10 +8,11 @@ use alloy_rpc_client::RpcClient; use alloy_rpc_types::request::TransactionRequest; use alloy_signer_wallet::LocalWallet; use alloy_transport_http::Http; +use eyre::Result; use reqwest::Client; #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<()> { // Spin up an Anvil node. let anvil = Anvil::new().block_time(1).spawn(); diff --git a/examples/wallets/examples/sign_message.rs b/examples/wallets/examples/sign_message.rs index 67689b96..61e30e57 100644 --- a/examples/wallets/examples/sign_message.rs +++ b/examples/wallets/examples/sign_message.rs @@ -2,9 +2,10 @@ use alloy_signer::Signer; use alloy_signer_wallet::LocalWallet; +use eyre::Result; #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<()> { // Setup up wallet. let wallet = LocalWallet::random(); diff --git a/examples/wallets/examples/sign_permit_hash.rs b/examples/wallets/examples/sign_permit_hash.rs index cf75db74..c9b6da78 100644 --- a/examples/wallets/examples/sign_permit_hash.rs +++ b/examples/wallets/examples/sign_permit_hash.rs @@ -4,6 +4,7 @@ use alloy_primitives::{address, keccak256, U256}; use alloy_signer::Signer; use alloy_signer_wallet::LocalWallet; use alloy_sol_types::{eip712_domain, sol, SolStruct}; +use eyre::Result; use serde::Serialize; sol! { @@ -18,7 +19,7 @@ sol! { } #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<()> { // Setup up wallet. let wallet = LocalWallet::random(); diff --git a/examples/wallets/examples/trezor_signer.rs b/examples/wallets/examples/trezor_signer.rs index baac9eb9..b18a7d09 100644 --- a/examples/wallets/examples/trezor_signer.rs +++ b/examples/wallets/examples/trezor_signer.rs @@ -7,10 +7,11 @@ use alloy_rpc_client::RpcClient; use alloy_rpc_types::request::TransactionRequest; use alloy_signer_trezor::{TrezorHDPath, TrezorSigner}; use alloy_transport_http::Http; +use eyre::Result; use reqwest::Client; #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<()> { // Instantiate the application by acquiring a lock on the Trezor device. let signer = TrezorSigner::new(TrezorHDPath::TrezorLive(0), Some(1)).await?; diff --git a/examples/wallets/examples/yubi_signer.rs b/examples/wallets/examples/yubi_signer.rs index afeb1a33..81fd4060 100644 --- a/examples/wallets/examples/yubi_signer.rs +++ b/examples/wallets/examples/yubi_signer.rs @@ -10,10 +10,11 @@ use alloy_signer_wallet::{ YubiWallet, }; use alloy_transport_http::Http; +use eyre::Result; use reqwest::Client; #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<()> { // We use USB for the example, but you can connect over HTTP as well. Refer // to the [YubiHSM](https://docs.rs/yubihsm/0.34.0/yubihsm/) docs for more information. let connector = Connector::usb(&UsbConfig::default());