docs: add some more docs

This commit is contained in:
Georgios Konstantopoulos 2020-06-04 21:44:02 +03:00
parent 73b502ed5f
commit 980e7fca8c
No known key found for this signature in database
GPG Key ID: FA607837CD26EDBC
5 changed files with 32 additions and 15 deletions

View File

@ -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),
}

View File

@ -35,6 +35,11 @@ pub enum ProviderError {
// JSON RPC bindings
impl<P: JsonRpcClient> Provider<P> {
/// 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

View File

@ -29,14 +29,18 @@ impl<P, S> From<Provider<P>> for Client<P, S> {
}
#[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<dyn std::error::Error + Send + Sync>),
#[error("ens name not found: {0}")]
/// Thrown when an ENS name is not found
EnsError(String),
}

View File

@ -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"]

View File

@ -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::<Http>::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::*;
}