Skip to content

Commit

Permalink
Merge branch 'dexie-storage' into npubcash-address
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Aug 11, 2024
2 parents 832e13f + 8387df9 commit 91ad28d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 17 additions & 10 deletions src/stores/mints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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`
Expand Down

0 comments on commit 91ad28d

Please sign in to comment.