upgrade ethers to 2.0.2
This commit is contained in:
parent
55924ff840
commit
7250a0c155
806
Cargo.lock
generated
806
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -13,5 +13,5 @@ path = "src/mod.rs"
|
||||
sea-orm = "0.11.2"
|
||||
serde = "1.0.159"
|
||||
uuid = "1.3.1"
|
||||
ethers = "1.0.2"
|
||||
ethers = "2.0.2"
|
||||
ulid = "1.0.0"
|
||||
|
@ -35,7 +35,7 @@ counter = "0.5.7"
|
||||
derive_more = "0.99.17"
|
||||
dotenv = "0.15.0"
|
||||
env_logger = "0.10.0"
|
||||
ethers = { version = "1.0.2", default-features = false, features = ["rustls", "ws"] }
|
||||
ethers = { version = "2.0.2", default-features = false, features = ["rustls", "ws"] }
|
||||
ewma = "0.1.1"
|
||||
fdlimit = "0.2.1"
|
||||
flume = "0.10.14"
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::frontend::errors::Web3ProxyResult;
|
||||
use crate::frontend::errors::{Web3ProxyError, Web3ProxyResult};
|
||||
use derive_more::From;
|
||||
use ethers::prelude::{HttpClientError, ProviderError, WsClientError};
|
||||
use ethers::prelude::ProviderError;
|
||||
use serde::de::{self, Deserializer, MapAccess, SeqAccess, Visitor};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
@ -248,41 +248,16 @@ impl JsonRpcForwardedResponse {
|
||||
let data;
|
||||
|
||||
match e {
|
||||
ProviderError::JsonRpcClientError(e) => {
|
||||
// TODO: check what type the provider is rather than trying to downcast both types of errors
|
||||
let e = e.downcast::<HttpClientError>();
|
||||
|
||||
if let Ok(e) = e {
|
||||
match *e {
|
||||
HttpClientError::JsonRpcError(e) => {
|
||||
code = e.code;
|
||||
message = e.message.clone();
|
||||
data = e.data;
|
||||
}
|
||||
e => {
|
||||
// this is not an rpc error. keep it as an error
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
ProviderError::JsonRpcClientError(err) => {
|
||||
if let Some(err) = err.as_error_response() {
|
||||
code = err.code;
|
||||
message = err.message.clone();
|
||||
data = err.data.clone();
|
||||
} else if let Some(err) = err.as_serde_error() {
|
||||
// this is not an rpc error. keep it as an error
|
||||
return Err(Web3ProxyError::BadRequest(format!("bad request: {}", err)));
|
||||
} else {
|
||||
// it wasn't an HttpClientError. try WsClientError
|
||||
let e = e.unwrap_err().downcast::<WsClientError>();
|
||||
|
||||
if let Ok(e) = e {
|
||||
match *e {
|
||||
WsClientError::JsonRpcError(e) => {
|
||||
code = e.code;
|
||||
message = e.message.clone();
|
||||
data = e.data;
|
||||
}
|
||||
e => {
|
||||
// this is not an rpc error. keep it as an error
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Err(anyhow::anyhow!("unexpected ethers error!").into());
|
||||
}
|
||||
return Err(anyhow::anyhow!("unexpected ethers error!").into());
|
||||
}
|
||||
}
|
||||
e => return Err(e.into()),
|
||||
|
@ -1338,7 +1338,7 @@ impl Web3Rpc {
|
||||
where
|
||||
// TODO: not sure about this type. would be better to not need clones, but measure and spawns combine to need it
|
||||
P: Clone + fmt::Debug + serde::Serialize + Send + Sync + 'static,
|
||||
R: serde::Serialize + serde::de::DeserializeOwned + fmt::Debug,
|
||||
R: serde::Serialize + serde::de::DeserializeOwned + fmt::Debug + Send,
|
||||
{
|
||||
self.wait_for_request_handle(&authorization, None, None)
|
||||
.await?
|
||||
|
@ -20,16 +20,6 @@ pub enum Web3Provider {
|
||||
}
|
||||
|
||||
impl Web3Provider {
|
||||
pub fn ready(&self) -> bool {
|
||||
match self {
|
||||
Self::Both(_, ws) => ws.as_ref().ready(),
|
||||
Self::Http(_) => true,
|
||||
Self::Ws(ws) => ws.as_ref().ready(),
|
||||
#[cfg(test)]
|
||||
Self::Mock => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn http(&self) -> Option<&EthersHttpProvider> {
|
||||
match self {
|
||||
Self::Http(x) => Some(x),
|
||||
|
@ -5,7 +5,7 @@ use anyhow::Context;
|
||||
use chrono::Utc;
|
||||
use entities::revert_log;
|
||||
use entities::sea_orm_active_enums::Method;
|
||||
use ethers::providers::{HttpClientError, ProviderError, WsClientError};
|
||||
use ethers::providers::ProviderError;
|
||||
use ethers::types::{Address, Bytes};
|
||||
use log::{debug, error, trace, warn, Level};
|
||||
use migration::sea_orm::{self, ActiveEnum, ActiveModelTrait};
|
||||
@ -156,7 +156,7 @@ impl OpenRequestHandle {
|
||||
where
|
||||
// TODO: not sure about this type. would be better to not need clones, but measure and spawns combine to need it
|
||||
P: Clone + fmt::Debug + serde::Serialize + Send + Sync + 'static,
|
||||
R: serde::Serialize + serde::de::DeserializeOwned + fmt::Debug,
|
||||
R: serde::Serialize + serde::de::DeserializeOwned + fmt::Debug + Send,
|
||||
{
|
||||
// TODO: use tracing spans
|
||||
// TODO: including params in this log is way too verbose
|
||||
@ -170,7 +170,8 @@ impl OpenRequestHandle {
|
||||
};
|
||||
|
||||
let mut logged = false;
|
||||
while provider.is_none() || provider.as_ref().map(|x| !x.ready()).unwrap() {
|
||||
// TODO: instead of a lock, i guess it should be a watch?
|
||||
while provider.is_none() {
|
||||
// trace!("waiting on provider: locking...");
|
||||
// TODO: i dont like this. subscribing to a channel could be better
|
||||
sleep(Duration::from_millis(100)).await;
|
||||
@ -277,37 +278,7 @@ impl OpenRequestHandle {
|
||||
let msg = match &*provider {
|
||||
#[cfg(test)]
|
||||
Web3Provider::Mock => unimplemented!(),
|
||||
Web3Provider::Both(_, _) => {
|
||||
if let Some(HttpClientError::JsonRpcError(err)) =
|
||||
err.downcast_ref::<HttpClientError>()
|
||||
{
|
||||
Some(&err.message)
|
||||
} else if let Some(WsClientError::JsonRpcError(err)) =
|
||||
err.downcast_ref::<WsClientError>()
|
||||
{
|
||||
Some(&err.message)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Web3Provider::Http(_) => {
|
||||
if let Some(HttpClientError::JsonRpcError(err)) =
|
||||
err.downcast_ref::<HttpClientError>()
|
||||
{
|
||||
Some(&err.message)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Web3Provider::Ws(_) => {
|
||||
if let Some(WsClientError::JsonRpcError(err)) =
|
||||
err.downcast_ref::<WsClientError>()
|
||||
{
|
||||
Some(&err.message)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => err.as_error_response().map(|x| x.message.clone()),
|
||||
};
|
||||
|
||||
if let Some(msg) = msg {
|
||||
|
Loading…
Reference in New Issue
Block a user