*WIP
This commit is contained in:
parent
18742dcd1c
commit
2e116d3e2f
|
@ -7,9 +7,6 @@ exclude = [
|
||||||
"benches"
|
"benches"
|
||||||
]
|
]
|
||||||
|
|
||||||
[build]
|
|
||||||
target = "wasm32-unknown-unknown"
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"cli",
|
"cli",
|
||||||
|
|
|
@ -4,7 +4,6 @@ use figment::{
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
use std::{path::PathBuf, process::exit};
|
use std::{path::PathBuf, process::exit};
|
||||||
use wasm_bindgen::JsValue;
|
|
||||||
|
|
||||||
use crate::base::BaseConfig;
|
use crate::base::BaseConfig;
|
||||||
use crate::cli::CliConfig;
|
use crate::cli::CliConfig;
|
||||||
|
|
|
@ -18,17 +18,18 @@ use super::ConsensusRpc;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RpcError {
|
pub struct RpcError {
|
||||||
message: String,
|
message: String,
|
||||||
|
_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RpcError {
|
impl RpcError {
|
||||||
pub fn new(message: String) -> Self {
|
pub fn new(message: String, _type: String) -> Self {
|
||||||
Self { message }
|
Self { message, _type }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for RpcError {
|
impl Display for RpcError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||||
write!(f, "{}", self.message)
|
write!(f, "{} error {}", self._type, self.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ impl From<JsValue> for RpcError {
|
||||||
let message = js_error
|
let message = js_error
|
||||||
.as_string()
|
.as_string()
|
||||||
.unwrap_or_else(|| "Unknown error".to_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 root_hex = hex::encode(block_root);
|
||||||
let path = format!("/eth/v1/beacon/light_client/bootstrap/0x{}", root_hex);
|
let path = format!("/eth/v1/beacon/light_client/bootstrap/0x{}", root_hex);
|
||||||
|
|
||||||
let res = self.request::<Bootstrap>(&path, "bootstrap").await?;
|
let res = self
|
||||||
|
.request::<BootstrapResponse>(&path, "bootstrap")
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(res)
|
Ok(res.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_updates(&self, period: u64, count: u8) -> Result<Vec<Update>> {
|
async fn get_updates(&self, period: u64, count: u8) -> Result<Vec<Update>> {
|
||||||
|
@ -176,7 +179,8 @@ impl NimbusRpc {
|
||||||
let result = js_future.await?;
|
let result = js_future.await?;
|
||||||
|
|
||||||
let json = result.as_string().unwrap();
|
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)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub struct ExecutionClient<R: ExecutionRpc> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: ExecutionRpc> ExecutionClient<R> {
|
impl<R: ExecutionRpc> ExecutionClient<R> {
|
||||||
pub fn new(rpc: &str) -> Result<Self> {
|
pub fn new(_rpc: &str) -> Result<Self> {
|
||||||
let rpc: R = ExecutionRpc::new()?;
|
let rpc: R = ExecutionRpc::new()?;
|
||||||
Ok(ExecutionClient { rpc })
|
Ok(ExecutionClient { rpc })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
[build]
|
|
||||||
target = "wasm32-unknown-unknown"
|
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "helios-ts"
|
name = "helios-ts"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub struct Client {
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl Client {
|
impl Client {
|
||||||
#[wasm_bindgen(constructor)]
|
#[wasm_bindgen(constructor)]
|
||||||
pub fn new(network: String, checkpoint: Option<String>) -> Self {
|
pub fn new(checkpoint: Option<String>) -> Self {
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
|
|
||||||
let base = networks::mainnet();
|
let base = networks::mainnet();
|
||||||
|
|
Loading…
Reference in New Issue