Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lwk_wollet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
18 changes: 3 additions & 15 deletions lwk_wollet/src/clients/asyncr/esplora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -765,22 +767,8 @@ async fn get_with_retry(client: &reqwest::Client, url: &str) -> Result<Response,
}
}

// based on https://users.rust-lang.org/t/rust-wasm-async-sleeping-for-100-milli-seconds-goes-up-to-1-minute/81177
// TODO remove/handle/justify unwraps
#[cfg(target_arch = "wasm32")]
pub async fn async_sleep(millis: i32) {
let mut cb = |resolve: js_sys::Function, _reject: js_sys::Function| {
web_sys::window()
.unwrap()
.set_timeout_with_callback_and_timeout_and_arguments_0(&resolve, millis)
.unwrap();
};
let p = js_sys::Promise::new(&mut cb);
wasm_bindgen_futures::JsFuture::from(p).await.unwrap();
}
#[cfg(not(target_arch = "wasm32"))]
pub async fn async_sleep(millis: i32) {
tokio::time::sleep(tokio::time::Duration::from_millis(millis as u64)).await;
tokio::time::sleep(Duration::from_millis(millis as u64)).await;
}

impl From<EsploraTx> for History {
Expand Down
Loading