diff --git a/Cargo.toml b/Cargo.toml index 285146b1..af070a81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,7 +99,7 @@ reqwest = { version = "0.12", default-features = false, features = [ "deflate", ]} once_cell = "1.20.2" -instant = { version = "0.1", default-features = false } +web-time = "1.1.0" rand = "0.9.1" regex = "1" home = "0.5.5" diff --git a/crates/cashu/Cargo.toml b/crates/cashu/Cargo.toml index 2ca6532c..affd6f52 100644 --- a/crates/cashu/Cargo.toml +++ b/crates/cashu/Cargo.toml @@ -37,9 +37,9 @@ regex = { workspace = true, optional = true } strum = { workspace = true, optional = true } strum_macros = { workspace = true, optional = true } zeroize = "1" +web-time.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] -instant = { workspace = true, features = ["wasm-bindgen", "inaccurate"] } uuid = { workspace = true, features = ["js"], optional = true } [dev-dependencies] diff --git a/crates/cashu/src/util/mod.rs b/crates/cashu/src/util/mod.rs index ae86f8a8..8afa9f64 100644 --- a/crates/cashu/src/util/mod.rs +++ b/crates/cashu/src/util/mod.rs @@ -1,18 +1,10 @@ //! Cashu utils -#[cfg(not(target_arch = "wasm32"))] -use std::time::{SystemTime, UNIX_EPOCH}; - -use bitcoin::secp256k1::{rand, All, Secp256k1}; -use once_cell::sync::Lazy; - pub mod hex; -#[cfg(target_arch = "wasm32")] -use instant::SystemTime; - -#[cfg(target_arch = "wasm32")] -const UNIX_EPOCH: SystemTime = SystemTime::UNIX_EPOCH; +use bitcoin::secp256k1::{rand, All, Secp256k1}; +use once_cell::sync::Lazy; +use web_time::{SystemTime, UNIX_EPOCH}; /// Secp256k1 global context pub static SECP256K1: Lazy> = Lazy::new(|| { @@ -46,7 +38,7 @@ pub enum CborError { /// /// See pub fn serialize_to_cbor_diag(data: &T) -> Result { - let mut cbor_buffer = Vec::new(); + let mut cbor_buffer = Vec::::new(); ciborium::ser::into_writer(data, &mut cbor_buffer)?; let diag = cbor_diag::parse_bytes(&cbor_buffer)?; diff --git a/crates/cdk-common/Cargo.toml b/crates/cdk-common/Cargo.toml index d19e851a..2ca99661 100644 --- a/crates/cdk-common/Cargo.toml +++ b/crates/cdk-common/Cargo.toml @@ -39,9 +39,9 @@ futures.workspace = true anyhow.workspace = true serde_json.workspace = true serde_with.workspace = true +web-time.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] -instant = { workspace = true, features = ["wasm-bindgen", "inaccurate"] } uuid = { workspace = true, features = ["js"], optional = true } [dev-dependencies] diff --git a/crates/cdk-integration-tests/Cargo.toml b/crates/cdk-integration-tests/Cargo.toml index 8e5dce7f..30f31452 100644 --- a/crates/cdk-integration-tests/Cargo.toml +++ b/crates/cdk-integration-tests/Cargo.toml @@ -50,6 +50,7 @@ tokio-util.workspace = true reqwest.workspace = true bitcoin = "0.32.0" clap = { workspace = true, features = ["derive"] } +web-time.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tokio.workspace = true @@ -57,7 +58,6 @@ tokio.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] tokio = { workspace = true, features = ["rt", "macros", "sync", "time"] } getrandom = { version = "0.2", features = ["js"] } -instant = { workspace = true, features = ["wasm-bindgen", "inaccurate"] } uuid = { workspace = true, features = ["js"] } [dev-dependencies] diff --git a/crates/cdk/Cargo.toml b/crates/cdk/Cargo.toml index 529dfebb..17ae3e76 100644 --- a/crates/cdk/Cargo.toml +++ b/crates/cdk/Cargo.toml @@ -45,6 +45,7 @@ uuid.workspace = true jsonwebtoken = { workspace = true, optional = true } trust-dns-resolver = { version = "0.23.2", optional = true } cdk-prometheus = {workspace = true, optional = true} +web-time.workspace = true # -Z minimal-versions sync_wrapper = "0.1.2" bech32 = "0.9.1" diff --git a/crates/cdk/src/wallet/mint_connector/http_client.rs b/crates/cdk/src/wallet/mint_connector/http_client.rs index 93cb752c..9a71cbf2 100644 --- a/crates/cdk/src/wallet/mint_connector/http_client.rs +++ b/crates/cdk/src/wallet/mint_connector/http_client.rs @@ -1,7 +1,6 @@ //! HTTP Mint client with pluggable transport use std::collections::HashSet; use std::sync::{Arc, RwLock as StdRwLock}; -use std::time::{Duration, Instant}; use async_trait::async_trait; use cdk_common::{nut19, MeltQuoteBolt12Request, MintQuoteBolt12Request, MintQuoteBolt12Response}; @@ -13,6 +12,7 @@ use serde::Serialize; use tokio::sync::RwLock; use tracing::instrument; use url::Url; +use web_time::{Duration, Instant}; use super::transport::Transport; use super::{Error, MintConnector}; diff --git a/crates/cdk/src/wallet/subscription/http.rs b/crates/cdk/src/wallet/subscription/http.rs index 22290e91..9933465c 100644 --- a/crates/cdk/src/wallet/subscription/http.rs +++ b/crates/cdk/src/wallet/subscription/http.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; use std::sync::Arc; -use std::time::Duration; use cdk_common::MintQuoteBolt12Response; use tokio::sync::{mpsc, RwLock}; use tokio::time; +use web_time::Duration; use super::WsSubscriptionBody; use crate::nuts::nut17::Kind;