303 lines
6.5 KiB
TypeScript
303 lines
6.5 KiB
TypeScript
export interface PollOption {
|
|
id: string
|
|
text: string
|
|
emoji: string
|
|
votes: number
|
|
totalAmount: number // in cUSD
|
|
}
|
|
|
|
export type VerificationType = 'chainlink' | 'curve' | 'dexscreener' | 'api' | 'espn' | 'manual'
|
|
|
|
export interface Poll {
|
|
id: string
|
|
creatorFid: number
|
|
creatorAddress: string
|
|
question: string
|
|
description?: string
|
|
emoji: string
|
|
options: PollOption[]
|
|
startTime: number
|
|
endTime: number
|
|
status: 'active' | 'closed' | 'verified' | 'distributed' | 'refunded'
|
|
|
|
// Verification
|
|
verificationType: VerificationType
|
|
verificationConfig: Record<string, any>
|
|
correctOptionId?: string
|
|
verifiedAt?: number
|
|
verificationProof?: any
|
|
|
|
// Financial
|
|
totalPot: number // Total cUSD in pot
|
|
protocolFee: number // 5% fee amount
|
|
creationFee: number // 5 cUSD creation fee
|
|
winnersCount: number // Number of winners
|
|
distributedAt?: number
|
|
}
|
|
|
|
export interface Vote {
|
|
id: string
|
|
pollId: string
|
|
userId: string // Farcaster FID
|
|
optionId: string
|
|
amount: number // cUSD amount
|
|
txHash: string
|
|
timestamp: number
|
|
}
|
|
|
|
export interface UserProfile {
|
|
fid: number
|
|
username?: string
|
|
displayName?: string
|
|
pfpUrl?: string
|
|
primaryAddress?: string
|
|
}
|
|
|
|
export interface PollResult {
|
|
poll: Poll
|
|
userVote?: Vote
|
|
userWon: boolean
|
|
userWinnings: number
|
|
userShare?: number // Percentage share of winnings
|
|
}
|
|
|
|
// ============= SOCIAL FEATURES =============
|
|
|
|
export interface Comment {
|
|
id: string
|
|
pollId: string
|
|
userFid: string
|
|
userAddress: string
|
|
content: string
|
|
parentId?: string
|
|
likesCount: number
|
|
createdAt: number
|
|
updatedAt: number
|
|
isDeleted: boolean
|
|
isLiked?: boolean // Current user has liked this comment
|
|
replies?: Comment[] // Nested replies (max 3 levels)
|
|
user?: UserProfile // User info populated from Farcaster
|
|
}
|
|
|
|
export interface CommentLike {
|
|
id: string
|
|
commentId: string
|
|
userFid: string
|
|
createdAt: number
|
|
}
|
|
|
|
export interface Follow {
|
|
id: string
|
|
followerFid: string
|
|
followingFid: string
|
|
createdAt: number
|
|
}
|
|
|
|
export type NotificationType = 'vote' | 'comment' | 'like' | 'follow' | 'win' | 'mention' | 'poll_closed' | 'achievement'
|
|
|
|
export interface Notification {
|
|
id: string
|
|
userFid: string
|
|
type: NotificationType
|
|
title: string
|
|
message: string
|
|
link?: string
|
|
isRead: boolean
|
|
createdAt: number
|
|
metadata?: Record<string, any>
|
|
}
|
|
|
|
export interface UserSettings {
|
|
userFid: string
|
|
notifyOnComment: boolean
|
|
notifyOnLike: boolean
|
|
notifyOnFollow: boolean
|
|
notifyOnWin: boolean
|
|
notifyOnMention: boolean
|
|
displayName?: string
|
|
bio?: string
|
|
updatedAt: number
|
|
}
|
|
|
|
export interface UserStats {
|
|
totalVotes: number
|
|
totalWins: number
|
|
totalEarnings: number // in cUSD
|
|
winRate: number // Percentage (0-100)
|
|
currentStreak: number // Days
|
|
longestStreak: number // Days
|
|
followersCount: number
|
|
followingCount: number
|
|
achievementsCount: number
|
|
pollsCreated: number
|
|
commentsCount: number
|
|
}
|
|
|
|
export interface Achievement {
|
|
id: string
|
|
name: string
|
|
description: string
|
|
icon: string // Emoji
|
|
category: 'voting' | 'winning' | 'social' | 'streak' | 'creation'
|
|
requirement: Record<string, any> // JSON with requirement details
|
|
}
|
|
|
|
export interface UserAchievement {
|
|
id: string
|
|
userFid: string
|
|
achievementId: string
|
|
earnedAt: number
|
|
progress: number
|
|
achievement?: Achievement // Populated achievement data
|
|
}
|
|
|
|
export interface Report {
|
|
id: string
|
|
reporterFid: string
|
|
resourceType: 'poll' | 'comment' | 'user'
|
|
resourceId: string
|
|
reason: string
|
|
description?: string
|
|
status: 'pending' | 'resolved' | 'dismissed'
|
|
createdAt: number
|
|
resolvedAt?: number
|
|
resolvedBy?: string
|
|
}
|
|
|
|
export interface Bookmark {
|
|
id: string
|
|
userFid: string
|
|
pollId: string
|
|
createdAt: number
|
|
poll?: Poll // Populated poll data
|
|
}
|
|
|
|
export interface PollShare {
|
|
id: string
|
|
pollId: string
|
|
userFid: string
|
|
platform: 'warpcast' | 'twitter' | 'link'
|
|
createdAt: number
|
|
}
|
|
|
|
// ============= FEED & ACTIVITY =============
|
|
|
|
export type ActivityType = 'vote' | 'comment' | 'follow' | 'poll_created' | 'achievement'
|
|
|
|
export interface ActivityItem {
|
|
id: string
|
|
type: ActivityType
|
|
userFid: string
|
|
timestamp: number
|
|
content: string // Formatted activity description
|
|
link?: string
|
|
metadata?: Record<string, any>
|
|
user?: UserProfile
|
|
}
|
|
|
|
// ============= LEADERBOARD =============
|
|
|
|
export type LeaderboardCategory = 'top_voters' | 'biggest_winners' | 'win_streak' | 'followers'
|
|
export type LeaderboardTimeframe = 'all_time' | 'month' | 'week'
|
|
|
|
export interface LeaderboardEntry {
|
|
rank: number
|
|
userFid: string
|
|
value: number // Score for the category
|
|
displayValue: string // Formatted value (e.g., "125 cUSD")
|
|
user?: UserProfile
|
|
}
|
|
|
|
export interface LeaderboardData {
|
|
category: LeaderboardCategory
|
|
timeframe: LeaderboardTimeframe
|
|
entries: LeaderboardEntry[]
|
|
userRank?: number // Current user's rank
|
|
}
|
|
|
|
// ============= SEARCH & DISCOVERY =============
|
|
|
|
export interface SearchResult {
|
|
polls: Poll[]
|
|
users: UserProfile[]
|
|
totalPolls: number
|
|
totalUsers: number
|
|
}
|
|
|
|
export interface DiscoverFilters {
|
|
status?: 'active' | 'closed' | 'verified' | 'distributed'
|
|
category?: string
|
|
dateRange?: { start: number; end: number }
|
|
sort?: 'newest' | 'popular' | 'ending_soon' | 'biggest_pot'
|
|
search?: string
|
|
}
|
|
|
|
// ============= ANALYTICS =============
|
|
|
|
export interface PlatformStats {
|
|
totalUsers: number
|
|
totalPolls: number
|
|
totalVotes: number
|
|
totalVolume: number // Total cUSD volume
|
|
dailyActiveUsers: number
|
|
averageVoteAmount: number
|
|
pollsCreatedToday: number
|
|
votesToday: number
|
|
}
|
|
|
|
export interface CategoryStats {
|
|
category: string
|
|
pollCount: number
|
|
voteCount: number
|
|
volume: number
|
|
averagePot: number
|
|
}
|
|
|
|
// ============= ADMIN =============
|
|
|
|
export interface AdminPollAction {
|
|
action: 'feature' | 'close' | 'delete' | 'refund'
|
|
reason?: string
|
|
}
|
|
|
|
export interface ModQueueItem extends Report {
|
|
resourceData?: any // The actual poll, comment, or user data
|
|
}
|
|
|
|
// ============= API RESPONSES =============
|
|
|
|
export interface PaginatedResponse<T> {
|
|
data: T[]
|
|
pagination: {
|
|
page: number
|
|
limit: number
|
|
total: number
|
|
hasMore: boolean
|
|
}
|
|
}
|
|
|
|
export interface ApiResponse<T> {
|
|
success: boolean
|
|
data?: T
|
|
error?: string
|
|
message?: string
|
|
}
|
|
|
|
// ============= FRONTEND STATE =============
|
|
|
|
export interface ToastMessage {
|
|
id: string
|
|
type: 'success' | 'error' | 'info' | 'warning'
|
|
title?: string
|
|
message: string
|
|
duration?: number // ms, default 3000
|
|
}
|
|
|
|
export interface ModalState {
|
|
isOpen: boolean
|
|
title: string
|
|
content: React.ReactNode
|
|
size?: 'sm' | 'md' | 'lg'
|
|
onClose: () => void
|
|
}
|