@provable-games/budokan-sdk 0.1.13 → 0.1.16

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