From 40c304d939c7b1c299cb7d480e9a6e1d97e6383c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 22 Jun 2022 19:09:25 +0200 Subject: [PATCH] chore: silence wasm warnings (#1404) --- Cargo.lock | 1 + ethers-providers/Cargo.toml | 3 +++ ethers-providers/src/pending_escalator.rs | 1 + ethers-providers/src/pending_transaction.rs | 1 + 4 files changed, 6 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index ef508757..f84f4dfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1342,6 +1342,7 @@ dependencies = [ "futures-core", "futures-timer", "futures-util", + "getrandom 0.2.7", "hashers", "hex", "http", diff --git a/ethers-providers/Cargo.toml b/ethers-providers/Cargo.toml index b8169732..e331f740 100644 --- a/ethers-providers/Cargo.toml +++ b/ethers-providers/Cargo.toml @@ -47,6 +47,7 @@ hashers = "1.0.1" tokio = { version = "1.18", features = ["time"] } tokio-tungstenite = { version = "0.17.1", default-features = false, features = ["connect"], optional = true } + [target.'cfg(target_arch = "wasm32")'.dependencies] ws_stream_wasm = "0.7" wasm-bindgen = "0.2" @@ -55,6 +56,8 @@ web-sys = { version = "0.3", features = ["console"] } wasm-timer = "0.2" # this is currently necessary for `wasm-timer::Delay` to work parking_lot = { version = "0.11", features = ["wasm-bindgen"] } +# NOTE: this enables wasm compatibility for getrandom indirectly +getrandom = { version = "0.2", features = ["js"] } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tokio = { version = "1.18", default-features = false, features = ["rt", "macros", "time"] } diff --git a/ethers-providers/src/pending_escalator.rs b/ethers-providers/src/pending_escalator.rs index 3dca65fb..b156c970 100644 --- a/ethers-providers/src/pending_escalator.rs +++ b/ethers-providers/src/pending_escalator.rs @@ -175,6 +175,7 @@ where { type Output = Result; + #[cfg_attr(target_arch = "wasm32", allow(unused_must_use))] fn poll( self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>, diff --git a/ethers-providers/src/pending_transaction.rs b/ethers-providers/src/pending_transaction.rs index 40fbdc0e..81b3228e 100644 --- a/ethers-providers/src/pending_transaction.rs +++ b/ethers-providers/src/pending_transaction.rs @@ -167,6 +167,7 @@ macro_rules! rewake_with_new_state_if { impl<'a, P: JsonRpcClient> Future for PendingTransaction<'a, P> { type Output = Result, ProviderError>; + #[cfg_attr(target_arch = "wasm32", allow(unused_must_use))] fn poll(self: Pin<&mut Self>, ctx: &mut Context) -> Poll { let this = self.project();