From 2e116d3e2f44cbe85c854e94318bb621839770e1 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 24 Mar 2023 11:14:48 -0400 Subject: [PATCH] *WIP --- Cargo.toml | 3 --- config/src/config.rs | 1 - consensus/src/rpc/nimbus_rpc.rs | 18 +++++++++++------- execution/src/execution.rs | 2 +- helios-ts/Cargo.toml | 3 --- helios-ts/src/lib.rs | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 72998d0..8088509 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,6 @@ exclude = [ "benches" ] -[build] -target = "wasm32-unknown-unknown" - [workspace] members = [ "cli", diff --git a/config/src/config.rs b/config/src/config.rs index d40947c..2e25710 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -4,7 +4,6 @@ use figment::{ }; use serde::{Deserialize, Deserializer}; use std::{path::PathBuf, process::exit}; -use wasm_bindgen::JsValue; use crate::base::BaseConfig; use crate::cli::CliConfig; diff --git a/consensus/src/rpc/nimbus_rpc.rs b/consensus/src/rpc/nimbus_rpc.rs index 6db281c..ddf5a00 100644 --- a/consensus/src/rpc/nimbus_rpc.rs +++ b/consensus/src/rpc/nimbus_rpc.rs @@ -18,17 +18,18 @@ use super::ConsensusRpc; #[derive(Debug)] pub struct RpcError { message: String, + _type: String, } impl RpcError { - pub fn new(message: String) -> Self { - Self { message } + pub fn new(message: String, _type: String) -> Self { + Self { message, _type } } } impl Display for RpcError { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - write!(f, "{}", self.message) + write!(f, "{} error {}", self._type, self.message) } } @@ -37,7 +38,7 @@ impl From for RpcError { let message = js_error .as_string() .unwrap_or_else(|| "Unknown error".to_string()); - RpcError::new(message) + RpcError::new(message, String::from("")) } } @@ -66,9 +67,11 @@ impl ConsensusRpc for NimbusRpc { let root_hex = hex::encode(block_root); let path = format!("/eth/v1/beacon/light_client/bootstrap/0x{}", root_hex); - let res = self.request::(&path, "bootstrap").await?; + let res = self + .request::(&path, "bootstrap") + .await?; - Ok(res) + Ok(res.data) } async fn get_updates(&self, period: u64, count: u8) -> Result> { @@ -176,7 +179,8 @@ impl NimbusRpc { let result = js_future.await?; let json = result.as_string().unwrap(); - let response: T = serde_json::from_str(&json).map_err(|e| RpcError::new(e.to_string()))?; + let response: T = serde_json::from_str(&json) + .map_err(|e| RpcError::new(e.to_string(), String::from(error_type)))?; Ok(response) } diff --git a/execution/src/execution.rs b/execution/src/execution.rs index 3d35418..467b594 100644 --- a/execution/src/execution.rs +++ b/execution/src/execution.rs @@ -31,7 +31,7 @@ pub struct ExecutionClient { } impl ExecutionClient { - pub fn new(rpc: &str) -> Result { + pub fn new(_rpc: &str) -> Result { let rpc: R = ExecutionRpc::new()?; Ok(ExecutionClient { rpc }) } diff --git a/helios-ts/Cargo.toml b/helios-ts/Cargo.toml index dd96f77..c0f683d 100644 --- a/helios-ts/Cargo.toml +++ b/helios-ts/Cargo.toml @@ -1,6 +1,3 @@ -[build] -target = "wasm32-unknown-unknown" - [package] name = "helios-ts" version = "0.1.0" diff --git a/helios-ts/src/lib.rs b/helios-ts/src/lib.rs index bd46c77..0e75e9d 100644 --- a/helios-ts/src/lib.rs +++ b/helios-ts/src/lib.rs @@ -27,7 +27,7 @@ pub struct Client { #[wasm_bindgen] impl Client { #[wasm_bindgen(constructor)] - pub fn new(network: String, checkpoint: Option) -> Self { + pub fn new(checkpoint: Option) -> Self { console_error_panic_hook::set_once(); let base = networks::mainnet();