*WIP
This commit is contained in:
parent
2e116d3e2f
commit
086884b617
|
@ -1562,6 +1562,7 @@ dependencies = [
|
|||
"triehash-ethereum",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2075,6 +2076,7 @@ dependencies = [
|
|||
"hex",
|
||||
"serde",
|
||||
"serde-wasm-bindgen 0.4.5",
|
||||
"tracing-wasm",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
|
@ -4638,6 +4640,17 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-wasm"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4575c663a174420fa2d78f4108ff68f65bf2fbb7dd89f33749b6e826b3626e07"
|
||||
dependencies = [
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "triehash"
|
||||
version = "0.8.4"
|
||||
|
|
|
@ -27,7 +27,7 @@ wasm-bindgen = "0.2.84"
|
|||
js-sys = "0.3.61"
|
||||
serde-wasm-bindgen = "0.5.0"
|
||||
wasm-bindgen-futures = "0.4.34"
|
||||
web-sys = {version ="0.3.61", features=["Window","WindowClient"]}
|
||||
web-sys = { version = "0.3.61" }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
|
|
|
@ -25,6 +25,7 @@ consensus = { path = "../consensus" }
|
|||
wasm-bindgen = "0.2.84"
|
||||
js-sys = "0.3.61"
|
||||
wasm-bindgen-futures = "0.4.34"
|
||||
web-sys = {version="0.3.61", features=["console"]}
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
|
|
|
@ -28,7 +28,7 @@ use wasm_bindgen_futures::JsFuture;
|
|||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(js_namespace = window)]
|
||||
fn consensus_rpc_handler(data: JsValue) -> Promise;
|
||||
fn execution_rpc_handler(data: JsValue) -> Promise;
|
||||
}
|
||||
|
||||
pub struct HttpRpc {
|
||||
|
@ -100,11 +100,20 @@ impl JsonRpcClient for LumeProvider {
|
|||
T: Debug + Serialize + Send + Sync,
|
||||
R: DeserializeOwned,
|
||||
{
|
||||
let request = js_sys::Map::new();
|
||||
request.set(&JsValue::from_str("method"), &JsValue::from_str(method));
|
||||
|
||||
if let Some(params) = Option::from(params) {
|
||||
let js_params = to_value(¶ms).unwrap();
|
||||
let json_str = serde_json::to_string(&js_params).unwrap();
|
||||
let js_value = JsValue::from_str(&json_str);
|
||||
request.set(&JsValue::from_str("params"), &JsValue::from_str(&json_str));
|
||||
} else {
|
||||
request.set(&JsValue::from_str("params"), &JsValue::null());
|
||||
}
|
||||
|
||||
let js_future = JsFuture::from(consensus_rpc_handler(js_value));
|
||||
web_sys::console::log_1(&request);
|
||||
|
||||
let js_future = JsFuture::from(execution_rpc_handler(JsValue::from(request)));
|
||||
let result = js_future.await?;
|
||||
|
||||
let json = result.as_string().unwrap();
|
||||
|
|
|
@ -25,6 +25,7 @@ common = { path = "../common" }
|
|||
consensus = { path = "../consensus" }
|
||||
execution = { path = "../execution" }
|
||||
config = { path = "../config" }
|
||||
tracing-wasm = "0.2.1"
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3.61"
|
||||
|
|
|
@ -10,6 +10,7 @@ use wasm_bindgen::prelude::*;
|
|||
|
||||
use client::database::ConfigDB;
|
||||
use config::{networks, Config};
|
||||
use tracing_wasm;
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! log {
|
||||
|
@ -29,6 +30,7 @@ impl Client {
|
|||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(checkpoint: Option<String>) -> Self {
|
||||
console_error_panic_hook::set_once();
|
||||
tracing_wasm::set_as_global_default();
|
||||
|
||||
let base = networks::mainnet();
|
||||
|
||||
|
|
Loading…
Reference in New Issue