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

37 lines
1.2 KiB
Rust
Raw Normal View History

2020-05-26 10:24:19 +00:00
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
2020-05-31 16:01:34 +00:00
use ethers_core::types::{Address, Signature, Transaction, TransactionRequest};
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
use ethers_providers::networks::{Any, Mainnet};
/// A Wallet instantiated with chain_id = 1 for Ethereum Mainnet.
pub type MainnetWallet = Wallet<Mainnet>;
/// A wallet which does not use EIP-155 and does not take the chain id into account
/// when creating transactions
pub type AnyWallet = Wallet<Any>;
/// An HTTP client configured to work with ANY blockchain without replay protection
pub type HttpClient<'a> = Client<'a, ethers_providers::http::Provider, Any, Wallet<Any>>;