@@ -6,9 +6,8 @@ use crate::{
|
||||
};
|
||||
use solana_sdk::{
|
||||
pubkey::Pubkey,
|
||||
signature::{Signature, Signer},
|
||||
signature::{Signature, Signer, SignerError},
|
||||
};
|
||||
use std::error;
|
||||
|
||||
pub struct RemoteKeypair {
|
||||
pub wallet_type: RemoteWalletType,
|
||||
@@ -25,7 +24,7 @@ impl RemoteKeypair {
|
||||
}
|
||||
|
||||
impl Signer for RemoteKeypair {
|
||||
fn try_pubkey(&self) -> Result<Pubkey, Box<dyn error::Error>> {
|
||||
fn try_pubkey(&self) -> Result<Pubkey, SignerError> {
|
||||
match &self.wallet_type {
|
||||
RemoteWalletType::Ledger(wallet) => wallet
|
||||
.get_pubkey(&self.derivation_path)
|
||||
@@ -33,7 +32,7 @@ impl Signer for RemoteKeypair {
|
||||
}
|
||||
}
|
||||
|
||||
fn try_sign_message(&self, message: &[u8]) -> Result<Signature, Box<dyn error::Error>> {
|
||||
fn try_sign_message(&self, message: &[u8]) -> Result<Signature, SignerError> {
|
||||
match &self.wallet_type {
|
||||
RemoteWalletType::Ledger(wallet) => wallet
|
||||
.sign_message(&self.derivation_path, message)
|
||||
|
@@ -1,7 +1,10 @@
|
||||
use crate::ledger::{is_valid_ledger, LedgerWallet};
|
||||
use log::*;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use solana_sdk::{pubkey::Pubkey, signature::Signature};
|
||||
use solana_sdk::{
|
||||
pubkey::Pubkey,
|
||||
signature::{Signature, SignerError},
|
||||
};
|
||||
use std::{
|
||||
fmt,
|
||||
str::FromStr,
|
||||
@@ -47,6 +50,23 @@ pub enum RemoteWalletError {
|
||||
UserCancel,
|
||||
}
|
||||
|
||||
impl From<RemoteWalletError> for SignerError {
|
||||
fn from(err: RemoteWalletError) -> SignerError {
|
||||
match err {
|
||||
RemoteWalletError::Hid(hid_error) => {
|
||||
SignerError::ConnectionError(hid_error.to_string())
|
||||
}
|
||||
RemoteWalletError::DeviceTypeMismatch => SignerError::ConnectionError(err.to_string()),
|
||||
RemoteWalletError::InvalidDevice => SignerError::ConnectionError(err.to_string()),
|
||||
RemoteWalletError::InvalidInput(input) => SignerError::InvalidInput(input),
|
||||
RemoteWalletError::NoDeviceFound => SignerError::NoDeviceFound,
|
||||
RemoteWalletError::Protocol(e) => SignerError::Protocol(e.to_string()),
|
||||
RemoteWalletError::UserCancel => SignerError::UserCancel,
|
||||
_ => SignerError::CustomError(err.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Collection of conntected RemoteWallets
|
||||
pub struct RemoteWalletManager {
|
||||
usb: Arc<Mutex<hidapi::HidApi>>,
|
||||
|
Reference in New Issue
Block a user