diff --git a/harbor-client/src/cashu_client.rs b/harbor-client/src/cashu_client.rs index bed6b97a..101d87ab 100644 --- a/harbor-client/src/cashu_client.rs +++ b/harbor-client/src/cashu_client.rs @@ -51,10 +51,10 @@ impl TorMintConnector { } #[inline] - async fn http_post( + async fn http_post( &self, url: Url, - payload: &P, + payload: P, ) -> Result { let res: R = make_tor_request(url.as_str(), Some(payload), self.cancel_handle.clone()) .await diff --git a/harbor-client/src/db.rs b/harbor-client/src/db.rs index 62314809..b459b1a1 100644 --- a/harbor-client/src/db.rs +++ b/harbor-client/src/db.rs @@ -236,10 +236,7 @@ impl DBConnection for SQLConnection { fn get_profile(&self) -> anyhow::Result> { let conn = &mut self.db.get()?; - match Profile::get_first(conn)? { - Some(p) => Ok(Some(p)), - None => Ok(None), - } + Profile::get_first(conn) } fn insert_new_profile(&self, new_profile: NewProfile) -> anyhow::Result { diff --git a/harbor-client/src/db_models/cashu_mint.rs b/harbor-client/src/db_models/cashu_mint.rs index 83837c3b..13bb0795 100644 --- a/harbor-client/src/db_models/cashu_mint.rs +++ b/harbor-client/src/db_models/cashu_mint.rs @@ -20,10 +20,10 @@ pub struct CashuMint { } impl CashuMint { - pub fn get(conn: &mut SqliteConnection, url: String) -> anyhow::Result> { + pub fn get(conn: &mut SqliteConnection, url: String) -> anyhow::Result> { Ok(cashu_mint::table .filter(cashu_mint::mint_url.eq(url)) - .first::(conn) + .first::(conn) .optional()?) } @@ -32,7 +32,7 @@ impl CashuMint { let exists = cashu_mint::table .filter(cashu_mint::mint_url.eq(&url)) .filter(cashu_mint::active.eq(1)) - .first::(conn) + .first::(conn) .optional()? .is_some(); @@ -79,7 +79,7 @@ impl CashuMint { // First check if the federation exists and is active let exists = cashu_mint::table .filter(cashu_mint::mint_url.eq(&mint_url)) - .first::(conn) + .first::(conn) .optional()? .is_some(); @@ -87,7 +87,7 @@ impl CashuMint { Self::set_active(conn, &mint_url)?; } - let mint = CashuMint { + let mint = Self { mint_url, active: 1, }; diff --git a/harbor-client/src/db_models/fedimint.rs b/harbor-client/src/db_models/fedimint.rs index 8c8aeefc..4e6578c8 100644 --- a/harbor-client/src/db_models/fedimint.rs +++ b/harbor-client/src/db_models/fedimint.rs @@ -17,15 +17,15 @@ impl Fedimint { pub fn get_value(conn: &mut SqliteConnection, id: String) -> anyhow::Result>> { Ok(fedimint::table .filter(fedimint::id.eq(id)) - .first::(conn) + .first::(conn) .optional()? .map(|v| v.value)) } - pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result> { + pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result> { Ok(fedimint::table .filter(fedimint::id.eq(id)) - .first::(conn) + .first::(conn) .optional()?) } @@ -34,7 +34,7 @@ impl Fedimint { let exists = fedimint::table .filter(fedimint::id.eq(&id)) .filter(fedimint::active.eq(1)) - .first::(conn) + .first::(conn) .optional()? .is_some(); @@ -101,7 +101,7 @@ pub struct NewFedimint { impl From<&NewFedimint> for Fedimint { fn from(new_fedimint: &NewFedimint) -> Self { - Fedimint { + Self { id: new_fedimint.id.clone(), invite_code: new_fedimint.invite_code.clone(), value: new_fedimint.value.clone(), diff --git a/harbor-client/src/db_models/mint_metadata.rs b/harbor-client/src/db_models/mint_metadata.rs index e49718b9..33e05e9f 100644 --- a/harbor-client/src/db_models/mint_metadata.rs +++ b/harbor-client/src/db_models/mint_metadata.rs @@ -21,7 +21,7 @@ pub struct MintMetadata { impl MintMetadata { pub fn from(id: FederationId, meta: FederationMeta) -> Self { - MintMetadata { + Self { id: id.to_string(), federation_expiry_timestamp: meta .federation_expiry_timestamp() @@ -38,10 +38,10 @@ impl MintMetadata { } } - pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result> { + pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result> { Ok(mint_metadata::table .filter(mint_metadata::id.eq(id)) - .first::(conn) + .first::(conn) .optional()?) } @@ -73,8 +73,8 @@ impl MintMetadata { } impl From for FederationMeta { - fn from(value: MintMetadata) -> FederationMeta { - FederationMeta { + fn from(value: MintMetadata) -> Self { + Self { federation_name: value.name, federation_expiry_timestamp: value.federation_expiry_timestamp.map(|f| f.to_string()), welcome_message: value.welcome_message, diff --git a/harbor-client/src/db_models/mod.rs b/harbor-client/src/db_models/mod.rs index 687ddda4..5252a6c5 100644 --- a/harbor-client/src/db_models/mod.rs +++ b/harbor-client/src/db_models/mod.rs @@ -87,10 +87,10 @@ pub enum PaymentStatus { impl PaymentStatus { pub fn from_i32(status: i32) -> Self { match status { - 0 => PaymentStatus::Pending, - 1 => PaymentStatus::WaitingConfirmation, - 2 => PaymentStatus::Success, - 3 => PaymentStatus::Failed, + 0 => Self::Pending, + 1 => Self::WaitingConfirmation, + 2 => Self::Success, + 3 => Self::Failed, _ => panic!("invalid status"), } } diff --git a/harbor-client/src/db_models/profile.rs b/harbor-client/src/db_models/profile.rs index 5782b3c1..fa338752 100644 --- a/harbor-client/src/db_models/profile.rs +++ b/harbor-client/src/db_models/profile.rs @@ -16,8 +16,8 @@ pub struct Profile { } impl Profile { - pub fn get_first(conn: &mut SqliteConnection) -> anyhow::Result> { - Ok(profile::table.first::(conn).optional()?) + pub fn get_first(conn: &mut SqliteConnection) -> anyhow::Result> { + Ok(profile::table.first::(conn).optional()?) } pub fn set_onchain_receive_enabled( @@ -29,7 +29,7 @@ impl Profile { enabled ); diesel::update(profile::table) - .set(profile::onchain_receive_enabled.eq(enabled as i32)) + .set(profile::onchain_receive_enabled.eq(i32::from(enabled))) .execute(conn)?; log::debug!("Successfully updated on-chain receive enabled setting in database"); Ok(()) @@ -42,7 +42,7 @@ impl Profile { pub fn set_tor_enabled(conn: &mut SqliteConnection, enabled: bool) -> anyhow::Result<()> { log::debug!("Updating Tor enabled setting in database to: {}", enabled); diesel::update(profile::table) - .set(profile::tor_enabled.eq(enabled as i32)) + .set(profile::tor_enabled.eq(i32::from(enabled))) .execute(conn)?; log::debug!("Successfully updated Tor enabled setting in database"); Ok(()) @@ -66,7 +66,7 @@ pub struct NewProfile { impl From<&NewProfile> for Profile { fn from(new_profile: &NewProfile) -> Self { - Profile { + Self { id: new_profile.id.clone(), seed_words: new_profile.seed_words.clone(), onchain_receive_enabled: 0, diff --git a/harbor-client/src/fedimint_client.rs b/harbor-client/src/fedimint_client.rs index 6b91a0f8..fc321c31 100644 --- a/harbor-client/src/fedimint_client.rs +++ b/harbor-client/src/fedimint_client.rs @@ -56,15 +56,15 @@ pub enum FederationInviteOrId { impl FederationInviteOrId { pub fn federation_id(&self) -> FederationId { match self { - FederationInviteOrId::Invite(i) => i.federation_id(), - FederationInviteOrId::Id(i) => *i, + Self::Invite(i) => i.federation_id(), + Self::Id(i) => *i, } } pub fn invite_code(&self) -> Option { match self { - FederationInviteOrId::Invite(i) => Some(i.clone()), - FederationInviteOrId::Id(_) => None, + Self::Invite(i) => Some(i.clone()), + Self::Id(_) => None, } } } @@ -170,7 +170,7 @@ impl FedimintClient { ) .await; match client.wait_for_all_recoveries().await { - Ok(_) => { + Ok(()) => { info!("Federation successfully recovered"); HarborCore::send_msg( &mut sender, @@ -240,7 +240,7 @@ impl FedimintClient { let start = Instant::now(); match client.backup_to_federation(Metadata::empty()).await { Err(e) => error!("Could not create backup to federation: {e}"), - Ok(_) => info!("Successfully created backup to federation"), + Ok(()) => info!("Successfully created backup to federation"), } info!("Creating backup took: {}ms", start.elapsed().as_millis()); @@ -255,7 +255,7 @@ impl FedimintClient { .expect("must have ln module"); match lightning_module.update_gateway_cache().await { - Ok(_) => { + Ok(()) => { trace!("Updated lightning gateway cache"); } Err(e) => { @@ -276,7 +276,7 @@ impl FedimintClient { debug!("Built fedimint client"); - Ok(FedimintClient { + Ok(Self { fedimint_client, stop, }) @@ -294,7 +294,7 @@ pub(crate) async fn select_gateway(client: &ClientHandleArc) -> Option = None; - for gateway in gateways.iter() { + for gateway in &gateways { // first try to find a vetted gateway if gateway.vetted { // if we can select the gateway, return it diff --git a/harbor-client/src/http.rs b/harbor-client/src/http.rs index ffea747e..0ed713b9 100644 --- a/harbor-client/src/http.rs +++ b/harbor-client/src/http.rs @@ -23,7 +23,7 @@ use url::Url; static TOR_CLIENT: OnceCell>> = OnceCell::new(); /// Initialize the Tor client if not already initialized -async fn initialize_tor_client() -> anyhow::Result>> { +fn initialize_tor_client() -> anyhow::Result>> { let client = TorClient::builder() .bootstrap_behavior(arti_client::BootstrapBehavior::OnDemand) .create_unbootstrapped()?; @@ -31,11 +31,11 @@ async fn initialize_tor_client() -> anyhow::Result anyhow::Result>> { +fn get_tor_client() -> anyhow::Result>> { match TOR_CLIENT.get() { Some(client) => Ok(client.clone()), _ => { - let client = initialize_tor_client().await?; + let client = initialize_tor_client()?; // It's okay if another thread beat us to initialization let _ = TOR_CLIENT.set(client.clone()); Ok(client) @@ -50,10 +50,10 @@ const MAX_RESPONSE_SIZE: usize = 10 * 1024 * 1024; // 10MB limit /// /// This is the standard way to make HTTPS requests. It: /// - Uses a connection pool for better performance -/// - Handles redirects automatically (up to MAX_REDIRECTS) +/// - Handles redirects automatically (up to `MAX_REDIRECTS`) /// - Enforces a response size limit /// - Returns deserialized JSON -pub(crate) async fn make_get_request_direct(url: &str) -> anyhow::Result +pub async fn make_get_request_direct(url: &str) -> anyhow::Result where T: DeserializeOwned + Send + 'static, { @@ -75,7 +75,7 @@ async fn check_cancel(cancel_handle: Arc) { /// - Enforcing HTTPS-only connections /// - Using fresh circuits for each request /// -/// The request can be cancelled at any time using the cancel_handle. +/// The request can be cancelled at any time using the `cancel_handle`. /// /// Note: This is slower than direct requests due to Tor routing. pub async fn make_get_request_tor(url: &str, cancel_handle: Arc) -> anyhow::Result @@ -93,10 +93,10 @@ where /// - Enforcing HTTPS-only connections /// - Using fresh circuits for each request /// -/// The request can be cancelled at any time using the cancel_handle. +/// The request can be cancelled at any time using the `cancel_handle`. /// /// Note: This is slower than direct requests due to Tor routing. -pub(crate) async fn make_tor_request( +pub async fn make_tor_request( url: &str, payload: Option

, cancel_handle: Arc, @@ -113,7 +113,7 @@ where } // Get a reference to the global TorClient - let tor_client = get_tor_client().await?; + let tor_client = get_tor_client()?; log::debug!("Starting bootstrap if needed"); @@ -123,14 +123,14 @@ where // Use select! to handle cancellation during bootstrap let bootstrap_result = tokio::select! { biased; // Check cancellation first - _ = check_cancel(cancel_handle.clone()) => { + () = check_cancel(cancel_handle.clone()) => { return Err(anyhow!("Request cancelled during bootstrap")); } result = tokio::time::timeout(bootstrap_timeout, tor_client.bootstrap()) => result, }; match bootstrap_result { - Ok(Ok(_)) => log::debug!("Successfully bootstrapped Tor client"), + Ok(Ok(())) => log::debug!("Successfully bootstrapped Tor client"), Ok(Err(e)) => return Err(anyhow!("Failed to bootstrap Tor client: {:?}", e)), Err(_) => { return Err(anyhow!( @@ -173,7 +173,7 @@ where // Use select! to handle cancellation during onion connection let stream_result = tokio::select! { biased; - _ = check_cancel(cancel_handle.clone()) => { + () = check_cancel(cancel_handle.clone()) => { return Err(anyhow!("Request cancelled during onion connection")); } result = tokio::time::timeout( @@ -199,7 +199,7 @@ where // Use select! to handle cancellation during regular connection let stream_result = tokio::select! { biased; - _ = check_cancel(cancel_handle.clone()) => { + () = check_cancel(cancel_handle.clone()) => { return Err(anyhow!("Request cancelled during connection")); } result = tokio::time::timeout(connect_timeout, tor_client.connect(tor_addr)) => result, @@ -239,7 +239,7 @@ where // Use select! to handle cancellation during TLS handshake let tls_result = tokio::select! { biased; - _ = check_cancel(cancel_handle.clone()) => { + () = check_cancel(cancel_handle.clone()) => { return Err(anyhow!("Request cancelled during TLS handshake")); } result = tokio::time::timeout(tls_timeout, connector.connect(server_name, stream)) => result, @@ -336,11 +336,9 @@ where } // Create a new Hyper client with TLS support and reasonable defaults -fn create_https_client() -> anyhow::Result< - Client< - hyper_rustls::HttpsConnector, - Empty, - >, +fn create_https_client() -> Client< + hyper_rustls::HttpsConnector, + Empty, > { let https = HttpsConnectorBuilder::new() .with_webpki_roots() @@ -348,12 +346,10 @@ fn create_https_client() -> anyhow::Result< .enable_http1() .build(); - let client = Client::builder(TokioExecutor::new()) + Client::builder(TokioExecutor::new()) .pool_idle_timeout(Duration::from_secs(30)) .pool_max_idle_per_host(1) - .build(https); - - Ok(client) + .build(https) } /// Common response handling logic @@ -450,7 +446,7 @@ where handle_response(response, 0, None).await } -/// Use what Chrome puts for User Agent for better privacy, copied from: https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome +/// Use what Chrome puts for User Agent for better privacy, copied from: `https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome` const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"; /// Build a GET request with common headers @@ -521,7 +517,7 @@ where log::debug!("Making direct get request to: {}", url); - let client = create_https_client()?; + let client = create_https_client(); let uri: Uri = url .parse() .map_err(|e| anyhow!("Invalid URL '{}': {}", url, e))?; @@ -565,8 +561,8 @@ mod tests { assert!(!res.federations.is_empty()); } Err(e) => { - log::error!("Failed to fetch metadata: {:?}", e); - panic!("Failed to fetch metadata: {:?}", e); + log::error!("Failed to fetch metadata: {e:?}"); + panic!("Failed to fetch metadata: {e:?}"); } } } @@ -586,8 +582,8 @@ mod tests { assert!(!res.federations.is_empty()); } Err(e) => { - log::error!("Failed to fetch metadata: {:?}", e); - panic!("Failed to fetch metadata: {:?}", e); + log::error!("Failed to fetch metadata: {e:?}"); + panic!("Failed to fetch metadata: {e:?}"); } } } @@ -631,8 +627,8 @@ mod tests { assert!(res.get("url").is_some(), "Expected 'url' field in response"); } Err(e) => { - log::error!("Failed to follow redirect: {:?}", e); - panic!("Failed to follow redirect: {:?}", e); + log::error!("Failed to follow redirect: {e:?}"); + panic!("Failed to follow redirect: {e:?}"); } } } diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index fbb0e353..8e99dc7c 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -1,3 +1,27 @@ +#![warn(clippy::nursery, clippy::pedantic)] +#![allow( + clippy::cast_possible_wrap, + clippy::cast_sign_loss, + clippy::default_trait_access, + clippy::derive_partial_eq_without_eq, + clippy::large_futures, + clippy::match_same_arms, + clippy::missing_const_for_fn, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::must_use_candidate, + clippy::needless_pass_by_value, + clippy::option_if_let_else, + clippy::or_fun_call, + clippy::redundant_closure_for_method_calls, + clippy::significant_drop_in_scrutinee, + clippy::significant_drop_tightening, + clippy::similar_names, + clippy::single_char_pattern, + clippy::single_match_else, + clippy::too_many_lines +)] + use crate::cashu_client::{ TorMintConnector, spawn_lightning_payment_thread, spawn_lightning_receive_thread, }; @@ -90,15 +114,15 @@ pub enum MintIdentifier { impl MintIdentifier { pub fn federation_id(&self) -> Option { match self { - MintIdentifier::Fedimint(id) => Some(*id), - _ => None, + Self::Fedimint(id) => Some(*id), + Self::Cashu(_) => None, } } pub fn mint_url(&self) -> Option { match self { - MintIdentifier::Cashu(url) => Some(url.clone()), - _ => None, + Self::Cashu(url) => Some(url.clone()), + Self::Fedimint(_) => None, } } } @@ -337,10 +361,10 @@ impl HarborCore { ) .await; } else { - storage.mark_ln_receive_as_failed(item.operation_id)? + storage.mark_ln_receive_as_failed(item.operation_id)?; } } else { - storage.mark_ln_receive_as_failed(item.operation_id)? + storage.mark_ln_receive_as_failed(item.operation_id)?; } } MintIdentifier::Cashu(mint_url) => { @@ -357,10 +381,10 @@ impl HarborCore { false, ); } else { - storage.mark_ln_receive_as_failed(item.operation_id)? + storage.mark_ln_receive_as_failed(item.operation_id)?; } } else { - storage.mark_ln_receive_as_failed(item.operation_id)? + storage.mark_ln_receive_as_failed(item.operation_id)?; } } } @@ -401,10 +425,10 @@ impl HarborCore { ) .await; } else { - storage.mark_lightning_payment_as_failed(item.operation_id)? + storage.mark_lightning_payment_as_failed(item.operation_id)?; } } else { - storage.mark_lightning_payment_as_failed(item.operation_id)? + storage.mark_lightning_payment_as_failed(item.operation_id)?; } } MintIdentifier::Cashu(mint_url) => { @@ -421,10 +445,10 @@ impl HarborCore { false, ); } else { - storage.mark_lightning_payment_as_failed(item.operation_id)? + storage.mark_lightning_payment_as_failed(item.operation_id)?; } } else { - storage.mark_lightning_payment_as_failed(item.operation_id)? + storage.mark_lightning_payment_as_failed(item.operation_id)?; } } } @@ -448,13 +472,13 @@ impl HarborCore { // Initial setup messages that don't have an id // Panics if fails to send async fn send_system_msg(&self, msg: CoreUIMsg) { - Self::send_msg(&mut self.tx.clone(), None, msg).await + Self::send_msg(&mut self.tx.clone(), None, msg).await; } // Standard core->ui communication with an id // Panics if fails to send pub async fn msg(&self, id: Uuid, msg: CoreUIMsg) { - Self::send_msg(&mut self.tx.clone(), Some(id), msg).await + Self::send_msg(&mut self.tx.clone(), Some(id), msg).await; } pub async fn send_msg(sender: &mut Sender, id: Option, msg: CoreUIMsg) { @@ -814,6 +838,8 @@ impl HarborCore { msg_id: Uuid, amount: Amount, ) -> anyhow::Result<(Bolt11Invoice, OperationId)> { + const DEFAULT_EXPIRY_TIME_SECS: u32 = 86400; + let enable_lnv2 = cfg!(feature = "lnv2"); if !enable_lnv2 { return Err(anyhow::anyhow!("LNv2 is not enabled")); @@ -822,7 +848,6 @@ impl HarborCore { log::info!("Trying to pay receive {amount} with LNv2..."); let lnv2_module = client.get_first_module::()?; - const DEFAULT_EXPIRY_TIME_SECS: u32 = 86400; self.status_update(msg_id, "Generating invoice").await; let receive = lnv2_module .receive( @@ -1659,11 +1684,11 @@ impl HarborCore { } } - pub async fn get_seed_words(&self) -> String { + pub fn get_seed_words(&self) -> String { self.mnemonic.to_string() } - pub async fn set_onchain_receive_enabled(&self, enabled: bool) -> anyhow::Result<()> { + pub fn set_onchain_receive_enabled(&self, enabled: bool) -> anyhow::Result<()> { log::info!("Setting on-chain receive enabled to: {}", enabled); self.storage.set_onchain_receive_enabled(enabled)?; log::info!( @@ -1673,7 +1698,7 @@ impl HarborCore { Ok(()) } - pub async fn set_tor_enabled(&self, enabled: bool) -> anyhow::Result<()> { + pub fn set_tor_enabled(&self, enabled: bool) -> anyhow::Result<()> { log::info!("Setting Tor enabled to: {}", enabled); self.tor_enabled.swap(enabled, Ordering::Relaxed); self.storage.set_tor_enabled(enabled)?; diff --git a/harbor-client/src/lightning_address.rs b/harbor-client/src/lightning_address.rs index 91000abf..c209a617 100644 --- a/harbor-client/src/lightning_address.rs +++ b/harbor-client/src/lightning_address.rs @@ -128,7 +128,7 @@ mod tests { // Test with Tor, but don't fail the whole test if Tor fails log::debug!("Starting Tor test"); match try_with_tor_mode(&ln_address, true).await { - Ok(_) => { + Ok(()) => { log::debug!("Tor test completed successfully"); } Err(e) => { diff --git a/harbor-client/src/metadata.rs b/harbor-client/src/metadata.rs index 3789b131..0e49878d 100644 --- a/harbor-client/src/metadata.rs +++ b/harbor-client/src/metadata.rs @@ -83,7 +83,7 @@ impl FederationMeta { impl From> for FederationMeta { fn from(info: Option) -> Self { - FederationMeta { + Self { federation_name: info.as_ref().and_then(|i| i.name.clone()), federation_expiry_timestamp: None, welcome_message: None, @@ -148,7 +148,7 @@ pub(crate) async fn get_federation_metadata( FederationMeta { meta_external_url, // Already set... federation_name: merge_values( - data.get_meta("federation_name").clone(), + data.get_meta("federation_name"), config.as_ref().and_then(|c| c.federation_name.clone()), ), federation_expiry_timestamp: merge_values( @@ -175,8 +175,7 @@ pub(crate) async fn get_federation_metadata( config.as_ref().and_then(|c| c.popup_end_timestamp.clone()), ), popup_countdown_message: merge_values( - data.get_meta("popup_countdown_message") - .map(|v| v.to_string()), + data.get_meta("popup_countdown_message"), config .as_ref() .and_then(|c| c.popup_countdown_message.clone()), diff --git a/harbor-ui/src/bridge.rs b/harbor-ui/src/bridge.rs index 8b774118..389e535e 100644 --- a/harbor-ui/src/bridge.rs +++ b/harbor-ui/src/bridge.rs @@ -74,13 +74,13 @@ pub fn create_handles() -> (UIHandle, CoreHandle) { (ui_handle, core_handle) } -/// Common setup function for creating a HarborCore instance +/// Common setup function for creating a `HarborCore` instance async fn setup_harbor_core( data_dir: PathBuf, db_path: &str, password: &str, network: Network, - tx: &mut Sender, + tx: &Sender, ) -> Option { // Setup core message channel let (core_tx, mut core_rx) = iced::futures::channel::mpsc::channel::(128); @@ -389,15 +389,7 @@ pub fn run_core() -> impl Stream { // Save password to keyring when successfully unlocked save_to_keyring(&password).await; - match setup_harbor_core( - path.to_path_buf(), - &db_path, - &password, - network, - &mut tx, - ) - .await - { + match setup_harbor_core(path.clone(), &db_path, &password, network, &tx).await { Some(core) => { tx.send(Message::core_msg(id, CoreUIMsg::UnlockSuccess)) .await @@ -469,7 +461,7 @@ pub fn run_core() -> impl Stream { let core = HarborCore::new( network, db.generate_mnemonic(seed).expect("should generate words"), - path.to_path_buf(), + path.clone(), core_tx, Arc::new(RwLock::new(HashMap::new())), Arc::new(RwLock::new(HashMap::new())), @@ -489,7 +481,7 @@ pub fn run_core() -> impl Stream { } _ => { - warn!("Ignoring unrelated message to locked core") + warn!("Ignoring unrelated message to locked core"); } } } @@ -654,7 +646,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { core.msg(msg.id, CoreUIMsg::AddMintFailed(e.to_string())) .await; } - Ok(_) => { + Ok(()) => { if let Ok(new_federation_list) = core.get_mint_items().await { core.msg( msg.id, @@ -679,7 +671,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { core.msg(msg.id, CoreUIMsg::AddMintFailed(e.to_string())) .await; } - Ok(_) => { + Ok(()) => { if let Ok(new_federation_list) = core.get_mint_items().await { core.msg(msg.id, CoreUIMsg::MintListUpdated(new_federation_list)) .await; @@ -713,7 +705,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { ) .await; } - Ok(_) => { + Ok(()) => { log::info!("Removed federation: {id}"); if let Ok(new_federation_list) = core.get_mint_items().await { @@ -737,7 +729,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { ) .await; } - Ok(_) => { + Ok(()) => { log::info!("Removed cashu mint: {url}"); if let Ok(new_federation_list) = core.get_mint_items().await { @@ -764,7 +756,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { core.msg(msg.id, CoreUIMsg::AddMintFailed(e.to_string())) .await; } - Ok(_) => { + Ok(()) => { if let Ok(new_federation_list) = core.get_mint_items().await { core.msg( @@ -786,7 +778,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { core.msg(msg.id, CoreUIMsg::AddMintFailed(e.to_string())) .await; } - Ok(_) => { + Ok(()) => { if let Ok(new_list) = core.get_mint_items().await { core.msg(msg.id, CoreUIMsg::MintListUpdated(new_list)) .await; @@ -804,11 +796,11 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { } } UICoreMsg::GetSeedWords => { - let seed_words = core.get_seed_words().await; + let seed_words = core.get_seed_words(); core.msg(msg.id, CoreUIMsg::SeedWords(seed_words)).await; } UICoreMsg::SetOnchainReceiveEnabled(enabled) => { - match core.set_onchain_receive_enabled(enabled).await { + match core.set_onchain_receive_enabled(enabled) { Err(e) => { error!("error setting onchain receive enabled: {e}"); } @@ -818,16 +810,14 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { } } } - UICoreMsg::SetTorEnabled(enabled) => { - match core.set_tor_enabled(enabled).await { - Err(e) => { - error!("error setting tor enabled: {e}"); - } - _ => { - core.msg(msg.id, CoreUIMsg::TorEnabled(enabled)).await; - } + UICoreMsg::SetTorEnabled(enabled) => match core.set_tor_enabled(enabled) { + Err(e) => { + error!("error setting tor enabled: {e}"); } - } + _ => { + core.msg(msg.id, CoreUIMsg::TorEnabled(enabled)).await; + } + }, UICoreMsg::TestStatusUpdates => { core.test_status_updates(msg.id).await; } diff --git a/harbor-ui/src/components/button.rs b/harbor-ui/src/components/button.rs index 997d0305..117b6aac 100644 --- a/harbor-ui/src/components/button.rs +++ b/harbor-ui/src/components/button.rs @@ -175,7 +175,7 @@ pub fn sidebar_button( pub fn text_link(text_str: String, url: String) -> Element<'static, Message> { let svg = map_icon(SvgIcon::ExternalLink, 16., 16.); let text = rich_text([span(text_str).link(url).underline(true).color(link())]) - .on_link_click(|url: String| Message::UrlClicked(url.to_string())); + .on_link_click(|url: String| Message::UrlClicked(url)); row![svg, text] .align_y(iced::Alignment::Center) diff --git a/harbor-ui/src/components/easing.rs b/harbor-ui/src/components/easing.rs index 6e657c6f..291d7164 100644 --- a/harbor-ui/src/components/easing.rs +++ b/harbor-ui/src/components/easing.rs @@ -8,8 +8,8 @@ use std::sync::LazyLock; pub static EMPHASIZED: LazyLock = LazyLock::new(|| { Easing::builder() - .cubic_bezier_to([0.05, 0.0], [0.133333, 0.06], [0.166666, 0.4]) - .cubic_bezier_to([0.208333, 0.82], [0.25, 1.0], [1.0, 1.0]) + .cubic_bezier_to([0.05, 0.0], [0.133_333, 0.06], [0.166_666, 0.4]) + .cubic_bezier_to([0.208_333, 0.82], [0.25, 1.0], [1.0, 1.0]) .build() }); diff --git a/harbor-ui/src/components/indicator.rs b/harbor-ui/src/components/indicator.rs index ae10cd1f..bdd916a3 100644 --- a/harbor-ui/src/components/indicator.rs +++ b/harbor-ui/src/components/indicator.rs @@ -347,10 +347,8 @@ where Theme: container::Catalog + 'a, Renderer: iced::advanced::text::Renderer + 'a, { - fn from( - indicator: Indicator<'a, Message, Theme, Renderer>, - ) -> Element<'a, Message, Theme, Renderer> { - Element::new(indicator) + fn from(indicator: Indicator<'a, Message, Theme, Renderer>) -> Self { + Self::new(indicator) } } diff --git a/harbor-ui/src/components/input.rs b/harbor-ui/src/components/input.rs index d0fb1407..5124d09c 100644 --- a/harbor-ui/src/components/input.rs +++ b/harbor-ui/src/components/input.rs @@ -114,7 +114,7 @@ pub fn h_input(args: InputArgs<'_>) -> Element { // If the value is already 0, typing 1 turns it into 10 // Which is annoying, so we'll just clear it if num == 0 { - "".to_string() + String::new() } else { num.to_string() } diff --git a/harbor-ui/src/components/mini_copy.rs b/harbor-ui/src/components/mini_copy.rs index 6a7719bd..48984803 100644 --- a/harbor-ui/src/components/mini_copy.rs +++ b/harbor-ui/src/components/mini_copy.rs @@ -14,7 +14,7 @@ pub fn mini_copy(text: String) -> Button<'static, Message, Theme> { let icon = map_icon(SvgIcon::Copy, 24., 24.); Button::new(icon) - .on_press(Message::CopyToClipboard(text.to_string())) + .on_press(Message::CopyToClipboard(text)) .style(|theme: &Theme, status| { let border = Border { color: Color::WHITE, diff --git a/harbor-ui/src/components/sidebar.rs b/harbor-ui/src/components/sidebar.rs index cd53e4ce..3aed4856 100644 --- a/harbor-ui/src/components/sidebar.rs +++ b/harbor-ui/src/components/sidebar.rs @@ -64,10 +64,10 @@ pub fn sidebar(harbor: &HarborWallet) -> Element { Position::Right, harbor.show_add_a_mint_cta ), - if !transfer_disabled { - transfer_button.on_press(Message::Navigate(Route::Transfer)) - } else { + if transfer_disabled { transfer_button + } else { + transfer_button.on_press(Message::Navigate(Route::Transfer)) }, sidebar_button( "History", diff --git a/harbor-ui/src/components/spinner.rs b/harbor-ui/src/components/spinner.rs index e4718f89..668019b3 100644 --- a/harbor-ui/src/components/spinner.rs +++ b/harbor-ui/src/components/spinner.rs @@ -148,7 +148,7 @@ impl Animation { start: now, progress: 0.0, rotation: rotation.wrapping_add(BASE_ROTATION_SPEED.wrapping_add( - (f64::from(WRAP_ANGLE / (2.0 * Radians::PI)) * u32::MAX as f64) as u32, + (f64::from(WRAP_ANGLE / (2.0 * Radians::PI)) * f64::from(u32::MAX)) as u32, )), last: now, }, diff --git a/harbor-ui/src/components/styles.rs b/harbor-ui/src/components/styles.rs index 2181d779..f2457929 100644 --- a/harbor-ui/src/components/styles.rs +++ b/harbor-ui/src/components/styles.rs @@ -89,7 +89,7 @@ pub fn pick_list_style(theme: &Theme, status: pick_list::Status) -> pick_list::S let background = match status { pick_list::Status::Hovered => lighten(theme.palette().background, 0.05), pick_list::Status::Opened { .. } => darken(Color::BLACK, 0.1), - _ => theme.palette().background, + pick_list::Status::Active => theme.palette().background, }; pick_list::Style { diff --git a/harbor-ui/src/components/toast.rs b/harbor-ui/src/components/toast.rs index 855bb5ab..e19ffc44 100644 --- a/harbor-ui/src/components/toast.rs +++ b/harbor-ui/src/components/toast.rs @@ -35,9 +35,9 @@ impl ToastStatus { impl fmt::Display for ToastStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ToastStatus::Neutral => "Neutral", - ToastStatus::Good => "Good", - ToastStatus::Bad => "Bad", + Self::Neutral => "Neutral", + Self::Good => "Good", + Self::Bad => "Bad", } .fmt(f) } diff --git a/harbor-ui/src/components/transaction_details.rs b/harbor-ui/src/components/transaction_details.rs index 82f9e6ef..2dbf3390 100644 --- a/harbor-ui/src/components/transaction_details.rs +++ b/harbor-ui/src/components/transaction_details.rs @@ -64,7 +64,7 @@ pub fn h_transaction_details<'a>( let mint_section = column![ text(mint_label).size(16).style(subtitle), - row![mint_icon, text(mint.name.clone()).size(16)] + row![mint_icon, text(mint.name).size(16)] .align_y(Alignment::Center) .spacing(8) ] @@ -109,7 +109,7 @@ pub fn h_transaction_details<'a>( Network::Signet => "https://mutinynet.com/tx/", _ => panic!("Unsupported network"), }; - let url = format!("{}{}", base_url, txid); + let url = format!("{base_url}{txid}"); details = details.push( column![ text("TXID").size(16).style(subtitle), diff --git a/harbor-ui/src/components/util.rs b/harbor-ui/src/components/util.rs index 35732cfb..60e10f6f 100644 --- a/harbor-ui/src/components/util.rs +++ b/harbor-ui/src/components/util.rs @@ -61,25 +61,16 @@ pub fn format_amount(amount: u64) -> String { } pub fn truncate_text(input: &str, max_len: usize, center: bool) -> String { - match center { + if input.len() <= max_len { + input.to_string() + } else if center { // center the elllipses around middle of the string - true => { - if input.len() > max_len { - format!( - "{}...{}", - &input[..(max_len / 2)], - &input[(input.len() - max_len / 2)..] - ) - } else { - input.to_string() - } - } - false => { - if input.len() > max_len { - format!("{}...", &input[input.len() - max_len..]) - } else { - input.to_string() - } - } + format!( + "{}...{}", + &input[..(max_len / 2)], + &input[(input.len() - max_len / 2)..] + ) + } else { + format!("{}...", &input[input.len() - max_len..]) } } diff --git a/harbor-ui/src/config.rs b/harbor-ui/src/config.rs index d341ea37..f3996060 100644 --- a/harbor-ui/src/config.rs +++ b/harbor-ui/src/config.rs @@ -16,9 +16,9 @@ pub enum ConfigError { impl fmt::Display for ConfigError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ConfigError::InvalidConfig => write!(f, "Config file is invalid"), - ConfigError::IoError(e) => write!(f, "IO error: {}", e), - ConfigError::SerdeError(e) => write!(f, "JSON error: {}", e), + Self::InvalidConfig => write!(f, "Config file is invalid"), + Self::IoError(e) => write!(f, "IO error: {e}"), + Self::SerdeError(e) => write!(f, "JSON error: {e}"), } } } @@ -27,13 +27,13 @@ impl Error for ConfigError {} impl From for ConfigError { fn from(error: io::Error) -> Self { - ConfigError::IoError(error) + Self::IoError(error) } } impl From for ConfigError { fn from(error: serde_json::Error) -> Self { - ConfigError::SerdeError(error) + Self::SerdeError(error) } } diff --git a/harbor-ui/src/keyring.rs b/harbor-ui/src/keyring.rs index 1a775f6f..568ac7e9 100644 --- a/harbor-ui/src/keyring.rs +++ b/harbor-ui/src/keyring.rs @@ -28,7 +28,7 @@ pub async fn save_to_keyring(password: &str) { set_global_service_name(KEYRING_SERVICE); match KeyringEntry::try_new(KEYRING_USERNAME) { Ok(entry) => match entry.set_secret(password).await { - Ok(_) => { + Ok(()) => { info!("Successfully saved password to keyring"); } Err(e) => { diff --git a/harbor-ui/src/lock.rs b/harbor-ui/src/lock.rs index 0dee18eb..3a611e0f 100644 --- a/harbor-ui/src/lock.rs +++ b/harbor-ui/src/lock.rs @@ -13,7 +13,7 @@ impl AppLock { let data_dir = data_dir(None); if !data_dir.exists() { std::fs::create_dir_all(&data_dir) - .map_err(|e| format!("Failed to create data directory: {}", e))?; + .map_err(|e| format!("Failed to create data directory: {e}"))?; } let lock_file_path = data_dir.join("harbor.lock"); @@ -24,7 +24,7 @@ impl AppLock { .create(true) .truncate(true) .open(&lock_file_path) - .map_err(|e| format!("Failed to create/open lock file: {}", e))?; + .map_err(|e| format!("Failed to create/open lock file: {e}"))?; let mut lock = RwLock::new(file); @@ -37,7 +37,7 @@ impl AppLock { std::mem::forget(guard); std::mem::forget(lock); - Ok(AppLock {}) + Ok(Self {}) } } @@ -52,7 +52,7 @@ pub fn restart_app() { let executable = &args[0]; if let Err(e) = Command::new(executable).args(&args[1..]).spawn() { - eprintln!("Failed to relaunch: {}", e); + eprintln!("Failed to relaunch: {e}"); std::process::exit(1); } diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 370a1ab9..0addd90d 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -1,3 +1,31 @@ +#![warn(clippy::nursery, clippy::pedantic)] +#![allow( + clippy::cast_possible_truncation, + clippy::cast_possible_wrap, + clippy::cast_precision_loss, + clippy::cast_sign_loss, + clippy::cognitive_complexity, + clippy::derive_partial_eq_without_eq, + clippy::large_futures, + clippy::manual_let_else, + clippy::match_same_arms, + clippy::missing_const_for_fn, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::must_use_candidate, + clippy::needless_pass_by_value, + clippy::option_if_let_else, + clippy::or_fun_call, + clippy::redundant_closure_for_method_calls, + clippy::redundant_else, + clippy::ref_option, + clippy::return_self_not_must_use, + clippy::single_match_else, + clippy::struct_excessive_bools, + clippy::suboptimal_flops, + clippy::too_many_lines, + clippy::unused_self +)] #![windows_subsystem = "windows"] use crate::bridge::run_core; @@ -47,7 +75,7 @@ pub mod routes; pub fn main() -> iced::Result { // Acquire the app lock - this prevents multiple instances from running if let Err(e) = lock::AppLock::acquire() { - eprintln!("{}", e); + eprintln!("{e}"); std::process::exit(1); } @@ -366,9 +394,9 @@ impl HarborWallet { let id = Uuid::new_v4(); let task = Task::perform( Self::with_ui_handle(self.ui_handle.clone(), move |h| async move { - h.send_msg(id, msg).await + h.send_msg(id, msg).await; }), - |_| Message::Noop, + |()| Message::Noop, ); (id, task) } @@ -484,7 +512,7 @@ impl HarborWallet { if let Some(amt) = msats { self.send_amount_input_str = (amt / 1_000).to_string(); } else { - self.send_amount_input_str = String::from(""); + self.send_amount_input_str = String::new(); } self.send_dest_input_str = input; Task::none() @@ -557,7 +585,7 @@ impl HarborWallet { if self.transfer_to_federation_selection == self.transfer_from_federation_selection { let fed = self.next_federation(&s); - self.transfer_to_federation_selection = Some(fed.name.clone()); + self.transfer_to_federation_selection = Some(fed.name); } Task::none() } @@ -567,7 +595,7 @@ impl HarborWallet { if self.transfer_from_federation_selection == self.transfer_to_federation_selection { let fed = self.next_federation(&s); - self.transfer_from_federation_selection = Some(fed.name.clone()); + self.transfer_from_federation_selection = Some(fed.name); } Task::none() } @@ -589,7 +617,7 @@ impl HarborWallet { Message::Noop => Task::none(), Message::Send(invoice_str) => match self.send_status { SendStatus::Sending => Task::none(), - _ => { + SendStatus::Idle => { self.send_failure_reason = None; let mint = match self.active_mint.clone() { Some(f) => f, @@ -954,7 +982,7 @@ impl HarborWallet { log::info!("Url clicked: {}", url); self.confirm_modal = Some(ConfirmModalState { title: "Open External Link?".to_string(), - description: format!("This will open {} in your default browser.", url), + description: format!("This will open {url} in your default browser."), confirm_action: Box::new(Message::OpenUrl(url)), cancel_action: Box::new(Message::SetConfirmModal(None)), confirm_button_text: "Open Link".to_string(), @@ -1016,14 +1044,14 @@ impl HarborWallet { self.clear_send_state(); } // Toast success - if params != SendSuccessMsg::Transfer { + if params == SendSuccessMsg::Transfer { + Task::none() + } else { Task::done(Message::AddToast(Toast { title: "Payment sent".to_string(), body: None, status: ToastStatus::Good, })) - } else { - Task::none() } } CoreUIMsg::SendFailure(reason) => { @@ -1034,7 +1062,7 @@ impl HarborWallet { } Task::done(Message::AddToast(Toast { title: "Failed to send".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } @@ -1054,16 +1082,15 @@ impl HarborWallet { self.active_route = Route::History; self.clear_transfer_state(); } - if params != ReceiveSuccessMsg::Transfer { - // Toast success + if params == ReceiveSuccessMsg::Transfer { Task::done(Message::AddToast(Toast { - title: "Payment received".to_string(), + title: "Transfer complete".to_string(), body: None, status: ToastStatus::Good, })) } else { Task::done(Message::AddToast(Toast { - title: "Transfer complete".to_string(), + title: "Payment received".to_string(), body: None, status: ToastStatus::Good, })) @@ -1078,7 +1105,7 @@ impl HarborWallet { } Task::done(Message::AddToast(Toast { title: "Failed to receive".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } @@ -1089,7 +1116,7 @@ impl HarborWallet { error!("Transfer failed: {reason}"); Task::done(Message::AddToast(Toast { title: "Failed to transfer".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } @@ -1128,20 +1155,18 @@ impl HarborWallet { Task::none() } CoreUIMsg::AddMintFailed(reason) => { - let reason = reason.clone(); self.clear_add_federation_state(); Task::done(Message::AddToast(Toast { title: "Failed to join mint".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } CoreUIMsg::RemoveFederationFailed(reason) => { - let reason = reason.clone(); self.clear_add_federation_state(); Task::done(Message::AddToast(Toast { title: "Failed to remove mint".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } @@ -1330,12 +1355,8 @@ impl HarborWallet { operation_id, } => { if let Some(id) = operation_id { - self.operation_status.insert( - id, - OperationStatus { - message: message.clone(), - }, - ); + self.operation_status + .insert(id, OperationStatus { message }); } Task::none() } diff --git a/harbor-ui/src/routes/history.rs b/harbor-ui/src/routes/history.rs index 06d5fd23..57344355 100644 --- a/harbor-ui/src/routes/history.rs +++ b/harbor-ui/src/routes/history.rs @@ -17,8 +17,7 @@ pub fn history(harbor: &HarborWallet) -> Element { let is_selected = harbor .selected_transaction .as_ref() - .map(|selected| selected == item) - .unwrap_or(false); + .is_some_and(|selected| selected == item); column .push(h_transaction_item(item, is_selected)) .push(hr()) diff --git a/harbor-ui/src/routes/home.rs b/harbor-ui/src/routes/home.rs index 6d79536c..632868be 100644 --- a/harbor-ui/src/routes/home.rs +++ b/harbor-ui/src/routes/home.rs @@ -18,15 +18,15 @@ pub fn home(harbor: &HarborWallet) -> Element { let receive_button = h_button("Deposit", SvgIcon::DownLeft, false); let buttons = row![ - if !send_disabled { - send_button.on_press(Message::Navigate(Route::Send)) - } else { + if send_disabled { send_button - }, - if !receive_disabled { - receive_button.on_press(Message::Navigate(Route::Receive)) } else { + send_button.on_press(Message::Navigate(Route::Send)) + }, + if receive_disabled { receive_button + } else { + receive_button.on_press(Message::Navigate(Route::Receive)) } ] .spacing(32); diff --git a/harbor-ui/src/routes/restore.rs b/harbor-ui/src/routes/restore.rs index b506975d..98ec399e 100644 --- a/harbor-ui/src/routes/restore.rs +++ b/harbor-ui/src/routes/restore.rs @@ -30,8 +30,7 @@ pub fn restore(harbor: &HarborWallet) -> Element { harbor_logo(), welcome_message, text(format!( - "Failed to initialize wallet. Config error: {}", - error + "Failed to initialize wallet. Config error: {error}" )) .size(24) .color(iced::Color::from_rgb8(250, 0, 80)) @@ -76,7 +75,7 @@ pub fn restore(harbor: &HarborWallet) -> Element { SvgIcon::Restart, harbor.unlock_status == UnlockStatus::Unlocking, ) - .on_press_maybe(action.clone()) + .on_press_maybe(action) .width(Length::Fill); column![ diff --git a/harbor-ui/src/routes/settings.rs b/harbor-ui/src/routes/settings.rs index fea38ef9..e9f30eb0 100644 --- a/harbor-ui/src/routes/settings.rs +++ b/harbor-ui/src/routes/settings.rs @@ -121,8 +121,7 @@ pub fn render_seed_words(seed_words: &str) -> Element<'static, Message> { .iter() .take(6) .enumerate() - .map(|(i, word)| text(format!("{}. {}", i + 1, word)).into()) - .collect::>>(), + .map(|(i, word)| text(format!("{}. {}", i + 1, word)).into()), ) .spacing(10); @@ -133,8 +132,7 @@ pub fn render_seed_words(seed_words: &str) -> Element<'static, Message> { .skip(6) .take(6) .enumerate() - .map(|(i, word)| text(format!("{}. {}", i + 7, word)).into()) - .collect::>>(), + .map(|(i, word)| text(format!("{}. {}", i + 7, word)).into()), ) .spacing(10); diff --git a/harbor-ui/src/routes/unlock.rs b/harbor-ui/src/routes/unlock.rs index 0b9a7441..0a4ffcb2 100644 --- a/harbor-ui/src/routes/unlock.rs +++ b/harbor-ui/src/routes/unlock.rs @@ -42,13 +42,13 @@ pub fn unlock(harbor: &HarborWallet) -> Element { .width(Length::Fixed(256.)); let page_column = page_column.push_maybe(harbor.unlock_failure_reason.as_ref().map(|r| { - text(format!("Error: {:?}", r)) + text(format!("Error: {r:?}")) .size(24) .color(Color::from_rgb8(250, 0, 80)) })); let page_column = page_column.push_maybe(harbor.init_failure_reason.as_ref().map(|r| { - text(format!("Init Error: {:?}", r)) + text(format!("Init Error: {r:?}")) .size(24) .color(Color::from_rgb8(250, 0, 80)) })); diff --git a/harbor-ui/src/routes/welcome.rs b/harbor-ui/src/routes/welcome.rs index 77374bce..35eb808b 100644 --- a/harbor-ui/src/routes/welcome.rs +++ b/harbor-ui/src/routes/welcome.rs @@ -30,8 +30,7 @@ pub fn welcome(harbor: &HarborWallet) -> Element { harbor_logo(), welcome_message, text(format!( - "Failed to initialize wallet. Config error: {}", - error + "Failed to initialize wallet. Config error: {error}" )) .size(24) .color(iced::Color::from_rgb8(250, 0, 80)) @@ -69,7 +68,7 @@ pub fn welcome(harbor: &HarborWallet) -> Element { label: "Password", value: &harbor.password_input_str, on_input: Message::PasswordInputChanged, - on_submit: action.clone(), + on_submit: action, disabled: harbor.unlock_status == UnlockStatus::Unlocking, secure: true, id: Some("password_init_input"),