diff --git a/src/lib/forum/relevance.test.ts b/src/lib/forum/__tests__/relevance.test.ts similarity index 97% rename from src/lib/forum/relevance.test.ts rename to src/lib/forum/__tests__/relevance.test.ts index b9fa2c7..e2a149a 100644 --- a/src/lib/forum/relevance.test.ts +++ b/src/lib/forum/__tests__/relevance.test.ts @@ -1,8 +1,7 @@ -import { RelevanceCalculator } from './relevance'; -import { Post, Comment, Cell, User } from '@/types'; +import { RelevanceCalculator } from '../relevance'; +import { Post, Comment, User, UserVerificationStatus } from '@/types/forum'; import { VoteMessage, MessageType } from '@/lib/waku/types'; import { expect, describe, beforeEach, it } from 'vitest'; -import { UserVerificationStatus } from './types'; describe('RelevanceCalculator', () => { let calculator: RelevanceCalculator; diff --git a/src/lib/forum/actions.ts b/src/lib/forum/actions.ts index e04e7b5..16fd8f0 100644 --- a/src/lib/forum/actions.ts +++ b/src/lib/forum/actions.ts @@ -7,7 +7,7 @@ import { VoteMessage, ModerateMessage, } from '@/lib/waku/types'; -import { Cell, Comment, Post, User } from '@/types'; +import { Cell, Comment, Post, User } from '@/types/forum'; import { transformCell, transformComment, transformPost } from './transformers'; import { MessageService } from '@/lib/identity/services/MessageService'; import { AuthService } from '@/lib/identity/services/AuthService'; diff --git a/src/lib/forum/relevance.ts b/src/lib/forum/relevance.ts index 2df051f..76b7134 100644 --- a/src/lib/forum/relevance.ts +++ b/src/lib/forum/relevance.ts @@ -1,6 +1,5 @@ -import { Post, Comment, Cell, User } from '@/types'; +import { Post, Comment, Cell, User, RelevanceScoreDetails, UserVerificationStatus } from '@/types/forum'; import { VoteMessage } from '@/lib/waku/types'; -import { RelevanceScoreDetails, UserVerificationStatus } from './types'; export class RelevanceCalculator { private static readonly BASE_SCORES = { diff --git a/src/lib/forum/sorting.ts b/src/lib/forum/sorting.ts index 4167621..369cbe0 100644 --- a/src/lib/forum/sorting.ts +++ b/src/lib/forum/sorting.ts @@ -1,4 +1,4 @@ -import { Post, Comment, Cell } from '@/types'; +import { Post, Comment, Cell } from '@/types/forum'; export type SortOption = 'relevance' | 'time'; diff --git a/src/lib/forum/types.ts b/src/lib/forum/types.ts deleted file mode 100644 index ed28658..0000000 --- a/src/lib/forum/types.ts +++ /dev/null @@ -1,27 +0,0 @@ -export interface RelevanceScoreDetails { - baseScore: number; - engagementScore: number; - authorVerificationBonus: number; - verifiedUpvoteBonus: number; - verifiedCommenterBonus: number; - timeDecayMultiplier: number; - moderationPenalty: number; - finalScore: number; - isVerified: boolean; - upvotes: number; - comments: number; - verifiedUpvotes: number; - verifiedCommenters: number; - daysOld: number; - isModerated: boolean; - } - - export interface UserVerificationStatus { - [address: string]: { - isVerified: boolean; - hasENS: boolean; - hasOrdinal: boolean; - ensName?: string; - verificationStatus?: 'unverified' | 'verified-none' | 'verified-basic' | 'verified-owner' | 'verifying'; - }; - } \ No newline at end of file diff --git a/src/types/forum.ts b/src/types/forum.ts new file mode 100644 index 0000000..6d5eb5b --- /dev/null +++ b/src/types/forum.ts @@ -0,0 +1,110 @@ +import { CellMessage, CommentMessage, PostMessage, VoteMessage, ModerateMessage } from "@/lib/waku/types"; + +export type OpchanMessage = CellMessage | PostMessage | CommentMessage | VoteMessage | ModerateMessage; + +export interface User { + address: string; + walletType: 'bitcoin' | 'ethereum'; + + // Bitcoin-specific + ordinalOwnership?: boolean | { id: string; details: string }; + + // Ethereum-specific + ensName?: string; + ensAvatar?: string; + ensOwnership?: boolean; + + verificationStatus: 'unverified' | 'verified-none' | 'verified-basic' | 'verified-owner' | 'verifying'; + + signature?: string; + lastChecked?: number; + browserPubKey?: string; // Browser-generated public key for key delegation + delegationSignature?: string; // Signature from Bitcoin/Ethereum wallet for delegation + delegationExpiry?: number; // When the delegation expires +} + +export interface Cell { + id: string; + name: string; + description: string; + icon?: string; + signature?: string; // Message signature + browserPubKey?: string; // Public key that signed the message + relevanceScore?: number; // Calculated relevance score + activeMemberCount?: number; // Number of active members in the cell + relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation +} + +export interface Post { + id: string; + cellId: string; + authorAddress: string; + title: string; + content: string; + timestamp: number; + upvotes: VoteMessage[]; + downvotes: VoteMessage[]; + signature?: string; // Message signature + browserPubKey?: string; // Public key that signed the message + moderated?: boolean; + moderatedBy?: string; + moderationReason?: string; + moderationTimestamp?: number; + relevanceScore?: number; // Calculated relevance score + verifiedUpvotes?: number; // Count of upvotes from verified users + verifiedCommenters?: string[]; // List of verified users who commented + relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation +} + +export interface Comment { + id: string; + postId: string; + authorAddress: string; + content: string; + timestamp: number; + upvotes: VoteMessage[]; + downvotes: VoteMessage[]; + signature?: string; // Message signature + browserPubKey?: string; // Public key that signed the message + moderated?: boolean; + moderatedBy?: string; + moderationReason?: string; + moderationTimestamp?: number; + relevanceScore?: number; // Calculated relevance score + relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation +} + +// Extended message types for verification +export interface SignedMessage { + signature?: string; // Signature of the message + browserPubKey?: string; // Public key that signed the message +} + + +export interface RelevanceScoreDetails { + baseScore: number; + engagementScore: number; + authorVerificationBonus: number; + verifiedUpvoteBonus: number; + verifiedCommenterBonus: number; + timeDecayMultiplier: number; + moderationPenalty: number; + finalScore: number; + isVerified: boolean; + upvotes: number; + comments: number; + verifiedUpvotes: number; + verifiedCommenters: number; + daysOld: number; + isModerated: boolean; + } + + export interface UserVerificationStatus { + [address: string]: { + isVerified: boolean; + hasENS: boolean; + hasOrdinal: boolean; + ensName?: string; + verificationStatus?: 'unverified' | 'verified-none' | 'verified-basic' | 'verified-owner' | 'verifying'; + }; + } \ No newline at end of file diff --git a/src/types/global.d.ts b/src/types/global.d.ts deleted file mode 100644 index fd8ebf5..0000000 --- a/src/types/global.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import 'react'; - -// Ensures file is treated as a module -export {}; \ No newline at end of file diff --git a/src/types/index.ts b/src/types/index.ts index 935b4c1..16e03ec 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,82 +1 @@ -import { CellMessage, CommentMessage, PostMessage, VoteMessage, ModerateMessage } from "@/lib/waku/types"; -import { RelevanceScoreDetails } from "@/lib/forum/relevance"; - -export type OpchanMessage = CellMessage | PostMessage | CommentMessage | VoteMessage | ModerateMessage; - -export interface User { - address: string; - walletType: 'bitcoin' | 'ethereum'; - - // Bitcoin-specific - ordinalOwnership?: boolean | { id: string; details: string }; - - // Ethereum-specific - ensName?: string; - ensAvatar?: string; - ensOwnership?: boolean; - - verificationStatus: 'unverified' | 'verified-none' | 'verified-basic' | 'verified-owner' | 'verifying'; - - signature?: string; - lastChecked?: number; - browserPubKey?: string; // Browser-generated public key for key delegation - delegationSignature?: string; // Signature from Bitcoin/Ethereum wallet for delegation - delegationExpiry?: number; // When the delegation expires -} - -export interface Cell { - id: string; - name: string; - description: string; - icon?: string; - signature?: string; // Message signature - browserPubKey?: string; // Public key that signed the message - relevanceScore?: number; // Calculated relevance score - activeMemberCount?: number; // Number of active members in the cell - relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation -} - -export interface Post { - id: string; - cellId: string; - authorAddress: string; - title: string; - content: string; - timestamp: number; - upvotes: VoteMessage[]; - downvotes: VoteMessage[]; - signature?: string; // Message signature - browserPubKey?: string; // Public key that signed the message - moderated?: boolean; - moderatedBy?: string; - moderationReason?: string; - moderationTimestamp?: number; - relevanceScore?: number; // Calculated relevance score - verifiedUpvotes?: number; // Count of upvotes from verified users - verifiedCommenters?: string[]; // List of verified users who commented - relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation -} - -export interface Comment { - id: string; - postId: string; - authorAddress: string; - content: string; - timestamp: number; - upvotes: VoteMessage[]; - downvotes: VoteMessage[]; - signature?: string; // Message signature - browserPubKey?: string; // Public key that signed the message - moderated?: boolean; - moderatedBy?: string; - moderationReason?: string; - moderationTimestamp?: number; - relevanceScore?: number; // Calculated relevance score - relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation -} - -// Extended message types for verification -export interface SignedMessage { - signature?: string; // Signature of the message - browserPubKey?: string; // Public key that signed the message -} +export * as forum from './forum'; \ No newline at end of file