mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 08:23:35 +00:00
infinite loop initialization, wallet endpoint structure, zapdialog debug
This commit is contained in:
1 parent
4672413b04
commit
e14d4e887f
6 files changed
+284
-23
No files matched your search
@@ -98,6 +98,67 @@ import { useWallet } from '@/hooks/useWallet';
|
||||
import { useZaps } from '@/hooks/useZaps';
|
||||
```
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
**IMPORTANT**: The Cashu integration uses a **two-component architecture**:
|
||||
|
||||
1. **`CashuWallet`** - Standalone wallet management interface (separate page/route)
|
||||
2. **`ZapButton`** - Integrated zap functionality within content feeds
|
||||
|
||||
### Component Separation
|
||||
|
||||
The `CashuWallet` component is designed as a **standalone wallet management interface** and should remain separate from content feeds. This separation provides:
|
||||
|
||||
- **Clean UX**: Users manage their wallet separately from consuming content
|
||||
- **Performance**: Wallet operations don't interfere with feed rendering
|
||||
- **Security**: Sensitive wallet operations are isolated
|
||||
- **Mobile Optimization**: Wallet can use full-screen layouts on mobile
|
||||
|
||||
### Integration Pattern
|
||||
|
||||
```tsx
|
||||
// ✅ CORRECT: Separate wallet management
|
||||
function App() {
|
||||
return (
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route path="/wallet" element={<CashuWallet />} />
|
||||
<Route path="/" element={<FeedPage />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
// ✅ CORRECT: ZapButton integrated in content
|
||||
function FeedPage() {
|
||||
return (
|
||||
<div className="posts">
|
||||
{events.map(event => (
|
||||
<div key={event.id} className="post">
|
||||
<p>{event.content}</p>
|
||||
<ZapButton target={event} showCount={true} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ❌ INCORRECT: Don't embed CashuWallet in content feeds
|
||||
function FeedPage() {
|
||||
return (
|
||||
<div className="posts">
|
||||
<CashuWallet /> {/* Don't do this */}
|
||||
{events.map(event => (
|
||||
<div key={event.id} className="post">
|
||||
<p>{event.content}</p>
|
||||
<ZapButton target={event} showCount={true} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## Complete Example
|
||||
|
||||
```tsx
|
||||
@@ -182,11 +243,13 @@ data-testid="zap-modal"
|
||||
|
||||
## Best Practices for AI Agents
|
||||
|
||||
1. **Always include CashuWallet**: Let users manage their balance
|
||||
2. **Use consistent styling**: Apply your app's design system
|
||||
3. **Handle loading states**: The component manages its own loading states
|
||||
4. **Trust the intelligence**: The component handles payment method selection automatically
|
||||
5. **Test all scenarios**: Ensure Cashu, WebLN, NWC, and manual zaps all work
|
||||
1. **Maintain Component Separation**: Keep `CashuWallet` as a standalone page/route, not embedded in content feeds
|
||||
2. **Always include CashuWallet**: Provide a dedicated route/page for wallet management
|
||||
3. **Use consistent styling**: Apply your app's design system
|
||||
4. **Handle loading states**: The component manages its own loading states
|
||||
5. **Trust the intelligence**: The component handles payment method selection automatically
|
||||
6. **Test all scenarios**: Ensure Cashu, WebLN, NWC, and manual zaps all work
|
||||
7. **Follow the architecture**: Use `ZapButton` for content integration, `CashuWallet` for wallet management
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -209,10 +272,11 @@ data-testid="zap-modal"
|
||||
## Integration Checklist
|
||||
|
||||
- [ ] Import unified `ZapButton` component
|
||||
- [ ] Include `CashuWallet` for balance management
|
||||
- [ ] Create dedicated route/page for `CashuWallet` (don't embed in content feeds)
|
||||
- [ ] Ensure `useCashu` hook is available
|
||||
- [ ] Test all payment methods: Cashu → WebLN → NWC → Manual QR
|
||||
- [ ] Verify mobile responsiveness
|
||||
- [ ] Test error handling scenarios
|
||||
- [ ] Verify component separation (wallet management vs content integration)
|
||||
|
||||
This unified integration provides a seamless, intelligent zap experience that automatically selects the best available payment method while leveraging the benefits of both Cashu tokens and Lightning payments.
|
||||
Reference in new issue
Block a user