diff --git a/src/App.tsx b/src/App.tsx index a5af3b43..8a9f9343 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -28,6 +28,7 @@ import { DynamicFavicon } from '@/components/DynamicFavicon'; import { OfflineIndicator } from '@/components/OfflineIndicator'; import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt'; import { ErrorBoundary } from '@/components/ErrorBoundary'; +import { NWCProvider } from '@/contexts/NWCContext'; import AppRouter from './AppRouter'; @@ -142,6 +143,7 @@ export function App() { + @@ -161,6 +163,7 @@ export function App() { + diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index 04d2723d..7818c4da 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -11,6 +11,7 @@ import NostrSettings from "./pages/NostrSettings"; import AISettings from "./pages/AISettings"; import GitSettings from "./pages/GitSettings"; import DeploySettings from "./pages/DeploySettings"; +import WalletSettings from "./pages/WalletSettings"; import SystemSettings from "./pages/SystemSettings"; import StorageSettings from "./pages/StorageSettings"; import AboutSettings from "./pages/AboutSettings"; @@ -48,6 +49,7 @@ export function AppRouter() { } /> } /> } /> + } /> } /> } /> } /> diff --git a/src/components/RepositoryCard.tsx b/src/components/RepositoryCard.tsx index e5c1ab18..2eb5b895 100644 --- a/src/components/RepositoryCard.tsx +++ b/src/components/RepositoryCard.tsx @@ -31,6 +31,9 @@ import { detectFork } from '@/lib/detectFork'; import { NostrRepoEditDialog } from '@/components/NostrRepoEditDialog'; import { useQueryClient } from '@tanstack/react-query'; import { useOGImage } from '@/hooks/useOGImage'; +import { ZapDialog } from '@/components/ZapDialog'; +import { Zap } from 'lucide-react'; +import type { Event } from 'nostr-tools'; interface RepositoryCardProps { repo: Repository; @@ -53,6 +56,8 @@ export function RepositoryCard({ repo }: RepositoryCardProps) { const displayName = authorData?.metadata?.name || genUserName(repo.pubkey); const profileImage = authorData?.metadata?.picture; const isOwnRepo = user?.pubkey === repo.pubkey; + const hasLightning = !!(authorData?.metadata?.lud16 || authorData?.metadata?.lud06); + const canZap = user && !isOwnRepo && hasLightning; // Get OG metadata from first web URL const firstWebUrl = repo.webUrls?.[0]; @@ -158,12 +163,20 @@ export function RepositoryCard({ repo }: RepositoryCardProps) { {repo.name} - - - - +
+ {canZap && ( + + + + )} + + + + {firstWebUrl && ( @@ -187,7 +200,8 @@ export function RepositoryCard({ repo }: RepositoryCardProps) { )} - + +
{/* Author */} diff --git a/src/lib/settingsItems.ts b/src/lib/settingsItems.ts index daadc24d..f20474a6 100644 --- a/src/lib/settingsItems.ts +++ b/src/lib/settingsItems.ts @@ -1,4 +1,4 @@ -import { Bot, GitBranch, Database, Wifi, Settings2, Info, Settings, Rocket } from 'lucide-react'; +import { Bot, GitBranch, Database, Wifi, Settings2, Info, Settings, Rocket, Wallet } from 'lucide-react'; export interface SettingsItem { id: string; @@ -59,6 +59,12 @@ export const getSettingsCategories = (t: (key: string) => string): SettingsCateg title: t('nostrSettings'), href: '/settings/nostr', }, + { + id: 'wallet', + icon: Wallet, + title: t('walletSettings'), + href: '/settings/wallet', + }, ], }, { diff --git a/src/locales/en.json b/src/locales/en.json index 31ae3827..beff6153 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -106,6 +106,33 @@ "deploySettingsDescription": "Configure deployment providers", "nostrSettings": "Nostr", "nostrSettingsDescription": "Configure relay connections and Nostr preferences", + "walletSettings": "Wallet", + "walletSettingsDescription": "Connect Lightning wallets for zaps", + "currentStatus": "Current Status", + "browserExtension": "Browser extension", + "ready": "Ready", + "notFound": "Not Found", + "nostrWalletConnect": "Nostr Wallet Connect", + "walletsConnected": "{{count}} wallet(s) connected", + "remoteWalletConnection": "Remote wallet connection", + "none": "None", + "noWalletsConnected": "No wallets connected", + "addNwcWalletToGetStarted": "Add an NWC wallet to get started", + "lightningWallet": "Lightning Wallet", + "nwcConnection": "NWC Connection", + "setAsActive": "Set as active", + "activeWalletChanged": "Active wallet changed", + "selectedWalletNowActive": "The selected wallet is now active for zaps.", + "installWeblnOrConnectNwc": "Install a WebLN extension or connect an NWC wallet to send zaps.", + "connectNwcWallet": "Connect NWC Wallet", + "enterConnectionStringFromWallet": "Enter your connection string from a compatible wallet.", + "walletNameOptional": "Wallet Name (optional)", + "myLightningWallet": "My Lightning Wallet", + "connectionUri": "Connection URI", + "connecting": "Connecting...", + "connect": "Connect", + "connectionUriRequired": "Connection URI required", + "pleaseEnterValidNwcUri": "Please enter a valid NWC connection URI.", "storageSettings": "Storage", "storageSettingsDescription": "Export files and manage local data", "emailUpdates": "Email Updates", diff --git a/src/pages/WalletSettings.tsx b/src/pages/WalletSettings.tsx new file mode 100644 index 00000000..361c18ff --- /dev/null +++ b/src/pages/WalletSettings.tsx @@ -0,0 +1,254 @@ +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Wallet, Plus, Trash2, Zap, Globe, WalletMinimal, CheckCircle } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; +import { Textarea } from '@/components/ui/textarea'; +import { Badge } from '@/components/ui/badge'; +import { Separator } from '@/components/ui/separator'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog'; +import { useNWC } from '@/hooks/useNWCContext'; +import { useWallet } from '@/hooks/useWallet'; +import { useToast } from '@/hooks/useToast'; +import { SettingsPageLayout } from '@/components/SettingsPageLayout'; + +export function WalletSettings() { + const { t } = useTranslation(); + const [addDialogOpen, setAddDialogOpen] = useState(false); + const [connectionUri, setConnectionUri] = useState(''); + const [alias, setAlias] = useState(''); + const [isConnecting, setIsConnecting] = useState(false); + const { toast } = useToast(); + + const { + connections, + activeConnection, + connectionInfo, + addConnection, + removeConnection, + setActiveConnection + } = useNWC(); + + const { webln } = useWallet(); + + const hasNWC = connections.length > 0 && connections.some(c => c.isConnected); + + const handleAddConnection = async () => { + if (!connectionUri.trim()) { + toast({ + title: t('connectionUriRequired'), + description: t('pleaseEnterValidNwcUri'), + variant: 'destructive', + }); + return; + } + + setIsConnecting(true); + try { + const success = await addConnection(connectionUri.trim(), alias.trim() || undefined); + if (success) { + setConnectionUri(''); + setAlias(''); + setAddDialogOpen(false); + } + } finally { + setIsConnecting(false); + } + }; + + const handleRemoveConnection = (connectionString: string) => { + removeConnection(connectionString); + }; + + const handleSetActive = (connectionString: string) => { + setActiveConnection(connectionString); + toast({ + title: t('activeWalletChanged'), + description: t('selectedWalletNowActive'), + }); + }; + + return ( + + {/* Current Status */} +
+

{t('currentStatus')}

+
+ {/* WebLN */} +
+
+ +
+

WebLN

+

{t('browserExtension')}

+
+
+
+ {webln && } + + {webln ? t('ready') : t('notFound')} + +
+
+ {/* NWC */} +
+
+ +
+

{t('nostrWalletConnect')}

+

+ {connections.length > 0 + ? t('walletsConnected', { count: connections.length }) + : t('remoteWalletConnection') + } +

+
+
+
+ {hasNWC && } + + {hasNWC ? t('ready') : t('none')} + +
+
+
+
+ + + + {/* NWC Management */} +
+
+

{t('nostrWalletConnect')}

+ +
+ + {/* Connected Wallets List */} + {connections.length === 0 ? ( +
+ +

{t('noWalletsConnected')}

+

{t('addNwcWalletToGetStarted')}

+
+ ) : ( +
+ {connections.map((connection) => { + const info = connectionInfo[connection.connectionString]; + const isActive = activeConnection === connection.connectionString; + return ( +
+
+ +
+

+ {connection.alias || info?.alias || t('lightningWallet')} +

+

+ {t('nwcConnection')} +

+
+
+
+ {isActive && } + {!isActive && ( + + )} + +
+
+ ); + })} +
+ )} +
+ + {/* Help */} + {!webln && connections.length === 0 && ( + <> + +
+

+ {t('installWeblnOrConnectNwc')} +

+
+ + )} + + {/* Add Wallet Dialog */} + + + + {t('connectNwcWallet')} + + {t('enterConnectionStringFromWallet')} + + +
+
+ + setAlias(e.target.value)} + /> +
+
+ +