@provable-games/budokan-sdk 0.1.9 → 0.1.11

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.
@@ -358,9 +358,15 @@ declare class BudokanClient {
358
358
  /**
359
359
  * Fetch registrations for a tournament.
360
360
  * Supports RPC fallback when API is unavailable.
361
- * Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings.
361
+ * Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings,
362
+ * and filter params (`playerAddress`, `gameTokenIds`, `hasSubmitted`, `isBanned`)
363
+ * are applied via on-chain viewer functions where supported.
362
364
  */
363
365
  getTournamentRegistrations(tournamentId: string, params?: {
366
+ playerAddress?: string;
367
+ gameTokenIds?: string[];
368
+ hasSubmitted?: boolean;
369
+ isBanned?: boolean;
364
370
  limit?: number;
365
371
  offset?: number;
366
372
  }): Promise<PaginatedResult<Registration>>;
@@ -358,9 +358,15 @@ declare class BudokanClient {
358
358
  /**
359
359
  * Fetch registrations for a tournament.
360
360
  * Supports RPC fallback when API is unavailable.
361
- * Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings.
361
+ * Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings,
362
+ * and filter params (`playerAddress`, `gameTokenIds`, `hasSubmitted`, `isBanned`)
363
+ * are applied via on-chain viewer functions where supported.
362
364
  */
363
365
  getTournamentRegistrations(tournamentId: string, params?: {
366
+ playerAddress?: string;
367
+ gameTokenIds?: string[];
368
+ hasSubmitted?: boolean;
369
+ isBanned?: boolean;
364
370
  limit?: number;
365
371
  offset?: number;
366
372
  }): Promise<PaginatedResult<Registration>>;
package/dist/index.cjs CHANGED
@@ -261,6 +261,10 @@ async function getTournamentLeaderboard(baseUrl, tournamentId, ctx) {
261
261
  }
262
262
  async function getTournamentRegistrations(baseUrl, tournamentId, params, ctx) {
263
263
  const qs = buildQueryString({
264
+ player_address: params?.playerAddress,
265
+ game_token_ids: params?.gameTokenIds?.length ? params.gameTokenIds.join(",") : void 0,
266
+ has_submitted: params?.hasSubmitted,
267
+ is_banned: params?.isBanned,
264
268
  limit: params?.limit,
265
269
  offset: params?.offset
266
270
  });
@@ -596,8 +600,8 @@ var CHAINS = {
596
600
  rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet/rpc/v0_10",
597
601
  apiBaseUrl: "https://budokan-api-production.up.railway.app",
598
602
  wsUrl: "wss://budokan-api-production.up.railway.app/ws",
599
- budokanAddress: "0x020239968a74f3e190d1b5aa0c6316845062a00cb98f787d661fd4aa860553de",
600
- viewerAddress: "0x00ace1cce7933fbf0d7a2f32c3b5d4c36e63462f81c7845b6d7ac5d8dbdbefa4"
603
+ budokanAddress: "0x04dae41808911e51af8efe8ac3202cb3b2a32c10c169703010b7e0cbd885bf83",
604
+ viewerAddress: "0x02ef405cf2a8e8aec2946e5be39fa4e8bcb51cea5ce3573760418e7cdc7e5a22"
601
605
  },
602
606
  sepolia: {
603
607
  rpcUrl: "https://starknet-sepolia.public.blastapi.io",
@@ -1149,6 +1153,34 @@ async function viewerRegistrations(contract, tournamentId, offset, limit) {
1149
1153
  };
1150
1154
  }, contract.address);
1151
1155
  }
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
+ async function viewerRegistrationsByTokenIds(contract, tournamentId, tokenIds, offset, limit) {
1171
+ return wrapRpcCall(async () => {
1172
+ const result = await contract.call("tournament_registrations_by_token_ids", [tournamentId, tokenIds, offset, limit]);
1173
+ const obj = result;
1174
+ const entries = obj.entries ?? [];
1175
+ const total = Number(obj.total ?? 0);
1176
+ return {
1177
+ data: entries.map((e) => parseRegistration(e, tournamentId)),
1178
+ total,
1179
+ limit,
1180
+ offset
1181
+ };
1182
+ }, contract.address);
1183
+ }
1152
1184
  async function viewerLeaderboard(contract, tournamentId, offset, limit) {
1153
1185
  return wrapRpcCall(async () => {
1154
1186
  const result = await contract.call("leaderboard", [tournamentId, offset, limit]);
@@ -2567,13 +2599,21 @@ var BudokanClient = class {
2567
2599
  /**
2568
2600
  * Fetch registrations for a tournament.
2569
2601
  * Supports RPC fallback when API is unavailable.
2570
- * Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings.
2602
+ * Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings,
2603
+ * and filter params (`playerAddress`, `gameTokenIds`, `hasSubmitted`, `isBanned`)
2604
+ * are applied via on-chain viewer functions where supported.
2571
2605
  */
2572
2606
  async getTournamentRegistrations(tournamentId, params) {
2573
2607
  const rpcFallback = async () => {
2574
2608
  const contract = await this.getViewerContract();
2575
2609
  const offset = params?.offset ?? 0;
2576
2610
  const limit = params?.limit ?? 20;
2611
+ if (params?.playerAddress) {
2612
+ return viewerRegistrationsByOwner(contract, tournamentId, params.playerAddress, offset, limit);
2613
+ }
2614
+ if (params?.gameTokenIds?.length) {
2615
+ return viewerRegistrationsByTokenIds(contract, tournamentId, params.gameTokenIds, offset, limit);
2616
+ }
2577
2617
  return viewerRegistrations(contract, tournamentId, offset, limit);
2578
2618
  };
2579
2619
  if (this.resolvedConfig.primarySource === "rpc") {