diff --git a/ethers-providers/src/http.rs b/ethers-providers/src/http.rs index 80501121..57b2f377 100644 --- a/ethers-providers/src/http.rs +++ b/ethers-providers/src/http.rs @@ -22,10 +22,13 @@ pub struct Provider { } #[derive(Error, Debug)] +/// Error thrown when sending an HTTP request pub enum ClientError { + /// Thrown if the request failed #[error(transparent)] ReqwestError(#[from] ReqwestError), #[error(transparent)] + /// Thrown if the response could not be parsed JsonRpcError(#[from] JsonRpcError), } diff --git a/ethers-providers/src/provider.rs b/ethers-providers/src/provider.rs index 885ab408..ae790c4f 100644 --- a/ethers-providers/src/provider.rs +++ b/ethers-providers/src/provider.rs @@ -35,6 +35,11 @@ pub enum ProviderError { // JSON RPC bindings impl Provider

{ + /// Instantiate a new provider with a backend. + pub fn new(provider: P) -> Self { + Self(provider, None) + } + ////// Blockchain Status // // Functions for querying the state of the blockchain diff --git a/ethers-signers/src/client.rs b/ethers-signers/src/client.rs index c30330ca..8cf3a6de 100644 --- a/ethers-signers/src/client.rs +++ b/ethers-signers/src/client.rs @@ -29,14 +29,18 @@ impl From> for Client { } #[derive(Debug, Error)] +/// Error thrown when the client interacts with the blockchain pub enum ClientError { #[error(transparent)] + /// Throw when the call to the provider fails ProviderError(#[from] ProviderError), #[error(transparent)] + /// Thrown when the internal call to the signer fails SignerError(#[from] Box), #[error("ens name not found: {0}")] + /// Thrown when an ENS name is not found EnsError(String), } diff --git a/ethers/Cargo.toml b/ethers/Cargo.toml index f5f71106..566b1fb3 100644 --- a/ethers/Cargo.toml +++ b/ethers/Cargo.toml @@ -11,6 +11,13 @@ description = """ Complete Ethereum library and wallet implementation in Rust. """ +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.playground] +features = ["full"] + [features] default = ["full"] full = [ @@ -37,10 +44,3 @@ tokio = { version = "0.2.21", features = ["macros"] } serde_json = "1.0.53" rand = "0.7" serde = { version = "1.0.110", features = ["derive"] } - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] - -[package.metadata.playground] -features = ["full"] diff --git a/ethers/src/lib.rs b/ethers/src/lib.rs index d422f81a..9626ba7c 100644 --- a/ethers/src/lib.rs +++ b/ethers/src/lib.rs @@ -17,6 +17,17 @@ //! //! # Quickstart //! +//! A prelude is provided which imports all the important things for you. You can connect +//! to the chain by providing a URL to the Provider along with the provider type (Http/Websockets). +//! +//! ```no_run +//! use ethers::prelude::*; +//! let provider = Provider::::try_from("http://localhost:8545").unwrap(); +//! ``` +//! +//! All functions +//! +//! //! ## Sending Ether //! //! ## Checking the state of the blockchain @@ -171,14 +182,8 @@ pub mod signers { /// # ABI Encoding and Decoding /// /// This crate re-exports the [`ethabi`](http://docs.rs/ethabi) crate's functions -/// under the `abi` module -/// -/// # A note about `secp256k1` and `rand` -/// -/// The version of `rand` used in the `secp256k1` crate is not compatible with the -/// latest one in crates at the time of writing (rand version 0.5.1, secp256k1 version 0.17.1) -/// As a result, the RNGs used for generating private keys must use a compatible rand crate -/// version. For convenience, we re-export it so that consumers can use it as `ethers_core::rand`. +/// under the `abi` module, as well as the [`secp256k1`](secp256k1) and [`rand`](rand) +/// crates for convenience. pub mod core { pub use ethers_core::*; }