ethers-rs/ethers-signers/src/lib.rs

29 lines
966 B
Rust
Raw Normal View History

2020-05-26 10:24:19 +00:00
mod wallet;
pub use wallet::Wallet;
mod client;
2020-06-01 22:27:23 +00:00
pub use client::{Client, ClientError};
2020-05-26 10:24:19 +00:00
2020-05-31 16:01:34 +00:00
use ethers_core::types::{Address, Signature, Transaction, TransactionRequest};
use ethers_providers::Http;
2020-05-26 10:24:19 +00:00
use std::error::Error;
/// Trait for signing transactions and messages
///
/// Implement this trait to support different signing modes, e.g. Ledger, hosted etc.
// TODO: We might need a `SignerAsync` trait for HSM use cases?
pub trait Signer: Clone {
2020-06-01 23:00:58 +00:00
type Error: Error + Into<ClientError>;
2020-05-26 10:24:19 +00:00
/// Signs the hash of the provided message after prefixing it
fn sign_message<S: AsRef<[u8]>>(&self, message: S) -> Signature;
/// Signs the transaction
fn sign_transaction(&self, message: TransactionRequest) -> Result<Transaction, Self::Error>;
/// Returns the signer's Ethereum Address
fn address(&self) -> Address;
2020-05-26 09:37:31 +00:00
}
2020-05-27 15:43:43 +00:00
/// An HTTP client configured to work with ANY blockchain without replay protection
pub type HttpClient = Client<Http, Wallet>;