Export light-client functionality for WASM

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-06-06 21:07:23 +03:00
parent 600a5cd14c
commit 9be09e8daa
11 changed files with 1035 additions and 241 deletions
+14
View File
@@ -2231,6 +2231,7 @@ dependencies = [
"smoldot-light",
"smoldot-light-wasm",
"sp-core-hashing",
"subxt-light-client",
"subxt-macro",
"subxt-metadata",
"thiserror",
@@ -2258,6 +2259,18 @@ dependencies = [
"tokio",
]
[[package]]
name = "subxt-light-client"
version = "0.28.0"
dependencies = [
"console_error_panic_hook",
"gloo-timers",
"lazy_static",
"tracing",
"tracing-wasm",
"wasm-bindgen",
]
[[package]]
name = "subxt-macro"
version = "0.28.0"
@@ -2670,6 +2683,7 @@ dependencies = [
"console_error_panic_hook",
"serde_json",
"subxt",
"tracing",
"tracing-wasm",
"wasm-bindgen-test",
]
+1
View File
@@ -10,6 +10,7 @@ publish = false
# subxt to work. So, we can't inherit versions.
wasm-bindgen-test = "0.3.24"
tracing-wasm = "0.2.1"
tracing = "0.1.34"
console_error_panic_hook = "0.1.7"
serde_json = "1"
subxt = { path = "../../subxt", default-features = false, features = ["jsonrpsee-web", "unstable-light-client"] }
+8 -2
View File
@@ -28,8 +28,14 @@ async fn wasm_ws_transport_works() {
async fn light_client_transport_works() {
init_tracing();
// let light_client = LightClient::new(include_str!("../../../artifacts/dev_spec.json")).unwrap();
// let client = subxt::client::OnlineClient::<PolkadotConfig>::from_rpc_client(Arc::new(light_client)).await.unwrap();
tracing::warn!("Starting test");
let light_client = LightClient::new(include_str!("../../../artifacts/dev_spec.json")).unwrap();
tracing::warn!("RPC layer created..");
let client = subxt::client::OnlineClient::<PolkadotConfig>::from_rpc_client(Arc::new(light_client)).await.unwrap();
tracing::warn!("Client Created");
// let chain = client.rpc().system_chain().await.unwrap();
// assert_eq!(&chain, "Development");