@provable-games/budokan-sdk 0.1.20 → 0.1.22

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 { j as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, n as Phase, m as LeaderboardEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, h as PrizeStats, a as Prize, P as PrizeAggregation, Q as QualificationEntry, f as PlatformStats, p as WSEventMessage, o as WSChannel, C as ConnectionMode } from './client-CoWIQozF.cjs';
3
+ import { i as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, m as Phase, l as LeaderboardEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, g as PrizeStats, a as Prize, P as PrizeAggregation, Q as QualificationEntry, f as PlatformStats, o as WSEventMessage, n as WSChannel, C as ConnectionMode } from './client-DlXvzneQ.cjs';
4
4
  import 'starknet';
5
5
  import '@provable-games/metagame-sdk';
6
6
 
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 { j as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, n as Phase, m as LeaderboardEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, h as PrizeStats, a as Prize, P as PrizeAggregation, Q as QualificationEntry, f as PlatformStats, p as WSEventMessage, o as WSChannel, C as ConnectionMode } from './client-CoWIQozF.js';
3
+ import { i as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, m as Phase, l as LeaderboardEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, g as PrizeStats, a as Prize, P as PrizeAggregation, Q as QualificationEntry, f as PlatformStats, o as WSEventMessage, n as WSChannel, C as ConnectionMode } from './client-DlXvzneQ.js';
4
4
  import 'starknet';
5
5
  import '@provable-games/metagame-sdk';
6
6
 
package/dist/react.js CHANGED
@@ -356,23 +356,6 @@ function fetchOpts3(ctx) {
356
356
  timeout: ctx?.timeout
357
357
  };
358
358
  }
359
- async function getActivity(baseUrl, params, ctx) {
360
- const qs = buildQueryString({
361
- event_type: params?.eventType,
362
- tournament_id: params?.tournamentId,
363
- player_address: params?.playerAddress,
364
- limit: params?.limit,
365
- offset: params?.offset
366
- });
367
- const result = await apiFetch(`${baseUrl}/activity${qs}`, fetchOpts3(ctx));
368
- const { total, limit: resLimit, offset: resOffset } = extractPagination(result, { limit: params?.limit, offset: params?.offset });
369
- return {
370
- data: result.data.map((item) => snakeToCamel(item)),
371
- total,
372
- limit: resLimit,
373
- offset: resOffset
374
- };
375
- }
376
359
  async function getActivityStats(baseUrl, ctx) {
377
360
  const result = await apiFetch(
378
361
  `${baseUrl}/activity/stats`,
@@ -1129,6 +1112,84 @@ async function viewerPrizes(contract, tournamentId) {
1129
1112
  return result.map(parsePrize);
1130
1113
  }, contract.address);
1131
1114
  }
1115
+ function translateCairoRewardType(rewardType) {
1116
+ if (!rewardType || typeof rewardType !== "object") {
1117
+ throw new Error(`Unexpected RewardType payload: ${JSON.stringify(rewardType)}`);
1118
+ }
1119
+ const rt = rewardType;
1120
+ const outer = typeof rt.activeVariant === "function" ? rt.activeVariant() : null;
1121
+ const innerBag = typeof rt.activeVariant === "function" ? rt.variant : rt;
1122
+ if (outer === "Prize" || innerBag.Prize !== void 0) {
1123
+ const prize = innerBag.Prize;
1124
+ const subVariant = typeof prize?.activeVariant === "function" ? prize.activeVariant() : null;
1125
+ const subBag = typeof prize?.activeVariant === "function" ? prize.variant : prize;
1126
+ if (subVariant === "Single" || subBag?.Single !== void 0) {
1127
+ return {
1128
+ claimKind: "prize_single",
1129
+ prizeId: BigInt(subBag.Single).toString(),
1130
+ payoutIndex: null,
1131
+ position: null,
1132
+ refundTokenId: null
1133
+ };
1134
+ }
1135
+ if (subVariant === "Distributed" || subBag?.Distributed !== void 0) {
1136
+ const distributed = subBag.Distributed;
1137
+ const prizeId = distributed?.["0"] ?? distributed?.[0];
1138
+ const payoutIndex = distributed?.["1"] ?? distributed?.[1];
1139
+ return {
1140
+ claimKind: "prize_distributed",
1141
+ prizeId: BigInt(prizeId).toString(),
1142
+ payoutIndex: Number(payoutIndex),
1143
+ position: null,
1144
+ refundTokenId: null
1145
+ };
1146
+ }
1147
+ }
1148
+ if (outer === "EntryFee" || innerBag.EntryFee !== void 0) {
1149
+ const entryFee = innerBag.EntryFee;
1150
+ const subVariant = typeof entryFee?.activeVariant === "function" ? entryFee.activeVariant() : null;
1151
+ const subBag = typeof entryFee?.activeVariant === "function" ? entryFee.variant : entryFee;
1152
+ if (subVariant === "Position" || subBag?.Position !== void 0) {
1153
+ return {
1154
+ claimKind: "entry_fee_position",
1155
+ prizeId: null,
1156
+ payoutIndex: null,
1157
+ position: Number(subBag.Position),
1158
+ refundTokenId: null
1159
+ };
1160
+ }
1161
+ if (subVariant === "TournamentCreator" || subBag?.TournamentCreator !== void 0) {
1162
+ return {
1163
+ claimKind: "entry_fee_tournament_creator",
1164
+ prizeId: null,
1165
+ payoutIndex: null,
1166
+ position: null,
1167
+ refundTokenId: null
1168
+ };
1169
+ }
1170
+ if (subVariant === "GameCreator" || subBag?.GameCreator !== void 0) {
1171
+ return {
1172
+ claimKind: "entry_fee_game_creator",
1173
+ prizeId: null,
1174
+ payoutIndex: null,
1175
+ position: null,
1176
+ refundTokenId: null
1177
+ };
1178
+ }
1179
+ if (subVariant === "Refund" || subBag?.Refund !== void 0) {
1180
+ return {
1181
+ claimKind: "entry_fee_refund",
1182
+ prizeId: null,
1183
+ payoutIndex: null,
1184
+ position: null,
1185
+ refundTokenId: `0x${BigInt(subBag.Refund).toString(16)}`
1186
+ };
1187
+ }
1188
+ }
1189
+ throw new Error(
1190
+ `Unrecognised on-chain RewardType variant: ${JSON.stringify(rewardType)}`
1191
+ );
1192
+ }
1132
1193
  async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1133
1194
  return wrapRpcCall(async () => {
1134
1195
  const result = await contract.call("tournament_reward_claims", [tournamentId, offset, limit]);
@@ -1136,7 +1197,7 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1136
1197
  const claims = obj.claims?.map((raw) => {
1137
1198
  const claim = raw;
1138
1199
  return {
1139
- rewardType: claim.reward_type,
1200
+ ...translateCairoRewardType(claim.reward_type),
1140
1201
  claimed: Boolean(claim.claimed)
1141
1202
  };
1142
1203
  }) ?? [];
@@ -4533,8 +4594,7 @@ var BudokanClient = class {
4533
4594
  const result = await viewerRewardClaims(contract, tournamentId, offset, limit);
4534
4595
  const data = result.claims.map((c) => ({
4535
4596
  tournamentId,
4536
- rewardType: c.rewardType,
4537
- claimed: c.claimed
4597
+ ...c
4538
4598
  }));
4539
4599
  return { data, total: result.total, limit, offset };
4540
4600
  };
@@ -4585,13 +4645,6 @@ var BudokanClient = class {
4585
4645
  return getTournamentPrizeAggregation(this.resolvedConfig.apiBaseUrl, tournamentId, this.apiCtx);
4586
4646
  }
4587
4647
  // ---- Activity Queries (API-only, activity is indexed) ----
4588
- /**
4589
- * Fetch activity events with optional filtering.
4590
- * API-only — no RPC fallback available.
4591
- */
4592
- async getActivity(params) {
4593
- return getActivity(this.resolvedConfig.apiBaseUrl, params, this.apiCtx);
4594
- }
4595
4648
  /**
4596
4649
  * Fetch platform-wide activity stats.
4597
4650
  * API-only — no RPC fallback available.