dep: replace anyhow with eyre in examples (#859)

This commit is contained in:
James Prestwich 2022-02-03 12:36:05 -08:00 committed by GitHub
parent d08f3ed2d4
commit 99230afd32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 18 additions and 19 deletions

2
Cargo.lock generated
View File

@ -1125,7 +1125,6 @@ dependencies = [
name = "ethers" name = "ethers"
version = "0.6.0" version = "0.6.0"
dependencies = [ dependencies = [
"anyhow",
"bytes", "bytes",
"ethers-addressbook", "ethers-addressbook",
"ethers-contract", "ethers-contract",
@ -1135,6 +1134,7 @@ dependencies = [
"ethers-providers", "ethers-providers",
"ethers-signers", "ethers-signers",
"ethers-solc", "ethers-solc",
"eyre",
"hex", "hex",
"rand 0.8.4", "rand 0.8.4",
"serde", "serde",

View File

@ -97,7 +97,7 @@ ethers-providers = { version = "^0.6.0", default-features = false, path = "./eth
[target.'cfg(target_family = "unix")'.dev-dependencies] [target.'cfg(target_family = "unix")'.dev-dependencies]
ethers-providers = { version = "^0.6.0", default-features = false, path = "./ethers-providers", features = ["ws", "ipc"] } ethers-providers = { version = "^0.6.0", default-features = false, path = "./ethers-providers", features = ["ws", "ipc"] }
anyhow = "1.0.39" eyre = "0.6.6"
rand = "0.8.4" rand = "0.8.4"
serde = { version = "1.0.124", features = ["derive"] } serde = { version = "1.0.124", features = ["derive"] }
serde_json = "1.0.64" serde_json = "1.0.64"

View File

@ -1,6 +1,6 @@
use ethers::{contract::Abigen, solc::Solc}; use ethers::{contract::Abigen, solc::Solc};
fn main() -> anyhow::Result<()> { fn main() -> eyre::Result<()> {
let mut args = std::env::args(); let mut args = std::env::args();
args.next().unwrap(); // skip program name args.next().unwrap(); // skip program name

View File

@ -1,9 +1,9 @@
use anyhow::Result;
use ethers::{ use ethers::{
prelude::*, prelude::*,
solc::{Project, ProjectPathsConfig}, solc::{Project, ProjectPathsConfig},
utils::Ganache, utils::Ganache,
}; };
use eyre::Result;
use std::{convert::TryFrom, path::PathBuf, sync::Arc, time::Duration}; use std::{convert::TryFrom, path::PathBuf, sync::Arc, time::Duration};
// Generate the type-safe contract bindings by providing the ABI // Generate the type-safe contract bindings by providing the ABI

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use ethers::{prelude::*, utils::Ganache}; use ethers::{prelude::*, utils::Ganache};
use eyre::Result;
use std::{convert::TryFrom, path::Path, sync::Arc, time::Duration}; use std::{convert::TryFrom, path::Path, sync::Arc, time::Duration};
// Generate the type-safe contract bindings by providing the ABI // Generate the type-safe contract bindings by providing the ABI

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use ethers::{prelude::*, utils::Ganache}; use ethers::{prelude::*, utils::Ganache};
use eyre::Result;
use std::convert::TryFrom; use std::convert::TryFrom;
#[tokio::main] #[tokio::main]
@ -20,7 +20,7 @@ async fn main() -> Result<()> {
.send_transaction(tx, None) .send_transaction(tx, None)
.await? .await?
.await? .await?
.ok_or_else(|| anyhow::format_err!("tx dropped from mempool"))?; .ok_or_else(|| eyre::format_err!("tx dropped from mempool"))?;
let tx = provider.get_transaction(receipt.transaction_hash).await?; let tx = provider.get_transaction(receipt.transaction_hash).await?;
println!("{}", serde_json::to_string(&tx)?); println!("{}", serde_json::to_string(&tx)?);

View File

@ -1,6 +1,6 @@
#[tokio::main] #[tokio::main]
#[cfg(feature = "ipc")] #[cfg(feature = "ipc")]
async fn main() -> anyhow::Result<()> { async fn main() -> eyre::Result<()> {
use ethers::prelude::*; use ethers::prelude::*;
let provider = Provider::connect_ipc("~/.ethereum/geth.ipc") let provider = Provider::connect_ipc("~/.ethereum/geth.ipc")

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use ethers::{prelude::*, utils::Ganache}; use ethers::{prelude::*, utils::Ganache};
use eyre::Result;
use std::convert::TryFrom; use std::convert::TryFrom;
#[tokio::main] #[tokio::main]
@ -22,8 +22,7 @@ async fn main() -> Result<()> {
let pending_tx = client.send_transaction(tx, None).await?; let pending_tx = client.send_transaction(tx, None).await?;
// get the mined tx // get the mined tx
let receipt = let receipt = pending_tx.await?.ok_or_else(|| eyre::format_err!("tx dropped from mempool"))?;
pending_tx.await?.ok_or_else(|| anyhow::format_err!("tx dropped from mempool"))?;
let tx = client.get_transaction(receipt.transaction_hash).await?; let tx = client.get_transaction(receipt.transaction_hash).await?;
println!("Sent tx: {}\n", serde_json::to_string(&tx)?); println!("Sent tx: {}\n", serde_json::to_string(&tx)?);

View File

@ -1,6 +1,6 @@
use ethers::signers::{coins_bip39::English, MnemonicBuilder}; use ethers::signers::{coins_bip39::English, MnemonicBuilder};
fn main() -> anyhow::Result<()> { fn main() -> eyre::Result<()> {
let phrase = "work man father plunge mystery proud hollow address reunion sauce theory bonus"; let phrase = "work man father plunge mystery proud hollow address reunion sauce theory bonus";
let index = 0u32; let index = 0u32;
let password = "TREZOR123"; let password = "TREZOR123";

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use ethers::prelude::*; use ethers::prelude::*;
use eyre::Result;
use std::{convert::TryFrom, path::Path, sync::Arc, time::Duration}; use std::{convert::TryFrom, path::Path, sync::Arc, time::Duration};
abigen!( abigen!(

View File

@ -5,7 +5,7 @@ use ethers::{prelude::*, utils::Ganache};
use std::{str::FromStr, time::Duration}; use std::{str::FromStr, time::Duration};
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> eyre::Result<()> {
let ganache = Ganache::new().spawn(); let ganache = Ganache::new().spawn();
// create a quorum provider with some providers // create a quorum provider with some providers

View File

@ -1,5 +1,5 @@
// use the anyhow crate for easy idiomatic error handling // use the eyre crate for easy idiomatic error handling
use anyhow::Result; use eyre::Result;
// use the ethers_core rand for rng // use the ethers_core rand for rng
use ethers_core::rand::thread_rng; use ethers_core::rand::thread_rng;
// use the ethers_signers crate to manage LocalWallet and Signer // use the ethers_signers crate to manage LocalWallet and Signer

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use ethers::{prelude::*, utils::Ganache}; use ethers::{prelude::*, utils::Ganache};
use eyre::Result;
use std::convert::TryFrom; use std::convert::TryFrom;
#[tokio::main] #[tokio::main]

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use ethers::prelude::*; use ethers::prelude::*;
use eyre::Result;
use std::sync::Arc; use std::sync::Arc;
// Generate the type-safe contract bindings by providing the ABI // Generate the type-safe contract bindings by providing the ABI

View File

@ -2,7 +2,7 @@ use ethers::{prelude::*, utils::Ganache};
use std::time::Duration; use std::time::Duration;
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> eyre::Result<()> {
let ganache = Ganache::new().block_time(1u64).spawn(); let ganache = Ganache::new().block_time(1u64).spawn();
let ws = Ws::connect(ganache.ws_endpoint()).await?; let ws = Ws::connect(ganache.ws_endpoint()).await?;
let provider = Provider::new(ws).interval(Duration::from_millis(2000)); let provider = Provider::new(ws).interval(Duration::from_millis(2000));