Skip to content

Commit

Permalink
fix: spent error
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Mar 5, 2025
1 parent 9b76f28 commit d035429
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions crates/cdk/src/mint/check_spendable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashSet;
use tracing::instrument;

use super::{CheckStateRequest, CheckStateResponse, Mint, ProofState, PublicKey, State};
use crate::Error;
use crate::{cdk_database, Error};

impl Mint {
/// Check state
Expand Down Expand Up @@ -41,10 +41,15 @@ impl Mint {
ys: &[PublicKey],
proof_state: State,
) -> Result<(), Error> {
let original_proofs_state = self
.localstore
.update_proofs_states(ys, proof_state)
.await?;
let original_proofs_state =
match self.localstore.update_proofs_states(ys, proof_state).await {
Ok(states) => states,
Err(cdk_database::Error::AttemptUpdateSpentProof)
| Err(cdk_database::Error::AttemptRemoveSpentProof) => {
return Err(Error::TokenAlreadySpent)
}
Err(err) => return Err(err.into()),
};

let proofs_state = original_proofs_state
.iter()
Expand Down

0 comments on commit d035429

Please sign in to comment.