From aee2abd285ea60c57a886849fc8e0820643637ec Mon Sep 17 00:00:00 2001 From: pablof7z Date: Fri, 22 Nov 2024 23:43:52 +0000 Subject: [PATCH] wip --- ndk-wallet/package.json | 2 +- ndk-wallet/src/cashu/decrypt.ts | 2 -- ndk-wallet/src/cashu/deposit.ts | 8 ++++---- ndk-wallet/src/cashu/pay/nut.ts | 3 +-- ndk-wallet/src/service/index.ts | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ndk-wallet/package.json b/ndk-wallet/package.json index 4bc6a340..27b5af59 100644 --- a/ndk-wallet/package.json +++ b/ndk-wallet/package.json @@ -38,7 +38,7 @@ }, "homepage": "https://github.com/nostr-dev-kit/ndk", "dependencies": { - "@cashu/cashu-ts": "2.0.0-rc1", + "@cashu/cashu-ts": "2.0.0-rc4", "@getalby/sdk": "^3.6.1", "@nostr-dev-kit/ndk": "workspace:*", "debug": "^4.3.4", diff --git a/ndk-wallet/src/cashu/decrypt.ts b/ndk-wallet/src/cashu/decrypt.ts index 85b61f22..0688e471 100644 --- a/ndk-wallet/src/cashu/decrypt.ts +++ b/ndk-wallet/src/cashu/decrypt.ts @@ -7,8 +7,6 @@ const debug = createDebug("ndk-wallet:cashu:decrypt"); * Decrypts an NDKEvent using nip44, and if that fails, using nip04. */ export async function decrypt(event: NDKEvent) { - console.log("decrypting with the nip44/nip04 implementation"); - try { await event.decrypt(undefined, undefined, "nip44"); return; diff --git a/ndk-wallet/src/cashu/deposit.ts b/ndk-wallet/src/cashu/deposit.ts index 6d0759da..a70bef21 100644 --- a/ndk-wallet/src/cashu/deposit.ts +++ b/ndk-wallet/src/cashu/deposit.ts @@ -116,13 +116,13 @@ export class NDKCashuDeposit extends EventEmitter<{ async finalize() { if (!this.quoteId) throw new Error("No quoteId set."); - let ret: { proofs: Array }; + let proofs: Array; try { d("Checking for minting status of %s", this.quoteId); this._wallet ??= await this.wallet.walletForMint(this.mint); - ret = await this._wallet.mintProofs(this.amount, this.quoteId); - if (!ret?.proofs) return; + proofs = await this._wallet.mintProofs(this.amount, this.quoteId); + if (proofs.length === 0) return; } catch (e: any) { if (e.message.match(/not paid/i)) return; d(e.message); @@ -133,7 +133,7 @@ export class NDKCashuDeposit extends EventEmitter<{ this.finalized = true; const tokenEvent = new NDKCashuToken(this.wallet.ndk); - tokenEvent.proofs = ret.proofs; + tokenEvent.proofs = proofs; tokenEvent.mint = this.mint; tokenEvent.wallet = this.wallet; diff --git a/ndk-wallet/src/cashu/pay/nut.ts b/ndk-wallet/src/cashu/pay/nut.ts index f8f076ef..b6f9d0d4 100644 --- a/ndk-wallet/src/cashu/pay/nut.ts +++ b/ndk-wallet/src/cashu/pay/nut.ts @@ -1,5 +1,4 @@ import type { Proof } from "@cashu/cashu-ts"; -import { CashuMint, CashuWallet } from "@cashu/cashu-ts"; import type { MintUrl } from "../mint/utils"; import type { NDKCashuPay } from "../pay"; import { chooseProofsForAmount, chooseProofsForAmounts, rollOverProofs } from "../proofs"; @@ -79,7 +78,7 @@ async function payNutWithMintTransfer( const wallet = await pay.wallet.walletForMint(mint); - const { proofs } = await wallet.mintProofs(amount, quote.quote, { + const proofs = await wallet.mintProofs(amount, quote.quote, { pubkey: p2pk, }); diff --git a/ndk-wallet/src/service/index.ts b/ndk-wallet/src/service/index.ts index 4d7292e5..a69cbe59 100644 --- a/ndk-wallet/src/service/index.ts +++ b/ndk-wallet/src/service/index.ts @@ -94,7 +94,7 @@ class NDKWalletService extends EventEmitter<{ /** * Starts monitoring changes for the user's wallets */ - public start({ user, walletEvent }: { user?: NDKUser; walletEvent?: NDKEvent }) { + public start({ user, walletEvent }: { user?: NDKUser; walletEvent?: NDKEvent } = {}) { // todo: check NIP-78 configuration for webln/nwc/nip-61 settings this.lifecycle = new NDKWalletLifecycle(this.ndk, user ?? this.ndk.activeUser!); this.lifecycle.on("mintlist:ready", (mintList: NDKCashuMintList) => {