From abb453755109892236d5fa332bae0b1d6aceef84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Fri, 13 Aug 2021 11:44:29 +0300 Subject: [PATCH] Switch from wasm-timer to fluvio-wasm-timer... (#735) ... which addresses the problem from https://github.com/Amanieu/parking_lot/issues/269 by taking the unmerged workaround of https://github.com/tomaka/wasm-timer/pull/13 , as wasm-timer appears to be unmaintained. --- Cargo.lock | 37 ++++++++++--------- common/client-libs/gateway-client/Cargo.toml | 4 +- .../client-libs/gateway-client/src/client.rs | 2 +- .../client-libs/validator-client/Cargo.toml | 2 +- .../client-libs/validator-client/src/lib.rs | 2 +- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0422534b91..35d0f9c76e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1170,6 +1170,21 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fluvio-wasm-timer" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b768c170dc045fa587a8f948c91f9bcfb87f774930477c6215addf54317f137f" +dependencies = [ + "futures", + "js-sys", + "parking_lot", + "pin-utils", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1331,6 +1346,7 @@ name = "gateway-client" version = "0.1.0" dependencies = [ "crypto", + "fluvio-wasm-timer", "futures", "gateway-requests", "getrandom 0.2.3", @@ -1342,7 +1358,6 @@ dependencies = [ "tungstenite", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-timer", "wasm-utils", ] @@ -1794,6 +1809,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", ] [[package]] @@ -4662,6 +4680,7 @@ dependencies = [ "cosmos_sdk", "cosmwasm-std", "flate2", + "fluvio-wasm-timer", "getrandom 0.2.3", "itertools 0.10.1", "log", @@ -4675,7 +4694,6 @@ dependencies = [ "thiserror", "tokio", "url", - "wasm-timer", ] [[package]] @@ -4828,21 +4846,6 @@ dependencies = [ "quote", ] -[[package]] -name = "wasm-timer" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" -dependencies = [ - "futures", - "js-sys", - "parking_lot", - "pin-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wasm-utils" version = "0.1.0" diff --git a/common/client-libs/gateway-client/Cargo.toml b/common/client-libs/gateway-client/Cargo.toml index c357a9d3dc..c93bf31639 100644 --- a/common/client-libs/gateway-client/Cargo.toml +++ b/common/client-libs/gateway-client/Cargo.toml @@ -41,8 +41,8 @@ version = "0.4" path = "../../wasm-utils" # only import it in wasm. Prefer proper tokio timer in non-wasm -[target."cfg(target_arch = \"wasm32\")".dependencies.wasm-timer] -version = "0.2" +[target."cfg(target_arch = \"wasm32\")".dependencies.fluvio-wasm-timer] +version = "0.2.5" # this is due to tungstenite using `rand` 0.8 and associated changes in `getrandom` crate # which now does not support wasm32-unknown-unknown target by default. diff --git a/common/client-libs/gateway-client/src/client.rs b/common/client-libs/gateway-client/src/client.rs index a507db08d1..4fe7d5657e 100644 --- a/common/client-libs/gateway-client/src/client.rs +++ b/common/client-libs/gateway-client/src/client.rs @@ -26,7 +26,7 @@ use tungstenite::protocol::Message; use tokio_tungstenite::connect_async; #[cfg(target_arch = "wasm32")] -use wasm_timer; +use fluvio_wasm_timer as wasm_timer; #[cfg(target_arch = "wasm32")] use wasm_utils::websocket::JSWebsocket; diff --git a/common/client-libs/validator-client/Cargo.toml b/common/client-libs/validator-client/Cargo.toml index 7a744bf424..2dec91b4eb 100644 --- a/common/client-libs/validator-client/Cargo.toml +++ b/common/client-libs/validator-client/Cargo.toml @@ -16,7 +16,7 @@ reqwest = { version="0.11", features=["json"] } thiserror = "1" log = "0.4" url = "2" -wasm-timer = "0.2" +fluvio-wasm-timer = "0.2.5" # required for nymd-client # at some point it might be possible to make it wasm-compatible diff --git a/common/client-libs/validator-client/src/lib.rs b/common/client-libs/validator-client/src/lib.rs index af4c2bdd4d..d5f512a79a 100644 --- a/common/client-libs/validator-client/src/lib.rs +++ b/common/client-libs/validator-client/src/lib.rs @@ -141,7 +141,7 @@ impl Client { error!("{}", url) } // Went with only wasm_timer so we can avoid features on the lib, and pulling in tokio - wasm_timer::Delay::new(Duration::from_secs(sleep_secs)).await?; + fluvio_wasm_timer::Delay::new(Duration::from_secs(sleep_secs)).await?; } }