-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
63 lines (54 loc) · 1.53 KB
/
types.ts
File metadata and controls
63 lines (54 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
export interface Founder {
id: string;
name: string;
color: string;
}
export interface AuctionConfig {
startPrice: number;
floorPrice: number;
decrementAmount: number;
dropIntervalMs: number;
participantCount: number;
}
export enum AuctionStatus {
IDLE = 'IDLE',
RUNNING = 'RUNNING',
PAUSED = 'PAUSED',
ENDED = 'ENDED',
}
export interface BidLog {
price: number;
timestamp: Date;
event: 'DROP' | 'START' | 'NO_DEAL' | 'WIN';
details?: string;
}
export type SyncHistoryEntry = {
price: number;
timestamp: number;
event: BidLog['event'];
details?: string;
};
export type SyncConfig = Pick<AuctionConfig, 'startPrice' | 'floorPrice' | 'decrementAmount' | 'dropIntervalMs'>;
export type SyncSnapshot = {
status: AuctionStatus;
currentPrice: number;
nextDropTime: number;
winnerId: string | null;
history: SyncHistoryEntry[];
config: SyncConfig;
participants: SyncParticipant[];
participantCount: number;
};
export interface AuctionState {
currentPrice: number;
status: AuctionStatus;
winner: Founder | null;
history: BidLog[];
nextDropTime: number;
}
export type SyncParticipant = { id: string; name: string; color: string };
export type SyncEvent =
| { type: 'START'; startTime: number; startPrice: number; config?: SyncConfig; participantCount?: number; participants?: SyncParticipant[] }
| { type: 'BID'; winnerId: string; price: number; timestamp: number; clientSeenPrice?: number }
| { type: 'NO_DEAL'; price: number; timestamp: number }
| { type: 'RESET'; nextStartPrice?: number };