@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/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, A as ActivityParams, g as ActivityEvent, h as PrizeStats, W as WSSubscribeOptions, i as WSEventHandler } from './client-CoWIQozF.cjs';
2
- export { B as BudokanClient, j as BudokanClientConfig, C as ConnectionMode, k as ConnectionStatus, l as ConnectionStatusState, D as DataSource, G as GameConfig, L as LeaderboardConfig, m as LeaderboardEntry, n as Phase, S as Schedule, o as WSChannel, p as WSEventMessage, q as WSMessage, r as WSSubscribeMessage, s as WSUnsubscribeMessage, t as createBudokanClient } from './client-CoWIQozF.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 './client-DlXvzneQ.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-DlXvzneQ.cjs';
3
3
  export { EntryFee } from '@provable-games/metagame-sdk';
4
4
  import 'starknet';
5
5
 
@@ -105,10 +105,6 @@ interface ApiContext {
105
105
  retryDelay?: number;
106
106
  timeout?: number;
107
107
  }
108
- /**
109
- * Fetch activity events with optional filtering.
110
- */
111
- declare function getActivity(baseUrl: string, params?: ActivityParams, ctx?: ApiContext): Promise<PaginatedResult<ActivityEvent>>;
112
108
  /**
113
109
  * Fetch platform-wide activity stats.
114
110
  */
@@ -194,4 +190,4 @@ interface ChainConfig {
194
190
  declare const CHAINS: Record<string, ChainConfig>;
195
191
  declare function getChainConfig(chain: string): ChainConfig | undefined;
196
192
 
197
- export { ActivityEvent, ActivityParams, BudokanApiError, BudokanConnectionError, BudokanError, BudokanTimeoutError, CHAINS, type ChainConfig, DataSourceError, PaginatedResult, PlatformStats, Prize, PrizeAggregation, PrizeStats, QualificationEntry, Registration, RewardClaim, RewardClaimSummary, RpcError, Tournament, TournamentListParams, TournamentNotFoundError, WSEventHandler, WSManager, WSSubscribeOptions, camelToSnake, getActivity, getActivityStats, getChainConfig, getGameStats, getGameTournaments, getPrizeStats, getTournament, getTournamentPrizeAggregation, getTournamentPrizes, getTournamentQualifications, getTournamentRegistrations, getTournamentRewardClaims, getTournamentRewardClaimsSummary, getTournaments, normalizeAddress, snakeToCamel, withRetry };
193
+ export { BudokanApiError, BudokanConnectionError, BudokanError, BudokanTimeoutError, CHAINS, type ChainConfig, DataSourceError, PaginatedResult, PlatformStats, Prize, PrizeAggregation, PrizeStats, QualificationEntry, Registration, RewardClaim, RewardClaimSummary, RpcError, Tournament, TournamentListParams, TournamentNotFoundError, WSEventHandler, WSManager, WSSubscribeOptions, camelToSnake, getActivityStats, getChainConfig, getGameStats, getGameTournaments, getPrizeStats, getTournament, getTournamentPrizeAggregation, getTournamentPrizes, getTournamentQualifications, getTournamentRegistrations, getTournamentRewardClaims, getTournamentRewardClaimsSummary, getTournaments, normalizeAddress, snakeToCamel, withRetry };
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, A as ActivityParams, g as ActivityEvent, h as PrizeStats, W as WSSubscribeOptions, i as WSEventHandler } from './client-CoWIQozF.js';
2
- export { B as BudokanClient, j as BudokanClientConfig, C as ConnectionMode, k as ConnectionStatus, l as ConnectionStatusState, D as DataSource, G as GameConfig, L as LeaderboardConfig, m as LeaderboardEntry, n as Phase, S as Schedule, o as WSChannel, p as WSEventMessage, q as WSMessage, r as WSSubscribeMessage, s as WSUnsubscribeMessage, t as createBudokanClient } from './client-CoWIQozF.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 './client-DlXvzneQ.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-DlXvzneQ.js';
3
3
  export { EntryFee } from '@provable-games/metagame-sdk';
4
4
  import 'starknet';
5
5
 
@@ -105,10 +105,6 @@ interface ApiContext {
105
105
  retryDelay?: number;
106
106
  timeout?: number;
107
107
  }
108
- /**
109
- * Fetch activity events with optional filtering.
110
- */
111
- declare function getActivity(baseUrl: string, params?: ActivityParams, ctx?: ApiContext): Promise<PaginatedResult<ActivityEvent>>;
112
108
  /**
113
109
  * Fetch platform-wide activity stats.
114
110
  */
@@ -194,4 +190,4 @@ interface ChainConfig {
194
190
  declare const CHAINS: Record<string, ChainConfig>;
195
191
  declare function getChainConfig(chain: string): ChainConfig | undefined;
196
192
 
197
- export { ActivityEvent, ActivityParams, BudokanApiError, BudokanConnectionError, BudokanError, BudokanTimeoutError, CHAINS, type ChainConfig, DataSourceError, PaginatedResult, PlatformStats, Prize, PrizeAggregation, PrizeStats, QualificationEntry, Registration, RewardClaim, RewardClaimSummary, RpcError, Tournament, TournamentListParams, TournamentNotFoundError, WSEventHandler, WSManager, WSSubscribeOptions, camelToSnake, getActivity, getActivityStats, getChainConfig, getGameStats, getGameTournaments, getPrizeStats, getTournament, getTournamentPrizeAggregation, getTournamentPrizes, getTournamentQualifications, getTournamentRegistrations, getTournamentRewardClaims, getTournamentRewardClaimsSummary, getTournaments, normalizeAddress, snakeToCamel, withRetry };
193
+ export { BudokanApiError, BudokanConnectionError, BudokanError, BudokanTimeoutError, CHAINS, type ChainConfig, DataSourceError, PaginatedResult, PlatformStats, Prize, PrizeAggregation, PrizeStats, QualificationEntry, Registration, RewardClaim, RewardClaimSummary, RpcError, Tournament, TournamentListParams, TournamentNotFoundError, WSEventHandler, WSManager, WSSubscribeOptions, camelToSnake, getActivityStats, getChainConfig, getGameStats, getGameTournaments, getPrizeStats, getTournament, getTournamentPrizeAggregation, getTournamentPrizes, getTournamentQualifications, getTournamentRegistrations, getTournamentRewardClaims, getTournamentRewardClaimsSummary, getTournaments, normalizeAddress, snakeToCamel, withRetry };
package/dist/index.js CHANGED
@@ -367,23 +367,6 @@ function fetchOpts3(ctx) {
367
367
  timeout: ctx?.timeout
368
368
  };
369
369
  }
370
- async function getActivity(baseUrl, params, ctx) {
371
- const qs = buildQueryString({
372
- event_type: params?.eventType,
373
- tournament_id: params?.tournamentId,
374
- player_address: params?.playerAddress,
375
- limit: params?.limit,
376
- offset: params?.offset
377
- });
378
- const result = await apiFetch(`${baseUrl}/activity${qs}`, fetchOpts3(ctx));
379
- const { total, limit: resLimit, offset: resOffset } = extractPagination(result, { limit: params?.limit, offset: params?.offset });
380
- return {
381
- data: result.data.map((item) => snakeToCamel(item)),
382
- total,
383
- limit: resLimit,
384
- offset: resOffset
385
- };
386
- }
387
370
  async function getActivityStats(baseUrl, ctx) {
388
371
  const result = await apiFetch(
389
372
  `${baseUrl}/activity/stats`,
@@ -1140,6 +1123,84 @@ async function viewerPrizes(contract, tournamentId) {
1140
1123
  return result.map(parsePrize);
1141
1124
  }, contract.address);
1142
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
+ }
1143
1204
  async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1144
1205
  return wrapRpcCall(async () => {
1145
1206
  const result = await contract.call("tournament_reward_claims", [tournamentId, offset, limit]);
@@ -1147,7 +1208,7 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1147
1208
  const claims = obj.claims?.map((raw) => {
1148
1209
  const claim = raw;
1149
1210
  return {
1150
- rewardType: claim.reward_type,
1211
+ ...translateCairoRewardType(claim.reward_type),
1151
1212
  claimed: Boolean(claim.claimed)
1152
1213
  };
1153
1214
  }) ?? [];
@@ -4544,8 +4605,7 @@ var BudokanClient = class {
4544
4605
  const result = await viewerRewardClaims(contract, tournamentId, offset, limit);
4545
4606
  const data = result.claims.map((c) => ({
4546
4607
  tournamentId,
4547
- rewardType: c.rewardType,
4548
- claimed: c.claimed
4608
+ ...c
4549
4609
  }));
4550
4610
  return { data, total: result.total, limit, offset };
4551
4611
  };
@@ -4596,13 +4656,6 @@ var BudokanClient = class {
4596
4656
  return getTournamentPrizeAggregation(this.resolvedConfig.apiBaseUrl, tournamentId, this.apiCtx);
4597
4657
  }
4598
4658
  // ---- Activity Queries (API-only, activity is indexed) ----
4599
- /**
4600
- * Fetch activity events with optional filtering.
4601
- * API-only — no RPC fallback available.
4602
- */
4603
- async getActivity(params) {
4604
- return getActivity(this.resolvedConfig.apiBaseUrl, params, this.apiCtx);
4605
- }
4606
4659
  /**
4607
4660
  * Fetch platform-wide activity stats.
4608
4661
  * API-only — no RPC fallback available.
@@ -4656,6 +4709,6 @@ function createBudokanClient(config) {
4656
4709
  return new BudokanClient(config);
4657
4710
  }
4658
4711
 
4659
- export { BudokanApiError, BudokanClient, BudokanConnectionError, BudokanError, BudokanTimeoutError, CHAINS, ConnectionStatus, DataSourceError, RpcError, TournamentNotFoundError, WSManager, camelToSnake, createBudokanClient, getActivity, getActivityStats, getChainConfig, getGameStats, getGameTournaments, getPrizeStats, getTournament, getTournamentPrizeAggregation, getTournamentPrizes, getTournamentQualifications, getTournamentRegistrations, getTournamentRewardClaims, getTournamentRewardClaimsSummary, getTournaments, normalizeAddress, snakeToCamel, withRetry };
4712
+ export { BudokanApiError, BudokanClient, BudokanConnectionError, BudokanError, BudokanTimeoutError, CHAINS, ConnectionStatus, DataSourceError, RpcError, TournamentNotFoundError, WSManager, camelToSnake, createBudokanClient, getActivityStats, getChainConfig, getGameStats, getGameTournaments, getPrizeStats, getTournament, getTournamentPrizeAggregation, getTournamentPrizes, getTournamentQualifications, getTournamentRegistrations, getTournamentRewardClaims, getTournamentRewardClaimsSummary, getTournaments, normalizeAddress, snakeToCamel, withRetry };
4660
4713
  //# sourceMappingURL=index.js.map
4661
4714
  //# sourceMappingURL=index.js.map