2020-09-20 15:17:02 +00:00
|
|
|
pub mod app;
|
|
|
|
pub mod types;
|
|
|
|
|
2020-09-24 21:33:09 +00:00
|
|
|
use crate::Signer;
|
2020-09-20 15:17:02 +00:00
|
|
|
use app::LedgerEthereum;
|
|
|
|
use async_trait::async_trait;
|
2020-09-24 21:33:09 +00:00
|
|
|
use ethers_core::types::{Address, Signature, TransactionRequest};
|
2020-09-20 15:17:02 +00:00
|
|
|
use types::LedgerError;
|
|
|
|
|
|
|
|
#[async_trait(?Send)]
|
|
|
|
impl Signer for LedgerEthereum {
|
|
|
|
type Error = LedgerError;
|
|
|
|
|
|
|
|
/// Signs the hash of the provided message after prefixing it
|
|
|
|
async fn sign_message<S: Send + Sync + AsRef<[u8]>>(
|
|
|
|
&self,
|
|
|
|
message: S,
|
|
|
|
) -> Result<Signature, Self::Error> {
|
|
|
|
self.sign_message(message).await
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Signs the transaction
|
|
|
|
async fn sign_transaction(
|
|
|
|
&self,
|
2020-09-24 21:33:09 +00:00
|
|
|
message: &TransactionRequest,
|
|
|
|
) -> Result<Signature, Self::Error> {
|
2020-09-20 15:17:02 +00:00
|
|
|
self.sign_tx(message, self.chain_id).await
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns the signer's Ethereum Address
|
2020-09-24 21:33:09 +00:00
|
|
|
fn address(&self) -> Address {
|
|
|
|
self.address
|
2020-09-20 15:17:02 +00:00
|
|
|
}
|
|
|
|
}
|