Skip to content

Commit

Permalink
cleaning up some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pablof7z committed Jan 3, 2025
1 parent 366cbe5 commit b2ef838
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 1 addition & 3 deletions ndk-mobile/src/hooks/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,14 @@ export const useSubscribe = <T extends NDKEvent>({ filters, opts = undefined, re
}, [ndk, relays]);

useEffect(() => {
console.log('mute list changed', muteList);

// go through the events and remove any that are from muted pubkeys
storeInstance.events.forEach((event) => {
if (muteList.has(event.pubkey)) {
storeInstance.removeEventId(event.id);
}
});

}, [ muteList ])
}, [ muteList.size ])

const handleEvent = useCallback(
(event: NDKEvent) => {
Expand Down
22 changes: 18 additions & 4 deletions ndk-wallet/src/wallets/nwc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NutPayment } from "../cashu/pay/nut.js";
import { sendReq } from "./req.js";
import createDebug from "debug";
import { NDKNWCGetInfoResult, NDKNWCRequestMap, NDKNWCResponseBase, NDKNWCResponseMap } from "./types.js";
import { CashuMint, CashuWallet } from "@cashu/cashu-ts";
import { CashuMint, CashuWallet, MintQuoteResponse } from "@cashu/cashu-ts";

const d = createDebug("ndk-wallet:nwc");

Expand Down Expand Up @@ -104,15 +104,28 @@ export class NDKNWCWallet extends EventEmitter<NDKWalletEvents> implements NDKWa
}

const wallet = new CashuWallet(new CashuMint(mint), { unit });
let quote: MintQuoteResponse | undefined;
try {
const quote = await wallet.createMintQuote(amount);
quote = await wallet.createMintQuote(amount);
d('cashuPay quote', quote);
} catch (e) {
console.error('error creating mint quote', e);
throw e;
}

if (!quote) throw new Error("Didnt receive a mint quote");

try {
const res = await this.req("pay_invoice", { invoice: quote.request });
d('cashuPay res', res);
} catch (e) {
console.error('error paying invoice', e);
throw e;
}

// todo check that the amount of the invoice matches the amount we want to pay
// todo check that the amount of the invoice matches the amount we want to pay

try {
// mint the tokens
const mintProofs = await wallet.mintProofs(amount, quote.quote, {
pubkey: payment.p2pk
Expand All @@ -124,7 +137,8 @@ export class NDKNWCWallet extends EventEmitter<NDKWalletEvents> implements NDKWa
mint: mint
};
} catch (e) {
console.error('error creating mint quote', e);
console.error('error minting tokens', e);
throw e;
}
}
}
Expand Down

0 comments on commit b2ef838

Please sign in to comment.