@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/{client-CoWIQozF.d.cts → client-DlXvzneQ.d.cts} +31 -43
- package/dist/{client-CoWIQozF.d.ts → client-DlXvzneQ.d.ts} +31 -43
- package/dist/index.cjs +80 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -7
- package/dist/index.d.ts +3 -7
- package/dist/index.js +81 -28
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +80 -27
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +80 -27
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -358,23 +358,6 @@ function fetchOpts3(ctx) {
|
|
|
358
358
|
timeout: ctx?.timeout
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
|
-
async function getActivity(baseUrl, params, ctx) {
|
|
362
|
-
const qs = buildQueryString({
|
|
363
|
-
event_type: params?.eventType,
|
|
364
|
-
tournament_id: params?.tournamentId,
|
|
365
|
-
player_address: params?.playerAddress,
|
|
366
|
-
limit: params?.limit,
|
|
367
|
-
offset: params?.offset
|
|
368
|
-
});
|
|
369
|
-
const result = await apiFetch(`${baseUrl}/activity${qs}`, fetchOpts3(ctx));
|
|
370
|
-
const { total, limit: resLimit, offset: resOffset } = extractPagination(result, { limit: params?.limit, offset: params?.offset });
|
|
371
|
-
return {
|
|
372
|
-
data: result.data.map((item) => snakeToCamel(item)),
|
|
373
|
-
total,
|
|
374
|
-
limit: resLimit,
|
|
375
|
-
offset: resOffset
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
361
|
async function getActivityStats(baseUrl, ctx) {
|
|
379
362
|
const result = await apiFetch(
|
|
380
363
|
`${baseUrl}/activity/stats`,
|
|
@@ -1131,6 +1114,84 @@ async function viewerPrizes(contract, tournamentId) {
|
|
|
1131
1114
|
return result.map(parsePrize);
|
|
1132
1115
|
}, contract.address);
|
|
1133
1116
|
}
|
|
1117
|
+
function translateCairoRewardType(rewardType) {
|
|
1118
|
+
if (!rewardType || typeof rewardType !== "object") {
|
|
1119
|
+
throw new Error(`Unexpected RewardType payload: ${JSON.stringify(rewardType)}`);
|
|
1120
|
+
}
|
|
1121
|
+
const rt = rewardType;
|
|
1122
|
+
const outer = typeof rt.activeVariant === "function" ? rt.activeVariant() : null;
|
|
1123
|
+
const innerBag = typeof rt.activeVariant === "function" ? rt.variant : rt;
|
|
1124
|
+
if (outer === "Prize" || innerBag.Prize !== void 0) {
|
|
1125
|
+
const prize = innerBag.Prize;
|
|
1126
|
+
const subVariant = typeof prize?.activeVariant === "function" ? prize.activeVariant() : null;
|
|
1127
|
+
const subBag = typeof prize?.activeVariant === "function" ? prize.variant : prize;
|
|
1128
|
+
if (subVariant === "Single" || subBag?.Single !== void 0) {
|
|
1129
|
+
return {
|
|
1130
|
+
claimKind: "prize_single",
|
|
1131
|
+
prizeId: BigInt(subBag.Single).toString(),
|
|
1132
|
+
payoutIndex: null,
|
|
1133
|
+
position: null,
|
|
1134
|
+
refundTokenId: null
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
if (subVariant === "Distributed" || subBag?.Distributed !== void 0) {
|
|
1138
|
+
const distributed = subBag.Distributed;
|
|
1139
|
+
const prizeId = distributed?.["0"] ?? distributed?.[0];
|
|
1140
|
+
const payoutIndex = distributed?.["1"] ?? distributed?.[1];
|
|
1141
|
+
return {
|
|
1142
|
+
claimKind: "prize_distributed",
|
|
1143
|
+
prizeId: BigInt(prizeId).toString(),
|
|
1144
|
+
payoutIndex: Number(payoutIndex),
|
|
1145
|
+
position: null,
|
|
1146
|
+
refundTokenId: null
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (outer === "EntryFee" || innerBag.EntryFee !== void 0) {
|
|
1151
|
+
const entryFee = innerBag.EntryFee;
|
|
1152
|
+
const subVariant = typeof entryFee?.activeVariant === "function" ? entryFee.activeVariant() : null;
|
|
1153
|
+
const subBag = typeof entryFee?.activeVariant === "function" ? entryFee.variant : entryFee;
|
|
1154
|
+
if (subVariant === "Position" || subBag?.Position !== void 0) {
|
|
1155
|
+
return {
|
|
1156
|
+
claimKind: "entry_fee_position",
|
|
1157
|
+
prizeId: null,
|
|
1158
|
+
payoutIndex: null,
|
|
1159
|
+
position: Number(subBag.Position),
|
|
1160
|
+
refundTokenId: null
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
if (subVariant === "TournamentCreator" || subBag?.TournamentCreator !== void 0) {
|
|
1164
|
+
return {
|
|
1165
|
+
claimKind: "entry_fee_tournament_creator",
|
|
1166
|
+
prizeId: null,
|
|
1167
|
+
payoutIndex: null,
|
|
1168
|
+
position: null,
|
|
1169
|
+
refundTokenId: null
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
if (subVariant === "GameCreator" || subBag?.GameCreator !== void 0) {
|
|
1173
|
+
return {
|
|
1174
|
+
claimKind: "entry_fee_game_creator",
|
|
1175
|
+
prizeId: null,
|
|
1176
|
+
payoutIndex: null,
|
|
1177
|
+
position: null,
|
|
1178
|
+
refundTokenId: null
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
if (subVariant === "Refund" || subBag?.Refund !== void 0) {
|
|
1182
|
+
return {
|
|
1183
|
+
claimKind: "entry_fee_refund",
|
|
1184
|
+
prizeId: null,
|
|
1185
|
+
payoutIndex: null,
|
|
1186
|
+
position: null,
|
|
1187
|
+
refundTokenId: `0x${BigInt(subBag.Refund).toString(16)}`
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
throw new Error(
|
|
1192
|
+
`Unrecognised on-chain RewardType variant: ${JSON.stringify(rewardType)}`
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1134
1195
|
async function viewerRewardClaims(contract, tournamentId, offset, limit) {
|
|
1135
1196
|
return wrapRpcCall(async () => {
|
|
1136
1197
|
const result = await contract.call("tournament_reward_claims", [tournamentId, offset, limit]);
|
|
@@ -1138,7 +1199,7 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
|
|
|
1138
1199
|
const claims = obj.claims?.map((raw) => {
|
|
1139
1200
|
const claim = raw;
|
|
1140
1201
|
return {
|
|
1141
|
-
|
|
1202
|
+
...translateCairoRewardType(claim.reward_type),
|
|
1142
1203
|
claimed: Boolean(claim.claimed)
|
|
1143
1204
|
};
|
|
1144
1205
|
}) ?? [];
|
|
@@ -4535,8 +4596,7 @@ var BudokanClient = class {
|
|
|
4535
4596
|
const result = await viewerRewardClaims(contract, tournamentId, offset, limit);
|
|
4536
4597
|
const data = result.claims.map((c) => ({
|
|
4537
4598
|
tournamentId,
|
|
4538
|
-
|
|
4539
|
-
claimed: c.claimed
|
|
4599
|
+
...c
|
|
4540
4600
|
}));
|
|
4541
4601
|
return { data, total: result.total, limit, offset };
|
|
4542
4602
|
};
|
|
@@ -4587,13 +4647,6 @@ var BudokanClient = class {
|
|
|
4587
4647
|
return getTournamentPrizeAggregation(this.resolvedConfig.apiBaseUrl, tournamentId, this.apiCtx);
|
|
4588
4648
|
}
|
|
4589
4649
|
// ---- Activity Queries (API-only, activity is indexed) ----
|
|
4590
|
-
/**
|
|
4591
|
-
* Fetch activity events with optional filtering.
|
|
4592
|
-
* API-only — no RPC fallback available.
|
|
4593
|
-
*/
|
|
4594
|
-
async getActivity(params) {
|
|
4595
|
-
return getActivity(this.resolvedConfig.apiBaseUrl, params, this.apiCtx);
|
|
4596
|
-
}
|
|
4597
4650
|
/**
|
|
4598
4651
|
* Fetch platform-wide activity stats.
|
|
4599
4652
|
* API-only — no RPC fallback available.
|