@provable-games/budokan-sdk 0.1.24 → 0.1.26

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.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 PlayerRewards, q as WSEventMessage, p as WSChannel, C as ConnectionMode } from './player-C2GE9Lop.cjs';
3
+ import { l as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, k as Phase, q 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, r as PlayerRewards, t as WSEventMessage, s as WSChannel, C as ConnectionMode } from './player-CbAYHoW8.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 PlayerRewards, q as WSEventMessage, p as WSChannel, C as ConnectionMode } from './player-C2GE9Lop.js';
3
+ import { l as BudokanClientConfig, B as BudokanClient, T as Tournament, b as PaginatedResult, e as TournamentListParams, k as Phase, q 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, r as PlayerRewards, t as WSEventMessage, s as WSChannel, C as ConnectionMode } from './player-CbAYHoW8.js';
4
4
  import 'starknet';
5
5
  import '@provable-games/metagame-sdk';
6
6
 
package/dist/react.js CHANGED
@@ -197,11 +197,37 @@ function snakeToCamel(obj) {
197
197
  return obj;
198
198
  }
199
199
 
200
+ // src/phase/index.ts
201
+ function tournamentPhase(t, nowSeconds) {
202
+ const createdAt = Number(t.createdAtOnchain ?? NaN);
203
+ if (!Number.isFinite(createdAt)) return null;
204
+ const regStartDelay = Number(t.registrationStartDelay ?? t.schedule?.registrationStartDelay ?? 0);
205
+ const regEndDelay = Number(t.registrationEndDelay ?? t.schedule?.registrationEndDelay ?? 0);
206
+ const gameStartDelay = Number(t.gameStartDelay ?? t.schedule?.gameStartDelay ?? 0);
207
+ const gameEndDelay = Number(t.gameEndDelay ?? t.schedule?.gameEndDelay ?? 0);
208
+ const submissionDuration = Number(t.submissionDuration ?? t.schedule?.submissionDuration ?? 0);
209
+ const now = Math.floor(Date.now() / 1e3);
210
+ const hasReg = regStartDelay > 0 || regEndDelay > 0;
211
+ const regStart = createdAt + regStartDelay;
212
+ const regEnd = regStart + regEndDelay;
213
+ const gameStart = createdAt + gameStartDelay;
214
+ const gameEnd = gameStart + gameEndDelay;
215
+ const subEnd = gameEnd + submissionDuration;
216
+ if (hasReg && now < regStart) return "scheduled";
217
+ if (hasReg && now < regEnd) return "registration";
218
+ if (now < gameStart) return "staging";
219
+ if (now < gameEnd) return "live";
220
+ if (now < subEnd) return "submission";
221
+ return "finalized";
222
+ }
223
+
200
224
  // src/api/tournaments.ts
201
225
  function normalizeTournament(raw) {
202
226
  const t = snakeToCamel(raw);
203
227
  const id = t.id ?? t.tournamentId;
204
- return { ...t, id, tournamentId: id };
228
+ const protocolFeeShare = t.protocolFeeShare ?? t.entryFee?.protocolFeeShare ?? null;
229
+ const phase = t.phase ?? tournamentPhase(t);
230
+ return { ...t, id, tournamentId: id, protocolFeeShare, phase };
205
231
  }
206
232
  function fetchOpts(ctx) {
207
233
  return {
@@ -526,7 +552,7 @@ var WSManager = class {
526
552
  // src/chains/constants.ts
527
553
  var CHAINS = {
528
554
  mainnet: {
529
- rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet/rpc/v0_10",
555
+ rpcUrl: "https://rpc.provable.games/rpc",
530
556
  apiBaseUrl: "https://budokan-api-production.up.railway.app",
531
557
  wsUrl: "wss://budokan-api-production.up.railway.app/ws",
532
558
  budokanAddress: "0x0596ced030e74ebc37f33607f07ecd5a62eff22cdc4ae31fe2d724040c1bdc0b",
@@ -805,7 +831,7 @@ function phaseToRpcArg(phase) {
805
831
  }
806
832
  return new CairoCustomEnum(variants);
807
833
  }
808
- function parseTournament(raw, entryCount) {
834
+ function parseTournament(raw, entryCount, protocolFeeShare = null) {
809
835
  const obj = raw;
810
836
  const id = String(obj.id ?? "0");
811
837
  const createdAt = Number(obj.created_at ?? 0);
@@ -903,6 +929,8 @@ function parseTournament(raw, entryCount) {
903
929
  leaderboardGameMustBeOver: gameMustBeOver,
904
930
  entryFeeToken,
905
931
  entryFeeAmount,
932
+ // Protocol-fee bps snapshot, surfaced by the viewer's TournamentFullState.
933
+ protocolFeeShare,
906
934
  hasEntryRequirement,
907
935
  schedule: {
908
936
  registrationStartDelay,
@@ -924,6 +952,14 @@ function parseTournament(raw, entryCount) {
924
952
  entryFeeExtension,
925
953
  entryRequirement,
926
954
  leaderboardConfig: { ascending, gameMustBeOver },
955
+ phase: tournamentPhase({
956
+ createdAtOnchain: createdAtStr,
957
+ registrationStartDelay,
958
+ registrationEndDelay,
959
+ gameStartDelay,
960
+ gameEndDelay,
961
+ submissionDuration
962
+ }),
927
963
  entryCount,
928
964
  prizeCount: 0,
929
965
  // Not available from viewer
@@ -1069,7 +1105,8 @@ function parseFilterResult(raw) {
1069
1105
  function parseTournamentFullState(raw) {
1070
1106
  const obj = raw;
1071
1107
  const entryCount = Number(obj.entry_count ?? 0);
1072
- return parseTournament(obj.tournament, entryCount);
1108
+ const protocolFeeShare = obj.protocol_fee_bps != null ? Number(obj.protocol_fee_bps) : null;
1109
+ return parseTournament(obj.tournament, entryCount, protocolFeeShare);
1073
1110
  }
1074
1111
  async function viewerTournaments(contract, offset, limit) {
1075
1112
  return wrapRpcCall(async () => {
@@ -1245,6 +1282,9 @@ function translateCairoRewardType(rewardType) {
1245
1282
  if (subVariant === "GameCreator" || subBag?.GameCreator !== void 0) {
1246
1283
  return rewardClaim({ claimKind: "entry_fee_game_creator" });
1247
1284
  }
1285
+ if (subVariant === "ProtocolFee" || subBag?.ProtocolFee !== void 0) {
1286
+ return rewardClaim({ claimKind: "entry_fee_protocol_fee" });
1287
+ }
1248
1288
  if (subVariant === "Refund" || subBag?.Refund !== void 0) {
1249
1289
  return rewardClaim({
1250
1290
  claimKind: "entry_fee_refund",
@@ -1717,6 +1757,10 @@ var budokanViewer_default = [
1717
1757
  {
1718
1758
  name: "phase",
1719
1759
  type: "budokan_interfaces::budokan::Phase"
1760
+ },
1761
+ {
1762
+ name: "protocol_fee_bps",
1763
+ type: "core::integer::u16"
1720
1764
  }
1721
1765
  ]
1722
1766
  },
@@ -1987,6 +2031,10 @@ var budokanViewer_default = [
1987
2031
  {
1988
2032
  name: "Refund",
1989
2033
  type: "core::felt252"
2034
+ },
2035
+ {
2036
+ name: "ProtocolFee",
2037
+ type: "()"
1990
2038
  }
1991
2039
  ]
1992
2040
  },
@@ -3365,6 +3413,10 @@ var budokan_default = [
3365
3413
  {
3366
3414
  name: "Refund",
3367
3415
  type: "core::felt252"
3416
+ },
3417
+ {
3418
+ name: "ProtocolFee",
3419
+ type: "()"
3368
3420
  }
3369
3421
  ]
3370
3422
  },
@@ -4653,6 +4705,11 @@ var budokan_default = [
4653
4705
  name: "entry_requirement",
4654
4706
  type: "core::option::Option::<game_components_interfaces::entry_requirement::EntryRequirement>",
4655
4707
  kind: "data"
4708
+ },
4709
+ {
4710
+ name: "protocol_fee_bps",
4711
+ type: "core::integer::u16",
4712
+ kind: "data"
4656
4713
  }
4657
4714
  ]
4658
4715
  },
@@ -4875,6 +4932,108 @@ var budokan_default = [
4875
4932
  name: "QualificationEntriesUpdated",
4876
4933
  type: "budokan::events::QualificationEntriesUpdated",
4877
4934
  kind: "nested"
4935
+ },
4936
+ {
4937
+ name: "ProtocolFeeBpsUpdated",
4938
+ type: "budokan::events::ProtocolFeeBpsUpdated",
4939
+ kind: "nested"
4940
+ },
4941
+ {
4942
+ name: "ProtocolFeeRecipientUpdated",
4943
+ type: "budokan::events::ProtocolFeeRecipientUpdated",
4944
+ kind: "nested"
4945
+ }
4946
+ ]
4947
+ },
4948
+ {
4949
+ type: "interface",
4950
+ name: "budokan::budokan::Budokan::IBudokanProtocolFeeAdmin",
4951
+ items: [
4952
+ {
4953
+ type: "function",
4954
+ name: "set_protocol_fee_bps",
4955
+ inputs: [
4956
+ {
4957
+ name: "bps",
4958
+ type: "core::integer::u16"
4959
+ }
4960
+ ],
4961
+ outputs: [],
4962
+ state_mutability: "external"
4963
+ },
4964
+ {
4965
+ type: "function",
4966
+ name: "set_protocol_fee_recipient",
4967
+ inputs: [
4968
+ {
4969
+ name: "recipient",
4970
+ type: "core::starknet::contract_address::ContractAddress"
4971
+ }
4972
+ ],
4973
+ outputs: [],
4974
+ state_mutability: "external"
4975
+ },
4976
+ {
4977
+ type: "function",
4978
+ name: "protocol_fee_bps",
4979
+ inputs: [],
4980
+ outputs: [
4981
+ {
4982
+ type: "core::integer::u16"
4983
+ }
4984
+ ],
4985
+ state_mutability: "view"
4986
+ },
4987
+ {
4988
+ type: "function",
4989
+ name: "protocol_fee_recipient",
4990
+ inputs: [],
4991
+ outputs: [
4992
+ {
4993
+ type: "core::starknet::contract_address::ContractAddress"
4994
+ }
4995
+ ],
4996
+ state_mutability: "view"
4997
+ },
4998
+ {
4999
+ type: "function",
5000
+ name: "tournament_protocol_fee_bps",
5001
+ inputs: [
5002
+ {
5003
+ name: "tournament_id",
5004
+ type: "core::integer::u64"
5005
+ }
5006
+ ],
5007
+ outputs: [
5008
+ {
5009
+ type: "core::integer::u16"
5010
+ }
5011
+ ],
5012
+ state_mutability: "view"
5013
+ }
5014
+ ]
5015
+ },
5016
+ {
5017
+ type: "event",
5018
+ name: "budokan::events::ProtocolFeeBpsUpdated",
5019
+ kind: "struct",
5020
+ members: [
5021
+ {
5022
+ name: "bps",
5023
+ type: "core::integer::u16",
5024
+ kind: "data"
5025
+ }
5026
+ ]
5027
+ },
5028
+ {
5029
+ type: "event",
5030
+ name: "budokan::events::ProtocolFeeRecipientUpdated",
5031
+ kind: "struct",
5032
+ members: [
5033
+ {
5034
+ name: "recipient",
5035
+ type: "core::starknet::contract_address::ContractAddress",
5036
+ kind: "key"
4878
5037
  }
4879
5038
  ]
4880
5039
  }