@provable-games/budokan-sdk 0.1.12 → 0.1.15

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.
@@ -328,6 +328,7 @@ declare class BudokanClient {
328
328
  private readonly connectionStatus;
329
329
  private cachedProvider;
330
330
  private cachedViewerContract;
331
+ private cachedBudokanContract;
331
332
  constructor(config: BudokanClientConfig);
332
333
  /** Returns the resolved configuration. */
333
334
  get clientConfig(): BudokanClientConfig;
@@ -339,6 +340,7 @@ declare class BudokanClient {
339
340
  onConnectionStatusChange(listener: (status: ConnectionStatusState) => void): () => void;
340
341
  private getProvider;
341
342
  private getViewerContract;
343
+ private getBudokanContract;
342
344
  private get apiCtx();
343
345
  /**
344
346
  * Fetch a paginated list of tournaments with optional filtering.
@@ -348,8 +350,39 @@ declare class BudokanClient {
348
350
  /**
349
351
  * Fetch a single tournament by its ID.
350
352
  * Supports RPC fallback when API is unavailable.
353
+ *
354
+ * On the RPC-fallback path, Custom distribution shares are populated via
355
+ * a follow-up call to `tournament_distribution_shares(id)` so callers see
356
+ * the same shape regardless of data source (the API/indexer path fills
357
+ * shares from the `TournamentCreated` event).
351
358
  */
352
359
  getTournament(tournamentId: string): Promise<Tournament | null>;
360
+ /**
361
+ * If the tournament's entry-fee distribution is `Custom` with an empty
362
+ * shares array (the on-chain `tournament()` view returns empty spans by
363
+ * design to keep the hot path small), fetch the shares via the
364
+ * dedicated view and graft them back onto the distribution object.
365
+ *
366
+ * Detection is tolerant: the Distribution shape may appear as
367
+ * `{ variant: { Custom: [] } }` or a flattened `{ Custom: [] }`
368
+ * depending on the starknet.js version / serialization path.
369
+ */
370
+ private fillCustomSharesIfEmpty;
371
+ /**
372
+ * Fetch the Custom distribution shares for a tournament via the Budokan
373
+ * contract's `tournament_distribution_shares(id)` view.
374
+ *
375
+ * Returns an empty array for tournaments configured with
376
+ * `Linear` / `Exponential` / `Uniform` distributions (those don't have a
377
+ * shares array), and for tournaments without an entry fee.
378
+ *
379
+ * This is a direct RPC call — consumers going through the primary API
380
+ * path typically don't need it, since the indexer sources Custom shares
381
+ * from the `TournamentCreated` event and exposes them via
382
+ * `getTournament()`'s `entryFee.distribution`. Use this when you need a
383
+ * fresh on-chain read or you're operating in RPC-only mode.
384
+ */
385
+ getTournamentDistributionShares(tournamentId: string): Promise<number[]>;
353
386
  /**
354
387
  * Fetch the leaderboard for a tournament.
355
388
  * Supports RPC fallback when API is unavailable.
@@ -328,6 +328,7 @@ declare class BudokanClient {
328
328
  private readonly connectionStatus;
329
329
  private cachedProvider;
330
330
  private cachedViewerContract;
331
+ private cachedBudokanContract;
331
332
  constructor(config: BudokanClientConfig);
332
333
  /** Returns the resolved configuration. */
333
334
  get clientConfig(): BudokanClientConfig;
@@ -339,6 +340,7 @@ declare class BudokanClient {
339
340
  onConnectionStatusChange(listener: (status: ConnectionStatusState) => void): () => void;
340
341
  private getProvider;
341
342
  private getViewerContract;
343
+ private getBudokanContract;
342
344
  private get apiCtx();
343
345
  /**
344
346
  * Fetch a paginated list of tournaments with optional filtering.
@@ -348,8 +350,39 @@ declare class BudokanClient {
348
350
  /**
349
351
  * Fetch a single tournament by its ID.
350
352
  * Supports RPC fallback when API is unavailable.
353
+ *
354
+ * On the RPC-fallback path, Custom distribution shares are populated via
355
+ * a follow-up call to `tournament_distribution_shares(id)` so callers see
356
+ * the same shape regardless of data source (the API/indexer path fills
357
+ * shares from the `TournamentCreated` event).
351
358
  */
352
359
  getTournament(tournamentId: string): Promise<Tournament | null>;
360
+ /**
361
+ * If the tournament's entry-fee distribution is `Custom` with an empty
362
+ * shares array (the on-chain `tournament()` view returns empty spans by
363
+ * design to keep the hot path small), fetch the shares via the
364
+ * dedicated view and graft them back onto the distribution object.
365
+ *
366
+ * Detection is tolerant: the Distribution shape may appear as
367
+ * `{ variant: { Custom: [] } }` or a flattened `{ Custom: [] }`
368
+ * depending on the starknet.js version / serialization path.
369
+ */
370
+ private fillCustomSharesIfEmpty;
371
+ /**
372
+ * Fetch the Custom distribution shares for a tournament via the Budokan
373
+ * contract's `tournament_distribution_shares(id)` view.
374
+ *
375
+ * Returns an empty array for tournaments configured with
376
+ * `Linear` / `Exponential` / `Uniform` distributions (those don't have a
377
+ * shares array), and for tournaments without an entry fee.
378
+ *
379
+ * This is a direct RPC call — consumers going through the primary API
380
+ * path typically don't need it, since the indexer sources Custom shares
381
+ * from the `TournamentCreated` event and exposes them via
382
+ * `getTournament()`'s `entryFee.distribution`. Use this when you need a
383
+ * fresh on-chain read or you're operating in RPC-only mode.
384
+ */
385
+ getTournamentDistributionShares(tournamentId: string): Promise<number[]>;
353
386
  /**
354
387
  * Fetch the leaderboard for a tournament.
355
388
  * Supports RPC fallback when API is unavailable.