Skip to content

Commit

Permalink
Merge pull request #646 from worldcoin/dcbuild3r/upgrade-ethers
Browse files Browse the repository at this point in the history
upgrade ethers
  • Loading branch information
dcbuild3r authored Nov 13, 2023
2 parents 47d8ebe + dc68374 commit fc4fd96
Show file tree
Hide file tree
Showing 14 changed files with 1,551 additions and 1,364 deletions.
1,322 changes: 538 additions & 784 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ cli-batteries = { git = "https://github.com/recmo/cli-batteries", rev = "fc1186d
"datadog",
] }
cognitoauth = { git = "https://github.com/lucdew/cognito-srp-auth.git" }
ethers = { version = "1.0.0", features = ["ws", "ipc", "openssl", "abigen"] }
ethers = { version = "2.0.10", features = ["ws", "ipc", "openssl", "abigen"] }
ethers-solc = "2.0.10"
eyre = "0.6"
futures = "0.3"
futures-util = { version = "^0.3" }
Expand Down
2 changes: 1 addition & 1 deletion crates/micro-oz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async-trait = "0.1.71"
axum = "0.6.19"
chrono = "0.4.26"
clap = { version = "4.3.14", features = ["env", "derive"] }
ethers = { version = "1.0.0", features = ["openssl"] }
ethers = { version = "2.0.10", features = ["openssl"] }
hyper = "0.14.27"
oz-api = { path = "../oz-api" }
serde = "1.0.171"
Expand Down
2 changes: 1 addition & 1 deletion crates/oz-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
anyhow = "1.0"
chrono = { version = "0.4.23", features = ["serde"] }
cognitoauth = { git = "https://github.com/lucdew/cognito-srp-auth.git" }
ethers = { version = "1.0.0", features = [ "ws", "ipc", "openssl", "abigen" ] }
ethers = { version = "2.0.10", features = [ "ws", "ipc", "openssl", "abigen" ] }
hyper = { version = "^0.14.17", features = ["server", "tcp", "http1", "http2"] }
reqwest = "0.11.14"
serde = { version = "1.0.154", features = ["derive"] }
Expand Down
Empty file added error.txt
Empty file.
8 changes: 3 additions & 5 deletions src/ethereum/read/mod.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use anyhow::{anyhow, Result as AnyhowResult};
use chrono::{Duration as ChronoDuration, Utc};
use ethers::abi::Error as AbiError;
use ethers::providers::{Middleware, Provider};
use ethers::providers::{Http, Middleware, Provider};
use ethers::types::{BlockId, BlockNumber, Chain, U256};
use futures::{try_join, FutureExt};
use thiserror::Error;
use tracing::{error, info};
use url::Url;

use self::rpc_logger::RpcLogger;
use self::transport::Transport;

pub mod rpc_logger;
pub mod transport;

type InnerProvider = Provider<RpcLogger<Transport>>;
type InnerProvider = Provider<RpcLogger<Http>>;

#[derive(Clone, Debug)]
pub struct ReadProvider {
Expand All @@ -37,7 +35,7 @@ impl ReadProvider {
provider = %url,
"Connecting to provider"
);
let transport = Transport::new(url).await?;
let transport = Http::new(url);
let logger = RpcLogger::new(transport);
let provider = Provider::new(logger);

Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/read/rpc_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where
async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
where
T: Debug + Serialize + Send + Sync,
R: DeserializeOwned,
R: DeserializeOwned + Send,
{
REQUESTS.with_label_values(&[method]).inc();
let timer = LATENCY.start_timer();
Expand Down
88 changes: 0 additions & 88 deletions src/ethereum/read/transport.rs

This file was deleted.

18 changes: 17 additions & 1 deletion src/ethereum/write_oz/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ethers::providers::ProviderError;
use ethers::providers::{JsonRpcError, ProviderError, RpcError};
use thiserror::Error;

#[derive(Error, Debug)]
Expand All @@ -15,6 +15,22 @@ pub enum Error {
MissingTransactionId,
}

impl RpcError for Error {
fn as_error_response(&self) -> Option<&JsonRpcError> {
match self {
Error::Transport(err) => err.as_error_response(),
_ => None,
}
}

fn as_serde_error(&self) -> Option<&serde_json::Error> {
match self {
Error::Transport(err) => err.as_serde_error(),
_ => None,
}
}
}

impl From<Error> for ProviderError {
fn from(error: Error) -> Self {
Self::JsonRpcClientError(Box::new(error))
Expand Down
Loading

0 comments on commit fc4fd96

Please sign in to comment.