@provable-games/budokan-sdk 0.1.9 → 0.1.10

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, 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-B-QSLs81.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-ugXv3NlV.cjs';
4
4
  import 'starknet';
5
5
  import '@provable-games/metagame-sdk';
6
6
 
@@ -79,6 +79,9 @@ interface UseRegistrationsResult {
79
79
  */
80
80
  declare function useRegistrations(tournamentId: string | undefined, params?: {
81
81
  playerAddress?: string;
82
+ gameTokenIds?: string[];
83
+ hasSubmitted?: boolean;
84
+ isBanned?: boolean;
82
85
  limit?: number;
83
86
  offset?: number;
84
87
  }): UseRegistrationsResult;
@@ -92,7 +95,7 @@ interface UsePlayerResult {
92
95
  /**
93
96
  * Hook to fetch a player's tournament history and stats.
94
97
  */
95
- declare function usePlayer(address: string | undefined): UsePlayerResult;
98
+ declare function usePlayer(address: string | undefined, params?: PlayerTournamentParams): UsePlayerResult;
96
99
  interface UsePlayerStatsResult {
97
100
  stats: PlayerStats | null;
98
101
  loading: boolean;
@@ -123,7 +126,10 @@ interface UseRewardClaimsResult {
123
126
  /**
124
127
  * Hook to fetch reward claims for a tournament.
125
128
  */
126
- declare function useRewardClaims(tournamentId: string | undefined): UseRewardClaimsResult;
129
+ declare function useRewardClaims(tournamentId: string | undefined, params?: {
130
+ limit?: number;
131
+ offset?: number;
132
+ }): UseRewardClaimsResult;
127
133
  interface UseRewardClaimsSummaryResult {
128
134
  summary: RewardClaimSummary | null;
129
135
  loading: boolean;
@@ -176,7 +182,10 @@ interface UseQualificationsResult {
176
182
  /**
177
183
  * Hook to fetch qualification entries for a tournament.
178
184
  */
179
- declare function useQualifications(tournamentId: string | undefined): UseQualificationsResult;
185
+ declare function useQualifications(tournamentId: string | undefined, params?: {
186
+ limit?: number;
187
+ offset?: number;
188
+ }): UseQualificationsResult;
180
189
 
181
190
  interface UseActivityStatsResult {
182
191
  stats: PlatformStats | null;
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, 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-B-QSLs81.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-ugXv3NlV.js';
4
4
  import 'starknet';
5
5
  import '@provable-games/metagame-sdk';
6
6
 
@@ -79,6 +79,9 @@ interface UseRegistrationsResult {
79
79
  */
80
80
  declare function useRegistrations(tournamentId: string | undefined, params?: {
81
81
  playerAddress?: string;
82
+ gameTokenIds?: string[];
83
+ hasSubmitted?: boolean;
84
+ isBanned?: boolean;
82
85
  limit?: number;
83
86
  offset?: number;
84
87
  }): UseRegistrationsResult;
@@ -92,7 +95,7 @@ interface UsePlayerResult {
92
95
  /**
93
96
  * Hook to fetch a player's tournament history and stats.
94
97
  */
95
- declare function usePlayer(address: string | undefined): UsePlayerResult;
98
+ declare function usePlayer(address: string | undefined, params?: PlayerTournamentParams): UsePlayerResult;
96
99
  interface UsePlayerStatsResult {
97
100
  stats: PlayerStats | null;
98
101
  loading: boolean;
@@ -123,7 +126,10 @@ interface UseRewardClaimsResult {
123
126
  /**
124
127
  * Hook to fetch reward claims for a tournament.
125
128
  */
126
- declare function useRewardClaims(tournamentId: string | undefined): UseRewardClaimsResult;
129
+ declare function useRewardClaims(tournamentId: string | undefined, params?: {
130
+ limit?: number;
131
+ offset?: number;
132
+ }): UseRewardClaimsResult;
127
133
  interface UseRewardClaimsSummaryResult {
128
134
  summary: RewardClaimSummary | null;
129
135
  loading: boolean;
@@ -176,7 +182,10 @@ interface UseQualificationsResult {
176
182
  /**
177
183
  * Hook to fetch qualification entries for a tournament.
178
184
  */
179
- declare function useQualifications(tournamentId: string | undefined): UseQualificationsResult;
185
+ declare function useQualifications(tournamentId: string | undefined, params?: {
186
+ limit?: number;
187
+ offset?: number;
188
+ }): UseQualificationsResult;
180
189
 
181
190
  interface UseActivityStatsResult {
182
191
  stats: PlatformStats | null;
package/dist/react.js CHANGED
@@ -247,6 +247,10 @@ async function getTournamentLeaderboard(baseUrl, tournamentId, ctx) {
247
247
  }
248
248
  async function getTournamentRegistrations(baseUrl, tournamentId, params, ctx) {
249
249
  const qs = buildQueryString({
250
+ player_address: params?.playerAddress,
251
+ game_token_ids: params?.gameTokenIds?.length ? params.gameTokenIds.join(",") : void 0,
252
+ has_submitted: params?.hasSubmitted,
253
+ is_banned: params?.isBanned,
250
254
  limit: params?.limit,
251
255
  offset: params?.offset
252
256
  });
@@ -1135,6 +1139,34 @@ async function viewerRegistrations(contract, tournamentId, offset, limit) {
1135
1139
  };
1136
1140
  }, contract.address);
1137
1141
  }
1142
+ async function viewerRegistrationsByOwner(contract, tournamentId, owner, offset, limit) {
1143
+ return wrapRpcCall(async () => {
1144
+ const result = await contract.call("tournament_registrations_by_owner", [tournamentId, owner, offset, limit]);
1145
+ const obj = result;
1146
+ const entries = obj.entries ?? [];
1147
+ const total = Number(obj.total ?? 0);
1148
+ return {
1149
+ data: entries.map((e) => parseRegistration(e, tournamentId)),
1150
+ total,
1151
+ limit,
1152
+ offset
1153
+ };
1154
+ }, contract.address);
1155
+ }
1156
+ async function viewerRegistrationsByTokenIds(contract, tournamentId, tokenIds, offset, limit) {
1157
+ return wrapRpcCall(async () => {
1158
+ const result = await contract.call("tournament_registrations_by_token_ids", [tournamentId, tokenIds, 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
+ }
1138
1170
  async function viewerLeaderboard(contract, tournamentId, offset, limit) {
1139
1171
  return wrapRpcCall(async () => {
1140
1172
  const result = await contract.call("leaderboard", [tournamentId, offset, limit]);
@@ -2553,13 +2585,21 @@ var BudokanClient = class {
2553
2585
  /**
2554
2586
  * Fetch registrations for a tournament.
2555
2587
  * Supports RPC fallback when API is unavailable.
2556
- * Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings.
2588
+ * Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings,
2589
+ * and filter params (`playerAddress`, `gameTokenIds`, `hasSubmitted`, `isBanned`)
2590
+ * are applied via on-chain viewer functions where supported.
2557
2591
  */
2558
2592
  async getTournamentRegistrations(tournamentId, params) {
2559
2593
  const rpcFallback = async () => {
2560
2594
  const contract = await this.getViewerContract();
2561
2595
  const offset = params?.offset ?? 0;
2562
2596
  const limit = params?.limit ?? 20;
2597
+ if (params?.playerAddress) {
2598
+ return viewerRegistrationsByOwner(contract, tournamentId, params.playerAddress, offset, limit);
2599
+ }
2600
+ if (params?.gameTokenIds?.length) {
2601
+ return viewerRegistrationsByTokenIds(contract, tournamentId, params.gameTokenIds, offset, limit);
2602
+ }
2563
2603
  return viewerRegistrations(contract, tournamentId, offset, limit);
2564
2604
  };
2565
2605
  if (this.resolvedConfig.primarySource === "rpc") {
@@ -2964,20 +3004,21 @@ function useRegistrations(tournamentId, params) {
2964
3004
  }, [fetch2]);
2965
3005
  return { registrations, loading, error, refetch: fetch2 };
2966
3006
  }
2967
- function usePlayer(address) {
3007
+ function usePlayer(address, params) {
2968
3008
  const client = useBudokanClient();
2969
3009
  const [tournaments, setTournaments] = useState(null);
2970
3010
  const [stats, setStats] = useState(null);
2971
3011
  const [loading, setLoading] = useState(!!address);
2972
3012
  const [error, setError] = useState(null);
2973
3013
  useResetOnClient(client, setTournaments, setStats, setError);
3014
+ const paramsKey = JSON.stringify(params);
2974
3015
  const fetch2 = useCallback(async () => {
2975
3016
  if (!address) return;
2976
3017
  setLoading(true);
2977
3018
  setError(null);
2978
3019
  try {
2979
3020
  const [tournamentsResult, statsResult] = await Promise.all([
2980
- client.getPlayerTournaments(address),
3021
+ client.getPlayerTournaments(address, params),
2981
3022
  client.getPlayerStats(address)
2982
3023
  ]);
2983
3024
  setTournaments(tournamentsResult);
@@ -2987,7 +3028,7 @@ function usePlayer(address) {
2987
3028
  } finally {
2988
3029
  setLoading(false);
2989
3030
  }
2990
- }, [client, address]);
3031
+ }, [client, address, paramsKey]);
2991
3032
  useEffect(() => {
2992
3033
  fetch2();
2993
3034
  }, [fetch2]);
@@ -3042,25 +3083,26 @@ function usePlayerTournaments(address, params) {
3042
3083
  }, [fetch2]);
3043
3084
  return { tournaments, loading, error, refetch: fetch2 };
3044
3085
  }
3045
- function useRewardClaims(tournamentId) {
3086
+ function useRewardClaims(tournamentId, params) {
3046
3087
  const client = useBudokanClient();
3047
3088
  const [rewardClaims, setRewardClaims] = useState(null);
3048
3089
  const [loading, setLoading] = useState(!!tournamentId);
3049
3090
  const [error, setError] = useState(null);
3050
3091
  useResetOnClient(client, setRewardClaims, setError);
3092
+ const paramsKey = JSON.stringify(params);
3051
3093
  const fetch2 = useCallback(async () => {
3052
3094
  if (!tournamentId) return;
3053
3095
  setLoading(true);
3054
3096
  setError(null);
3055
3097
  try {
3056
- const result = await client.getTournamentRewardClaims(tournamentId);
3098
+ const result = await client.getTournamentRewardClaims(tournamentId, params);
3057
3099
  setRewardClaims(result);
3058
3100
  } catch (e) {
3059
3101
  setError(e);
3060
3102
  } finally {
3061
3103
  setLoading(false);
3062
3104
  }
3063
- }, [client, tournamentId]);
3105
+ }, [client, tournamentId, paramsKey]);
3064
3106
  useEffect(() => {
3065
3107
  fetch2();
3066
3108
  }, [fetch2]);
@@ -3161,25 +3203,26 @@ function usePrizeAggregation(tournamentId) {
3161
3203
  }, [fetch2]);
3162
3204
  return { prizeAggregation, loading, error, refetch: fetch2 };
3163
3205
  }
3164
- function useQualifications(tournamentId) {
3206
+ function useQualifications(tournamentId, params) {
3165
3207
  const client = useBudokanClient();
3166
3208
  const [qualifications, setQualifications] = useState(null);
3167
3209
  const [loading, setLoading] = useState(!!tournamentId);
3168
3210
  const [error, setError] = useState(null);
3169
3211
  useResetOnClient(client, setQualifications, setError);
3212
+ const paramsKey = JSON.stringify(params);
3170
3213
  const fetch2 = useCallback(async () => {
3171
3214
  if (!tournamentId) return;
3172
3215
  setLoading(true);
3173
3216
  setError(null);
3174
3217
  try {
3175
- const result = await client.getTournamentQualifications(tournamentId);
3218
+ const result = await client.getTournamentQualifications(tournamentId, params);
3176
3219
  setQualifications(result);
3177
3220
  } catch (e) {
3178
3221
  setError(e);
3179
3222
  } finally {
3180
3223
  setLoading(false);
3181
3224
  }
3182
- }, [client, tournamentId]);
3225
+ }, [client, tournamentId, paramsKey]);
3183
3226
  useEffect(() => {
3184
3227
  fetch2();
3185
3228
  }, [fetch2]);