@dubsdotapp/expo 0.1.0
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/README.md +158 -0
- package/dist/index.d.mts +577 -0
- package/dist/index.d.ts +577 -0
- package/dist/index.js +1364 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1318 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +57 -0
- package/src/client.ts +355 -0
- package/src/constants.ts +3 -0
- package/src/errors.ts +127 -0
- package/src/hooks/index.ts +12 -0
- package/src/hooks/useAuth.ts +180 -0
- package/src/hooks/useClaim.ts +64 -0
- package/src/hooks/useCreateGame.ts +78 -0
- package/src/hooks/useEvents.ts +34 -0
- package/src/hooks/useGame.ts +30 -0
- package/src/hooks/useGames.ts +31 -0
- package/src/hooks/useJoinGame.ts +78 -0
- package/src/hooks/useNetworkGames.ts +31 -0
- package/src/index.ts +83 -0
- package/src/provider.tsx +39 -0
- package/src/types.ts +340 -0
- package/src/ui/ConnectWalletScreen.tsx +145 -0
- package/src/ui/SettingsSheet.tsx +173 -0
- package/src/ui/UserProfileCard.tsx +90 -0
- package/src/ui/index.ts +8 -0
- package/src/ui/theme.ts +57 -0
- package/src/utils/transaction.ts +67 -0
- package/src/wallet/index.ts +3 -0
- package/src/wallet/mwa-adapter.ts +156 -0
- package/src/wallet/types.ts +30 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { PublicKey, Transaction, Connection, TransactionConfirmationStatus } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
interface Opponent {
|
|
6
|
+
name: string | null;
|
|
7
|
+
imageUrl: string | null;
|
|
8
|
+
score: number | null;
|
|
9
|
+
}
|
|
10
|
+
interface EventMedia {
|
|
11
|
+
poster: string | null;
|
|
12
|
+
thumbnail: string | null;
|
|
13
|
+
streams: EventStream[];
|
|
14
|
+
}
|
|
15
|
+
interface EventStream {
|
|
16
|
+
url: string | null;
|
|
17
|
+
language: string | null;
|
|
18
|
+
}
|
|
19
|
+
interface EventMeta {
|
|
20
|
+
matchType: string | null;
|
|
21
|
+
numberOfGames: number | null;
|
|
22
|
+
tournament: string | null;
|
|
23
|
+
country: string | null;
|
|
24
|
+
}
|
|
25
|
+
interface UnifiedEvent {
|
|
26
|
+
id: string;
|
|
27
|
+
type: 'sports' | 'esports';
|
|
28
|
+
title: string;
|
|
29
|
+
league: string | null;
|
|
30
|
+
game: string | null;
|
|
31
|
+
startTime: string | null;
|
|
32
|
+
status: 'upcoming' | 'live' | 'finished' | 'canceled';
|
|
33
|
+
tier: string | null;
|
|
34
|
+
venue: string | null;
|
|
35
|
+
opponents: Opponent[];
|
|
36
|
+
media: EventMedia;
|
|
37
|
+
meta: EventMeta;
|
|
38
|
+
}
|
|
39
|
+
interface Pagination {
|
|
40
|
+
page: number;
|
|
41
|
+
perPage: number;
|
|
42
|
+
total: number;
|
|
43
|
+
totalPages: number;
|
|
44
|
+
}
|
|
45
|
+
interface EsportsMatchOpponent {
|
|
46
|
+
id: number;
|
|
47
|
+
name: string;
|
|
48
|
+
acronym: string | null;
|
|
49
|
+
imageUrl: string | null;
|
|
50
|
+
}
|
|
51
|
+
interface EsportsMatchResult {
|
|
52
|
+
teamId: number;
|
|
53
|
+
score: number;
|
|
54
|
+
}
|
|
55
|
+
interface EsportsMatchDetail {
|
|
56
|
+
matchId: number;
|
|
57
|
+
title: string;
|
|
58
|
+
status: string;
|
|
59
|
+
videogame: string | null;
|
|
60
|
+
league: string | null;
|
|
61
|
+
serie: string | null;
|
|
62
|
+
tournament: string | null;
|
|
63
|
+
tier: string | null;
|
|
64
|
+
startTime: string | null;
|
|
65
|
+
endTime: string | null;
|
|
66
|
+
matchType: string | null;
|
|
67
|
+
numberOfGames: number | null;
|
|
68
|
+
opponents: EsportsMatchOpponent[];
|
|
69
|
+
results: EsportsMatchResult[];
|
|
70
|
+
winnerId: number | null;
|
|
71
|
+
}
|
|
72
|
+
interface ValidateEventResult {
|
|
73
|
+
bettable: boolean;
|
|
74
|
+
gameMode: number;
|
|
75
|
+
lockTimestamp: number;
|
|
76
|
+
startTime: string | null;
|
|
77
|
+
status: string;
|
|
78
|
+
}
|
|
79
|
+
interface CreateGameParams {
|
|
80
|
+
id: string;
|
|
81
|
+
playerWallet: string;
|
|
82
|
+
teamChoice: 'home' | 'away' | 'draw';
|
|
83
|
+
wagerAmount: number;
|
|
84
|
+
}
|
|
85
|
+
interface CreateGameResult {
|
|
86
|
+
gameId: string;
|
|
87
|
+
gameAddress: string;
|
|
88
|
+
transaction: string;
|
|
89
|
+
lockTimestamp: number;
|
|
90
|
+
event: UnifiedEvent;
|
|
91
|
+
}
|
|
92
|
+
interface JoinGameParams {
|
|
93
|
+
playerWallet: string;
|
|
94
|
+
gameId: string;
|
|
95
|
+
teamChoice: 'home' | 'away' | 'draw';
|
|
96
|
+
amount: number;
|
|
97
|
+
}
|
|
98
|
+
interface JoinGameResult {
|
|
99
|
+
gameId: string;
|
|
100
|
+
transaction: string;
|
|
101
|
+
gameAddress: string;
|
|
102
|
+
}
|
|
103
|
+
interface ConfirmGameParams {
|
|
104
|
+
gameId: string;
|
|
105
|
+
playerWallet: string;
|
|
106
|
+
signature: string;
|
|
107
|
+
teamChoice?: 'home' | 'away' | 'draw';
|
|
108
|
+
wagerAmount?: number;
|
|
109
|
+
role?: 'creator' | 'joiner';
|
|
110
|
+
gameAddress?: string;
|
|
111
|
+
}
|
|
112
|
+
interface ConfirmGameResult {
|
|
113
|
+
gameId: string;
|
|
114
|
+
signature: string;
|
|
115
|
+
explorerUrl: string;
|
|
116
|
+
message: string;
|
|
117
|
+
}
|
|
118
|
+
interface BuildClaimParams {
|
|
119
|
+
playerWallet: string;
|
|
120
|
+
gameId: string;
|
|
121
|
+
}
|
|
122
|
+
interface BuildClaimResult {
|
|
123
|
+
transaction: string;
|
|
124
|
+
gameAddress: string;
|
|
125
|
+
message: string;
|
|
126
|
+
}
|
|
127
|
+
interface GameMedia {
|
|
128
|
+
poster: string | null;
|
|
129
|
+
thumbnail: string | null;
|
|
130
|
+
}
|
|
131
|
+
interface GameDetail {
|
|
132
|
+
gameId: string;
|
|
133
|
+
gameAddress: string;
|
|
134
|
+
title: string;
|
|
135
|
+
buyIn: number;
|
|
136
|
+
gameMode: number;
|
|
137
|
+
isLocked: boolean;
|
|
138
|
+
isResolved: boolean;
|
|
139
|
+
status: string;
|
|
140
|
+
lockTimestamp: number | null;
|
|
141
|
+
homePlayers: string[];
|
|
142
|
+
awayPlayers: string[];
|
|
143
|
+
drawPlayers: string[];
|
|
144
|
+
homePool: number;
|
|
145
|
+
awayPool: number;
|
|
146
|
+
drawPool: number;
|
|
147
|
+
totalPool: number;
|
|
148
|
+
sportsEvent: Record<string, unknown> | null;
|
|
149
|
+
media: GameMedia;
|
|
150
|
+
createdAt: string;
|
|
151
|
+
updatedAt: string;
|
|
152
|
+
}
|
|
153
|
+
interface GameListOpponent {
|
|
154
|
+
name: string | null;
|
|
155
|
+
imageUrl: string | null;
|
|
156
|
+
}
|
|
157
|
+
interface GameListItem {
|
|
158
|
+
gameId: string;
|
|
159
|
+
title: string;
|
|
160
|
+
buyIn: number;
|
|
161
|
+
gameMode: number;
|
|
162
|
+
isLocked: boolean;
|
|
163
|
+
isResolved: boolean;
|
|
164
|
+
status: string;
|
|
165
|
+
totalPool: number;
|
|
166
|
+
league: string | null;
|
|
167
|
+
lockTimestamp: number | null;
|
|
168
|
+
createdAt: string;
|
|
169
|
+
opponents: GameListOpponent[];
|
|
170
|
+
media: GameMedia;
|
|
171
|
+
}
|
|
172
|
+
interface GetGamesParams {
|
|
173
|
+
wallet?: string;
|
|
174
|
+
status?: 'open' | 'locked' | 'resolved';
|
|
175
|
+
limit?: number;
|
|
176
|
+
offset?: number;
|
|
177
|
+
}
|
|
178
|
+
interface GetNetworkGamesParams {
|
|
179
|
+
league?: string;
|
|
180
|
+
limit?: number;
|
|
181
|
+
offset?: number;
|
|
182
|
+
}
|
|
183
|
+
interface GetUpcomingEventsParams {
|
|
184
|
+
type?: 'sports' | 'esports';
|
|
185
|
+
game?: string;
|
|
186
|
+
page?: number;
|
|
187
|
+
per_page?: number;
|
|
188
|
+
}
|
|
189
|
+
interface ParsedError {
|
|
190
|
+
code: string;
|
|
191
|
+
message: string;
|
|
192
|
+
}
|
|
193
|
+
interface SolanaErrorCode {
|
|
194
|
+
code: string;
|
|
195
|
+
message: string;
|
|
196
|
+
}
|
|
197
|
+
interface DubsUser {
|
|
198
|
+
walletAddress: string;
|
|
199
|
+
username: string;
|
|
200
|
+
avatar: string | null;
|
|
201
|
+
myReferralCode: string | null;
|
|
202
|
+
onboardingComplete: boolean;
|
|
203
|
+
createdAt: string;
|
|
204
|
+
}
|
|
205
|
+
interface DubsPublicUser {
|
|
206
|
+
walletAddress: string;
|
|
207
|
+
username: string;
|
|
208
|
+
avatar: string | null;
|
|
209
|
+
createdAt: string;
|
|
210
|
+
}
|
|
211
|
+
interface DubsAppUser extends DubsPublicUser {
|
|
212
|
+
firstSeenAt: string;
|
|
213
|
+
lastSeenAt: string;
|
|
214
|
+
}
|
|
215
|
+
interface NonceResult {
|
|
216
|
+
nonce: string;
|
|
217
|
+
message: string;
|
|
218
|
+
}
|
|
219
|
+
interface AuthenticateParams {
|
|
220
|
+
walletAddress: string;
|
|
221
|
+
signature: string;
|
|
222
|
+
nonce: string;
|
|
223
|
+
}
|
|
224
|
+
interface AuthenticateResult {
|
|
225
|
+
needsRegistration: boolean;
|
|
226
|
+
user?: DubsUser;
|
|
227
|
+
token?: string;
|
|
228
|
+
}
|
|
229
|
+
interface RegisterParams {
|
|
230
|
+
walletAddress: string;
|
|
231
|
+
signature: string;
|
|
232
|
+
nonce: string;
|
|
233
|
+
username: string;
|
|
234
|
+
referralCode?: string;
|
|
235
|
+
}
|
|
236
|
+
interface RegisterResult {
|
|
237
|
+
user: DubsUser;
|
|
238
|
+
token: string;
|
|
239
|
+
}
|
|
240
|
+
interface CheckUsernameResult {
|
|
241
|
+
available: boolean;
|
|
242
|
+
reason?: string;
|
|
243
|
+
}
|
|
244
|
+
type AuthStatus = 'idle' | 'authenticating' | 'signing' | 'verifying' | 'needsRegistration' | 'registering' | 'authenticated' | 'error';
|
|
245
|
+
type MutationStatus = 'idle' | 'building' | 'signing' | 'confirming' | 'saving' | 'success' | 'error';
|
|
246
|
+
interface QueryResult<T> {
|
|
247
|
+
data: T | null;
|
|
248
|
+
loading: boolean;
|
|
249
|
+
error: Error | null;
|
|
250
|
+
refetch: () => void;
|
|
251
|
+
}
|
|
252
|
+
interface MutationResult<TParams, TResult> {
|
|
253
|
+
execute: (params: TParams) => Promise<TResult>;
|
|
254
|
+
status: MutationStatus;
|
|
255
|
+
error: Error | null;
|
|
256
|
+
data: TResult | null;
|
|
257
|
+
reset: () => void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
interface DubsClientConfig {
|
|
261
|
+
apiKey: string;
|
|
262
|
+
baseUrl?: string;
|
|
263
|
+
}
|
|
264
|
+
declare class DubsClient {
|
|
265
|
+
private readonly apiKey;
|
|
266
|
+
private readonly baseUrl;
|
|
267
|
+
private _token;
|
|
268
|
+
constructor(config: DubsClientConfig);
|
|
269
|
+
/** Set the user JWT token for authenticated requests */
|
|
270
|
+
setToken(token: string | null): void;
|
|
271
|
+
/** Get the current user JWT token */
|
|
272
|
+
getToken(): string | null;
|
|
273
|
+
private request;
|
|
274
|
+
getUpcomingEvents(params?: GetUpcomingEventsParams): Promise<{
|
|
275
|
+
events: UnifiedEvent[];
|
|
276
|
+
pagination: Pagination;
|
|
277
|
+
}>;
|
|
278
|
+
getSportsEvents(league: string): Promise<UnifiedEvent[]>;
|
|
279
|
+
getEsportsMatches(videogame?: string): Promise<UnifiedEvent[]>;
|
|
280
|
+
getEsportsMatchDetail(matchId: string | number): Promise<EsportsMatchDetail>;
|
|
281
|
+
validateEvent(id: string): Promise<ValidateEventResult>;
|
|
282
|
+
createGame(params: CreateGameParams): Promise<CreateGameResult>;
|
|
283
|
+
joinGame(params: JoinGameParams): Promise<JoinGameResult>;
|
|
284
|
+
confirmGame(params: ConfirmGameParams): Promise<ConfirmGameResult>;
|
|
285
|
+
buildClaimTransaction(params: BuildClaimParams): Promise<BuildClaimResult>;
|
|
286
|
+
getGame(gameId: string): Promise<GameDetail>;
|
|
287
|
+
getGames(params?: GetGamesParams): Promise<GameListItem[]>;
|
|
288
|
+
getNetworkGames(params?: GetNetworkGamesParams): Promise<{
|
|
289
|
+
games: GameListItem[];
|
|
290
|
+
pagination: Pagination;
|
|
291
|
+
}>;
|
|
292
|
+
getNonce(walletAddress: string): Promise<NonceResult>;
|
|
293
|
+
authenticate(params: AuthenticateParams): Promise<AuthenticateResult>;
|
|
294
|
+
register(params: RegisterParams): Promise<RegisterResult>;
|
|
295
|
+
getMe(): Promise<DubsUser>;
|
|
296
|
+
getUser(walletAddress: string): Promise<DubsPublicUser | null>;
|
|
297
|
+
getAppUsers(params?: {
|
|
298
|
+
limit?: number;
|
|
299
|
+
offset?: number;
|
|
300
|
+
}): Promise<{
|
|
301
|
+
users: DubsAppUser[];
|
|
302
|
+
pagination: {
|
|
303
|
+
total: number;
|
|
304
|
+
limit: number;
|
|
305
|
+
offset: number;
|
|
306
|
+
};
|
|
307
|
+
}>;
|
|
308
|
+
checkUsername(username: string): Promise<CheckUsernameResult>;
|
|
309
|
+
logout(): Promise<void>;
|
|
310
|
+
parseError(error: unknown): Promise<ParsedError>;
|
|
311
|
+
getErrorCodes(): Promise<Record<number, SolanaErrorCode>>;
|
|
312
|
+
/**
|
|
313
|
+
* Parse a Solana error locally without an API call.
|
|
314
|
+
* Useful for instant feedback in the UI.
|
|
315
|
+
*/
|
|
316
|
+
parseErrorLocal(error: unknown): ParsedError;
|
|
317
|
+
/** Get the full local error code map */
|
|
318
|
+
getErrorCodesLocal(): Record<number, SolanaErrorCode>;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
declare class DubsApiError extends Error {
|
|
322
|
+
readonly code: string;
|
|
323
|
+
readonly httpStatus: number;
|
|
324
|
+
constructor(code: string, message: string, httpStatus: number);
|
|
325
|
+
}
|
|
326
|
+
/** Custom error codes from dubs_solana_program (6000-6049) */
|
|
327
|
+
declare const SOLANA_PROGRAM_ERRORS: Record<number, SolanaErrorCode>;
|
|
328
|
+
/**
|
|
329
|
+
* Parse a raw Solana transaction error into a human-readable { code, message }.
|
|
330
|
+
* Handles: { InstructionError: [idx, { Custom: N }] }, string errors, etc.
|
|
331
|
+
*/
|
|
332
|
+
declare function parseSolanaError(err: unknown): ParsedError;
|
|
333
|
+
|
|
334
|
+
declare const DEFAULT_BASE_URL = "https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1";
|
|
335
|
+
declare const DEFAULT_RPC_URL = "https://api.mainnet-beta.solana.com";
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Minimal wallet adapter interface.
|
|
339
|
+
* Two required methods: publicKey + signTransaction.
|
|
340
|
+
* signAndSendTransaction is optional — if not provided, the SDK signs then sends via RPC.
|
|
341
|
+
*/
|
|
342
|
+
interface WalletAdapter {
|
|
343
|
+
/** The connected wallet's public key, or null if not connected */
|
|
344
|
+
publicKey: PublicKey | null;
|
|
345
|
+
/** Whether the wallet is currently connected */
|
|
346
|
+
connected: boolean;
|
|
347
|
+
/** Sign a transaction without sending it */
|
|
348
|
+
signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
349
|
+
/**
|
|
350
|
+
* Optional: Sign and send in one step.
|
|
351
|
+
* If provided, the SDK will prefer this over signTransaction + sendRawTransaction.
|
|
352
|
+
* Returns the transaction signature.
|
|
353
|
+
*/
|
|
354
|
+
signAndSendTransaction?(transaction: Transaction): Promise<string>;
|
|
355
|
+
/**
|
|
356
|
+
* Optional: Sign an arbitrary message (for authentication).
|
|
357
|
+
* Returns the signature as a Uint8Array.
|
|
358
|
+
*/
|
|
359
|
+
signMessage?(message: Uint8Array): Promise<Uint8Array>;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
interface DubsContextValue {
|
|
363
|
+
client: DubsClient;
|
|
364
|
+
wallet: WalletAdapter;
|
|
365
|
+
connection: Connection;
|
|
366
|
+
}
|
|
367
|
+
interface DubsProviderProps {
|
|
368
|
+
apiKey: string;
|
|
369
|
+
baseUrl?: string;
|
|
370
|
+
rpcUrl?: string;
|
|
371
|
+
wallet: WalletAdapter;
|
|
372
|
+
children: React.ReactNode;
|
|
373
|
+
}
|
|
374
|
+
declare function DubsProvider({ apiKey, baseUrl, rpcUrl, wallet, children }: DubsProviderProps): react_jsx_runtime.JSX.Element;
|
|
375
|
+
declare function useDubs(): DubsContextValue;
|
|
376
|
+
|
|
377
|
+
/** The `transact` function signature from @solana-mobile/mobile-wallet-adapter-protocol-web3js */
|
|
378
|
+
type MwaTransactFn = (callback: (wallet: any) => Promise<any>) => Promise<any>;
|
|
379
|
+
interface MwaAdapterConfig {
|
|
380
|
+
/** The MWA `transact` function — import it from @solana-mobile/mobile-wallet-adapter-protocol-web3js */
|
|
381
|
+
transact: MwaTransactFn;
|
|
382
|
+
appIdentity: {
|
|
383
|
+
name: string;
|
|
384
|
+
uri?: string;
|
|
385
|
+
icon?: string;
|
|
386
|
+
};
|
|
387
|
+
cluster?: string;
|
|
388
|
+
onAuthTokenChange?: (token: string | null) => void;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Mobile Wallet Adapter implementation.
|
|
392
|
+
* Wraps @solana-mobile/mobile-wallet-adapter-protocol-web3js.
|
|
393
|
+
*
|
|
394
|
+
* Usage:
|
|
395
|
+
* ```ts
|
|
396
|
+
* import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
|
|
397
|
+
*
|
|
398
|
+
* const adapter = new MwaWalletAdapter({
|
|
399
|
+
* transact,
|
|
400
|
+
* appIdentity: { name: 'My App' },
|
|
401
|
+
* });
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
declare class MwaWalletAdapter implements WalletAdapter {
|
|
405
|
+
private _publicKey;
|
|
406
|
+
private _connected;
|
|
407
|
+
private _authToken;
|
|
408
|
+
private readonly config;
|
|
409
|
+
private readonly transact;
|
|
410
|
+
constructor(config: MwaAdapterConfig);
|
|
411
|
+
get publicKey(): PublicKey | null;
|
|
412
|
+
get connected(): boolean;
|
|
413
|
+
/**
|
|
414
|
+
* Connect to a mobile wallet. Call this before any signing.
|
|
415
|
+
*/
|
|
416
|
+
connect(): Promise<void>;
|
|
417
|
+
/**
|
|
418
|
+
* Disconnect and clear auth token.
|
|
419
|
+
*/
|
|
420
|
+
disconnect(): void;
|
|
421
|
+
signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
422
|
+
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
423
|
+
signAndSendTransaction(transaction: Transaction): Promise<string>;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
declare function useEvents(params?: GetUpcomingEventsParams): QueryResult<{
|
|
427
|
+
events: UnifiedEvent[];
|
|
428
|
+
pagination: Pagination;
|
|
429
|
+
}>;
|
|
430
|
+
|
|
431
|
+
declare function useGame(gameId: string | null): QueryResult<GameDetail>;
|
|
432
|
+
|
|
433
|
+
declare function useGames(params?: GetGamesParams): QueryResult<GameListItem[]>;
|
|
434
|
+
|
|
435
|
+
declare function useNetworkGames(params?: GetNetworkGamesParams): QueryResult<{
|
|
436
|
+
games: GameListItem[];
|
|
437
|
+
pagination: Pagination;
|
|
438
|
+
}>;
|
|
439
|
+
|
|
440
|
+
interface CreateGameMutationResult {
|
|
441
|
+
gameId: string;
|
|
442
|
+
gameAddress: string;
|
|
443
|
+
signature: string;
|
|
444
|
+
explorerUrl: string;
|
|
445
|
+
}
|
|
446
|
+
declare function useCreateGame(): {
|
|
447
|
+
execute: (params: CreateGameParams) => Promise<CreateGameMutationResult>;
|
|
448
|
+
status: MutationStatus;
|
|
449
|
+
error: Error | null;
|
|
450
|
+
data: CreateGameMutationResult | null;
|
|
451
|
+
reset: () => void;
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
interface JoinGameMutationResult {
|
|
455
|
+
gameId: string;
|
|
456
|
+
gameAddress: string;
|
|
457
|
+
signature: string;
|
|
458
|
+
explorerUrl: string;
|
|
459
|
+
}
|
|
460
|
+
declare function useJoinGame(): {
|
|
461
|
+
execute: (params: JoinGameParams) => Promise<JoinGameMutationResult>;
|
|
462
|
+
status: MutationStatus;
|
|
463
|
+
error: Error | null;
|
|
464
|
+
data: JoinGameMutationResult | null;
|
|
465
|
+
reset: () => void;
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
interface ClaimMutationResult {
|
|
469
|
+
gameId: string;
|
|
470
|
+
signature: string;
|
|
471
|
+
explorerUrl: string;
|
|
472
|
+
}
|
|
473
|
+
declare function useClaim(): {
|
|
474
|
+
execute: (params: BuildClaimParams) => Promise<ClaimMutationResult>;
|
|
475
|
+
status: MutationStatus;
|
|
476
|
+
error: Error | null;
|
|
477
|
+
data: ClaimMutationResult | null;
|
|
478
|
+
reset: () => void;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
interface UseAuthResult {
|
|
482
|
+
/** Current auth status */
|
|
483
|
+
status: AuthStatus;
|
|
484
|
+
/** Authenticated user profile, or null */
|
|
485
|
+
user: DubsUser | null;
|
|
486
|
+
/** JWT token, or null */
|
|
487
|
+
token: string | null;
|
|
488
|
+
/** Convenience boolean */
|
|
489
|
+
isAuthenticated: boolean;
|
|
490
|
+
/** Error from the last operation, or null */
|
|
491
|
+
error: Error | null;
|
|
492
|
+
/**
|
|
493
|
+
* Full nonce → sign → verify flow.
|
|
494
|
+
* If the wallet is already registered, resolves to authenticated state.
|
|
495
|
+
* If new wallet, resolves to needsRegistration state — call register() next.
|
|
496
|
+
*/
|
|
497
|
+
authenticate: () => Promise<void>;
|
|
498
|
+
/**
|
|
499
|
+
* Register a new user after authenticate() returned needsRegistration.
|
|
500
|
+
* Reuses the nonce+signature from authenticate() — no second signing prompt.
|
|
501
|
+
*/
|
|
502
|
+
register: (username: string, referralCode?: string) => Promise<void>;
|
|
503
|
+
/** Log out and clear state */
|
|
504
|
+
logout: () => Promise<void>;
|
|
505
|
+
/**
|
|
506
|
+
* Restore a session from a saved token (e.g. AsyncStorage on app restart).
|
|
507
|
+
* Calls GET /auth/me to validate. Returns true if valid, false otherwise.
|
|
508
|
+
*/
|
|
509
|
+
restoreSession: (token: string) => Promise<boolean>;
|
|
510
|
+
/** Reset to idle state, clearing errors and user */
|
|
511
|
+
reset: () => void;
|
|
512
|
+
}
|
|
513
|
+
declare function useAuth(): UseAuthResult;
|
|
514
|
+
|
|
515
|
+
interface ConnectWalletScreenProps {
|
|
516
|
+
/** Called when the user taps Connect Wallet */
|
|
517
|
+
onConnect: () => void | Promise<void>;
|
|
518
|
+
/** Show a loading spinner on the button while connecting */
|
|
519
|
+
connecting?: boolean;
|
|
520
|
+
/** Error message to display (e.g. "User rejected the request") */
|
|
521
|
+
error?: string | null;
|
|
522
|
+
/** App name shown in the header. Defaults to "Dubs" */
|
|
523
|
+
appName?: string;
|
|
524
|
+
}
|
|
525
|
+
declare function ConnectWalletScreen({ onConnect, connecting, error, appName, }: ConnectWalletScreenProps): react_jsx_runtime.JSX.Element;
|
|
526
|
+
|
|
527
|
+
interface UserProfileCardProps {
|
|
528
|
+
walletAddress: string;
|
|
529
|
+
username?: string;
|
|
530
|
+
avatarUrl?: string | null;
|
|
531
|
+
memberSince?: string | null;
|
|
532
|
+
}
|
|
533
|
+
declare function UserProfileCard({ walletAddress, username, avatarUrl, memberSince, }: UserProfileCardProps): react_jsx_runtime.JSX.Element;
|
|
534
|
+
|
|
535
|
+
interface SettingsSheetProps {
|
|
536
|
+
walletAddress: string;
|
|
537
|
+
username?: string;
|
|
538
|
+
avatarUrl?: string | null;
|
|
539
|
+
memberSince?: string | null;
|
|
540
|
+
appVersion?: string;
|
|
541
|
+
onCopyAddress?: () => void;
|
|
542
|
+
onSupport?: () => void;
|
|
543
|
+
onLogout: () => void | Promise<void>;
|
|
544
|
+
loggingOut?: boolean;
|
|
545
|
+
}
|
|
546
|
+
declare function SettingsSheet({ walletAddress, username, avatarUrl, memberSince, appVersion, onCopyAddress, onSupport, onLogout, loggingOut, }: SettingsSheetProps): react_jsx_runtime.JSX.Element;
|
|
547
|
+
|
|
548
|
+
interface DubsTheme {
|
|
549
|
+
background: string;
|
|
550
|
+
surface: string;
|
|
551
|
+
surfaceActive: string;
|
|
552
|
+
border: string;
|
|
553
|
+
text: string;
|
|
554
|
+
textSecondary: string;
|
|
555
|
+
textMuted: string;
|
|
556
|
+
textDim: string;
|
|
557
|
+
accent: string;
|
|
558
|
+
success: string;
|
|
559
|
+
live: string;
|
|
560
|
+
errorText: string;
|
|
561
|
+
errorBg: string;
|
|
562
|
+
errorBorder: string;
|
|
563
|
+
}
|
|
564
|
+
declare function useDubsTheme(): DubsTheme;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Deserialize a base64-encoded transaction, sign via wallet adapter, send to Solana.
|
|
568
|
+
* Returns the transaction signature.
|
|
569
|
+
*/
|
|
570
|
+
declare function signAndSendBase64Transaction(base64Tx: string, wallet: WalletAdapter, connection: Connection): Promise<string>;
|
|
571
|
+
/**
|
|
572
|
+
* Poll for transaction confirmation using getSignatureStatuses.
|
|
573
|
+
* Uses polling instead of deprecated WebSocket-based confirmTransaction.
|
|
574
|
+
*/
|
|
575
|
+
declare function pollTransactionConfirmation(signature: string, connection: Connection, commitment?: TransactionConfirmationStatus, timeout?: number, interval?: number): Promise<void>;
|
|
576
|
+
|
|
577
|
+
export { type AuthStatus, type AuthenticateParams, type AuthenticateResult, type BuildClaimParams, type BuildClaimResult, type CheckUsernameResult, type ClaimMutationResult, type ConfirmGameParams, type ConfirmGameResult, ConnectWalletScreen, type ConnectWalletScreenProps, type CreateGameMutationResult, type CreateGameParams, type CreateGameResult, DEFAULT_BASE_URL, DEFAULT_RPC_URL, DubsApiError, type DubsAppUser, DubsClient, type DubsClientConfig, type DubsContextValue, DubsProvider, type DubsProviderProps, type DubsPublicUser, type DubsTheme, type DubsUser, type EsportsMatchDetail, type EsportsMatchOpponent, type EsportsMatchResult, type EventMedia, type EventMeta, type EventStream, type GameDetail, type GameListItem, type GameListOpponent, type GameMedia, type GetGamesParams, type GetNetworkGamesParams, type GetUpcomingEventsParams, type JoinGameMutationResult, type JoinGameParams, type JoinGameResult, type MutationResult, type MutationStatus, type MwaAdapterConfig, type MwaTransactFn, MwaWalletAdapter, type NonceResult, type Opponent, type Pagination, type ParsedError, type QueryResult, type RegisterParams, type RegisterResult, SOLANA_PROGRAM_ERRORS, SettingsSheet, type SettingsSheetProps, type SolanaErrorCode, type UnifiedEvent, type UseAuthResult, UserProfileCard, type UserProfileCardProps, type ValidateEventResult, type WalletAdapter, parseSolanaError, pollTransactionConfirmation, signAndSendBase64Transaction, useAuth, useClaim, useCreateGame, useDubs, useDubsTheme, useEvents, useGame, useGames, useJoinGame, useNetworkGames };
|