@dubsdotapp/expo 0.5.14 → 0.5.16
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.js +299 -211
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +246 -160
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useHighlights.ts +38 -0
- package/src/hooks/useShorts.ts +36 -0
- package/src/index.ts +4 -0
- package/src/ui/game/JoinGameSheet.tsx +43 -11
- package/dist/index.d.mts +0 -1500
- package/dist/index.d.ts +0 -1500
package/dist/index.mjs
CHANGED
|
@@ -645,7 +645,7 @@ function createSecureStoreStorage() {
|
|
|
645
645
|
}
|
|
646
646
|
|
|
647
647
|
// src/provider.tsx
|
|
648
|
-
import { createContext as createContext4, useContext as useContext4, useMemo as useMemo3, useCallback as
|
|
648
|
+
import { createContext as createContext4, useContext as useContext4, useMemo as useMemo3, useCallback as useCallback22, useState as useState24, useEffect as useEffect16 } from "react";
|
|
649
649
|
|
|
650
650
|
// src/ui/theme.ts
|
|
651
651
|
import { createContext, useContext } from "react";
|
|
@@ -1710,7 +1710,7 @@ function ManagedWalletProvider({
|
|
|
1710
1710
|
}
|
|
1711
1711
|
|
|
1712
1712
|
// src/ui/AuthGate.tsx
|
|
1713
|
-
import React2, { useState as
|
|
1713
|
+
import React2, { useState as useState23, useEffect as useEffect15, useRef as useRef6, useCallback as useCallback21 } from "react";
|
|
1714
1714
|
import {
|
|
1715
1715
|
View as View3,
|
|
1716
1716
|
Text as Text3,
|
|
@@ -2413,25 +2413,79 @@ function useUFCFighterDetail(athleteId) {
|
|
|
2413
2413
|
return { data, loading, error, refetch: fetchData };
|
|
2414
2414
|
}
|
|
2415
2415
|
|
|
2416
|
+
// src/hooks/useHighlights.ts
|
|
2417
|
+
import { useState as useState14, useEffect as useEffect9, useCallback as useCallback13 } from "react";
|
|
2418
|
+
function useHighlights(league, limit = 8) {
|
|
2419
|
+
const { client } = useDubs();
|
|
2420
|
+
const [data, setData] = useState14(null);
|
|
2421
|
+
const [loading, setLoading] = useState14(true);
|
|
2422
|
+
const [error, setError] = useState14(null);
|
|
2423
|
+
const fetchData = useCallback13(async () => {
|
|
2424
|
+
setLoading(true);
|
|
2425
|
+
setError(null);
|
|
2426
|
+
try {
|
|
2427
|
+
const qs = new URLSearchParams();
|
|
2428
|
+
if (league) qs.set("league", league);
|
|
2429
|
+
qs.set("limit", String(limit));
|
|
2430
|
+
const res = await client.request("GET", `/highlights?${qs.toString()}`);
|
|
2431
|
+
setData(res.videos || []);
|
|
2432
|
+
} catch (err) {
|
|
2433
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
2434
|
+
} finally {
|
|
2435
|
+
setLoading(false);
|
|
2436
|
+
}
|
|
2437
|
+
}, [client, league, limit]);
|
|
2438
|
+
useEffect9(() => {
|
|
2439
|
+
fetchData();
|
|
2440
|
+
}, [fetchData]);
|
|
2441
|
+
return { data, loading, error, refetch: fetchData };
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
// src/hooks/useShorts.ts
|
|
2445
|
+
import { useState as useState15, useEffect as useEffect10, useCallback as useCallback14 } from "react";
|
|
2446
|
+
function useShorts(league = "NBA", limit = 20) {
|
|
2447
|
+
const { client } = useDubs();
|
|
2448
|
+
const [data, setData] = useState15(null);
|
|
2449
|
+
const [loading, setLoading] = useState15(true);
|
|
2450
|
+
const [error, setError] = useState15(null);
|
|
2451
|
+
const fetchData = useCallback14(async () => {
|
|
2452
|
+
setLoading(true);
|
|
2453
|
+
setError(null);
|
|
2454
|
+
try {
|
|
2455
|
+
const qs = new URLSearchParams({ league, limit: String(limit) });
|
|
2456
|
+
const res = await client.request("GET", `/shorts?${qs.toString()}`);
|
|
2457
|
+
setData(res.videos || []);
|
|
2458
|
+
} catch (err) {
|
|
2459
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
2460
|
+
} finally {
|
|
2461
|
+
setLoading(false);
|
|
2462
|
+
}
|
|
2463
|
+
}, [client, league, limit]);
|
|
2464
|
+
useEffect10(() => {
|
|
2465
|
+
fetchData();
|
|
2466
|
+
}, [fetchData]);
|
|
2467
|
+
return { data, loading, error, refetch: fetchData };
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2416
2470
|
// src/hooks/usePushNotifications.ts
|
|
2417
|
-
import { useState as
|
|
2471
|
+
import { useState as useState16, useCallback as useCallback15, useRef as useRef3, useMemo, useEffect as useEffect11 } from "react";
|
|
2418
2472
|
import { Platform as Platform3 } from "react-native";
|
|
2419
2473
|
function usePushNotifications() {
|
|
2420
2474
|
const { client, appName, pushEnabled } = useDubs();
|
|
2421
2475
|
const channelId = useMemo(() => appName.toLowerCase().replace(/[^a-z0-9-]/g, ""), [appName]);
|
|
2422
|
-
const [hasPermission, setHasPermission] =
|
|
2423
|
-
const [pushToken, setPushToken] =
|
|
2424
|
-
const [loading, setLoading] =
|
|
2425
|
-
const [error, setError] =
|
|
2476
|
+
const [hasPermission, setHasPermission] = useState16(false);
|
|
2477
|
+
const [pushToken, setPushToken] = useState16(null);
|
|
2478
|
+
const [loading, setLoading] = useState16(false);
|
|
2479
|
+
const [error, setError] = useState16(null);
|
|
2426
2480
|
const registering = useRef3(false);
|
|
2427
|
-
const getNotificationsModule =
|
|
2481
|
+
const getNotificationsModule = useCallback15(() => {
|
|
2428
2482
|
try {
|
|
2429
2483
|
return __require("expo-notifications");
|
|
2430
2484
|
} catch {
|
|
2431
2485
|
return null;
|
|
2432
2486
|
}
|
|
2433
2487
|
}, []);
|
|
2434
|
-
const getDeviceName =
|
|
2488
|
+
const getDeviceName = useCallback15(() => {
|
|
2435
2489
|
try {
|
|
2436
2490
|
const Device = __require("expo-device");
|
|
2437
2491
|
return Device.deviceName || null;
|
|
@@ -2439,7 +2493,7 @@ function usePushNotifications() {
|
|
|
2439
2493
|
return null;
|
|
2440
2494
|
}
|
|
2441
2495
|
}, []);
|
|
2442
|
-
const setupAndroidChannels =
|
|
2496
|
+
const setupAndroidChannels = useCallback15((Notifications) => {
|
|
2443
2497
|
if (Platform3.OS === "android") {
|
|
2444
2498
|
Notifications.setNotificationChannelAsync(channelId || "default", {
|
|
2445
2499
|
name: appName || "Default",
|
|
@@ -2449,7 +2503,7 @@ function usePushNotifications() {
|
|
|
2449
2503
|
});
|
|
2450
2504
|
}
|
|
2451
2505
|
}, [channelId, appName]);
|
|
2452
|
-
const registerTokenWithServer =
|
|
2506
|
+
const registerTokenWithServer = useCallback15(async (token) => {
|
|
2453
2507
|
const deviceName = getDeviceName();
|
|
2454
2508
|
await client.registerPushToken({
|
|
2455
2509
|
token,
|
|
@@ -2457,7 +2511,7 @@ function usePushNotifications() {
|
|
|
2457
2511
|
deviceName: deviceName || void 0
|
|
2458
2512
|
});
|
|
2459
2513
|
}, [client, getDeviceName]);
|
|
2460
|
-
const register =
|
|
2514
|
+
const register = useCallback15(async () => {
|
|
2461
2515
|
if (!pushEnabled) return false;
|
|
2462
2516
|
if (registering.current) return false;
|
|
2463
2517
|
registering.current = true;
|
|
@@ -2498,7 +2552,7 @@ function usePushNotifications() {
|
|
|
2498
2552
|
return false;
|
|
2499
2553
|
}
|
|
2500
2554
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2501
|
-
const unregister =
|
|
2555
|
+
const unregister = useCallback15(async () => {
|
|
2502
2556
|
if (!pushToken) return;
|
|
2503
2557
|
try {
|
|
2504
2558
|
await client.unregisterPushToken(pushToken);
|
|
@@ -2507,7 +2561,7 @@ function usePushNotifications() {
|
|
|
2507
2561
|
console.error("[usePushNotifications] Unregister error:", err);
|
|
2508
2562
|
}
|
|
2509
2563
|
}, [client, pushToken]);
|
|
2510
|
-
const restoreIfGranted =
|
|
2564
|
+
const restoreIfGranted = useCallback15(async () => {
|
|
2511
2565
|
if (!pushEnabled) return;
|
|
2512
2566
|
try {
|
|
2513
2567
|
const Notifications = getNotificationsModule();
|
|
@@ -2526,7 +2580,7 @@ function usePushNotifications() {
|
|
|
2526
2580
|
}
|
|
2527
2581
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2528
2582
|
const didMount = useRef3(false);
|
|
2529
|
-
|
|
2583
|
+
useEffect11(() => {
|
|
2530
2584
|
if (didMount.current) return;
|
|
2531
2585
|
didMount.current = true;
|
|
2532
2586
|
const Notifications = getNotificationsModule();
|
|
@@ -2556,13 +2610,13 @@ function usePushNotifications() {
|
|
|
2556
2610
|
}
|
|
2557
2611
|
|
|
2558
2612
|
// src/hooks/useArcadePools.ts
|
|
2559
|
-
import { useState as
|
|
2613
|
+
import { useState as useState17, useEffect as useEffect12, useCallback as useCallback16 } from "react";
|
|
2560
2614
|
function useArcadePools(gameSlug) {
|
|
2561
2615
|
const { client } = useDubs();
|
|
2562
|
-
const [pools, setPools] =
|
|
2563
|
-
const [loading, setLoading] =
|
|
2564
|
-
const [error, setError] =
|
|
2565
|
-
const fetch2 =
|
|
2616
|
+
const [pools, setPools] = useState17([]);
|
|
2617
|
+
const [loading, setLoading] = useState17(false);
|
|
2618
|
+
const [error, setError] = useState17(null);
|
|
2619
|
+
const fetch2 = useCallback16(async () => {
|
|
2566
2620
|
setLoading(true);
|
|
2567
2621
|
setError(null);
|
|
2568
2622
|
try {
|
|
@@ -2574,22 +2628,22 @@ function useArcadePools(gameSlug) {
|
|
|
2574
2628
|
setLoading(false);
|
|
2575
2629
|
}
|
|
2576
2630
|
}, [client, gameSlug]);
|
|
2577
|
-
|
|
2631
|
+
useEffect12(() => {
|
|
2578
2632
|
fetch2();
|
|
2579
2633
|
}, [fetch2]);
|
|
2580
2634
|
return { pools, loading, error, refetch: fetch2 };
|
|
2581
2635
|
}
|
|
2582
2636
|
|
|
2583
2637
|
// src/hooks/useArcadePool.ts
|
|
2584
|
-
import { useState as
|
|
2638
|
+
import { useState as useState18, useEffect as useEffect13, useCallback as useCallback17 } from "react";
|
|
2585
2639
|
function useArcadePool(poolId) {
|
|
2586
2640
|
const { client } = useDubs();
|
|
2587
|
-
const [pool, setPool] =
|
|
2588
|
-
const [stats, setStats] =
|
|
2589
|
-
const [leaderboard, setLeaderboard] =
|
|
2590
|
-
const [loading, setLoading] =
|
|
2591
|
-
const [error, setError] =
|
|
2592
|
-
const fetch2 =
|
|
2641
|
+
const [pool, setPool] = useState18(null);
|
|
2642
|
+
const [stats, setStats] = useState18(null);
|
|
2643
|
+
const [leaderboard, setLeaderboard] = useState18([]);
|
|
2644
|
+
const [loading, setLoading] = useState18(false);
|
|
2645
|
+
const [error, setError] = useState18(null);
|
|
2646
|
+
const fetch2 = useCallback17(async () => {
|
|
2593
2647
|
if (!poolId) return;
|
|
2594
2648
|
setLoading(true);
|
|
2595
2649
|
setError(null);
|
|
@@ -2607,22 +2661,22 @@ function useArcadePool(poolId) {
|
|
|
2607
2661
|
setLoading(false);
|
|
2608
2662
|
}
|
|
2609
2663
|
}, [client, poolId]);
|
|
2610
|
-
|
|
2664
|
+
useEffect13(() => {
|
|
2611
2665
|
fetch2();
|
|
2612
2666
|
}, [fetch2]);
|
|
2613
2667
|
return { pool, stats, leaderboard, loading, error, refetch: fetch2 };
|
|
2614
2668
|
}
|
|
2615
2669
|
|
|
2616
2670
|
// src/hooks/useArcadeGame.ts
|
|
2617
|
-
import { useState as
|
|
2671
|
+
import { useState as useState19, useCallback as useCallback18 } from "react";
|
|
2618
2672
|
function useArcadeGame(poolId, maxLives = 3) {
|
|
2619
2673
|
const { client } = useDubs();
|
|
2620
2674
|
const { user } = useAuth();
|
|
2621
|
-
const [entry, setEntry] =
|
|
2622
|
-
const [loading, setLoading] =
|
|
2623
|
-
const [error, setError] =
|
|
2675
|
+
const [entry, setEntry] = useState19(null);
|
|
2676
|
+
const [loading, setLoading] = useState19(false);
|
|
2677
|
+
const [error, setError] = useState19(null);
|
|
2624
2678
|
const walletAddress = user?.walletAddress || "";
|
|
2625
|
-
const refreshEntry =
|
|
2679
|
+
const refreshEntry = useCallback18(async () => {
|
|
2626
2680
|
if (!poolId || !walletAddress) return;
|
|
2627
2681
|
setLoading(true);
|
|
2628
2682
|
setError(null);
|
|
@@ -2639,7 +2693,7 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2639
2693
|
setLoading(false);
|
|
2640
2694
|
}
|
|
2641
2695
|
}, [client, poolId, walletAddress]);
|
|
2642
|
-
const startAttempt =
|
|
2696
|
+
const startAttempt = useCallback18(async () => {
|
|
2643
2697
|
if (!poolId || !walletAddress) throw new Error("Not ready");
|
|
2644
2698
|
setError(null);
|
|
2645
2699
|
try {
|
|
@@ -2651,7 +2705,7 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2651
2705
|
throw e;
|
|
2652
2706
|
}
|
|
2653
2707
|
}, [client, poolId, walletAddress]);
|
|
2654
|
-
const submitScore =
|
|
2708
|
+
const submitScore = useCallback18(async (sessionToken, score, durationMs) => {
|
|
2655
2709
|
if (!poolId || !walletAddress) throw new Error("Not ready");
|
|
2656
2710
|
setError(null);
|
|
2657
2711
|
try {
|
|
@@ -2688,19 +2742,19 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2688
2742
|
}
|
|
2689
2743
|
|
|
2690
2744
|
// src/hooks/useEnterArcadePool.ts
|
|
2691
|
-
import { useState as
|
|
2745
|
+
import { useState as useState20, useCallback as useCallback19 } from "react";
|
|
2692
2746
|
function useEnterArcadePool() {
|
|
2693
2747
|
const { client, wallet, connection } = useDubs();
|
|
2694
2748
|
const { user } = useAuth();
|
|
2695
|
-
const [status, setStatus] =
|
|
2696
|
-
const [error, setError] =
|
|
2697
|
-
const [data, setData] =
|
|
2698
|
-
const reset =
|
|
2749
|
+
const [status, setStatus] = useState20("idle");
|
|
2750
|
+
const [error, setError] = useState20(null);
|
|
2751
|
+
const [data, setData] = useState20(null);
|
|
2752
|
+
const reset = useCallback19(() => {
|
|
2699
2753
|
setStatus("idle");
|
|
2700
2754
|
setError(null);
|
|
2701
2755
|
setData(null);
|
|
2702
2756
|
}, []);
|
|
2703
|
-
const execute =
|
|
2757
|
+
const execute = useCallback19(async (poolId) => {
|
|
2704
2758
|
if (!wallet.publicKey) throw new Error("Wallet not connected");
|
|
2705
2759
|
const walletAddress = wallet.publicKey.toBase58();
|
|
2706
2760
|
setStatus("building");
|
|
@@ -2748,7 +2802,7 @@ function useEnterArcadePool() {
|
|
|
2748
2802
|
}
|
|
2749
2803
|
|
|
2750
2804
|
// src/hooks/useArcadeCountdown.ts
|
|
2751
|
-
import { useState as
|
|
2805
|
+
import { useState as useState21, useEffect as useEffect14, useRef as useRef4 } from "react";
|
|
2752
2806
|
function formatCountdown(ms) {
|
|
2753
2807
|
if (ms <= 0) return "Ended";
|
|
2754
2808
|
const s2 = Math.floor(ms / 1e3);
|
|
@@ -2761,9 +2815,9 @@ function formatCountdown(ms) {
|
|
|
2761
2815
|
return `${s2}s`;
|
|
2762
2816
|
}
|
|
2763
2817
|
function useArcadeCountdown(nextResolution) {
|
|
2764
|
-
const [now, setNow] =
|
|
2818
|
+
const [now, setNow] = useState21(Date.now());
|
|
2765
2819
|
const intervalRef = useRef4(null);
|
|
2766
|
-
|
|
2820
|
+
useEffect14(() => {
|
|
2767
2821
|
if (!nextResolution) return;
|
|
2768
2822
|
intervalRef.current = setInterval(() => setNow(Date.now()), 1e3);
|
|
2769
2823
|
return () => {
|
|
@@ -2792,7 +2846,7 @@ function useArcadeCountdown(nextResolution) {
|
|
|
2792
2846
|
}
|
|
2793
2847
|
|
|
2794
2848
|
// src/hooks/useArcadeBridge.ts
|
|
2795
|
-
import { useRef as useRef5, useState as
|
|
2849
|
+
import { useRef as useRef5, useState as useState22, useCallback as useCallback20 } from "react";
|
|
2796
2850
|
var PROTOCOL_VERSION = "1.0";
|
|
2797
2851
|
function useArcadeBridge({
|
|
2798
2852
|
canPlay,
|
|
@@ -2807,9 +2861,9 @@ function useArcadeBridge({
|
|
|
2807
2861
|
const gameStartTimeRef = useRef5(0);
|
|
2808
2862
|
const canPlayRef = useRef5(canPlay);
|
|
2809
2863
|
canPlayRef.current = canPlay;
|
|
2810
|
-
const [lastResult, setLastResult] =
|
|
2811
|
-
const [bridgeLoading, setBridgeLoading] =
|
|
2812
|
-
const injectSession =
|
|
2864
|
+
const [lastResult, setLastResult] = useState22(null);
|
|
2865
|
+
const [bridgeLoading, setBridgeLoading] = useState22(false);
|
|
2866
|
+
const injectSession = useCallback20((token, attemptNumber) => {
|
|
2813
2867
|
webviewRef.current?.injectJavaScript(`
|
|
2814
2868
|
window.ARCADE_SESSION_TOKEN = ${JSON.stringify(token)};
|
|
2815
2869
|
window.ARCADE_ATTEMPT_NUMBER = ${attemptNumber};
|
|
@@ -2818,7 +2872,7 @@ function useArcadeBridge({
|
|
|
2818
2872
|
true;
|
|
2819
2873
|
`);
|
|
2820
2874
|
}, []);
|
|
2821
|
-
const triggerPlay =
|
|
2875
|
+
const triggerPlay = useCallback20(async () => {
|
|
2822
2876
|
if (!canPlay) return;
|
|
2823
2877
|
setBridgeLoading(true);
|
|
2824
2878
|
try {
|
|
@@ -2835,7 +2889,7 @@ function useArcadeBridge({
|
|
|
2835
2889
|
setBridgeLoading(false);
|
|
2836
2890
|
}
|
|
2837
2891
|
}, [canPlay, startAttempt, injectSession, onPlayStarted, onError]);
|
|
2838
|
-
const handleMessage =
|
|
2892
|
+
const handleMessage = useCallback20(
|
|
2839
2893
|
async (event) => {
|
|
2840
2894
|
let data;
|
|
2841
2895
|
try {
|
|
@@ -3048,11 +3102,11 @@ function AuthGate({
|
|
|
3048
3102
|
}) {
|
|
3049
3103
|
const { client, pushEnabled } = useDubs();
|
|
3050
3104
|
const auth = useAuth();
|
|
3051
|
-
const [phase, setPhase] =
|
|
3052
|
-
const [registrationPhase, setRegistrationPhase] =
|
|
3053
|
-
const [showPushSetup, setShowPushSetup] =
|
|
3054
|
-
const [isRestoredSession, setIsRestoredSession] =
|
|
3055
|
-
|
|
3105
|
+
const [phase, setPhase] = useState23("init");
|
|
3106
|
+
const [registrationPhase, setRegistrationPhase] = useState23(false);
|
|
3107
|
+
const [showPushSetup, setShowPushSetup] = useState23(false);
|
|
3108
|
+
const [isRestoredSession, setIsRestoredSession] = useState23(false);
|
|
3109
|
+
useEffect15(() => {
|
|
3056
3110
|
let cancelled = false;
|
|
3057
3111
|
(async () => {
|
|
3058
3112
|
try {
|
|
@@ -3079,23 +3133,23 @@ function AuthGate({
|
|
|
3079
3133
|
cancelled = true;
|
|
3080
3134
|
};
|
|
3081
3135
|
}, []);
|
|
3082
|
-
|
|
3136
|
+
useEffect15(() => {
|
|
3083
3137
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
3084
3138
|
}, [auth.status]);
|
|
3085
|
-
|
|
3139
|
+
useEffect15(() => {
|
|
3086
3140
|
if (pushEnabled && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
3087
3141
|
setShowPushSetup(true);
|
|
3088
3142
|
}
|
|
3089
3143
|
}, [pushEnabled, auth.status, registrationPhase, isRestoredSession]);
|
|
3090
|
-
|
|
3144
|
+
useEffect15(() => {
|
|
3091
3145
|
if (auth.token) onSaveToken(auth.token);
|
|
3092
3146
|
}, [auth.token]);
|
|
3093
|
-
const retry =
|
|
3147
|
+
const retry = useCallback21(() => {
|
|
3094
3148
|
setRegistrationPhase(false);
|
|
3095
3149
|
auth.reset();
|
|
3096
3150
|
auth.authenticate();
|
|
3097
3151
|
}, [auth]);
|
|
3098
|
-
const handleRegister =
|
|
3152
|
+
const handleRegister = useCallback21(
|
|
3099
3153
|
(username, referralCode, avatarUrl) => {
|
|
3100
3154
|
auth.register(username, referralCode, avatarUrl);
|
|
3101
3155
|
},
|
|
@@ -3219,20 +3273,20 @@ function DefaultRegistrationScreen({
|
|
|
3219
3273
|
}) {
|
|
3220
3274
|
const t = useDubsTheme();
|
|
3221
3275
|
const accent = accentColor || t.accent;
|
|
3222
|
-
const [step, setStep] =
|
|
3223
|
-
const [avatarSeed, setAvatarSeed] =
|
|
3224
|
-
const [avatarStyle, setAvatarStyle] =
|
|
3225
|
-
const [avatarBg, setAvatarBg] =
|
|
3226
|
-
const [showStyles, setShowStyles] =
|
|
3227
|
-
const [username, setUsername] =
|
|
3228
|
-
const [referralCode, setReferralCode] =
|
|
3229
|
-
const [checking, setChecking] =
|
|
3230
|
-
const [availability, setAvailability] =
|
|
3276
|
+
const [step, setStep] = useState23(0);
|
|
3277
|
+
const [avatarSeed, setAvatarSeed] = useState23(generateSeed);
|
|
3278
|
+
const [avatarStyle, setAvatarStyle] = useState23("adventurer");
|
|
3279
|
+
const [avatarBg, setAvatarBg] = useState23("1a1a2e");
|
|
3280
|
+
const [showStyles, setShowStyles] = useState23(false);
|
|
3281
|
+
const [username, setUsername] = useState23("");
|
|
3282
|
+
const [referralCode, setReferralCode] = useState23("");
|
|
3283
|
+
const [checking, setChecking] = useState23(false);
|
|
3284
|
+
const [availability, setAvailability] = useState23(null);
|
|
3231
3285
|
const debounceRef = useRef6(null);
|
|
3232
3286
|
const fadeAnim = useRef6(new Animated.Value(1)).current;
|
|
3233
3287
|
const slideAnim = useRef6(new Animated.Value(0)).current;
|
|
3234
3288
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3235
|
-
|
|
3289
|
+
useEffect15(() => {
|
|
3236
3290
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3237
3291
|
const trimmed = username.trim();
|
|
3238
3292
|
if (trimmed.length < 3) {
|
|
@@ -3255,7 +3309,7 @@ function DefaultRegistrationScreen({
|
|
|
3255
3309
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3256
3310
|
};
|
|
3257
3311
|
}, [username, client]);
|
|
3258
|
-
const animateToStep =
|
|
3312
|
+
const animateToStep = useCallback21((newStep) => {
|
|
3259
3313
|
const dir = newStep > step ? 1 : -1;
|
|
3260
3314
|
Keyboard.dismiss();
|
|
3261
3315
|
Animated.parallel([
|
|
@@ -3495,7 +3549,7 @@ function DefaultRegistrationScreen({
|
|
|
3495
3549
|
function PushTokenRestorer() {
|
|
3496
3550
|
const push = usePushNotifications();
|
|
3497
3551
|
const restored = useRef6(false);
|
|
3498
|
-
|
|
3552
|
+
useEffect15(() => {
|
|
3499
3553
|
if (restored.current) return;
|
|
3500
3554
|
restored.current = true;
|
|
3501
3555
|
push.restoreIfGranted();
|
|
@@ -3512,7 +3566,7 @@ function PushSetupScreen({
|
|
|
3512
3566
|
const push = usePushNotifications();
|
|
3513
3567
|
const fadeAnim = useRef6(new Animated.Value(0)).current;
|
|
3514
3568
|
const slideAnim = useRef6(new Animated.Value(30)).current;
|
|
3515
|
-
|
|
3569
|
+
useEffect15(() => {
|
|
3516
3570
|
Animated.parallel([
|
|
3517
3571
|
Animated.timing(fadeAnim, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
3518
3572
|
Animated.timing(slideAnim, { toValue: 0, duration: 300, useNativeDriver: true })
|
|
@@ -3672,9 +3726,9 @@ function DubsProvider({
|
|
|
3672
3726
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
3673
3727
|
const client = useMemo3(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
3674
3728
|
const storage = useMemo3(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
3675
|
-
const [uiConfig, setUiConfig] =
|
|
3676
|
-
const [resolvedNetwork, setResolvedNetwork] =
|
|
3677
|
-
|
|
3729
|
+
const [uiConfig, setUiConfig] = useState24(null);
|
|
3730
|
+
const [resolvedNetwork, setResolvedNetwork] = useState24(network);
|
|
3731
|
+
useEffect16(() => {
|
|
3678
3732
|
client.getAppConfig().then((cfg) => {
|
|
3679
3733
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
3680
3734
|
setUiConfig(cfg);
|
|
@@ -3766,7 +3820,7 @@ function ManagedInner({
|
|
|
3766
3820
|
children
|
|
3767
3821
|
}) {
|
|
3768
3822
|
const managedDisconnect = useDisconnect();
|
|
3769
|
-
const disconnect =
|
|
3823
|
+
const disconnect = useCallback22(async () => {
|
|
3770
3824
|
client.setToken(null);
|
|
3771
3825
|
await managedDisconnect?.();
|
|
3772
3826
|
}, [client, managedDisconnect]);
|
|
@@ -3807,7 +3861,7 @@ function ExternalWalletProvider({
|
|
|
3807
3861
|
pushEnabled,
|
|
3808
3862
|
children
|
|
3809
3863
|
}) {
|
|
3810
|
-
const disconnect =
|
|
3864
|
+
const disconnect = useCallback22(async () => {
|
|
3811
3865
|
client.setToken(null);
|
|
3812
3866
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
3813
3867
|
});
|
|
@@ -4128,7 +4182,7 @@ var styles5 = StyleSheet6.create({
|
|
|
4128
4182
|
});
|
|
4129
4183
|
|
|
4130
4184
|
// src/ui/UserProfileSheet.tsx
|
|
4131
|
-
import { useState as
|
|
4185
|
+
import { useState as useState25, useEffect as useEffect17, useRef as useRef7, useCallback as useCallback23, useMemo as useMemo5 } from "react";
|
|
4132
4186
|
import {
|
|
4133
4187
|
View as View7,
|
|
4134
4188
|
Text as Text7,
|
|
@@ -4161,29 +4215,29 @@ function UserProfileSheet({
|
|
|
4161
4215
|
const push = usePushNotifications();
|
|
4162
4216
|
const overlayOpacity = useRef7(new Animated2.Value(0)).current;
|
|
4163
4217
|
const parsed = useMemo5(() => parseAvatarUrl(user.avatar), [user.avatar]);
|
|
4164
|
-
const [avatarStyle, setAvatarStyle] =
|
|
4165
|
-
const [avatarSeed, setAvatarSeed] =
|
|
4166
|
-
const [bgColor, setBgColor] =
|
|
4167
|
-
const [saving, setSaving] =
|
|
4168
|
-
const [error, setError] =
|
|
4169
|
-
|
|
4218
|
+
const [avatarStyle, setAvatarStyle] = useState25(parsed.style);
|
|
4219
|
+
const [avatarSeed, setAvatarSeed] = useState25(parsed.seed);
|
|
4220
|
+
const [bgColor, setBgColor] = useState25(parsed.bg);
|
|
4221
|
+
const [saving, setSaving] = useState25(false);
|
|
4222
|
+
const [error, setError] = useState25(null);
|
|
4223
|
+
useEffect17(() => {
|
|
4170
4224
|
const p = parseAvatarUrl(user.avatar);
|
|
4171
4225
|
setAvatarStyle(p.style);
|
|
4172
4226
|
setAvatarSeed(p.seed);
|
|
4173
4227
|
setBgColor(p.bg);
|
|
4174
4228
|
}, [user.avatar]);
|
|
4175
|
-
|
|
4229
|
+
useEffect17(() => {
|
|
4176
4230
|
Animated2.timing(overlayOpacity, {
|
|
4177
4231
|
toValue: visible ? 1 : 0,
|
|
4178
4232
|
duration: 250,
|
|
4179
4233
|
useNativeDriver: true
|
|
4180
4234
|
}).start();
|
|
4181
4235
|
}, [visible, overlayOpacity]);
|
|
4182
|
-
|
|
4236
|
+
useEffect17(() => {
|
|
4183
4237
|
if (visible) setError(null);
|
|
4184
4238
|
}, [visible]);
|
|
4185
4239
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4186
|
-
const saveAvatar =
|
|
4240
|
+
const saveAvatar = useCallback23(async (newUrl) => {
|
|
4187
4241
|
setSaving(true);
|
|
4188
4242
|
setError(null);
|
|
4189
4243
|
try {
|
|
@@ -4196,16 +4250,16 @@ function UserProfileSheet({
|
|
|
4196
4250
|
setSaving(false);
|
|
4197
4251
|
}
|
|
4198
4252
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4199
|
-
const handleStyleChange =
|
|
4253
|
+
const handleStyleChange = useCallback23((style) => {
|
|
4200
4254
|
setAvatarStyle(style);
|
|
4201
4255
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4202
4256
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4203
|
-
const handleShuffle =
|
|
4257
|
+
const handleShuffle = useCallback23(() => {
|
|
4204
4258
|
const newSeed = generateSeed();
|
|
4205
4259
|
setAvatarSeed(newSeed);
|
|
4206
4260
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4207
4261
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4208
|
-
const handleBgChange =
|
|
4262
|
+
const handleBgChange = useCallback23((color) => {
|
|
4209
4263
|
setBgColor(color);
|
|
4210
4264
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4211
4265
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4485,7 +4539,7 @@ var styles6 = StyleSheet7.create({
|
|
|
4485
4539
|
});
|
|
4486
4540
|
|
|
4487
4541
|
// src/ui/game/GamePoster.tsx
|
|
4488
|
-
import { useState as
|
|
4542
|
+
import { useState as useState26 } from "react";
|
|
4489
4543
|
import { StyleSheet as StyleSheet8, View as View8, Text as Text8 } from "react-native";
|
|
4490
4544
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4491
4545
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4535,7 +4589,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4535
4589
|
] });
|
|
4536
4590
|
}
|
|
4537
4591
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4538
|
-
const [failed, setFailed] =
|
|
4592
|
+
const [failed, setFailed] = useState26(false);
|
|
4539
4593
|
if (!url || failed) {
|
|
4540
4594
|
return /* @__PURE__ */ jsx10(View8, { style: [styles7.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4541
4595
|
}
|
|
@@ -4715,7 +4769,7 @@ var styles8 = StyleSheet9.create({
|
|
|
4715
4769
|
});
|
|
4716
4770
|
|
|
4717
4771
|
// src/ui/game/PickWinnerCard.tsx
|
|
4718
|
-
import { useState as
|
|
4772
|
+
import { useState as useState27, useMemo as useMemo7 } from "react";
|
|
4719
4773
|
import { StyleSheet as StyleSheet10, View as View10, Text as Text10, TouchableOpacity as TouchableOpacity7 } from "react-native";
|
|
4720
4774
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4721
4775
|
function PickWinnerCard({
|
|
@@ -4786,7 +4840,7 @@ function TeamOption({
|
|
|
4786
4840
|
ImageComponent,
|
|
4787
4841
|
t
|
|
4788
4842
|
}) {
|
|
4789
|
-
const [imgFailed, setImgFailed] =
|
|
4843
|
+
const [imgFailed, setImgFailed] = useState27(false);
|
|
4790
4844
|
const Img = ImageComponent || __require("react-native").Image;
|
|
4791
4845
|
const showImage = imageUrl && !imgFailed;
|
|
4792
4846
|
return /* @__PURE__ */ jsxs9(
|
|
@@ -4827,7 +4881,7 @@ var styles9 = StyleSheet10.create({
|
|
|
4827
4881
|
});
|
|
4828
4882
|
|
|
4829
4883
|
// src/ui/game/PlayersCard.tsx
|
|
4830
|
-
import { useState as
|
|
4884
|
+
import { useState as useState28 } from "react";
|
|
4831
4885
|
import { StyleSheet as StyleSheet11, View as View11, Text as Text11 } from "react-native";
|
|
4832
4886
|
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
4833
4887
|
function truncateWallet(addr, chars) {
|
|
@@ -4876,7 +4930,7 @@ function BettorRow({
|
|
|
4876
4930
|
ImageComponent,
|
|
4877
4931
|
t
|
|
4878
4932
|
}) {
|
|
4879
|
-
const [imgFailed, setImgFailed] =
|
|
4933
|
+
const [imgFailed, setImgFailed] = useState28(false);
|
|
4880
4934
|
const Img = ImageComponent || __require("react-native").Image;
|
|
4881
4935
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
4882
4936
|
return /* @__PURE__ */ jsxs10(View11, { style: [styles10.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -4955,7 +5009,7 @@ var styles11 = StyleSheet12.create({
|
|
|
4955
5009
|
});
|
|
4956
5010
|
|
|
4957
5011
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
4958
|
-
import { useState as
|
|
5012
|
+
import { useState as useState29, useEffect as useEffect18, useRef as useRef8, useCallback as useCallback24 } from "react";
|
|
4959
5013
|
import {
|
|
4960
5014
|
View as View13,
|
|
4961
5015
|
Text as Text13,
|
|
@@ -4992,18 +5046,18 @@ function CreateCustomGameSheet({
|
|
|
4992
5046
|
const t = useDubsTheme();
|
|
4993
5047
|
const { wallet } = useDubs();
|
|
4994
5048
|
const mutation = useCreateCustomGame();
|
|
4995
|
-
const [selectedAmount, setSelectedAmount] =
|
|
4996
|
-
const [customAmount, setCustomAmount] =
|
|
4997
|
-
const [isCustom, setIsCustom] =
|
|
5049
|
+
const [selectedAmount, setSelectedAmount] = useState29(null);
|
|
5050
|
+
const [customAmount, setCustomAmount] = useState29("");
|
|
5051
|
+
const [isCustom, setIsCustom] = useState29(false);
|
|
4998
5052
|
const overlayOpacity = useRef8(new Animated3.Value(0)).current;
|
|
4999
|
-
|
|
5053
|
+
useEffect18(() => {
|
|
5000
5054
|
Animated3.timing(overlayOpacity, {
|
|
5001
5055
|
toValue: visible ? 1 : 0,
|
|
5002
5056
|
duration: 250,
|
|
5003
5057
|
useNativeDriver: true
|
|
5004
5058
|
}).start();
|
|
5005
5059
|
}, [visible, overlayOpacity]);
|
|
5006
|
-
|
|
5060
|
+
useEffect18(() => {
|
|
5007
5061
|
if (visible) {
|
|
5008
5062
|
setSelectedAmount(defaultAmount ?? null);
|
|
5009
5063
|
setCustomAmount("");
|
|
@@ -5011,7 +5065,7 @@ function CreateCustomGameSheet({
|
|
|
5011
5065
|
mutation.reset();
|
|
5012
5066
|
}
|
|
5013
5067
|
}, [visible]);
|
|
5014
|
-
|
|
5068
|
+
useEffect18(() => {
|
|
5015
5069
|
if (mutation.status === "success" && mutation.data) {
|
|
5016
5070
|
onSuccess?.(mutation.data);
|
|
5017
5071
|
const timer = setTimeout(() => {
|
|
@@ -5020,23 +5074,23 @@ function CreateCustomGameSheet({
|
|
|
5020
5074
|
return () => clearTimeout(timer);
|
|
5021
5075
|
}
|
|
5022
5076
|
}, [mutation.status, mutation.data]);
|
|
5023
|
-
|
|
5077
|
+
useEffect18(() => {
|
|
5024
5078
|
if (mutation.status === "error" && mutation.error) {
|
|
5025
5079
|
onError?.(mutation.error);
|
|
5026
5080
|
}
|
|
5027
5081
|
}, [mutation.status, mutation.error]);
|
|
5028
|
-
const handlePresetSelect =
|
|
5082
|
+
const handlePresetSelect = useCallback24((amount) => {
|
|
5029
5083
|
setSelectedAmount(amount);
|
|
5030
5084
|
setIsCustom(false);
|
|
5031
5085
|
setCustomAmount("");
|
|
5032
5086
|
onAmountChange?.(amount);
|
|
5033
5087
|
}, [onAmountChange]);
|
|
5034
|
-
const handleCustomSelect =
|
|
5088
|
+
const handleCustomSelect = useCallback24(() => {
|
|
5035
5089
|
setIsCustom(true);
|
|
5036
5090
|
setSelectedAmount(null);
|
|
5037
5091
|
onAmountChange?.(null);
|
|
5038
5092
|
}, [onAmountChange]);
|
|
5039
|
-
const handleCustomAmountChange =
|
|
5093
|
+
const handleCustomAmountChange = useCallback24((text) => {
|
|
5040
5094
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
5041
5095
|
setCustomAmount(cleaned);
|
|
5042
5096
|
const parsed = parseFloat(cleaned);
|
|
@@ -5051,7 +5105,7 @@ function CreateCustomGameSheet({
|
|
|
5051
5105
|
const winnerTakes = pot * (1 - fee / 100);
|
|
5052
5106
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5053
5107
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
5054
|
-
const handleCreate =
|
|
5108
|
+
const handleCreate = useCallback24(async () => {
|
|
5055
5109
|
if (!finalAmount || !wallet.publicKey) return;
|
|
5056
5110
|
try {
|
|
5057
5111
|
await mutation.execute({
|
|
@@ -5320,7 +5374,7 @@ var styles12 = StyleSheet13.create({
|
|
|
5320
5374
|
});
|
|
5321
5375
|
|
|
5322
5376
|
// src/ui/game/JoinGameSheet.tsx
|
|
5323
|
-
import { useState as
|
|
5377
|
+
import { useState as useState31, useEffect as useEffect19, useRef as useRef10, useCallback as useCallback26, useMemo as useMemo9 } from "react";
|
|
5324
5378
|
import {
|
|
5325
5379
|
View as View16,
|
|
5326
5380
|
Text as Text16,
|
|
@@ -5530,7 +5584,7 @@ var styles13 = StyleSheet14.create({
|
|
|
5530
5584
|
});
|
|
5531
5585
|
|
|
5532
5586
|
// src/ui/game/TeamButton.tsx
|
|
5533
|
-
import { useState as
|
|
5587
|
+
import { useState as useState30 } from "react";
|
|
5534
5588
|
import { View as View15, Text as Text15, TouchableOpacity as TouchableOpacity10, StyleSheet as StyleSheet15 } from "react-native";
|
|
5535
5589
|
import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5536
5590
|
function TeamButton({
|
|
@@ -5544,7 +5598,7 @@ function TeamButton({
|
|
|
5544
5598
|
ImageComponent,
|
|
5545
5599
|
t
|
|
5546
5600
|
}) {
|
|
5547
|
-
const [imgFailed, setImgFailed] =
|
|
5601
|
+
const [imgFailed, setImgFailed] = useState30(false);
|
|
5548
5602
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5549
5603
|
const showImage = imageUrl && !imgFailed;
|
|
5550
5604
|
return /* @__PURE__ */ jsxs14(
|
|
@@ -5635,6 +5689,7 @@ function JoinGameSheet({
|
|
|
5635
5689
|
shortName,
|
|
5636
5690
|
homeColor = "#3B82F6",
|
|
5637
5691
|
awayColor = "#EF4444",
|
|
5692
|
+
drawColor = "#F59E0B",
|
|
5638
5693
|
onSuccess,
|
|
5639
5694
|
onError,
|
|
5640
5695
|
onTeamSelect,
|
|
@@ -5647,20 +5702,20 @@ function JoinGameSheet({
|
|
|
5647
5702
|
const { wallet } = useDubs();
|
|
5648
5703
|
const mutation = useJoinGame();
|
|
5649
5704
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
5650
|
-
const [selectedTeam, setSelectedTeam] =
|
|
5651
|
-
const [wager, setWager] =
|
|
5652
|
-
const [showSuccess, setShowSuccess] =
|
|
5705
|
+
const [selectedTeam, setSelectedTeam] = useState31(null);
|
|
5706
|
+
const [wager, setWager] = useState31(game.buyIn);
|
|
5707
|
+
const [showSuccess, setShowSuccess] = useState31(false);
|
|
5653
5708
|
const overlayOpacity = useRef10(new Animated4.Value(0)).current;
|
|
5654
5709
|
const successScale = useRef10(new Animated4.Value(0)).current;
|
|
5655
5710
|
const successOpacity = useRef10(new Animated4.Value(0)).current;
|
|
5656
|
-
|
|
5711
|
+
useEffect19(() => {
|
|
5657
5712
|
Animated4.timing(overlayOpacity, {
|
|
5658
5713
|
toValue: visible ? 1 : 0,
|
|
5659
5714
|
duration: 250,
|
|
5660
5715
|
useNativeDriver: true
|
|
5661
5716
|
}).start();
|
|
5662
5717
|
}, [visible, overlayOpacity]);
|
|
5663
|
-
|
|
5718
|
+
useEffect19(() => {
|
|
5664
5719
|
if (visible) {
|
|
5665
5720
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
5666
5721
|
setWager(game.buyIn);
|
|
@@ -5670,7 +5725,7 @@ function JoinGameSheet({
|
|
|
5670
5725
|
mutation.reset();
|
|
5671
5726
|
}
|
|
5672
5727
|
}, [visible]);
|
|
5673
|
-
|
|
5728
|
+
useEffect19(() => {
|
|
5674
5729
|
if (mutation.status === "success" && mutation.data) {
|
|
5675
5730
|
setShowSuccess(true);
|
|
5676
5731
|
onSuccess?.(mutation.data);
|
|
@@ -5687,7 +5742,7 @@ function JoinGameSheet({
|
|
|
5687
5742
|
return () => clearTimeout(timer);
|
|
5688
5743
|
}
|
|
5689
5744
|
}, [mutation.status, mutation.data]);
|
|
5690
|
-
|
|
5745
|
+
useEffect19(() => {
|
|
5691
5746
|
if (mutation.status === "error" && mutation.error) {
|
|
5692
5747
|
onError?.(mutation.error);
|
|
5693
5748
|
}
|
|
@@ -5697,18 +5752,29 @@ function JoinGameSheet({
|
|
|
5697
5752
|
const totalPool = game.totalPool || 0;
|
|
5698
5753
|
const homePool = game.homePool || 0;
|
|
5699
5754
|
const awayPool = game.awayPool || 0;
|
|
5755
|
+
const drawPool = game.drawPool || 0;
|
|
5700
5756
|
const buyIn = game.buyIn;
|
|
5757
|
+
const drawBettors = bettors.filter((b) => b.team === "draw");
|
|
5758
|
+
const hasDrawOption = drawPool > 0 || drawBettors.length > 0 || game.league && ["English Premier League", "EPL", "MLS", "La Liga", "Serie A", "Bundesliga", "Ligue 1"].some((l) => (game.league || "").includes(l));
|
|
5701
5759
|
const poolAfterJoin = totalPool + wager;
|
|
5702
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = useMemo9(() => {
|
|
5760
|
+
const { homeOdds, awayOdds, drawOdds, homeBets, awayBets, drawBets } = useMemo9(() => {
|
|
5761
|
+
const homeBetsCount = bettors.filter((b) => b.team === "home").length;
|
|
5762
|
+
const awayBetsCount = bettors.filter((b) => b.team === "away").length;
|
|
5763
|
+
const drawBetsCount = bettors.filter((b) => b.team === "draw").length;
|
|
5703
5764
|
const newPool = totalPool + wager;
|
|
5765
|
+
const newHome = homePool + (selectedTeam === "home" ? wager : 0);
|
|
5766
|
+
const newAway = awayPool + (selectedTeam === "away" ? wager : 0);
|
|
5767
|
+
const newDraw = drawPool + (selectedTeam === "draw" ? wager : 0);
|
|
5704
5768
|
return {
|
|
5705
|
-
homeOdds:
|
|
5706
|
-
awayOdds:
|
|
5707
|
-
|
|
5708
|
-
|
|
5769
|
+
homeOdds: newHome > 0 ? (newPool / newHome).toFixed(2) : "\u2014",
|
|
5770
|
+
awayOdds: newAway > 0 ? (newPool / newAway).toFixed(2) : "\u2014",
|
|
5771
|
+
drawOdds: newDraw > 0 ? (newPool / newDraw).toFixed(2) : "\u2014",
|
|
5772
|
+
homeBets: homeBetsCount,
|
|
5773
|
+
awayBets: awayBetsCount,
|
|
5774
|
+
drawBets: drawBetsCount
|
|
5709
5775
|
};
|
|
5710
|
-
}, [totalPool, homePool, awayPool, bettors, wager, selectedTeam]);
|
|
5711
|
-
const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : "\u2014";
|
|
5776
|
+
}, [totalPool, homePool, awayPool, drawPool, bettors, wager, selectedTeam]);
|
|
5777
|
+
const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : selectedTeam === "draw" ? drawOdds : "\u2014";
|
|
5712
5778
|
const potentialWinnings = selectedOdds !== "\u2014" ? formatSol(parseFloat(selectedOdds) * wager) : "\u2014";
|
|
5713
5779
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
5714
5780
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
@@ -5720,7 +5786,7 @@ function JoinGameSheet({
|
|
|
5720
5786
|
const alreadyJoined = myBet !== null;
|
|
5721
5787
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5722
5788
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
5723
|
-
const handleJoin =
|
|
5789
|
+
const handleJoin = useCallback26(async () => {
|
|
5724
5790
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
5725
5791
|
try {
|
|
5726
5792
|
await mutation.execute({
|
|
@@ -5817,11 +5883,26 @@ function JoinGameSheet({
|
|
|
5817
5883
|
t
|
|
5818
5884
|
}
|
|
5819
5885
|
)
|
|
5820
|
-
] })
|
|
5886
|
+
] }),
|
|
5887
|
+
hasDrawOption && /* @__PURE__ */ jsx18(View16, { style: styles15.drawRow, children: /* @__PURE__ */ jsx18(
|
|
5888
|
+
TeamButton,
|
|
5889
|
+
{
|
|
5890
|
+
name: "Draw",
|
|
5891
|
+
odds: drawOdds,
|
|
5892
|
+
bets: drawBets,
|
|
5893
|
+
color: drawColor,
|
|
5894
|
+
selected: selectedTeam === "draw",
|
|
5895
|
+
onPress: () => {
|
|
5896
|
+
setSelectedTeam("draw");
|
|
5897
|
+
onTeamSelect?.("draw");
|
|
5898
|
+
},
|
|
5899
|
+
t
|
|
5900
|
+
}
|
|
5901
|
+
) })
|
|
5821
5902
|
] }),
|
|
5822
|
-
alreadyJoined && myBet && /* @__PURE__ */ jsxs15(View16, { style: [styles15.myBetCard, { backgroundColor: (myBet.team === "home" ? homeColor : awayColor) + "15", borderColor: myBet.team === "home" ? homeColor : awayColor }], children: [
|
|
5823
|
-
/* @__PURE__ */ jsx18(Text16, { style: [styles15.myBetLabel, { color: myBet.team === "home" ? homeColor : awayColor }], children: "YOUR BET" }),
|
|
5824
|
-
/* @__PURE__ */ jsx18(Text16, { style: [styles15.myBetTeam, { color: t.text }], children: myBet.team === "home" ? homeName : awayName }),
|
|
5903
|
+
alreadyJoined && myBet && /* @__PURE__ */ jsxs15(View16, { style: [styles15.myBetCard, { backgroundColor: (myBet.team === "home" ? homeColor : myBet.team === "away" ? awayColor : drawColor) + "15", borderColor: myBet.team === "home" ? homeColor : myBet.team === "away" ? awayColor : drawColor }], children: [
|
|
5904
|
+
/* @__PURE__ */ jsx18(Text16, { style: [styles15.myBetLabel, { color: myBet.team === "home" ? homeColor : myBet.team === "away" ? awayColor : drawColor }], children: "YOUR BET" }),
|
|
5905
|
+
/* @__PURE__ */ jsx18(Text16, { style: [styles15.myBetTeam, { color: t.text }], children: myBet.team === "home" ? homeName : myBet.team === "away" ? awayName : "Draw" }),
|
|
5825
5906
|
/* @__PURE__ */ jsxs15(Text16, { style: [styles15.myBetAmount, { color: t.textMuted }], children: [
|
|
5826
5907
|
formatSol(myBet.amount),
|
|
5827
5908
|
" SOL"
|
|
@@ -6020,6 +6101,9 @@ var styles15 = StyleSheet16.create({
|
|
|
6020
6101
|
flexDirection: "row",
|
|
6021
6102
|
gap: 12
|
|
6022
6103
|
},
|
|
6104
|
+
drawRow: {
|
|
6105
|
+
marginTop: 8
|
|
6106
|
+
},
|
|
6023
6107
|
summaryCard: {
|
|
6024
6108
|
marginTop: 20,
|
|
6025
6109
|
borderRadius: 16,
|
|
@@ -6095,7 +6179,7 @@ var styles15 = StyleSheet16.create({
|
|
|
6095
6179
|
});
|
|
6096
6180
|
|
|
6097
6181
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
6098
|
-
import { useState as
|
|
6182
|
+
import { useState as useState32, useEffect as useEffect20, useRef as useRef11, useCallback as useCallback27 } from "react";
|
|
6099
6183
|
import {
|
|
6100
6184
|
View as View17,
|
|
6101
6185
|
Text as Text17,
|
|
@@ -6129,15 +6213,15 @@ function ClaimPrizeSheet({
|
|
|
6129
6213
|
const overlayOpacity = useRef11(new Animated5.Value(0)).current;
|
|
6130
6214
|
const celebrationScale = useRef11(new Animated5.Value(0)).current;
|
|
6131
6215
|
const celebrationOpacity = useRef11(new Animated5.Value(0)).current;
|
|
6132
|
-
const [showCelebration, setShowCelebration] =
|
|
6133
|
-
|
|
6216
|
+
const [showCelebration, setShowCelebration] = useState32(false);
|
|
6217
|
+
useEffect20(() => {
|
|
6134
6218
|
Animated5.timing(overlayOpacity, {
|
|
6135
6219
|
toValue: visible ? 1 : 0,
|
|
6136
6220
|
duration: 250,
|
|
6137
6221
|
useNativeDriver: true
|
|
6138
6222
|
}).start();
|
|
6139
6223
|
}, [visible, overlayOpacity]);
|
|
6140
|
-
|
|
6224
|
+
useEffect20(() => {
|
|
6141
6225
|
if (visible) {
|
|
6142
6226
|
mutation.reset();
|
|
6143
6227
|
setShowCelebration(false);
|
|
@@ -6145,7 +6229,7 @@ function ClaimPrizeSheet({
|
|
|
6145
6229
|
celebrationOpacity.setValue(0);
|
|
6146
6230
|
}
|
|
6147
6231
|
}, [visible]);
|
|
6148
|
-
|
|
6232
|
+
useEffect20(() => {
|
|
6149
6233
|
if (mutation.status === "success" && mutation.data) {
|
|
6150
6234
|
setShowCelebration(true);
|
|
6151
6235
|
Animated5.parallel([
|
|
@@ -6168,14 +6252,14 @@ function ClaimPrizeSheet({
|
|
|
6168
6252
|
return () => clearTimeout(timer);
|
|
6169
6253
|
}
|
|
6170
6254
|
}, [mutation.status, mutation.data]);
|
|
6171
|
-
|
|
6255
|
+
useEffect20(() => {
|
|
6172
6256
|
if (mutation.status === "error" && mutation.error) {
|
|
6173
6257
|
onError?.(mutation.error);
|
|
6174
6258
|
}
|
|
6175
6259
|
}, [mutation.status, mutation.error]);
|
|
6176
6260
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6177
6261
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
6178
|
-
const handleClaim =
|
|
6262
|
+
const handleClaim = useCallback27(async () => {
|
|
6179
6263
|
if (!wallet.publicKey) return;
|
|
6180
6264
|
try {
|
|
6181
6265
|
await mutation.execute({
|
|
@@ -6408,7 +6492,7 @@ var styles16 = StyleSheet17.create({
|
|
|
6408
6492
|
});
|
|
6409
6493
|
|
|
6410
6494
|
// src/ui/game/ClaimButton.tsx
|
|
6411
|
-
import { useState as
|
|
6495
|
+
import { useState as useState33, useMemo as useMemo10, useCallback as useCallback28 } from "react";
|
|
6412
6496
|
import { StyleSheet as StyleSheet18, Text as Text18, TouchableOpacity as TouchableOpacity13 } from "react-native";
|
|
6413
6497
|
import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6414
6498
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -6416,7 +6500,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6416
6500
|
const { wallet } = useDubs();
|
|
6417
6501
|
const game = useGame(gameId);
|
|
6418
6502
|
const claimStatus = useHasClaimed(gameId);
|
|
6419
|
-
const [sheetVisible, setSheetVisible] =
|
|
6503
|
+
const [sheetVisible, setSheetVisible] = useState33(false);
|
|
6420
6504
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
6421
6505
|
const myBet = useMemo10(() => {
|
|
6422
6506
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
@@ -6427,7 +6511,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6427
6511
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
6428
6512
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
6429
6513
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
6430
|
-
const handleSuccess =
|
|
6514
|
+
const handleSuccess = useCallback28(
|
|
6431
6515
|
(result) => {
|
|
6432
6516
|
claimStatus.refetch();
|
|
6433
6517
|
onSuccess?.(result);
|
|
@@ -6514,7 +6598,7 @@ var styles17 = StyleSheet18.create({
|
|
|
6514
6598
|
});
|
|
6515
6599
|
|
|
6516
6600
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
6517
|
-
import { useEffect as
|
|
6601
|
+
import { useEffect as useEffect21, useRef as useRef12, useCallback as useCallback29 } from "react";
|
|
6518
6602
|
import {
|
|
6519
6603
|
View as View18,
|
|
6520
6604
|
Text as Text19,
|
|
@@ -6546,19 +6630,19 @@ function EnterArcadePoolSheet({
|
|
|
6546
6630
|
const { wallet } = useDubs();
|
|
6547
6631
|
const mutation = useEnterArcadePool();
|
|
6548
6632
|
const overlayOpacity = useRef12(new Animated6.Value(0)).current;
|
|
6549
|
-
|
|
6633
|
+
useEffect21(() => {
|
|
6550
6634
|
Animated6.timing(overlayOpacity, {
|
|
6551
6635
|
toValue: visible ? 1 : 0,
|
|
6552
6636
|
duration: 250,
|
|
6553
6637
|
useNativeDriver: true
|
|
6554
6638
|
}).start();
|
|
6555
6639
|
}, [visible, overlayOpacity]);
|
|
6556
|
-
|
|
6640
|
+
useEffect21(() => {
|
|
6557
6641
|
if (visible) {
|
|
6558
6642
|
mutation.reset();
|
|
6559
6643
|
}
|
|
6560
6644
|
}, [visible]);
|
|
6561
|
-
|
|
6645
|
+
useEffect21(() => {
|
|
6562
6646
|
if (mutation.status === "success" && mutation.data) {
|
|
6563
6647
|
onSuccess?.(mutation.data);
|
|
6564
6648
|
const timer = setTimeout(() => {
|
|
@@ -6567,7 +6651,7 @@ function EnterArcadePoolSheet({
|
|
|
6567
6651
|
return () => clearTimeout(timer);
|
|
6568
6652
|
}
|
|
6569
6653
|
}, [mutation.status, mutation.data]);
|
|
6570
|
-
|
|
6654
|
+
useEffect21(() => {
|
|
6571
6655
|
if (mutation.status === "error" && mutation.error) {
|
|
6572
6656
|
onError?.(mutation.error);
|
|
6573
6657
|
}
|
|
@@ -6579,7 +6663,7 @@ function EnterArcadePoolSheet({
|
|
|
6579
6663
|
const potSol = (pool.buy_in_lamports * Number(totalBuyIns) / 1e9).toFixed(4);
|
|
6580
6664
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6581
6665
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
6582
|
-
const handleJoin =
|
|
6666
|
+
const handleJoin = useCallback29(async () => {
|
|
6583
6667
|
if (!wallet.publicKey) return;
|
|
6584
6668
|
try {
|
|
6585
6669
|
await mutation.execute(pool.id);
|
|
@@ -6730,7 +6814,7 @@ var styles18 = StyleSheet19.create({
|
|
|
6730
6814
|
});
|
|
6731
6815
|
|
|
6732
6816
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
6733
|
-
import { useEffect as
|
|
6817
|
+
import { useEffect as useEffect22, useRef as useRef13 } from "react";
|
|
6734
6818
|
import {
|
|
6735
6819
|
View as View19,
|
|
6736
6820
|
Text as Text20,
|
|
@@ -6759,14 +6843,14 @@ function ArcadeLeaderboardSheet({
|
|
|
6759
6843
|
const t = useDubsTheme();
|
|
6760
6844
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
6761
6845
|
const overlayOpacity = useRef13(new Animated7.Value(0)).current;
|
|
6762
|
-
|
|
6846
|
+
useEffect22(() => {
|
|
6763
6847
|
Animated7.timing(overlayOpacity, {
|
|
6764
6848
|
toValue: visible ? 1 : 0,
|
|
6765
6849
|
duration: 250,
|
|
6766
6850
|
useNativeDriver: true
|
|
6767
6851
|
}).start();
|
|
6768
6852
|
}, [visible, overlayOpacity]);
|
|
6769
|
-
|
|
6853
|
+
useEffect22(() => {
|
|
6770
6854
|
if (visible) refetch();
|
|
6771
6855
|
}, [visible]);
|
|
6772
6856
|
const renderItem = ({ item, index }) => {
|
|
@@ -6913,7 +6997,7 @@ var styles19 = StyleSheet20.create({
|
|
|
6913
6997
|
});
|
|
6914
6998
|
|
|
6915
6999
|
// src/ui/game/CreateGameSheet.tsx
|
|
6916
|
-
import { useState as
|
|
7000
|
+
import { useState as useState35, useEffect as useEffect23, useRef as useRef14, useCallback as useCallback30 } from "react";
|
|
6917
7001
|
import {
|
|
6918
7002
|
View as View20,
|
|
6919
7003
|
Text as Text21,
|
|
@@ -6952,20 +7036,20 @@ function CreateGameSheet({
|
|
|
6952
7036
|
const t = useDubsTheme();
|
|
6953
7037
|
const { wallet } = useDubs();
|
|
6954
7038
|
const mutation = useCreateGame();
|
|
6955
|
-
const [selectedTeam, setSelectedTeam] =
|
|
6956
|
-
const [wager, setWager] =
|
|
6957
|
-
const [showSuccess, setShowSuccess] =
|
|
7039
|
+
const [selectedTeam, setSelectedTeam] = useState35(null);
|
|
7040
|
+
const [wager, setWager] = useState35(0.01);
|
|
7041
|
+
const [showSuccess, setShowSuccess] = useState35(false);
|
|
6958
7042
|
const overlayOpacity = useRef14(new Animated8.Value(0)).current;
|
|
6959
7043
|
const successScale = useRef14(new Animated8.Value(0)).current;
|
|
6960
7044
|
const successOpacity = useRef14(new Animated8.Value(0)).current;
|
|
6961
|
-
|
|
7045
|
+
useEffect23(() => {
|
|
6962
7046
|
Animated8.timing(overlayOpacity, {
|
|
6963
7047
|
toValue: visible ? 1 : 0,
|
|
6964
7048
|
duration: 250,
|
|
6965
7049
|
useNativeDriver: true
|
|
6966
7050
|
}).start();
|
|
6967
7051
|
}, [visible]);
|
|
6968
|
-
|
|
7052
|
+
useEffect23(() => {
|
|
6969
7053
|
if (visible) {
|
|
6970
7054
|
setSelectedTeam(null);
|
|
6971
7055
|
setWager(0.01);
|
|
@@ -6975,7 +7059,7 @@ function CreateGameSheet({
|
|
|
6975
7059
|
mutation.reset();
|
|
6976
7060
|
}
|
|
6977
7061
|
}, [visible]);
|
|
6978
|
-
|
|
7062
|
+
useEffect23(() => {
|
|
6979
7063
|
if (mutation.status === "success" && mutation.data) {
|
|
6980
7064
|
setShowSuccess(true);
|
|
6981
7065
|
onSuccess?.(mutation.data);
|
|
@@ -6992,7 +7076,7 @@ function CreateGameSheet({
|
|
|
6992
7076
|
return () => clearTimeout(timer);
|
|
6993
7077
|
}
|
|
6994
7078
|
}, [mutation.status, mutation.data]);
|
|
6995
|
-
|
|
7079
|
+
useEffect23(() => {
|
|
6996
7080
|
if (mutation.status === "error" && mutation.error) {
|
|
6997
7081
|
onError?.(mutation.error);
|
|
6998
7082
|
}
|
|
@@ -7002,7 +7086,7 @@ function CreateGameSheet({
|
|
|
7002
7086
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
7003
7087
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7004
7088
|
const canCreate = selectedTeam !== null && !isMutating && mutation.status !== "success";
|
|
7005
|
-
const handleCreate =
|
|
7089
|
+
const handleCreate = useCallback30(async () => {
|
|
7006
7090
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
7007
7091
|
try {
|
|
7008
7092
|
await mutation.execute({
|
|
@@ -7202,9 +7286,11 @@ export {
|
|
|
7202
7286
|
useGame,
|
|
7203
7287
|
useGames,
|
|
7204
7288
|
useHasClaimed,
|
|
7289
|
+
useHighlights,
|
|
7205
7290
|
useJoinGame,
|
|
7206
7291
|
useNetworkGames,
|
|
7207
7292
|
usePushNotifications,
|
|
7293
|
+
useShorts,
|
|
7208
7294
|
useUFCFightCard,
|
|
7209
7295
|
useUFCFighterDetail
|
|
7210
7296
|
};
|