Skip to content

Commit

Permalink
Merge imports (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
vorot93 authored Dec 10, 2020
1 parent 22c2100 commit 117eb05
Show file tree
Hide file tree
Showing 39 changed files with 320 additions and 288 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
uses: actions-rs/cargo@master
with:
command: fmt
args: --all -- --check
args: --all -- --check --config merge_imports=true
6 changes: 4 additions & 2 deletions examples/bench.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use parking_lot::Mutex;
use std::sync::{atomic, Arc};
use std::{thread, time};
use std::{
sync::{atomic, Arc},
thread, time,
};

#[tokio::main]
async fn main() -> web3::Result {
Expand Down
6 changes: 4 additions & 2 deletions examples/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use hex_literal::hex;
use web3::contract::{Contract, Options};
use web3::types::U256;
use web3::{
contract::{Contract, Options},
types::U256,
};

#[tokio::main]
async fn main() -> web3::contract::Result<()> {
Expand Down
8 changes: 5 additions & 3 deletions examples/contract_log_filter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use hex_literal::hex;
use std::time;
use web3::contract::{Contract, Options};
use web3::futures::StreamExt;
use web3::types::FilterBuilder;
use web3::{
contract::{Contract, Options},
futures::StreamExt,
types::FilterBuilder,
};

#[tokio::main]
async fn main() -> web3::contract::Result<()> {
Expand Down
8 changes: 5 additions & 3 deletions examples/contract_log_pubsub.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use hex_literal::hex;
use std::time;
use web3::contract::{Contract, Options};
use web3::futures::{future, StreamExt};
use web3::types::FilterBuilder;
use web3::{
contract::{Contract, Options},
futures::{future, StreamExt},
types::FilterBuilder,
};

#[tokio::main]
async fn main() -> web3::contract::Result<()> {
Expand Down
6 changes: 4 additions & 2 deletions examples/contract_storage.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//based on examples/contract.rs

use std::time;
use web3::contract::{Contract, Options};
use web3::types::U256;
use web3::{
contract::{Contract, Options},
types::U256,
};

#[tokio::main]
async fn main() -> web3::contract::Result<()> {
Expand Down
28 changes: 14 additions & 14 deletions src/api/accounts.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Partial implementation of the `Accounts` namespace.

use crate::api::Namespace;
use crate::signing;
use crate::types::H256;
use crate::Transport;
use crate::{api::Namespace, signing, types::H256, Transport};

/// `Accounts` namespace
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -46,11 +43,13 @@ impl<T: Transport> Accounts<T> {
#[cfg(feature = "signing")]
mod accounts_signing {
use super::*;
use crate::api::Web3;
use crate::error;
use crate::signing::Signature;
use crate::types::{
Address, Bytes, Recovery, RecoveryMessage, SignedData, SignedTransaction, TransactionParameters, U256,
use crate::{
api::Web3,
error,
signing::Signature,
types::{
Address, Bytes, Recovery, RecoveryMessage, SignedData, SignedTransaction, TransactionParameters, U256,
},
};
use rlp::RlpStream;
use std::convert::TryInto;
Expand Down Expand Up @@ -243,14 +242,15 @@ mod accounts_signing {
#[cfg(test)]
mod tests {
use super::*;
use crate::signing::{SecretKey, SecretKeyRef};
use crate::transports::test::TestTransport;
use crate::types::{Address, Recovery, SignedTransaction, TransactionParameters, U256};
use crate::{
signing::{SecretKey, SecretKeyRef},
transports::test::TestTransport,
types::{Address, Recovery, SignedTransaction, TransactionParameters, U256},
};
use accounts_signing::*;
use hex_literal::hex;
use serde_json::json;

use accounts_signing::*;

#[test]
fn accounts_sign_transaction() {
// retrieved test vector from:
Expand Down
32 changes: 17 additions & 15 deletions src/api/eth.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! `Eth` namespace

use crate::api::Namespace;
use crate::helpers::{self, CallFuture};
use crate::types::{
Address, Block, BlockHeader, BlockId, BlockNumber, Bytes, CallRequest, Filter, Index, Log, SyncState, Transaction,
TransactionId, TransactionReceipt, TransactionRequest, Work, H256, H520, H64, U256, U64,
use crate::{
api::Namespace,
helpers::{self, CallFuture},
types::{
Address, Block, BlockHeader, BlockId, BlockNumber, Bytes, CallRequest, Filter, Index, Log, SyncState,
Transaction, TransactionId, TransactionReceipt, TransactionRequest, Work, H256, H520, H64, U256, U64,
},
Transport,
};
use crate::Transport;

/// `Eth` namespace
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -349,18 +351,18 @@ impl<T: Transport> Eth<T> {

#[cfg(test)]
mod tests {
use super::Eth;
use crate::{
api::Namespace,
rpc::Value,
types::{
Address, Block, BlockHeader, BlockId, BlockNumber, CallRequest, FilterBuilder, Log, SyncInfo, SyncState,
Transaction, TransactionId, TransactionReceipt, TransactionRequest, Work, H256, H520, H64,
},
};
use hex_literal::hex;
use serde_json::json;

use crate::api::Namespace;
use crate::rpc::Value;
use crate::types::{
Address, Block, BlockHeader, BlockId, BlockNumber, CallRequest, FilterBuilder, Log, SyncInfo, SyncState,
Transaction, TransactionId, TransactionReceipt, TransactionRequest, Work, H256, H520, H64,
};

use super::Eth;

// taken from RPC docs.
const EXAMPLE_BLOCK: &str = r#"{
"number": "0x1b4",
Expand Down
25 changes: 13 additions & 12 deletions src/api/eth_filter.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
//! `Eth` namespace, filters.

use crate::{
api::Namespace,
error, helpers, rpc,
types::{Filter, Log, H256},
Transport,
};
use futures::{stream, Stream, TryStreamExt};
use futures_timer::Delay;
use serde::de::DeserializeOwned;
use std::marker::PhantomData;
use std::time::Duration;
use std::{fmt, vec};

use crate::api::Namespace;
use crate::helpers;
use crate::types::{Filter, Log, H256};
use crate::{error, rpc, Transport};
use std::{fmt, marker::PhantomData, time::Duration, vec};

fn filter_stream<T: Transport, I: DeserializeOwned>(
base: BaseFilter<T, I>,
Expand Down Expand Up @@ -201,10 +200,12 @@ impl<T: Transport> EthFilter<T> {
#[cfg(test)]
mod tests {
use super::EthFilter;
use crate::api::Namespace;
use crate::rpc::Value;
use crate::transports::test::TestTransport;
use crate::types::{Address, FilterBuilder, Log, H256};
use crate::{
api::Namespace,
rpc::Value,
transports::test::TestTransport,
types::{Address, FilterBuilder, Log, H256},
};
use futures::stream::StreamExt;
use hex_literal::hex;
use std::time::Duration;
Expand Down
13 changes: 7 additions & 6 deletions src/api/eth_subscribe.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
//! `Eth` namespace, subscriptions

use crate::api::Namespace;
use crate::helpers;
use crate::types::{BlockHeader, Filter, Log, SyncState, H256};
use crate::{error, DuplexTransport};
use crate::{
api::Namespace,
error, helpers,
types::{BlockHeader, Filter, Log, SyncState, H256},
DuplexTransport,
};
use futures::{
task::{Context, Poll},
Stream,
};
use pin_project::{pin_project, pinned_drop};
use std::marker::PhantomData;
use std::pin::Pin;
use std::{marker::PhantomData, pin::Pin};

/// `Eth` namespace, subscriptions
#[derive(Debug, Clone)]
Expand Down
35 changes: 20 additions & 15 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ mod traces;
mod txpool;
mod web3;

pub use self::accounts::Accounts;
pub use self::eth::Eth;
pub use self::eth_filter::{BaseFilter, EthFilter};
pub use self::eth_subscribe::{EthSubscribe, SubscriptionId, SubscriptionStream};
pub use self::net::Net;
pub use self::parity::Parity;
pub use self::parity_accounts::ParityAccounts;
pub use self::parity_set::ParitySet;
pub use self::personal::Personal;
pub use self::traces::Traces;
pub use self::txpool::Txpool;
pub use self::web3::Web3 as Web3Api;

use crate::types::{Bytes, TransactionReceipt, TransactionRequest, U64};
use crate::{confirm, error, DuplexTransport, Transport};
pub use self::{
accounts::Accounts,
eth::Eth,
eth_filter::{BaseFilter, EthFilter},
eth_subscribe::{EthSubscribe, SubscriptionId, SubscriptionStream},
net::Net,
parity::Parity,
parity_accounts::ParityAccounts,
parity_set::ParitySet,
personal::Personal,
traces::Traces,
txpool::Txpool,
web3::Web3 as Web3Api,
};

use crate::{
confirm, error,
types::{Bytes, TransactionReceipt, TransactionRequest, U64},
DuplexTransport, Transport,
};
use futures::Future;
use std::time::Duration;

Expand Down
11 changes: 2 additions & 9 deletions src/api/net.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
//! `Net` namespace

use crate::api::Namespace;
use crate::helpers::CallFuture;
use crate::types::U256;

use crate::Transport;
use crate::{api::Namespace, helpers::CallFuture, types::U256, Transport};

/// `Net` namespace
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -44,11 +40,8 @@ impl<T: Transport> Net<T> {

#[cfg(test)]
mod tests {
use crate::api::Namespace;
use crate::rpc::Value;
use crate::types::U256;

use super::Net;
use crate::{api::Namespace, rpc::Value, types::U256};

rpc_test! (
Net:version => "net_version";
Expand Down
16 changes: 8 additions & 8 deletions src/api/parity_accounts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::api::Namespace;
use crate::helpers::{self, CallFuture};
use crate::types::{Address, H256};
use crate::Transport;
use crate::{
api::Namespace,
helpers::{self, CallFuture},
types::{Address, H256},
Transport,
};

/// `Parity_Accounts` namespace
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -60,11 +62,9 @@ impl<T: Transport> ParityAccounts<T> {

#[cfg(test)]
mod tests {
use crate::api::Namespace;
use crate::rpc::Value;
use ethereum_types::{Address, H256};

use super::ParityAccounts;
use crate::{api::Namespace, rpc::Value};
use ethereum_types::{Address, H256};

rpc_test! (
ParityAccounts : parity_kill_account, &"9b776baeaf3896657a9ba0db5564623b3e0173e0".parse::<Address>().unwrap(), "123456789"
Expand Down
19 changes: 11 additions & 8 deletions src/api/parity_set.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::api::Namespace;
use crate::helpers::{self, CallFuture};
use crate::types::{Address, ParityPeerType, H256};

use crate::Transport;
use crate::{
api::Namespace,
helpers::{self, CallFuture},
types::{Address, ParityPeerType, H256},
Transport,
};

#[derive(Debug, Clone)]
/// `Parity_Set` Specific API
Expand Down Expand Up @@ -132,9 +133,11 @@ impl<T: Transport> ParitySet<T> {
#[cfg(test)]
mod tests {
use super::ParitySet;
use crate::api::Namespace;
use crate::rpc::Value;
use crate::types::{Address, ParityPeerInfo, ParityPeerType, PeerNetworkInfo, PeerProtocolsInfo, H256};
use crate::{
api::Namespace,
rpc::Value,
types::{Address, ParityPeerInfo, ParityPeerType, PeerNetworkInfo, PeerProtocolsInfo, H256},
};

rpc_test! (
ParitySet:accept_non_reserved_peers => "parity_acceptNonReservedPeers";
Expand Down
22 changes: 12 additions & 10 deletions src/api/personal.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//! `Personal` namespace

use crate::api::Namespace;
use crate::helpers::{self, CallFuture};
use crate::types::{Address, RawTransaction, TransactionRequest, H256};

use crate::Transport;
use crate::{
api::Namespace,
helpers::{self, CallFuture},
types::{Address, RawTransaction, TransactionRequest, H256},
Transport,
};

/// `Personal` namespace
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -80,12 +81,13 @@ impl<T: Transport> Personal<T> {

#[cfg(test)]
mod tests {
use crate::api::Namespace;
use crate::rpc::Value;
use crate::types::{Address, RawTransaction, TransactionRequest};
use hex_literal::hex;

use super::Personal;
use crate::{
api::Namespace,
rpc::Value,
types::{Address, RawTransaction, TransactionRequest},
};
use hex_literal::hex;

const EXAMPLE_TX: &str = r#"{
"raw": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
Expand Down
Loading

0 comments on commit 117eb05

Please sign in to comment.