@provable-games/budokan-sdk 0.1.0 → 0.1.2

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.
@@ -0,0 +1,205 @@
1
+ import { T as Tournament, L as LeaderboardEntry, P as PrizeAggregation, a as Prize, b as PaginatedResult, Q as QualificationEntry, R as Registration, c as RewardClaim, d as RewardClaimSummary, e as TournamentListParams, f as PlayerStats, g as PlayerTournamentParams, h as PlayerTournament, i as PlatformStats, A as ActivityParams, j as ActivityEvent, k as PrizeStats, W as WSSubscribeOptions, l as WSEventHandler } from './client-BtC3ngNe.js';
2
+ export { B as BudokanClient, m as BudokanClientConfig, C as ConnectionMode, n as ConnectionStatus, o as ConnectionStatusState, D as DataSource, E as EntryFee, G as GameConfig, p as LeaderboardConfig, q as Phase, S as Schedule, r as WSChannel, s as WSEventMessage, t as WSMessage, u as WSSubscribeMessage, v as WSUnsubscribeMessage, w as createBudokanClient } from './client-BtC3ngNe.js';
3
+
4
+ declare class BudokanError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ declare class BudokanApiError extends BudokanError {
8
+ readonly status: number;
9
+ readonly statusText: string;
10
+ constructor(message: string, status: number, statusText?: string);
11
+ }
12
+ declare class BudokanTimeoutError extends BudokanError {
13
+ constructor(message?: string);
14
+ }
15
+ declare class BudokanConnectionError extends BudokanError {
16
+ constructor(message?: string);
17
+ }
18
+ declare class TournamentNotFoundError extends BudokanError {
19
+ readonly tournamentId: string;
20
+ constructor(tournamentId: string);
21
+ }
22
+ declare class RpcError extends BudokanError {
23
+ readonly contractAddress?: string;
24
+ constructor(message: string, contractAddress?: string);
25
+ }
26
+ declare class DataSourceError extends BudokanError {
27
+ readonly primaryError: Error;
28
+ readonly fallbackError: Error;
29
+ constructor(primaryError: Error, fallbackError: Error);
30
+ }
31
+
32
+ interface ApiContext$3 {
33
+ retryAttempts?: number;
34
+ retryDelay?: number;
35
+ timeout?: number;
36
+ }
37
+ /**
38
+ * Fetch a paginated list of tournaments.
39
+ */
40
+ declare function getTournaments(baseUrl: string, params?: TournamentListParams, ctx?: ApiContext$3): Promise<PaginatedResult<Tournament>>;
41
+ /**
42
+ * Fetch a single tournament by ID.
43
+ */
44
+ declare function getTournament(baseUrl: string, tournamentId: string, ctx?: ApiContext$3): Promise<Tournament>;
45
+ /**
46
+ * Fetch the leaderboard for a tournament.
47
+ */
48
+ declare function getTournamentLeaderboard(baseUrl: string, tournamentId: string, ctx?: ApiContext$3): Promise<LeaderboardEntry[]>;
49
+ /**
50
+ * Fetch registrations for a tournament.
51
+ */
52
+ declare function getTournamentRegistrations(baseUrl: string, tournamentId: string, params?: {
53
+ limit?: number;
54
+ offset?: number;
55
+ }, ctx?: ApiContext$3): Promise<PaginatedResult<Registration>>;
56
+ /**
57
+ * Fetch prizes for a tournament.
58
+ */
59
+ declare function getTournamentPrizes(baseUrl: string, tournamentId: string, ctx?: ApiContext$3): Promise<Prize[]>;
60
+ /**
61
+ * Fetch reward claims for a tournament.
62
+ */
63
+ declare function getTournamentRewardClaims(baseUrl: string, tournamentId: string, params?: {
64
+ limit?: number;
65
+ offset?: number;
66
+ }, ctx?: ApiContext$3): Promise<PaginatedResult<RewardClaim>>;
67
+ /**
68
+ * Fetch reward claims summary for a tournament.
69
+ */
70
+ declare function getTournamentRewardClaimsSummary(baseUrl: string, tournamentId: string, ctx?: ApiContext$3): Promise<RewardClaimSummary>;
71
+ /**
72
+ * Fetch qualifications for a tournament.
73
+ */
74
+ declare function getTournamentQualifications(baseUrl: string, tournamentId: string, params?: {
75
+ limit?: number;
76
+ offset?: number;
77
+ }, ctx?: ApiContext$3): Promise<PaginatedResult<QualificationEntry>>;
78
+ /**
79
+ * Fetch prize aggregation for a tournament.
80
+ */
81
+ declare function getTournamentPrizeAggregation(baseUrl: string, tournamentId: string, ctx?: ApiContext$3): Promise<PrizeAggregation[]>;
82
+
83
+ interface ApiContext$2 {
84
+ retryAttempts?: number;
85
+ retryDelay?: number;
86
+ timeout?: number;
87
+ }
88
+ /**
89
+ * Fetch tournaments for a player.
90
+ */
91
+ declare function getPlayerTournaments(baseUrl: string, address: string, params?: PlayerTournamentParams, ctx?: ApiContext$2): Promise<PaginatedResult<PlayerTournament>>;
92
+ /**
93
+ * Fetch stats for a player.
94
+ */
95
+ declare function getPlayerStats(baseUrl: string, address: string, ctx?: ApiContext$2): Promise<PlayerStats>;
96
+
97
+ interface ApiContext$1 {
98
+ retryAttempts?: number;
99
+ retryDelay?: number;
100
+ timeout?: number;
101
+ }
102
+ /**
103
+ * Fetch tournaments for a specific game.
104
+ */
105
+ declare function getGameTournaments(baseUrl: string, gameAddress: string, params?: Omit<TournamentListParams, "gameAddress">, ctx?: ApiContext$1): Promise<PaginatedResult<Tournament>>;
106
+ /**
107
+ * Fetch tournament stats for a specific game.
108
+ */
109
+ declare function getGameStats(baseUrl: string, gameAddress: string, ctx?: ApiContext$1): Promise<PlatformStats>;
110
+
111
+ interface ApiContext {
112
+ retryAttempts?: number;
113
+ retryDelay?: number;
114
+ timeout?: number;
115
+ }
116
+ /**
117
+ * Fetch activity events with optional filtering.
118
+ */
119
+ declare function getActivity(baseUrl: string, params?: ActivityParams, ctx?: ApiContext): Promise<PaginatedResult<ActivityEvent>>;
120
+ /**
121
+ * Fetch platform-wide activity stats.
122
+ */
123
+ declare function getActivityStats(baseUrl: string, ctx?: ApiContext): Promise<PlatformStats>;
124
+ /**
125
+ * Fetch platform-wide prize stats.
126
+ */
127
+ declare function getPrizeStats(baseUrl: string, ctx?: ApiContext): Promise<PrizeStats>;
128
+
129
+ interface WSManagerConfig {
130
+ maxReconnectAttempts: number;
131
+ reconnectBaseDelay: number;
132
+ }
133
+ /**
134
+ * WebSocket manager with auto-reconnect and subscription management.
135
+ */
136
+ declare class WSManager {
137
+ private ws;
138
+ private readonly wsUrl;
139
+ private readonly config;
140
+ private reconnectAttempts;
141
+ private reconnectTimeout;
142
+ private subscriptions;
143
+ private nextSubId;
144
+ private connected;
145
+ private connectionListeners;
146
+ constructor(wsUrl: string, config?: Partial<WSManagerConfig>);
147
+ /**
148
+ * Open a WebSocket connection. No-op if already connected.
149
+ */
150
+ connect(): void;
151
+ /**
152
+ * Close the WebSocket connection and stop reconnecting.
153
+ */
154
+ disconnect(): void;
155
+ /**
156
+ * Subscribe to channels with an optional tournament filter.
157
+ * Returns an unsubscribe function.
158
+ */
159
+ subscribe(options: WSSubscribeOptions, handler: WSEventHandler): () => void;
160
+ /**
161
+ * Register a callback for a single message. Convenience wrapper around subscribe.
162
+ * Returns an unsubscribe function.
163
+ */
164
+ onMessage(callback: WSEventHandler): () => void;
165
+ /**
166
+ * Whether the WebSocket is currently connected.
167
+ */
168
+ get isConnected(): boolean;
169
+ /**
170
+ * Register a listener for connection state changes.
171
+ * Returns an unsubscribe function.
172
+ */
173
+ onConnectionChange(listener: (connected: boolean) => void): () => void;
174
+ private notifyConnectionChange;
175
+ private sendSubscribe;
176
+ private attemptReconnect;
177
+ }
178
+
179
+ /**
180
+ * Normalize a Starknet address to a 0x-prefixed, 66-character lowercase hex string.
181
+ */
182
+ declare function normalizeAddress(address: string): string;
183
+
184
+ /**
185
+ * Deeply convert all keys in an object from snake_case to camelCase.
186
+ */
187
+ declare function snakeToCamel<T>(obj: unknown): T;
188
+ /**
189
+ * Deeply convert all keys in an object from camelCase to snake_case.
190
+ */
191
+ declare function camelToSnake<T>(obj: unknown): T;
192
+
193
+ declare function withRetry<T>(fn: () => Promise<T>, attempts?: number, delay?: number): Promise<T>;
194
+
195
+ interface ChainConfig {
196
+ rpcUrl: string;
197
+ apiBaseUrl: string;
198
+ wsUrl: string;
199
+ budokanAddress: string;
200
+ viewerAddress: string;
201
+ }
202
+ declare const CHAINS: Record<string, ChainConfig>;
203
+ declare function getChainConfig(chain: string): ChainConfig | undefined;
204
+
205
+ export { ActivityEvent, ActivityParams, BudokanApiError, BudokanConnectionError, BudokanError, BudokanTimeoutError, CHAINS, type ChainConfig, DataSourceError, LeaderboardEntry, PaginatedResult, PlatformStats, PlayerStats, PlayerTournament, PlayerTournamentParams, Prize, PrizeAggregation, PrizeStats, QualificationEntry, Registration, RewardClaim, RewardClaimSummary, RpcError, Tournament, TournamentListParams, TournamentNotFoundError, WSEventHandler, WSManager, WSSubscribeOptions, camelToSnake, getActivity, getActivityStats, getChainConfig, getGameStats, getGameTournaments, getPlayerStats, getPlayerTournaments, getPrizeStats, getTournament, getTournamentLeaderboard, getTournamentPrizeAggregation, getTournamentPrizes, getTournamentQualifications, getTournamentRegistrations, getTournamentRewardClaims, getTournamentRewardClaimsSummary, getTournaments, normalizeAddress, snakeToCamel, withRetry };