diff --git a/ton_client/Cargo.toml b/ton_client/Cargo.toml index 155febec8..1f68299b1 100644 --- a/ton_client/Cargo.toml +++ b/ton_client/Cargo.toml @@ -67,7 +67,7 @@ tokio-tungstenite = { version = "0.11.0", features = ["tls"], optional = true } # optional for wasm js-sys = { version = "0.3.50", optional = true } -wasm-bindgen = { version = "0.2.73", features = ["serde-serialize"], optional = true } +wasm-bindgen = { version = "0.2.73", optional = true } wasm-bindgen-futures = { version = "0.4.15", optional = true } [dependencies.web-sys] diff --git a/ton_client/src/client/wasm_client_env.rs b/ton_client/src/client/wasm_client_env.rs index 18b6a3997..fd83f0c04 100644 --- a/ton_client/src/client/wasm_client_env.rs +++ b/ton_client/src/client/wasm_client_env.rs @@ -19,19 +19,14 @@ use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use wasm_bindgen_futures::JsFuture; use web_sys::{Event, MessageEvent, Request, RequestInit, Response, Window}; +use js_sys::JSON; -fn js_value_to_value(js_value: JsValue) -> ClientResult { - js_value - .into_serde::() - .map_err(|_| Error::cannot_convert_jsvalue_to_json(js_value)) -} - -fn js_value_to_string(js_value: JsValue) -> String { +fn js_error_to_string(js_value: JsValue) -> String { if let Ok(txt) = js_value.clone().dyn_into::() { String::from(txt.message()) } else { - js_value_to_value(js_value) - .map(|val| format!("{:#}", val)) + JSON::stringify(&js_value) + .map(|val| String::from(val)) .unwrap_or("Unserializable value".to_owned()) } } @@ -214,7 +209,7 @@ impl ClientEnv { log::trace!("Websocket send: {}", string); let result = ws .send_with_str(&string) - .map_err(|err| Error::websocket_send_error(js_value_to_string(err))); + .map_err(|err| Error::websocket_send_error(js_error_to_string(err))); let _ = sender.send(result); } let _ = ws.close(); @@ -285,7 +280,7 @@ impl ClientEnv { let mut resp_future = JsFuture::from(window.fetch_with_request(&request)) .map(|result| match result { Ok(result) => Ok(result), - Err(err) => Err(Error::http_request_send_error(js_value_to_string(err))), + Err(err) => Err(Error::http_request_send_error(js_error_to_string(err))), }); let resp_result = match timeout_ms {