diff --git a/examples/local_signer.rs b/examples/local_signer.rs index dcbc01f5..2d1d2d5c 100644 --- a/examples/local_signer.rs +++ b/examples/local_signer.rs @@ -1,12 +1,10 @@ -use ethers::providers::{Provider, ProviderTrait}; -use ethers::types::{BlockNumber, UnsignedTransaction}; -use ethers::wallet::MainnetWallet; +use ethers::{types::UnsignedTransaction, HttpProvider, MainnetWallet}; use std::convert::TryFrom; use std::str::FromStr; #[tokio::main] async fn main() -> Result<(), failure::Error> { - let provider = Provider::try_from("http://localhost:8545")?; + let provider = HttpProvider::try_from("http://localhost:8545")?; let client = MainnetWallet::from_str( "d8ebe1e50cfea1f9961908d9df28e64bb163fee9ee48320361b2eb0a54974269", )? @@ -19,7 +17,7 @@ async fn main() -> Result<(), failure::Error> { let tx = UnsignedTransaction { to: Some("986eE0C8B91A58e490Ee59718Cca41056Cf55f24".parse().unwrap()), gas: 21000.into(), - gas_price: 100000.into(), + gas_price: 100_000.into(), value: 10000.into(), input: vec![].into(), nonce, diff --git a/examples/transfer_eth.rs b/examples/transfer_eth.rs index 86c3eeb4..4a9b0e7e 100644 --- a/examples/transfer_eth.rs +++ b/examples/transfer_eth.rs @@ -1,20 +1,18 @@ -use ethers::providers::{Provider, ProviderTrait}; -use ethers::types::{Address, BlockNumber, TransactionRequest}; +use ethers::{ + types::{BlockNumber, TransactionRequest}, + HttpProvider, +}; use std::convert::TryFrom; -use std::str::FromStr; #[tokio::main] async fn main() -> Result<(), failure::Error> { - let provider = Provider::try_from("http://localhost:8545")?; - - let from = Address::from_str("4916064D2E9C1b2ccC466EEc3d30B2b08F1C130D")?; + let provider = HttpProvider::try_from("http://localhost:8545")?; + let from = "4916064D2E9C1b2ccC466EEc3d30B2b08F1C130D".parse()?; let tx_hash = provider .send_transaction(TransactionRequest { from, - to: Some(Address::from_str( - "9A7e5d4bcA656182e66e33340d776D1542143006", - )?), + to: Some("9A7e5d4bcA656182e66e33340d776D1542143006".parse()?), value: Some(1000u64.into()), gas: None, gas_price: None, diff --git a/src/lib.rs b/src/lib.rs index 2a574067..b4a0a5fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,25 @@ //! ethers-rs //! //! ethers-rs is a port of [ethers-js](github.com/ethers-io/ethers.js) in Rust. +//! +//! # Quickstart +//! +//! ## Sending Ether +//! +//! ## Checking the state of the blockchain +//! +//! ## Deploying and interacting with a smart contract +//! +//! ## Watching on-chain events +//! +//! More examples can be found in the [`examples` directory of the +//! repositry](https://github.com/gakonst/ethers-rs) pub mod providers; +pub use providers::HttpProvider; pub mod signers; +pub use signers::{AnyWallet, MainnetWallet}; /// Ethereum related datatypes pub mod types; diff --git a/src/providers/http.rs b/src/providers/http.rs index 95c1907d..5ca0e76d 100644 --- a/src/providers/http.rs +++ b/src/providers/http.rs @@ -69,11 +69,11 @@ impl Provider { } } -impl TryFrom<&str> for Provider { +impl TryFrom<&str> for super::Provider { type Error = ParseError; fn try_from(src: &str) -> Result { - Ok(Provider::new(Url::parse(src)?)) + Ok(super::Provider(Provider::new(Url::parse(src)?))) } } diff --git a/src/signers/networks.rs b/src/signers/networks.rs index 92a73377..84ba0177 100644 --- a/src/signers/networks.rs +++ b/src/signers/networks.rs @@ -30,6 +30,10 @@ pub mod instantiated { use super::*; use crate::signers::Wallet; + /// A Wallet instantiated with chain_id = 1 for Ethereum Mainnet. pub type MainnetWallet = Wallet; + + /// A wallet which does not use EIP-155 and does not take the chain id into account + /// when creating transactions pub type AnyWallet = Wallet; }