#![doc = include_str!("../README.md")]
#![deny(unsafe_code, rustdoc::broken_intra_doc_links)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
mod wallet;
pub use wallet::{MnemonicBuilder, Wallet, WalletError};
pub use coins_bip39;
pub type LocalWallet = Wallet<ethers_core::k256::ecdsa::SigningKey>;
#[cfg(all(feature = "yubihsm", not(target_arch = "wasm32")))]
pub type YubiWallet = Wallet<yubihsm::ecdsa::Signer<ethers_core::k256::Secp256k1>>;
#[cfg(all(feature = "ledger", not(target_arch = "wasm32")))]
mod ledger;
#[cfg(all(feature = "ledger", not(target_arch = "wasm32")))]
pub use ledger::{
app::LedgerEthereum as Ledger,
types::{DerivationType as HDPath, LedgerError},
};
#[cfg(all(feature = "trezor", not(target_arch = "wasm32")))]
mod trezor;
#[cfg(all(feature = "trezor", not(target_arch = "wasm32")))]
pub use trezor::{
app::TrezorEthereum as Trezor,
types::{DerivationType as TrezorHDPath, TrezorError},
};
#[cfg(all(feature = "yubihsm", not(target_arch = "wasm32")))]
pub use yubihsm;
#[cfg(feature = "aws")]
mod aws;
#[cfg(feature = "aws")]
pub use aws::{AwsSigner, AwsSignerError};
use async_trait::async_trait;
use ethers_core::types::{
transaction::{eip2718::TypedTransaction, eip712::Eip712},
Address, Signature,
};
use std::error::Error;
pub fn to_eip155_v<T: Into<u8>>(recovery_id: T, chain_id: u64) -> u64 {
(recovery_id.into() as u64) + 35 + chain_id * 2
}
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait Signer: std::fmt::Debug + Send + Sync {
type Error: Error + Send + Sync;
async fn sign_message<S: Send + Sync + AsRef<[u8]>>(
&self,
message: S,
) -> Result<Signature, Self::Error>;
async fn sign_transaction(&self, message: &TypedTransaction) -> Result<Signature, Self::Error>;
async fn sign_typed_data<T: Eip712 + Send + Sync>(
&self,
payload: &T,
) -> Result<Signature, Self::Error>;
fn address(&self) -> Address;
fn chain_id(&self) -> u64;
#[must_use]
fn with_chain_id<T: Into<u64>>(self, chain_id: T) -> Self;
}