Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
chore: remove cyclical dependencies (#410)
Browse files Browse the repository at this point in the history
* chore(core): remove ethers dep

* chore(providers): remove ethers dep

tests using higher-rank crates are temporarily disabled

* chore(middleware): remove ethers dep and move tests over from providers

* chore(signers): remove ethers dep

* fix(contracts): correctly determine ethers sub-crates & remove ethers

* fix: re-enable tests for all members

* fix: make contract compile without middleware dep

move over the test using middleware to ethers-middleware

* chore: cargo fmt

* chore(contract): add missing import

* WIP

* WIP

* fix(middleware): use rustls as dev dep

* chore: cargo fmt

* fix: use different key for nonce manager to avoid nonce conflicts

* chore: fix celo test ported over to middlewares

the test had the same private key with an existing middleware test,
causing potential nonce reuses

it now also uses a different storage contract, so we had to change
it to use u256 instead of string

* fix(middleware): enable contracts/celo feature

* chore: ignore non-eip2718 txs to rinkeby
  • Loading branch information
gakonst authored Aug 28, 2021
1 parent 6cc2068 commit 38c7f50
Show file tree
Hide file tree
Showing 39 changed files with 299 additions and 298 deletions.
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ethers-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ futures-util = { version = "0.3.16" }
hex = { version = "0.4.3", default-features = false, features = ["std"] }

[dev-dependencies]
ethers = { version = "0.4.0", path = ".." }
ethers-providers = { version = "0.4.6", path = "../ethers-providers", default-features = false, features = ["ws"] }
ethers-signers = { version = "0.4.6", path = "../ethers-signers" }
ethers-middleware = { version = "0.4.8", path = "../ethers-middleware" }
ethers-contract-abigen = { version = "0.4.7", path = "ethers-contract-abigen" }
ethers-contract-derive = { version = "0.4.7", path = "ethers-contract-derive" }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
tokio = { version = "1.5", default-features = false, features = ["macros"] }
Expand Down
10 changes: 5 additions & 5 deletions ethers-contract/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ use std::{fmt::Debug, marker::PhantomData, sync::Arc};
/// interact with its methods and retrieve raw logs it has emitted.
///
/// ```no_run
/// use ethers::{
/// use ethers_core::{
/// abi::Abi,
/// utils::Solc,
/// types::{Address, H256},
/// contract::Contract,
/// providers::{Provider, Http},
/// signers::Wallet,
/// };
/// use ethers_contract::Contract;
/// use ethers_providers::{Provider, Http};
/// use ethers_signers::Wallet;
/// use std::convert::TryFrom;
///
/// # async fn foo() -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -112,7 +112,7 @@ use std::{fmt::Debug, marker::PhantomData, sync::Arc};
/// datatypes and to have implemented `Detokenize` for it. This boilerplate code
/// is generated for you via the [`abigen`] and [`Abigen` builder] utilities.
///
/// ```no_run
/// ```ignore
/// # async fn foo() -> Result<(), Box<dyn std::error::Error>> {
/// use ethers_core::{abi::Abi, types::Address};
/// use ethers_contract::{Contract, EthEvent};
Expand Down
10 changes: 4 additions & 6 deletions ethers-contract/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,10 @@ impl<M: Middleware> Deployer<M> {
/// # Example
///
/// ```no_run
/// use ethers::{
/// utils::Solc,
/// contract::ContractFactory,
/// providers::{Provider, Http},
/// signers::Wallet
/// };
/// use ethers_core::utils::Solc;
/// use ethers_contract::ContractFactory;
/// use ethers_providers::{Provider, Http};
/// use ethers_signers::Wallet;
/// use std::convert::TryFrom;
///
/// # async fn foo() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
4 changes: 2 additions & 2 deletions ethers-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ pub mod builders {
pub use super::factory::Deployer;
}

#[cfg(feature = "abigen")]
#[cfg(any(test, feature = "abigen"))]
#[cfg_attr(docsrs, doc(cfg(feature = "abigen")))]
pub use ethers_contract_abigen::Abigen;

#[cfg(feature = "abigen")]
#[cfg(any(test, feature = "abigen"))]
#[cfg_attr(docsrs, doc(cfg(feature = "abigen")))]
pub use ethers_contract_derive::{abigen, EthAbiType, EthEvent};

Expand Down
17 changes: 11 additions & 6 deletions ethers-contract/src/multicall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ pub static ADDRESS_BOOK: Lazy<HashMap<U256, Address>> = Lazy::new(|| {
/// # Example
///
/// ```no_run
/// use ethers::{
/// use ethers_core::{
/// abi::Abi,
/// contract::{Contract, Multicall},
/// providers::{Middleware, Http, Provider, PendingTransaction},
/// types::{Address, H256, U256},
/// };
/// use ethers_contract::{Contract, Multicall};
/// use ethers_providers::{Middleware, Http, Provider, PendingTransaction};
/// use std::{convert::TryFrom, sync::Arc};
///
/// # async fn bar() -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -247,7 +247,9 @@ impl<M: Middleware> Multicall<M> {
///
/// ```no_run
/// # async fn foo() -> Result<(), Box<dyn std::error::Error>> {
/// # use ethers::{abi::Abi, prelude::*};
/// # use ethers_core::{abi::Abi, types::{Address, H256}};
/// # use ethers_providers::{Provider, Http};
/// # use ethers_contract::{Multicall, Contract};
/// # use std::{sync::Arc, convert::TryFrom};
/// #
/// # let client = Provider::<Http>::try_from("http://localhost:8545")?;
Expand Down Expand Up @@ -290,7 +292,9 @@ impl<M: Middleware> Multicall<M> {
///
/// ```no_run
/// # async fn foo() -> Result<(), Box<dyn std::error::Error>> {
/// # use ethers::prelude::*;
/// # use ethers_core::types::{U256, Address};
/// # use ethers_providers::{Provider, Http};
/// # use ethers_contract::Multicall;
/// # use std::convert::TryFrom;
/// #
/// # let client = Provider::<Http>::try_from("http://localhost:8545")?;
Expand Down Expand Up @@ -343,7 +347,8 @@ impl<M: Middleware> Multicall<M> {
///
/// ```no_run
/// # async fn foo() -> Result<(), Box<dyn std::error::Error>> {
/// # use ethers::prelude::*;
/// # use ethers_providers::{Provider, Http};
/// # use ethers_contract::Multicall;
/// # use std::convert::TryFrom;
/// # let client = Provider::<Http>::try_from("http://localhost:8545")?;
/// # let multicall = Multicall::new(client, None).await?;
Expand Down
1 change: 1 addition & 0 deletions ethers-contract/tests/abigen.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "abigen")]
//! Test cases to validate the `abigen!` macro
use ethers_contract::{abigen, EthEvent};
use ethers_core::abi::Tokenizable;
Expand Down
5 changes: 3 additions & 2 deletions ethers-contract/tests/common/derive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use ethers::core::types::{H160, H256, I256, U128, U256};
use ethers_contract::{abigen, EthAbiType, EthEvent, EthLogDecode};
use ethers_contract::EthLogDecode;
use ethers_contract::{abigen, EthAbiType, EthEvent};
use ethers_core::abi::{RawLog, Tokenizable};
use ethers_core::types::Address;
use ethers_core::types::{H160, H256, I256, U128, U256};

#[derive(Debug, Clone, PartialEq, EthAbiType)]
struct ValueChanged {
Expand Down
30 changes: 16 additions & 14 deletions ethers-contract/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#![cfg(not(target_arch = "wasm32"))]

#[cfg(feature = "abigen")]
use ethers_core::types::Address;

#[cfg(feature = "abigen")]
use ethers_contract::EthEvent;

#[cfg(feature = "abigen")]
mod derive;
use ethers_core::{
abi::Abi,
types::{Address, Bytes},
};

use ethers_contract::{Contract, ContractFactory, EthEvent};
use ethers_contract::{Contract, ContractFactory};
use ethers_core::utils::{GanacheInstance, Solc};
use ethers_middleware::signer::SignerMiddleware;
use ethers_core::{abi::Abi, types::Bytes};
use ethers_providers::{Http, Middleware, Provider};
use ethers_signers::{LocalWallet, Signer};
use std::{convert::TryFrom, sync::Arc, time::Duration};

// Note: The `EthEvent` derive macro implements the necessary conversion between `Tokens` and
// the struct
#[cfg(feature = "abigen")]
#[derive(Clone, Debug, EthEvent)]
pub struct ValueChanged {
#[ethevent(indexed)]
Expand All @@ -33,16 +37,14 @@ pub fn compile_contract(name: &str, filename: &str) -> (Abi, Bytes) {
(contract.abi.clone(), contract.bytecode.clone())
}

type HttpWallet = SignerMiddleware<Provider<Http>, LocalWallet>;

/// connects the private key to http://localhost:8545
pub fn connect(ganache: &GanacheInstance, idx: usize) -> Arc<HttpWallet> {
pub fn connect(ganache: &GanacheInstance, idx: usize) -> Arc<Provider<Http>> {
let sender = ganache.addresses()[idx];
let provider = Provider::<Http>::try_from(ganache.endpoint())
.unwrap()
.interval(Duration::from_millis(10u64));
let wallet: LocalWallet = ganache.keys()[idx].clone().into();
let wallet = wallet.with_chain_id(1u64);
Arc::new(SignerMiddleware::new(provider, wallet))
.interval(Duration::from_millis(10u64))
.with_sender(sender);
Arc::new(provider)
}

/// Launches a ganache instance and deploys the SimpleStorage contract
Expand Down
Loading

0 comments on commit 38c7f50

Please sign in to comment.