chore: move wallet to services

This commit is contained in:
Danish Arora 2025-09-02 10:21:08 +05:30
parent df1b052770
commit 9ade3efb10
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
11 changed files with 54 additions and 14 deletions

View File

@ -15,61 +15,73 @@ The OpChan application has successfully implemented most core functionality incl
### ✅ IMPLEMENTED ### ✅ IMPLEMENTED
#### 1. Bitcoin Key Authentication #### 1. Bitcoin Key Authentication
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/identity/wallets/ReOwnWalletService.ts`, `src/contexts/AuthContext.tsx` - **Implementation**: `src/lib/identity/wallets/ReOwnWalletService.ts`, `src/contexts/AuthContext.tsx`
- **Details**: Complete Bitcoin wallet integration with message signing capabilities - **Details**: Complete Bitcoin wallet integration with message signing capabilities
#### 2. Cell Creation Restrictions #### 2. Cell Creation Restrictions
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/CreateCellDialog.tsx` - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/CreateCellDialog.tsx`
- **Details**: Only users with Logos ordinal or ENS can create cells - **Details**: Only users with Logos ordinal or ENS can create cells
#### 3. Content Visibility #### 3. Content Visibility
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/contexts/ForumContext.tsx`, `src/components/PostList.tsx` - **Implementation**: `src/contexts/ForumContext.tsx`, `src/components/PostList.tsx`
- **Details**: All users can view content regardless of authentication status - **Details**: All users can view content regardless of authentication status
#### 4. Cell Listing #### 4. Cell Listing
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/components/CellList.tsx`, `src/pages/Index.tsx` - **Implementation**: `src/components/CellList.tsx`, `src/pages/Index.tsx`
- **Details**: Complete cell browsing with sorting and filtering - **Details**: Complete cell browsing with sorting and filtering
#### 5. Cell Creation #### 5. Cell Creation
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/CreateCellDialog.tsx` - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/CreateCellDialog.tsx`
- **Details**: Name, description, and icon support with admin privileges - **Details**: Name, description, and icon support with admin privileges
#### 6. Post Creation #### 6. Post Creation
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostList.tsx` - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostList.tsx`
- **Details**: Title and body support with proper validation - **Details**: Title and body support with proper validation
#### 7. Comment System #### 7. Comment System
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostDetail.tsx` - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostDetail.tsx`
- **Details**: Nested commenting with proper threading - **Details**: Nested commenting with proper threading
#### 8. Voting System #### 8. Voting System
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostCard.tsx` - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostCard.tsx`
- **Details**: Upvote/downvote functionality with verification requirements - **Details**: Upvote/downvote functionality with verification requirements
#### 9. Web3 Key Authentication #### 9. Web3 Key Authentication
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/identity/wallets/ReOwnWalletService.ts` - **Implementation**: `src/lib/identity/wallets/ReOwnWalletService.ts`
- **Details**: Ethereum wallet support alongside Bitcoin - **Details**: Ethereum wallet support alongside Bitcoin
#### 10. Relevance Index System #### 10. Relevance Index System
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/RelevanceCalculator.ts`, `src/lib/forum/transformers.ts` - **Implementation**: `src/lib/forum/RelevanceCalculator.ts`, `src/lib/forum/transformers.ts`
- **Details**: Comprehensive scoring with verification bonuses and moderation penalties - **Details**: Comprehensive scoring with verification bonuses and moderation penalties
#### 11. Moderation System #### 11. Moderation System
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostDetail.tsx` - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostDetail.tsx`
- **Details**: Cell admin moderation for posts, comments, and users - **Details**: Cell admin moderation for posts, comments, and users
#### 12. Anonymous Voting #### 12. Anonymous Voting
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/ForumActions.ts` - **Implementation**: `src/lib/forum/ForumActions.ts`
- **Details**: Anonymous users can vote with proper verification checks - **Details**: Anonymous users can vote with proper verification checks
@ -77,12 +89,14 @@ The OpChan application has successfully implemented most core functionality incl
### ⚠️ PARTIALLY IMPLEMENTED ### ⚠️ PARTIALLY IMPLEMENTED
#### 13. Call Sign Setup #### 13. Call Sign Setup
- **Status**: ⚠️ Partially Implemented - **Status**: ⚠️ Partially Implemented
- **Implementation**: `src/types/identity.ts` (interface defined) - **Implementation**: `src/types/identity.ts` (interface defined)
- **Details**: Interface exists but no UI for setting up call signs - **Details**: Interface exists but no UI for setting up call signs
- **Missing**: User interface for call sign configuration - **Missing**: User interface for call sign configuration
#### 14. Ordinal Avatar Display #### 14. Ordinal Avatar Display
- **Status**: ⚠️ Partially Implemented - **Status**: ⚠️ Partially Implemented
- **Implementation**: `src/components/ui/author-display.tsx` - **Implementation**: `src/components/ui/author-display.tsx`
- **Details**: Basic ordinal detection but limited avatar display - **Details**: Basic ordinal detection but limited avatar display
@ -91,6 +105,7 @@ The OpChan application has successfully implemented most core functionality incl
### ❌ NOT IMPLEMENTED ### ❌ NOT IMPLEMENTED
#### 15. Bookmarking System #### 15. Bookmarking System
- **Status**: ❌ Not Implemented - **Status**: ❌ Not Implemented
- **Missing**: Local storage for bookmarked posts and topics - **Missing**: Local storage for bookmarked posts and topics
- **Impact**: Users cannot save content for later reference - **Impact**: Users cannot save content for later reference
@ -102,56 +117,67 @@ The OpChan application has successfully implemented most core functionality incl
### ✅ IMPLEMENTED ### ✅ IMPLEMENTED
#### 1. Cross-Cell Topic Viewing #### 1. Cross-Cell Topic Viewing
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/pages/FeedPage.tsx`, `src/components/ActivityFeed.tsx` - **Implementation**: `src/pages/FeedPage.tsx`, `src/components/ActivityFeed.tsx`
- **Details**: Global feed showing posts from all cells - **Details**: Global feed showing posts from all cells
#### 2. Active Member Count #### 2. Active Member Count
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/transformers.ts` - **Implementation**: `src/lib/forum/transformers.ts`
- **Details**: Calculated from post activity per cell - **Details**: Calculated from post activity per cell
#### 3. Topic Sorting #### 3. Topic Sorting
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/utils/sorting.ts`, `src/components/CellList.tsx` - **Implementation**: `src/lib/utils/sorting.ts`, `src/components/CellList.tsx`
- **Details**: Sort by relevance (top) or time (new) - **Details**: Sort by relevance (top) or time (new)
#### 4. User Identification #### 4. User Identification
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/components/ui/author-display.tsx` - **Implementation**: `src/components/ui/author-display.tsx`
- **Details**: Ordinal pictures, ENS names, and custom nicknames - **Details**: Ordinal pictures, ENS names, and custom nicknames
#### 5. Moderation Hiding #### 5. Moderation Hiding
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/components/PostList.tsx`, `src/components/PostDetail.tsx` - **Implementation**: `src/components/PostList.tsx`, `src/components/PostDetail.tsx`
- **Details**: Moderated content is hidden from regular users - **Details**: Moderated content is hidden from regular users
#### 6. Key Delegation #### 6. Key Delegation
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/services/CryptoService.ts`, `src/components/ui/wallet-wizard.tsx` - **Implementation**: `src/lib/services/CryptoService.ts`, `src/components/ui/wallet-wizard.tsx`
- **Details**: Browser key generation for improved UX - **Details**: Browser key generation for improved UX
#### 7. Browser-Only Usage #### 7. Browser-Only Usage
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: React web application - **Implementation**: React web application
- **Details**: No additional software required beyond browser - **Details**: No additional software required beyond browser
#### 8. Prototype UI #### 8. Prototype UI
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: Complete React component library - **Implementation**: Complete React component library
- **Details**: Modern, responsive interface with cypherpunk theme - **Details**: Modern, responsive interface with cypherpunk theme
#### 9. Library API #### 9. Library API
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/` directory structure - **Implementation**: `src/lib/` directory structure
- **Details**: Clear separation of concerns with well-defined interfaces - **Details**: Clear separation of concerns with well-defined interfaces
#### 10. ENS Display Integration #### 10. ENS Display Integration
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/components/ui/author-display.tsx` - **Implementation**: `src/components/ui/author-display.tsx`
- **Details**: ENS holders can use ENS for display purposes - **Details**: ENS holders can use ENS for display purposes
#### 11. Relevance-Based Ordering #### 11. Relevance-Based Ordering
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/forum/RelevanceCalculator.ts` - **Implementation**: `src/lib/forum/RelevanceCalculator.ts`
- **Details**: Posts and comments ordered by relevance score - **Details**: Posts and comments ordered by relevance score
@ -163,11 +189,13 @@ The OpChan application has successfully implemented most core functionality incl
### ✅ IMPLEMENTED ### ✅ IMPLEMENTED
#### 1. Ephemeral Data Handling #### 1. Ephemeral Data Handling
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/waku/services/CacheService.ts` - **Implementation**: `src/lib/waku/services/CacheService.ts`
- **Details**: Local caching with network synchronization - **Details**: Local caching with network synchronization
#### 2. End-to-End Reliability #### 2. End-to-End Reliability
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/waku/core/ReliableMessaging.ts` - **Implementation**: `src/lib/waku/core/ReliableMessaging.ts`
- **Details**: Message acknowledgment and retry mechanisms - **Details**: Message acknowledgment and retry mechanisms
@ -179,6 +207,7 @@ The OpChan application has successfully implemented most core functionality incl
### ✅ IMPLEMENTED ### ✅ IMPLEMENTED
#### 1. Efficient Message Handling #### 1. Efficient Message Handling
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/waku/services/CacheService.ts` - **Implementation**: `src/lib/waku/services/CacheService.ts`
- **Details**: Optimized message processing and caching - **Details**: Optimized message processing and caching
@ -190,11 +219,13 @@ The OpChan application has successfully implemented most core functionality incl
### ✅ IMPLEMENTED ### ✅ IMPLEMENTED
#### 1. Web Application #### 1. Web Application
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: React-based SPA - **Implementation**: React-based SPA
- **Details**: Cross-platform web application - **Details**: Cross-platform web application
#### 2. Optional Wallet Support #### 2. Optional Wallet Support
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/contexts/AuthContext.tsx` - **Implementation**: `src/contexts/AuthContext.tsx`
- **Details**: Bitcoin and Ethereum wallet integration - **Details**: Bitcoin and Ethereum wallet integration
@ -206,11 +237,13 @@ The OpChan application has successfully implemented most core functionality incl
### ✅ IMPLEMENTED ### ✅ IMPLEMENTED
#### 1. Centralized Ordinal API #### 1. Centralized Ordinal API
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/identity/ordinal.ts` - **Implementation**: `src/lib/identity/ordinal.ts`
- **Details**: Integration with Logos dashboard API - **Details**: Integration with Logos dashboard API
#### 2. Waku Network Integration #### 2. Waku Network Integration
- **Status**: ✅ Fully Implemented - **Status**: ✅ Fully Implemented
- **Implementation**: `src/lib/waku/` directory - **Implementation**: `src/lib/waku/` directory
- **Details**: Complete Waku protocol implementation - **Details**: Complete Waku protocol implementation
@ -265,14 +298,17 @@ The OpChan application has successfully implemented most core functionality incl
## Technical Debt & Improvements ## Technical Debt & Improvements
### Code Quality ### Code Quality
- **Status**: ✅ Good - **Status**: ✅ Good
- **Details**: Well-structured TypeScript with proper type safety - **Details**: Well-structured TypeScript with proper type safety
### Testing Coverage ### Testing Coverage
- **Status**: ⚠️ Partial - **Status**: ⚠️ Partial
- **Details**: Basic tests exist but coverage could be improved - **Details**: Basic tests exist but coverage could be improved
### Documentation ### Documentation
- **Status**: ✅ Good - **Status**: ✅ Good
- **Details**: Comprehensive README and inline documentation - **Details**: Comprehensive README and inline documentation
@ -283,6 +319,7 @@ The OpChan application has successfully implemented most core functionality incl
OpChan has successfully implemented the vast majority of FURPS requirements, providing a solid foundation for a decentralized forum application. The core functionality is robust and well-architected, with only a few user experience features remaining to be implemented. OpChan has successfully implemented the vast majority of FURPS requirements, providing a solid foundation for a decentralized forum application. The core functionality is robust and well-architected, with only a few user experience features remaining to be implemented.
**Key Strengths:** **Key Strengths:**
- Complete authentication and authorization system - Complete authentication and authorization system
- Robust forum operations (cells, posts, comments, voting) - Robust forum operations (cells, posts, comments, voting)
- Sophisticated relevance scoring algorithm - Sophisticated relevance scoring algorithm
@ -290,6 +327,7 @@ OpChan has successfully implemented the vast majority of FURPS requirements, pro
- Professional-grade UI with cypherpunk aesthetic - Professional-grade UI with cypherpunk aesthetic
**Areas for Improvement:** **Areas for Improvement:**
- User personalization features (bookmarks, call signs) - User personalization features (bookmarks, call signs)
- Enhanced ordinal integration - Enhanced ordinal integration
- Advanced search and filtering - Advanced search and filtering

View File

@ -23,9 +23,9 @@ import PostPage from './pages/PostPage';
import NotFound from './pages/NotFound'; import NotFound from './pages/NotFound';
import Dashboard from './pages/Dashboard'; import Dashboard from './pages/Dashboard';
import Index from './pages/Index'; import Index from './pages/Index';
import { appkitConfig } from './lib/identity/wallets/config'; import { appkitConfig } from './lib/services/WalletService/config';
import { WagmiProvider } from 'wagmi'; import { WagmiProvider } from 'wagmi';
import { config } from './lib/identity/wallets/config'; import { config } from './lib/services/WalletService/config';
import { AppKitProvider } from '@reown/appkit/react'; import { AppKitProvider } from '@reown/appkit/react';
// Create a client // Create a client

View File

@ -3,8 +3,8 @@ import { Badge } from '@/components/ui/badge';
import { Shield, Crown } from 'lucide-react'; import { Shield, Crown } from 'lucide-react';
import { UserVerificationStatus } from '@/types/forum'; import { UserVerificationStatus } from '@/types/forum';
import { getEnsName } from '@wagmi/core'; import { getEnsName } from '@wagmi/core';
import { config } from '@/lib/identity/wallets/config'; import { config } from '@/lib/services/WalletService/config';
import { OrdinalAPI } from '@/lib/identity/ordinal'; import { OrdinalAPI } from '@/lib/services/Ordinal';
interface AuthorDisplayProps { interface AuthorDisplayProps {
address: string; address: string;

View File

@ -21,7 +21,7 @@ import { RelevanceCalculator } from '@/lib/forum/RelevanceCalculator';
import { UserVerificationStatus } from '@/types/forum'; import { UserVerificationStatus } from '@/types/forum';
import { CryptoService } from '@/lib/services'; import { CryptoService } from '@/lib/services';
import { getEnsName } from '@wagmi/core'; import { getEnsName } from '@wagmi/core';
import { config } from '@/lib/identity/wallets/config'; import { config } from '@/lib/services/WalletService/config';
interface ForumContextType { interface ForumContextType {
cells: Cell[]; cells: Cell[];

View File

@ -1 +0,0 @@
export { ReOwnWalletService as WalletService } from './ReOwnWalletService';

View File

@ -1,9 +1,9 @@
import { WalletService } from '../identity/wallets/index'; import walletService from './WalletService';
import { UseAppKitAccountReturn } from '@reown/appkit/react'; import { UseAppKitAccountReturn } from '@reown/appkit/react';
import { AppKit } from '@reown/appkit'; import { AppKit } from '@reown/appkit';
import { CryptoService, DelegationDuration } from './CryptoService'; import { CryptoService, DelegationDuration } from './CryptoService';
import { EVerificationStatus, User, DisplayPreference } from '@/types/identity'; import { EVerificationStatus, User, DisplayPreference } from '@/types/identity';
import { WalletInfo } from '../identity/wallets/ReOwnWalletService'; import { WalletInfo } from './WalletService';
export interface AuthResult { export interface AuthResult {
success: boolean; success: boolean;
@ -37,11 +37,11 @@ export interface AuthServiceInterface {
} }
export class AuthService implements AuthServiceInterface { export class AuthService implements AuthServiceInterface {
private walletService: WalletService; private walletService: typeof walletService;
private cryptoService: CryptoService; private cryptoService: CryptoService;
constructor(cryptoService: CryptoService) { constructor(cryptoService: CryptoService) {
this.walletService = new WalletService(); this.walletService = walletService;
this.cryptoService = cryptoService; this.cryptoService = cryptoService;
} }

View File

@ -2,7 +2,7 @@ import { UseAppKitAccountReturn } from '@reown/appkit/react';
import { import {
CryptoService, CryptoService,
DelegationDuration, DelegationDuration,
} from '../../services/CryptoService'; } from '../CryptoService';
import { AppKit } from '@reown/appkit'; import { AppKit } from '@reown/appkit';
import { getEnsName } from '@wagmi/core'; import { getEnsName } from '@wagmi/core';
import { ChainNamespace } from '@reown/appkit-common'; import { ChainNamespace } from '@reown/appkit-common';
@ -16,7 +16,7 @@ export interface WalletInfo {
isConnected: boolean; isConnected: boolean;
} }
export class ReOwnWalletService { class WalletService {
private cryptoService: CryptoService; private cryptoService: CryptoService;
private bitcoinAccount?: UseAppKitAccountReturn; private bitcoinAccount?: UseAppKitAccountReturn;
private ethereumAccount?: UseAppKitAccountReturn; private ethereumAccount?: UseAppKitAccountReturn;
@ -247,3 +247,6 @@ export class ReOwnWalletService {
return null; return null;
} }
} }
const walletService = new WalletService();
export default walletService;