@wkalidev/trivia-quest-sdk 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,109 +1,410 @@
1
- export declare const TRIVQ_TOKEN_ADDRESS: "0xe65fc5cacaf9a5aebbc0e151dee08a53f24a05c5";
2
- export declare const TRIVIA_QUEST_ADDRESS: "0xffe22d3d1b63866ac9da8ac92fdb9ceddeadb0bb";
3
- export declare const DAILY_CHECKIN_ADDRESS: "0x8650e6c477f8ae3933dc6d61d85e65c90cf71828";
4
- export declare const REFERRAL_ADDRESS: "0xa0fcd85a25ecb71ca1ea9d63da058c832c27c62e";
5
- export declare const TRIVQ_ABI: readonly [{
6
- readonly name: "balanceOf";
1
+ export declare const SDK_VERSION = "2.0.0";
2
+ export declare const TRIVIA_QUEST_ADDRESS_CELO: "0xffe22d3d1b63866ac9da8ac92fdb9ceddeadb0bb";
3
+ export declare const TRIVQ_TOKEN_ADDRESS_CELO: "0xe65fc5cacaf9a5aebbc0e151dee08a53f24a05c5";
4
+ export declare const CHECKIN_ADDRESS_CELO: "0x8650e6c477f8ae3933dc6d61d85e65c90cf71828";
5
+ export declare const REFERRAL_ADDRESS_CELO: "0xa0fcd85a25ecb71ca1ea9d63da058c832c27c62e";
6
+ export declare const DUEL_ADDRESS_CELO: "0xee7be00cd5454b9bea56d864d82076b8b5de5ca1";
7
+ export declare const TRIVIA_QUEST_ADDRESS_BASE: "0x1e2c209412ec30915ccf922654f0593faf61fcfb";
8
+ export declare const TRIVQ_TOKEN_ADDRESS_BASE: "0x8ecc1dc70f3bc5be941b61b42707eb7dbddb54c3";
9
+ export declare const CHECKIN_ADDRESS_BASE: "0x0f19851d5cd905d110c000a7d26d74a2f21f8ff9";
10
+ export declare const REFERRAL_ADDRESS_BASE: "0x4fb5285263354e1e75f044c65166ab22c3840074";
11
+ export declare const CONTRACT_ADDRESS_MAINNET: "0xffe22d3d1b63866ac9da8ac92fdb9ceddeadb0bb";
12
+ export declare const CONTRACT_ADDRESS_TESTNET: "0x50b20728ba0ad803679b5428f267c89aede9a378";
13
+ export declare const CELO_MAINNET: {
14
+ id: number;
15
+ name: string;
16
+ rpcUrl: string;
17
+ explorerUrl: string;
18
+ contracts: {
19
+ game: "0xffe22d3d1b63866ac9da8ac92fdb9ceddeadb0bb";
20
+ token: "0xe65fc5cacaf9a5aebbc0e151dee08a53f24a05c5";
21
+ checkin: "0x8650e6c477f8ae3933dc6d61d85e65c90cf71828";
22
+ referral: "0xa0fcd85a25ecb71ca1ea9d63da058c832c27c62e";
23
+ duel: "0xee7be00cd5454b9bea56d864d82076b8b5de5ca1";
24
+ };
25
+ };
26
+ export declare const BASE_MAINNET: {
27
+ id: number;
28
+ name: string;
29
+ rpcUrl: string;
30
+ explorerUrl: string;
31
+ contracts: {
32
+ game: "0x1e2c209412ec30915ccf922654f0593faf61fcfb";
33
+ token: "0x8ecc1dc70f3bc5be941b61b42707eb7dbddb54c3";
34
+ checkin: "0x0f19851d5cd905d110c000a7d26d74a2f21f8ff9";
35
+ referral: "0x4fb5285263354e1e75f044c65166ab22c3840074";
36
+ duel: "";
37
+ };
38
+ };
39
+ export declare const CELO_TESTNET: {
40
+ id: number;
41
+ name: string;
42
+ rpcUrl: string;
43
+ explorerUrl: string;
44
+ contracts: {
45
+ game: "0x50b20728ba0ad803679b5428f267c89aede9a378";
46
+ token: "";
47
+ checkin: "";
48
+ referral: "";
49
+ duel: "0xd9456518d7acbe6bcab494aa5894ce4cdf7c5ad7";
50
+ };
51
+ };
52
+ export declare function getAddress(chainId: number, contract: "game" | "token" | "checkin" | "referral" | "duel"): `0x${string}`;
53
+ export declare const CONTRACT_ABI: readonly [{
54
+ readonly name: "joinRound";
55
+ readonly type: "function";
56
+ readonly stateMutability: "payable";
57
+ readonly inputs: readonly [];
58
+ readonly outputs: readonly [];
59
+ }, {
60
+ readonly name: "getCurrentRound";
61
+ readonly type: "function";
62
+ readonly stateMutability: "view";
63
+ readonly inputs: readonly [];
64
+ readonly outputs: readonly [{
65
+ readonly type: "tuple";
66
+ readonly components: readonly [{
67
+ readonly name: "id";
68
+ readonly type: "uint256";
69
+ }, {
70
+ readonly name: "prizePool";
71
+ readonly type: "uint256";
72
+ }, {
73
+ readonly name: "startTime";
74
+ readonly type: "uint256";
75
+ }, {
76
+ readonly name: "endTime";
77
+ readonly type: "uint256";
78
+ }, {
79
+ readonly name: "topWinners";
80
+ readonly type: "address[]";
81
+ }, {
82
+ readonly name: "finished";
83
+ readonly type: "bool";
84
+ }];
85
+ }];
86
+ }, {
87
+ readonly name: "entryFee";
88
+ readonly type: "function";
89
+ readonly stateMutability: "view";
90
+ readonly inputs: readonly [];
91
+ readonly outputs: readonly [{
92
+ readonly type: "uint256";
93
+ }];
94
+ }, {
95
+ readonly name: "getLeaderboard";
96
+ readonly type: "function";
97
+ readonly stateMutability: "view";
98
+ readonly inputs: readonly [];
99
+ readonly outputs: readonly [{
100
+ readonly type: "tuple[]";
101
+ readonly components: readonly [{
102
+ readonly name: "player";
103
+ readonly type: "address";
104
+ }, {
105
+ readonly name: "totalPoints";
106
+ readonly type: "uint256";
107
+ }, {
108
+ readonly name: "bestScore";
109
+ readonly type: "uint256";
110
+ }, {
111
+ readonly name: "gamesPlayed";
112
+ readonly type: "uint256";
113
+ }];
114
+ }];
115
+ }, {
116
+ readonly name: "getPlayerStats";
7
117
  readonly type: "function";
8
118
  readonly stateMutability: "view";
9
119
  readonly inputs: readonly [{
10
- readonly name: "account";
120
+ readonly name: "player";
11
121
  readonly type: "address";
12
122
  }];
13
123
  readonly outputs: readonly [{
14
- readonly name: "";
124
+ readonly type: "tuple";
125
+ readonly components: readonly [{
126
+ readonly name: "score";
127
+ readonly type: "uint256";
128
+ }, {
129
+ readonly name: "totalWinnings";
130
+ readonly type: "uint256";
131
+ }, {
132
+ readonly name: "totalPoints";
133
+ readonly type: "uint256";
134
+ }, {
135
+ readonly name: "gamesPlayed";
136
+ readonly type: "uint256";
137
+ }, {
138
+ readonly name: "bestScore";
139
+ readonly type: "uint256";
140
+ }, {
141
+ readonly name: "exists";
142
+ readonly type: "bool";
143
+ }];
144
+ }];
145
+ }, {
146
+ readonly name: "getTotalPlayers";
147
+ readonly type: "function";
148
+ readonly stateMutability: "view";
149
+ readonly inputs: readonly [];
150
+ readonly outputs: readonly [{
15
151
  readonly type: "uint256";
16
152
  }];
17
153
  }, {
18
- readonly name: "mintReward";
154
+ readonly name: "submitScore";
19
155
  readonly type: "function";
20
156
  readonly stateMutability: "nonpayable";
21
157
  readonly inputs: readonly [{
22
158
  readonly name: "player";
23
159
  readonly type: "address";
24
160
  }, {
25
- readonly name: "amount";
161
+ readonly name: "score";
162
+ readonly type: "uint256";
163
+ }, {
164
+ readonly name: "points";
26
165
  readonly type: "uint256";
27
166
  }];
28
167
  readonly outputs: readonly [];
29
- }, {
30
- readonly name: "rewardsRemaining";
168
+ }];
169
+ export declare const DUEL_ABI: readonly [{
170
+ readonly name: "createDuel";
31
171
  readonly type: "function";
32
- readonly stateMutability: "view";
172
+ readonly stateMutability: "payable";
33
173
  readonly inputs: readonly [];
34
174
  readonly outputs: readonly [{
35
175
  readonly type: "uint256";
36
176
  }];
37
- }];
38
- export declare const TRIVIA_QUEST_ABI: readonly [{
39
- readonly name: "joinRound";
177
+ }, {
178
+ readonly name: "joinDuel";
40
179
  readonly type: "function";
41
180
  readonly stateMutability: "payable";
42
- readonly inputs: readonly [];
181
+ readonly inputs: readonly [{
182
+ readonly name: "duelId";
183
+ readonly type: "uint256";
184
+ }];
43
185
  readonly outputs: readonly [];
44
186
  }, {
45
- readonly name: "getCurrentRound";
187
+ readonly name: "cancelExpiredDuel";
46
188
  readonly type: "function";
47
- readonly stateMutability: "view";
48
- readonly inputs: readonly [];
49
- readonly outputs: readonly [{
50
- readonly name: "id";
51
- readonly type: "uint256";
52
- }, {
53
- readonly name: "prizePool";
54
- readonly type: "uint256";
55
- }, {
56
- readonly name: "startTime";
189
+ readonly stateMutability: "nonpayable";
190
+ readonly inputs: readonly [{
191
+ readonly name: "duelId";
57
192
  readonly type: "uint256";
58
- }, {
59
- readonly name: "endTime";
193
+ }];
194
+ readonly outputs: readonly [];
195
+ }, {
196
+ readonly name: "getDuel";
197
+ readonly type: "function";
198
+ readonly stateMutability: "view";
199
+ readonly inputs: readonly [{
200
+ readonly name: "duelId";
60
201
  readonly type: "uint256";
61
- }, {
62
- readonly name: "topWinners";
63
- readonly type: "address[]";
64
- }, {
65
- readonly name: "finished";
66
- readonly type: "bool";
202
+ }];
203
+ readonly outputs: readonly [{
204
+ readonly type: "tuple";
205
+ readonly components: readonly [{
206
+ readonly name: "id";
207
+ readonly type: "uint256";
208
+ }, {
209
+ readonly name: "playerA";
210
+ readonly type: "address";
211
+ }, {
212
+ readonly name: "playerB";
213
+ readonly type: "address";
214
+ }, {
215
+ readonly name: "wager";
216
+ readonly type: "uint256";
217
+ }, {
218
+ readonly name: "scoreA";
219
+ readonly type: "uint256";
220
+ }, {
221
+ readonly name: "scoreB";
222
+ readonly type: "uint256";
223
+ }, {
224
+ readonly name: "scoreASubmitted";
225
+ readonly type: "bool";
226
+ }, {
227
+ readonly name: "scoreBSubmitted";
228
+ readonly type: "bool";
229
+ }, {
230
+ readonly name: "winner";
231
+ readonly type: "address";
232
+ }, {
233
+ readonly name: "status";
234
+ readonly type: "uint8";
235
+ }, {
236
+ readonly name: "createdAt";
237
+ readonly type: "uint256";
238
+ }, {
239
+ readonly name: "expiresAt";
240
+ readonly type: "uint256";
241
+ }];
67
242
  }];
68
243
  }, {
69
- readonly name: "getLeaderboard";
244
+ readonly name: "getOpenDuels";
70
245
  readonly type: "function";
71
246
  readonly stateMutability: "view";
72
- readonly inputs: readonly [];
247
+ readonly inputs: readonly [{
248
+ readonly name: "limit";
249
+ readonly type: "uint256";
250
+ }];
73
251
  readonly outputs: readonly [{
74
252
  readonly type: "tuple[]";
75
253
  readonly components: readonly [{
76
- readonly name: "player";
254
+ readonly name: "id";
255
+ readonly type: "uint256";
256
+ }, {
257
+ readonly name: "playerA";
77
258
  readonly type: "address";
78
259
  }, {
79
- readonly name: "totalPoints";
260
+ readonly name: "playerB";
261
+ readonly type: "address";
262
+ }, {
263
+ readonly name: "wager";
80
264
  readonly type: "uint256";
81
265
  }, {
82
- readonly name: "bestScore";
266
+ readonly name: "scoreA";
83
267
  readonly type: "uint256";
84
268
  }, {
85
- readonly name: "gamesPlayed";
269
+ readonly name: "scoreB";
270
+ readonly type: "uint256";
271
+ }, {
272
+ readonly name: "scoreASubmitted";
273
+ readonly type: "bool";
274
+ }, {
275
+ readonly name: "scoreBSubmitted";
276
+ readonly type: "bool";
277
+ }, {
278
+ readonly name: "winner";
279
+ readonly type: "address";
280
+ }, {
281
+ readonly name: "status";
282
+ readonly type: "uint8";
283
+ }, {
284
+ readonly name: "createdAt";
285
+ readonly type: "uint256";
286
+ }, {
287
+ readonly name: "expiresAt";
86
288
  readonly type: "uint256";
87
289
  }];
88
290
  }];
89
291
  }, {
90
- readonly name: "getTotalPlayers";
292
+ readonly name: "getPlayerDuels";
293
+ readonly type: "function";
294
+ readonly stateMutability: "view";
295
+ readonly inputs: readonly [{
296
+ readonly name: "player";
297
+ readonly type: "address";
298
+ }];
299
+ readonly outputs: readonly [{
300
+ readonly type: "uint256[]";
301
+ }];
302
+ }, {
303
+ readonly name: "duelCounter";
91
304
  readonly type: "function";
92
305
  readonly stateMutability: "view";
93
306
  readonly inputs: readonly [];
94
307
  readonly outputs: readonly [{
95
308
  readonly type: "uint256";
96
309
  }];
310
+ }];
311
+ export declare const TRIVQ_ABI: readonly [{
312
+ readonly name: "balanceOf";
313
+ readonly type: "function";
314
+ readonly stateMutability: "view";
315
+ readonly inputs: readonly [{
316
+ readonly name: "account";
317
+ readonly type: "address";
318
+ }];
319
+ readonly outputs: readonly [{
320
+ readonly type: "uint256";
321
+ }];
97
322
  }, {
98
- readonly name: "entryFee";
323
+ readonly name: "transfer";
324
+ readonly type: "function";
325
+ readonly stateMutability: "nonpayable";
326
+ readonly inputs: readonly [{
327
+ readonly name: "to";
328
+ readonly type: "address";
329
+ }, {
330
+ readonly name: "amount";
331
+ readonly type: "uint256";
332
+ }];
333
+ readonly outputs: readonly [{
334
+ readonly type: "bool";
335
+ }];
336
+ }, {
337
+ readonly name: "totalSupply";
99
338
  readonly type: "function";
100
339
  readonly stateMutability: "view";
101
340
  readonly inputs: readonly [];
102
341
  readonly outputs: readonly [{
103
342
  readonly type: "uint256";
104
343
  }];
344
+ }, {
345
+ readonly name: "decimals";
346
+ readonly type: "function";
347
+ readonly stateMutability: "view";
348
+ readonly inputs: readonly [];
349
+ readonly outputs: readonly [{
350
+ readonly type: "uint8";
351
+ }];
105
352
  }];
106
- export declare const DAILY_CHECKIN_ABI: readonly [{
353
+ export type LeaderboardEntry = {
354
+ player: string;
355
+ totalPoints: bigint;
356
+ bestScore: bigint;
357
+ gamesPlayed: bigint;
358
+ };
359
+ export type PlayerStats = {
360
+ score: bigint;
361
+ totalWinnings: bigint;
362
+ totalPoints: bigint;
363
+ gamesPlayed: bigint;
364
+ bestScore: bigint;
365
+ exists: boolean;
366
+ };
367
+ export type Round = {
368
+ id: bigint;
369
+ prizePool: bigint;
370
+ startTime: bigint;
371
+ endTime: bigint;
372
+ topWinners: string[];
373
+ finished: boolean;
374
+ };
375
+ export declare enum DuelStatus {
376
+ Open = 0,
377
+ Active = 1,
378
+ Finished = 2,
379
+ Cancelled = 3
380
+ }
381
+ export type Duel = {
382
+ id: bigint;
383
+ playerA: string;
384
+ playerB: string;
385
+ wager: bigint;
386
+ scoreA: bigint;
387
+ scoreB: bigint;
388
+ scoreASubmitted: boolean;
389
+ scoreBSubmitted: boolean;
390
+ winner: string;
391
+ status: DuelStatus;
392
+ createdAt: bigint;
393
+ expiresAt: bigint;
394
+ };
395
+ export declare function getMultiplier(streak: number): number;
396
+ export declare function calculatePoints(correct: boolean, streak: number): number;
397
+ export declare function getStreakLabel(streak: number): string;
398
+ export declare function getDuelStatusLabel(status: DuelStatus): string;
399
+ export declare function formatWager(wager: bigint): string;
400
+ export declare function getDuelNetPrize(wager: bigint, feeBps?: number): bigint;
401
+ export declare function isDuelExpired(expiresAt: bigint): boolean;
402
+ export declare function isMiniPay(): boolean;
403
+ export declare function getMiniPayAccount(): Promise<string | null>;
404
+ export declare function formatAddress(address: string): string;
405
+ export declare function formatTrivq(raw: bigint): string;
406
+ export declare function formatCelo(wei: bigint): string;
407
+ export declare const CHECKIN_ABI: readonly [{
107
408
  readonly name: "checkIn";
108
409
  readonly type: "function";
109
410
  readonly stateMutability: "nonpayable";
@@ -137,15 +438,12 @@ export declare const DAILY_CHECKIN_ABI: readonly [{
137
438
  readonly type: "uint256";
138
439
  }];
139
440
  }, {
140
- readonly name: "isCheckInAvailable";
441
+ readonly name: "totalCheckIns";
141
442
  readonly type: "function";
142
443
  readonly stateMutability: "view";
143
- readonly inputs: readonly [{
144
- readonly name: "player";
145
- readonly type: "address";
146
- }];
444
+ readonly inputs: readonly [];
147
445
  readonly outputs: readonly [{
148
- readonly type: "bool";
446
+ readonly type: "uint256";
149
447
  }];
150
448
  }];
151
449
  export declare const REFERRAL_ABI: readonly [{
@@ -158,7 +456,7 @@ export declare const REFERRAL_ABI: readonly [{
158
456
  }];
159
457
  readonly outputs: readonly [];
160
458
  }, {
161
- readonly name: "getReferralStats";
459
+ readonly name: "getReferrer";
162
460
  readonly type: "function";
163
461
  readonly stateMutability: "view";
164
462
  readonly inputs: readonly [{
@@ -166,22 +464,106 @@ export declare const REFERRAL_ABI: readonly [{
166
464
  readonly type: "address";
167
465
  }];
168
466
  readonly outputs: readonly [{
169
- readonly name: "refs";
170
- readonly type: "uint256";
171
- }, {
172
- readonly name: "earned";
173
- readonly type: "uint256";
174
- }, {
175
- readonly name: "referred";
176
- readonly type: "bool";
177
- }, {
467
+ readonly type: "address";
468
+ }];
469
+ }, {
470
+ readonly name: "getReferralCount";
471
+ readonly type: "function";
472
+ readonly stateMutability: "view";
473
+ readonly inputs: readonly [{
178
474
  readonly name: "referrer";
179
475
  readonly type: "address";
180
476
  }];
477
+ readonly outputs: readonly [{
478
+ readonly type: "uint256";
479
+ }];
480
+ }];
481
+ export type CheckInData = {
482
+ lastCheckIn: bigint;
483
+ streak: bigint;
484
+ totalCheckIns: bigint;
485
+ checkInAvailable: boolean;
486
+ secondsUntilNext: bigint;
487
+ };
488
+ export type NetworkStats = {
489
+ players: number;
490
+ roundId: number;
491
+ prizePool: string;
492
+ totalCheckins: number;
493
+ };
494
+ export declare function fetchNetworkStats(): Promise<NetworkStats>;
495
+ export declare function getStreakBonus(streak: number): number;
496
+ export declare function getNextStreakMilestone(streak: number): number;
497
+ export declare function formatCountdown(seconds: number): string;
498
+ export declare const CATEGORIES: readonly [{
499
+ readonly id: 1;
500
+ readonly name: "Africa Explorer";
501
+ readonly emoji: "🌍";
502
+ readonly description: "African Geography";
503
+ }, {
504
+ readonly id: 2;
505
+ readonly name: "Crypto Master";
506
+ readonly emoji: "⛓";
507
+ readonly description: "Web3 & Crypto";
508
+ }, {
509
+ readonly id: 3;
510
+ readonly name: "Culture Keeper";
511
+ readonly emoji: "📜";
512
+ readonly description: "History & Culture";
513
+ }, {
514
+ readonly id: 4;
515
+ readonly name: "Tech Wizard";
516
+ readonly emoji: "⚡";
517
+ readonly description: "Science & Tech";
518
+ }, {
519
+ readonly id: 5;
520
+ readonly name: "Sport Champion";
521
+ readonly emoji: "🏆";
522
+ readonly description: "Sports";
523
+ }, {
524
+ readonly id: 6;
525
+ readonly name: "Trivia Legend";
526
+ readonly emoji: "✨";
527
+ readonly description: "General Knowledge";
181
528
  }];
182
- export declare const CELO_CHAIN_ID = 42220;
183
- export declare const CELO_RPC = "https://forno.celo.org";
184
- export declare const DAILY_REWARD_TRIVQ = 100;
185
- export declare const WEEK_BONUS_TRIVQ = 2000;
186
- export declare const REFERRAL_REWARD_TRIVQ = 500;
187
- export declare const TRIVQ_PER_POINT = 100;
529
+ export declare function getCategoryById(id: number): {
530
+ readonly id: 1;
531
+ readonly name: "Africa Explorer";
532
+ readonly emoji: "🌍";
533
+ readonly description: "African Geography";
534
+ } | {
535
+ readonly id: 2;
536
+ readonly name: "Crypto Master";
537
+ readonly emoji: "⛓";
538
+ readonly description: "Web3 & Crypto";
539
+ } | {
540
+ readonly id: 3;
541
+ readonly name: "Culture Keeper";
542
+ readonly emoji: "📜";
543
+ readonly description: "History & Culture";
544
+ } | {
545
+ readonly id: 4;
546
+ readonly name: "Tech Wizard";
547
+ readonly emoji: "⚡";
548
+ readonly description: "Science & Tech";
549
+ } | {
550
+ readonly id: 5;
551
+ readonly name: "Sport Champion";
552
+ readonly emoji: "🏆";
553
+ readonly description: "Sports";
554
+ } | {
555
+ readonly id: 6;
556
+ readonly name: "Trivia Legend";
557
+ readonly emoji: "✨";
558
+ readonly description: "General Knowledge";
559
+ } | null;
560
+ export declare function calculateRewards(params: {
561
+ score: number;
562
+ streak: number;
563
+ isCheckIn?: boolean;
564
+ isDuelWinner?: boolean;
565
+ wager?: bigint;
566
+ }): {
567
+ trivq: number;
568
+ celoWin: bigint;
569
+ };