From 2f8abbb93e5263832032d5e93844f5adc9242bcd Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Thu, 22 Feb 2024 11:20:19 +0000 Subject: [PATCH] fix: clippy --- mutiny-core/src/federation.rs | 15 +++++++-------- mutiny-core/src/lib.rs | 29 ++++++++++++++++++++--------- mutiny-wasm/src/lib.rs | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/mutiny-core/src/federation.rs b/mutiny-core/src/federation.rs index 87d7c0e45..0ba42b4dd 100644 --- a/mutiny-core/src/federation.rs +++ b/mutiny-core/src/federation.rs @@ -603,25 +603,24 @@ impl FederationClient { } } - pub(crate) async fn reissue(&self, oob_notes: OOBNotes) -> Result { + pub(crate) async fn reissue(&self, oob_notes: OOBNotes) -> Result<(), MutinyError> { let logger = Arc::clone(&self.logger); // Get the `MintClientModule` let mint_module = self.fedimint_client.get_first_module::(); - // TODO: (@leonardo) Do we need any `extra_meta` ? // Reissue `OOBNotes` let operation_id = mint_module.reissue_external_notes(oob_notes, ()).await?; // TODO: (@leonardo) re-think about the results and errors that we need/want match process_reissue_outcome(&mint_module, operation_id, logger.clone()).await? { ReissueExternalNotesState::Created | ReissueExternalNotesState::Failed(_) => { - log_info!(logger, "re-issuance of OOBNotes failed!"); + log_trace!(logger, "re-issuance of OOBNotes failed!"); Err(MutinyError::FedimintReissueFailed) } _ => { - log_info!(logger, "re-issuance of OOBNotes was successful!"); - Ok(true) + log_trace!(logger, "re-issuance of OOBNotes was successful!"); + Ok(()) } } } @@ -892,12 +891,12 @@ async fn process_reissue_outcome( let stream_or_outcome = mint_module .subscribe_reissue_external_notes(operation_id) .await - .map_err(|e| MutinyError::Other(e))?; + .map_err(MutinyError::Other)?; match stream_or_outcome { UpdateStreamOrOutcome::Outcome(outcome) => { log_trace!(logger, "outcome received {:?}", outcome); - return Ok(outcome); + Ok(outcome) } UpdateStreamOrOutcome::UpdateStream(mut stream) => { let timeout = DEFAULT_REISSUE_TIMEOUT * 1_000; @@ -925,7 +924,7 @@ async fn process_reissue_outcome( } }; } - return Err(MutinyError::FedimintReissueFailed); + Err(MutinyError::FedimintReissueFailed) } } } diff --git a/mutiny-core/src/lib.rs b/mutiny-core/src/lib.rs index 7b9ce2221..5328af500 100644 --- a/mutiny-core/src/lib.rs +++ b/mutiny-core/src/lib.rs @@ -112,7 +112,7 @@ use crate::utils::parse_profile_metadata; use mockall::{automock, predicate::*}; const DEFAULT_PAYMENT_TIMEOUT: u64 = 30; -const DEFAULT_REISSUE_TIMEOUT: u64 = 60; +const DEFAULT_REISSUE_TIMEOUT: u64 = 5; const MAX_FEDERATION_INVOICE_AMT: u64 = 200_000; const SWAP_LABEL: &str = "SWAP"; @@ -1353,7 +1353,7 @@ impl MutinyWallet { }) } - pub async fn reissue_oob_notes(&self, oob_notes: OOBNotes) -> Result { + pub async fn reissue_oob_notes(&self, oob_notes: OOBNotes) -> Result<(), MutinyError> { let federation_lock = self.federations.read().await; let federation_ids = self.list_federation_ids().await?; @@ -1362,14 +1362,25 @@ impl MutinyWallet { .find(|id| id.to_prefix() == oob_notes.federation_id_prefix()); if let Some(fed_id) = maybe_federation_id { - log_info!(self.logger, "found federation_id {:?}", fed_id); - let fedimint_client = federation_lock.get(&fed_id).ok_or(MutinyError::NotFound)?; - log_info!(self.logger, "got fedimint client for federation_id {:?}", fed_id); - let reissue = fedimint_client.reissue(oob_notes).await?; - log_info!(self.logger, "successfully reissued for federation_id {:?}", fed_id); - Ok(reissue) + log_trace!(self.logger, "found federation_id {:?}", fed_id); + + let fedimint_client = federation_lock.get(fed_id).ok_or(MutinyError::NotFound)?; + log_trace!( + self.logger, + "got fedimint client for federation_id {:?}", + fed_id + ); + + fedimint_client.reissue(oob_notes).await?; + log_trace!( + self.logger, + "successfully reissued for federation_id {:?}", + fed_id + ); + + Ok(()) } else { - return Err(MutinyError::NotFound); + Err(MutinyError::NotFound) } } diff --git a/mutiny-wasm/src/lib.rs b/mutiny-wasm/src/lib.rs index 9f3bb7a86..d90fd940e 100644 --- a/mutiny-wasm/src/lib.rs +++ b/mutiny-wasm/src/lib.rs @@ -1022,7 +1022,7 @@ impl MutinyWallet { Ok(self.inner.sweep_federation_balance(amount).await?.into()) } - pub async fn reissue_oob_notes(&self, oob_notes: String) -> Result { + pub async fn reissue_oob_notes(&self, oob_notes: String) -> Result<(), MutinyJsError> { let notes = OOBNotes::from_str(&oob_notes).map_err(|e| { log_error!( self.inner.logger,