hyper_exchange/
adapter.rs1use crate::signer::Signer;
8use motosan_wallet_core::{HlSigner, WalletError};
9
10pub struct SingleAddressSigner<'a, S: Signer + ?Sized> {
13 signer: &'a S,
14 address: String,
15}
16
17impl<'a, S: Signer + ?Sized> SingleAddressSigner<'a, S> {
18 pub fn new(signer: &'a S, address: String) -> Self {
19 Self { signer, address }
20 }
21}
22
23impl<S: Signer + ?Sized> HlSigner for SingleAddressSigner<'_, S> {
24 fn address(&self) -> Result<String, WalletError> {
25 Ok(self.address.clone())
26 }
27
28 fn sign_prehash(&self, hash: &[u8; 32]) -> Result<[u8; 65], WalletError> {
29 let mut sig = self
30 .signer
31 .sign_hash(&self.address, hash)
32 .map_err(|e| WalletError::SigningError(e.to_string()))?;
33 sig[64] += 27;
35 Ok(sig)
36 }
37}