From 9ed8676d1732a0cb4b5b5354eaef37645bf5e208 Mon Sep 17 00:00:00 2001 From: Chad Curtis Date: Mon, 14 Jul 2025 01:40:04 +0000 Subject: [PATCH] context updae + app nwccontext --- CONTEXT.md | 14 ++++++++++++-- src/App.tsx | 17 ++++++++++------- src/test/TestApp.tsx | 9 ++++++--- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CONTEXT.md b/CONTEXT.md index f5e1cf6..b7d4b5c 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -18,6 +18,7 @@ This project is a Nostr client application built with React 18.x, TailwindCSS 3. - `/src/components/`: UI components including NostrProvider for Nostr integration - `/src/components/ui/`: shadcn/ui components (48+ components available) - `/src/components/auth/`: Authentication-related components (LoginArea, LoginDialog, etc.) + - Zap components: `ZapButton`, `ZapDialog`, `WalletModal` for Lightning payments - `/src/hooks/`: Custom hooks including: - `useNostr`: Core Nostr protocol integration - `useAuthor`: Fetch user profile data by pubkey @@ -31,9 +32,13 @@ This project is a Nostr client application built with React 18.x, TailwindCSS 3. - `useLoggedInAccounts`: Manage multiple accounts - `useLoginActions`: Authentication actions - `useIsMobile`: Responsive design helper + - `useZaps`: Lightning zap functionality with payment processing + - `useWallet`: Unified wallet detection (WebLN + NWC) + - `useNWC`: Nostr Wallet Connect connection management + - `useNWCContext`: Access NWC context provider - `/src/pages/`: Page components used by React Router (Index, NotFound) - `/src/lib/`: Utility functions and shared logic -- `/src/contexts/`: React context providers (AppContext) +- `/src/contexts/`: React context providers (AppContext, NWCContext) - `/src/test/`: Testing utilities including TestApp component - `/public/`: Static assets - `App.tsx`: Main app component with provider setup @@ -669,10 +674,15 @@ import { NWCProvider } from '@/contexts/NWCContext'; ``` ```tsx -// Use unified wallet detection +// Use unified wallet detection and zap components const { webln, activeNWC, preferredMethod } = useWallet(); const { zap } = useZaps(target, webln, activeNWC, onSuccess); +// Pre-built components available +import { ZapButton } from '@/components/ZapButton'; +import { ZapDialog } from '@/components/ZapDialog'; +import { WalletModal } from '@/components/WalletModal'; + // Validate recipient can receive zaps if (!author.metadata?.lud16 && !author.metadata?.lud06) { return null; // Hide zap button diff --git a/src/App.tsx b/src/App.tsx index 7cab833..21bad2b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,6 +11,7 @@ import { Toaster as Sonner } from "@/components/ui/sonner"; import { TooltipProvider } from "@/components/ui/tooltip"; import { NostrLoginProvider } from '@nostrify/react/login'; import { AppProvider } from '@/components/AppProvider'; +import { NWCProvider } from '@/contexts/NWCContext'; import { AppConfig } from '@/contexts/AppContext'; import AppRouter from './AppRouter'; @@ -49,13 +50,15 @@ export function App() { - - - - - - - + + + + + + + + + diff --git a/src/test/TestApp.tsx b/src/test/TestApp.tsx index ba46d95..d4edfdd 100644 --- a/src/test/TestApp.tsx +++ b/src/test/TestApp.tsx @@ -4,6 +4,7 @@ import { BrowserRouter } from 'react-router-dom'; import { NostrLoginProvider } from '@nostrify/react/login'; import NostrProvider from '@/components/NostrProvider'; import { AppProvider } from '@/components/AppProvider'; +import { NWCProvider } from '@/contexts/NWCContext'; import { AppConfig } from '@/contexts/AppContext'; interface TestAppProps { @@ -31,9 +32,11 @@ export function TestApp({ children }: TestAppProps) { - - {children} - + + + {children} + +