@provable-games/budokan-sdk 0.1.19 → 0.1.20

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.
@@ -122,11 +122,20 @@ interface LeaderboardEntry {
122
122
  tokenId: string;
123
123
  }
124
124
 
125
+ /**
126
+ * A registration row keyed by (tournamentId, gameTokenId).
127
+ *
128
+ * Note: there is intentionally no `playerAddress` field. The contract keys
129
+ * registrations by token id only — once the underlying NFT transfers, any
130
+ * stored "registrant" address is the wrong signal for current ownership.
131
+ * Callers that need the current owner of an entry should resolve it via
132
+ * `denshokan-sdk.useTokens` (filtering by minterAddress + contextId).
133
+ * See Provable-Games/budokan#241.
134
+ */
125
135
  interface Registration {
126
136
  tournamentId: string;
127
137
  gameTokenId: string;
128
138
  gameAddress: string;
129
- playerAddress: string;
130
139
  entryNumber: number;
131
140
  hasSubmitted: boolean;
132
141
  isBanned: boolean;
@@ -182,20 +191,6 @@ interface RewardClaimSummary {
182
191
  totalUnclaimed: number;
183
192
  }
184
193
 
185
- interface PlayerStats {
186
- totalTournaments: number;
187
- totalSubmissions: number;
188
- }
189
- interface PlayerTournament extends Tournament {
190
- registration: Registration;
191
- }
192
- interface PlayerTournamentParams {
193
- phase?: Phase;
194
- gameTokenIds?: string[];
195
- limit?: number;
196
- offset?: number;
197
- }
198
-
199
194
  interface ActivityEvent {
200
195
  id: string;
201
196
  eventType: string;
@@ -409,7 +404,6 @@ declare class BudokanClient {
409
404
  * are applied via on-chain viewer functions where supported.
410
405
  */
411
406
  getTournamentRegistrations(tournamentId: string, params?: {
412
- playerAddress?: string;
413
407
  gameTokenIds?: string[];
414
408
  hasSubmitted?: boolean;
415
409
  isBanned?: boolean;
@@ -421,16 +415,6 @@ declare class BudokanClient {
421
415
  * Supports RPC fallback when API is unavailable.
422
416
  */
423
417
  getTournamentPrizes(tournamentId: string): Promise<Prize[]>;
424
- /**
425
- * Fetch tournaments that a player has registered for.
426
- * Supports RPC fallback via viewer contract.
427
- */
428
- getPlayerTournaments(address: string, params?: PlayerTournamentParams): Promise<PaginatedResult<PlayerTournament>>;
429
- /**
430
- * Fetch stats for a player.
431
- * API-only — no RPC fallback available.
432
- */
433
- getPlayerStats(address: string): Promise<PlayerStats>;
434
418
  /**
435
419
  * Fetch tournaments for a specific game.
436
420
  * Supports RPC fallback when API is unavailable.
@@ -510,4 +494,4 @@ declare class BudokanClient {
510
494
  */
511
495
  declare function createBudokanClient(config: BudokanClientConfig): BudokanClient;
512
496
 
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 };
497
+ 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 PlatformStats as f, type ActivityEvent as g, type PrizeStats as h, type WSEventHandler as i, type BudokanClientConfig as j, ConnectionStatus as k, type ConnectionStatusState as l, type LeaderboardEntry as m, type Phase as n, type WSChannel as o, type WSEventMessage as p, type WSMessage as q, type WSSubscribeMessage as r, type WSUnsubscribeMessage as s, createBudokanClient as t };
@@ -122,11 +122,20 @@ interface LeaderboardEntry {
122
122
  tokenId: string;
123
123
  }
124
124
 
125
+ /**
126
+ * A registration row keyed by (tournamentId, gameTokenId).
127
+ *
128
+ * Note: there is intentionally no `playerAddress` field. The contract keys
129
+ * registrations by token id only — once the underlying NFT transfers, any
130
+ * stored "registrant" address is the wrong signal for current ownership.
131
+ * Callers that need the current owner of an entry should resolve it via
132
+ * `denshokan-sdk.useTokens` (filtering by minterAddress + contextId).
133
+ * See Provable-Games/budokan#241.
134
+ */
125
135
  interface Registration {
126
136
  tournamentId: string;
127
137
  gameTokenId: string;
128
138
  gameAddress: string;
129
- playerAddress: string;
130
139
  entryNumber: number;
131
140
  hasSubmitted: boolean;
132
141
  isBanned: boolean;
@@ -182,20 +191,6 @@ interface RewardClaimSummary {
182
191
  totalUnclaimed: number;
183
192
  }
184
193
 
185
- interface PlayerStats {
186
- totalTournaments: number;
187
- totalSubmissions: number;
188
- }
189
- interface PlayerTournament extends Tournament {
190
- registration: Registration;
191
- }
192
- interface PlayerTournamentParams {
193
- phase?: Phase;
194
- gameTokenIds?: string[];
195
- limit?: number;
196
- offset?: number;
197
- }
198
-
199
194
  interface ActivityEvent {
200
195
  id: string;
201
196
  eventType: string;
@@ -409,7 +404,6 @@ declare class BudokanClient {
409
404
  * are applied via on-chain viewer functions where supported.
410
405
  */
411
406
  getTournamentRegistrations(tournamentId: string, params?: {
412
- playerAddress?: string;
413
407
  gameTokenIds?: string[];
414
408
  hasSubmitted?: boolean;
415
409
  isBanned?: boolean;
@@ -421,16 +415,6 @@ declare class BudokanClient {
421
415
  * Supports RPC fallback when API is unavailable.
422
416
  */
423
417
  getTournamentPrizes(tournamentId: string): Promise<Prize[]>;
424
- /**
425
- * Fetch tournaments that a player has registered for.
426
- * Supports RPC fallback via viewer contract.
427
- */
428
- getPlayerTournaments(address: string, params?: PlayerTournamentParams): Promise<PaginatedResult<PlayerTournament>>;
429
- /**
430
- * Fetch stats for a player.
431
- * API-only — no RPC fallback available.
432
- */
433
- getPlayerStats(address: string): Promise<PlayerStats>;
434
418
  /**
435
419
  * Fetch tournaments for a specific game.
436
420
  * Supports RPC fallback when API is unavailable.
@@ -510,4 +494,4 @@ declare class BudokanClient {
510
494
  */
511
495
  declare function createBudokanClient(config: BudokanClientConfig): BudokanClient;
512
496
 
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 };
497
+ 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 PlatformStats as f, type ActivityEvent as g, type PrizeStats as h, type WSEventHandler as i, type BudokanClientConfig as j, ConnectionStatus as k, type ConnectionStatusState as l, type LeaderboardEntry as m, type Phase as n, type WSChannel as o, type WSEventMessage as p, type WSMessage as q, type WSSubscribeMessage as r, type WSUnsubscribeMessage as s, createBudokanClient as t };
package/dist/index.cjs CHANGED
@@ -255,7 +255,6 @@ async function getTournament(baseUrl, tournamentId, ctx) {
255
255
  }
256
256
  async function getTournamentRegistrations(baseUrl, tournamentId, params, ctx) {
257
257
  const qs = buildQueryString({
258
- player_address: params?.playerAddress,
259
258
  game_token_ids: params?.gameTokenIds?.length ? params.gameTokenIds.join(",") : void 0,
260
259
  has_submitted: params?.hasSubmitted,
261
260
  is_banned: params?.isBanned,
@@ -328,42 +327,8 @@ function normalizeAddress(address) {
328
327
  return ("0x" + stripped.padStart(64, "0")).toLowerCase();
329
328
  }
330
329
 
331
- // src/api/players.ts
332
- function fetchOpts2(ctx) {
333
- return {
334
- retryAttempts: ctx?.retryAttempts,
335
- retryDelay: ctx?.retryDelay,
336
- timeout: ctx?.timeout
337
- };
338
- }
339
- async function getPlayerTournaments(baseUrl, address, params, ctx) {
340
- const normalized = normalizeAddress(address);
341
- const qs = buildQueryString({
342
- limit: params?.limit,
343
- offset: params?.offset,
344
- phase: params?.phase,
345
- game_token_ids: params?.gameTokenIds?.join(",")
346
- });
347
- const result = await apiFetch(`${baseUrl}/players/${normalized}/tournaments${qs}`, fetchOpts2(ctx));
348
- const { total, limit: resLimit, offset: resOffset } = extractPagination(result, { limit: params?.limit, offset: params?.offset });
349
- return {
350
- data: result.data.map((item) => snakeToCamel(item)),
351
- total,
352
- limit: resLimit,
353
- offset: resOffset
354
- };
355
- }
356
- async function getPlayerStats(baseUrl, address, ctx) {
357
- const normalized = normalizeAddress(address);
358
- const result = await apiFetch(
359
- `${baseUrl}/players/${normalized}/stats`,
360
- fetchOpts2(ctx)
361
- );
362
- return snakeToCamel(result.data);
363
- }
364
-
365
330
  // src/api/games.ts
366
- function fetchOpts3(ctx) {
331
+ function fetchOpts2(ctx) {
367
332
  return {
368
333
  retryAttempts: ctx?.retryAttempts,
369
334
  retryDelay: ctx?.retryDelay,
@@ -378,7 +343,7 @@ async function getGameTournaments(baseUrl, gameAddress, params, ctx) {
378
343
  limit: params?.limit,
379
344
  offset: params?.offset
380
345
  });
381
- const result = await apiFetch(`${baseUrl}/games/${normalized}/tournaments${qs}`, fetchOpts3(ctx));
346
+ const result = await apiFetch(`${baseUrl}/games/${normalized}/tournaments${qs}`, fetchOpts2(ctx));
382
347
  const { total, limit: resLimit, offset: resOffset } = extractPagination(result, { limit: params?.limit, offset: params?.offset });
383
348
  return {
384
349
  data: result.data.map((item) => snakeToCamel(item)),
@@ -391,13 +356,13 @@ async function getGameStats(baseUrl, gameAddress, ctx) {
391
356
  const normalized = normalizeAddress(gameAddress);
392
357
  const result = await apiFetch(
393
358
  `${baseUrl}/games/${normalized}/stats`,
394
- fetchOpts3(ctx)
359
+ fetchOpts2(ctx)
395
360
  );
396
361
  return snakeToCamel(result.data);
397
362
  }
398
363
 
399
364
  // src/api/activity.ts
400
- function fetchOpts4(ctx) {
365
+ function fetchOpts3(ctx) {
401
366
  return {
402
367
  retryAttempts: ctx?.retryAttempts,
403
368
  retryDelay: ctx?.retryDelay,
@@ -412,7 +377,7 @@ async function getActivity(baseUrl, params, ctx) {
412
377
  limit: params?.limit,
413
378
  offset: params?.offset
414
379
  });
415
- const result = await apiFetch(`${baseUrl}/activity${qs}`, fetchOpts4(ctx));
380
+ const result = await apiFetch(`${baseUrl}/activity${qs}`, fetchOpts3(ctx));
416
381
  const { total, limit: resLimit, offset: resOffset } = extractPagination(result, { limit: params?.limit, offset: params?.offset });
417
382
  return {
418
383
  data: result.data.map((item) => snakeToCamel(item)),
@@ -424,14 +389,14 @@ async function getActivity(baseUrl, params, ctx) {
424
389
  async function getActivityStats(baseUrl, ctx) {
425
390
  const result = await apiFetch(
426
391
  `${baseUrl}/activity/stats`,
427
- fetchOpts4(ctx)
392
+ fetchOpts3(ctx)
428
393
  );
429
394
  return snakeToCamel(result.data);
430
395
  }
431
396
  async function getPrizeStats(baseUrl, ctx) {
432
397
  const result = await apiFetch(
433
398
  `${baseUrl}/activity/prize-stats`,
434
- fetchOpts4(ctx)
399
+ fetchOpts3(ctx)
435
400
  );
436
401
  return snakeToCamel(result.data);
437
402
  }
@@ -993,8 +958,6 @@ function parseRegistration(raw, tournamentId) {
993
958
  gameTokenId: starknet.num.toHex(obj.game_token_id),
994
959
  gameAddress: "",
995
960
  // Not in on-chain struct
996
- playerAddress: "",
997
- // Not in on-chain struct
998
961
  entryNumber: Number(obj.entry_id ?? 0),
999
962
  hasSubmitted: Boolean(obj.has_submitted),
1000
963
  isBanned: Boolean(obj.is_banned)
@@ -1153,20 +1116,6 @@ async function viewerRegistrations(contract, tournamentId, offset, limit) {
1153
1116
  };
1154
1117
  }, contract.address);
1155
1118
  }
1156
- async function viewerRegistrationsByOwner(contract, tournamentId, owner, offset, limit) {
1157
- return wrapRpcCall(async () => {
1158
- const result = await contract.call("tournament_registrations_by_owner", [tournamentId, owner, offset, limit]);
1159
- const obj = result;
1160
- const entries = obj.entries ?? [];
1161
- const total = Number(obj.total ?? 0);
1162
- return {
1163
- data: entries.map((e) => parseRegistration(e, tournamentId)),
1164
- total,
1165
- limit,
1166
- offset
1167
- };
1168
- }, contract.address);
1169
- }
1170
1119
  async function viewerRegistrationsByTokenIds(contract, tournamentId, tokenIds, offset, limit) {
1171
1120
  return wrapRpcCall(async () => {
1172
1121
  const result = await contract.call("tournament_registrations_by_token_ids", [tournamentId, tokenIds, offset, limit]);
@@ -1212,12 +1161,6 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1212
1161
  };
1213
1162
  }, contract.address);
1214
1163
  }
1215
- async function viewerPlayerTournaments(contract, playerAddress, offset, limit) {
1216
- return wrapRpcCall(async () => {
1217
- const result = await contract.call("player_tournaments", [playerAddress, offset, limit]);
1218
- return parseFilterResult(result);
1219
- }, contract.address);
1220
- }
1221
1164
 
1222
1165
  // src/rpc/abis/budokanViewer.json
1223
1166
  var budokanViewer_default = [
@@ -4525,9 +4468,6 @@ var BudokanClient = class {
4525
4468
  const contract = await this.getViewerContract();
4526
4469
  const offset = params?.offset ?? 0;
4527
4470
  const limit = params?.limit ?? 20;
4528
- if (params?.playerAddress) {
4529
- return viewerRegistrationsByOwner(contract, tournamentId, params.playerAddress, offset, limit);
4530
- }
4531
4471
  if (params?.gameTokenIds?.length) {
4532
4472
  return viewerRegistrationsByTokenIds(contract, tournamentId, params.gameTokenIds, offset, limit);
4533
4473
  }
@@ -4560,43 +4500,6 @@ var BudokanClient = class {
4560
4500
  this.connectionStatus
4561
4501
  );
4562
4502
  }
4563
- // ---- Player Queries (API-only, no on-chain equivalent) ----
4564
- /**
4565
- * Fetch tournaments that a player has registered for.
4566
- * Supports RPC fallback via viewer contract.
4567
- */
4568
- async getPlayerTournaments(address, params) {
4569
- const rpcFallback = async () => {
4570
- const contract = await this.getViewerContract();
4571
- const offset = params?.offset ?? 0;
4572
- const limit = params?.limit ?? 20;
4573
- const filterResult = await viewerPlayerTournaments(contract, address, offset, limit);
4574
- let data = [];
4575
- if (filterResult.tournamentIds.length > 0) {
4576
- const tournaments = await viewerTournamentsBatch(contract, filterResult.tournamentIds);
4577
- data = tournaments.map((t) => ({
4578
- ...t,
4579
- tournamentId: t.id
4580
- }));
4581
- }
4582
- return { data, total: filterResult.total, limit, offset };
4583
- };
4584
- if (this.resolvedConfig.primarySource === "rpc") {
4585
- return rpcFallback();
4586
- }
4587
- return withFallback(
4588
- () => getPlayerTournaments(this.resolvedConfig.apiBaseUrl, address, params, this.apiCtx),
4589
- rpcFallback,
4590
- this.connectionStatus
4591
- );
4592
- }
4593
- /**
4594
- * Fetch stats for a player.
4595
- * API-only — no RPC fallback available.
4596
- */
4597
- async getPlayerStats(address) {
4598
- return getPlayerStats(this.resolvedConfig.apiBaseUrl, address, this.apiCtx);
4599
- }
4600
4503
  // ---- Game Queries ----
4601
4504
  /**
4602
4505
  * Fetch tournaments for a specific game.
@@ -4773,8 +4676,6 @@ exports.getActivityStats = getActivityStats;
4773
4676
  exports.getChainConfig = getChainConfig;
4774
4677
  exports.getGameStats = getGameStats;
4775
4678
  exports.getGameTournaments = getGameTournaments;
4776
- exports.getPlayerStats = getPlayerStats;
4777
- exports.getPlayerTournaments = getPlayerTournaments;
4778
4679
  exports.getPrizeStats = getPrizeStats;
4779
4680
  exports.getTournament = getTournament;
4780
4681
  exports.getTournamentPrizeAggregation = getTournamentPrizeAggregation;