From 9ade3efb10c9ba606797f42f0ef7f5cfb68c6dfd Mon Sep 17 00:00:00 2001 From: Danish Arora Date: Tue, 2 Sep 2025 10:21:08 +0530 Subject: [PATCH] chore: move wallet to services --- furps-report.md | 38 +++++++++++++++++++ furps.md | 4 +- src/App.tsx | 4 +- src/components/ui/author-display.tsx | 4 +- src/contexts/ForumContext.tsx | 2 +- src/lib/identity/wallets/index.ts | 1 - src/lib/services/AuthService.ts | 8 ++-- .../ordinal.ts => services/Ordinal/index.ts} | 0 .../{identity => services/Ordinal}/types.ts | 0 .../WalletService}/config.ts | 0 .../WalletService/index.ts} | 7 +++- 11 files changed, 54 insertions(+), 14 deletions(-) delete mode 100644 src/lib/identity/wallets/index.ts rename src/lib/{identity/ordinal.ts => services/Ordinal/index.ts} (100%) rename src/lib/{identity => services/Ordinal}/types.ts (100%) rename src/lib/{identity/wallets => services/WalletService}/config.ts (100%) rename src/lib/{identity/wallets/ReOwnWalletService.ts => services/WalletService/index.ts} (98%) diff --git a/furps-report.md b/furps-report.md index a3e9d0b..8fe531b 100644 --- a/furps-report.md +++ b/furps-report.md @@ -15,61 +15,73 @@ The OpChan application has successfully implemented most core functionality incl ### ✅ IMPLEMENTED #### 1. Bitcoin Key Authentication + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/identity/wallets/ReOwnWalletService.ts`, `src/contexts/AuthContext.tsx` - **Details**: Complete Bitcoin wallet integration with message signing capabilities #### 2. Cell Creation Restrictions + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/CreateCellDialog.tsx` - **Details**: Only users with Logos ordinal or ENS can create cells #### 3. Content Visibility + - **Status**: ✅ Fully Implemented - **Implementation**: `src/contexts/ForumContext.tsx`, `src/components/PostList.tsx` - **Details**: All users can view content regardless of authentication status #### 4. Cell Listing + - **Status**: ✅ Fully Implemented - **Implementation**: `src/components/CellList.tsx`, `src/pages/Index.tsx` - **Details**: Complete cell browsing with sorting and filtering #### 5. Cell Creation + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/CreateCellDialog.tsx` - **Details**: Name, description, and icon support with admin privileges #### 6. Post Creation + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostList.tsx` - **Details**: Title and body support with proper validation #### 7. Comment System + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostDetail.tsx` - **Details**: Nested commenting with proper threading #### 8. Voting System + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostCard.tsx` - **Details**: Upvote/downvote functionality with verification requirements #### 9. Web3 Key Authentication + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/identity/wallets/ReOwnWalletService.ts` - **Details**: Ethereum wallet support alongside Bitcoin #### 10. Relevance Index System + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/RelevanceCalculator.ts`, `src/lib/forum/transformers.ts` - **Details**: Comprehensive scoring with verification bonuses and moderation penalties #### 11. Moderation System + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/ForumActions.ts`, `src/components/PostDetail.tsx` - **Details**: Cell admin moderation for posts, comments, and users #### 12. Anonymous Voting + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/ForumActions.ts` - **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 #### 13. Call Sign Setup + - **Status**: ⚠️ Partially Implemented - **Implementation**: `src/types/identity.ts` (interface defined) - **Details**: Interface exists but no UI for setting up call signs - **Missing**: User interface for call sign configuration #### 14. Ordinal Avatar Display + - **Status**: ⚠️ Partially Implemented - **Implementation**: `src/components/ui/author-display.tsx` - **Details**: Basic ordinal detection but limited avatar display @@ -91,6 +105,7 @@ The OpChan application has successfully implemented most core functionality incl ### ❌ NOT IMPLEMENTED #### 15. Bookmarking System + - **Status**: ❌ Not Implemented - **Missing**: Local storage for bookmarked posts and topics - **Impact**: Users cannot save content for later reference @@ -102,56 +117,67 @@ The OpChan application has successfully implemented most core functionality incl ### ✅ IMPLEMENTED #### 1. Cross-Cell Topic Viewing + - **Status**: ✅ Fully Implemented - **Implementation**: `src/pages/FeedPage.tsx`, `src/components/ActivityFeed.tsx` - **Details**: Global feed showing posts from all cells #### 2. Active Member Count + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/transformers.ts` - **Details**: Calculated from post activity per cell #### 3. Topic Sorting + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/utils/sorting.ts`, `src/components/CellList.tsx` - **Details**: Sort by relevance (top) or time (new) #### 4. User Identification + - **Status**: ✅ Fully Implemented - **Implementation**: `src/components/ui/author-display.tsx` - **Details**: Ordinal pictures, ENS names, and custom nicknames #### 5. Moderation Hiding + - **Status**: ✅ Fully Implemented - **Implementation**: `src/components/PostList.tsx`, `src/components/PostDetail.tsx` - **Details**: Moderated content is hidden from regular users #### 6. Key Delegation + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/services/CryptoService.ts`, `src/components/ui/wallet-wizard.tsx` - **Details**: Browser key generation for improved UX #### 7. Browser-Only Usage + - **Status**: ✅ Fully Implemented - **Implementation**: React web application - **Details**: No additional software required beyond browser #### 8. Prototype UI + - **Status**: ✅ Fully Implemented - **Implementation**: Complete React component library - **Details**: Modern, responsive interface with cypherpunk theme #### 9. Library API + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/` directory structure - **Details**: Clear separation of concerns with well-defined interfaces #### 10. ENS Display Integration + - **Status**: ✅ Fully Implemented - **Implementation**: `src/components/ui/author-display.tsx` - **Details**: ENS holders can use ENS for display purposes #### 11. Relevance-Based Ordering + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/forum/RelevanceCalculator.ts` - **Details**: Posts and comments ordered by relevance score @@ -163,11 +189,13 @@ The OpChan application has successfully implemented most core functionality incl ### ✅ IMPLEMENTED #### 1. Ephemeral Data Handling + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/waku/services/CacheService.ts` - **Details**: Local caching with network synchronization #### 2. End-to-End Reliability + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/waku/core/ReliableMessaging.ts` - **Details**: Message acknowledgment and retry mechanisms @@ -179,6 +207,7 @@ The OpChan application has successfully implemented most core functionality incl ### ✅ IMPLEMENTED #### 1. Efficient Message Handling + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/waku/services/CacheService.ts` - **Details**: Optimized message processing and caching @@ -190,11 +219,13 @@ The OpChan application has successfully implemented most core functionality incl ### ✅ IMPLEMENTED #### 1. Web Application + - **Status**: ✅ Fully Implemented - **Implementation**: React-based SPA - **Details**: Cross-platform web application #### 2. Optional Wallet Support + - **Status**: ✅ Fully Implemented - **Implementation**: `src/contexts/AuthContext.tsx` - **Details**: Bitcoin and Ethereum wallet integration @@ -206,11 +237,13 @@ The OpChan application has successfully implemented most core functionality incl ### ✅ IMPLEMENTED #### 1. Centralized Ordinal API + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/identity/ordinal.ts` - **Details**: Integration with Logos dashboard API #### 2. Waku Network Integration + - **Status**: ✅ Fully Implemented - **Implementation**: `src/lib/waku/` directory - **Details**: Complete Waku protocol implementation @@ -265,14 +298,17 @@ The OpChan application has successfully implemented most core functionality incl ## Technical Debt & Improvements ### Code Quality + - **Status**: ✅ Good - **Details**: Well-structured TypeScript with proper type safety ### Testing Coverage + - **Status**: ⚠️ Partial - **Details**: Basic tests exist but coverage could be improved ### Documentation + - **Status**: ✅ Good - **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. **Key Strengths:** + - Complete authentication and authorization system - Robust forum operations (cells, posts, comments, voting) - 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 **Areas for Improvement:** + - User personalization features (bookmarks, call signs) - Enhanced ordinal integration - Advanced search and filtering diff --git a/furps.md b/furps.md index 46bee15..9d33a81 100644 --- a/furps.md +++ b/furps.md @@ -14,7 +14,7 @@ 10. Cell admin can mark posts and comments as moderated. 11. Cell admin can mark users as moderated. 12. Users can identify themselves by signing with their Web3 key. -13. Posts, comments and cells have a relevance index, which can be used to order or hide them in the UX. +13. Posts, comments and cells have a relevance index, which can be used to order or hide them in the UX. 14. The relevance index is lowered for post and comments which are moderated, or from a moderated user. 15. The relevance index is increased if the author owns an ENS or Logos ordinal. 16. The relevance index is increased if the post or comment is upvoted by an ENS or Logos ordinal owner. @@ -52,4 +52,4 @@ None ## + (Privacy, Anonymity, Deployments) 1. A centralised API is used to get Bitcoin ordinal information. -2. The Forum uses The Waku Network. \ No newline at end of file +2. The Forum uses The Waku Network. diff --git a/src/App.tsx b/src/App.tsx index 58c2e12..3f46068 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -23,9 +23,9 @@ import PostPage from './pages/PostPage'; import NotFound from './pages/NotFound'; import Dashboard from './pages/Dashboard'; import Index from './pages/Index'; -import { appkitConfig } from './lib/identity/wallets/config'; +import { appkitConfig } from './lib/services/WalletService/config'; import { WagmiProvider } from 'wagmi'; -import { config } from './lib/identity/wallets/config'; +import { config } from './lib/services/WalletService/config'; import { AppKitProvider } from '@reown/appkit/react'; // Create a client diff --git a/src/components/ui/author-display.tsx b/src/components/ui/author-display.tsx index 9acd89e..b398609 100644 --- a/src/components/ui/author-display.tsx +++ b/src/components/ui/author-display.tsx @@ -3,8 +3,8 @@ import { Badge } from '@/components/ui/badge'; import { Shield, Crown } from 'lucide-react'; import { UserVerificationStatus } from '@/types/forum'; import { getEnsName } from '@wagmi/core'; -import { config } from '@/lib/identity/wallets/config'; -import { OrdinalAPI } from '@/lib/identity/ordinal'; +import { config } from '@/lib/services/WalletService/config'; +import { OrdinalAPI } from '@/lib/services/Ordinal'; interface AuthorDisplayProps { address: string; diff --git a/src/contexts/ForumContext.tsx b/src/contexts/ForumContext.tsx index 8521fc3..21d469c 100644 --- a/src/contexts/ForumContext.tsx +++ b/src/contexts/ForumContext.tsx @@ -21,7 +21,7 @@ import { RelevanceCalculator } from '@/lib/forum/RelevanceCalculator'; import { UserVerificationStatus } from '@/types/forum'; import { CryptoService } from '@/lib/services'; import { getEnsName } from '@wagmi/core'; -import { config } from '@/lib/identity/wallets/config'; +import { config } from '@/lib/services/WalletService/config'; interface ForumContextType { cells: Cell[]; diff --git a/src/lib/identity/wallets/index.ts b/src/lib/identity/wallets/index.ts deleted file mode 100644 index c14729f..0000000 --- a/src/lib/identity/wallets/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ReOwnWalletService as WalletService } from './ReOwnWalletService'; diff --git a/src/lib/services/AuthService.ts b/src/lib/services/AuthService.ts index 283c534..60a5018 100644 --- a/src/lib/services/AuthService.ts +++ b/src/lib/services/AuthService.ts @@ -1,9 +1,9 @@ -import { WalletService } from '../identity/wallets/index'; +import walletService from './WalletService'; import { UseAppKitAccountReturn } from '@reown/appkit/react'; import { AppKit } from '@reown/appkit'; import { CryptoService, DelegationDuration } from './CryptoService'; import { EVerificationStatus, User, DisplayPreference } from '@/types/identity'; -import { WalletInfo } from '../identity/wallets/ReOwnWalletService'; +import { WalletInfo } from './WalletService'; export interface AuthResult { success: boolean; @@ -37,11 +37,11 @@ export interface AuthServiceInterface { } export class AuthService implements AuthServiceInterface { - private walletService: WalletService; + private walletService: typeof walletService; private cryptoService: CryptoService; constructor(cryptoService: CryptoService) { - this.walletService = new WalletService(); + this.walletService = walletService; this.cryptoService = cryptoService; } diff --git a/src/lib/identity/ordinal.ts b/src/lib/services/Ordinal/index.ts similarity index 100% rename from src/lib/identity/ordinal.ts rename to src/lib/services/Ordinal/index.ts diff --git a/src/lib/identity/types.ts b/src/lib/services/Ordinal/types.ts similarity index 100% rename from src/lib/identity/types.ts rename to src/lib/services/Ordinal/types.ts diff --git a/src/lib/identity/wallets/config.ts b/src/lib/services/WalletService/config.ts similarity index 100% rename from src/lib/identity/wallets/config.ts rename to src/lib/services/WalletService/config.ts diff --git a/src/lib/identity/wallets/ReOwnWalletService.ts b/src/lib/services/WalletService/index.ts similarity index 98% rename from src/lib/identity/wallets/ReOwnWalletService.ts rename to src/lib/services/WalletService/index.ts index 872f81c..b9fcf13 100644 --- a/src/lib/identity/wallets/ReOwnWalletService.ts +++ b/src/lib/services/WalletService/index.ts @@ -2,7 +2,7 @@ import { UseAppKitAccountReturn } from '@reown/appkit/react'; import { CryptoService, DelegationDuration, -} from '../../services/CryptoService'; +} from '../CryptoService'; import { AppKit } from '@reown/appkit'; import { getEnsName } from '@wagmi/core'; import { ChainNamespace } from '@reown/appkit-common'; @@ -16,7 +16,7 @@ export interface WalletInfo { isConnected: boolean; } -export class ReOwnWalletService { +class WalletService { private cryptoService: CryptoService; private bitcoinAccount?: UseAppKitAccountReturn; private ethereumAccount?: UseAppKitAccountReturn; @@ -247,3 +247,6 @@ export class ReOwnWalletService { return null; } } + +const walletService = new WalletService(); +export default walletService;