From 5a313243586d143d8321b3335a8a151289eb5db2 Mon Sep 17 00:00:00 2001 From: edouardparis Date: Fri, 21 Jun 2024 16:31:41 +0200 Subject: [PATCH] bump async-hwi for hw serial connection fix --- gui/Cargo.lock | 4 +-- gui/Cargo.toml | 2 +- gui/src/hw.rs | 69 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/gui/Cargo.lock b/gui/Cargo.lock index d1d0b87c7..661c303f4 100644 --- a/gui/Cargo.lock +++ b/gui/Cargo.lock @@ -199,9 +199,9 @@ dependencies = [ [[package]] name = "async-hwi" -version = "0.0.18" +version = "0.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db4e95bcb10d14662ffcf56bc33330f47947677e5834a7edaa5ec8520562b36" +checksum = "a278b99ded5aa103de53c13496b0fd9266f2218ec7a37c8f7083285bba567fa7" dependencies = [ "async-trait", "bitbox-api", diff --git a/gui/Cargo.toml b/gui/Cargo.toml index 40bfc06fe..7cca854fb 100644 --- a/gui/Cargo.toml +++ b/gui/Cargo.toml @@ -15,7 +15,7 @@ path = "src/main.rs" [dependencies] async-trait = "0.1" -async-hwi = "0.0.18" +async-hwi = { version = "0.0.21" } liana = { git = "https://github.com/wizardsardine/liana", branch = "master", default-features = false, features = ["nonblocking_shutdown"] } liana_ui = { path = "ui" } backtrace = "0.3" diff --git a/gui/src/hw.rs b/gui/src/hw.rs index 102bd5589..51126270b 100644 --- a/gui/src/hw.rs +++ b/gui/src/hw.rs @@ -414,20 +414,30 @@ async fn refresh(mut state: State) -> (HardwareWalletMessage, State) { if state.connected_supported_hws.contains(&id) { still.push(id); } else { - let device = specter::Specter::::new(port.clone()); - if tokio::time::timeout( - std::time::Duration::from_millis(500), - device.fingerprint(), - ) - .await - .is_ok() - { - match HardwareWallet::new(id, Arc::new(device), Some(&state.keys_aliases)) + match specter::Specter::::new(port.clone()) { + Err(e) => { + warn!("{}", e); + } + Ok(device) => { + if tokio::time::timeout( + std::time::Duration::from_millis(500), + device.fingerprint(), + ) .await - { - Ok(hw) => hws.push(hw), - Err(e) => { - debug!("{}", e); + .is_ok() + { + match HardwareWallet::new( + id, + Arc::new(device), + Some(&state.keys_aliases), + ) + .await + { + Ok(hw) => hws.push(hw), + Err(e) => { + debug!("{}", e); + } + } } } } @@ -444,23 +454,28 @@ async fn refresh(mut state: State) -> (HardwareWalletMessage, State) { if state.connected_supported_hws.contains(&id) { still.push(id); } else { - let device = - Jade::new(jade::SerialTransport::new(port)).with_network(state.network); - match handle_jade_device( - id, - state.network, - device, - state.wallet.as_ref().map(|w| w.as_ref()), - Some(&state.keys_aliases), - ) - .await - { - Ok(hw) => { - hws.push(hw); - } + match jade::SerialTransport::new(port) { Err(e) => { warn!("{:?}", e); } + Ok(device) => { + match handle_jade_device( + id, + state.network, + Jade::new(device).with_network(state.network), + state.wallet.as_ref().map(|w| w.as_ref()), + Some(&state.keys_aliases), + ) + .await + { + Ok(hw) => { + hws.push(hw); + } + Err(e) => { + warn!("{:?}", e); + } + } + } } } }