@provable-games/budokan-sdk 0.1.1 → 0.1.3

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.
package/dist/react.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { m as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, L as LeaderboardEntry, h as PlayerTournament, f as PlayerStats, g as PlayerTournamentParams, c as RewardClaim, d as RewardClaimSummary, k as PrizeStats, a as Prize, Q as QualificationEntry, s as WSEventMessage, r as WSChannel, C as ConnectionMode } from './client-BtC3ngNe.cjs';
3
+ import { m as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, q as Phase, L as LeaderboardEntry, R as Registration, h as PlayerTournament, f as PlayerStats, g as PlayerTournamentParams, c as RewardClaim, d as RewardClaimSummary, k as PrizeStats, a as Prize, P as PrizeAggregation, Q as QualificationEntry, i as PlatformStats, s as WSEventMessage, r as WSChannel, C as ConnectionMode } from './client-BtC3ngNe.cjs';
4
4
 
5
5
  interface BudokanProviderProps {
6
6
  children: ReactNode;
@@ -26,6 +26,7 @@ interface UseTournamentsResult {
26
26
  }
27
27
  /**
28
28
  * Hook to fetch a paginated list of tournaments.
29
+ * Pass `undefined` to skip fetching (useful for conditional queries).
29
30
  */
30
31
  declare function useTournaments(params?: TournamentListParams): UseTournamentsResult;
31
32
  interface UseTournamentResult {
@@ -39,6 +40,21 @@ interface UseTournamentResult {
39
40
  */
40
41
  declare function useTournament(tournamentId: string | undefined): UseTournamentResult;
41
42
 
43
+ interface UseTournamentCountResult {
44
+ count: number | null;
45
+ loading: boolean;
46
+ error: Error | null;
47
+ refetch: () => void;
48
+ }
49
+ /**
50
+ * Hook to fetch the total count of tournaments matching a phase filter.
51
+ */
52
+ declare function useTournamentCount(phase?: Phase): UseTournamentCountResult;
53
+ /**
54
+ * Hook to fetch the total count of tournaments a player is registered for.
55
+ */
56
+ declare function usePlayerTournamentCount(address: string | undefined, phase?: Phase): UseTournamentCountResult;
57
+
42
58
  interface UseLeaderboardResult {
43
59
  leaderboard: LeaderboardEntry[] | null;
44
60
  loading: boolean;
@@ -50,6 +66,21 @@ interface UseLeaderboardResult {
50
66
  */
51
67
  declare function useLeaderboard(tournamentId: string | undefined): UseLeaderboardResult;
52
68
 
69
+ interface UseRegistrationsResult {
70
+ registrations: PaginatedResult<Registration> | null;
71
+ loading: boolean;
72
+ error: Error | null;
73
+ refetch: () => void;
74
+ }
75
+ /**
76
+ * Hook to fetch registrations for a tournament.
77
+ */
78
+ declare function useRegistrations(tournamentId: string | undefined, params?: {
79
+ playerAddress?: string;
80
+ limit?: number;
81
+ offset?: number;
82
+ }): UseRegistrationsResult;
83
+
53
84
  interface UsePlayerResult {
54
85
  tournaments: PaginatedResult<PlayerTournament> | null;
55
86
  stats: PlayerStats | null;
@@ -123,6 +154,17 @@ interface UsePrizeStatsResult {
123
154
  */
124
155
  declare function usePrizeStats(): UsePrizeStatsResult;
125
156
 
157
+ interface UsePrizeAggregationResult {
158
+ prizeAggregation: PrizeAggregation[] | null;
159
+ loading: boolean;
160
+ error: Error | null;
161
+ refetch: () => void;
162
+ }
163
+ /**
164
+ * Hook to fetch prize aggregation for a tournament.
165
+ */
166
+ declare function usePrizeAggregation(tournamentId: string | undefined): UsePrizeAggregationResult;
167
+
126
168
  interface UseQualificationsResult {
127
169
  qualifications: PaginatedResult<QualificationEntry> | null;
128
170
  loading: boolean;
@@ -134,6 +176,17 @@ interface UseQualificationsResult {
134
176
  */
135
177
  declare function useQualifications(tournamentId: string | undefined): UseQualificationsResult;
136
178
 
179
+ interface UseActivityStatsResult {
180
+ stats: PlatformStats | null;
181
+ loading: boolean;
182
+ error: Error | null;
183
+ refetch: () => void;
184
+ }
185
+ /**
186
+ * Hook to fetch platform-wide activity stats.
187
+ */
188
+ declare function useActivityStats(): UseActivityStatsResult;
189
+
137
190
  interface UseSubscriptionResult {
138
191
  lastMessage: WSEventMessage | null;
139
192
  isConnected: boolean;
@@ -157,4 +210,4 @@ declare function useConnectionStatus(): {
157
210
  datasourceMode: ConnectionMode;
158
211
  };
159
212
 
160
- export { BudokanProvider, type BudokanProviderProps, type UseLeaderboardResult, type UsePlayerResult, type UsePlayerStatsResult, type UsePlayerTournamentsResult, type UsePrizeStatsResult, type UsePrizesResult, type UseQualificationsResult, type UseRewardClaimsResult, type UseRewardClaimsSummaryResult, type UseSubscriptionResult, type UseTournamentResult, type UseTournamentsResult, useBudokanClient, useConnectionStatus, useLeaderboard, usePlayer, usePlayerStats, usePlayerTournaments, usePrizeStats, usePrizes, useQualifications, useRewardClaims, useRewardClaimsSummary, useSubscription, useTournament, useTournaments };
213
+ export { BudokanProvider, type BudokanProviderProps, type UseActivityStatsResult, type UseLeaderboardResult, type UsePlayerResult, type UsePlayerStatsResult, type UsePlayerTournamentsResult, type UsePrizeAggregationResult, type UsePrizeStatsResult, type UsePrizesResult, type UseQualificationsResult, type UseRegistrationsResult, type UseRewardClaimsResult, type UseRewardClaimsSummaryResult, type UseSubscriptionResult, type UseTournamentCountResult, type UseTournamentResult, type UseTournamentsResult, useActivityStats, useBudokanClient, useConnectionStatus, useLeaderboard, usePlayer, usePlayerStats, usePlayerTournamentCount, usePlayerTournaments, usePrizeAggregation, usePrizeStats, usePrizes, useQualifications, useRegistrations, useRewardClaims, useRewardClaimsSummary, useSubscription, useTournament, useTournamentCount, useTournaments };
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { m as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, L as LeaderboardEntry, h as PlayerTournament, f as PlayerStats, g as PlayerTournamentParams, c as RewardClaim, d as RewardClaimSummary, k as PrizeStats, a as Prize, Q as QualificationEntry, s as WSEventMessage, r as WSChannel, C as ConnectionMode } from './client-BtC3ngNe.js';
3
+ import { m as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, q as Phase, L as LeaderboardEntry, R as Registration, h as PlayerTournament, f as PlayerStats, g as PlayerTournamentParams, c as RewardClaim, d as RewardClaimSummary, k as PrizeStats, a as Prize, P as PrizeAggregation, Q as QualificationEntry, i as PlatformStats, s as WSEventMessage, r as WSChannel, C as ConnectionMode } from './client-BtC3ngNe.js';
4
4
 
5
5
  interface BudokanProviderProps {
6
6
  children: ReactNode;
@@ -26,6 +26,7 @@ interface UseTournamentsResult {
26
26
  }
27
27
  /**
28
28
  * Hook to fetch a paginated list of tournaments.
29
+ * Pass `undefined` to skip fetching (useful for conditional queries).
29
30
  */
30
31
  declare function useTournaments(params?: TournamentListParams): UseTournamentsResult;
31
32
  interface UseTournamentResult {
@@ -39,6 +40,21 @@ interface UseTournamentResult {
39
40
  */
40
41
  declare function useTournament(tournamentId: string | undefined): UseTournamentResult;
41
42
 
43
+ interface UseTournamentCountResult {
44
+ count: number | null;
45
+ loading: boolean;
46
+ error: Error | null;
47
+ refetch: () => void;
48
+ }
49
+ /**
50
+ * Hook to fetch the total count of tournaments matching a phase filter.
51
+ */
52
+ declare function useTournamentCount(phase?: Phase): UseTournamentCountResult;
53
+ /**
54
+ * Hook to fetch the total count of tournaments a player is registered for.
55
+ */
56
+ declare function usePlayerTournamentCount(address: string | undefined, phase?: Phase): UseTournamentCountResult;
57
+
42
58
  interface UseLeaderboardResult {
43
59
  leaderboard: LeaderboardEntry[] | null;
44
60
  loading: boolean;
@@ -50,6 +66,21 @@ interface UseLeaderboardResult {
50
66
  */
51
67
  declare function useLeaderboard(tournamentId: string | undefined): UseLeaderboardResult;
52
68
 
69
+ interface UseRegistrationsResult {
70
+ registrations: PaginatedResult<Registration> | null;
71
+ loading: boolean;
72
+ error: Error | null;
73
+ refetch: () => void;
74
+ }
75
+ /**
76
+ * Hook to fetch registrations for a tournament.
77
+ */
78
+ declare function useRegistrations(tournamentId: string | undefined, params?: {
79
+ playerAddress?: string;
80
+ limit?: number;
81
+ offset?: number;
82
+ }): UseRegistrationsResult;
83
+
53
84
  interface UsePlayerResult {
54
85
  tournaments: PaginatedResult<PlayerTournament> | null;
55
86
  stats: PlayerStats | null;
@@ -123,6 +154,17 @@ interface UsePrizeStatsResult {
123
154
  */
124
155
  declare function usePrizeStats(): UsePrizeStatsResult;
125
156
 
157
+ interface UsePrizeAggregationResult {
158
+ prizeAggregation: PrizeAggregation[] | null;
159
+ loading: boolean;
160
+ error: Error | null;
161
+ refetch: () => void;
162
+ }
163
+ /**
164
+ * Hook to fetch prize aggregation for a tournament.
165
+ */
166
+ declare function usePrizeAggregation(tournamentId: string | undefined): UsePrizeAggregationResult;
167
+
126
168
  interface UseQualificationsResult {
127
169
  qualifications: PaginatedResult<QualificationEntry> | null;
128
170
  loading: boolean;
@@ -134,6 +176,17 @@ interface UseQualificationsResult {
134
176
  */
135
177
  declare function useQualifications(tournamentId: string | undefined): UseQualificationsResult;
136
178
 
179
+ interface UseActivityStatsResult {
180
+ stats: PlatformStats | null;
181
+ loading: boolean;
182
+ error: Error | null;
183
+ refetch: () => void;
184
+ }
185
+ /**
186
+ * Hook to fetch platform-wide activity stats.
187
+ */
188
+ declare function useActivityStats(): UseActivityStatsResult;
189
+
137
190
  interface UseSubscriptionResult {
138
191
  lastMessage: WSEventMessage | null;
139
192
  isConnected: boolean;
@@ -157,4 +210,4 @@ declare function useConnectionStatus(): {
157
210
  datasourceMode: ConnectionMode;
158
211
  };
159
212
 
160
- export { BudokanProvider, type BudokanProviderProps, type UseLeaderboardResult, type UsePlayerResult, type UsePlayerStatsResult, type UsePlayerTournamentsResult, type UsePrizeStatsResult, type UsePrizesResult, type UseQualificationsResult, type UseRewardClaimsResult, type UseRewardClaimsSummaryResult, type UseSubscriptionResult, type UseTournamentResult, type UseTournamentsResult, useBudokanClient, useConnectionStatus, useLeaderboard, usePlayer, usePlayerStats, usePlayerTournaments, usePrizeStats, usePrizes, useQualifications, useRewardClaims, useRewardClaimsSummary, useSubscription, useTournament, useTournaments };
213
+ export { BudokanProvider, type BudokanProviderProps, type UseActivityStatsResult, type UseLeaderboardResult, type UsePlayerResult, type UsePlayerStatsResult, type UsePlayerTournamentsResult, type UsePrizeAggregationResult, type UsePrizeStatsResult, type UsePrizesResult, type UseQualificationsResult, type UseRegistrationsResult, type UseRewardClaimsResult, type UseRewardClaimsSummaryResult, type UseSubscriptionResult, type UseTournamentCountResult, type UseTournamentResult, type UseTournamentsResult, useActivityStats, useBudokanClient, useConnectionStatus, useLeaderboard, usePlayer, usePlayerStats, usePlayerTournamentCount, usePlayerTournaments, usePrizeAggregation, usePrizeStats, usePrizes, useQualifications, useRegistrations, useRewardClaims, useRewardClaimsSummary, useSubscription, useTournament, useTournamentCount, useTournaments };
package/dist/react.js CHANGED
@@ -2531,10 +2531,11 @@ function useBudokanClient() {
2531
2531
  function useTournaments(params) {
2532
2532
  const client = useBudokanClient();
2533
2533
  const [tournaments, setTournaments] = useState(null);
2534
- const [loading, setLoading] = useState(true);
2534
+ const [loading, setLoading] = useState(!!params);
2535
2535
  const [error, setError] = useState(null);
2536
2536
  const paramsKey = JSON.stringify(params);
2537
2537
  const fetch2 = useCallback(() => {
2538
+ if (params === void 0) return;
2538
2539
  setLoading(true);
2539
2540
  setError(null);
2540
2541
  client.getTournaments(params).then(setTournaments).catch(setError).finally(() => setLoading(false));
@@ -2560,6 +2561,37 @@ function useTournament(tournamentId) {
2560
2561
  }, [fetch2]);
2561
2562
  return { tournament, loading, error, refetch: fetch2 };
2562
2563
  }
2564
+ function useTournamentCount(phase) {
2565
+ const client = useBudokanClient();
2566
+ const [count, setCount] = useState(null);
2567
+ const [loading, setLoading] = useState(true);
2568
+ const [error, setError] = useState(null);
2569
+ const fetch2 = useCallback(() => {
2570
+ setLoading(true);
2571
+ setError(null);
2572
+ client.getTournaments({ phase, limit: 1 }).then((r) => setCount(r.total ?? 0)).catch(setError).finally(() => setLoading(false));
2573
+ }, [client, phase]);
2574
+ useEffect(() => {
2575
+ fetch2();
2576
+ }, [fetch2]);
2577
+ return { count, loading, error, refetch: fetch2 };
2578
+ }
2579
+ function usePlayerTournamentCount(address, phase) {
2580
+ const client = useBudokanClient();
2581
+ const [count, setCount] = useState(null);
2582
+ const [loading, setLoading] = useState(!!address);
2583
+ const [error, setError] = useState(null);
2584
+ const fetch2 = useCallback(() => {
2585
+ if (!address) return;
2586
+ setLoading(true);
2587
+ setError(null);
2588
+ client.getPlayerTournaments(address, { phase, limit: 1 }).then((r) => setCount(r.total ?? 0)).catch(setError).finally(() => setLoading(false));
2589
+ }, [client, address, phase]);
2590
+ useEffect(() => {
2591
+ fetch2();
2592
+ }, [fetch2]);
2593
+ return { count, loading, error, refetch: fetch2 };
2594
+ }
2563
2595
  function useLeaderboard(tournamentId) {
2564
2596
  const client = useBudokanClient();
2565
2597
  const [leaderboard, setLeaderboard] = useState(null);
@@ -2576,6 +2608,23 @@ function useLeaderboard(tournamentId) {
2576
2608
  }, [fetch2]);
2577
2609
  return { leaderboard, loading, error, refetch: fetch2 };
2578
2610
  }
2611
+ function useRegistrations(tournamentId, params) {
2612
+ const client = useBudokanClient();
2613
+ const [registrations, setRegistrations] = useState(null);
2614
+ const [loading, setLoading] = useState(!!tournamentId);
2615
+ const [error, setError] = useState(null);
2616
+ const paramsKey = JSON.stringify(params);
2617
+ const fetch2 = useCallback(() => {
2618
+ if (!tournamentId) return;
2619
+ setLoading(true);
2620
+ setError(null);
2621
+ client.getTournamentRegistrations(tournamentId, params).then(setRegistrations).catch(setError).finally(() => setLoading(false));
2622
+ }, [client, tournamentId, paramsKey]);
2623
+ useEffect(() => {
2624
+ fetch2();
2625
+ }, [fetch2]);
2626
+ return { registrations, loading, error, refetch: fetch2 };
2627
+ }
2579
2628
  function usePlayer(address) {
2580
2629
  const client = useBudokanClient();
2581
2630
  const [tournaments, setTournaments] = useState(null);
@@ -2620,12 +2669,13 @@ function usePlayerTournaments(address, params) {
2620
2669
  const [tournaments, setTournaments] = useState(null);
2621
2670
  const [loading, setLoading] = useState(!!address);
2622
2671
  const [error, setError] = useState(null);
2672
+ const paramsKey = JSON.stringify(params);
2623
2673
  const fetch2 = useCallback(() => {
2624
2674
  if (!address) return;
2625
2675
  setLoading(true);
2626
2676
  setError(null);
2627
2677
  client.getPlayerTournaments(address, params).then(setTournaments).catch(setError).finally(() => setLoading(false));
2628
- }, [client, address, params]);
2678
+ }, [client, address, paramsKey]);
2629
2679
  useEffect(() => {
2630
2680
  fetch2();
2631
2681
  }, [fetch2]);
@@ -2694,6 +2744,22 @@ function usePrizeStats() {
2694
2744
  }, [fetch2]);
2695
2745
  return { prizeStats, loading, error, refetch: fetch2 };
2696
2746
  }
2747
+ function usePrizeAggregation(tournamentId) {
2748
+ const client = useBudokanClient();
2749
+ const [prizeAggregation, setPrizeAggregation] = useState(null);
2750
+ const [loading, setLoading] = useState(!!tournamentId);
2751
+ const [error, setError] = useState(null);
2752
+ const fetch2 = useCallback(() => {
2753
+ if (!tournamentId) return;
2754
+ setLoading(true);
2755
+ setError(null);
2756
+ client.getTournamentPrizeAggregation(tournamentId).then(setPrizeAggregation).catch(setError).finally(() => setLoading(false));
2757
+ }, [client, tournamentId]);
2758
+ useEffect(() => {
2759
+ fetch2();
2760
+ }, [fetch2]);
2761
+ return { prizeAggregation, loading, error, refetch: fetch2 };
2762
+ }
2697
2763
  function useQualifications(tournamentId) {
2698
2764
  const client = useBudokanClient();
2699
2765
  const [qualifications, setQualifications] = useState(null);
@@ -2710,6 +2776,21 @@ function useQualifications(tournamentId) {
2710
2776
  }, [fetch2]);
2711
2777
  return { qualifications, loading, error, refetch: fetch2 };
2712
2778
  }
2779
+ function useActivityStats() {
2780
+ const client = useBudokanClient();
2781
+ const [stats, setStats] = useState(null);
2782
+ const [loading, setLoading] = useState(true);
2783
+ const [error, setError] = useState(null);
2784
+ const fetch2 = useCallback(() => {
2785
+ setLoading(true);
2786
+ setError(null);
2787
+ client.getActivityStats().then(setStats).catch(setError).finally(() => setLoading(false));
2788
+ }, [client]);
2789
+ useEffect(() => {
2790
+ fetch2();
2791
+ }, [fetch2]);
2792
+ return { stats, loading, error, refetch: fetch2 };
2793
+ }
2713
2794
  function useSubscription(channels, tournamentIds) {
2714
2795
  const client = useBudokanClient();
2715
2796
  const [lastMessage, setLastMessage] = useState(null);
@@ -2755,6 +2836,6 @@ function useConnectionStatus() {
2755
2836
  return { isConnected, datasourceMode };
2756
2837
  }
2757
2838
 
2758
- export { BudokanProvider, useBudokanClient, useConnectionStatus, useLeaderboard, usePlayer, usePlayerStats, usePlayerTournaments, usePrizeStats, usePrizes, useQualifications, useRewardClaims, useRewardClaimsSummary, useSubscription, useTournament, useTournaments };
2839
+ export { BudokanProvider, useActivityStats, useBudokanClient, useConnectionStatus, useLeaderboard, usePlayer, usePlayerStats, usePlayerTournamentCount, usePlayerTournaments, usePrizeAggregation, usePrizeStats, usePrizes, useQualifications, useRegistrations, useRewardClaims, useRewardClaimsSummary, useSubscription, useTournament, useTournamentCount, useTournaments };
2759
2840
  //# sourceMappingURL=react.js.map
2760
2841
  //# sourceMappingURL=react.js.map