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

40 lines
1.0 KiB
Rust
Raw Normal View History

2020-05-26 10:24:19 +00:00
//! Ethereum compatible signers
//!
//! Currently supported:
//! - [x] Private Key
//! - [ ] Encrypted Json
//! - [ ] Ledger
//! - [ ] Trezor
//!
//! Implement the `Signer` trait to add support for new signers, e.g. with Ledger.
//!
//! TODO: We might need a `SignerAsync` trait for HSM use cases?
mod networks;
pub use networks::instantiated::*;
use networks::Network;
mod wallet;
pub use wallet::Wallet;
mod client;
2020-05-26 10:44:35 +00:00
pub use client::Client;
2020-05-26 10:24:19 +00:00
use ethers_types::{Address, Signature, Transaction, TransactionRequest};
use std::error::Error;
/// Trait for signing transactions and messages
///
/// Implement this trait to support different signing modes, e.g. Ledger, hosted etc.
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
}