@provable-games/budokan-sdk 0.1.21 → 0.1.23

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as Tournament, P as PrizeAggregation, a as Prize, b as PaginatedResult, Q as QualificationEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, e as TournamentListParams, f as PlatformStats, g as PrizeStats, W as WSSubscribeOptions, h as WSEventHandler } from './client-0HDPKrdw.cjs';
2
- export { B as BudokanClient, i as BudokanClientConfig, C as ConnectionMode, j as ConnectionStatus, k as ConnectionStatusState, D as DataSource, G as GameConfig, L as LeaderboardConfig, l as LeaderboardEntry, m as Phase, S as Schedule, n as WSChannel, o as WSEventMessage, p as WSMessage, q as WSSubscribeMessage, r as WSUnsubscribeMessage, s as createBudokanClient } from './client-0HDPKrdw.cjs';
1
+ import { T as Tournament, P as PrizeAggregation, a as Prize, b as PaginatedResult, Q as QualificationEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, e as TournamentListParams, f as PlatformStats, g as PrizeStats, W as WSSubscribeOptions, h as WSEventHandler } from './player-BUynfv7D.cjs';
2
+ export { B as BudokanClient, i as BudokanClientConfig, C as ConnectionMode, j as ConnectionStatus, k as ConnectionStatusState, D as DataSource, G as GameConfig, L as LeaderboardConfig, l as LeaderboardEntry, m as Phase, n as PlayerPlacement, o as PlayerRewards, S as Schedule, p as WSChannel, q as WSEventMessage, r as WSMessage, s as WSSubscribeMessage, t as WSUnsubscribeMessage, u as createBudokanClient } from './player-BUynfv7D.cjs';
3
3
  export { EntryFee } from '@provable-games/metagame-sdk';
4
4
  import 'starknet';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as Tournament, P as PrizeAggregation, a as Prize, b as PaginatedResult, Q as QualificationEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, e as TournamentListParams, f as PlatformStats, g as PrizeStats, W as WSSubscribeOptions, h as WSEventHandler } from './client-0HDPKrdw.js';
2
- export { B as BudokanClient, i as BudokanClientConfig, C as ConnectionMode, j as ConnectionStatus, k as ConnectionStatusState, D as DataSource, G as GameConfig, L as LeaderboardConfig, l as LeaderboardEntry, m as Phase, S as Schedule, n as WSChannel, o as WSEventMessage, p as WSMessage, q as WSSubscribeMessage, r as WSUnsubscribeMessage, s as createBudokanClient } from './client-0HDPKrdw.js';
1
+ import { T as Tournament, P as PrizeAggregation, a as Prize, b as PaginatedResult, Q as QualificationEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, e as TournamentListParams, f as PlatformStats, g as PrizeStats, W as WSSubscribeOptions, h as WSEventHandler } from './player-BUynfv7D.js';
2
+ export { B as BudokanClient, i as BudokanClientConfig, C as ConnectionMode, j as ConnectionStatus, k as ConnectionStatusState, D as DataSource, G as GameConfig, L as LeaderboardConfig, l as LeaderboardEntry, m as Phase, n as PlayerPlacement, o as PlayerRewards, S as Schedule, p as WSChannel, q as WSEventMessage, r as WSMessage, s as WSSubscribeMessage, t as WSUnsubscribeMessage, u as createBudokanClient } from './player-BUynfv7D.js';
3
3
  export { EntryFee } from '@provable-games/metagame-sdk';
4
4
  import 'starknet';
5
5
 
package/dist/index.js CHANGED
@@ -1123,6 +1123,84 @@ async function viewerPrizes(contract, tournamentId) {
1123
1123
  return result.map(parsePrize);
1124
1124
  }, contract.address);
1125
1125
  }
1126
+ function translateCairoRewardType(rewardType) {
1127
+ if (!rewardType || typeof rewardType !== "object") {
1128
+ throw new Error(`Unexpected RewardType payload: ${JSON.stringify(rewardType)}`);
1129
+ }
1130
+ const rt = rewardType;
1131
+ const outer = typeof rt.activeVariant === "function" ? rt.activeVariant() : null;
1132
+ const innerBag = typeof rt.activeVariant === "function" ? rt.variant : rt;
1133
+ if (outer === "Prize" || innerBag.Prize !== void 0) {
1134
+ const prize = innerBag.Prize;
1135
+ const subVariant = typeof prize?.activeVariant === "function" ? prize.activeVariant() : null;
1136
+ const subBag = typeof prize?.activeVariant === "function" ? prize.variant : prize;
1137
+ if (subVariant === "Single" || subBag?.Single !== void 0) {
1138
+ return {
1139
+ claimKind: "prize_single",
1140
+ prizeId: BigInt(subBag.Single).toString(),
1141
+ payoutIndex: null,
1142
+ position: null,
1143
+ refundTokenId: null
1144
+ };
1145
+ }
1146
+ if (subVariant === "Distributed" || subBag?.Distributed !== void 0) {
1147
+ const distributed = subBag.Distributed;
1148
+ const prizeId = distributed?.["0"] ?? distributed?.[0];
1149
+ const payoutIndex = distributed?.["1"] ?? distributed?.[1];
1150
+ return {
1151
+ claimKind: "prize_distributed",
1152
+ prizeId: BigInt(prizeId).toString(),
1153
+ payoutIndex: Number(payoutIndex),
1154
+ position: null,
1155
+ refundTokenId: null
1156
+ };
1157
+ }
1158
+ }
1159
+ if (outer === "EntryFee" || innerBag.EntryFee !== void 0) {
1160
+ const entryFee = innerBag.EntryFee;
1161
+ const subVariant = typeof entryFee?.activeVariant === "function" ? entryFee.activeVariant() : null;
1162
+ const subBag = typeof entryFee?.activeVariant === "function" ? entryFee.variant : entryFee;
1163
+ if (subVariant === "Position" || subBag?.Position !== void 0) {
1164
+ return {
1165
+ claimKind: "entry_fee_position",
1166
+ prizeId: null,
1167
+ payoutIndex: null,
1168
+ position: Number(subBag.Position),
1169
+ refundTokenId: null
1170
+ };
1171
+ }
1172
+ if (subVariant === "TournamentCreator" || subBag?.TournamentCreator !== void 0) {
1173
+ return {
1174
+ claimKind: "entry_fee_tournament_creator",
1175
+ prizeId: null,
1176
+ payoutIndex: null,
1177
+ position: null,
1178
+ refundTokenId: null
1179
+ };
1180
+ }
1181
+ if (subVariant === "GameCreator" || subBag?.GameCreator !== void 0) {
1182
+ return {
1183
+ claimKind: "entry_fee_game_creator",
1184
+ prizeId: null,
1185
+ payoutIndex: null,
1186
+ position: null,
1187
+ refundTokenId: null
1188
+ };
1189
+ }
1190
+ if (subVariant === "Refund" || subBag?.Refund !== void 0) {
1191
+ return {
1192
+ claimKind: "entry_fee_refund",
1193
+ prizeId: null,
1194
+ payoutIndex: null,
1195
+ position: null,
1196
+ refundTokenId: `0x${BigInt(subBag.Refund).toString(16)}`
1197
+ };
1198
+ }
1199
+ }
1200
+ throw new Error(
1201
+ `Unrecognised on-chain RewardType variant: ${JSON.stringify(rewardType)}`
1202
+ );
1203
+ }
1126
1204
  async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1127
1205
  return wrapRpcCall(async () => {
1128
1206
  const result = await contract.call("tournament_reward_claims", [tournamentId, offset, limit]);
@@ -1130,7 +1208,7 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1130
1208
  const claims = obj.claims?.map((raw) => {
1131
1209
  const claim = raw;
1132
1210
  return {
1133
- rewardType: claim.reward_type,
1211
+ ...translateCairoRewardType(claim.reward_type),
1134
1212
  claimed: Boolean(claim.claimed)
1135
1213
  };
1136
1214
  }) ?? [];
@@ -4527,8 +4605,7 @@ var BudokanClient = class {
4527
4605
  const result = await viewerRewardClaims(contract, tournamentId, offset, limit);
4528
4606
  const data = result.claims.map((c) => ({
4529
4607
  tournamentId,
4530
- rewardType: c.rewardType,
4531
- claimed: c.claimed
4608
+ ...c
4532
4609
  }));
4533
4610
  return { data, total: result.total, limit, offset };
4534
4611
  };