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"
version = "0.6.0"
dependencies = [
"anyhow",
"bytes",
"ethers-addressbook",
"ethers-contract",
@ -1135,6 +1134,7 @@ dependencies = [
"ethers-providers",
"ethers-signers",
"ethers-solc",
"eyre",
"hex",
"rand 0.8.4",
"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]
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"
serde = { version = "1.0.124", features = ["derive"] }
serde_json = "1.0.64"

View File

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

View File

@ -1,9 +1,9 @@
use anyhow::Result;
use ethers::{
prelude::*,
solc::{Project, ProjectPathsConfig},
utils::Ganache,
};
use eyre::Result;
use std::{convert::TryFrom, path::PathBuf, sync::Arc, time::Duration};
// 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 eyre::Result;
use std::{convert::TryFrom, path::Path, sync::Arc, time::Duration};
// 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 eyre::Result;
use std::convert::TryFrom;
#[tokio::main]
@ -20,7 +20,7 @@ async fn main() -> Result<()> {
.send_transaction(tx, None)
.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?;
println!("{}", serde_json::to_string(&tx)?);

View File

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

View File

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

View File

@ -1,6 +1,6 @@
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 index = 0u32;
let password = "TREZOR123";

View File

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

View File

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

View File

@ -1,5 +1,5 @@
// use the anyhow crate for easy idiomatic error handling
use anyhow::Result;
// use the eyre crate for easy idiomatic error handling
use eyre::Result;
// use the ethers_core rand for rng
use ethers_core::rand::thread_rng;
// 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 eyre::Result;
use std::convert::TryFrom;
#[tokio::main]

View File

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