Skip to content

Commit b2ef838

Browse files
committed
cleaning up some logs
1 parent 366cbe5 commit b2ef838

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

ndk-mobile/src/hooks/subscribe.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,14 @@ export const useSubscribe = <T extends NDKEvent>({ filters, opts = undefined, re
186186
}, [ndk, relays]);
187187

188188
useEffect(() => {
189-
console.log('mute list changed', muteList);
190-
191189
// go through the events and remove any that are from muted pubkeys
192190
storeInstance.events.forEach((event) => {
193191
if (muteList.has(event.pubkey)) {
194192
storeInstance.removeEventId(event.id);
195193
}
196194
});
197195

198-
}, [ muteList ])
196+
}, [ muteList.size ])
199197

200198
const handleEvent = useCallback(
201199
(event: NDKEvent) => {

ndk-wallet/src/wallets/nwc/index.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { NutPayment } from "../cashu/pay/nut.js";
55
import { sendReq } from "./req.js";
66
import createDebug from "debug";
77
import { NDKNWCGetInfoResult, NDKNWCRequestMap, NDKNWCResponseBase, NDKNWCResponseMap } from "./types.js";
8-
import { CashuMint, CashuWallet } from "@cashu/cashu-ts";
8+
import { CashuMint, CashuWallet, MintQuoteResponse } from "@cashu/cashu-ts";
99

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

@@ -104,15 +104,28 @@ export class NDKNWCWallet extends EventEmitter<NDKWalletEvents> implements NDKWa
104104
}
105105

106106
const wallet = new CashuWallet(new CashuMint(mint), { unit });
107+
let quote: MintQuoteResponse | undefined;
107108
try {
108-
const quote = await wallet.createMintQuote(amount);
109+
quote = await wallet.createMintQuote(amount);
109110
d('cashuPay quote', quote);
111+
} catch (e) {
112+
console.error('error creating mint quote', e);
113+
throw e;
114+
}
110115

116+
if (!quote) throw new Error("Didnt receive a mint quote");
117+
118+
try {
111119
const res = await this.req("pay_invoice", { invoice: quote.request });
112120
d('cashuPay res', res);
121+
} catch (e) {
122+
console.error('error paying invoice', e);
123+
throw e;
124+
}
113125

114-
// todo check that the amount of the invoice matches the amount we want to pay
126+
// todo check that the amount of the invoice matches the amount we want to pay
115127

128+
try {
116129
// mint the tokens
117130
const mintProofs = await wallet.mintProofs(amount, quote.quote, {
118131
pubkey: payment.p2pk
@@ -124,7 +137,8 @@ export class NDKNWCWallet extends EventEmitter<NDKWalletEvents> implements NDKWa
124137
mint: mint
125138
};
126139
} catch (e) {
127-
console.error('error creating mint quote', e);
140+
console.error('error minting tokens', e);
141+
throw e;
128142
}
129143
}
130144
}

0 commit comments

Comments
 (0)