@provable-games/budokan-sdk 0.1.19 → 0.1.21

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,37 +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
- interface ActivityEvent {
200
- id: string;
201
- eventType: string;
202
- tournamentId: string | null;
203
- playerAddress: string | null;
204
- data: Record<string, unknown>;
205
- blockNumber: string;
206
- txHash: string;
207
- eventIndex: number;
208
- }
209
- interface ActivityParams {
210
- eventType?: string;
211
- tournamentId?: string;
212
- playerAddress?: string;
213
- limit?: number;
214
- offset?: number;
215
- }
216
194
  interface PlatformStats {
217
195
  totalTournaments: number;
218
196
  totalPrizes: number;
@@ -409,7 +387,6 @@ declare class BudokanClient {
409
387
  * are applied via on-chain viewer functions where supported.
410
388
  */
411
389
  getTournamentRegistrations(tournamentId: string, params?: {
412
- playerAddress?: string;
413
390
  gameTokenIds?: string[];
414
391
  hasSubmitted?: boolean;
415
392
  isBanned?: boolean;
@@ -421,16 +398,6 @@ declare class BudokanClient {
421
398
  * Supports RPC fallback when API is unavailable.
422
399
  */
423
400
  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
401
  /**
435
402
  * Fetch tournaments for a specific game.
436
403
  * Supports RPC fallback when API is unavailable.
@@ -467,11 +434,6 @@ declare class BudokanClient {
467
434
  * API-only -- no RPC fallback available.
468
435
  */
469
436
  getTournamentPrizeAggregation(tournamentId: string): Promise<PrizeAggregation[]>;
470
- /**
471
- * Fetch activity events with optional filtering.
472
- * API-only — no RPC fallback available.
473
- */
474
- getActivity(params?: ActivityParams): Promise<PaginatedResult<ActivityEvent>>;
475
437
  /**
476
438
  * Fetch platform-wide activity stats.
477
439
  * API-only — no RPC fallback available.
@@ -510,4 +472,4 @@ declare class BudokanClient {
510
472
  */
511
473
  declare function createBudokanClient(config: BudokanClientConfig): BudokanClient;
512
474
 
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 };
475
+ export { 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 PrizeStats as g, type WSEventHandler as h, type BudokanClientConfig as i, ConnectionStatus as j, type ConnectionStatusState as k, type LeaderboardEntry as l, type Phase as m, type WSChannel as n, type WSEventMessage as o, type WSMessage as p, type WSSubscribeMessage as q, type WSUnsubscribeMessage as r, createBudokanClient as s };
@@ -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,37 +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
- interface ActivityEvent {
200
- id: string;
201
- eventType: string;
202
- tournamentId: string | null;
203
- playerAddress: string | null;
204
- data: Record<string, unknown>;
205
- blockNumber: string;
206
- txHash: string;
207
- eventIndex: number;
208
- }
209
- interface ActivityParams {
210
- eventType?: string;
211
- tournamentId?: string;
212
- playerAddress?: string;
213
- limit?: number;
214
- offset?: number;
215
- }
216
194
  interface PlatformStats {
217
195
  totalTournaments: number;
218
196
  totalPrizes: number;
@@ -409,7 +387,6 @@ declare class BudokanClient {
409
387
  * are applied via on-chain viewer functions where supported.
410
388
  */
411
389
  getTournamentRegistrations(tournamentId: string, params?: {
412
- playerAddress?: string;
413
390
  gameTokenIds?: string[];
414
391
  hasSubmitted?: boolean;
415
392
  isBanned?: boolean;
@@ -421,16 +398,6 @@ declare class BudokanClient {
421
398
  * Supports RPC fallback when API is unavailable.
422
399
  */
423
400
  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
401
  /**
435
402
  * Fetch tournaments for a specific game.
436
403
  * Supports RPC fallback when API is unavailable.
@@ -467,11 +434,6 @@ declare class BudokanClient {
467
434
  * API-only -- no RPC fallback available.
468
435
  */
469
436
  getTournamentPrizeAggregation(tournamentId: string): Promise<PrizeAggregation[]>;
470
- /**
471
- * Fetch activity events with optional filtering.
472
- * API-only — no RPC fallback available.
473
- */
474
- getActivity(params?: ActivityParams): Promise<PaginatedResult<ActivityEvent>>;
475
437
  /**
476
438
  * Fetch platform-wide activity stats.
477
439
  * API-only — no RPC fallback available.
@@ -510,4 +472,4 @@ declare class BudokanClient {
510
472
  */
511
473
  declare function createBudokanClient(config: BudokanClientConfig): BudokanClient;
512
474
 
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 };
475
+ export { 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 PrizeStats as g, type WSEventHandler as h, type BudokanClientConfig as i, ConnectionStatus as j, type ConnectionStatusState as k, type LeaderboardEntry as l, type Phase as m, type WSChannel as n, type WSEventMessage as o, type WSMessage as p, type WSSubscribeMessage as q, type WSUnsubscribeMessage as r, createBudokanClient as s };
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,47 +356,30 @@ 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,
404
369
  timeout: ctx?.timeout
405
370
  };
406
371
  }
407
- async function getActivity(baseUrl, params, ctx) {
408
- const qs = buildQueryString({
409
- event_type: params?.eventType,
410
- tournament_id: params?.tournamentId,
411
- player_address: params?.playerAddress,
412
- limit: params?.limit,
413
- offset: params?.offset
414
- });
415
- const result = await apiFetch(`${baseUrl}/activity${qs}`, fetchOpts4(ctx));
416
- const { total, limit: resLimit, offset: resOffset } = extractPagination(result, { limit: params?.limit, offset: params?.offset });
417
- return {
418
- data: result.data.map((item) => snakeToCamel(item)),
419
- total,
420
- limit: resLimit,
421
- offset: resOffset
422
- };
423
- }
424
372
  async function getActivityStats(baseUrl, ctx) {
425
373
  const result = await apiFetch(
426
374
  `${baseUrl}/activity/stats`,
427
- fetchOpts4(ctx)
375
+ fetchOpts3(ctx)
428
376
  );
429
377
  return snakeToCamel(result.data);
430
378
  }
431
379
  async function getPrizeStats(baseUrl, ctx) {
432
380
  const result = await apiFetch(
433
381
  `${baseUrl}/activity/prize-stats`,
434
- fetchOpts4(ctx)
382
+ fetchOpts3(ctx)
435
383
  );
436
384
  return snakeToCamel(result.data);
437
385
  }
@@ -993,8 +941,6 @@ function parseRegistration(raw, tournamentId) {
993
941
  gameTokenId: starknet.num.toHex(obj.game_token_id),
994
942
  gameAddress: "",
995
943
  // Not in on-chain struct
996
- playerAddress: "",
997
- // Not in on-chain struct
998
944
  entryNumber: Number(obj.entry_id ?? 0),
999
945
  hasSubmitted: Boolean(obj.has_submitted),
1000
946
  isBanned: Boolean(obj.is_banned)
@@ -1153,20 +1099,6 @@ async function viewerRegistrations(contract, tournamentId, offset, limit) {
1153
1099
  };
1154
1100
  }, contract.address);
1155
1101
  }
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
1102
  async function viewerRegistrationsByTokenIds(contract, tournamentId, tokenIds, offset, limit) {
1171
1103
  return wrapRpcCall(async () => {
1172
1104
  const result = await contract.call("tournament_registrations_by_token_ids", [tournamentId, tokenIds, offset, limit]);
@@ -1212,12 +1144,6 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1212
1144
  };
1213
1145
  }, contract.address);
1214
1146
  }
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
1147
 
1222
1148
  // src/rpc/abis/budokanViewer.json
1223
1149
  var budokanViewer_default = [
@@ -4525,9 +4451,6 @@ var BudokanClient = class {
4525
4451
  const contract = await this.getViewerContract();
4526
4452
  const offset = params?.offset ?? 0;
4527
4453
  const limit = params?.limit ?? 20;
4528
- if (params?.playerAddress) {
4529
- return viewerRegistrationsByOwner(contract, tournamentId, params.playerAddress, offset, limit);
4530
- }
4531
4454
  if (params?.gameTokenIds?.length) {
4532
4455
  return viewerRegistrationsByTokenIds(contract, tournamentId, params.gameTokenIds, offset, limit);
4533
4456
  }
@@ -4560,43 +4483,6 @@ var BudokanClient = class {
4560
4483
  this.connectionStatus
4561
4484
  );
4562
4485
  }
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
4486
  // ---- Game Queries ----
4601
4487
  /**
4602
4488
  * Fetch tournaments for a specific game.
@@ -4695,13 +4581,6 @@ var BudokanClient = class {
4695
4581
  return getTournamentPrizeAggregation(this.resolvedConfig.apiBaseUrl, tournamentId, this.apiCtx);
4696
4582
  }
4697
4583
  // ---- Activity Queries (API-only, activity is indexed) ----
4698
- /**
4699
- * Fetch activity events with optional filtering.
4700
- * API-only — no RPC fallback available.
4701
- */
4702
- async getActivity(params) {
4703
- return getActivity(this.resolvedConfig.apiBaseUrl, params, this.apiCtx);
4704
- }
4705
4584
  /**
4706
4585
  * Fetch platform-wide activity stats.
4707
4586
  * API-only — no RPC fallback available.
@@ -4768,13 +4647,10 @@ exports.TournamentNotFoundError = TournamentNotFoundError;
4768
4647
  exports.WSManager = WSManager;
4769
4648
  exports.camelToSnake = camelToSnake;
4770
4649
  exports.createBudokanClient = createBudokanClient;
4771
- exports.getActivity = getActivity;
4772
4650
  exports.getActivityStats = getActivityStats;
4773
4651
  exports.getChainConfig = getChainConfig;
4774
4652
  exports.getGameStats = getGameStats;
4775
4653
  exports.getGameTournaments = getGameTournaments;
4776
- exports.getPlayerStats = getPlayerStats;
4777
- exports.getPlayerTournaments = getPlayerTournaments;
4778
4654
  exports.getPrizeStats = getPrizeStats;
4779
4655
  exports.getTournament = getTournament;
4780
4656
  exports.getTournamentPrizeAggregation = getTournamentPrizeAggregation;