Skip to content

Commit 0ab766f

Browse files
committed
feat(node/web): expose api to get node state
1 parent f29f0d5 commit 0ab766f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

node/common/src/service/rpc/state.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ impl State {
2323
#[cfg(target_family = "wasm")]
2424
#[cfg_attr(target_family = "wasm", wasm_bindgen)]
2525
impl State {
26+
pub async fn get(&self, filter: String) -> JsValue {
27+
let res = self
28+
.sender
29+
.oneshot_request::<RpcStateGetResponse>(RpcRequest::StateGet(Some(filter)))
30+
.await
31+
.and_then(|v| v.ok());
32+
res.map(|res| JsValue::from_serde(&res).unwrap_or_default())
33+
.unwrap_or_default()
34+
}
35+
2636
pub async fn peers(&self) -> JsValue {
2737
let res = self
2838
.sender

0 commit comments

Comments
 (0)