@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/{client-B-QSLs81.d.cts → client-ugXv3NlV.d.cts} +7 -1
- package/dist/{client-B-QSLs81.d.ts → client-ugXv3NlV.d.ts} +7 -1
- package/dist/index.cjs +41 -1
- 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 +41 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +53 -10
- 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 +53 -10
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -249,6 +249,10 @@ async function getTournamentLeaderboard(baseUrl, tournamentId, ctx) {
|
|
|
249
249
|
}
|
|
250
250
|
async function getTournamentRegistrations(baseUrl, tournamentId, params, ctx) {
|
|
251
251
|
const qs = buildQueryString({
|
|
252
|
+
player_address: params?.playerAddress,
|
|
253
|
+
game_token_ids: params?.gameTokenIds?.length ? params.gameTokenIds.join(",") : void 0,
|
|
254
|
+
has_submitted: params?.hasSubmitted,
|
|
255
|
+
is_banned: params?.isBanned,
|
|
252
256
|
limit: params?.limit,
|
|
253
257
|
offset: params?.offset
|
|
254
258
|
});
|
|
@@ -1137,6 +1141,34 @@ async function viewerRegistrations(contract, tournamentId, offset, limit) {
|
|
|
1137
1141
|
};
|
|
1138
1142
|
}, contract.address);
|
|
1139
1143
|
}
|
|
1144
|
+
async function viewerRegistrationsByOwner(contract, tournamentId, owner, offset, limit) {
|
|
1145
|
+
return wrapRpcCall(async () => {
|
|
1146
|
+
const result = await contract.call("tournament_registrations_by_owner", [tournamentId, owner, offset, limit]);
|
|
1147
|
+
const obj = result;
|
|
1148
|
+
const entries = obj.entries ?? [];
|
|
1149
|
+
const total = Number(obj.total ?? 0);
|
|
1150
|
+
return {
|
|
1151
|
+
data: entries.map((e) => parseRegistration(e, tournamentId)),
|
|
1152
|
+
total,
|
|
1153
|
+
limit,
|
|
1154
|
+
offset
|
|
1155
|
+
};
|
|
1156
|
+
}, contract.address);
|
|
1157
|
+
}
|
|
1158
|
+
async function viewerRegistrationsByTokenIds(contract, tournamentId, tokenIds, offset, limit) {
|
|
1159
|
+
return wrapRpcCall(async () => {
|
|
1160
|
+
const result = await contract.call("tournament_registrations_by_token_ids", [tournamentId, tokenIds, offset, limit]);
|
|
1161
|
+
const obj = result;
|
|
1162
|
+
const entries = obj.entries ?? [];
|
|
1163
|
+
const total = Number(obj.total ?? 0);
|
|
1164
|
+
return {
|
|
1165
|
+
data: entries.map((e) => parseRegistration(e, tournamentId)),
|
|
1166
|
+
total,
|
|
1167
|
+
limit,
|
|
1168
|
+
offset
|
|
1169
|
+
};
|
|
1170
|
+
}, contract.address);
|
|
1171
|
+
}
|
|
1140
1172
|
async function viewerLeaderboard(contract, tournamentId, offset, limit) {
|
|
1141
1173
|
return wrapRpcCall(async () => {
|
|
1142
1174
|
const result = await contract.call("leaderboard", [tournamentId, offset, limit]);
|
|
@@ -2555,13 +2587,21 @@ var BudokanClient = class {
|
|
|
2555
2587
|
/**
|
|
2556
2588
|
* Fetch registrations for a tournament.
|
|
2557
2589
|
* Supports RPC fallback when API is unavailable.
|
|
2558
|
-
* Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings
|
|
2590
|
+
* Note: In RPC mode, `playerAddress` and `gameAddress` fields will be empty strings,
|
|
2591
|
+
* and filter params (`playerAddress`, `gameTokenIds`, `hasSubmitted`, `isBanned`)
|
|
2592
|
+
* are applied via on-chain viewer functions where supported.
|
|
2559
2593
|
*/
|
|
2560
2594
|
async getTournamentRegistrations(tournamentId, params) {
|
|
2561
2595
|
const rpcFallback = async () => {
|
|
2562
2596
|
const contract = await this.getViewerContract();
|
|
2563
2597
|
const offset = params?.offset ?? 0;
|
|
2564
2598
|
const limit = params?.limit ?? 20;
|
|
2599
|
+
if (params?.playerAddress) {
|
|
2600
|
+
return viewerRegistrationsByOwner(contract, tournamentId, params.playerAddress, offset, limit);
|
|
2601
|
+
}
|
|
2602
|
+
if (params?.gameTokenIds?.length) {
|
|
2603
|
+
return viewerRegistrationsByTokenIds(contract, tournamentId, params.gameTokenIds, offset, limit);
|
|
2604
|
+
}
|
|
2565
2605
|
return viewerRegistrations(contract, tournamentId, offset, limit);
|
|
2566
2606
|
};
|
|
2567
2607
|
if (this.resolvedConfig.primarySource === "rpc") {
|
|
@@ -2966,20 +3006,21 @@ function useRegistrations(tournamentId, params) {
|
|
|
2966
3006
|
}, [fetch2]);
|
|
2967
3007
|
return { registrations, loading, error, refetch: fetch2 };
|
|
2968
3008
|
}
|
|
2969
|
-
function usePlayer(address) {
|
|
3009
|
+
function usePlayer(address, params) {
|
|
2970
3010
|
const client = useBudokanClient();
|
|
2971
3011
|
const [tournaments, setTournaments] = react.useState(null);
|
|
2972
3012
|
const [stats, setStats] = react.useState(null);
|
|
2973
3013
|
const [loading, setLoading] = react.useState(!!address);
|
|
2974
3014
|
const [error, setError] = react.useState(null);
|
|
2975
3015
|
useResetOnClient(client, setTournaments, setStats, setError);
|
|
3016
|
+
const paramsKey = JSON.stringify(params);
|
|
2976
3017
|
const fetch2 = react.useCallback(async () => {
|
|
2977
3018
|
if (!address) return;
|
|
2978
3019
|
setLoading(true);
|
|
2979
3020
|
setError(null);
|
|
2980
3021
|
try {
|
|
2981
3022
|
const [tournamentsResult, statsResult] = await Promise.all([
|
|
2982
|
-
client.getPlayerTournaments(address),
|
|
3023
|
+
client.getPlayerTournaments(address, params),
|
|
2983
3024
|
client.getPlayerStats(address)
|
|
2984
3025
|
]);
|
|
2985
3026
|
setTournaments(tournamentsResult);
|
|
@@ -2989,7 +3030,7 @@ function usePlayer(address) {
|
|
|
2989
3030
|
} finally {
|
|
2990
3031
|
setLoading(false);
|
|
2991
3032
|
}
|
|
2992
|
-
}, [client, address]);
|
|
3033
|
+
}, [client, address, paramsKey]);
|
|
2993
3034
|
react.useEffect(() => {
|
|
2994
3035
|
fetch2();
|
|
2995
3036
|
}, [fetch2]);
|
|
@@ -3044,25 +3085,26 @@ function usePlayerTournaments(address, params) {
|
|
|
3044
3085
|
}, [fetch2]);
|
|
3045
3086
|
return { tournaments, loading, error, refetch: fetch2 };
|
|
3046
3087
|
}
|
|
3047
|
-
function useRewardClaims(tournamentId) {
|
|
3088
|
+
function useRewardClaims(tournamentId, params) {
|
|
3048
3089
|
const client = useBudokanClient();
|
|
3049
3090
|
const [rewardClaims, setRewardClaims] = react.useState(null);
|
|
3050
3091
|
const [loading, setLoading] = react.useState(!!tournamentId);
|
|
3051
3092
|
const [error, setError] = react.useState(null);
|
|
3052
3093
|
useResetOnClient(client, setRewardClaims, setError);
|
|
3094
|
+
const paramsKey = JSON.stringify(params);
|
|
3053
3095
|
const fetch2 = react.useCallback(async () => {
|
|
3054
3096
|
if (!tournamentId) return;
|
|
3055
3097
|
setLoading(true);
|
|
3056
3098
|
setError(null);
|
|
3057
3099
|
try {
|
|
3058
|
-
const result = await client.getTournamentRewardClaims(tournamentId);
|
|
3100
|
+
const result = await client.getTournamentRewardClaims(tournamentId, params);
|
|
3059
3101
|
setRewardClaims(result);
|
|
3060
3102
|
} catch (e) {
|
|
3061
3103
|
setError(e);
|
|
3062
3104
|
} finally {
|
|
3063
3105
|
setLoading(false);
|
|
3064
3106
|
}
|
|
3065
|
-
}, [client, tournamentId]);
|
|
3107
|
+
}, [client, tournamentId, paramsKey]);
|
|
3066
3108
|
react.useEffect(() => {
|
|
3067
3109
|
fetch2();
|
|
3068
3110
|
}, [fetch2]);
|
|
@@ -3163,25 +3205,26 @@ function usePrizeAggregation(tournamentId) {
|
|
|
3163
3205
|
}, [fetch2]);
|
|
3164
3206
|
return { prizeAggregation, loading, error, refetch: fetch2 };
|
|
3165
3207
|
}
|
|
3166
|
-
function useQualifications(tournamentId) {
|
|
3208
|
+
function useQualifications(tournamentId, params) {
|
|
3167
3209
|
const client = useBudokanClient();
|
|
3168
3210
|
const [qualifications, setQualifications] = react.useState(null);
|
|
3169
3211
|
const [loading, setLoading] = react.useState(!!tournamentId);
|
|
3170
3212
|
const [error, setError] = react.useState(null);
|
|
3171
3213
|
useResetOnClient(client, setQualifications, setError);
|
|
3214
|
+
const paramsKey = JSON.stringify(params);
|
|
3172
3215
|
const fetch2 = react.useCallback(async () => {
|
|
3173
3216
|
if (!tournamentId) return;
|
|
3174
3217
|
setLoading(true);
|
|
3175
3218
|
setError(null);
|
|
3176
3219
|
try {
|
|
3177
|
-
const result = await client.getTournamentQualifications(tournamentId);
|
|
3220
|
+
const result = await client.getTournamentQualifications(tournamentId, params);
|
|
3178
3221
|
setQualifications(result);
|
|
3179
3222
|
} catch (e) {
|
|
3180
3223
|
setError(e);
|
|
3181
3224
|
} finally {
|
|
3182
3225
|
setLoading(false);
|
|
3183
3226
|
}
|
|
3184
|
-
}, [client, tournamentId]);
|
|
3227
|
+
}, [client, tournamentId, paramsKey]);
|
|
3185
3228
|
react.useEffect(() => {
|
|
3186
3229
|
fetch2();
|
|
3187
3230
|
}, [fetch2]);
|