@dubsdotapp/expo 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.
- package/README.md +9 -10
- package/dist/index.d.mts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +432 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +442 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/ui/AuthGate.tsx +520 -0
- package/src/ui/index.ts +2 -0
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @dubsdotapp/expo
|
|
2
2
|
|
|
3
3
|
React Native SDK for the [Dubs](https://dubs.fun) betting platform. Pure TypeScript — no native code.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npx expo install @
|
|
8
|
+
npx expo install @dubsdotapp/expo @solana/web3.js
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
For the built-in Mobile Wallet Adapter (optional):
|
|
@@ -19,7 +19,7 @@ npx expo install @solana-mobile/mobile-wallet-adapter-protocol-web3js
|
|
|
19
19
|
### 1. Set up the provider
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
import { DubsProvider, MwaWalletAdapter } from '@
|
|
22
|
+
import { DubsProvider, MwaWalletAdapter } from '@dubsdotapp/expo';
|
|
23
23
|
|
|
24
24
|
const wallet = new MwaWalletAdapter({
|
|
25
25
|
appIdentity: { name: 'My App' },
|
|
@@ -28,8 +28,7 @@ const wallet = new MwaWalletAdapter({
|
|
|
28
28
|
export default function App() {
|
|
29
29
|
return (
|
|
30
30
|
<DubsProvider
|
|
31
|
-
apiKey="
|
|
32
|
-
rpcUrl="https://api.mainnet-beta.solana.com"
|
|
31
|
+
apiKey="your_api_key_here"
|
|
33
32
|
wallet={wallet}
|
|
34
33
|
>
|
|
35
34
|
<HomeScreen />
|
|
@@ -41,7 +40,7 @@ export default function App() {
|
|
|
41
40
|
### 2. Browse events
|
|
42
41
|
|
|
43
42
|
```tsx
|
|
44
|
-
import { useEvents } from '@
|
|
43
|
+
import { useEvents } from '@dubsdotapp/expo';
|
|
45
44
|
|
|
46
45
|
function EventsList() {
|
|
47
46
|
const { data, loading, error, refetch } = useEvents({ type: 'sports' });
|
|
@@ -63,7 +62,7 @@ function EventsList() {
|
|
|
63
62
|
### 3. Create a bet
|
|
64
63
|
|
|
65
64
|
```tsx
|
|
66
|
-
import { useCreateGame } from '@
|
|
65
|
+
import { useCreateGame } from '@dubsdotapp/expo';
|
|
67
66
|
|
|
68
67
|
function CreateBet({ eventId }: { eventId: string }) {
|
|
69
68
|
const { execute, status, error } = useCreateGame();
|
|
@@ -94,8 +93,8 @@ function CreateBet({ eventId }: { eventId: string }) {
|
|
|
94
93
|
If you're using Privy, Dynamic, or another wallet provider, implement the `WalletAdapter` interface:
|
|
95
94
|
|
|
96
95
|
```tsx
|
|
97
|
-
import { DubsProvider } from '@
|
|
98
|
-
import type { WalletAdapter } from '@
|
|
96
|
+
import { DubsProvider } from '@dubsdotapp/expo';
|
|
97
|
+
import type { WalletAdapter } from '@dubsdotapp/expo';
|
|
99
98
|
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
100
99
|
|
|
101
100
|
const myAdapter: WalletAdapter = {
|
|
@@ -139,7 +138,7 @@ Mutation hooks expose granular status:
|
|
|
139
138
|
For use outside React or for custom integrations:
|
|
140
139
|
|
|
141
140
|
```ts
|
|
142
|
-
import { DubsClient } from '@
|
|
141
|
+
import { DubsClient } from '@dubsdotapp/expo';
|
|
143
142
|
|
|
144
143
|
const client = new DubsClient({ apiKey: 'dubs_live_...' });
|
|
145
144
|
|
package/dist/index.d.mts
CHANGED
|
@@ -512,6 +512,33 @@ interface UseAuthResult {
|
|
|
512
512
|
}
|
|
513
513
|
declare function useAuth(): UseAuthResult;
|
|
514
514
|
|
|
515
|
+
interface RegistrationScreenProps {
|
|
516
|
+
/** Called when the user submits registration */
|
|
517
|
+
onRegister: (username: string, referralCode?: string) => void;
|
|
518
|
+
/** Whether a registration request is in flight */
|
|
519
|
+
registering: boolean;
|
|
520
|
+
/** Error from the last registration attempt, or null */
|
|
521
|
+
error: Error | null;
|
|
522
|
+
/** DubsClient instance for checkUsername() availability checks */
|
|
523
|
+
client: DubsClient;
|
|
524
|
+
}
|
|
525
|
+
interface AuthGateProps {
|
|
526
|
+
children: React.ReactNode;
|
|
527
|
+
/** Persist or clear the JWT token (called with null on logout) */
|
|
528
|
+
onSaveToken: (token: string | null) => void | Promise<void>;
|
|
529
|
+
/** Load a previously persisted JWT token */
|
|
530
|
+
onLoadToken: () => string | null | Promise<string | null>;
|
|
531
|
+
/** Custom loading screen (receives current auth status) */
|
|
532
|
+
renderLoading?: (status: AuthStatus) => React.ReactNode;
|
|
533
|
+
/** Custom error screen (receives the error and a retry callback) */
|
|
534
|
+
renderError?: (error: Error, retry: () => void) => React.ReactNode;
|
|
535
|
+
/** Custom registration screen */
|
|
536
|
+
renderRegistration?: (props: RegistrationScreenProps) => React.ReactNode;
|
|
537
|
+
/** App name shown in default screens. Defaults to "Dubs" */
|
|
538
|
+
appName?: string;
|
|
539
|
+
}
|
|
540
|
+
declare function AuthGate({ children, onSaveToken, onLoadToken, renderLoading, renderError, renderRegistration, appName, }: AuthGateProps): react_jsx_runtime.JSX.Element;
|
|
541
|
+
|
|
515
542
|
interface ConnectWalletScreenProps {
|
|
516
543
|
/** Called when the user taps Connect Wallet */
|
|
517
544
|
onConnect: () => void | Promise<void>;
|
|
@@ -574,4 +601,4 @@ declare function signAndSendBase64Transaction(base64Tx: string, wallet: WalletAd
|
|
|
574
601
|
*/
|
|
575
602
|
declare function pollTransactionConfirmation(signature: string, connection: Connection, commitment?: TransactionConfirmationStatus, timeout?: number, interval?: number): Promise<void>;
|
|
576
603
|
|
|
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 };
|
|
604
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -512,6 +512,33 @@ interface UseAuthResult {
|
|
|
512
512
|
}
|
|
513
513
|
declare function useAuth(): UseAuthResult;
|
|
514
514
|
|
|
515
|
+
interface RegistrationScreenProps {
|
|
516
|
+
/** Called when the user submits registration */
|
|
517
|
+
onRegister: (username: string, referralCode?: string) => void;
|
|
518
|
+
/** Whether a registration request is in flight */
|
|
519
|
+
registering: boolean;
|
|
520
|
+
/** Error from the last registration attempt, or null */
|
|
521
|
+
error: Error | null;
|
|
522
|
+
/** DubsClient instance for checkUsername() availability checks */
|
|
523
|
+
client: DubsClient;
|
|
524
|
+
}
|
|
525
|
+
interface AuthGateProps {
|
|
526
|
+
children: React.ReactNode;
|
|
527
|
+
/** Persist or clear the JWT token (called with null on logout) */
|
|
528
|
+
onSaveToken: (token: string | null) => void | Promise<void>;
|
|
529
|
+
/** Load a previously persisted JWT token */
|
|
530
|
+
onLoadToken: () => string | null | Promise<string | null>;
|
|
531
|
+
/** Custom loading screen (receives current auth status) */
|
|
532
|
+
renderLoading?: (status: AuthStatus) => React.ReactNode;
|
|
533
|
+
/** Custom error screen (receives the error and a retry callback) */
|
|
534
|
+
renderError?: (error: Error, retry: () => void) => React.ReactNode;
|
|
535
|
+
/** Custom registration screen */
|
|
536
|
+
renderRegistration?: (props: RegistrationScreenProps) => React.ReactNode;
|
|
537
|
+
/** App name shown in default screens. Defaults to "Dubs" */
|
|
538
|
+
appName?: string;
|
|
539
|
+
}
|
|
540
|
+
declare function AuthGate({ children, onSaveToken, onLoadToken, renderLoading, renderError, renderRegistration, appName, }: AuthGateProps): react_jsx_runtime.JSX.Element;
|
|
541
|
+
|
|
515
542
|
interface ConnectWalletScreenProps {
|
|
516
543
|
/** Called when the user taps Connect Wallet */
|
|
517
544
|
onConnect: () => void | Promise<void>;
|
|
@@ -574,4 +601,4 @@ declare function signAndSendBase64Transaction(base64Tx: string, wallet: WalletAd
|
|
|
574
601
|
*/
|
|
575
602
|
declare function pollTransactionConfirmation(signature: string, connection: Connection, commitment?: TransactionConfirmationStatus, timeout?: number, interval?: number): Promise<void>;
|
|
576
603
|
|
|
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 };
|
|
604
|
+
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 };
|