@provable-games/budokan-sdk 0.1.8 → 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/{client-CYj1Iw_w.d.cts → client-ugXv3NlV.d.cts} +8 -2
- package/dist/{client-CYj1Iw_w.d.ts → client-ugXv3NlV.d.ts} +8 -2
- package/dist/index.cjs +54 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +54 -7
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +66 -16
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +13 -4
- package/dist/react.d.ts +13 -4
- package/dist/react.js +66 -16
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
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-
|
|
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
|
|
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
|
|
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-
|
|
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
|
|
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
|
|
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
|
});
|
|
@@ -1110,7 +1114,9 @@ async function viewerTournamentsByPhase(contract, phase, offset, limit) {
|
|
|
1110
1114
|
async function viewerTournamentDetail(contract, tournamentId) {
|
|
1111
1115
|
return wrapRpcCall(async () => {
|
|
1112
1116
|
const result = await contract.call("tournament_detail", [tournamentId]);
|
|
1113
|
-
|
|
1117
|
+
const tournament = parseTournamentFullState(result);
|
|
1118
|
+
if (!tournament.gameAddress || tournament.gameAddress === "0x0") return null;
|
|
1119
|
+
return tournament;
|
|
1114
1120
|
}, contract.address);
|
|
1115
1121
|
}
|
|
1116
1122
|
async function viewerTournamentsBatch(contract, tournamentIds) {
|
|
@@ -1133,6 +1139,34 @@ async function viewerRegistrations(contract, tournamentId, offset, limit) {
|
|
|
1133
1139
|
};
|
|
1134
1140
|
}, contract.address);
|
|
1135
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
|
+
}
|
|
1136
1170
|
async function viewerLeaderboard(contract, tournamentId, offset, limit) {
|
|
1137
1171
|
return wrapRpcCall(async () => {
|
|
1138
1172
|
const result = await contract.call("leaderboard", [tournamentId, offset, limit]);
|
|
@@ -2519,11 +2553,16 @@ var BudokanClient = class {
|
|
|
2519
2553
|
if (this.resolvedConfig.primarySource === "rpc") {
|
|
2520
2554
|
return rpcFallback();
|
|
2521
2555
|
}
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2556
|
+
try {
|
|
2557
|
+
return await getTournament(this.resolvedConfig.apiBaseUrl, tournamentId, this.apiCtx);
|
|
2558
|
+
} catch {
|
|
2559
|
+
try {
|
|
2560
|
+
this.connectionStatus.markApiUnavailable();
|
|
2561
|
+
return await rpcFallback();
|
|
2562
|
+
} catch {
|
|
2563
|
+
return null;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2527
2566
|
}
|
|
2528
2567
|
/**
|
|
2529
2568
|
* Fetch the leaderboard for a tournament.
|
|
@@ -2546,13 +2585,21 @@ var BudokanClient = class {
|
|
|
2546
2585
|
/**
|
|
2547
2586
|
* Fetch registrations for a tournament.
|
|
2548
2587
|
* Supports RPC fallback when API is unavailable.
|
|
2549
|
-
* 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.
|
|
2550
2591
|
*/
|
|
2551
2592
|
async getTournamentRegistrations(tournamentId, params) {
|
|
2552
2593
|
const rpcFallback = async () => {
|
|
2553
2594
|
const contract = await this.getViewerContract();
|
|
2554
2595
|
const offset = params?.offset ?? 0;
|
|
2555
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
|
+
}
|
|
2556
2603
|
return viewerRegistrations(contract, tournamentId, offset, limit);
|
|
2557
2604
|
};
|
|
2558
2605
|
if (this.resolvedConfig.primarySource === "rpc") {
|
|
@@ -2957,20 +3004,21 @@ function useRegistrations(tournamentId, params) {
|
|
|
2957
3004
|
}, [fetch2]);
|
|
2958
3005
|
return { registrations, loading, error, refetch: fetch2 };
|
|
2959
3006
|
}
|
|
2960
|
-
function usePlayer(address) {
|
|
3007
|
+
function usePlayer(address, params) {
|
|
2961
3008
|
const client = useBudokanClient();
|
|
2962
3009
|
const [tournaments, setTournaments] = useState(null);
|
|
2963
3010
|
const [stats, setStats] = useState(null);
|
|
2964
3011
|
const [loading, setLoading] = useState(!!address);
|
|
2965
3012
|
const [error, setError] = useState(null);
|
|
2966
3013
|
useResetOnClient(client, setTournaments, setStats, setError);
|
|
3014
|
+
const paramsKey = JSON.stringify(params);
|
|
2967
3015
|
const fetch2 = useCallback(async () => {
|
|
2968
3016
|
if (!address) return;
|
|
2969
3017
|
setLoading(true);
|
|
2970
3018
|
setError(null);
|
|
2971
3019
|
try {
|
|
2972
3020
|
const [tournamentsResult, statsResult] = await Promise.all([
|
|
2973
|
-
client.getPlayerTournaments(address),
|
|
3021
|
+
client.getPlayerTournaments(address, params),
|
|
2974
3022
|
client.getPlayerStats(address)
|
|
2975
3023
|
]);
|
|
2976
3024
|
setTournaments(tournamentsResult);
|
|
@@ -2980,7 +3028,7 @@ function usePlayer(address) {
|
|
|
2980
3028
|
} finally {
|
|
2981
3029
|
setLoading(false);
|
|
2982
3030
|
}
|
|
2983
|
-
}, [client, address]);
|
|
3031
|
+
}, [client, address, paramsKey]);
|
|
2984
3032
|
useEffect(() => {
|
|
2985
3033
|
fetch2();
|
|
2986
3034
|
}, [fetch2]);
|
|
@@ -3035,25 +3083,26 @@ function usePlayerTournaments(address, params) {
|
|
|
3035
3083
|
}, [fetch2]);
|
|
3036
3084
|
return { tournaments, loading, error, refetch: fetch2 };
|
|
3037
3085
|
}
|
|
3038
|
-
function useRewardClaims(tournamentId) {
|
|
3086
|
+
function useRewardClaims(tournamentId, params) {
|
|
3039
3087
|
const client = useBudokanClient();
|
|
3040
3088
|
const [rewardClaims, setRewardClaims] = useState(null);
|
|
3041
3089
|
const [loading, setLoading] = useState(!!tournamentId);
|
|
3042
3090
|
const [error, setError] = useState(null);
|
|
3043
3091
|
useResetOnClient(client, setRewardClaims, setError);
|
|
3092
|
+
const paramsKey = JSON.stringify(params);
|
|
3044
3093
|
const fetch2 = useCallback(async () => {
|
|
3045
3094
|
if (!tournamentId) return;
|
|
3046
3095
|
setLoading(true);
|
|
3047
3096
|
setError(null);
|
|
3048
3097
|
try {
|
|
3049
|
-
const result = await client.getTournamentRewardClaims(tournamentId);
|
|
3098
|
+
const result = await client.getTournamentRewardClaims(tournamentId, params);
|
|
3050
3099
|
setRewardClaims(result);
|
|
3051
3100
|
} catch (e) {
|
|
3052
3101
|
setError(e);
|
|
3053
3102
|
} finally {
|
|
3054
3103
|
setLoading(false);
|
|
3055
3104
|
}
|
|
3056
|
-
}, [client, tournamentId]);
|
|
3105
|
+
}, [client, tournamentId, paramsKey]);
|
|
3057
3106
|
useEffect(() => {
|
|
3058
3107
|
fetch2();
|
|
3059
3108
|
}, [fetch2]);
|
|
@@ -3154,25 +3203,26 @@ function usePrizeAggregation(tournamentId) {
|
|
|
3154
3203
|
}, [fetch2]);
|
|
3155
3204
|
return { prizeAggregation, loading, error, refetch: fetch2 };
|
|
3156
3205
|
}
|
|
3157
|
-
function useQualifications(tournamentId) {
|
|
3206
|
+
function useQualifications(tournamentId, params) {
|
|
3158
3207
|
const client = useBudokanClient();
|
|
3159
3208
|
const [qualifications, setQualifications] = useState(null);
|
|
3160
3209
|
const [loading, setLoading] = useState(!!tournamentId);
|
|
3161
3210
|
const [error, setError] = useState(null);
|
|
3162
3211
|
useResetOnClient(client, setQualifications, setError);
|
|
3212
|
+
const paramsKey = JSON.stringify(params);
|
|
3163
3213
|
const fetch2 = useCallback(async () => {
|
|
3164
3214
|
if (!tournamentId) return;
|
|
3165
3215
|
setLoading(true);
|
|
3166
3216
|
setError(null);
|
|
3167
3217
|
try {
|
|
3168
|
-
const result = await client.getTournamentQualifications(tournamentId);
|
|
3218
|
+
const result = await client.getTournamentQualifications(tournamentId, params);
|
|
3169
3219
|
setQualifications(result);
|
|
3170
3220
|
} catch (e) {
|
|
3171
3221
|
setError(e);
|
|
3172
3222
|
} finally {
|
|
3173
3223
|
setLoading(false);
|
|
3174
3224
|
}
|
|
3175
|
-
}, [client, tournamentId]);
|
|
3225
|
+
}, [client, tournamentId, paramsKey]);
|
|
3176
3226
|
useEffect(() => {
|
|
3177
3227
|
fetch2();
|
|
3178
3228
|
}, [fetch2]);
|