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