diff --git a/Cargo.lock b/Cargo.lock index 5fb5575f..9d4c67ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -233,7 +233,6 @@ dependencies = [ "ethers-providers 0.1.0", "ethers-signers 0.1.0", "ethers-types 0.1.0", - "ethers-utils 0.1.0", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)", @@ -291,7 +290,6 @@ version = "0.1.0" dependencies = [ "async-trait 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "ethers-types 0.1.0", - "ethers-utils 0.1.0", "reqwest 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", @@ -307,7 +305,6 @@ version = "0.1.0" dependencies = [ "ethers-providers 0.1.0", "ethers-types 0.1.0", - "ethers-utils 0.1.0", ] [[package]] @@ -318,7 +315,6 @@ dependencies = [ "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ethers-utils 0.1.0", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -327,18 +323,8 @@ dependencies = [ "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ethers-utils" -version = "0.1.0" -dependencies = [ - "ethereum-types 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d8f202d7..ee3b6c6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,4 @@ members = [ "./crates/ethers-providers", "./crates/ethers-signers", "./crates/ethers-types", - "./crates/ethers-utils", ] diff --git a/crates/ethers-providers/Cargo.toml b/crates/ethers-providers/Cargo.toml index 232c6910..16a7f91e 100644 --- a/crates/ethers-providers/Cargo.toml +++ b/crates/ethers-providers/Cargo.toml @@ -6,7 +6,6 @@ edition = "2018" [dependencies] ethers-types = { version = "0.1.0", path = "../ethers-types" } -ethers-utils = { version = "0.1.0", path = "../ethers-utils" } async-trait = { version = "0.1.31", default-features = false } reqwest = { version = "0.10.4", default-features = false, features = ["json", "rustls-tls"] } diff --git a/crates/ethers-providers/src/ens.rs b/crates/ethers-providers/src/ens.rs index 856dbd22..446f91ad 100644 --- a/crates/ethers-providers/src/ens.rs +++ b/crates/ethers-providers/src/ens.rs @@ -1,10 +1,8 @@ /// [Ethereum Name Service](https://docs.ens.domains/) support // Adapted from https://github.com/hhatto/rust-ens/blob/master/src/lib.rs -use ethers_types::{Address, NameOrAddress, Selector, TransactionRequest, H256}; -use ethers_utils::keccak256; +use ethers_types::{utils::keccak256, Address, NameOrAddress, Selector, TransactionRequest, H256}; // Selectors - const ENS_REVERSE_REGISTRAR_DOMAIN: &str = "addr.reverse"; /// resolver(bytes32) diff --git a/crates/ethers-providers/src/provider.rs b/crates/ethers-providers/src/provider.rs index 8eb52433..948326b3 100644 --- a/crates/ethers-providers/src/provider.rs +++ b/crates/ethers-providers/src/provider.rs @@ -2,10 +2,9 @@ use crate::{ens, http::Provider as HttpProvider, networks::Network, JsonRpcClien use ethers_types::{ abi::{self, Detokenize, ParamType}, - Address, Block, BlockId, BlockNumber, Bytes, Filter, Log, NameOrAddress, Selector, Transaction, - TransactionReceipt, TransactionRequest, TxHash, U256, + utils, Address, Block, BlockId, BlockNumber, Bytes, Filter, Log, NameOrAddress, Selector, + Transaction, TransactionReceipt, TransactionRequest, TxHash, U256, }; -use ethers_utils as utils; use serde::Deserialize; use url::{ParseError, Url}; diff --git a/crates/ethers-signers/Cargo.toml b/crates/ethers-signers/Cargo.toml index 21008092..3b758378 100644 --- a/crates/ethers-signers/Cargo.toml +++ b/crates/ethers-signers/Cargo.toml @@ -7,4 +7,3 @@ edition = "2018" [dependencies] ethers-types = { version = "0.1.0", path = "../ethers-types" } ethers-providers = { version = "0.1.0", path = "../ethers-providers" } -ethers-utils = { version = "0.1.0", path = "../ethers-utils" } diff --git a/crates/ethers-types/Cargo.toml b/crates/ethers-types/Cargo.toml index 236460ff..65a6ad0f 100644 --- a/crates/ethers-types/Cargo.toml +++ b/crates/ethers-types/Cargo.toml @@ -5,8 +5,6 @@ authors = ["Georgios Konstantopoulos "] edition = "2018" [dependencies] -ethers-utils = { version = "0.1.0", path = "../ethers-utils" } - # ethereum related ethereum-types = { version = "0.9.2", default-features = false, features = ["serialize"] } rlp = { version = "0.4.5", default-features = false } @@ -16,6 +14,8 @@ ethabi = { version = "12.0.0", default-features = false, optional = true } secp256k1 = { version = "0.17.2", default-features = false, features = ["std", "recovery", "rand"] } rand = { version = "0.5.1", default-features = false } # this should be the same rand crate version as the one in secp zeroize = { version = "1.1.0", default-features = false } +tiny-keccak = { version = "2.0.2", default-features = false } + # misc serde = { version = "1.0.110", default-features = false, features = ["derive"] } diff --git a/crates/ethers-types/src/abi/mod.rs b/crates/ethers-types/src/abi/mod.rs index 91c7ab26..2d67f96f 100644 --- a/crates/ethers-types/src/abi/mod.rs +++ b/crates/ethers-types/src/abi/mod.rs @@ -1,7 +1,6 @@ //! This module implements extensions to the `ethabi` API. // Adapted from [Gnosis' ethcontract](https://github.com/gnosis/ethcontract-rs/blob/master/common/src/abiext.rs) -use crate::Selector; -use ethers_utils::id; +use crate::{utils::id, Selector}; pub use ethabi::Contract as Abi; pub use ethabi::*; diff --git a/crates/ethers-types/src/chainstate/log.rs b/crates/ethers-types/src/chainstate/log.rs index 2ddd3b79..80cf5d89 100644 --- a/crates/ethers-types/src/chainstate/log.rs +++ b/crates/ethers-types/src/chainstate/log.rs @@ -1,6 +1,5 @@ // Adapted from https://github.com/tomusdrw/rust-web3/blob/master/src/types/log.rs -use crate::{Address, BlockNumber, Bytes, H256, U256, U64}; -use ethers_utils::keccak256; +use crate::{utils::keccak256, Address, BlockNumber, Bytes, H256, U256, U64}; use serde::{ser::SerializeSeq, Deserialize, Serialize, Serializer}; use std::str::FromStr; @@ -221,7 +220,7 @@ where #[cfg(test)] mod tests { use super::*; - use ethers_utils::serialize; + use crate::utils::serialize; #[test] fn filter_serialization_test() { diff --git a/crates/ethers-types/src/chainstate/transaction.rs b/crates/ethers-types/src/chainstate/transaction.rs index b150bb20..3f6a5c34 100644 --- a/crates/ethers-types/src/chainstate/transaction.rs +++ b/crates/ethers-types/src/chainstate/transaction.rs @@ -1,6 +1,7 @@ //! Transaction types -use crate::{Address, Bloom, Bytes, Log, NameOrAddress, Signature, H256, U256, U64}; -use ethers_utils::keccak256; +use crate::{ + utils::keccak256, Address, Bloom, Bytes, Log, NameOrAddress, Signature, H256, U256, U64, +}; use rlp::RlpStream; use serde::{Deserialize, Serialize}; diff --git a/crates/ethers-types/src/crypto/keys.rs b/crates/ethers-types/src/crypto/keys.rs index c021426a..a024fd6d 100644 --- a/crates/ethers-types/src/crypto/keys.rs +++ b/crates/ethers-types/src/crypto/keys.rs @@ -1,5 +1,7 @@ -use crate::{Address, NameOrAddress, Signature, Transaction, TransactionRequest, H256, U256, U64}; -use ethers_utils::{hash_message, keccak256}; +use crate::{ + utils::{hash_message, keccak256}, + Address, NameOrAddress, Signature, Transaction, TransactionRequest, H256, U256, U64, +}; use rand::Rng; use secp256k1::{ diff --git a/crates/ethers-types/src/crypto/signature.rs b/crates/ethers-types/src/crypto/signature.rs index 71bd8d88..dcd6b96c 100644 --- a/crates/ethers-types/src/crypto/signature.rs +++ b/crates/ethers-types/src/crypto/signature.rs @@ -1,6 +1,5 @@ // Code adapted from: https://github.com/tomusdrw/rust-web3/blob/master/src/api/accounts.rs -use crate::{Address, PublicKey, H256}; -use ethers_utils::hash_message; +use crate::{utils::hash_message, Address, PublicKey, H256}; use rustc_hex::ToHex; use secp256k1::{ diff --git a/crates/ethers-types/src/lib.rs b/crates/ethers-types/src/lib.rs index b8d22f15..d4ce76ea 100644 --- a/crates/ethers-types/src/lib.rs +++ b/crates/ethers-types/src/lib.rs @@ -44,8 +44,4 @@ pub use chainstate::*; #[cfg(feature = "abi")] pub mod abi; -// Convenience re-export -pub use ethers_utils as utils; - -mod solc; -pub use solc::Solc; +pub mod utils; diff --git a/crates/ethers-utils/src/ganache.rs b/crates/ethers-types/src/utils/ganache.rs similarity index 97% rename from crates/ethers-utils/src/ganache.rs rename to crates/ethers-types/src/utils/ganache.rs index aa3813c9..b3870862 100644 --- a/crates/ethers-utils/src/ganache.rs +++ b/crates/ethers-types/src/utils/ganache.rs @@ -18,7 +18,8 @@ impl Drop for Ganache { /// # Example /// /// ```rust,ignore -/// use ethers_utils::ganache::GanacheBuilder; +/// use ethers_types::utils::ganache::GanacheBuilder; +/// /// let port = 8545u64; /// let url = format!("http://localhost:{}", port).to_string(); /// diff --git a/crates/ethers-utils/src/lib.rs b/crates/ethers-types/src/utils/hash.rs similarity index 97% rename from crates/ethers-utils/src/lib.rs rename to crates/ethers-types/src/utils/hash.rs index 09aa48c7..6c804eb7 100644 --- a/crates/ethers-utils/src/lib.rs +++ b/crates/ethers-types/src/utils/hash.rs @@ -2,9 +2,6 @@ use ethereum_types::H256; use tiny_keccak::{Hasher, Keccak}; -/// Utilities for launching a ganache-cli testnet instance -pub mod ganache; - const PREFIX: &str = "\x19Ethereum Signed Message:\n"; /// Hash a message according to EIP-191. diff --git a/crates/ethers-types/src/utils/mod.rs b/crates/ethers-types/src/utils/mod.rs new file mode 100644 index 00000000..7d6d70fc --- /dev/null +++ b/crates/ethers-types/src/utils/mod.rs @@ -0,0 +1,10 @@ +/// Utilities for launching a ganache-cli testnet instance +mod ganache; +pub use ganache::{Ganache, GanacheBuilder}; + +/// Solidity compiler bindings +mod solc; +pub use solc::{CompiledContract, Solc}; + +mod hash; +pub use hash::{hash_message, id, keccak256, serialize}; diff --git a/crates/ethers-types/src/solc.rs b/crates/ethers-types/src/utils/solc.rs similarity index 98% rename from crates/ethers-types/src/solc.rs rename to crates/ethers-types/src/utils/solc.rs index 8c30a99d..d173a806 100644 --- a/crates/ethers-types/src/solc.rs +++ b/crates/ethers-types/src/utils/solc.rs @@ -116,7 +116,7 @@ impl Solc { .into(); let name = name - .rsplit(":") + .rsplit(':') .next() .expect("could not strip fname") .to_owned(); @@ -136,7 +136,7 @@ impl Solc { let command_output = Command::new(SOLC) .arg("--version") .output() - .expect(&format!("`{}` not in user's $PATH", SOLC)); + .unwrap_or_else(|_| panic!("`{}` not in user's $PATH", SOLC)); let version = command_output .stdout diff --git a/crates/ethers-utils/Cargo.toml b/crates/ethers-utils/Cargo.toml deleted file mode 100644 index 7ce132a6..00000000 --- a/crates/ethers-utils/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "ethers-utils" -version = "0.1.0" -authors = ["Georgios Konstantopoulos "] -edition = "2018" - -[dependencies] -ethereum-types = { version = "0.9.2", default-features = false, features = ["serialize"] } -tiny-keccak = { version = "2.0.2", default-features = false } -serde = { version = "1.0.110", default-features = false } -serde_json = { version = "1.0.53", default-features = false, features = ["alloc"] } - -[dev-dependencies] -rustc-hex = "2.1.0" diff --git a/crates/ethers/Cargo.toml b/crates/ethers/Cargo.toml index 29e443f5..33c3d644 100644 --- a/crates/ethers/Cargo.toml +++ b/crates/ethers/Cargo.toml @@ -11,25 +11,20 @@ full = [ "providers", "signers", "types", - "utils", ] contract = ["ethers-contract"] providers = ["ethers-providers"] signers = ["ethers-signers"] types = ["ethers-types"] -utils = ["ethers-utils"] [dependencies] ethers-contract = { version = "0.1.0", path = "../ethers-contract", features = ["abigen"], optional = true } ethers-providers = { version = "0.1.0", path = "../ethers-providers", optional = true } ethers-signers = { version = "0.1.0", path = "../ethers-signers", optional = true } ethers-types = { version = "0.1.0", path = "../ethers-types", optional = true } -ethers-utils = { version = "0.1.0", path = "../ethers-utils", optional = true } [dev-dependencies] -ethers-contract = { version = "0.1.0", path = "../ethers-contract", features = ["abigen"] } - anyhow = "1.0.31" tokio = { version = "0.2.21", features = ["macros"] } serde_json = "1.0.53" diff --git a/crates/ethers/examples/contract.rs b/crates/ethers/examples/contract.rs index a30e0015..ed73c69d 100644 --- a/crates/ethers/examples/contract.rs +++ b/crates/ethers/examples/contract.rs @@ -3,8 +3,7 @@ use ethers::{ contract::{abigen, ContractFactory}, providers::HttpProvider, signers::MainnetWallet, - types::Solc, - utils::ganache::GanacheBuilder, + types::utils::{GanacheBuilder, Solc}, }; use std::convert::TryFrom; @@ -50,7 +49,7 @@ async fn main() -> Result<()> { let addr = contract.address(); // 9. instantiate the contract - let contract = SimpleContract::new(addr.clone(), &client); + let contract = SimpleContract::new(*addr, &client); // 10. call the `setValue` method let _tx_hash = contract.set_value("hi".to_owned()).send().await?; diff --git a/crates/ethers/examples/local_signer.rs b/crates/ethers/examples/local_signer.rs index d4b38dcd..5bf0dfaf 100644 --- a/crates/ethers/examples/local_signer.rs +++ b/crates/ethers/examples/local_signer.rs @@ -1,7 +1,8 @@ use anyhow::Result; use ethers::{ - providers::HttpProvider, signers::MainnetWallet, types::TransactionRequest, - utils::ganache::GanacheBuilder, + providers::HttpProvider, + signers::MainnetWallet, + types::{utils::GanacheBuilder, TransactionRequest}, }; use std::convert::TryFrom; diff --git a/crates/ethers/examples/transfer_eth.rs b/crates/ethers/examples/transfer_eth.rs index ad0afb79..86ea7f29 100644 --- a/crates/ethers/examples/transfer_eth.rs +++ b/crates/ethers/examples/transfer_eth.rs @@ -1,8 +1,7 @@ use anyhow::Result; use ethers::{ providers::{networks::Any, HttpProvider}, - types::{BlockNumber, TransactionRequest}, - utils::ganache::GanacheBuilder, + types::{utils::GanacheBuilder, BlockNumber, TransactionRequest}, }; use std::convert::TryFrom; diff --git a/crates/ethers/src/lib.rs b/crates/ethers/src/lib.rs index a4324b58..a865986d 100644 --- a/crates/ethers/src/lib.rs +++ b/crates/ethers/src/lib.rs @@ -34,8 +34,3 @@ pub mod signers { pub mod types { pub use ethers_types::*; } - -#[cfg(feature = "utils")] -pub mod utils { - pub use ethers_utils::*; -}