From ff05a8762b14833465d93067f0707c16fe5b7883 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 27 Jan 2023 19:14:26 +0100 Subject: [PATCH] fix: add getrandom with js feature for wasm (#2076) --- Cargo.lock | 1 + ethers-core/Cargo.toml | 4 ++++ ethers-core/src/lib.rs | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 18e99060..57421658 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1409,6 +1409,7 @@ dependencies = [ "elliptic-curve", "ethabi", "generic-array 0.14.6", + "getrandom 0.2.8", "hex", "hex-literal", "k256", diff --git a/ethers-core/Cargo.toml b/ethers-core/Cargo.toml index 02c1fd9f..f03ae067 100644 --- a/ethers-core/Cargo.toml +++ b/ethers-core/Cargo.toml @@ -47,6 +47,10 @@ num_enum = "0.5.9" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tempfile = { version = "3.3.0", default-features = false } +[target.'cfg(target_arch = "wasm32")'.dependencies] +# NOTE: this enables wasm compatibility for getrandom indirectly +getrandom = { version = "0.2", features = ["js"] } + [dev-dependencies] serde_json = { version = "1.0.64", default-features = false } bincode = { version = "1.3.3", default-features = false } diff --git a/ethers-core/src/lib.rs b/ethers-core/src/lib.rs index f9b4d2ac..446a58f8 100644 --- a/ethers-core/src/lib.rs +++ b/ethers-core/src/lib.rs @@ -1,7 +1,7 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] #![deny(rustdoc::broken_intra_doc_links)] -#![deny(unused_crate_dependencies)] +#![cfg_attr(not(target_arch = "wasm32"), deny(unused_crate_dependencies))] pub mod types;