@provable-games/budokan-sdk 0.1.22 → 0.1.24

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/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createContext, useMemo, useRef, useEffect, useContext, useState, useCallback } from 'react';
2
2
  import { num, CairoCustomEnum } from 'starknet';
3
3
  import { jsx } from 'react/jsx-runtime';
4
- import { useTokens } from '@provable-games/denshokan-sdk/react';
4
+ import { useTokens, useDenshokanClient } from '@provable-games/denshokan-sdk/react';
5
5
 
6
6
  // src/react/context.tsx
7
7
 
@@ -533,11 +533,14 @@ var CHAINS = {
533
533
  viewerAddress: "0x013c8239361fdbd7ec26db2c83f4ff270c5bba83a0bc105b4005b676ff57fdbe"
534
534
  },
535
535
  sepolia: {
536
- rpcUrl: "https://starknet-sepolia.public.blastapi.io",
536
+ rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia/rpc/v0_10",
537
537
  apiBaseUrl: "https://budokan-api-sepolia.up.railway.app",
538
538
  wsUrl: "wss://budokan-api-sepolia.up.railway.app/ws",
539
- budokanAddress: "0x017750a167b7c4968249d7db06dccc8b3908ef8954cb40cfe4d3c651ca0dcd1d",
540
- viewerAddress: "0x03d5febe0042b943967074f4ebd850a6b5d50850cd3fb84fbd0eb66dadd9ddec"
539
+ budokanAddress: "0x074cc823c382d98e6b8d657aa86776a57d85e1dc2912d54d83a4fef147472683",
540
+ // Redeployed 2026-06-18 to match the upgraded #264/#269 budokan class —
541
+ // the prior viewer (0x03da56…) was built against the old budokan interface
542
+ // (called the removed `tournament_entries`) and reverted RPC reads.
543
+ viewerAddress: "0x06b2773d5f1f8bfa5aa3b698fbbaea0472b30af003ea6058330ed52a1acaa283"
541
544
  }
542
545
  };
543
546
  function getChainConfig(chain) {
@@ -838,23 +841,36 @@ function parseTournament(raw, entryCount) {
838
841
  const lc = obj.leaderboard_config;
839
842
  const ascending = Boolean(lc?.ascending);
840
843
  const gameMustBeOver = Boolean(lc?.game_must_be_over);
841
- const entryFeeRaw = parseOption(obj.entry_fee);
844
+ const entryFeeKind = parseOption(obj.entry_fee);
842
845
  let entryFeeToken = null;
843
846
  let entryFeeAmount = null;
844
847
  let entryFee = null;
845
- if (entryFeeRaw) {
846
- const ef = entryFeeRaw;
847
- entryFeeToken = num.toHex(ef.token_address);
848
- entryFeeAmount = String(ef.amount ?? "0");
849
- entryFee = {
850
- tokenAddress: entryFeeToken,
851
- amount: entryFeeAmount,
852
- tournamentCreatorShare: Number(ef.tournament_creator_share ?? 0),
853
- gameCreatorShare: Number(ef.game_creator_share ?? 0),
854
- refundShare: Number(ef.refund_share ?? 0),
855
- distribution: ef.distribution ?? null,
856
- distributionCount: Number(ef.distribution_count ?? 0)
857
- };
848
+ let entryFeeKindTag = null;
849
+ let entryFeeExtension = null;
850
+ if (entryFeeKind) {
851
+ const variantBag = entryFeeKind.variant ?? entryFeeKind;
852
+ const ef = variantBag.BuiltIn;
853
+ const ext = variantBag.Extension;
854
+ if (ef) {
855
+ entryFeeKindTag = "builtin";
856
+ entryFeeToken = num.toHex(ef.token_address);
857
+ entryFeeAmount = String(ef.amount ?? "0");
858
+ entryFee = {
859
+ tokenAddress: entryFeeToken,
860
+ amount: entryFeeAmount,
861
+ tournamentCreatorShare: Number(ef.tournament_creator_share ?? 0),
862
+ gameCreatorShare: Number(ef.game_creator_share ?? 0),
863
+ refundShare: Number(ef.refund_share ?? 0),
864
+ distribution: ef.distribution ?? null,
865
+ distributionCount: Number(ef.distribution_count ?? 0)
866
+ };
867
+ } else if (ext) {
868
+ entryFeeKindTag = "extension";
869
+ entryFeeExtension = {
870
+ address: num.toHex(ext.address),
871
+ config: Array.isArray(ext.config) ? ext.config.map((x) => num.toHex(x)) : []
872
+ };
873
+ }
858
874
  }
859
875
  const entryRequirement = parseOption(obj.entry_requirement);
860
876
  const hasEntryRequirement = entryRequirement !== null;
@@ -904,6 +920,8 @@ function parseTournament(raw, entryCount) {
904
920
  renderer
905
921
  },
906
922
  entryFee,
923
+ entryFeeKind: entryFeeKindTag,
924
+ entryFeeExtension,
907
925
  entryRequirement,
908
926
  leaderboardConfig: { ascending, gameMustBeOver },
909
927
  entryCount,
@@ -934,8 +952,40 @@ function parseRegistration(raw, tournamentId) {
934
952
  };
935
953
  }
936
954
  function parsePrize(raw) {
937
- const obj = raw;
938
- const tokenTypeData = obj.token_type;
955
+ const record = raw;
956
+ const prizeEnum = record.prize;
957
+ if (!prizeEnum) {
958
+ throw new Error(`PrizeRecord missing prize field: ${JSON.stringify(raw)}`);
959
+ }
960
+ const activePrize = typeof prizeEnum.activeVariant === "function" ? prizeEnum.activeVariant() : prizeEnum.Token !== void 0 ? "Token" : prizeEnum.Extension !== void 0 ? "Extension" : null;
961
+ const prizeVariantBag = prizeEnum.variant ?? prizeEnum;
962
+ if (activePrize === "Extension") {
963
+ const ext = prizeVariantBag.Extension;
964
+ return {
965
+ prizeId: String(record.id ?? "0"),
966
+ tournamentId: String(record.context_id ?? "0"),
967
+ payoutPosition: 0,
968
+ tokenAddress: null,
969
+ tokenType: "extension",
970
+ amount: null,
971
+ tokenId: null,
972
+ distributionType: null,
973
+ distributionWeight: null,
974
+ distributionShares: null,
975
+ distributionCount: null,
976
+ sponsorAddress: num.toHex(record.sponsor_address),
977
+ extensionAddress: ext?.address != null ? num.toHex(ext.address) : null,
978
+ extensionConfig: Array.isArray(ext?.config) ? ext.config.map((x) => num.toHex(x)) : null
979
+ };
980
+ }
981
+ if (activePrize !== "Token") {
982
+ throw new Error(`Unrecognised Prize variant: ${JSON.stringify(prizeEnum)}`);
983
+ }
984
+ const tokenPayload = prizeVariantBag.Token;
985
+ if (!tokenPayload) {
986
+ throw new Error(`Prize::Token missing payload: ${JSON.stringify(prizeEnum)}`);
987
+ }
988
+ const tokenTypeData = tokenPayload.token_type;
939
989
  let tokenType = "erc20";
940
990
  let amount = null;
941
991
  let tokenId = null;
@@ -976,10 +1026,10 @@ function parsePrize(raw) {
976
1026
  }
977
1027
  }
978
1028
  return {
979
- prizeId: String(obj.id ?? "0"),
980
- tournamentId: String(obj.context_id ?? "0"),
1029
+ prizeId: String(record.id ?? "0"),
1030
+ tournamentId: String(record.context_id ?? "0"),
981
1031
  payoutPosition,
982
- tokenAddress: num.toHex(obj.token_address),
1032
+ tokenAddress: num.toHex(tokenPayload.token_address),
983
1033
  tokenType,
984
1034
  amount,
985
1035
  tokenId,
@@ -987,7 +1037,9 @@ function parsePrize(raw) {
987
1037
  distributionWeight,
988
1038
  distributionShares,
989
1039
  distributionCount,
990
- sponsorAddress: num.toHex(obj.sponsor_address)
1040
+ sponsorAddress: num.toHex(record.sponsor_address),
1041
+ extensionAddress: null,
1042
+ extensionConfig: null
991
1043
  };
992
1044
  }
993
1045
  function parseOption(raw) {
@@ -1112,6 +1164,20 @@ async function viewerPrizes(contract, tournamentId) {
1112
1164
  return result.map(parsePrize);
1113
1165
  }, contract.address);
1114
1166
  }
1167
+ function rewardClaim(partial) {
1168
+ return {
1169
+ prizeId: null,
1170
+ payoutIndex: null,
1171
+ position: null,
1172
+ refundTokenId: null,
1173
+ extensionTokenId: null,
1174
+ extensionParams: null,
1175
+ ...partial
1176
+ };
1177
+ }
1178
+ function spanToHex(v) {
1179
+ return Array.isArray(v) ? v.map((x) => num.toHex(x)) : [];
1180
+ }
1115
1181
  function translateCairoRewardType(rewardType) {
1116
1182
  if (!rewardType || typeof rewardType !== "object") {
1117
1183
  throw new Error(`Unexpected RewardType payload: ${JSON.stringify(rewardType)}`);
@@ -1120,70 +1186,70 @@ function translateCairoRewardType(rewardType) {
1120
1186
  const outer = typeof rt.activeVariant === "function" ? rt.activeVariant() : null;
1121
1187
  const innerBag = typeof rt.activeVariant === "function" ? rt.variant : rt;
1122
1188
  if (outer === "Prize" || innerBag.Prize !== void 0) {
1123
- const prize = innerBag.Prize;
1189
+ const prizeClaim = innerBag.Prize;
1190
+ const pcBag = typeof prizeClaim?.activeVariant === "function" ? prizeClaim.variant : prizeClaim;
1191
+ if (pcBag?.Token === void 0 && pcBag?.Extension !== void 0) {
1192
+ const ext = pcBag.Extension;
1193
+ const tokenId = parseOption(ext.token_id);
1194
+ return rewardClaim({
1195
+ claimKind: "prize_extension",
1196
+ prizeId: BigInt(ext.prize_id ?? 0).toString(),
1197
+ extensionTokenId: tokenId != null ? num.toHex(tokenId) : null,
1198
+ extensionParams: spanToHex(ext.payout_params)
1199
+ });
1200
+ }
1201
+ const prize = pcBag?.Token ?? prizeClaim;
1124
1202
  const subVariant = typeof prize?.activeVariant === "function" ? prize.activeVariant() : null;
1125
1203
  const subBag = typeof prize?.activeVariant === "function" ? prize.variant : prize;
1126
1204
  if (subVariant === "Single" || subBag?.Single !== void 0) {
1127
- return {
1205
+ return rewardClaim({
1128
1206
  claimKind: "prize_single",
1129
- prizeId: BigInt(subBag.Single).toString(),
1130
- payoutIndex: null,
1131
- position: null,
1132
- refundTokenId: null
1133
- };
1207
+ prizeId: BigInt(subBag.Single).toString()
1208
+ });
1134
1209
  }
1135
1210
  if (subVariant === "Distributed" || subBag?.Distributed !== void 0) {
1136
1211
  const distributed = subBag.Distributed;
1137
1212
  const prizeId = distributed?.["0"] ?? distributed?.[0];
1138
1213
  const payoutIndex = distributed?.["1"] ?? distributed?.[1];
1139
- return {
1214
+ return rewardClaim({
1140
1215
  claimKind: "prize_distributed",
1141
1216
  prizeId: BigInt(prizeId).toString(),
1142
- payoutIndex: Number(payoutIndex),
1143
- position: null,
1144
- refundTokenId: null
1145
- };
1217
+ payoutIndex: Number(payoutIndex)
1218
+ });
1146
1219
  }
1147
1220
  }
1148
1221
  if (outer === "EntryFee" || innerBag.EntryFee !== void 0) {
1149
- const entryFee = innerBag.EntryFee;
1222
+ const entryFeeClaim = innerBag.EntryFee;
1223
+ const efBag = typeof entryFeeClaim?.activeVariant === "function" ? entryFeeClaim.variant : entryFeeClaim;
1224
+ if (efBag?.Token === void 0 && efBag?.Extension !== void 0) {
1225
+ const ext = efBag.Extension;
1226
+ const tokenId = parseOption(ext.token_id);
1227
+ return rewardClaim({
1228
+ claimKind: "entry_fee_extension",
1229
+ extensionTokenId: tokenId != null ? num.toHex(tokenId) : null,
1230
+ extensionParams: spanToHex(ext.claim_params)
1231
+ });
1232
+ }
1233
+ const entryFee = efBag?.Token ?? entryFeeClaim;
1150
1234
  const subVariant = typeof entryFee?.activeVariant === "function" ? entryFee.activeVariant() : null;
1151
1235
  const subBag = typeof entryFee?.activeVariant === "function" ? entryFee.variant : entryFee;
1152
1236
  if (subVariant === "Position" || subBag?.Position !== void 0) {
1153
- return {
1237
+ return rewardClaim({
1154
1238
  claimKind: "entry_fee_position",
1155
- prizeId: null,
1156
- payoutIndex: null,
1157
- position: Number(subBag.Position),
1158
- refundTokenId: null
1159
- };
1239
+ position: Number(subBag.Position)
1240
+ });
1160
1241
  }
1161
1242
  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
- };
1243
+ return rewardClaim({ claimKind: "entry_fee_tournament_creator" });
1169
1244
  }
1170
1245
  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
- };
1246
+ return rewardClaim({ claimKind: "entry_fee_game_creator" });
1178
1247
  }
1179
1248
  if (subVariant === "Refund" || subBag?.Refund !== void 0) {
1180
- return {
1249
+ return rewardClaim({
1181
1250
  claimKind: "entry_fee_refund",
1182
- prizeId: null,
1183
- payoutIndex: null,
1184
- position: null,
1185
1251
  refundTokenId: `0x${BigInt(subBag.Refund).toString(16)}`
1186
- };
1252
+ });
1187
1253
  }
1188
1254
  }
1189
1255
  throw new Error(
@@ -1194,13 +1260,15 @@ async function viewerRewardClaims(contract, tournamentId, offset, limit) {
1194
1260
  return wrapRpcCall(async () => {
1195
1261
  const result = await contract.call("tournament_reward_claims", [tournamentId, offset, limit]);
1196
1262
  const obj = result;
1197
- const claims = obj.claims?.map((raw) => {
1198
- const claim = raw;
1199
- return {
1200
- ...translateCairoRewardType(claim.reward_type),
1201
- claimed: Boolean(claim.claimed)
1202
- };
1203
- }) ?? [];
1263
+ const claims = (obj.claims ?? []).map(
1264
+ (raw) => {
1265
+ const claim = raw;
1266
+ return {
1267
+ ...translateCairoRewardType(claim.reward_type),
1268
+ claimed: Boolean(claim.claimed)
1269
+ };
1270
+ }
1271
+ );
1204
1272
  return {
1205
1273
  claims,
1206
1274
  total: Number(obj.total ?? 0),
@@ -1480,20 +1548,6 @@ var budokanViewer_default = [
1480
1548
  }
1481
1549
  ]
1482
1550
  },
1483
- {
1484
- type: "enum",
1485
- name: "core::option::Option::<budokan_interfaces::budokan::EntryFee>",
1486
- variants: [
1487
- {
1488
- name: "Some",
1489
- type: "budokan_interfaces::budokan::EntryFee"
1490
- },
1491
- {
1492
- name: "None",
1493
- type: "()"
1494
- }
1495
- ]
1496
- },
1497
1551
  {
1498
1552
  type: "struct",
1499
1553
  name: "core::array::Span::<core::felt252>",
@@ -1518,6 +1572,34 @@ var budokanViewer_default = [
1518
1572
  }
1519
1573
  ]
1520
1574
  },
1575
+ {
1576
+ type: "enum",
1577
+ name: "budokan_interfaces::budokan::EntryFeeKind",
1578
+ variants: [
1579
+ {
1580
+ name: "BuiltIn",
1581
+ type: "budokan_interfaces::budokan::EntryFee"
1582
+ },
1583
+ {
1584
+ name: "Extension",
1585
+ type: "metagame_extensions_interfaces::extension::ExtensionConfig"
1586
+ }
1587
+ ]
1588
+ },
1589
+ {
1590
+ type: "enum",
1591
+ name: "core::option::Option::<budokan_interfaces::budokan::EntryFeeKind>",
1592
+ variants: [
1593
+ {
1594
+ name: "Some",
1595
+ type: "budokan_interfaces::budokan::EntryFeeKind"
1596
+ },
1597
+ {
1598
+ name: "None",
1599
+ type: "()"
1600
+ }
1601
+ ]
1602
+ },
1521
1603
  {
1522
1604
  type: "enum",
1523
1605
  name: "game_components_interfaces::entry_requirement::EntryRequirementType",
@@ -1608,7 +1690,7 @@ var budokanViewer_default = [
1608
1690
  },
1609
1691
  {
1610
1692
  name: "entry_fee",
1611
- type: "core::option::Option::<budokan_interfaces::budokan::EntryFee>"
1693
+ type: "core::option::Option::<budokan_interfaces::budokan::EntryFeeKind>"
1612
1694
  },
1613
1695
  {
1614
1696
  name: "entry_requirement",
@@ -1764,7 +1846,49 @@ var budokanViewer_default = [
1764
1846
  },
1765
1847
  {
1766
1848
  type: "struct",
1767
- name: "game_components_interfaces::prize::PrizeData",
1849
+ name: "game_components_interfaces::prize::TokenPrizePayload",
1850
+ members: [
1851
+ {
1852
+ name: "token_address",
1853
+ type: "core::starknet::contract_address::ContractAddress"
1854
+ },
1855
+ {
1856
+ name: "token_type",
1857
+ type: "game_components_interfaces::prize::TokenTypeData"
1858
+ }
1859
+ ]
1860
+ },
1861
+ {
1862
+ type: "struct",
1863
+ name: "game_components_interfaces::prize::ExtensionPrizePayload",
1864
+ members: [
1865
+ {
1866
+ name: "address",
1867
+ type: "core::starknet::contract_address::ContractAddress"
1868
+ },
1869
+ {
1870
+ name: "config",
1871
+ type: "core::array::Span::<core::felt252>"
1872
+ }
1873
+ ]
1874
+ },
1875
+ {
1876
+ type: "enum",
1877
+ name: "game_components_interfaces::prize::Prize",
1878
+ variants: [
1879
+ {
1880
+ name: "Token",
1881
+ type: "game_components_interfaces::prize::TokenPrizePayload"
1882
+ },
1883
+ {
1884
+ name: "Extension",
1885
+ type: "game_components_interfaces::prize::ExtensionPrizePayload"
1886
+ }
1887
+ ]
1888
+ },
1889
+ {
1890
+ type: "struct",
1891
+ name: "game_components_interfaces::prize::PrizeRecord",
1768
1892
  members: [
1769
1893
  {
1770
1894
  name: "id",
@@ -1775,16 +1899,12 @@ var budokanViewer_default = [
1775
1899
  type: "core::integer::u64"
1776
1900
  },
1777
1901
  {
1778
- name: "token_address",
1902
+ name: "sponsor_address",
1779
1903
  type: "core::starknet::contract_address::ContractAddress"
1780
1904
  },
1781
1905
  {
1782
- name: "token_type",
1783
- type: "game_components_interfaces::prize::TokenTypeData"
1784
- },
1785
- {
1786
- name: "sponsor_address",
1787
- type: "core::starknet::contract_address::ContractAddress"
1906
+ name: "prize",
1907
+ type: "game_components_interfaces::prize::Prize"
1788
1908
  }
1789
1909
  ]
1790
1910
  },
@@ -1802,6 +1922,52 @@ var budokanViewer_default = [
1802
1922
  }
1803
1923
  ]
1804
1924
  },
1925
+ {
1926
+ type: "enum",
1927
+ name: "core::option::Option::<core::felt252>",
1928
+ variants: [
1929
+ {
1930
+ name: "Some",
1931
+ type: "core::felt252"
1932
+ },
1933
+ {
1934
+ name: "None",
1935
+ type: "()"
1936
+ }
1937
+ ]
1938
+ },
1939
+ {
1940
+ type: "struct",
1941
+ name: "budokan_interfaces::budokan::ExtensionPrizeClaim",
1942
+ members: [
1943
+ {
1944
+ name: "prize_id",
1945
+ type: "core::integer::u64"
1946
+ },
1947
+ {
1948
+ name: "token_id",
1949
+ type: "core::option::Option::<core::felt252>"
1950
+ },
1951
+ {
1952
+ name: "payout_params",
1953
+ type: "core::array::Span::<core::felt252>"
1954
+ }
1955
+ ]
1956
+ },
1957
+ {
1958
+ type: "enum",
1959
+ name: "budokan_interfaces::budokan::PrizeClaim",
1960
+ variants: [
1961
+ {
1962
+ name: "Token",
1963
+ type: "game_components_interfaces::prize::PrizeType"
1964
+ },
1965
+ {
1966
+ name: "Extension",
1967
+ type: "budokan_interfaces::budokan::ExtensionPrizeClaim"
1968
+ }
1969
+ ]
1970
+ },
1805
1971
  {
1806
1972
  type: "enum",
1807
1973
  name: "budokan_interfaces::budokan::EntryFeeRewardType",
@@ -1824,17 +1990,45 @@ var budokanViewer_default = [
1824
1990
  }
1825
1991
  ]
1826
1992
  },
1993
+ {
1994
+ type: "struct",
1995
+ name: "budokan_interfaces::budokan::ExtensionEntryFeeClaim",
1996
+ members: [
1997
+ {
1998
+ name: "token_id",
1999
+ type: "core::option::Option::<core::felt252>"
2000
+ },
2001
+ {
2002
+ name: "claim_params",
2003
+ type: "core::array::Span::<core::felt252>"
2004
+ }
2005
+ ]
2006
+ },
2007
+ {
2008
+ type: "enum",
2009
+ name: "budokan_interfaces::budokan::EntryFeeClaim",
2010
+ variants: [
2011
+ {
2012
+ name: "Token",
2013
+ type: "budokan_interfaces::budokan::EntryFeeRewardType"
2014
+ },
2015
+ {
2016
+ name: "Extension",
2017
+ type: "budokan_interfaces::budokan::ExtensionEntryFeeClaim"
2018
+ }
2019
+ ]
2020
+ },
1827
2021
  {
1828
2022
  type: "enum",
1829
2023
  name: "budokan_interfaces::budokan::RewardType",
1830
2024
  variants: [
1831
2025
  {
1832
2026
  name: "Prize",
1833
- type: "game_components_interfaces::prize::PrizeType"
2027
+ type: "budokan_interfaces::budokan::PrizeClaim"
1834
2028
  },
1835
2029
  {
1836
2030
  name: "EntryFee",
1837
- type: "budokan_interfaces::budokan::EntryFeeRewardType"
2031
+ type: "budokan_interfaces::budokan::EntryFeeClaim"
1838
2032
  }
1839
2033
  ]
1840
2034
  },
@@ -2125,6 +2319,62 @@ var budokanViewer_default = [
2125
2319
  ],
2126
2320
  state_mutability: "view"
2127
2321
  },
2322
+ {
2323
+ type: "function",
2324
+ name: "tournament_registrations_by_owner",
2325
+ inputs: [
2326
+ {
2327
+ name: "tournament_id",
2328
+ type: "core::integer::u64"
2329
+ },
2330
+ {
2331
+ name: "owner",
2332
+ type: "core::starknet::contract_address::ContractAddress"
2333
+ },
2334
+ {
2335
+ name: "offset",
2336
+ type: "core::integer::u32"
2337
+ },
2338
+ {
2339
+ name: "limit",
2340
+ type: "core::integer::u32"
2341
+ }
2342
+ ],
2343
+ outputs: [
2344
+ {
2345
+ type: "budokan_interfaces::viewer::RegistrationResult"
2346
+ }
2347
+ ],
2348
+ state_mutability: "view"
2349
+ },
2350
+ {
2351
+ type: "function",
2352
+ name: "tournament_registrations_by_token_ids",
2353
+ inputs: [
2354
+ {
2355
+ name: "tournament_id",
2356
+ type: "core::integer::u64"
2357
+ },
2358
+ {
2359
+ name: "token_ids",
2360
+ type: "core::array::Array::<core::felt252>"
2361
+ },
2362
+ {
2363
+ name: "offset",
2364
+ type: "core::integer::u32"
2365
+ },
2366
+ {
2367
+ name: "limit",
2368
+ type: "core::integer::u32"
2369
+ }
2370
+ ],
2371
+ outputs: [
2372
+ {
2373
+ type: "budokan_interfaces::viewer::RegistrationResult"
2374
+ }
2375
+ ],
2376
+ state_mutability: "view"
2377
+ },
2128
2378
  {
2129
2379
  type: "function",
2130
2380
  name: "leaderboard",
@@ -2160,7 +2410,7 @@ var budokanViewer_default = [
2160
2410
  ],
2161
2411
  outputs: [
2162
2412
  {
2163
- type: "core::array::Array::<game_components_interfaces::prize::PrizeData>"
2413
+ type: "core::array::Array::<game_components_interfaces::prize::PrizeRecord>"
2164
2414
  }
2165
2415
  ],
2166
2416
  state_mutability: "view"
@@ -2421,35 +2671,69 @@ var budokan_default = [
2421
2671
  },
2422
2672
  {
2423
2673
  type: "impl",
2424
- name: "GameContextImpl",
2425
- interface_name: "game_components_interfaces::metagame::context::IMetagameContext"
2426
- },
2427
- {
2428
- type: "enum",
2429
- name: "core::bool",
2430
- variants: [
2431
- {
2432
- name: "False",
2433
- type: "()"
2434
- },
2435
- {
2436
- name: "True",
2437
- type: "()"
2438
- }
2439
- ]
2674
+ name: "BudokanRewardsAdminImpl",
2675
+ interface_name: "budokan::budokan::Budokan::IBudokanRewardsAdmin"
2440
2676
  },
2441
2677
  {
2442
2678
  type: "interface",
2443
- name: "game_components_interfaces::metagame::context::IMetagameContext",
2679
+ name: "budokan::budokan::Budokan::IBudokanRewardsAdmin",
2444
2680
  items: [
2445
2681
  {
2446
2682
  type: "function",
2447
- name: "has_context",
2683
+ name: "set_rewards_class_hash",
2448
2684
  inputs: [
2449
2685
  {
2450
- name: "token_id",
2451
- type: "core::felt252"
2452
- }
2686
+ name: "new_class_hash",
2687
+ type: "core::starknet::class_hash::ClassHash"
2688
+ }
2689
+ ],
2690
+ outputs: [],
2691
+ state_mutability: "external"
2692
+ },
2693
+ {
2694
+ type: "function",
2695
+ name: "rewards_class_hash",
2696
+ inputs: [],
2697
+ outputs: [
2698
+ {
2699
+ type: "core::starknet::class_hash::ClassHash"
2700
+ }
2701
+ ],
2702
+ state_mutability: "view"
2703
+ }
2704
+ ]
2705
+ },
2706
+ {
2707
+ type: "impl",
2708
+ name: "GameContextImpl",
2709
+ interface_name: "game_components_interfaces::metagame::context::IMetagameContext"
2710
+ },
2711
+ {
2712
+ type: "enum",
2713
+ name: "core::bool",
2714
+ variants: [
2715
+ {
2716
+ name: "False",
2717
+ type: "()"
2718
+ },
2719
+ {
2720
+ name: "True",
2721
+ type: "()"
2722
+ }
2723
+ ]
2724
+ },
2725
+ {
2726
+ type: "interface",
2727
+ name: "game_components_interfaces::metagame::context::IMetagameContext",
2728
+ items: [
2729
+ {
2730
+ type: "function",
2731
+ name: "has_context",
2732
+ inputs: [
2733
+ {
2734
+ name: "token_id",
2735
+ type: "core::felt252"
2736
+ }
2453
2737
  ],
2454
2738
  outputs: [
2455
2739
  {
@@ -2503,11 +2787,11 @@ var budokan_default = [
2503
2787
  members: [
2504
2788
  {
2505
2789
  name: "name",
2506
- type: "core::byte_array::ByteArray"
2790
+ type: "core::felt252"
2507
2791
  },
2508
2792
  {
2509
2793
  name: "value",
2510
- type: "core::byte_array::ByteArray"
2794
+ type: "core::felt252"
2511
2795
  }
2512
2796
  ]
2513
2797
  },
@@ -2735,50 +3019,54 @@ var budokan_default = [
2735
3019
  ]
2736
3020
  },
2737
3021
  {
2738
- type: "enum",
2739
- name: "core::option::Option::<budokan_interfaces::budokan::EntryFee>",
2740
- variants: [
2741
- {
2742
- name: "Some",
2743
- type: "budokan_interfaces::budokan::EntryFee"
2744
- },
3022
+ type: "struct",
3023
+ name: "core::array::Span::<core::felt252>",
3024
+ members: [
2745
3025
  {
2746
- name: "None",
2747
- type: "()"
3026
+ name: "snapshot",
3027
+ type: "@core::array::Array::<core::felt252>"
2748
3028
  }
2749
3029
  ]
2750
3030
  },
2751
3031
  {
2752
3032
  type: "struct",
2753
- name: "core::array::Span::<core::starknet::contract_address::ContractAddress>",
3033
+ name: "metagame_extensions_interfaces::extension::ExtensionConfig",
2754
3034
  members: [
2755
3035
  {
2756
- name: "snapshot",
2757
- type: "@core::array::Array::<core::starknet::contract_address::ContractAddress>"
3036
+ name: "address",
3037
+ type: "core::starknet::contract_address::ContractAddress"
3038
+ },
3039
+ {
3040
+ name: "config",
3041
+ type: "core::array::Span::<core::felt252>"
2758
3042
  }
2759
3043
  ]
2760
3044
  },
2761
3045
  {
2762
- type: "struct",
2763
- name: "core::array::Span::<core::felt252>",
2764
- members: [
3046
+ type: "enum",
3047
+ name: "budokan_interfaces::budokan::EntryFeeKind",
3048
+ variants: [
2765
3049
  {
2766
- name: "snapshot",
2767
- type: "@core::array::Array::<core::felt252>"
3050
+ name: "BuiltIn",
3051
+ type: "budokan_interfaces::budokan::EntryFee"
3052
+ },
3053
+ {
3054
+ name: "Extension",
3055
+ type: "metagame_extensions_interfaces::extension::ExtensionConfig"
2768
3056
  }
2769
3057
  ]
2770
3058
  },
2771
3059
  {
2772
- type: "struct",
2773
- name: "interfaces::extension::ExtensionConfig",
2774
- members: [
3060
+ type: "enum",
3061
+ name: "core::option::Option::<budokan_interfaces::budokan::EntryFeeKind>",
3062
+ variants: [
2775
3063
  {
2776
- name: "address",
2777
- type: "core::starknet::contract_address::ContractAddress"
3064
+ name: "Some",
3065
+ type: "budokan_interfaces::budokan::EntryFeeKind"
2778
3066
  },
2779
3067
  {
2780
- name: "config",
2781
- type: "core::array::Span::<core::felt252>"
3068
+ name: "None",
3069
+ type: "()"
2782
3070
  }
2783
3071
  ]
2784
3072
  },
@@ -2792,7 +3080,7 @@ var budokan_default = [
2792
3080
  },
2793
3081
  {
2794
3082
  name: "extension",
2795
- type: "interfaces::extension::ExtensionConfig"
3083
+ type: "metagame_extensions_interfaces::extension::ExtensionConfig"
2796
3084
  }
2797
3085
  ]
2798
3086
  },
@@ -2872,7 +3160,7 @@ var budokan_default = [
2872
3160
  },
2873
3161
  {
2874
3162
  name: "entry_fee",
2875
- type: "core::option::Option::<budokan_interfaces::budokan::EntryFee>"
3163
+ type: "core::option::Option::<budokan_interfaces::budokan::EntryFeeKind>"
2876
3164
  },
2877
3165
  {
2878
3166
  name: "entry_requirement",
@@ -2914,6 +3202,20 @@ var budokan_default = [
2914
3202
  }
2915
3203
  ]
2916
3204
  },
3205
+ {
3206
+ type: "enum",
3207
+ name: "core::option::Option::<core::felt252>",
3208
+ variants: [
3209
+ {
3210
+ name: "Some",
3211
+ type: "core::felt252"
3212
+ },
3213
+ {
3214
+ name: "None",
3215
+ type: "()"
3216
+ }
3217
+ ]
3218
+ },
2917
3219
  {
2918
3220
  type: "struct",
2919
3221
  name: "core::integer::u256",
@@ -2946,10 +3248,6 @@ var budokan_default = [
2946
3248
  name: "NFT",
2947
3249
  type: "game_components_interfaces::entry_requirement::NFTQualification"
2948
3250
  },
2949
- {
2950
- name: "Address",
2951
- type: "core::starknet::contract_address::ContractAddress"
2952
- },
2953
3251
  {
2954
3252
  name: "Extension",
2955
3253
  type: "core::array::Span::<core::felt252>"
@@ -2970,6 +3268,38 @@ var budokan_default = [
2970
3268
  }
2971
3269
  ]
2972
3270
  },
3271
+ {
3272
+ type: "enum",
3273
+ name: "core::option::Option::<core::array::Span::<core::felt252>>",
3274
+ variants: [
3275
+ {
3276
+ name: "Some",
3277
+ type: "core::array::Span::<core::felt252>"
3278
+ },
3279
+ {
3280
+ name: "None",
3281
+ type: "()"
3282
+ }
3283
+ ]
3284
+ },
3285
+ {
3286
+ type: "struct",
3287
+ name: "budokan_interfaces::budokan::TournamentRecipientParams",
3288
+ members: [
3289
+ {
3290
+ name: "player_address",
3291
+ type: "core::option::Option::<core::starknet::contract_address::ContractAddress>"
3292
+ },
3293
+ {
3294
+ name: "qualifier",
3295
+ type: "core::option::Option::<core::starknet::contract_address::ContractAddress>"
3296
+ },
3297
+ {
3298
+ name: "qualification",
3299
+ type: "core::option::Option::<game_components_interfaces::entry_requirement::QualificationProof>"
3300
+ }
3301
+ ]
3302
+ },
2973
3303
  {
2974
3304
  type: "enum",
2975
3305
  name: "game_components_interfaces::prize::PrizeType",
@@ -2984,6 +3314,38 @@ var budokan_default = [
2984
3314
  }
2985
3315
  ]
2986
3316
  },
3317
+ {
3318
+ type: "struct",
3319
+ name: "budokan_interfaces::budokan::ExtensionPrizeClaim",
3320
+ members: [
3321
+ {
3322
+ name: "prize_id",
3323
+ type: "core::integer::u64"
3324
+ },
3325
+ {
3326
+ name: "token_id",
3327
+ type: "core::option::Option::<core::felt252>"
3328
+ },
3329
+ {
3330
+ name: "payout_params",
3331
+ type: "core::array::Span::<core::felt252>"
3332
+ }
3333
+ ]
3334
+ },
3335
+ {
3336
+ type: "enum",
3337
+ name: "budokan_interfaces::budokan::PrizeClaim",
3338
+ variants: [
3339
+ {
3340
+ name: "Token",
3341
+ type: "game_components_interfaces::prize::PrizeType"
3342
+ },
3343
+ {
3344
+ name: "Extension",
3345
+ type: "budokan_interfaces::budokan::ExtensionPrizeClaim"
3346
+ }
3347
+ ]
3348
+ },
2987
3349
  {
2988
3350
  type: "enum",
2989
3351
  name: "budokan_interfaces::budokan::EntryFeeRewardType",
@@ -3006,17 +3368,45 @@ var budokan_default = [
3006
3368
  }
3007
3369
  ]
3008
3370
  },
3371
+ {
3372
+ type: "struct",
3373
+ name: "budokan_interfaces::budokan::ExtensionEntryFeeClaim",
3374
+ members: [
3375
+ {
3376
+ name: "token_id",
3377
+ type: "core::option::Option::<core::felt252>"
3378
+ },
3379
+ {
3380
+ name: "claim_params",
3381
+ type: "core::array::Span::<core::felt252>"
3382
+ }
3383
+ ]
3384
+ },
3385
+ {
3386
+ type: "enum",
3387
+ name: "budokan_interfaces::budokan::EntryFeeClaim",
3388
+ variants: [
3389
+ {
3390
+ name: "Token",
3391
+ type: "budokan_interfaces::budokan::EntryFeeRewardType"
3392
+ },
3393
+ {
3394
+ name: "Extension",
3395
+ type: "budokan_interfaces::budokan::ExtensionEntryFeeClaim"
3396
+ }
3397
+ ]
3398
+ },
3009
3399
  {
3010
3400
  type: "enum",
3011
3401
  name: "budokan_interfaces::budokan::RewardType",
3012
3402
  variants: [
3013
3403
  {
3014
3404
  name: "Prize",
3015
- type: "game_components_interfaces::prize::PrizeType"
3405
+ type: "budokan_interfaces::budokan::PrizeClaim"
3016
3406
  },
3017
3407
  {
3018
3408
  name: "EntryFee",
3019
- type: "budokan_interfaces::budokan::EntryFeeRewardType"
3409
+ type: "budokan_interfaces::budokan::EntryFeeClaim"
3020
3410
  }
3021
3411
  ]
3022
3412
  },
@@ -3078,16 +3468,8 @@ var budokan_default = [
3078
3468
  },
3079
3469
  {
3080
3470
  type: "struct",
3081
- name: "game_components_interfaces::prize::PrizeData",
3471
+ name: "game_components_interfaces::prize::TokenPrizePayload",
3082
3472
  members: [
3083
- {
3084
- name: "id",
3085
- type: "core::integer::u64"
3086
- },
3087
- {
3088
- name: "context_id",
3089
- type: "core::integer::u64"
3090
- },
3091
3473
  {
3092
3474
  name: "token_address",
3093
3475
  type: "core::starknet::contract_address::ContractAddress"
@@ -3095,10 +3477,34 @@ var budokan_default = [
3095
3477
  {
3096
3478
  name: "token_type",
3097
3479
  type: "game_components_interfaces::prize::TokenTypeData"
3098
- },
3480
+ }
3481
+ ]
3482
+ },
3483
+ {
3484
+ type: "struct",
3485
+ name: "game_components_interfaces::prize::ExtensionPrizePayload",
3486
+ members: [
3099
3487
  {
3100
- name: "sponsor_address",
3488
+ name: "address",
3101
3489
  type: "core::starknet::contract_address::ContractAddress"
3490
+ },
3491
+ {
3492
+ name: "config",
3493
+ type: "core::array::Span::<core::felt252>"
3494
+ }
3495
+ ]
3496
+ },
3497
+ {
3498
+ type: "enum",
3499
+ name: "game_components_interfaces::prize::Prize",
3500
+ variants: [
3501
+ {
3502
+ name: "Token",
3503
+ type: "game_components_interfaces::prize::TokenPrizePayload"
3504
+ },
3505
+ {
3506
+ name: "Extension",
3507
+ type: "game_components_interfaces::prize::ExtensionPrizePayload"
3102
3508
  }
3103
3509
  ]
3104
3510
  },
@@ -3133,38 +3539,6 @@ var budokan_default = [
3133
3539
  ],
3134
3540
  state_mutability: "view"
3135
3541
  },
3136
- {
3137
- type: "function",
3138
- name: "tournament_entries",
3139
- inputs: [
3140
- {
3141
- name: "tournament_id",
3142
- type: "core::integer::u64"
3143
- }
3144
- ],
3145
- outputs: [
3146
- {
3147
- type: "core::integer::u32"
3148
- }
3149
- ],
3150
- state_mutability: "view"
3151
- },
3152
- {
3153
- type: "function",
3154
- name: "get_leaderboard",
3155
- inputs: [
3156
- {
3157
- name: "tournament_id",
3158
- type: "core::integer::u64"
3159
- }
3160
- ],
3161
- outputs: [
3162
- {
3163
- type: "core::array::Array::<core::felt252>"
3164
- }
3165
- ],
3166
- state_mutability: "view"
3167
- },
3168
3542
  {
3169
3543
  type: "function",
3170
3544
  name: "current_phase",
@@ -3219,7 +3593,7 @@ var budokan_default = [
3219
3593
  },
3220
3594
  {
3221
3595
  name: "entry_fee",
3222
- type: "core::option::Option::<budokan_interfaces::budokan::EntryFee>"
3596
+ type: "core::option::Option::<budokan_interfaces::budokan::EntryFeeKind>"
3223
3597
  },
3224
3598
  {
3225
3599
  name: "entry_requirement",
@@ -3255,16 +3629,24 @@ var budokan_default = [
3255
3629
  },
3256
3630
  {
3257
3631
  name: "player_name",
3258
- type: "core::felt252"
3632
+ type: "core::option::Option::<core::felt252>"
3259
3633
  },
3260
3634
  {
3261
3635
  name: "player_address",
3262
- type: "core::starknet::contract_address::ContractAddress"
3636
+ type: "core::option::Option::<core::starknet::contract_address::ContractAddress>"
3263
3637
  },
3264
3638
  {
3265
- name: "qualification",
3639
+ name: "qualifier",
3640
+ type: "core::option::Option::<core::starknet::contract_address::ContractAddress>"
3641
+ },
3642
+ {
3643
+ name: "qualification",
3266
3644
  type: "core::option::Option::<game_components_interfaces::entry_requirement::QualificationProof>"
3267
3645
  },
3646
+ {
3647
+ name: "entry_fee_pay_params",
3648
+ type: "core::option::Option::<core::array::Span::<core::felt252>>"
3649
+ },
3268
3650
  {
3269
3651
  name: "salt",
3270
3652
  type: "core::integer::u16"
@@ -3281,6 +3663,38 @@ var budokan_default = [
3281
3663
  ],
3282
3664
  state_mutability: "external"
3283
3665
  },
3666
+ {
3667
+ type: "function",
3668
+ name: "enter_tournament_for_recipients",
3669
+ inputs: [
3670
+ {
3671
+ name: "tournament_id",
3672
+ type: "core::integer::u64"
3673
+ },
3674
+ {
3675
+ name: "recipients",
3676
+ type: "core::array::Array::<budokan_interfaces::budokan::TournamentRecipientParams>"
3677
+ },
3678
+ {
3679
+ name: "player_name",
3680
+ type: "core::option::Option::<core::felt252>"
3681
+ },
3682
+ {
3683
+ name: "salt",
3684
+ type: "core::integer::u16"
3685
+ },
3686
+ {
3687
+ name: "metadata_value",
3688
+ type: "core::integer::u16"
3689
+ }
3690
+ ],
3691
+ outputs: [
3692
+ {
3693
+ type: "core::array::Array::<core::felt252>"
3694
+ }
3695
+ ],
3696
+ state_mutability: "external"
3697
+ },
3284
3698
  {
3285
3699
  type: "function",
3286
3700
  name: "ban_entry",
@@ -3346,12 +3760,8 @@ var budokan_default = [
3346
3760
  type: "core::integer::u64"
3347
3761
  },
3348
3762
  {
3349
- name: "token_address",
3350
- type: "core::starknet::contract_address::ContractAddress"
3351
- },
3352
- {
3353
- name: "token_type",
3354
- type: "game_components_interfaces::prize::TokenTypeData"
3763
+ name: "prize",
3764
+ type: "game_components_interfaces::prize::Prize"
3355
3765
  },
3356
3766
  {
3357
3767
  name: "position",
@@ -3360,7 +3770,7 @@ var budokan_default = [
3360
3770
  ],
3361
3771
  outputs: [
3362
3772
  {
3363
- type: "game_components_interfaces::prize::PrizeData"
3773
+ type: "core::integer::u64"
3364
3774
  }
3365
3775
  ],
3366
3776
  state_mutability: "external"
@@ -3534,6 +3944,14 @@ var budokan_default = [
3534
3944
  {
3535
3945
  name: "additional_shares",
3536
3946
  type: "core::array::Span::<game_components_interfaces::entry_fee::AdditionalShare>"
3947
+ },
3948
+ {
3949
+ name: "distribution",
3950
+ type: "core::option::Option::<game_components_interfaces::distribution::Distribution>"
3951
+ },
3952
+ {
3953
+ name: "distribution_count",
3954
+ type: "core::integer::u32"
3537
3955
  }
3538
3956
  ]
3539
3957
  },
@@ -3545,19 +3963,273 @@ var budokan_default = [
3545
3963
  name: "Some",
3546
3964
  type: "game_components_interfaces::entry_fee::EntryFeeConfig"
3547
3965
  },
3548
- {
3549
- name: "None",
3550
- type: "()"
3551
- }
3552
- ]
3553
- },
3554
- {
3555
- type: "interface",
3556
- name: "game_components_interfaces::entry_fee::IEntryFee",
3557
- items: [
3966
+ {
3967
+ name: "None",
3968
+ type: "()"
3969
+ }
3970
+ ]
3971
+ },
3972
+ {
3973
+ type: "interface",
3974
+ name: "game_components_interfaces::entry_fee::IEntryFee",
3975
+ items: [
3976
+ {
3977
+ type: "function",
3978
+ name: "get_entry_fee",
3979
+ inputs: [
3980
+ {
3981
+ name: "context_id",
3982
+ type: "core::integer::u64"
3983
+ }
3984
+ ],
3985
+ outputs: [
3986
+ {
3987
+ type: "core::option::Option::<game_components_interfaces::entry_fee::EntryFeeConfig>"
3988
+ }
3989
+ ],
3990
+ state_mutability: "view"
3991
+ }
3992
+ ]
3993
+ },
3994
+ {
3995
+ type: "impl",
3996
+ name: "EntryRequirementImpl",
3997
+ interface_name: "game_components_interfaces::entry_requirement::IEntryRequirement"
3998
+ },
3999
+ {
4000
+ type: "struct",
4001
+ name: "game_components_interfaces::entry_requirement::QualificationEntries",
4002
+ members: [
4003
+ {
4004
+ name: "context_id",
4005
+ type: "core::integer::u64"
4006
+ },
4007
+ {
4008
+ name: "qualification_proof",
4009
+ type: "game_components_interfaces::entry_requirement::QualificationProof"
4010
+ },
4011
+ {
4012
+ name: "entry_count",
4013
+ type: "core::integer::u32"
4014
+ }
4015
+ ]
4016
+ },
4017
+ {
4018
+ type: "interface",
4019
+ name: "game_components_interfaces::entry_requirement::IEntryRequirement",
4020
+ items: [
4021
+ {
4022
+ type: "function",
4023
+ name: "get_entry_requirement",
4024
+ inputs: [
4025
+ {
4026
+ name: "context_id",
4027
+ type: "core::integer::u64"
4028
+ }
4029
+ ],
4030
+ outputs: [
4031
+ {
4032
+ type: "core::option::Option::<game_components_interfaces::entry_requirement::EntryRequirement>"
4033
+ }
4034
+ ],
4035
+ state_mutability: "view"
4036
+ },
4037
+ {
4038
+ type: "function",
4039
+ name: "get_qualification_entries",
4040
+ inputs: [
4041
+ {
4042
+ name: "context_id",
4043
+ type: "core::integer::u64"
4044
+ },
4045
+ {
4046
+ name: "proof",
4047
+ type: "game_components_interfaces::entry_requirement::QualificationProof"
4048
+ }
4049
+ ],
4050
+ outputs: [
4051
+ {
4052
+ type: "game_components_interfaces::entry_requirement::QualificationEntries"
4053
+ }
4054
+ ],
4055
+ state_mutability: "view"
4056
+ }
4057
+ ]
4058
+ },
4059
+ {
4060
+ type: "impl",
4061
+ name: "PrizeImpl",
4062
+ interface_name: "game_components_interfaces::prize::IPrize"
4063
+ },
4064
+ {
4065
+ type: "struct",
4066
+ name: "game_components_interfaces::prize::PrizeRecord",
4067
+ members: [
4068
+ {
4069
+ name: "id",
4070
+ type: "core::integer::u64"
4071
+ },
4072
+ {
4073
+ name: "context_id",
4074
+ type: "core::integer::u64"
4075
+ },
4076
+ {
4077
+ name: "sponsor_address",
4078
+ type: "core::starknet::contract_address::ContractAddress"
4079
+ },
4080
+ {
4081
+ name: "prize",
4082
+ type: "game_components_interfaces::prize::Prize"
4083
+ }
4084
+ ]
4085
+ },
4086
+ {
4087
+ type: "interface",
4088
+ name: "game_components_interfaces::prize::IPrize",
4089
+ items: [
4090
+ {
4091
+ type: "function",
4092
+ name: "get_prize",
4093
+ inputs: [
4094
+ {
4095
+ name: "prize_id",
4096
+ type: "core::integer::u64"
4097
+ }
4098
+ ],
4099
+ outputs: [
4100
+ {
4101
+ type: "game_components_interfaces::prize::PrizeRecord"
4102
+ }
4103
+ ],
4104
+ state_mutability: "view"
4105
+ },
4106
+ {
4107
+ type: "function",
4108
+ name: "get_total_prizes",
4109
+ inputs: [],
4110
+ outputs: [
4111
+ {
4112
+ type: "core::integer::u64"
4113
+ }
4114
+ ],
4115
+ state_mutability: "view"
4116
+ },
4117
+ {
4118
+ type: "function",
4119
+ name: "is_prize_claimed",
4120
+ inputs: [
4121
+ {
4122
+ name: "context_id",
4123
+ type: "core::integer::u64"
4124
+ },
4125
+ {
4126
+ name: "prize_type",
4127
+ type: "game_components_interfaces::prize::PrizeType"
4128
+ }
4129
+ ],
4130
+ outputs: [
4131
+ {
4132
+ type: "core::bool"
4133
+ }
4134
+ ],
4135
+ state_mutability: "view"
4136
+ }
4137
+ ]
4138
+ },
4139
+ {
4140
+ type: "impl",
4141
+ name: "RegistrationImpl",
4142
+ interface_name: "game_components_interfaces::registration::IRegistration"
4143
+ },
4144
+ {
4145
+ type: "struct",
4146
+ name: "game_components_interfaces::registration::Registration",
4147
+ members: [
4148
+ {
4149
+ name: "context_id",
4150
+ type: "core::integer::u64"
4151
+ },
4152
+ {
4153
+ name: "entry_id",
4154
+ type: "core::integer::u32"
4155
+ },
4156
+ {
4157
+ name: "game_token_id",
4158
+ type: "core::felt252"
4159
+ },
4160
+ {
4161
+ name: "has_submitted",
4162
+ type: "core::bool"
4163
+ },
4164
+ {
4165
+ name: "is_banned",
4166
+ type: "core::bool"
4167
+ }
4168
+ ]
4169
+ },
4170
+ {
4171
+ type: "interface",
4172
+ name: "game_components_interfaces::registration::IRegistration",
4173
+ items: [
4174
+ {
4175
+ type: "function",
4176
+ name: "get_entry",
4177
+ inputs: [
4178
+ {
4179
+ name: "context_id",
4180
+ type: "core::integer::u64"
4181
+ },
4182
+ {
4183
+ name: "entry_id",
4184
+ type: "core::integer::u32"
4185
+ }
4186
+ ],
4187
+ outputs: [
4188
+ {
4189
+ type: "game_components_interfaces::registration::Registration"
4190
+ }
4191
+ ],
4192
+ state_mutability: "view"
4193
+ },
4194
+ {
4195
+ type: "function",
4196
+ name: "entry_exists",
4197
+ inputs: [
4198
+ {
4199
+ name: "context_id",
4200
+ type: "core::integer::u64"
4201
+ },
4202
+ {
4203
+ name: "entry_id",
4204
+ type: "core::integer::u32"
4205
+ }
4206
+ ],
4207
+ outputs: [
4208
+ {
4209
+ type: "core::bool"
4210
+ }
4211
+ ],
4212
+ state_mutability: "view"
4213
+ },
4214
+ {
4215
+ type: "function",
4216
+ name: "is_token_banned",
4217
+ inputs: [
4218
+ {
4219
+ name: "token_id",
4220
+ type: "core::felt252"
4221
+ }
4222
+ ],
4223
+ outputs: [
4224
+ {
4225
+ type: "core::bool"
4226
+ }
4227
+ ],
4228
+ state_mutability: "view"
4229
+ },
3558
4230
  {
3559
4231
  type: "function",
3560
- name: "get_entry_fee",
4232
+ name: "get_entry_count",
3561
4233
  inputs: [
3562
4234
  {
3563
4235
  name: "context_id",
@@ -3566,7 +4238,7 @@ var budokan_default = [
3566
4238
  ],
3567
4239
  outputs: [
3568
4240
  {
3569
- type: "core::option::Option::<game_components_interfaces::entry_fee::EntryFeeConfig>"
4241
+ type: "core::integer::u32"
3570
4242
  }
3571
4243
  ],
3572
4244
  state_mutability: "view"
@@ -3575,34 +4247,48 @@ var budokan_default = [
3575
4247
  },
3576
4248
  {
3577
4249
  type: "impl",
3578
- name: "EntryRequirementImpl",
3579
- interface_name: "game_components_interfaces::entry_requirement::IEntryRequirement"
4250
+ name: "LeaderboardImpl",
4251
+ interface_name: "game_components_interfaces::leaderboard::ILeaderboard"
3580
4252
  },
3581
4253
  {
3582
4254
  type: "struct",
3583
- name: "game_components_interfaces::entry_requirement::QualificationEntries",
4255
+ name: "game_components_interfaces::structs::leaderboard::LeaderboardEntry",
3584
4256
  members: [
3585
4257
  {
3586
- name: "context_id",
4258
+ name: "id",
4259
+ type: "core::felt252"
4260
+ },
4261
+ {
4262
+ name: "score",
3587
4263
  type: "core::integer::u64"
4264
+ }
4265
+ ]
4266
+ },
4267
+ {
4268
+ type: "struct",
4269
+ name: "game_components_interfaces::structs::leaderboard::LeaderboardStoreConfig",
4270
+ members: [
4271
+ {
4272
+ name: "max_entries",
4273
+ type: "core::integer::u32"
3588
4274
  },
3589
4275
  {
3590
- name: "qualification_proof",
3591
- type: "game_components_interfaces::entry_requirement::QualificationProof"
4276
+ name: "ascending",
4277
+ type: "core::bool"
3592
4278
  },
3593
4279
  {
3594
- name: "entry_count",
3595
- type: "core::integer::u32"
4280
+ name: "game_address",
4281
+ type: "core::starknet::contract_address::ContractAddress"
3596
4282
  }
3597
4283
  ]
3598
4284
  },
3599
4285
  {
3600
4286
  type: "interface",
3601
- name: "game_components_interfaces::entry_requirement::IEntryRequirement",
4287
+ name: "game_components_interfaces::leaderboard::ILeaderboard",
3602
4288
  items: [
3603
4289
  {
3604
4290
  type: "function",
3605
- name: "get_entry_requirement",
4291
+ name: "get_leaderboard_entries",
3606
4292
  inputs: [
3607
4293
  {
3608
4294
  name: "context_id",
@@ -3611,80 +4297,82 @@ var budokan_default = [
3611
4297
  ],
3612
4298
  outputs: [
3613
4299
  {
3614
- type: "core::option::Option::<game_components_interfaces::entry_requirement::EntryRequirement>"
4300
+ type: "core::array::Array::<game_components_interfaces::structs::leaderboard::LeaderboardEntry>"
3615
4301
  }
3616
4302
  ],
3617
4303
  state_mutability: "view"
3618
4304
  },
3619
4305
  {
3620
4306
  type: "function",
3621
- name: "get_qualification_entries",
4307
+ name: "get_leaderboard_entry",
3622
4308
  inputs: [
3623
4309
  {
3624
4310
  name: "context_id",
3625
4311
  type: "core::integer::u64"
3626
4312
  },
3627
4313
  {
3628
- name: "proof",
3629
- type: "game_components_interfaces::entry_requirement::QualificationProof"
4314
+ name: "position",
4315
+ type: "core::integer::u32"
3630
4316
  }
3631
4317
  ],
3632
4318
  outputs: [
3633
4319
  {
3634
- type: "game_components_interfaces::entry_requirement::QualificationEntries"
4320
+ type: "game_components_interfaces::structs::leaderboard::LeaderboardEntry"
3635
4321
  }
3636
4322
  ],
3637
4323
  state_mutability: "view"
3638
- }
3639
- ]
3640
- },
3641
- {
3642
- type: "impl",
3643
- name: "PrizeImpl",
3644
- interface_name: "game_components_interfaces::prize::IPrize"
3645
- },
3646
- {
3647
- type: "interface",
3648
- name: "game_components_interfaces::prize::IPrize",
3649
- items: [
4324
+ },
3650
4325
  {
3651
4326
  type: "function",
3652
- name: "get_prize",
4327
+ name: "get_top_leaderboard_entries",
3653
4328
  inputs: [
3654
4329
  {
3655
- name: "prize_id",
4330
+ name: "context_id",
3656
4331
  type: "core::integer::u64"
4332
+ },
4333
+ {
4334
+ name: "count",
4335
+ type: "core::integer::u32"
3657
4336
  }
3658
4337
  ],
3659
4338
  outputs: [
3660
4339
  {
3661
- type: "game_components_interfaces::prize::PrizeData"
4340
+ type: "core::array::Array::<game_components_interfaces::structs::leaderboard::LeaderboardEntry>"
3662
4341
  }
3663
4342
  ],
3664
4343
  state_mutability: "view"
3665
4344
  },
3666
4345
  {
3667
4346
  type: "function",
3668
- name: "get_total_prizes",
3669
- inputs: [],
3670
- outputs: [
4347
+ name: "get_position",
4348
+ inputs: [
3671
4349
  {
4350
+ name: "context_id",
3672
4351
  type: "core::integer::u64"
4352
+ },
4353
+ {
4354
+ name: "token_id",
4355
+ type: "core::felt252"
4356
+ }
4357
+ ],
4358
+ outputs: [
4359
+ {
4360
+ type: "core::option::Option::<core::integer::u32>"
3673
4361
  }
3674
4362
  ],
3675
4363
  state_mutability: "view"
3676
4364
  },
3677
4365
  {
3678
4366
  type: "function",
3679
- name: "is_prize_claimed",
4367
+ name: "qualifies",
3680
4368
  inputs: [
3681
4369
  {
3682
4370
  name: "context_id",
3683
4371
  type: "core::integer::u64"
3684
4372
  },
3685
4373
  {
3686
- name: "prize_type",
3687
- type: "game_components_interfaces::prize::PrizeType"
4374
+ name: "score",
4375
+ type: "core::integer::u64"
3688
4376
  }
3689
4377
  ],
3690
4378
  outputs: [
@@ -3693,116 +4381,75 @@ var budokan_default = [
3693
4381
  }
3694
4382
  ],
3695
4383
  state_mutability: "view"
3696
- }
3697
- ]
3698
- },
3699
- {
3700
- type: "impl",
3701
- name: "RegistrationImpl",
3702
- interface_name: "game_components_interfaces::registration::IRegistration"
3703
- },
3704
- {
3705
- type: "struct",
3706
- name: "game_components_interfaces::registration::Registration",
3707
- members: [
3708
- {
3709
- name: "context_id",
3710
- type: "core::integer::u64"
3711
- },
3712
- {
3713
- name: "entry_id",
3714
- type: "core::integer::u32"
3715
- },
3716
- {
3717
- name: "game_token_id",
3718
- type: "core::felt252"
3719
- },
3720
- {
3721
- name: "has_submitted",
3722
- type: "core::bool"
3723
4384
  },
3724
- {
3725
- name: "is_banned",
3726
- type: "core::bool"
3727
- }
3728
- ]
3729
- },
3730
- {
3731
- type: "interface",
3732
- name: "game_components_interfaces::registration::IRegistration",
3733
- items: [
3734
4385
  {
3735
4386
  type: "function",
3736
- name: "get_entry",
4387
+ name: "is_full",
3737
4388
  inputs: [
3738
4389
  {
3739
4390
  name: "context_id",
3740
4391
  type: "core::integer::u64"
3741
- },
3742
- {
3743
- name: "entry_id",
3744
- type: "core::integer::u32"
3745
4392
  }
3746
4393
  ],
3747
4394
  outputs: [
3748
4395
  {
3749
- type: "game_components_interfaces::registration::Registration"
4396
+ type: "core::bool"
3750
4397
  }
3751
4398
  ],
3752
4399
  state_mutability: "view"
3753
4400
  },
3754
4401
  {
3755
4402
  type: "function",
3756
- name: "entry_exists",
4403
+ name: "get_leaderboard_length",
3757
4404
  inputs: [
3758
4405
  {
3759
4406
  name: "context_id",
3760
4407
  type: "core::integer::u64"
3761
- },
3762
- {
3763
- name: "entry_id",
3764
- type: "core::integer::u32"
3765
4408
  }
3766
4409
  ],
3767
4410
  outputs: [
3768
4411
  {
3769
- type: "core::bool"
4412
+ type: "core::integer::u32"
3770
4413
  }
3771
4414
  ],
3772
4415
  state_mutability: "view"
3773
4416
  },
3774
4417
  {
3775
4418
  type: "function",
3776
- name: "is_entry_banned",
4419
+ name: "get_config",
3777
4420
  inputs: [
3778
4421
  {
3779
4422
  name: "context_id",
3780
4423
  type: "core::integer::u64"
3781
- },
3782
- {
3783
- name: "entry_id",
3784
- type: "core::integer::u32"
3785
4424
  }
3786
4425
  ],
3787
4426
  outputs: [
3788
4427
  {
3789
- type: "core::bool"
4428
+ type: "game_components_interfaces::structs::leaderboard::LeaderboardStoreConfig"
3790
4429
  }
3791
4430
  ],
3792
4431
  state_mutability: "view"
3793
4432
  },
3794
4433
  {
3795
4434
  type: "function",
3796
- name: "get_entry_count",
4435
+ name: "find_position",
3797
4436
  inputs: [
3798
4437
  {
3799
4438
  name: "context_id",
3800
4439
  type: "core::integer::u64"
4440
+ },
4441
+ {
4442
+ name: "score",
4443
+ type: "core::integer::u64"
4444
+ },
4445
+ {
4446
+ name: "token_id",
4447
+ type: "core::felt252"
3801
4448
  }
3802
4449
  ],
3803
4450
  outputs: [
3804
4451
  {
3805
- type: "core::integer::u32"
4452
+ type: "core::option::Option::<core::integer::u32>"
3806
4453
  }
3807
4454
  ],
3808
4455
  state_mutability: "view"
@@ -3946,6 +4593,12 @@ var budokan_default = [
3946
4593
  kind: "enum",
3947
4594
  variants: []
3948
4595
  },
4596
+ {
4597
+ type: "event",
4598
+ name: "openzeppelin_security::reentrancyguard::ReentrancyGuardComponent::Event",
4599
+ kind: "enum",
4600
+ variants: []
4601
+ },
3949
4602
  {
3950
4603
  type: "event",
3951
4604
  name: "budokan::events::TournamentCreated",
@@ -3961,11 +4614,6 @@ var budokan_default = [
3961
4614
  type: "core::starknet::contract_address::ContractAddress",
3962
4615
  kind: "key"
3963
4616
  },
3964
- {
3965
- name: "created_at",
3966
- type: "core::integer::u64",
3967
- kind: "data"
3968
- },
3969
4617
  {
3970
4618
  name: "created_by",
3971
4619
  type: "core::starknet::contract_address::ContractAddress",
@@ -3982,28 +4630,28 @@ var budokan_default = [
3982
4630
  kind: "data"
3983
4631
  },
3984
4632
  {
3985
- name: "schedule",
3986
- type: "budokan_interfaces::budokan::Schedule",
4633
+ name: "config",
4634
+ type: "core::felt252",
3987
4635
  kind: "data"
3988
4636
  },
3989
4637
  {
3990
- name: "game_config",
3991
- type: "budokan_interfaces::budokan::GameConfig",
4638
+ name: "client_url",
4639
+ type: "core::option::Option::<core::byte_array::ByteArray>",
3992
4640
  kind: "data"
3993
4641
  },
3994
4642
  {
3995
- name: "entry_fee",
3996
- type: "core::option::Option::<budokan_interfaces::budokan::EntryFee>",
4643
+ name: "renderer",
4644
+ type: "core::option::Option::<core::starknet::contract_address::ContractAddress>",
3997
4645
  kind: "data"
3998
4646
  },
3999
4647
  {
4000
- name: "entry_requirement",
4001
- type: "core::option::Option::<game_components_interfaces::entry_requirement::EntryRequirement>",
4648
+ name: "entry_fee",
4649
+ type: "core::option::Option::<budokan_interfaces::budokan::EntryFeeKind>",
4002
4650
  kind: "data"
4003
4651
  },
4004
4652
  {
4005
- name: "leaderboard_config",
4006
- type: "budokan_interfaces::budokan::LeaderboardConfig",
4653
+ name: "entry_requirement",
4654
+ type: "core::option::Option::<game_components_interfaces::entry_requirement::EntryRequirement>",
4007
4655
  kind: "data"
4008
4656
  }
4009
4657
  ]
@@ -4023,11 +4671,6 @@ var budokan_default = [
4023
4671
  type: "core::felt252",
4024
4672
  kind: "key"
4025
4673
  },
4026
- {
4027
- name: "game_address",
4028
- type: "core::starknet::contract_address::ContractAddress",
4029
- kind: "data"
4030
- },
4031
4674
  {
4032
4675
  name: "player_address",
4033
4676
  type: "core::starknet::contract_address::ContractAddress",
@@ -4037,22 +4680,12 @@ var budokan_default = [
4037
4680
  name: "entry_number",
4038
4681
  type: "core::integer::u32",
4039
4682
  kind: "data"
4040
- },
4041
- {
4042
- name: "has_submitted",
4043
- type: "core::bool",
4044
- kind: "data"
4045
- },
4046
- {
4047
- name: "is_banned",
4048
- type: "core::bool",
4049
- kind: "data"
4050
4683
  }
4051
4684
  ]
4052
4685
  },
4053
4686
  {
4054
4687
  type: "event",
4055
- name: "budokan::events::LeaderboardUpdated",
4688
+ name: "budokan::events::TournamentEntryStateChanged",
4056
4689
  kind: "struct",
4057
4690
  members: [
4058
4691
  {
@@ -4061,8 +4694,18 @@ var budokan_default = [
4061
4694
  kind: "key"
4062
4695
  },
4063
4696
  {
4064
- name: "token_ids",
4065
- type: "core::array::Span::<core::felt252>",
4697
+ name: "game_token_id",
4698
+ type: "core::felt252",
4699
+ kind: "key"
4700
+ },
4701
+ {
4702
+ name: "has_submitted",
4703
+ type: "core::bool",
4704
+ kind: "data"
4705
+ },
4706
+ {
4707
+ name: "is_banned",
4708
+ type: "core::bool",
4066
4709
  kind: "data"
4067
4710
  }
4068
4711
  ]
@@ -4088,13 +4731,8 @@ var budokan_default = [
4088
4731
  kind: "data"
4089
4732
  },
4090
4733
  {
4091
- name: "token_address",
4092
- type: "core::starknet::contract_address::ContractAddress",
4093
- kind: "data"
4094
- },
4095
- {
4096
- name: "token_type",
4097
- type: "game_components_interfaces::prize::TokenTypeData",
4734
+ name: "prize",
4735
+ type: "game_components_interfaces::prize::Prize",
4098
4736
  kind: "data"
4099
4737
  },
4100
4738
  {
@@ -4203,6 +4841,11 @@ var budokan_default = [
4203
4841
  type: "game_components_metagame::prize::prize_component::PrizeComponent::Event",
4204
4842
  kind: "flat"
4205
4843
  },
4844
+ {
4845
+ name: "ReentrancyGuardEvent",
4846
+ type: "openzeppelin_security::reentrancyguard::ReentrancyGuardComponent::Event",
4847
+ kind: "flat"
4848
+ },
4206
4849
  {
4207
4850
  name: "TournamentCreated",
4208
4851
  type: "budokan::events::TournamentCreated",
@@ -4214,8 +4857,8 @@ var budokan_default = [
4214
4857
  kind: "nested"
4215
4858
  },
4216
4859
  {
4217
- name: "LeaderboardUpdated",
4218
- type: "budokan::events::LeaderboardUpdated",
4860
+ name: "TournamentEntryStateChanged",
4861
+ type: "budokan::events::TournamentEntryStateChanged",
4219
4862
  kind: "nested"
4220
4863
  },
4221
4864
  {
@@ -4383,6 +5026,7 @@ var BudokanClient = class {
4383
5026
  if (prizes.length === 0) return t;
4384
5027
  const tokenMap = /* @__PURE__ */ new Map();
4385
5028
  for (const p of prizes) {
5029
+ if (p.tokenType === "extension" || p.tokenAddress == null) continue;
4386
5030
  const key = p.tokenAddress;
4387
5031
  const existing = tokenMap.get(key);
4388
5032
  if (existing) {
@@ -4869,7 +5513,6 @@ function useOwnedTournamentIds(owner, contextId) {
4869
5513
  enabled ? {
4870
5514
  owner,
4871
5515
  minterAddress: budokanAddress,
4872
- hasContext: true,
4873
5516
  ...{},
4874
5517
  limit: MAX_OWNED_TOKENS
4875
5518
  } : void 0
@@ -4985,7 +5628,11 @@ function useRegistrationsByOwner(tournamentId, owner, params) {
4985
5628
  }, [enabled, tokensResult]);
4986
5629
  const inner = useRegistrations(
4987
5630
  ownedGameTokenIds && ownedGameTokenIds.length > 0 ? tournamentId : void 0,
4988
- ownedGameTokenIds && ownedGameTokenIds.length > 0 ? { ...params, gameTokenIds: ownedGameTokenIds } : void 0
5631
+ ownedGameTokenIds && ownedGameTokenIds.length > 0 ? {
5632
+ limit: Math.min(ownedGameTokenIds.length, MAX_OWNED_TOKENS),
5633
+ ...params,
5634
+ gameTokenIds: ownedGameTokenIds
5635
+ } : void 0
4989
5636
  );
4990
5637
  if (ownedGameTokenIds !== null && ownedGameTokenIds.length === 0) {
4991
5638
  return {
@@ -5174,6 +5821,200 @@ function useActivityStats() {
5174
5821
  }, [fetch2]);
5175
5822
  return { stats, loading, error, refetch: fetch2 };
5176
5823
  }
5824
+ function usePlayerRewards(address) {
5825
+ const budokan = useBudokanClient();
5826
+ const denshokan = useDenshokanClient();
5827
+ const budokanAddress = budokan.clientConfig.budokanAddress;
5828
+ const [rewards, setRewards] = useState(null);
5829
+ const [aggregating, setAggregating] = useState(false);
5830
+ const [error, setError] = useState(null);
5831
+ useResetOnClient(budokan, setRewards, setError);
5832
+ const tokensEnabled = !!address && !!budokanAddress;
5833
+ const { data: tokensResult, isLoading: tokensLoading } = useTokens(
5834
+ tokensEnabled ? {
5835
+ owner: address,
5836
+ minterAddress: budokanAddress,
5837
+ limit: 1e3
5838
+ } : void 0
5839
+ );
5840
+ const tokensByTournament = useMemo(() => {
5841
+ if (!tokensResult?.data) return null;
5842
+ const map = /* @__PURE__ */ new Map();
5843
+ for (const t of tokensResult.data) {
5844
+ if (t.contextId == null || !t.tokenId) continue;
5845
+ const tid = String(t.contextId);
5846
+ let list = map.get(tid);
5847
+ if (!list) {
5848
+ list = [];
5849
+ map.set(tid, list);
5850
+ }
5851
+ list.push(t.tokenId);
5852
+ }
5853
+ return map;
5854
+ }, [tokensResult]);
5855
+ const tournamentIds = useMemo(
5856
+ () => tokensByTournament ? Array.from(tokensByTournament.keys()) : [],
5857
+ [tokensByTournament]
5858
+ );
5859
+ const { tournaments: tournamentsPage, loading: tournamentsLoading } = useTournaments(
5860
+ tournamentIds.length > 0 ? { tournamentIds, limit: 1e3 } : void 0
5861
+ );
5862
+ const tournamentIdsKey = tournamentIds.join(",");
5863
+ const fetch2 = useCallback(async () => {
5864
+ if (!tokensEnabled) {
5865
+ setRewards(null);
5866
+ return;
5867
+ }
5868
+ if (!tokensByTournament) return;
5869
+ if (tokensByTournament.size === 0) {
5870
+ setRewards(emptyRewards());
5871
+ return;
5872
+ }
5873
+ if (!tournamentsPage?.data) return;
5874
+ const now = Math.floor(Date.now() / 1e3);
5875
+ const finalized = tournamentsPage.data.filter((t) => {
5876
+ const sub = Number(t.submissionEndTime ?? 0);
5877
+ return sub > 0 && sub <= now;
5878
+ });
5879
+ if (finalized.length === 0) {
5880
+ setRewards(emptyRewards());
5881
+ return;
5882
+ }
5883
+ setAggregating(true);
5884
+ setError(null);
5885
+ try {
5886
+ const settled = await Promise.allSettled(
5887
+ finalized.map(async (t) => {
5888
+ const tid = t.id;
5889
+ const tokenIds = tokensByTournament.get(tid) ?? [];
5890
+ if (tokenIds.length === 0) return null;
5891
+ const [prizes, allClaims, ranksResult] = await Promise.all([
5892
+ budokan.getTournamentPrizes(tid),
5893
+ fetchAllRewardClaims(budokan, tid),
5894
+ denshokan.getTokenRanks(tokenIds, {
5895
+ contextId: Number(tid),
5896
+ minterAddress: budokanAddress
5897
+ })
5898
+ ]);
5899
+ let maxPaid = 0;
5900
+ for (const p of prizes) {
5901
+ if ((p.payoutPosition ?? 0) > 0) {
5902
+ maxPaid = Math.max(maxPaid, p.payoutPosition);
5903
+ }
5904
+ if ((p.distributionCount ?? 0) > 0) {
5905
+ maxPaid = Math.max(maxPaid, p.distributionCount);
5906
+ }
5907
+ }
5908
+ const efDistCount = Number(t.entryFee?.distributionCount ?? 0);
5909
+ if (efDistCount > 0) maxPaid = Math.max(maxPaid, efDistCount);
5910
+ if (maxPaid === 0) return null;
5911
+ const placements = ranksResult.data.filter((r) => r.rank > 0 && r.rank <= maxPaid).map((r) => ({
5912
+ tournamentId: tid,
5913
+ tokenId: r.tokenId,
5914
+ position: r.rank,
5915
+ score: String(r.score ?? "0")
5916
+ }));
5917
+ if (placements.length === 0) return null;
5918
+ return {
5919
+ tournament: t,
5920
+ prizes,
5921
+ rewardClaims: allClaims,
5922
+ placements
5923
+ };
5924
+ })
5925
+ );
5926
+ const valid = settled.map((s, i) => {
5927
+ if (s.status === "fulfilled") return s.value;
5928
+ console.warn(
5929
+ `usePlayerRewards: tournament ${finalized[i].id} fetch failed; skipping`,
5930
+ s.reason
5931
+ );
5932
+ return null;
5933
+ }).filter((r) => r !== null);
5934
+ const allPlacements = valid.flatMap(
5935
+ (r) => r.placements
5936
+ );
5937
+ const wins = allPlacements.length;
5938
+ const bestPlacement = wins > 0 ? Math.min(...allPlacements.map((p) => p.position)) : null;
5939
+ const tournamentsList = valid.map((r) => r.tournament);
5940
+ const prizesList = valid.flatMap((r) => r.prizes);
5941
+ const rewardClaimsList = valid.flatMap(
5942
+ (r) => r.rewardClaims
5943
+ );
5944
+ setRewards({
5945
+ wins,
5946
+ bestPlacement,
5947
+ placements: allPlacements,
5948
+ tournaments: tournamentsList,
5949
+ prizes: prizesList,
5950
+ rewardClaims: rewardClaimsList
5951
+ });
5952
+ } catch (e) {
5953
+ setError(e);
5954
+ } finally {
5955
+ setAggregating(false);
5956
+ }
5957
+ }, [
5958
+ tokensEnabled,
5959
+ tokensByTournament,
5960
+ tournamentsPage,
5961
+ tournamentIdsKey,
5962
+ budokan,
5963
+ denshokan,
5964
+ budokanAddress
5965
+ ]);
5966
+ const lastRunRef = useRef("");
5967
+ useEffect(() => {
5968
+ if (!tokensEnabled) {
5969
+ setRewards(null);
5970
+ return;
5971
+ }
5972
+ if (!tokensByTournament || !tournamentsPage?.data) return;
5973
+ const fingerprint = `${address}|${tournamentIdsKey}|${tournamentsPage.data.length}`;
5974
+ if (fingerprint === lastRunRef.current) return;
5975
+ lastRunRef.current = fingerprint;
5976
+ fetch2();
5977
+ }, [
5978
+ address,
5979
+ tokensEnabled,
5980
+ tokensByTournament,
5981
+ tournamentsPage,
5982
+ tournamentIdsKey,
5983
+ fetch2
5984
+ ]);
5985
+ const loading = tokensEnabled && (tokensLoading || tournamentsLoading) || aggregating;
5986
+ return { rewards, loading, error, refetch: fetch2 };
5987
+ }
5988
+ function emptyRewards() {
5989
+ return {
5990
+ wins: 0,
5991
+ bestPlacement: null,
5992
+ placements: [],
5993
+ tournaments: [],
5994
+ prizes: [],
5995
+ rewardClaims: []
5996
+ };
5997
+ }
5998
+ async function fetchAllRewardClaims(client, tournamentId) {
5999
+ const first = await client.getTournamentRewardClaims(tournamentId, {
6000
+ limit: 100
6001
+ });
6002
+ const accumulated = [...first.data];
6003
+ const total = first.total ?? accumulated.length;
6004
+ if (accumulated.length >= total) return accumulated;
6005
+ const pageSize = Math.max(first.data.length, 1);
6006
+ let offset = accumulated.length;
6007
+ while (offset < total) {
6008
+ const next = await client.getTournamentRewardClaims(tournamentId, {
6009
+ limit: pageSize,
6010
+ offset
6011
+ });
6012
+ if (next.data.length === 0) break;
6013
+ accumulated.push(...next.data);
6014
+ offset += next.data.length;
6015
+ }
6016
+ return accumulated;
6017
+ }
5177
6018
  function useSubscription(channels, tournamentIds) {
5178
6019
  const client = useBudokanClient();
5179
6020
  const [lastMessage, setLastMessage] = useState(null);
@@ -5219,6 +6060,6 @@ function useConnectionStatus() {
5219
6060
  return { isConnected, datasourceMode };
5220
6061
  }
5221
6062
 
5222
- export { BudokanProvider, useActivityStats, useBudokanClient, useConnectionStatus, useLeaderboard, usePrizeAggregation, usePrizeStats, usePrizes, useQualifications, useRegistrations, useRegistrationsByOwner, useRewardClaims, useRewardClaimsSummary, useSubscription, useTournament, useTournamentCount, useTournaments, useTournamentsByOwner, useTournamentsByOwnerCount };
6063
+ export { BudokanProvider, useActivityStats, useBudokanClient, useConnectionStatus, useLeaderboard, usePlayerRewards, usePrizeAggregation, usePrizeStats, usePrizes, useQualifications, useRegistrations, useRegistrationsByOwner, useRewardClaims, useRewardClaimsSummary, useSubscription, useTournament, useTournamentCount, useTournaments, useTournamentsByOwner, useTournamentsByOwnerCount };
5223
6064
  //# sourceMappingURL=react.js.map
5224
6065
  //# sourceMappingURL=react.js.map