From 33a39cff86e9049610ae4b9f67aea5af5f4133a4 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Sat, 1 May 2021 21:26:37 +0300 Subject: [PATCH] fix: remove dependency on curl (#285) --- Cargo.lock | 73 +++++-------------- .../ethers-contract-abigen/Cargo.toml | 2 +- .../ethers-contract-abigen/src/util.rs | 17 +---- 3 files changed, 21 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 760ba6a4..de493fd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -559,36 +559,6 @@ dependencies = [ "cipher", ] -[[package]] -name = "curl" -version = "0.4.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a872858e9cb9e3b96c80dd78774ad9e32e44d3b05dc31e142b858d14aebc82c" -dependencies = [ - "curl-sys", - "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2 0.3.19", - "winapi", -] - -[[package]] -name = "curl-sys" -version = "0.4.41+curl-7.75.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ec466abd277c7cab2905948f3e94d10bc4963f1f5d47921c1cc4ffd2028fe65" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", - "winapi", -] - [[package]] name = "curve25519-dalek" version = "3.0.2" @@ -824,11 +794,11 @@ version = "0.2.2" dependencies = [ "Inflector", "anyhow", - "curl", "ethers-core", "hex", "proc-macro2", "quote", + "reqwest", "serde_json", "syn", "url", @@ -1308,7 +1278,7 @@ dependencies = [ "httpdate", "itoa", "pin-project", - "socket2 0.4.0", + "socket2", "tokio", "tower-service", "tracing", @@ -1330,6 +1300,19 @@ dependencies = [ "webpki", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "idna" version = "0.2.2" @@ -1451,18 +1434,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "libz-sys" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "log" version = "0.4.14" @@ -1973,11 +1944,13 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", + "hyper-tls", "ipnet", "js-sys", "lazy_static", "log", "mime", + "native-tls", "percent-encoding", "pin-project-lite", "rustls", @@ -1985,6 +1958,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "tokio", + "tokio-native-tls", "tokio-rustls", "url", "wasm-bindgen", @@ -2269,17 +2243,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -[[package]] -name = "socket2" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "winapi", -] - [[package]] name = "socket2" version = "0.4.0" diff --git a/ethers-contract/ethers-contract-abigen/Cargo.toml b/ethers-contract/ethers-contract-abigen/Cargo.toml index 14ab6e00..b63d02ad 100644 --- a/ethers-contract/ethers-contract-abigen/Cargo.toml +++ b/ethers-contract/ethers-contract-abigen/Cargo.toml @@ -13,7 +13,6 @@ keywords = ["ethereum", "web3", "celo", "ethers"] ethers-core = { version = "0.2.2", path = "../../ethers-core" } anyhow = "1.0.37" -curl = "0.4" Inflector = "0.11" proc-macro2 = "1.0" quote = "1.0" @@ -21,6 +20,7 @@ syn = "1.0.12" url = "2.1" serde_json = "1.0.61" hex = { version = "0.4.2", default-features = false, features = ["std"] } +reqwest = { version = "0.11.3", features = ["blocking"] } [package.metadata.docs.rs] all-features = true diff --git a/ethers-contract/ethers-contract-abigen/src/util.rs b/ethers-contract/ethers-contract-abigen/src/util.rs index 532b9f54..ffc835c8 100644 --- a/ethers-contract/ethers-contract-abigen/src/util.rs +++ b/ethers-contract/ethers-contract-abigen/src/util.rs @@ -1,10 +1,10 @@ use ethers_core::types::Address; use anyhow::{anyhow, Result}; -use curl::easy::Easy; use inflector::Inflector; use proc_macro2::{Ident, Literal, Span, TokenStream}; use quote::quote; +use reqwest::Client; use syn::Ident as SynIdent; /// Expands a identifier string into an token. @@ -56,20 +56,7 @@ where /// Perform an HTTP GET request and return the contents of the response. pub fn http_get(url: &str) -> Result { - let mut buffer = Vec::new(); - let mut handle = Easy::new(); - handle.url(url)?; - { - let mut transfer = handle.transfer(); - transfer.write_function(|data| { - buffer.extend_from_slice(data); - Ok(data.len()) - })?; - transfer.perform()?; - } - - let buffer = String::from_utf8(buffer)?; - Ok(buffer) + Ok(reqwest::blocking::get(url)?.text()?) } #[cfg(test)]