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

29 lines
953 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};
2020-06-01 22:27:23 +00:00
use ethers_providers::http::Provider;
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?
2020-05-26 10:24:19 +00:00
pub trait Signer {
type Error: Error;
/// 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
2020-06-01 22:27:23 +00:00
pub type HttpClient = Client<Provider, Wallet>;