2020-06-10 08:58:27 +00:00
|
|
|
mod http;
|
2020-06-01 21:58:21 +00:00
|
|
|
pub use http::Provider as Http;
|
2020-06-10 08:58:27 +00:00
|
|
|
|
2020-05-26 10:24:19 +00:00
|
|
|
mod provider;
|
2020-05-26 09:52:15 +00:00
|
|
|
|
2020-05-28 16:34:06 +00:00
|
|
|
// ENS support
|
|
|
|
mod ens;
|
2020-05-27 11:32:44 +00:00
|
|
|
|
2020-06-15 12:40:06 +00:00
|
|
|
mod pending_transaction;
|
|
|
|
pub use pending_transaction::PendingTransaction;
|
|
|
|
|
2020-06-15 08:46:07 +00:00
|
|
|
mod stream;
|
|
|
|
pub use stream::FilterStream;
|
|
|
|
// re-export `StreamExt` so that consumers can call `next()` on the `FilterStream`
|
|
|
|
// without having to import futures themselves
|
|
|
|
pub use futures_util::StreamExt;
|
|
|
|
|
2020-05-26 09:52:15 +00:00
|
|
|
use async_trait::async_trait;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use std::{error::Error, fmt::Debug};
|
|
|
|
|
2020-06-01 21:31:32 +00:00
|
|
|
pub use provider::{Provider, ProviderError};
|
2020-05-26 10:24:19 +00:00
|
|
|
|
2020-05-26 09:52:15 +00:00
|
|
|
#[async_trait]
|
2020-05-28 16:34:06 +00:00
|
|
|
/// Trait which must be implemented by data transports to be used with the Ethereum
|
|
|
|
/// JSON-RPC provider.
|
2020-06-02 10:36:02 +00:00
|
|
|
pub trait JsonRpcClient: Debug + Clone {
|
2020-05-28 16:34:06 +00:00
|
|
|
/// A JSON-RPC Error
|
2020-06-01 23:00:58 +00:00
|
|
|
type Error: Error + Into<ProviderError>;
|
2020-05-26 09:52:15 +00:00
|
|
|
|
2020-05-28 16:34:06 +00:00
|
|
|
/// Sends a request with the provided JSON-RPC and parameters serialized as JSON
|
2020-06-15 10:53:40 +00:00
|
|
|
async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
|
2020-06-10 07:10:33 +00:00
|
|
|
where
|
2020-06-15 12:40:06 +00:00
|
|
|
T: Debug + Serialize + Send + Sync,
|
2020-06-10 07:10:33 +00:00
|
|
|
R: for<'a> Deserialize<'a>;
|
2020-05-26 09:37:31 +00:00
|
|
|
}
|