@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RpcProvider } from 'starknet';
|
|
2
|
-
import { EntryFee, EntryRequirement
|
|
2
|
+
import { EntryFee, EntryRequirement } from '@provable-games/metagame-sdk';
|
|
3
3
|
|
|
4
4
|
type DataSource = "api" | "rpc";
|
|
5
5
|
interface BudokanClientConfig {
|
|
@@ -111,9 +111,20 @@ interface TournamentListParams {
|
|
|
111
111
|
whitelistedExtensions?: string[];
|
|
112
112
|
includePrizeSummary?: "summary" | boolean;
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Discriminator for `QualificationEntry.qualificationKind`. Picks one of
|
|
116
|
+
* the two terminal variants of the on-chain `QualificationProof` enum
|
|
117
|
+
* (NFT, Extension). `nftTokenId` is populated only for `nft`;
|
|
118
|
+
* `extensionConfig` only for `extension`.
|
|
119
|
+
*/
|
|
120
|
+
type QualificationKind = "nft" | "extension";
|
|
114
121
|
interface QualificationEntry {
|
|
115
122
|
tournamentId: string;
|
|
116
|
-
|
|
123
|
+
qualificationKind: QualificationKind;
|
|
124
|
+
/** Populated when `qualificationKind === "nft"`. u256 token id, decimal string. */
|
|
125
|
+
nftTokenId: string | null;
|
|
126
|
+
/** Populated when `qualificationKind === "extension"`. List of felt252 hex strings. */
|
|
127
|
+
extensionConfig: string[] | null;
|
|
117
128
|
entryCount: number;
|
|
118
129
|
}
|
|
119
130
|
|
|
@@ -141,23 +152,6 @@ interface Registration {
|
|
|
141
152
|
isBanned: boolean;
|
|
142
153
|
}
|
|
143
154
|
|
|
144
|
-
type RewardType = {
|
|
145
|
-
Prize: {
|
|
146
|
-
tokenAddress: string;
|
|
147
|
-
tokenType: string;
|
|
148
|
-
};
|
|
149
|
-
} | {
|
|
150
|
-
EntryFee: EntryFeeRewardType;
|
|
151
|
-
};
|
|
152
|
-
type EntryFeeRewardType = {
|
|
153
|
-
Position: number;
|
|
154
|
-
} | {
|
|
155
|
-
TournamentCreator: Record<string, never>;
|
|
156
|
-
} | {
|
|
157
|
-
GameCreator: Record<string, never>;
|
|
158
|
-
} | {
|
|
159
|
-
Refund: string;
|
|
160
|
-
};
|
|
161
155
|
interface Prize {
|
|
162
156
|
prizeId: string;
|
|
163
157
|
tournamentId: string;
|
|
@@ -174,9 +168,25 @@ interface Prize {
|
|
|
174
168
|
distributionCount: number | null;
|
|
175
169
|
sponsorAddress: string;
|
|
176
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Discriminator for `RewardClaim.claimKind`. Picks one of the six terminal
|
|
173
|
+
* variants of the on-chain `RewardType` enum (Prize::Single, Prize::Distributed,
|
|
174
|
+
* EntryFee::Position / TournamentCreator / GameCreator / Refund). The
|
|
175
|
+
* variant-specific fields below are populated only for the kinds that carry
|
|
176
|
+
* them; the two pure-marker creator kinds leave all four nullable fields null.
|
|
177
|
+
*/
|
|
178
|
+
type RewardClaimKind = "prize_single" | "prize_distributed" | "entry_fee_position" | "entry_fee_tournament_creator" | "entry_fee_game_creator" | "entry_fee_refund";
|
|
177
179
|
interface RewardClaim {
|
|
178
180
|
tournamentId: string;
|
|
179
|
-
|
|
181
|
+
claimKind: RewardClaimKind;
|
|
182
|
+
/** Populated for `prize_single` and `prize_distributed`. Stringified u64. */
|
|
183
|
+
prizeId: string | null;
|
|
184
|
+
/** Populated for `prize_distributed`. */
|
|
185
|
+
payoutIndex: number | null;
|
|
186
|
+
/** Populated for `entry_fee_position`. */
|
|
187
|
+
position: number | null;
|
|
188
|
+
/** Populated for `entry_fee_refund`. felt252 hex string of the game token. */
|
|
189
|
+
refundTokenId: string | null;
|
|
180
190
|
claimed: boolean;
|
|
181
191
|
}
|
|
182
192
|
interface PrizeAggregation {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RpcProvider } from 'starknet';
|
|
2
|
-
import { EntryFee, EntryRequirement
|
|
2
|
+
import { EntryFee, EntryRequirement } from '@provable-games/metagame-sdk';
|
|
3
3
|
|
|
4
4
|
type DataSource = "api" | "rpc";
|
|
5
5
|
interface BudokanClientConfig {
|
|
@@ -111,9 +111,20 @@ interface TournamentListParams {
|
|
|
111
111
|
whitelistedExtensions?: string[];
|
|
112
112
|
includePrizeSummary?: "summary" | boolean;
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Discriminator for `QualificationEntry.qualificationKind`. Picks one of
|
|
116
|
+
* the two terminal variants of the on-chain `QualificationProof` enum
|
|
117
|
+
* (NFT, Extension). `nftTokenId` is populated only for `nft`;
|
|
118
|
+
* `extensionConfig` only for `extension`.
|
|
119
|
+
*/
|
|
120
|
+
type QualificationKind = "nft" | "extension";
|
|
114
121
|
interface QualificationEntry {
|
|
115
122
|
tournamentId: string;
|
|
116
|
-
|
|
123
|
+
qualificationKind: QualificationKind;
|
|
124
|
+
/** Populated when `qualificationKind === "nft"`. u256 token id, decimal string. */
|
|
125
|
+
nftTokenId: string | null;
|
|
126
|
+
/** Populated when `qualificationKind === "extension"`. List of felt252 hex strings. */
|
|
127
|
+
extensionConfig: string[] | null;
|
|
117
128
|
entryCount: number;
|
|
118
129
|
}
|
|
119
130
|
|
|
@@ -141,23 +152,6 @@ interface Registration {
|
|
|
141
152
|
isBanned: boolean;
|
|
142
153
|
}
|
|
143
154
|
|
|
144
|
-
type RewardType = {
|
|
145
|
-
Prize: {
|
|
146
|
-
tokenAddress: string;
|
|
147
|
-
tokenType: string;
|
|
148
|
-
};
|
|
149
|
-
} | {
|
|
150
|
-
EntryFee: EntryFeeRewardType;
|
|
151
|
-
};
|
|
152
|
-
type EntryFeeRewardType = {
|
|
153
|
-
Position: number;
|
|
154
|
-
} | {
|
|
155
|
-
TournamentCreator: Record<string, never>;
|
|
156
|
-
} | {
|
|
157
|
-
GameCreator: Record<string, never>;
|
|
158
|
-
} | {
|
|
159
|
-
Refund: string;
|
|
160
|
-
};
|
|
161
155
|
interface Prize {
|
|
162
156
|
prizeId: string;
|
|
163
157
|
tournamentId: string;
|
|
@@ -174,9 +168,25 @@ interface Prize {
|
|
|
174
168
|
distributionCount: number | null;
|
|
175
169
|
sponsorAddress: string;
|
|
176
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Discriminator for `RewardClaim.claimKind`. Picks one of the six terminal
|
|
173
|
+
* variants of the on-chain `RewardType` enum (Prize::Single, Prize::Distributed,
|
|
174
|
+
* EntryFee::Position / TournamentCreator / GameCreator / Refund). The
|
|
175
|
+
* variant-specific fields below are populated only for the kinds that carry
|
|
176
|
+
* them; the two pure-marker creator kinds leave all four nullable fields null.
|
|
177
|
+
*/
|
|
178
|
+
type RewardClaimKind = "prize_single" | "prize_distributed" | "entry_fee_position" | "entry_fee_tournament_creator" | "entry_fee_game_creator" | "entry_fee_refund";
|
|
177
179
|
interface RewardClaim {
|
|
178
180
|
tournamentId: string;
|
|
179
|
-
|
|
181
|
+
claimKind: RewardClaimKind;
|
|
182
|
+
/** Populated for `prize_single` and `prize_distributed`. Stringified u64. */
|
|
183
|
+
prizeId: string | null;
|
|
184
|
+
/** Populated for `prize_distributed`. */
|
|
185
|
+
payoutIndex: number | null;
|
|
186
|
+
/** Populated for `entry_fee_position`. */
|
|
187
|
+
position: number | null;
|
|
188
|
+
/** Populated for `entry_fee_refund`. felt252 hex string of the game token. */
|
|
189
|
+
refundTokenId: string | null;
|
|
180
190
|
claimed: boolean;
|
|
181
191
|
}
|
|
182
192
|
interface PrizeAggregation {
|
package/dist/index.cjs
CHANGED
|
@@ -1125,6 +1125,84 @@ async function viewerPrizes(contract, tournamentId) {
|
|
|
1125
1125
|
return result.map(parsePrize);
|
|
1126
1126
|
}, contract.address);
|
|
1127
1127
|
}
|
|
1128
|
+
function translateCairoRewardType(rewardType) {
|
|
1129
|
+
if (!rewardType || typeof rewardType !== "object") {
|
|
1130
|
+
throw new Error(`Unexpected RewardType payload: ${JSON.stringify(rewardType)}`);
|
|
1131
|
+
}
|
|
1132
|
+
const rt = rewardType;
|
|
1133
|
+
const outer = typeof rt.activeVariant === "function" ? rt.activeVariant() : null;
|
|
1134
|
+
const innerBag = typeof rt.activeVariant === "function" ? rt.variant : rt;
|
|
1135
|
+
if (outer === "Prize" || innerBag.Prize !== void 0) {
|
|
1136
|
+
const prize = innerBag.Prize;
|
|
1137
|
+
const subVariant = typeof prize?.activeVariant === "function" ? prize.activeVariant() : null;
|
|
1138
|
+
const subBag = typeof prize?.activeVariant === "function" ? prize.variant : prize;
|
|
1139
|
+
if (subVariant === "Single" || subBag?.Single !== void 0) {
|
|
1140
|
+
return {
|
|
1141
|
+
claimKind: "prize_single",
|
|
1142
|
+
prizeId: BigInt(subBag.Single).toString(),
|
|
1143
|
+
payoutIndex: null,
|
|
1144
|
+
position: null,
|
|
1145
|
+
refundTokenId: null
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
if (subVariant === "Distributed" || subBag?.Distributed !== void 0) {
|
|
1149
|
+
const distributed = subBag.Distributed;
|
|
1150
|
+
const prizeId = distributed?.["0"] ?? distributed?.[0];
|
|
1151
|
+
const payoutIndex = distributed?.["1"] ?? distributed?.[1];
|
|
1152
|
+
return {
|
|
1153
|
+
claimKind: "prize_distributed",
|
|
1154
|
+
prizeId: BigInt(prizeId).toString(),
|
|
1155
|
+
payoutIndex: Number(payoutIndex),
|
|
1156
|
+
position: null,
|
|
1157
|
+
refundTokenId: null
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
if (outer === "EntryFee" || innerBag.EntryFee !== void 0) {
|
|
1162
|
+
const entryFee = innerBag.EntryFee;
|
|
1163
|
+
const subVariant = typeof entryFee?.activeVariant === "function" ? entryFee.activeVariant() : null;
|
|
1164
|
+
const subBag = typeof entryFee?.activeVariant === "function" ? entryFee.variant : entryFee;
|
|
1165
|
+
if (subVariant === "Position" || subBag?.Position !== void 0) {
|
|
1166
|
+
return {
|
|
1167
|
+
claimKind: "entry_fee_position",
|
|
1168
|
+
prizeId: null,
|
|
1169
|
+
payoutIndex: null,
|
|
1170
|
+
position: Number(subBag.Position),
|
|
1171
|
+
refundTokenId: null
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
if (subVariant === "TournamentCreator" || subBag?.TournamentCreator !== void 0) {
|
|
1175
|
+
return {
|
|
1176
|
+
claimKind: "entry_fee_tournament_creator",
|
|
1177
|
+
prizeId: null,
|
|
1178
|
+
payoutIndex: null,
|
|
1179
|
+
position: null,
|
|
1180
|
+
refundTokenId: null
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
if (subVariant === "GameCreator" || subBag?.GameCreator !== void 0) {
|
|
1184
|
+
return {
|
|
1185
|
+
claimKind: "entry_fee_game_creator",
|
|
1186
|
+
prizeId: null,
|
|
1187
|
+
payoutIndex: null,
|
|
1188
|
+
position: null,
|
|
1189
|
+
refundTokenId: null
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
if (subVariant === "Refund" || subBag?.Refund !== void 0) {
|
|
1193
|
+
return {
|
|
1194
|
+
claimKind: "entry_fee_refund",
|
|
1195
|
+
prizeId: null,
|
|
1196
|
+
payoutIndex: null,
|
|
1197
|
+
position: null,
|
|
1198
|
+
refundTokenId: `0x${BigInt(subBag.Refund).toString(16)}`
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
throw new Error(
|
|
1203
|
+
`Unrecognised on-chain RewardType variant: ${JSON.stringify(rewardType)}`
|
|
1204
|
+
);
|
|
1205
|
+
}
|
|
1128
1206
|
async function viewerRewardClaims(contract, tournamentId, offset, limit) {
|
|
1129
1207
|
return wrapRpcCall(async () => {
|
|
1130
1208
|
const result = await contract.call("tournament_reward_claims", [tournamentId, offset, limit]);
|
|
@@ -1132,7 +1210,7 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
|
|
|
1132
1210
|
const claims = obj.claims?.map((raw) => {
|
|
1133
1211
|
const claim = raw;
|
|
1134
1212
|
return {
|
|
1135
|
-
|
|
1213
|
+
...translateCairoRewardType(claim.reward_type),
|
|
1136
1214
|
claimed: Boolean(claim.claimed)
|
|
1137
1215
|
};
|
|
1138
1216
|
}) ?? [];
|
|
@@ -4529,8 +4607,7 @@ var BudokanClient = class {
|
|
|
4529
4607
|
const result = await viewerRewardClaims(contract, tournamentId, offset, limit);
|
|
4530
4608
|
const data = result.claims.map((c) => ({
|
|
4531
4609
|
tournamentId,
|
|
4532
|
-
|
|
4533
|
-
claimed: c.claimed
|
|
4610
|
+
...c
|
|
4534
4611
|
}));
|
|
4535
4612
|
return { data, total: result.total, limit, offset };
|
|
4536
4613
|
};
|