chore(provider): make websockets optional (#45)

This commit is contained in:
Georgios Konstantopoulos 2020-07-02 18:33:16 +03:00 committed by GitHub
parent 1cbd86dbd3
commit da20a042d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 42 deletions

52
Cargo.lock generated
View File

@ -526,9 +526,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "1.2.4" version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a64b0126b293b050395b37b10489951590ed024c03d7df4f249d219c8ded7cbf" checksum = "b90eb1dec02087df472ab9f0db65f27edaa654a746830042688bcc2eaf68090f"
[[package]] [[package]]
name = "fixed-hash" name = "fixed-hash"
@ -1082,9 +1082,9 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.29" version = "0.10.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd" checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if",
@ -1102,9 +1102,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.57" version = "0.9.58"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7410fef80af8ac071d4f63755c0ab89ac3df0fd1ea91f1d1f37cf5cec4395990" checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@ -1127,9 +1127,9 @@ dependencies = [
[[package]] [[package]]
name = "parking" name = "parking"
version = "1.0.1" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a7fad362df89617628a7508b3e9d588ade1b0ac31aa25de168193ad999c2dd4" checksum = "c4029bc3504a62d92e42f30b9095fdef73b8a0b2a06aa41ce2935143b05a1a06"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
@ -1169,18 +1169,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "piper"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01608bfa680dafb103f9207fa944facf572e4e3e708d10de19a0d0c3d36e5f18"
dependencies = [
"crossbeam-utils",
"futures-io",
"futures-sink",
"futures-util",
]
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.17" version = "0.3.17"
@ -1531,9 +1519,9 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4"
[[package]] [[package]]
name = "smol" name = "smol"
version = "0.1.15" version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c3546640e104d1ee544df9c08ac4896d44ef1de89a6d7cc4a3c22f677d5ef38" checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5"
dependencies = [ dependencies = [
"async-task", "async-task",
"blocking", "blocking",
@ -1543,11 +1531,11 @@ dependencies = [
"futures-util", "futures-util",
"libc", "libc",
"once_cell", "once_cell",
"piper",
"scoped-tls", "scoped-tls",
"slab", "slab",
"socket2", "socket2",
"wepoll-binding", "wepoll-sys-stjepang",
"winapi 0.3.8",
] ]
[[package]] [[package]]
@ -1971,20 +1959,10 @@ dependencies = [
] ]
[[package]] [[package]]
name = "wepoll-binding" name = "wepoll-sys-stjepang"
version = "2.0.2" version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "374fff4ff9701ff8b6ad0d14bacd3156c44063632d8c136186ff5967d48999a7" checksum = "6fd319e971980166b53e17b1026812ad66c6b54063be879eb182342b55284694"
dependencies = [
"bitflags",
"wepoll-sys",
]
[[package]]
name = "wepoll-sys"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9082a777aed991f6769e2b654aa0cb29f1c3d615daf009829b07b66c7aff6a24"
dependencies = [ dependencies = [
"cc", "cc",
] ]

View File

@ -26,17 +26,17 @@ url = { version = "2.1.1", default-features = false }
# required for implementing stream on the filters # required for implementing stream on the filters
futures-core = { version = "0.3.5", default-features = false } futures-core = { version = "0.3.5", default-features = false }
futures-util = { version = "0.3.5", default-features = false } futures-util = { version = "0.3.5", default-features = false }
futures-timer = { version = "3.0.2", default-features = false }
pin-project = { version = "0.4.20", default-features = false } pin-project = { version = "0.4.20", default-features = false }
async-tungstenite = { version = "0.6.0", default-features = false }
# ws support async-std and tokio runtimes for the convenience methods # ws support async-std and tokio runtimes for the convenience methods
async-tungstenite = { version = "0.6.0", default-features = false, optional = true }
async-std = { version = "1.6.2", default-features = false, optional = true } async-std = { version = "1.6.2", default-features = false, optional = true }
tokio = { version = "0.2.21", default-features = false, optional = true } tokio = { version = "0.2.21", default-features = false, optional = true }
# needed for tls # needed for tls
real-tokio-native-tls = { package = "tokio-native-tls", version = "0.1.0", optional = true } real-tokio-native-tls = { package = "tokio-native-tls", version = "0.1.0", optional = true }
async-tls = { version = "0.7.0", optional = true } async-tls = { version = "0.7.0", optional = true }
futures-timer = "3.0.2"
[dev-dependencies] [dev-dependencies]
ethers = { version = "0.1.3", path = "../ethers" } ethers = { version = "0.1.3", path = "../ethers" }
@ -44,15 +44,17 @@ ethers = { version = "0.1.3", path = "../ethers" }
rustc-hex = "2.1.0" rustc-hex = "2.1.0"
tokio = { version = "0.2.21", default-features = false, features = ["rt-core", "macros"] } tokio = { version = "0.2.21", default-features = false, features = ["rt-core", "macros"] }
async-std = { version = "1.6.2", default-features = false, features = ["attributes"] } async-std = { version = "1.6.2", default-features = false, features = ["attributes"] }
async-tungstenite = { version = "0.6.0", features = ["tokio-runtime"] } async-tungstenite = { version = "0.6.0", default-features = false, features = ["tokio-runtime"] }
[features] [features]
# slightly opinionated, but for convenience we default to tokio-tls # slightly opinionated, but for convenience we default to tokio-tls
# to allow websockets w/ TLS support # to allow websockets w/ TLS support
default = ["tokio-tls"] default = ["tokio-tls"]
celo = ["ethers-core/celo"] celo = ["ethers-core/celo"]
ws = ["async-tungstenite"]
tokio-runtime = [ tokio-runtime = [
"ws",
"tokio", "tokio",
"async-tungstenite/tokio-runtime" "async-tungstenite/tokio-runtime"
] ]
@ -63,6 +65,7 @@ tokio-tls = [
] ]
async-std-runtime = [ async-std-runtime = [
"ws",
"async-std", "async-std",
"async-tungstenite/async-std-runtime" "async-tungstenite/async-std-runtime"
] ]

View File

@ -100,7 +100,7 @@
//! # } //! # }
//! ``` //! ```
mod transports; mod transports;
pub use transports::{Http, Ws}; pub use transports::*;
mod provider; mod provider;

View File

@ -3,5 +3,7 @@ mod common;
mod http; mod http;
pub use http::Provider as Http; pub use http::Provider as Http;
#[cfg(feature = "ws")]
mod ws; mod ws;
#[cfg(feature = "ws")]
pub use ws::Provider as Ws; pub use ws::Provider as Ws;

View File

@ -49,7 +49,7 @@ ethers-signers = { version = "0.1.3", path = "../ethers-signers", optional = tru
[dev-dependencies] [dev-dependencies]
ethers-contract = { version = "0.1.3", path = "../ethers-contract", features = ["abigen"] } ethers-contract = { version = "0.1.3", path = "../ethers-contract", features = ["abigen"] }
ethers-providers = { version = "0.1.3", path = "../ethers-providers", features = ["tokio-runtime"] } ethers-providers = { version = "0.1.3", path = "../ethers-providers" }
anyhow = "1.0.31" anyhow = "1.0.31"
rand = "0.7" rand = "0.7"