diff --git a/package.json b/package.json index 9627265..7b9c2c8 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "bech32": "^2.0.0", "core-js": "^3.6.5", "date-fns": "^3.6.0", + "dexie": "^4.0.4", "light-bolt11-decoder": "^3.1.1", "nostr-tools": "^2.5.2", "pinia": "^2.0.35", diff --git a/src/stores/mints.ts b/src/stores/mints.ts index de885b3..7a7250a 100644 --- a/src/stores/mints.ts +++ b/src/stores/mints.ts @@ -3,6 +3,9 @@ import { useLocalStorage } from "@vueuse/core"; import { useWorkersStore } from "./workers"; import { notifyApiError, notifyError, notifySuccess } from "src/js/notify"; import { CashuMint, MintKeys, MintAllKeysets, Proof, SerializedBlindedSignature, MintKeyset } from "@cashu/cashu-ts"; +import { useDexieStore } from "src/stores/dexie" + +const dexieStore = useDexieStore(); export type Mint = { url: string; @@ -155,6 +158,12 @@ export const useMintsStore = defineStore("mints", { addProofs(proofs: Proof[]) { const walletProofs = this.proofsToWalletProofs(proofs); this.proofs = this.proofs.concat(walletProofs); + + const proofsTable = dexieStore.db.proofs; + walletProofs.forEach((p) => { + proofsTable.put(p); + } + ); }, removeProofs(proofs: Proof[]) { const walletProofs = this.proofsToWalletProofs(proofs); @@ -165,16 +174,14 @@ export const useMintsStore = defineStore("mints", { }); }); this.spentProofs = this.spentProofs.concat(walletProofs); - }, - appendBlindSignatures(signature: SerializedBlindedSignature, amount: number, secret: Uint8Array, r: Uint8Array) { - const audit: BlindSignatureAudit = { - signature: signature, - amount: amount, - secret: secret, - id: signature.id, - r: Buffer.from(r).toString("hex"), - }; - this.blindSignatures.push(audit); + + // dexie + const proofsTable = dexieStore.db.proofs; + const spentProofsTable = dexieStore.db.spentProofs; + walletProofs.forEach((p) => { + proofsTable.delete(p.secret); + spentProofsTable.put(p); + }); }, toggleActiveUnitForMint(mint: Mint) { // method to set the active unit to one that is supported by `mint`