Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
oleonardolima committed Feb 22, 2024
1 parent 3d234f2 commit 2f8abbb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
15 changes: 7 additions & 8 deletions mutiny-core/src/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,25 +603,24 @@ impl<S: MutinyStorage> FederationClient<S> {
}
}

pub(crate) async fn reissue(&self, oob_notes: OOBNotes) -> Result<bool, MutinyError> {
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::<MintClientModule>();

// 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(())
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -925,7 +924,7 @@ async fn process_reissue_outcome(
}
};
}
return Err(MutinyError::FedimintReissueFailed);
Err(MutinyError::FedimintReissueFailed)
}
}
}
Expand Down
29 changes: 20 additions & 9 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -1353,7 +1353,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
})
}

pub async fn reissue_oob_notes(&self, oob_notes: OOBNotes) -> Result<bool, MutinyError> {
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?;

Expand All @@ -1362,14 +1362,25 @@ impl<S: MutinyStorage> MutinyWallet<S> {
.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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion mutiny-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool, MutinyJsError> {
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,
Expand Down

0 comments on commit 2f8abbb

Please sign in to comment.