From 9f563d93bc3ecb01f4b1c73e06a77c5f330c1a09 Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Fri, 23 May 2025 10:37:17 +0200 Subject: [PATCH] Update async_sleep to be non-web compatible --- Cargo.lock | 26 +++++++++++++++++++++++- lwk_wollet/Cargo.toml | 4 +++- lwk_wollet/src/clients/asyncr/esplora.rs | 18 +++------------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2b468854..406fb834f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2346,10 +2346,10 @@ dependencies = [ "tempfile", "thiserror 1.0.69", "tokio", + "tokio_with_wasm", "url", "wasm-bindgen-futures", "waterfalls", - "web-sys", ] [[package]] @@ -3943,6 +3943,30 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio_with_wasm" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42d20f41cbfe26740d0c2fb320d44ce7dfa716be135cb663e99a48248a0e897" +dependencies = [ + "js-sys", + "tokio", + "tokio_with_wasm_proc", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "tokio_with_wasm_proc" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "499ed9d797c376545920fa64c39c3efb34217ba4db826102db6c3912555291c9" +dependencies = [ + "quote", + "syn 2.0.100", +] + [[package]] name = "toml" version = "0.5.11" diff --git a/lwk_wollet/Cargo.toml b/lwk_wollet/Cargo.toml index 05977cb76..87f821230 100644 --- a/lwk_wollet/Cargo.toml +++ b/lwk_wollet/Cargo.toml @@ -42,6 +42,9 @@ reqwest = { version = "0.12", optional = true, default-features = false, feature "json", "rustls-tls", ] } +tokio_with_wasm = { version = "=0.8.2", features = [ + "time", +] } #registry @@ -74,7 +77,6 @@ tokio = { version = "1.36.0", default-features = false, features = [ ] } # wasm wasm-bindgen-futures = { version = "0.4.41" } -web-sys = { version = "0.3.68", features = ["Window"] } js-sys = { version = "0.3.68" } [dev-dependencies] diff --git a/lwk_wollet/src/clients/asyncr/esplora.rs b/lwk_wollet/src/clients/asyncr/esplora.rs index b75be45bc..9223cb092 100644 --- a/lwk_wollet/src/clients/asyncr/esplora.rs +++ b/lwk_wollet/src/clients/asyncr/esplora.rs @@ -22,12 +22,14 @@ use elements_miniscript::{ConfidentialDescriptor, DescriptorPublicKey}; use futures::stream::{iter, StreamExt}; use reqwest::Response; use serde::Deserialize; +use std::time::Duration; use std::{ collections::{HashMap, HashSet}, io::Write, str::FromStr, sync::atomic, }; +use tokio_with_wasm::alias as tokio; // TODO: Perhaps the waterfalls server's MAX_ADDRESSES could be configurable and return // the max page size in the response, so we know when we have to request another page @@ -765,22 +767,8 @@ async fn get_with_retry(client: &reqwest::Client, url: &str) -> Result for History {