@provable-games/budokan-sdk 0.1.17 → 0.1.19

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.
@@ -100,6 +100,14 @@ interface TournamentListParams {
100
100
  sort?: "start_time" | "end_time" | "players" | "created_at";
101
101
  fromId?: string;
102
102
  excludeIds?: string[];
103
+ /**
104
+ * Restrict results to this set of tournament IDs. Used by the
105
+ * "My Tournaments" UX where the caller derives ids from currently-owned
106
+ * game tokens (denshokan-sdk) and asks Budokan only for those tournaments.
107
+ * Mutually exclusive with no-filter "show everything" semantics — an empty
108
+ * array yields zero results, not all tournaments.
109
+ */
110
+ tournamentIds?: string[];
103
111
  whitelistedExtensions?: string[];
104
112
  includePrizeSummary?: "summary" | boolean;
105
113
  }
@@ -227,7 +235,7 @@ interface PaginatedResult<T> {
227
235
  offset: number;
228
236
  }
229
237
 
230
- type WSChannel = "tournaments" | "registrations" | "leaderboards" | "prizes" | "rewards" | "metrics";
238
+ type WSChannel = "tournaments" | "registrations" | "prizes" | "rewards" | "metrics";
231
239
  interface WSSubscribeMessage {
232
240
  type: "subscribe";
233
241
  channels: WSChannel[];
@@ -387,8 +395,10 @@ declare class BudokanClient {
387
395
  */
388
396
  getTournamentDistributionShares(tournamentId: string): Promise<number[]>;
389
397
  /**
390
- * Fetch the leaderboard for a tournament.
391
- * Supports RPC fallback when API is unavailable.
398
+ * Fetch the leaderboard for a tournament from the on-chain viewer
399
+ * contract. Live leaderboard data for UIs is best sourced via
400
+ * denshokan-sdk's `useLiveLeaderboard`; this method is kept for
401
+ * one-shot RPC reads (e.g. server-side scoring scripts).
392
402
  */
393
403
  getTournamentLeaderboard(tournamentId: string): Promise<LeaderboardEntry[]>;
394
404
  /**
@@ -500,4 +510,4 @@ declare class BudokanClient {
500
510
  */
501
511
  declare function createBudokanClient(config: BudokanClientConfig): BudokanClient;
502
512
 
503
- export { type ActivityParams as A, BudokanClient as B, type ConnectionMode as C, type DataSource as D, type GameConfig as G, type LeaderboardEntry 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 PlayerStats as f, type PlayerTournamentParams as g, type PlayerTournament as h, type PlatformStats as i, type ActivityEvent as j, type PrizeStats as k, type WSEventHandler as l, type BudokanClientConfig as m, ConnectionStatus as n, type ConnectionStatusState as o, type LeaderboardConfig as p, type Phase as q, type WSChannel as r, type WSEventMessage as s, type WSMessage as t, type WSSubscribeMessage as u, type WSUnsubscribeMessage as v, createBudokanClient as w };
513
+ export { type ActivityParams as A, BudokanClient as B, type ConnectionMode as C, type DataSource as D, 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 PlayerStats as f, type PlayerTournamentParams as g, type PlayerTournament as h, type PlatformStats as i, type ActivityEvent as j, type PrizeStats as k, type WSEventHandler as l, type BudokanClientConfig as m, ConnectionStatus as n, type ConnectionStatusState as o, type LeaderboardEntry as p, type Phase as q, type WSChannel as r, type WSEventMessage as s, type WSMessage as t, type WSSubscribeMessage as u, type WSUnsubscribeMessage as v, createBudokanClient as w };
@@ -100,6 +100,14 @@ interface TournamentListParams {
100
100
  sort?: "start_time" | "end_time" | "players" | "created_at";
101
101
  fromId?: string;
102
102
  excludeIds?: string[];
103
+ /**
104
+ * Restrict results to this set of tournament IDs. Used by the
105
+ * "My Tournaments" UX where the caller derives ids from currently-owned
106
+ * game tokens (denshokan-sdk) and asks Budokan only for those tournaments.
107
+ * Mutually exclusive with no-filter "show everything" semantics — an empty
108
+ * array yields zero results, not all tournaments.
109
+ */
110
+ tournamentIds?: string[];
103
111
  whitelistedExtensions?: string[];
104
112
  includePrizeSummary?: "summary" | boolean;
105
113
  }
@@ -227,7 +235,7 @@ interface PaginatedResult<T> {
227
235
  offset: number;
228
236
  }
229
237
 
230
- type WSChannel = "tournaments" | "registrations" | "leaderboards" | "prizes" | "rewards" | "metrics";
238
+ type WSChannel = "tournaments" | "registrations" | "prizes" | "rewards" | "metrics";
231
239
  interface WSSubscribeMessage {
232
240
  type: "subscribe";
233
241
  channels: WSChannel[];
@@ -387,8 +395,10 @@ declare class BudokanClient {
387
395
  */
388
396
  getTournamentDistributionShares(tournamentId: string): Promise<number[]>;
389
397
  /**
390
- * Fetch the leaderboard for a tournament.
391
- * Supports RPC fallback when API is unavailable.
398
+ * Fetch the leaderboard for a tournament from the on-chain viewer
399
+ * contract. Live leaderboard data for UIs is best sourced via
400
+ * denshokan-sdk's `useLiveLeaderboard`; this method is kept for
401
+ * one-shot RPC reads (e.g. server-side scoring scripts).
392
402
  */
393
403
  getTournamentLeaderboard(tournamentId: string): Promise<LeaderboardEntry[]>;
394
404
  /**
@@ -500,4 +510,4 @@ declare class BudokanClient {
500
510
  */
501
511
  declare function createBudokanClient(config: BudokanClientConfig): BudokanClient;
502
512
 
503
- export { type ActivityParams as A, BudokanClient as B, type ConnectionMode as C, type DataSource as D, type GameConfig as G, type LeaderboardEntry 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 PlayerStats as f, type PlayerTournamentParams as g, type PlayerTournament as h, type PlatformStats as i, type ActivityEvent as j, type PrizeStats as k, type WSEventHandler as l, type BudokanClientConfig as m, ConnectionStatus as n, type ConnectionStatusState as o, type LeaderboardConfig as p, type Phase as q, type WSChannel as r, type WSEventMessage as s, type WSMessage as t, type WSSubscribeMessage as u, type WSUnsubscribeMessage as v, createBudokanClient as w };
513
+ export { type ActivityParams as A, BudokanClient as B, type ConnectionMode as C, type DataSource as D, 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 PlayerStats as f, type PlayerTournamentParams as g, type PlayerTournament as h, type PlatformStats as i, type ActivityEvent as j, type PrizeStats as k, type WSEventHandler as l, type BudokanClientConfig as m, ConnectionStatus as n, type ConnectionStatusState as o, type LeaderboardEntry as p, type Phase as q, type WSChannel as r, type WSEventMessage as s, type WSMessage as t, type WSSubscribeMessage as u, type WSUnsubscribeMessage as v, createBudokanClient as w };
package/dist/index.cjs CHANGED
@@ -233,6 +233,7 @@ async function getTournaments(baseUrl, params, ctx) {
233
233
  sort: params?.sort,
234
234
  from_id: params?.fromId,
235
235
  exclude_ids: params?.excludeIds?.join(","),
236
+ tournament_ids: params?.tournamentIds?.join(","),
236
237
  whitelisted_extensions: params?.whitelistedExtensions?.join(","),
237
238
  include_prizes: params?.includePrizeSummary
238
239
  });
@@ -252,13 +253,6 @@ async function getTournament(baseUrl, tournamentId, ctx) {
252
253
  );
253
254
  return normalizeTournament(result.data);
254
255
  }
255
- async function getTournamentLeaderboard(baseUrl, tournamentId, ctx) {
256
- const result = await apiFetch(
257
- `${baseUrl}/tournaments/${tournamentId}/leaderboard`,
258
- fetchOpts(ctx)
259
- );
260
- return result.data.map((item) => snakeToCamel(item));
261
- }
262
256
  async function getTournamentRegistrations(baseUrl, tournamentId, params, ctx) {
263
257
  const qs = buildQueryString({
264
258
  player_address: params?.playerAddress,
@@ -600,15 +594,15 @@ var CHAINS = {
600
594
  rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet/rpc/v0_10",
601
595
  apiBaseUrl: "https://budokan-api-production.up.railway.app",
602
596
  wsUrl: "wss://budokan-api-production.up.railway.app/ws",
603
- budokanAddress: "0x00f4941e73cc38f67f79ae1f7cdae48f28ca5a6c0e013f6136818e777f61c6ee",
604
- viewerAddress: "0x027c264f4417dfd25d0626bce7304e9b3140ab06afeaf639b2678d2a05f1beb3"
597
+ budokanAddress: "0x0596ced030e74ebc37f33607f07ecd5a62eff22cdc4ae31fe2d724040c1bdc0b",
598
+ viewerAddress: "0x013c8239361fdbd7ec26db2c83f4ff270c5bba83a0bc105b4005b676ff57fdbe"
605
599
  },
606
600
  sepolia: {
607
601
  rpcUrl: "https://starknet-sepolia.public.blastapi.io",
608
602
  apiBaseUrl: "https://budokan-api-sepolia.up.railway.app",
609
603
  wsUrl: "wss://budokan-api-sepolia.up.railway.app/ws",
610
- budokanAddress: "0x0169083e63f3caff2c15f83eb238b1f4ab8f74903c0e6b5d433b448972c578d4",
611
- viewerAddress: "0x02cc4473948170cf42c2f3abc6391fd4401650375ee8e4661b7b6966cda4f15e"
604
+ budokanAddress: "0x017750a167b7c4968249d7db06dccc8b3908ef8954cb40cfe4d3c651ca0dcd1d",
605
+ viewerAddress: "0x03d5febe0042b943967074f4ebd850a6b5d50850cd3fb84fbd0eb66dadd9ddec"
612
606
  }
613
607
  };
614
608
  function getChainConfig(chain) {
@@ -4510,22 +4504,14 @@ var BudokanClient = class {
4510
4504
  return budokanTournamentDistributionShares(contract, tournamentId);
4511
4505
  }
4512
4506
  /**
4513
- * Fetch the leaderboard for a tournament.
4514
- * Supports RPC fallback when API is unavailable.
4507
+ * Fetch the leaderboard for a tournament from the on-chain viewer
4508
+ * contract. Live leaderboard data for UIs is best sourced via
4509
+ * denshokan-sdk's `useLiveLeaderboard`; this method is kept for
4510
+ * one-shot RPC reads (e.g. server-side scoring scripts).
4515
4511
  */
4516
4512
  async getTournamentLeaderboard(tournamentId) {
4517
- const rpcFallback = async () => {
4518
- const contract = await this.getViewerContract();
4519
- return viewerLeaderboard(contract, tournamentId, 0, 1e3);
4520
- };
4521
- if (this.resolvedConfig.primarySource === "rpc") {
4522
- return rpcFallback();
4523
- }
4524
- return withFallback(
4525
- () => getTournamentLeaderboard(this.resolvedConfig.apiBaseUrl, tournamentId, this.apiCtx),
4526
- rpcFallback,
4527
- this.connectionStatus
4528
- );
4513
+ const contract = await this.getViewerContract();
4514
+ return viewerLeaderboard(contract, tournamentId, 0, 1e3);
4529
4515
  }
4530
4516
  /**
4531
4517
  * Fetch registrations for a tournament.
@@ -4791,7 +4777,6 @@ exports.getPlayerStats = getPlayerStats;
4791
4777
  exports.getPlayerTournaments = getPlayerTournaments;
4792
4778
  exports.getPrizeStats = getPrizeStats;
4793
4779
  exports.getTournament = getTournament;
4794
- exports.getTournamentLeaderboard = getTournamentLeaderboard;
4795
4780
  exports.getTournamentPrizeAggregation = getTournamentPrizeAggregation;
4796
4781
  exports.getTournamentPrizes = getTournamentPrizes;
4797
4782
  exports.getTournamentQualifications = getTournamentQualifications;