@provable-games/budokan-sdk 0.1.8 → 0.1.9

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.
@@ -349,7 +349,7 @@ declare class BudokanClient {
349
349
  * Fetch a single tournament by its ID.
350
350
  * Supports RPC fallback when API is unavailable.
351
351
  */
352
- getTournament(tournamentId: string): Promise<Tournament>;
352
+ getTournament(tournamentId: string): Promise<Tournament | null>;
353
353
  /**
354
354
  * Fetch the leaderboard for a tournament.
355
355
  * Supports RPC fallback when API is unavailable.
@@ -349,7 +349,7 @@ declare class BudokanClient {
349
349
  * Fetch a single tournament by its ID.
350
350
  * Supports RPC fallback when API is unavailable.
351
351
  */
352
- getTournament(tournamentId: string): Promise<Tournament>;
352
+ getTournament(tournamentId: string): Promise<Tournament | null>;
353
353
  /**
354
354
  * Fetch the leaderboard for a tournament.
355
355
  * Supports RPC fallback when API is unavailable.
package/dist/index.cjs CHANGED
@@ -1124,7 +1124,9 @@ async function viewerTournamentsByPhase(contract, phase, offset, limit) {
1124
1124
  async function viewerTournamentDetail(contract, tournamentId) {
1125
1125
  return wrapRpcCall(async () => {
1126
1126
  const result = await contract.call("tournament_detail", [tournamentId]);
1127
- return parseTournamentFullState(result);
1127
+ const tournament = parseTournamentFullState(result);
1128
+ if (!tournament.gameAddress || tournament.gameAddress === "0x0") return null;
1129
+ return tournament;
1128
1130
  }, contract.address);
1129
1131
  }
1130
1132
  async function viewerTournamentsBatch(contract, tournamentIds) {
@@ -2533,11 +2535,16 @@ var BudokanClient = class {
2533
2535
  if (this.resolvedConfig.primarySource === "rpc") {
2534
2536
  return rpcFallback();
2535
2537
  }
2536
- return withFallback(
2537
- () => getTournament(this.resolvedConfig.apiBaseUrl, tournamentId, this.apiCtx),
2538
- rpcFallback,
2539
- this.connectionStatus
2540
- );
2538
+ try {
2539
+ return await getTournament(this.resolvedConfig.apiBaseUrl, tournamentId, this.apiCtx);
2540
+ } catch {
2541
+ try {
2542
+ this.connectionStatus.markApiUnavailable();
2543
+ return await rpcFallback();
2544
+ } catch {
2545
+ return null;
2546
+ }
2547
+ }
2541
2548
  }
2542
2549
  /**
2543
2550
  * Fetch the leaderboard for a tournament.