diff --git a/crates/ethers-signers/src/client.rs b/crates/ethers-signers/src/client.rs index 2b42eeed..fec5f125 100644 --- a/crates/ethers-signers/src/client.rs +++ b/crates/ethers-signers/src/client.rs @@ -6,6 +6,9 @@ use ethers_types::{Address, BlockNumber, NameOrAddress, TransactionRequest, TxHa use std::ops::Deref; #[derive(Clone, Debug)] +/// A client provides an interface for signing and broadcasting locally signed transactions +/// It Derefs to `Provider`, which allows interacting with the Ethereum JSON-RPC provider +/// via the same API. pub struct Client<'a, P, N, S> { pub(crate) provider: &'a Provider
,
pub(crate) signer: Option,
@@ -26,8 +29,7 @@ where
P: JsonRpcClient,
N: Network,
{
- /// Signs the transaction and then broadcasts its RLP encoding via the `eth_sendRawTransaction`
- /// API
+ /// Signs and broadcasts the transaction
pub async fn send_transaction(
&self,
mut tx: TransactionRequest,
@@ -92,6 +94,7 @@ where
Ok(())
}
+ /// Returns the client's address
pub fn address(&self) -> Address {
self.signer
.as_ref()
@@ -99,6 +102,7 @@ where
.unwrap_or_default()
}
+ /// Returns a reference to the client's provider
pub fn provider(&self) -> &Provider
{
self.provider
}
diff --git a/crates/ethers-signers/src/lib.rs b/crates/ethers-signers/src/lib.rs
index 6ac4a081..94e6bc9f 100644
--- a/crates/ethers-signers/src/lib.rs
+++ b/crates/ethers-signers/src/lib.rs
@@ -1,14 +1,42 @@
-//! Ethereum compatible signers
+//! # ethers-signers
//!
-//! Currently supported:
-//! - [x] Private Key
-//! - [ ] Encrypted Json
-//! - [ ] Ledger
-//! - [ ] Trezor
+//! Provides a unified interface for locally signing transactions and interacting
+//! with the Ethereum JSON-RPC. You can implement the `Signer` trait to extend
+//! functionality to other signers such as Hardware Security Modules, KMS etc.
//!
-//! Implement the `Signer` trait to add support for new signers, e.g. with Ledger.
+//! ```ignore
+//! # use anyhow::Result;
+//! # use ethers::{providers::HttpProvider, signers::MainnetWallet, types::TransactionRequest};
+//! # use std::convert::TryFrom;
+//! # async fn main() -> Result<()> {
+//! // connect to the network
+//! let provider = HttpProvider::try_from("http://localhost:8545")?;
//!
-//! TODO: We might need a `SignerAsync` trait for HSM use cases?
+//! // instantiate the wallet and connect it to the provider to get a client
+//! let client = "dcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3118b37348c72f7"
+//! .parse::