From b1dda4f615f03726a54c0c5262444864dfcb2411 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Thu, 9 May 2024 20:52:06 +0200 Subject: [PATCH 1/2] detect if another tab is already running --- src/pages/AlreadyRunning.vue | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/pages/AlreadyRunning.vue diff --git a/src/pages/AlreadyRunning.vue b/src/pages/AlreadyRunning.vue new file mode 100644 index 00000000..6e76801f --- /dev/null +++ b/src/pages/AlreadyRunning.vue @@ -0,0 +1,29 @@ + + + From f556af4977c00a89b21de28cbe62fef15265368f Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Fri, 10 May 2024 00:06:37 +0200 Subject: [PATCH 2/2] wip: add diexie --- package.json | 1 + src/stores/mints.ts | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index f769bb41..91720b3d 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 b4940f2c..f37412c1 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; @@ -148,6 +151,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); @@ -158,16 +167,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`