Skip to content

Commit

Permalink
cleanup: some clippy and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
prestwich committed Aug 2, 2023
1 parent dcdb4cf commit d45a19d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 54 deletions.
1 change: 1 addition & 0 deletions crates/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ edition = "2021"
alloy-json-rpc.workspace = true
alloy-rlp.workspace = true
alloy-transports.workspace = true
tower = "0.4.13"
66 changes: 27 additions & 39 deletions crates/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,30 @@ pub trait Transaction: alloy_rlp::Encodable + alloy_rlp::Decodable + RpcObject {

pub trait Eip1559Transaction: Transaction {}

// pub trait Middleware<N: Network>
// where
// <Self::Transport as Transport>::Fut: Send,
// {
// type Transport: Transport;
// type Inner: Middleware<N, Transport = Self::Transport>;

// fn client(&self) -> &RpcClient<Self::Transport>;

// fn inner(&self) -> &Self::Inner;

// fn send_transaction(
// &self,
// tx: &N::Transaction,
// ) -> RpcCall<Self::Transport, N::Transaction, N::Receipt> {
// self.inner().send_transaction(tx)
// }
// }

// impl<N: Network, T: Transport> Middleware<N> for RpcClient<T> {
// type Transport = T;

// type Inner = Self;

// fn client(&self) -> &RpcClient<Self::Transport> {
// self
// }

// fn inner(&self) -> &Self::Inner {
// panic!("called inner on RpcClient")
// }

// fn send_transaction(
// &self,
// tx: &N::Transaction,
// ) -> RpcCall<Self::Transport, N::Transaction, N::Receipt> {
// self.prepare("eth_sendTransaction", tx)
// }
// }
pub trait Middleware<N: Network, T: Transport> {
type Inner: Middleware<N, T>;

fn client(&self) -> &RpcClient<T>;

fn inner(&self) -> &Self::Inner;

fn send_transaction(&self, tx: &N::Transaction) -> RpcCall<T, N::Transaction, N::Receipt> {
self.inner().send_transaction(tx)
}
}

impl<N: Network, T: Transport> Middleware<N, T> for RpcClient<T> {
type Inner = Self;

fn client(&self) -> &RpcClient<T> {
self
}

fn inner(&self) -> &Self::Inner {
panic!("called inner on RpcClient")
}

fn send_transaction(&self, tx: &N::Transaction) -> RpcCall<T, N::Transaction, N::Receipt> {
self.prepare("eth_sendTransaction", tx)
}
}
15 changes: 0 additions & 15 deletions crates/transports/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,3 @@ mod transports;
pub use transports::{Http, Transport};

pub use alloy_json_rpc::RpcResult;

#[cfg(test)]
mod test {
use tower::util::BoxCloneService;

use super::*;

fn box_clone_transport() -> BoxCloneService<
Box<serde_json::value::RawValue>,
Box<serde_json::value::RawValue>,
TransportError,
> {
BoxCloneService::new(Http::new("http://localhost:8545".parse().unwrap()))
}
}

0 comments on commit d45a19d

Please sign in to comment.