*WIP
This commit is contained in:
parent
15fd1b8f88
commit
7adc38ae1a
File diff suppressed because it is too large
Load Diff
|
@ -29,12 +29,12 @@ common = { path = "./common" }
|
||||||
consensus = { path = "./consensus" }
|
consensus = { path = "./consensus" }
|
||||||
execution = { path = "./execution" }
|
execution = { path = "./execution" }
|
||||||
serde = { version = "1.0.154", features = ["derive"] }
|
serde = { version = "1.0.154", features = ["derive"] }
|
||||||
|
ethers = "1.0.2"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
eyre = "0.6.8"
|
eyre = "0.6.8"
|
||||||
dirs = "4.0.0"
|
dirs = "4.0.0"
|
||||||
ethers = { version = "1.0.2", features = [ "abigen" ] }
|
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.9.0"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
tracing-test = "0.2.4"
|
tracing-test = "0.2.4"
|
||||||
|
@ -93,3 +93,6 @@ harness = false
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "sync"
|
name = "sync"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
|
[replace]
|
||||||
|
"ethers:1.0.2" = { git = "https://git.lumeweb.com/LumeWeb/ethers-rs.git", branch= "lume" }
|
||||||
|
|
|
@ -8,7 +8,7 @@ eyre = "0.6.8"
|
||||||
serde = { version = "1.0.143", features = ["derive"] }
|
serde = { version = "1.0.143", features = ["derive"] }
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "d09f55b4f8554491e3431e01af1c32347a8781cd" }
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "d09f55b4f8554491e3431e01af1c32347a8781cd" }
|
||||||
ethers = "1.0.0"
|
ethers = { version = "1.0.2", path = "../../helios-workspace/ethers-rs"}
|
||||||
futures = "0.3.23"
|
futures = "0.3.23"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
use ethers::providers::HttpClientError;
|
||||||
|
use ethers::providers::JsonRpcError;
|
||||||
|
use ethers::providers::Provider;
|
||||||
use ethers::types::H256;
|
use ethers::types::H256;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ eyre = "0.6.8"
|
||||||
serde = { version = "1.0.143", features = ["derive"] }
|
serde = { version = "1.0.143", features = ["derive"] }
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "d09f55b4f8554491e3431e01af1c32347a8781cd" }
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "d09f55b4f8554491e3431e01af1c32347a8781cd" }
|
||||||
ethers = "1.0.0"
|
ethers = { version = "1.0.2", path = "../../helios-workspace/ethers-rs"}
|
||||||
figment = { version = "0.10.7", features = ["toml", "env"] }
|
figment = { version = "0.10.7", features = ["toml", "env"] }
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
|
|
|
@ -11,7 +11,7 @@ serde_json = "1.0.85"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "d09f55b4f8554491e3431e01af1c32347a8781cd" }
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "d09f55b4f8554491e3431e01af1c32347a8781cd" }
|
||||||
milagro_bls = { git = "https://github.com/Snowfork/milagro_bls" }
|
milagro_bls = { git = "https://github.com/Snowfork/milagro_bls" }
|
||||||
ethers = "1.0.0"
|
ethers = { version = "1.0.2", path = "../../helios-workspace/ethers-rs"}
|
||||||
bytes = "1.2.1"
|
bytes = "1.2.1"
|
||||||
toml = "0.5.9"
|
toml = "0.5.9"
|
||||||
async-trait = "0.1.57"
|
async-trait = "0.1.57"
|
||||||
|
|
|
@ -11,7 +11,7 @@ serde_json = "1.0.85"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "d09f55b4f8554491e3431e01af1c32347a8781cd" }
|
ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "d09f55b4f8554491e3431e01af1c32347a8781cd" }
|
||||||
revm = { version = "2.3", default-features = false, features = ["std", "k256", "with-serde"] }
|
revm = { version = "2.3", default-features = false, features = ["std", "k256", "with-serde"] }
|
||||||
ethers = "1.0.0"
|
ethers = { version = "1.0.2", path = "../../helios-workspace/ethers-rs"}
|
||||||
bytes = "1.2.1"
|
bytes = "1.2.1"
|
||||||
futures = "0.3.23"
|
futures = "0.3.23"
|
||||||
toml = "0.5.9"
|
toml = "0.5.9"
|
||||||
|
|
|
@ -3,7 +3,9 @@ use std::fmt::{Debug, Display, Formatter};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use ethers::prelude::Address;
|
use ethers::prelude::Address;
|
||||||
use ethers::providers::{JsonRpcClient, Middleware, Provider, ProviderError};
|
use ethers::providers::{
|
||||||
|
HttpClientError, JsonRpcClient, Middleware, Provider, ProviderError, Response,
|
||||||
|
};
|
||||||
use ethers::types::transaction::eip2718::TypedTransaction;
|
use ethers::types::transaction::eip2718::TypedTransaction;
|
||||||
use ethers::types::transaction::eip2930::AccessList;
|
use ethers::types::transaction::eip2930::AccessList;
|
||||||
use ethers::types::{
|
use ethers::types::{
|
||||||
|
@ -41,47 +43,6 @@ impl Clone for HttpRpc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LumeError {
|
|
||||||
message: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for LumeError {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "Error: {}", self.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for LumeError {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "Debug: {}", self.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Error for LumeError {}
|
|
||||||
|
|
||||||
impl From<LumeError> for ProviderError {
|
|
||||||
fn from(err: LumeError) -> Self {
|
|
||||||
ProviderError::CustomError(err.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<JsValue> for LumeError {
|
|
||||||
fn from(error: JsValue) -> Self {
|
|
||||||
LumeError {
|
|
||||||
message: error
|
|
||||||
.as_string()
|
|
||||||
.unwrap_or_else(|| "Unknown error".to_string()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<RpcError<String>> for LumeError {
|
|
||||||
fn from(error: RpcError<String>) -> Self {
|
|
||||||
LumeError {
|
|
||||||
message: error.to_string(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct LumeProvider {}
|
pub struct LumeProvider {}
|
||||||
|
|
||||||
|
@ -90,10 +51,9 @@ impl LumeProvider {
|
||||||
LumeProvider {}
|
LumeProvider {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
|
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
|
||||||
impl JsonRpcClient for LumeProvider {
|
impl JsonRpcClient for LumeProvider {
|
||||||
type Error = LumeError;
|
type Error = HttpClientError;
|
||||||
|
|
||||||
async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
|
async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
|
||||||
where
|
where
|
||||||
|
@ -113,40 +73,35 @@ impl JsonRpcClient for LumeProvider {
|
||||||
|
|
||||||
let js_future = JsFuture::from(execution_rpc_handler(JsValue::from(request)));
|
let js_future = JsFuture::from(execution_rpc_handler(JsValue::from(request)));
|
||||||
let result = js_future.await?;
|
let result = js_future.await?;
|
||||||
let json = result.as_string().ok_or_else(|| {
|
let json = result.as_string().expect("response is not a string");
|
||||||
let err_msg = "response is not a string".to_string();
|
|
||||||
panic!("{}", err_msg);
|
|
||||||
// web_sys::console::log_1(&JsValue::from_str(&err_msg));
|
|
||||||
RpcError::new(method, err_msg)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
web_sys::console::log_1(&JsValue::from_str(&json));
|
let body = json.as_bytes();
|
||||||
|
|
||||||
let json_value: serde_json::Value = serde_json::from_str(&json).map_err(|e| {
|
let raw = match serde_json::from_slice(&body) {
|
||||||
let err_msg = e.to_string();
|
Ok(Response::Success { result, .. }) => result.to_owned(),
|
||||||
panic!("{}", err_msg);
|
Ok(Response::Error { error, .. }) => return Err(error.into()),
|
||||||
// web_sys::console::log_1(&JsValue::from_str(&err_msg));
|
Ok(_) => {
|
||||||
RpcError::new(method, err_msg)
|
panic!(
|
||||||
})?;
|
"{} {}",
|
||||||
|
"unexpected notification over HTTP transport",
|
||||||
if let serde_json::Value::Object(obj) = json_value {
|
String::from_utf8_lossy(&body).to_string()
|
||||||
web_sys::console::log_1(&JsValue::from_str("serde_json::Value matches"));
|
);
|
||||||
if obj.contains_key("error") {
|
|
||||||
let error_message = obj.get("error").unwrap().clone();
|
|
||||||
let err_msg = serde_json::to_string(&error_message).unwrap();
|
|
||||||
panic!("{}", err_msg);
|
|
||||||
// web_sys::console::log_1(&JsValue::from_str(&err_msg));
|
|
||||||
}
|
}
|
||||||
}
|
Err(err) => {
|
||||||
|
panic!(
|
||||||
|
"{} {}",
|
||||||
|
err.to_string(),
|
||||||
|
String::from_utf8_lossy(&body).to_string()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let response: R = serde_json::from_str(&json).map_err(|e| {
|
let res = serde_json::from_str(raw.get()).map_err(|err| HttpClientError::SerdeJson {
|
||||||
let err_msg = e.to_string();
|
err,
|
||||||
panic!("{}", err_msg);
|
text: raw.to_string(),
|
||||||
// web_sys::console::log_1(&JsValue::from_str(&err_msg));
|
|
||||||
RpcError::new(method, err_msg)
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(response)
|
Ok(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ console_error_panic_hook = "0.1.7"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
serde = { version = "1.0.85", features = ["derive"] }
|
serde = { version = "1.0.85", features = ["derive"] }
|
||||||
|
|
||||||
ethers = "1.0.0"
|
ethers = { version = "1.0.2", features = [ "abigen" ], path = "../../helios-workspace/ethers-rs" }
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue