chore(deps): replace instant with web-time (#1830)

* chore(deps): replace `instant` with `web-time`

Close https://github.com/paritytech/subxt/issues/1597

* fix build

* fix build v2

* cargo fmt
This commit is contained in:
Niklas Adolfsson
2024-10-22 15:54:54 +02:00
committed by GitHub
parent c07c760d85
commit 418bd88e62
6 changed files with 21 additions and 24 deletions
Generated
+12 -14
View File
@@ -3927,18 +3927,6 @@ dependencies = [
"generic-array",
]
[[package]]
name = "instant"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
dependencies = [
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "integer-sqrt"
version = "0.1.5"
@@ -10562,7 +10550,6 @@ dependencies = [
"http-body",
"hyper",
"impl-serde",
"instant",
"jsonrpsee",
"parity-scale-codec",
"polkadot-sdk",
@@ -10587,6 +10574,7 @@ dependencies = [
"tracing-subscriber",
"url",
"wasm-bindgen-futures",
"web-time",
]
[[package]]
@@ -10677,7 +10665,6 @@ dependencies = [
"futures-timer",
"futures-util",
"getrandom",
"instant",
"js-sys",
"pin-project",
"send_wrapper 0.6.0",
@@ -10692,6 +10679,7 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"web-time",
]
[[package]]
@@ -11876,6 +11864,16 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "webpki-roots"
version = "0.26.3"
+1 -1
View File
@@ -133,7 +133,7 @@ send_wrapper = "0.6.0"
js-sys = "0.3.70"
wasm-bindgen-futures = "0.4.43"
futures-timer = "3"
instant = { version = "0.1.13", default-features = false }
web-time = { version = "1.1", default-features = false }
tokio-util = "0.7.12"
# Substrate crates:
+2 -2
View File
@@ -36,7 +36,7 @@ web = [
# For the light-client platform.
"wasm-bindgen-futures",
"futures-timer/wasm-bindgen",
"instant/wasm-bindgen",
"web-time",
"pin-project",
# For websocket.
@@ -66,7 +66,7 @@ wasm-bindgen-futures = { workspace = true, optional = true }
smoldot = { workspace = true, optional = true }
pin-project = { workspace = true, optional = true }
futures-timer = { workspace = true, optional = true }
instant = { workspace = true, optional = true }
web-time = { workspace = true, optional = true }
getrandom = { workspace = true, optional = true }
[package.metadata.docs.rs]
+4 -4
View File
@@ -11,17 +11,17 @@ use core::time::Duration;
use futures_util::{future, FutureExt};
pub fn now_from_unix_epoch() -> Duration {
instant::SystemTime::now()
.duration_since(instant::SystemTime::UNIX_EPOCH)
web_time::SystemTime::now()
.duration_since(web_time::SystemTime::UNIX_EPOCH)
.unwrap_or_else(|_| {
panic!("Invalid systime cannot be configured earlier than `UNIX_EPOCH`")
})
}
pub type Instant = instant::Instant;
pub type Instant = web_time::Instant;
pub fn now() -> Instant {
instant::Instant::now()
web_time::Instant::now()
}
pub type Delay = future::BoxFuture<'static, ()>;
+1 -2
View File
@@ -42,7 +42,6 @@ web = [
"getrandom/js",
"subxt-lightclient?/web",
"subxt-macro/web",
"instant/wasm-bindgen",
"tokio?/sync",
"finito?/wasm-bindgen",
]
@@ -99,7 +98,7 @@ thiserror = { workspace = true }
tracing = { workspace = true }
frame-metadata = { workspace = true }
either = { workspace = true }
instant = { workspace = true }
web-time = { workspace = true }
# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
impl-serde = { workspace = true }
+1 -1
View File
@@ -560,7 +560,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
let mut finalized_hash: Option<T::Hash> = None;
// Record the start time so that we can time out if things appear to take too long.
let start_instant = instant::Instant::now();
let start_instant = web_time::Instant::now();
// A quick helper to return a generic error.
let err_other = |s: &str| Some(Err(Error::Other(s.into())));