ethers-rs/ethers-providers/src/lib.rs

32 lines
806 B
Rust
Raw Normal View History

pub mod http;
2020-05-26 10:24:19 +00:00
mod provider;
2020-05-26 09:52:15 +00:00
2020-05-27 15:43:43 +00:00
pub mod networks;
2020-05-28 16:34:06 +00:00
// ENS support
mod ens;
2020-05-27 11:32:44 +00:00
2020-05-26 09:52:15 +00:00
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::{error::Error, fmt::Debug};
2020-05-26 10:24:19 +00:00
pub use provider::Provider;
2020-05-26 09:52:15 +00:00
/// An HTTP provider for interacting with an Ethereum-compatible blockchain
2020-05-27 15:43:43 +00:00
pub type HttpProvider<N> = Provider<http::Provider, N>;
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-05-26 09:52:15 +00:00
pub trait JsonRpcClient: Debug {
2020-05-28 16:34:06 +00:00
/// A JSON-RPC Error
2020-05-26 09:52:15 +00:00
type Error: Error;
2020-05-28 16:34:06 +00:00
/// Sends a request with the provided JSON-RPC and parameters serialized as JSON
2020-05-26 09:52:15 +00:00
async fn request<T: Serialize + Send + Sync, R: for<'a> Deserialize<'a>>(
&self,
method: &str,
params: Option<T>,
) -> Result<R, Self::Error>;
2020-05-26 09:37:31 +00:00
}