diff --git a/src/components/ConnectWalletDialog.tsx b/src/components/ConnectWalletDialog.tsx index f028e1d..9301d64 100644 --- a/src/components/ConnectWalletDialog.tsx +++ b/src/components/ConnectWalletDialog.tsx @@ -59,19 +59,29 @@ export default function ConnectWalletDialog({ // This waits for the wallet to be ready (support$ must emit) const wallet = await createWalletFromURI(connectionString); - // Get wallet info (wallet is already ready at this point) - const info = await wallet.getInfo(); + // Get support info from the already-emitted support$ (no network request needed) + const support = await wallet.getSupport(); - // Get initial balance + // Try to get extended info (alias, network) but don't fail if it times out + let alias: string | undefined; + let network: string | undefined; + try { + const info = await wallet.getInfo(); + alias = info.alias; + network = info.network; + } catch (err) { + console.warn("[NWC] Failed to get extended wallet info:", err); + // Continue without alias/network - they're optional + } + + // Get initial balance (also optional) let balance: number | undefined; try { const balanceResult = await wallet.getBalance(); balance = balanceResult.balance; - // Update the observable immediately so WalletViewer shows correct balance balance$.next(balance); } catch (err) { console.warn("[NWC] Failed to get balance:", err); - // Balance is optional, continue anyway } // Get connection details from the wallet instance @@ -85,10 +95,10 @@ export default function ConnectWalletDialog({ lud16: serialized.lud16, balance, info: { - alias: info.alias, - network: info.network, - methods: info.methods, - notifications: info.notifications, + alias, + network, + methods: support?.methods ?? [], + notifications: support?.notifications, }, }); @@ -99,10 +109,10 @@ export default function ConnectWalletDialog({ // Update info updateNWCInfo({ - alias: info.alias, - network: info.network, - methods: info.methods, - notifications: info.notifications, + alias, + network, + methods: support?.methods ?? [], + notifications: support?.notifications, }); // Show success toast diff --git a/src/components/ZapWindow.tsx b/src/components/ZapWindow.tsx index 380f12b..8cda816 100644 --- a/src/components/ZapWindow.tsx +++ b/src/components/ZapWindow.tsx @@ -11,7 +11,7 @@ * - Shows feed render of zapped event */ -import { useState, useMemo, useEffect, useRef } from "react"; +import { useState, useMemo, useRef } from "react"; import { toast } from "sonner"; import { Zap, @@ -118,17 +118,7 @@ export function ZapWindow({ const activeAccount = accountManager.active; const canSign = !!activeAccount?.signer; - const { wallet, payInvoice, refreshBalance, getInfo } = useWallet(); - - // Fetch wallet info - const [walletInfo, setWalletInfo] = useState(null); - useEffect(() => { - if (wallet) { - getInfo() - .then((info) => setWalletInfo(info)) - .catch((error) => console.error("Failed to get wallet info:", error)); - } - }, [wallet, getInfo]); + const { wallet, walletMethods, payInvoice, refreshBalance } = useWallet(); // Cache LNURL data for recipient's Lightning address const { data: lnurlData } = useLnurlCache(recipientProfile?.lud16); @@ -400,7 +390,7 @@ export function ZapWindow({ setInvoice(invoiceText); // Step 5: Pay or show QR code - if (useWallet && wallet && walletInfo?.methods.includes("pay_invoice")) { + if (useWallet && wallet && walletMethods.includes("pay_invoice")) { // Pay with NWC wallet with timeout setIsPayingWithWallet(true); try { @@ -568,7 +558,7 @@ export function ZapWindow({ {/* Retry with wallet button if payment failed/timed out */} {paymentTimedOut && wallet && - walletInfo?.methods.includes("pay_invoice") && ( + walletMethods.includes("pay_invoice") && (