parent
ea010be5cb
commit
beead7e54d
|
@ -1412,7 +1412,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hidapi"
|
name = "hidapi"
|
||||||
version = "1.1.1"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -4337,7 +4337,7 @@ version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base32 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"base32 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dialoguer 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dialoguer 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hidapi 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hidapi 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -6229,7 +6229,7 @@ dependencies = [
|
||||||
"checksum hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0"
|
"checksum hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0"
|
||||||
"checksum hex-literal-impl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06095d08c7c05760f11a071b3e1d4c5b723761c01bd8d7201c30a9536668a612"
|
"checksum hex-literal-impl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06095d08c7c05760f11a071b3e1d4c5b723761c01bd8d7201c30a9536668a612"
|
||||||
"checksum hex_fmt 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f"
|
"checksum hex_fmt 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f"
|
||||||
"checksum hidapi 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "289d0fb85e9ea18785708d4d735eca4f480b533b005e6f8aa2ffba0207800c75"
|
"checksum hidapi 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1cfd6cd631a5f39abaabad541f0b64bfcb7e55fa5c7de9a1e5d5578cb86dd687"
|
||||||
"checksum histogram 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "12cb882ccb290b8646e554b157ab0b71e64e8d5bef775cd66b6531e52d302669"
|
"checksum histogram 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "12cb882ccb290b8646e554b157ab0b71e64e8d5bef775cd66b6531e52d302669"
|
||||||
"checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695"
|
"checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695"
|
||||||
"checksum http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0"
|
"checksum http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0"
|
||||||
|
|
|
@ -11,7 +11,7 @@ homepage = "https://solana.com/"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base32 = "0.4.0"
|
base32 = "0.4.0"
|
||||||
dialoguer = "0.5.0"
|
dialoguer = "0.5.0"
|
||||||
hidapi = { version = "1.1.1", default-features = false }
|
hidapi = { version = "1.2.0", default-features = false }
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
parking_lot = "0.10"
|
parking_lot = "0.10"
|
||||||
semver = "0.9"
|
semver = "0.9"
|
||||||
|
|
|
@ -249,24 +249,25 @@ impl LedgerWallet {
|
||||||
impl RemoteWallet for LedgerWallet {
|
impl RemoteWallet for LedgerWallet {
|
||||||
fn read_device(
|
fn read_device(
|
||||||
&self,
|
&self,
|
||||||
dev_info: &hidapi::HidDeviceInfo,
|
dev_info: &hidapi::DeviceInfo,
|
||||||
) -> Result<RemoteWalletInfo, RemoteWalletError> {
|
) -> Result<RemoteWalletInfo, RemoteWalletError> {
|
||||||
let manufacturer = dev_info
|
let manufacturer = dev_info
|
||||||
.manufacturer_string
|
.manufacturer_string()
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| "Unknown".to_owned())
|
.unwrap_or("Unknown")
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
.replace(" ", "-");
|
.replace(" ", "-");
|
||||||
let model = dev_info
|
let model = dev_info
|
||||||
.product_string
|
.product_string()
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| "Unknown".to_owned())
|
.unwrap_or("Unknown")
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
.replace(" ", "-");
|
.replace(" ", "-");
|
||||||
let serial = dev_info
|
let serial = dev_info
|
||||||
.serial_number
|
.serial_number()
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| "Unknown".to_owned());
|
.unwrap_or("Unknown")
|
||||||
|
.to_string();
|
||||||
let pubkey_result = self.get_pubkey(&DerivationPath::default(), false);
|
let pubkey_result = self.get_pubkey(&DerivationPath::default(), false);
|
||||||
let (pubkey, error) = match pubkey_result {
|
let (pubkey, error) = match pubkey_result {
|
||||||
Ok(pubkey) => (pubkey, None),
|
Ok(pubkey) => (pubkey, None),
|
||||||
|
|
|
@ -94,21 +94,20 @@ impl RemoteWalletManager {
|
||||||
pub fn update_devices(&self) -> Result<usize, RemoteWalletError> {
|
pub fn update_devices(&self) -> Result<usize, RemoteWalletError> {
|
||||||
let mut usb = self.usb.lock();
|
let mut usb = self.usb.lock();
|
||||||
usb.refresh_devices()?;
|
usb.refresh_devices()?;
|
||||||
let devices = usb.devices();
|
let devices = usb.device_list();
|
||||||
let num_prev_devices = self.devices.read().len();
|
let num_prev_devices = self.devices.read().len();
|
||||||
|
|
||||||
let detected_devices = devices
|
let detected_devices = devices
|
||||||
.iter()
|
|
||||||
.filter(|&device_info| {
|
.filter(|&device_info| {
|
||||||
is_valid_hid_device(device_info.usage_page, device_info.interface_number)
|
is_valid_hid_device(device_info.usage_page(), device_info.interface_number())
|
||||||
})
|
})
|
||||||
.fold(Vec::new(), |mut v, device_info| {
|
.fold(Vec::new(), |mut v, device_info| {
|
||||||
if is_valid_ledger(device_info.vendor_id, device_info.product_id) {
|
if is_valid_ledger(device_info.vendor_id(), device_info.product_id()) {
|
||||||
match usb.open_path(&device_info.path) {
|
match usb.open_path(&device_info.path()) {
|
||||||
Ok(device) => {
|
Ok(device) => {
|
||||||
let ledger = LedgerWallet::new(device);
|
let ledger = LedgerWallet::new(device);
|
||||||
if let Ok(info) = ledger.read_device(&device_info) {
|
if let Ok(info) = ledger.read_device(&device_info) {
|
||||||
let path = device_info.path.to_str().unwrap().to_string();
|
let path = device_info.path().to_str().unwrap().to_string();
|
||||||
trace!("Found device: {:?}", info);
|
trace!("Found device: {:?}", info);
|
||||||
v.push(Device {
|
v.push(Device {
|
||||||
path,
|
path,
|
||||||
|
@ -176,7 +175,7 @@ pub trait RemoteWallet {
|
||||||
/// Parse device info and get device base pubkey
|
/// Parse device info and get device base pubkey
|
||||||
fn read_device(
|
fn read_device(
|
||||||
&self,
|
&self,
|
||||||
dev_info: &hidapi::HidDeviceInfo,
|
dev_info: &hidapi::DeviceInfo,
|
||||||
) -> Result<RemoteWalletInfo, RemoteWalletError>;
|
) -> Result<RemoteWalletInfo, RemoteWalletError>;
|
||||||
|
|
||||||
/// Get solana pubkey from a RemoteWallet
|
/// Get solana pubkey from a RemoteWallet
|
||||||
|
|
Loading…
Reference in New Issue