@provable-games/budokan-sdk 0.1.21 → 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-0HDPKrdw.d.cts → client-DlXvzneQ.d.cts} +30 -20
- package/dist/{client-0HDPKrdw.d.ts → client-DlXvzneQ.d.ts} +30 -20
- package/dist/index.cjs +80 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +80 -3
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +80 -3
- 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 -3
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
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 { 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-
|
|
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 { 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-
|
|
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
|
@@ -1112,6 +1112,84 @@ async function viewerPrizes(contract, tournamentId) {
|
|
|
1112
1112
|
return result.map(parsePrize);
|
|
1113
1113
|
}, contract.address);
|
|
1114
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
|
+
}
|
|
1115
1193
|
async function viewerRewardClaims(contract, tournamentId, offset, limit) {
|
|
1116
1194
|
return wrapRpcCall(async () => {
|
|
1117
1195
|
const result = await contract.call("tournament_reward_claims", [tournamentId, offset, limit]);
|
|
@@ -1119,7 +1197,7 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
|
|
|
1119
1197
|
const claims = obj.claims?.map((raw) => {
|
|
1120
1198
|
const claim = raw;
|
|
1121
1199
|
return {
|
|
1122
|
-
|
|
1200
|
+
...translateCairoRewardType(claim.reward_type),
|
|
1123
1201
|
claimed: Boolean(claim.claimed)
|
|
1124
1202
|
};
|
|
1125
1203
|
}) ?? [];
|
|
@@ -4516,8 +4594,7 @@ var BudokanClient = class {
|
|
|
4516
4594
|
const result = await viewerRewardClaims(contract, tournamentId, offset, limit);
|
|
4517
4595
|
const data = result.claims.map((c) => ({
|
|
4518
4596
|
tournamentId,
|
|
4519
|
-
|
|
4520
|
-
claimed: c.claimed
|
|
4597
|
+
...c
|
|
4521
4598
|
}));
|
|
4522
4599
|
return { data, total: result.total, limit, offset };
|
|
4523
4600
|
};
|