@dubsdotapp/expo 0.1.3 → 0.2.1

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
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';
2
+ import React$1 from 'react';
3
+ import { PublicKey, Transaction, Connection } from '@solana/web3.js';
4
4
 
5
5
  interface Opponent {
6
6
  name: string | null;
@@ -128,6 +128,13 @@ interface GameMedia {
128
128
  poster: string | null;
129
129
  thumbnail: string | null;
130
130
  }
131
+ interface Bettor {
132
+ wallet: string;
133
+ username: string | null;
134
+ avatar: string | null;
135
+ team: 'home' | 'away' | 'draw';
136
+ amount: number;
137
+ }
131
138
  interface GameDetail {
132
139
  gameId: string;
133
140
  gameAddress: string;
@@ -137,15 +144,14 @@ interface GameDetail {
137
144
  isLocked: boolean;
138
145
  isResolved: boolean;
139
146
  status: string;
147
+ league: string | null;
140
148
  lockTimestamp: number | null;
141
- homePlayers: string[];
142
- awayPlayers: string[];
143
- drawPlayers: string[];
149
+ opponents: GameListOpponent[];
150
+ bettors: Bettor[];
144
151
  homePool: number;
145
152
  awayPool: number;
146
153
  drawPool: number;
147
154
  totalPool: number;
148
- sportsEvent: Record<string, unknown> | null;
149
155
  media: GameMedia;
150
156
  createdAt: string;
151
157
  updatedAt: string;
@@ -177,6 +183,7 @@ interface GetGamesParams {
177
183
  }
178
184
  interface GetNetworkGamesParams {
179
185
  league?: string;
186
+ exclude_wallet?: string;
180
187
  limit?: number;
181
188
  offset?: number;
182
189
  }
@@ -257,6 +264,34 @@ interface MutationResult<TParams, TResult> {
257
264
  data: TResult | null;
258
265
  reset: () => void;
259
266
  }
267
+ interface LiveScoreCompetitor {
268
+ name: string;
269
+ homeAway: 'home' | 'away';
270
+ score: number;
271
+ logo: string | null;
272
+ abbreviation: string;
273
+ }
274
+ interface LiveScore {
275
+ status: string;
276
+ period: number | null;
277
+ displayClock: string | null;
278
+ detail: string | null;
279
+ shortDetail: string | null;
280
+ competitors: LiveScoreCompetitor[];
281
+ ufcData?: {
282
+ currentRound: number;
283
+ totalRounds: number;
284
+ clock: string;
285
+ fightState: string;
286
+ statusDetail: string;
287
+ };
288
+ }
289
+ interface UiConfig {
290
+ accentColor?: string;
291
+ appIcon?: string;
292
+ appName?: string;
293
+ tagline?: string;
294
+ }
260
295
 
261
296
  interface DubsClientConfig {
262
297
  apiKey: string;
@@ -285,6 +320,7 @@ declare class DubsClient {
285
320
  confirmGame(params: ConfirmGameParams): Promise<ConfirmGameResult>;
286
321
  buildClaimTransaction(params: BuildClaimParams): Promise<BuildClaimResult>;
287
322
  getGame(gameId: string): Promise<GameDetail>;
323
+ getLiveScore(gameId: string): Promise<LiveScore | null>;
288
324
  getGames(params?: GetGamesParams): Promise<GameListItem[]>;
289
325
  getNetworkGames(params?: GetNetworkGamesParams): Promise<{
290
326
  games: GameListItem[];
@@ -317,6 +353,8 @@ declare class DubsClient {
317
353
  parseErrorLocal(error: unknown): ParsedError;
318
354
  /** Get the full local error code map */
319
355
  getErrorCodesLocal(): Record<number, SolanaErrorCode>;
356
+ /** Fetch the app's UI customization config (accent color, icon, tagline) */
357
+ getAppConfig(): Promise<UiConfig>;
320
358
  }
321
359
 
322
360
  declare class DubsApiError extends Error {
@@ -334,6 +372,28 @@ declare function parseSolanaError(err: unknown): ParsedError;
334
372
 
335
373
  declare const DEFAULT_BASE_URL = "https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1";
336
374
  declare const DEFAULT_RPC_URL = "https://api.mainnet-beta.solana.com";
375
+ type DubsNetwork = 'devnet' | 'mainnet-beta';
376
+ declare const NETWORK_CONFIG: Record<DubsNetwork, {
377
+ baseUrl: string;
378
+ rpcUrl: string;
379
+ cluster: string;
380
+ }>;
381
+
382
+ interface TokenStorage {
383
+ getItem(key: string): Promise<string | null>;
384
+ setItem(key: string, value: string): Promise<void>;
385
+ deleteItem(key: string): Promise<void>;
386
+ }
387
+ declare const STORAGE_KEYS: {
388
+ readonly MWA_AUTH_TOKEN: "dubs_mwa_auth_token";
389
+ readonly JWT_TOKEN: "dubs_jwt_token";
390
+ };
391
+ /**
392
+ * Creates a TokenStorage backed by expo-secure-store.
393
+ * Lazy-imports the module so it's only required at runtime when actually used.
394
+ * Throws a clear error if expo-secure-store is not installed.
395
+ */
396
+ declare function createSecureStoreStorage(): TokenStorage;
337
397
 
338
398
  /**
339
399
  * Minimal wallet adapter interface.
@@ -358,21 +418,82 @@ interface WalletAdapter {
358
418
  * Returns the signature as a Uint8Array.
359
419
  */
360
420
  signMessage?(message: Uint8Array): Promise<Uint8Array>;
421
+ /** Optional: Connect the wallet */
422
+ connect?(): Promise<void>;
423
+ /** Optional: Disconnect the wallet */
424
+ disconnect?(): void | Promise<void>;
361
425
  }
362
426
 
427
+ interface RegistrationScreenProps {
428
+ onRegister: (username: string, referralCode?: string, avatarUrl?: string) => void;
429
+ registering: boolean;
430
+ error: Error | null;
431
+ client: DubsClient;
432
+ }
433
+ interface AuthGateProps {
434
+ children: React$1.ReactNode;
435
+ onSaveToken: (token: string | null) => void | Promise<void>;
436
+ onLoadToken: () => string | null | Promise<string | null>;
437
+ renderLoading?: (status: AuthStatus) => React$1.ReactNode;
438
+ renderError?: (error: Error, retry: () => void) => React$1.ReactNode;
439
+ renderRegistration?: (props: RegistrationScreenProps) => React$1.ReactNode;
440
+ appName?: string;
441
+ /** Override accent color for registration screens (from developer UI config) */
442
+ accentColor?: string;
443
+ }
444
+ declare function AuthGate({ children, onSaveToken, onLoadToken, renderLoading, renderError, renderRegistration, appName, accentColor, }: AuthGateProps): react_jsx_runtime.JSX.Element;
445
+
446
+ interface ConnectWalletScreenProps {
447
+ /** Called when the user taps Connect Wallet */
448
+ onConnect: () => void | Promise<void>;
449
+ /** Show a loading spinner on the button while connecting */
450
+ connecting?: boolean;
451
+ /** Error message to display (e.g. "User rejected the request") */
452
+ error?: string | null;
453
+ /** App name shown in the header. Defaults to "Dubs" */
454
+ appName?: string;
455
+ /** Override accent color (e.g. from developer UI config) */
456
+ accentColor?: string;
457
+ /** URL to app icon — renders as Image instead of the default letter circle */
458
+ appIcon?: string;
459
+ /** Override subtitle text below app name */
460
+ tagline?: string;
461
+ }
462
+ declare function ConnectWalletScreen({ onConnect, connecting, error, appName, accentColor, appIcon, tagline, }: ConnectWalletScreenProps): react_jsx_runtime.JSX.Element;
463
+
363
464
  interface DubsContextValue {
364
465
  client: DubsClient;
365
466
  wallet: WalletAdapter;
366
467
  connection: Connection;
468
+ appName: string;
469
+ network: DubsNetwork;
470
+ disconnect: () => Promise<void>;
367
471
  }
368
472
  interface DubsProviderProps {
369
473
  apiKey: string;
474
+ children: React$1.ReactNode;
475
+ appName?: string;
476
+ network?: DubsNetwork;
477
+ /** Escape hatch: bring your own wallet adapter. Disables managed MWA. */
478
+ wallet?: WalletAdapter;
479
+ /** Escape hatch: custom token persistence. Defaults to expo-secure-store. */
480
+ tokenStorage?: TokenStorage;
481
+ /** Escape hatch: override base URL (takes precedence over network). */
370
482
  baseUrl?: string;
483
+ /** Escape hatch: override RPC URL (takes precedence over network). */
371
484
  rpcUrl?: string;
372
- wallet: WalletAdapter;
373
- children: React.ReactNode;
374
- }
375
- declare function DubsProvider({ apiKey, baseUrl, rpcUrl, wallet, children }: DubsProviderProps): react_jsx_runtime.JSX.Element;
485
+ /** Custom connect screen, or false to hide it entirely (headless mode). */
486
+ renderConnectScreen?: ((props: ConnectWalletScreenProps) => React$1.ReactNode) | false;
487
+ /** Custom loading screen shown during auth. */
488
+ renderLoading?: (status: AuthStatus) => React$1.ReactNode;
489
+ /** Custom error screen shown on auth failure. */
490
+ renderError?: (error: Error, retry: () => void) => React$1.ReactNode;
491
+ /** Custom registration screen. */
492
+ renderRegistration?: (props: RegistrationScreenProps) => React$1.ReactNode;
493
+ /** Set to false to skip AuthGate and connect screen (headless/BYOA mode). Default: true. */
494
+ managed?: boolean;
495
+ }
496
+ declare function DubsProvider({ apiKey, children, appName, network, wallet: externalWallet, tokenStorage, baseUrl: baseUrlOverride, rpcUrl: rpcUrlOverride, renderConnectScreen, renderLoading, renderError, renderRegistration, managed, }: DubsProviderProps): react_jsx_runtime.JSX.Element;
376
497
  declare function useDubs(): DubsContextValue;
377
498
 
378
499
  /** The `transact` function signature from @solana-mobile/mobile-wallet-adapter-protocol-web3js */
@@ -411,6 +532,8 @@ declare class MwaWalletAdapter implements WalletAdapter {
411
532
  constructor(config: MwaAdapterConfig);
412
533
  get publicKey(): PublicKey | null;
413
534
  get connected(): boolean;
535
+ get authToken(): string | null;
536
+ setAuthToken(token: string | null): void;
414
537
  /**
415
538
  * Connect to a mobile wallet. Call this before any signing.
416
539
  */
@@ -513,35 +636,6 @@ interface UseAuthResult {
513
636
  }
514
637
  declare function useAuth(): UseAuthResult;
515
638
 
516
- interface RegistrationScreenProps {
517
- onRegister: (username: string, referralCode?: string, avatarUrl?: string) => void;
518
- registering: boolean;
519
- error: Error | null;
520
- client: DubsClient;
521
- }
522
- interface AuthGateProps {
523
- children: React.ReactNode;
524
- onSaveToken: (token: string | null) => void | Promise<void>;
525
- onLoadToken: () => string | null | Promise<string | null>;
526
- renderLoading?: (status: AuthStatus) => React.ReactNode;
527
- renderError?: (error: Error, retry: () => void) => React.ReactNode;
528
- renderRegistration?: (props: RegistrationScreenProps) => React.ReactNode;
529
- appName?: string;
530
- }
531
- declare function AuthGate({ children, onSaveToken, onLoadToken, renderLoading, renderError, renderRegistration, appName, }: AuthGateProps): react_jsx_runtime.JSX.Element;
532
-
533
- interface ConnectWalletScreenProps {
534
- /** Called when the user taps Connect Wallet */
535
- onConnect: () => void | Promise<void>;
536
- /** Show a loading spinner on the button while connecting */
537
- connecting?: boolean;
538
- /** Error message to display (e.g. "User rejected the request") */
539
- error?: string | null;
540
- /** App name shown in the header. Defaults to "Dubs" */
541
- appName?: string;
542
- }
543
- declare function ConnectWalletScreen({ onConnect, connecting, error, appName, }: ConnectWalletScreenProps): react_jsx_runtime.JSX.Element;
544
-
545
639
  interface UserProfileCardProps {
546
640
  walletAddress: string;
547
641
  username?: string;
@@ -580,16 +674,83 @@ interface DubsTheme {
580
674
  errorBorder: string;
581
675
  }
582
676
  declare function useDubsTheme(): DubsTheme;
677
+ /** Merge overrides into a base theme (e.g. custom accent color from developer config) */
678
+ declare function mergeTheme(base: DubsTheme, overrides: Partial<DubsTheme>): DubsTheme;
583
679
 
680
+ interface GamePosterProps {
681
+ game: GameDetail;
682
+ /** Optional Image component — pass expo-image or RN Image. Defaults to RN Image. */
683
+ ImageComponent?: React.ComponentType<any>;
684
+ }
584
685
  /**
585
- * Deserialize a base64-encoded transaction, sign via wallet adapter, send to Solana.
586
- * Returns the transaction signature.
686
+ * Matchup poster hero widget.
687
+ * Shows the game poster image (or team logo fallback), countdown pill, and pool total.
688
+ */
689
+ declare function GamePoster({ game, ImageComponent }: GamePosterProps): react_jsx_runtime.JSX.Element;
690
+
691
+ interface LivePoolsCardProps {
692
+ game: GameDetail;
693
+ /** Custom short-name function for team labels. Defaults to full name. */
694
+ shortName?: (name: string | null) => string;
695
+ /** Override bar colors. Defaults to blue/red. */
696
+ homeColor?: string;
697
+ awayColor?: string;
698
+ }
699
+ /**
700
+ * Pool breakdown card showing each side's SOL amount, bar chart, and implied odds.
701
+ */
702
+ declare function LivePoolsCard({ game, shortName, homeColor, awayColor, }: LivePoolsCardProps): react_jsx_runtime.JSX.Element;
703
+
704
+ interface PickWinnerCardProps {
705
+ game: GameDetail;
706
+ selectedTeam: 'home' | 'away' | null;
707
+ onSelect: (team: 'home' | 'away') => void;
708
+ /** Custom short-name function for team labels. Defaults to full name. */
709
+ shortName?: (name: string | null) => string;
710
+ /** Override colors. Defaults to blue/red. */
711
+ homeColor?: string;
712
+ awayColor?: string;
713
+ /** Optional Image component (expo-image, etc.). */
714
+ ImageComponent?: React.ComponentType<any>;
715
+ }
716
+ /**
717
+ * Team selection card for picking which side to bet on.
718
+ */
719
+ declare function PickWinnerCard({ game, selectedTeam, onSelect, shortName, homeColor, awayColor, ImageComponent, }: PickWinnerCardProps): react_jsx_runtime.JSX.Element;
720
+
721
+ interface PlayersCardProps {
722
+ game: GameDetail;
723
+ /** How many chars to show on each side of a truncated wallet. Default 4. */
724
+ truncateChars?: number;
725
+ /** Override team dot colors. */
726
+ homeColor?: string;
727
+ awayColor?: string;
728
+ drawColor?: string;
729
+ /** Optional Image component (expo-image, etc.). */
730
+ ImageComponent?: React.ComponentType<any>;
731
+ }
732
+ /**
733
+ * Card showing all bettors in a game with their avatar, username, team, and wager amount.
587
734
  */
588
- declare function signAndSendBase64Transaction(base64Tx: string, wallet: WalletAdapter, connection: Connection): Promise<string>;
735
+ declare function PlayersCard({ game, truncateChars, homeColor, awayColor, drawColor, ImageComponent, }: PlayersCardProps): react_jsx_runtime.JSX.Element;
736
+
737
+ interface JoinGameButtonProps {
738
+ game: GameDetail;
739
+ walletAddress: string;
740
+ selectedTeam: 'home' | 'away' | null;
741
+ status: MutationStatus;
742
+ onJoin: () => void;
743
+ }
589
744
  /**
590
- * Poll for transaction confirmation using getSignatureStatuses.
591
- * Uses polling instead of deprecated WebSocket-based confirmTransaction.
745
+ * Fixed bottom bar with buy-in info and join button.
746
+ * Renders nothing if the user already joined, or the game is locked/resolved.
747
+ */
748
+ declare function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }: JoinGameButtonProps): react_jsx_runtime.JSX.Element | null;
749
+
750
+ /**
751
+ * Deserialize a base64-encoded transaction, sign via wallet adapter, send to Solana.
752
+ * Returns the transaction signature.
592
753
  */
593
- declare function pollTransactionConfirmation(signature: string, connection: Connection, commitment?: TransactionConfirmationStatus, timeout?: number, interval?: number): Promise<void>;
754
+ declare function signAndSendBase64Transaction(base64Tx: string, wallet: WalletAdapter): Promise<string>;
594
755
 
595
- export { AuthGate, type AuthGateProps, 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, type RegistrationScreenProps, 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 };
756
+ export { AuthGate, type AuthGateProps, type AuthStatus, type AuthenticateParams, type AuthenticateResult, type Bettor, 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, type DubsNetwork, 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, GamePoster, type GamePosterProps, type GetGamesParams, type GetNetworkGamesParams, type GetUpcomingEventsParams, JoinGameButton, type JoinGameButtonProps, type JoinGameMutationResult, type JoinGameParams, type JoinGameResult, LivePoolsCard, type LivePoolsCardProps, type LiveScore, type LiveScoreCompetitor, type MutationResult, type MutationStatus, type MwaAdapterConfig, type MwaTransactFn, MwaWalletAdapter, NETWORK_CONFIG, type NonceResult, type Opponent, type Pagination, type ParsedError, PickWinnerCard, type PickWinnerCardProps, PlayersCard, type PlayersCardProps, type QueryResult, type RegisterParams, type RegisterResult, type RegistrationScreenProps, SOLANA_PROGRAM_ERRORS, STORAGE_KEYS, SettingsSheet, type SettingsSheetProps, type SolanaErrorCode, type TokenStorage, type UiConfig, type UnifiedEvent, type UseAuthResult, UserProfileCard, type UserProfileCardProps, type ValidateEventResult, type WalletAdapter, createSecureStoreStorage, mergeTheme, parseSolanaError, signAndSendBase64Transaction, useAuth, useClaim, useCreateGame, useDubs, useDubsTheme, useEvents, useGame, useGames, useJoinGame, useNetworkGames };