@provable-games/budokan-sdk 0.1.25 → 0.1.26
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.
- package/dist/index.cjs +286 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +230 -3
- package/dist/index.d.ts +230 -3
- package/dist/index.js +278 -3
- package/dist/index.js.map +1 -1
- package/dist/{player-P6Dd1lNb.d.cts → player-CbAYHoW8.d.cts} +10 -2
- package/dist/{player-P6Dd1lNb.d.ts → player-CbAYHoW8.d.ts} +10 -2
- package/dist/react.cjs +35 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +35 -2
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
|
@@ -78,6 +78,14 @@ interface Tournament {
|
|
|
78
78
|
} | null;
|
|
79
79
|
entryRequirement: EntryRequirement | null;
|
|
80
80
|
leaderboardConfig: LeaderboardConfig | null;
|
|
81
|
+
/**
|
|
82
|
+
* Lifecycle phase derived from the schedule + on-chain creation time.
|
|
83
|
+
* Populated by `getTournament`/`getTournaments` (computed at read time via
|
|
84
|
+
* `tournamentPhase`); `null` when the creation time is unknown. Because it's
|
|
85
|
+
* time-derived, treat it as a snapshot for the moment it was read — call
|
|
86
|
+
* `tournamentPhase(t)` to re-evaluate later.
|
|
87
|
+
*/
|
|
88
|
+
phase: Phase | null;
|
|
81
89
|
entryCount: number;
|
|
82
90
|
prizeCount: number;
|
|
83
91
|
submissionCount: number;
|
|
@@ -375,7 +383,7 @@ declare class ConnectionStatus {
|
|
|
375
383
|
* // RPC-only (bypass API entirely)
|
|
376
384
|
* const client = new BudokanClient({
|
|
377
385
|
* primarySource: "rpc",
|
|
378
|
-
* rpcUrl: "https://
|
|
386
|
+
* rpcUrl: "https://rpc.provable.games/rpc",
|
|
379
387
|
* viewerAddress: "0x...",
|
|
380
388
|
* });
|
|
381
389
|
* ```
|
|
@@ -576,4 +584,4 @@ interface PlayerRewards {
|
|
|
576
584
|
rewardClaims: RewardClaim[];
|
|
577
585
|
}
|
|
578
586
|
|
|
579
|
-
export { BudokanClient as B, type ConnectionMode as C, type DataSource as D, type ExtensionPrize as E, type GameConfig as G, type LeaderboardConfig as L, type PrizeAggregation as P, type QualificationEntry as Q, type Registration as R, type Schedule as S, type Tournament as T, type WSSubscribeOptions as W, type Prize as a, type PaginatedResult as b, type RewardClaim as c, type RewardClaimSummary as d, type TournamentListParams as e, type PlatformStats as f, type PrizeStats as g, type WSEventHandler as h, type TokenPrize as i, type
|
|
587
|
+
export { BudokanClient as B, type ConnectionMode as C, type DataSource as D, type ExtensionPrize as E, type GameConfig as G, type LeaderboardConfig as L, type PrizeAggregation as P, type QualificationEntry as Q, type Registration as R, type Schedule as S, type Tournament as T, type WSSubscribeOptions as W, type Prize as a, type PaginatedResult as b, type RewardClaim as c, type RewardClaimSummary as d, type TournamentListParams as e, type PlatformStats as f, type PrizeStats as g, type WSEventHandler as h, type TokenPrize as i, type PlayerPlacement as j, type Phase as k, type BudokanClientConfig as l, ConnectionStatus as m, type ConnectionStatusState as n, type Erc20Prize as o, type Erc721Prize as p, type LeaderboardEntry as q, type PlayerRewards as r, type WSChannel as s, type WSEventMessage as t, type WSMessage as u, type WSSubscribeMessage as v, type WSUnsubscribeMessage as w, createBudokanClient as x };
|
|
@@ -78,6 +78,14 @@ interface Tournament {
|
|
|
78
78
|
} | null;
|
|
79
79
|
entryRequirement: EntryRequirement | null;
|
|
80
80
|
leaderboardConfig: LeaderboardConfig | null;
|
|
81
|
+
/**
|
|
82
|
+
* Lifecycle phase derived from the schedule + on-chain creation time.
|
|
83
|
+
* Populated by `getTournament`/`getTournaments` (computed at read time via
|
|
84
|
+
* `tournamentPhase`); `null` when the creation time is unknown. Because it's
|
|
85
|
+
* time-derived, treat it as a snapshot for the moment it was read — call
|
|
86
|
+
* `tournamentPhase(t)` to re-evaluate later.
|
|
87
|
+
*/
|
|
88
|
+
phase: Phase | null;
|
|
81
89
|
entryCount: number;
|
|
82
90
|
prizeCount: number;
|
|
83
91
|
submissionCount: number;
|
|
@@ -375,7 +383,7 @@ declare class ConnectionStatus {
|
|
|
375
383
|
* // RPC-only (bypass API entirely)
|
|
376
384
|
* const client = new BudokanClient({
|
|
377
385
|
* primarySource: "rpc",
|
|
378
|
-
* rpcUrl: "https://
|
|
386
|
+
* rpcUrl: "https://rpc.provable.games/rpc",
|
|
379
387
|
* viewerAddress: "0x...",
|
|
380
388
|
* });
|
|
381
389
|
* ```
|
|
@@ -576,4 +584,4 @@ interface PlayerRewards {
|
|
|
576
584
|
rewardClaims: RewardClaim[];
|
|
577
585
|
}
|
|
578
586
|
|
|
579
|
-
export { BudokanClient as B, type ConnectionMode as C, type DataSource as D, type ExtensionPrize as E, type GameConfig as G, type LeaderboardConfig as L, type PrizeAggregation as P, type QualificationEntry as Q, type Registration as R, type Schedule as S, type Tournament as T, type WSSubscribeOptions as W, type Prize as a, type PaginatedResult as b, type RewardClaim as c, type RewardClaimSummary as d, type TournamentListParams as e, type PlatformStats as f, type PrizeStats as g, type WSEventHandler as h, type TokenPrize as i, type
|
|
587
|
+
export { BudokanClient as B, type ConnectionMode as C, type DataSource as D, type ExtensionPrize as E, type GameConfig as G, type LeaderboardConfig as L, type PrizeAggregation as P, type QualificationEntry as Q, type Registration as R, type Schedule as S, type Tournament as T, type WSSubscribeOptions as W, type Prize as a, type PaginatedResult as b, type RewardClaim as c, type RewardClaimSummary as d, type TournamentListParams as e, type PlatformStats as f, type PrizeStats as g, type WSEventHandler as h, type TokenPrize as i, type PlayerPlacement as j, type Phase as k, type BudokanClientConfig as l, ConnectionStatus as m, type ConnectionStatusState as n, type Erc20Prize as o, type Erc721Prize as p, type LeaderboardEntry as q, type PlayerRewards as r, type WSChannel as s, type WSEventMessage as t, type WSMessage as u, type WSSubscribeMessage as v, type WSUnsubscribeMessage as w, createBudokanClient as x };
|
package/dist/react.cjs
CHANGED
|
@@ -199,12 +199,37 @@ function snakeToCamel(obj) {
|
|
|
199
199
|
return obj;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
// src/phase/index.ts
|
|
203
|
+
function tournamentPhase(t, nowSeconds) {
|
|
204
|
+
const createdAt = Number(t.createdAtOnchain ?? NaN);
|
|
205
|
+
if (!Number.isFinite(createdAt)) return null;
|
|
206
|
+
const regStartDelay = Number(t.registrationStartDelay ?? t.schedule?.registrationStartDelay ?? 0);
|
|
207
|
+
const regEndDelay = Number(t.registrationEndDelay ?? t.schedule?.registrationEndDelay ?? 0);
|
|
208
|
+
const gameStartDelay = Number(t.gameStartDelay ?? t.schedule?.gameStartDelay ?? 0);
|
|
209
|
+
const gameEndDelay = Number(t.gameEndDelay ?? t.schedule?.gameEndDelay ?? 0);
|
|
210
|
+
const submissionDuration = Number(t.submissionDuration ?? t.schedule?.submissionDuration ?? 0);
|
|
211
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
212
|
+
const hasReg = regStartDelay > 0 || regEndDelay > 0;
|
|
213
|
+
const regStart = createdAt + regStartDelay;
|
|
214
|
+
const regEnd = regStart + regEndDelay;
|
|
215
|
+
const gameStart = createdAt + gameStartDelay;
|
|
216
|
+
const gameEnd = gameStart + gameEndDelay;
|
|
217
|
+
const subEnd = gameEnd + submissionDuration;
|
|
218
|
+
if (hasReg && now < regStart) return "scheduled";
|
|
219
|
+
if (hasReg && now < regEnd) return "registration";
|
|
220
|
+
if (now < gameStart) return "staging";
|
|
221
|
+
if (now < gameEnd) return "live";
|
|
222
|
+
if (now < subEnd) return "submission";
|
|
223
|
+
return "finalized";
|
|
224
|
+
}
|
|
225
|
+
|
|
202
226
|
// src/api/tournaments.ts
|
|
203
227
|
function normalizeTournament(raw) {
|
|
204
228
|
const t = snakeToCamel(raw);
|
|
205
229
|
const id = t.id ?? t.tournamentId;
|
|
206
230
|
const protocolFeeShare = t.protocolFeeShare ?? t.entryFee?.protocolFeeShare ?? null;
|
|
207
|
-
|
|
231
|
+
const phase = t.phase ?? tournamentPhase(t);
|
|
232
|
+
return { ...t, id, tournamentId: id, protocolFeeShare, phase };
|
|
208
233
|
}
|
|
209
234
|
function fetchOpts(ctx) {
|
|
210
235
|
return {
|
|
@@ -529,7 +554,7 @@ var WSManager = class {
|
|
|
529
554
|
// src/chains/constants.ts
|
|
530
555
|
var CHAINS = {
|
|
531
556
|
mainnet: {
|
|
532
|
-
rpcUrl: "https://
|
|
557
|
+
rpcUrl: "https://rpc.provable.games/rpc",
|
|
533
558
|
apiBaseUrl: "https://budokan-api-production.up.railway.app",
|
|
534
559
|
wsUrl: "wss://budokan-api-production.up.railway.app/ws",
|
|
535
560
|
budokanAddress: "0x0596ced030e74ebc37f33607f07ecd5a62eff22cdc4ae31fe2d724040c1bdc0b",
|
|
@@ -929,6 +954,14 @@ function parseTournament(raw, entryCount, protocolFeeShare = null) {
|
|
|
929
954
|
entryFeeExtension,
|
|
930
955
|
entryRequirement,
|
|
931
956
|
leaderboardConfig: { ascending, gameMustBeOver },
|
|
957
|
+
phase: tournamentPhase({
|
|
958
|
+
createdAtOnchain: createdAtStr,
|
|
959
|
+
registrationStartDelay,
|
|
960
|
+
registrationEndDelay,
|
|
961
|
+
gameStartDelay,
|
|
962
|
+
gameEndDelay,
|
|
963
|
+
submissionDuration
|
|
964
|
+
}),
|
|
932
965
|
entryCount,
|
|
933
966
|
prizeCount: 0,
|
|
934
967
|
// Not available from viewer
|