@dubsdotapp/expo 0.5.14 → 0.5.15
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 +271 -211
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +219 -160
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useHighlights.ts +38 -0
- package/src/index.ts +3 -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 useCallback21, useState as useState23, useEffect as useEffect15 } 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 useState22, useEffect as useEffect14, useRef as useRef6, useCallback as useCallback20 } from "react";
|
|
1714
1714
|
import {
|
|
1715
1715
|
View as View3,
|
|
1716
1716
|
Text as Text3,
|
|
@@ -2413,25 +2413,53 @@ 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
|
+
|
|
2416
2444
|
// src/hooks/usePushNotifications.ts
|
|
2417
|
-
import { useState as
|
|
2445
|
+
import { useState as useState15, useCallback as useCallback14, useRef as useRef3, useMemo, useEffect as useEffect10 } from "react";
|
|
2418
2446
|
import { Platform as Platform3 } from "react-native";
|
|
2419
2447
|
function usePushNotifications() {
|
|
2420
2448
|
const { client, appName, pushEnabled } = useDubs();
|
|
2421
2449
|
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] =
|
|
2450
|
+
const [hasPermission, setHasPermission] = useState15(false);
|
|
2451
|
+
const [pushToken, setPushToken] = useState15(null);
|
|
2452
|
+
const [loading, setLoading] = useState15(false);
|
|
2453
|
+
const [error, setError] = useState15(null);
|
|
2426
2454
|
const registering = useRef3(false);
|
|
2427
|
-
const getNotificationsModule =
|
|
2455
|
+
const getNotificationsModule = useCallback14(() => {
|
|
2428
2456
|
try {
|
|
2429
2457
|
return __require("expo-notifications");
|
|
2430
2458
|
} catch {
|
|
2431
2459
|
return null;
|
|
2432
2460
|
}
|
|
2433
2461
|
}, []);
|
|
2434
|
-
const getDeviceName =
|
|
2462
|
+
const getDeviceName = useCallback14(() => {
|
|
2435
2463
|
try {
|
|
2436
2464
|
const Device = __require("expo-device");
|
|
2437
2465
|
return Device.deviceName || null;
|
|
@@ -2439,7 +2467,7 @@ function usePushNotifications() {
|
|
|
2439
2467
|
return null;
|
|
2440
2468
|
}
|
|
2441
2469
|
}, []);
|
|
2442
|
-
const setupAndroidChannels =
|
|
2470
|
+
const setupAndroidChannels = useCallback14((Notifications) => {
|
|
2443
2471
|
if (Platform3.OS === "android") {
|
|
2444
2472
|
Notifications.setNotificationChannelAsync(channelId || "default", {
|
|
2445
2473
|
name: appName || "Default",
|
|
@@ -2449,7 +2477,7 @@ function usePushNotifications() {
|
|
|
2449
2477
|
});
|
|
2450
2478
|
}
|
|
2451
2479
|
}, [channelId, appName]);
|
|
2452
|
-
const registerTokenWithServer =
|
|
2480
|
+
const registerTokenWithServer = useCallback14(async (token) => {
|
|
2453
2481
|
const deviceName = getDeviceName();
|
|
2454
2482
|
await client.registerPushToken({
|
|
2455
2483
|
token,
|
|
@@ -2457,7 +2485,7 @@ function usePushNotifications() {
|
|
|
2457
2485
|
deviceName: deviceName || void 0
|
|
2458
2486
|
});
|
|
2459
2487
|
}, [client, getDeviceName]);
|
|
2460
|
-
const register =
|
|
2488
|
+
const register = useCallback14(async () => {
|
|
2461
2489
|
if (!pushEnabled) return false;
|
|
2462
2490
|
if (registering.current) return false;
|
|
2463
2491
|
registering.current = true;
|
|
@@ -2498,7 +2526,7 @@ function usePushNotifications() {
|
|
|
2498
2526
|
return false;
|
|
2499
2527
|
}
|
|
2500
2528
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2501
|
-
const unregister =
|
|
2529
|
+
const unregister = useCallback14(async () => {
|
|
2502
2530
|
if (!pushToken) return;
|
|
2503
2531
|
try {
|
|
2504
2532
|
await client.unregisterPushToken(pushToken);
|
|
@@ -2507,7 +2535,7 @@ function usePushNotifications() {
|
|
|
2507
2535
|
console.error("[usePushNotifications] Unregister error:", err);
|
|
2508
2536
|
}
|
|
2509
2537
|
}, [client, pushToken]);
|
|
2510
|
-
const restoreIfGranted =
|
|
2538
|
+
const restoreIfGranted = useCallback14(async () => {
|
|
2511
2539
|
if (!pushEnabled) return;
|
|
2512
2540
|
try {
|
|
2513
2541
|
const Notifications = getNotificationsModule();
|
|
@@ -2526,7 +2554,7 @@ function usePushNotifications() {
|
|
|
2526
2554
|
}
|
|
2527
2555
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2528
2556
|
const didMount = useRef3(false);
|
|
2529
|
-
|
|
2557
|
+
useEffect10(() => {
|
|
2530
2558
|
if (didMount.current) return;
|
|
2531
2559
|
didMount.current = true;
|
|
2532
2560
|
const Notifications = getNotificationsModule();
|
|
@@ -2556,13 +2584,13 @@ function usePushNotifications() {
|
|
|
2556
2584
|
}
|
|
2557
2585
|
|
|
2558
2586
|
// src/hooks/useArcadePools.ts
|
|
2559
|
-
import { useState as
|
|
2587
|
+
import { useState as useState16, useEffect as useEffect11, useCallback as useCallback15 } from "react";
|
|
2560
2588
|
function useArcadePools(gameSlug) {
|
|
2561
2589
|
const { client } = useDubs();
|
|
2562
|
-
const [pools, setPools] =
|
|
2563
|
-
const [loading, setLoading] =
|
|
2564
|
-
const [error, setError] =
|
|
2565
|
-
const fetch2 =
|
|
2590
|
+
const [pools, setPools] = useState16([]);
|
|
2591
|
+
const [loading, setLoading] = useState16(false);
|
|
2592
|
+
const [error, setError] = useState16(null);
|
|
2593
|
+
const fetch2 = useCallback15(async () => {
|
|
2566
2594
|
setLoading(true);
|
|
2567
2595
|
setError(null);
|
|
2568
2596
|
try {
|
|
@@ -2574,22 +2602,22 @@ function useArcadePools(gameSlug) {
|
|
|
2574
2602
|
setLoading(false);
|
|
2575
2603
|
}
|
|
2576
2604
|
}, [client, gameSlug]);
|
|
2577
|
-
|
|
2605
|
+
useEffect11(() => {
|
|
2578
2606
|
fetch2();
|
|
2579
2607
|
}, [fetch2]);
|
|
2580
2608
|
return { pools, loading, error, refetch: fetch2 };
|
|
2581
2609
|
}
|
|
2582
2610
|
|
|
2583
2611
|
// src/hooks/useArcadePool.ts
|
|
2584
|
-
import { useState as
|
|
2612
|
+
import { useState as useState17, useEffect as useEffect12, useCallback as useCallback16 } from "react";
|
|
2585
2613
|
function useArcadePool(poolId) {
|
|
2586
2614
|
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 =
|
|
2615
|
+
const [pool, setPool] = useState17(null);
|
|
2616
|
+
const [stats, setStats] = useState17(null);
|
|
2617
|
+
const [leaderboard, setLeaderboard] = useState17([]);
|
|
2618
|
+
const [loading, setLoading] = useState17(false);
|
|
2619
|
+
const [error, setError] = useState17(null);
|
|
2620
|
+
const fetch2 = useCallback16(async () => {
|
|
2593
2621
|
if (!poolId) return;
|
|
2594
2622
|
setLoading(true);
|
|
2595
2623
|
setError(null);
|
|
@@ -2607,22 +2635,22 @@ function useArcadePool(poolId) {
|
|
|
2607
2635
|
setLoading(false);
|
|
2608
2636
|
}
|
|
2609
2637
|
}, [client, poolId]);
|
|
2610
|
-
|
|
2638
|
+
useEffect12(() => {
|
|
2611
2639
|
fetch2();
|
|
2612
2640
|
}, [fetch2]);
|
|
2613
2641
|
return { pool, stats, leaderboard, loading, error, refetch: fetch2 };
|
|
2614
2642
|
}
|
|
2615
2643
|
|
|
2616
2644
|
// src/hooks/useArcadeGame.ts
|
|
2617
|
-
import { useState as
|
|
2645
|
+
import { useState as useState18, useCallback as useCallback17 } from "react";
|
|
2618
2646
|
function useArcadeGame(poolId, maxLives = 3) {
|
|
2619
2647
|
const { client } = useDubs();
|
|
2620
2648
|
const { user } = useAuth();
|
|
2621
|
-
const [entry, setEntry] =
|
|
2622
|
-
const [loading, setLoading] =
|
|
2623
|
-
const [error, setError] =
|
|
2649
|
+
const [entry, setEntry] = useState18(null);
|
|
2650
|
+
const [loading, setLoading] = useState18(false);
|
|
2651
|
+
const [error, setError] = useState18(null);
|
|
2624
2652
|
const walletAddress = user?.walletAddress || "";
|
|
2625
|
-
const refreshEntry =
|
|
2653
|
+
const refreshEntry = useCallback17(async () => {
|
|
2626
2654
|
if (!poolId || !walletAddress) return;
|
|
2627
2655
|
setLoading(true);
|
|
2628
2656
|
setError(null);
|
|
@@ -2639,7 +2667,7 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2639
2667
|
setLoading(false);
|
|
2640
2668
|
}
|
|
2641
2669
|
}, [client, poolId, walletAddress]);
|
|
2642
|
-
const startAttempt =
|
|
2670
|
+
const startAttempt = useCallback17(async () => {
|
|
2643
2671
|
if (!poolId || !walletAddress) throw new Error("Not ready");
|
|
2644
2672
|
setError(null);
|
|
2645
2673
|
try {
|
|
@@ -2651,7 +2679,7 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2651
2679
|
throw e;
|
|
2652
2680
|
}
|
|
2653
2681
|
}, [client, poolId, walletAddress]);
|
|
2654
|
-
const submitScore =
|
|
2682
|
+
const submitScore = useCallback17(async (sessionToken, score, durationMs) => {
|
|
2655
2683
|
if (!poolId || !walletAddress) throw new Error("Not ready");
|
|
2656
2684
|
setError(null);
|
|
2657
2685
|
try {
|
|
@@ -2688,19 +2716,19 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2688
2716
|
}
|
|
2689
2717
|
|
|
2690
2718
|
// src/hooks/useEnterArcadePool.ts
|
|
2691
|
-
import { useState as
|
|
2719
|
+
import { useState as useState19, useCallback as useCallback18 } from "react";
|
|
2692
2720
|
function useEnterArcadePool() {
|
|
2693
2721
|
const { client, wallet, connection } = useDubs();
|
|
2694
2722
|
const { user } = useAuth();
|
|
2695
|
-
const [status, setStatus] =
|
|
2696
|
-
const [error, setError] =
|
|
2697
|
-
const [data, setData] =
|
|
2698
|
-
const reset =
|
|
2723
|
+
const [status, setStatus] = useState19("idle");
|
|
2724
|
+
const [error, setError] = useState19(null);
|
|
2725
|
+
const [data, setData] = useState19(null);
|
|
2726
|
+
const reset = useCallback18(() => {
|
|
2699
2727
|
setStatus("idle");
|
|
2700
2728
|
setError(null);
|
|
2701
2729
|
setData(null);
|
|
2702
2730
|
}, []);
|
|
2703
|
-
const execute =
|
|
2731
|
+
const execute = useCallback18(async (poolId) => {
|
|
2704
2732
|
if (!wallet.publicKey) throw new Error("Wallet not connected");
|
|
2705
2733
|
const walletAddress = wallet.publicKey.toBase58();
|
|
2706
2734
|
setStatus("building");
|
|
@@ -2748,7 +2776,7 @@ function useEnterArcadePool() {
|
|
|
2748
2776
|
}
|
|
2749
2777
|
|
|
2750
2778
|
// src/hooks/useArcadeCountdown.ts
|
|
2751
|
-
import { useState as
|
|
2779
|
+
import { useState as useState20, useEffect as useEffect13, useRef as useRef4 } from "react";
|
|
2752
2780
|
function formatCountdown(ms) {
|
|
2753
2781
|
if (ms <= 0) return "Ended";
|
|
2754
2782
|
const s2 = Math.floor(ms / 1e3);
|
|
@@ -2761,9 +2789,9 @@ function formatCountdown(ms) {
|
|
|
2761
2789
|
return `${s2}s`;
|
|
2762
2790
|
}
|
|
2763
2791
|
function useArcadeCountdown(nextResolution) {
|
|
2764
|
-
const [now, setNow] =
|
|
2792
|
+
const [now, setNow] = useState20(Date.now());
|
|
2765
2793
|
const intervalRef = useRef4(null);
|
|
2766
|
-
|
|
2794
|
+
useEffect13(() => {
|
|
2767
2795
|
if (!nextResolution) return;
|
|
2768
2796
|
intervalRef.current = setInterval(() => setNow(Date.now()), 1e3);
|
|
2769
2797
|
return () => {
|
|
@@ -2792,7 +2820,7 @@ function useArcadeCountdown(nextResolution) {
|
|
|
2792
2820
|
}
|
|
2793
2821
|
|
|
2794
2822
|
// src/hooks/useArcadeBridge.ts
|
|
2795
|
-
import { useRef as useRef5, useState as
|
|
2823
|
+
import { useRef as useRef5, useState as useState21, useCallback as useCallback19 } from "react";
|
|
2796
2824
|
var PROTOCOL_VERSION = "1.0";
|
|
2797
2825
|
function useArcadeBridge({
|
|
2798
2826
|
canPlay,
|
|
@@ -2807,9 +2835,9 @@ function useArcadeBridge({
|
|
|
2807
2835
|
const gameStartTimeRef = useRef5(0);
|
|
2808
2836
|
const canPlayRef = useRef5(canPlay);
|
|
2809
2837
|
canPlayRef.current = canPlay;
|
|
2810
|
-
const [lastResult, setLastResult] =
|
|
2811
|
-
const [bridgeLoading, setBridgeLoading] =
|
|
2812
|
-
const injectSession =
|
|
2838
|
+
const [lastResult, setLastResult] = useState21(null);
|
|
2839
|
+
const [bridgeLoading, setBridgeLoading] = useState21(false);
|
|
2840
|
+
const injectSession = useCallback19((token, attemptNumber) => {
|
|
2813
2841
|
webviewRef.current?.injectJavaScript(`
|
|
2814
2842
|
window.ARCADE_SESSION_TOKEN = ${JSON.stringify(token)};
|
|
2815
2843
|
window.ARCADE_ATTEMPT_NUMBER = ${attemptNumber};
|
|
@@ -2818,7 +2846,7 @@ function useArcadeBridge({
|
|
|
2818
2846
|
true;
|
|
2819
2847
|
`);
|
|
2820
2848
|
}, []);
|
|
2821
|
-
const triggerPlay =
|
|
2849
|
+
const triggerPlay = useCallback19(async () => {
|
|
2822
2850
|
if (!canPlay) return;
|
|
2823
2851
|
setBridgeLoading(true);
|
|
2824
2852
|
try {
|
|
@@ -2835,7 +2863,7 @@ function useArcadeBridge({
|
|
|
2835
2863
|
setBridgeLoading(false);
|
|
2836
2864
|
}
|
|
2837
2865
|
}, [canPlay, startAttempt, injectSession, onPlayStarted, onError]);
|
|
2838
|
-
const handleMessage =
|
|
2866
|
+
const handleMessage = useCallback19(
|
|
2839
2867
|
async (event) => {
|
|
2840
2868
|
let data;
|
|
2841
2869
|
try {
|
|
@@ -3048,11 +3076,11 @@ function AuthGate({
|
|
|
3048
3076
|
}) {
|
|
3049
3077
|
const { client, pushEnabled } = useDubs();
|
|
3050
3078
|
const auth = useAuth();
|
|
3051
|
-
const [phase, setPhase] =
|
|
3052
|
-
const [registrationPhase, setRegistrationPhase] =
|
|
3053
|
-
const [showPushSetup, setShowPushSetup] =
|
|
3054
|
-
const [isRestoredSession, setIsRestoredSession] =
|
|
3055
|
-
|
|
3079
|
+
const [phase, setPhase] = useState22("init");
|
|
3080
|
+
const [registrationPhase, setRegistrationPhase] = useState22(false);
|
|
3081
|
+
const [showPushSetup, setShowPushSetup] = useState22(false);
|
|
3082
|
+
const [isRestoredSession, setIsRestoredSession] = useState22(false);
|
|
3083
|
+
useEffect14(() => {
|
|
3056
3084
|
let cancelled = false;
|
|
3057
3085
|
(async () => {
|
|
3058
3086
|
try {
|
|
@@ -3079,23 +3107,23 @@ function AuthGate({
|
|
|
3079
3107
|
cancelled = true;
|
|
3080
3108
|
};
|
|
3081
3109
|
}, []);
|
|
3082
|
-
|
|
3110
|
+
useEffect14(() => {
|
|
3083
3111
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
3084
3112
|
}, [auth.status]);
|
|
3085
|
-
|
|
3113
|
+
useEffect14(() => {
|
|
3086
3114
|
if (pushEnabled && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
3087
3115
|
setShowPushSetup(true);
|
|
3088
3116
|
}
|
|
3089
3117
|
}, [pushEnabled, auth.status, registrationPhase, isRestoredSession]);
|
|
3090
|
-
|
|
3118
|
+
useEffect14(() => {
|
|
3091
3119
|
if (auth.token) onSaveToken(auth.token);
|
|
3092
3120
|
}, [auth.token]);
|
|
3093
|
-
const retry =
|
|
3121
|
+
const retry = useCallback20(() => {
|
|
3094
3122
|
setRegistrationPhase(false);
|
|
3095
3123
|
auth.reset();
|
|
3096
3124
|
auth.authenticate();
|
|
3097
3125
|
}, [auth]);
|
|
3098
|
-
const handleRegister =
|
|
3126
|
+
const handleRegister = useCallback20(
|
|
3099
3127
|
(username, referralCode, avatarUrl) => {
|
|
3100
3128
|
auth.register(username, referralCode, avatarUrl);
|
|
3101
3129
|
},
|
|
@@ -3219,20 +3247,20 @@ function DefaultRegistrationScreen({
|
|
|
3219
3247
|
}) {
|
|
3220
3248
|
const t = useDubsTheme();
|
|
3221
3249
|
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] =
|
|
3250
|
+
const [step, setStep] = useState22(0);
|
|
3251
|
+
const [avatarSeed, setAvatarSeed] = useState22(generateSeed);
|
|
3252
|
+
const [avatarStyle, setAvatarStyle] = useState22("adventurer");
|
|
3253
|
+
const [avatarBg, setAvatarBg] = useState22("1a1a2e");
|
|
3254
|
+
const [showStyles, setShowStyles] = useState22(false);
|
|
3255
|
+
const [username, setUsername] = useState22("");
|
|
3256
|
+
const [referralCode, setReferralCode] = useState22("");
|
|
3257
|
+
const [checking, setChecking] = useState22(false);
|
|
3258
|
+
const [availability, setAvailability] = useState22(null);
|
|
3231
3259
|
const debounceRef = useRef6(null);
|
|
3232
3260
|
const fadeAnim = useRef6(new Animated.Value(1)).current;
|
|
3233
3261
|
const slideAnim = useRef6(new Animated.Value(0)).current;
|
|
3234
3262
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3235
|
-
|
|
3263
|
+
useEffect14(() => {
|
|
3236
3264
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3237
3265
|
const trimmed = username.trim();
|
|
3238
3266
|
if (trimmed.length < 3) {
|
|
@@ -3255,7 +3283,7 @@ function DefaultRegistrationScreen({
|
|
|
3255
3283
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3256
3284
|
};
|
|
3257
3285
|
}, [username, client]);
|
|
3258
|
-
const animateToStep =
|
|
3286
|
+
const animateToStep = useCallback20((newStep) => {
|
|
3259
3287
|
const dir = newStep > step ? 1 : -1;
|
|
3260
3288
|
Keyboard.dismiss();
|
|
3261
3289
|
Animated.parallel([
|
|
@@ -3495,7 +3523,7 @@ function DefaultRegistrationScreen({
|
|
|
3495
3523
|
function PushTokenRestorer() {
|
|
3496
3524
|
const push = usePushNotifications();
|
|
3497
3525
|
const restored = useRef6(false);
|
|
3498
|
-
|
|
3526
|
+
useEffect14(() => {
|
|
3499
3527
|
if (restored.current) return;
|
|
3500
3528
|
restored.current = true;
|
|
3501
3529
|
push.restoreIfGranted();
|
|
@@ -3512,7 +3540,7 @@ function PushSetupScreen({
|
|
|
3512
3540
|
const push = usePushNotifications();
|
|
3513
3541
|
const fadeAnim = useRef6(new Animated.Value(0)).current;
|
|
3514
3542
|
const slideAnim = useRef6(new Animated.Value(30)).current;
|
|
3515
|
-
|
|
3543
|
+
useEffect14(() => {
|
|
3516
3544
|
Animated.parallel([
|
|
3517
3545
|
Animated.timing(fadeAnim, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
3518
3546
|
Animated.timing(slideAnim, { toValue: 0, duration: 300, useNativeDriver: true })
|
|
@@ -3672,9 +3700,9 @@ function DubsProvider({
|
|
|
3672
3700
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
3673
3701
|
const client = useMemo3(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
3674
3702
|
const storage = useMemo3(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
3675
|
-
const [uiConfig, setUiConfig] =
|
|
3676
|
-
const [resolvedNetwork, setResolvedNetwork] =
|
|
3677
|
-
|
|
3703
|
+
const [uiConfig, setUiConfig] = useState23(null);
|
|
3704
|
+
const [resolvedNetwork, setResolvedNetwork] = useState23(network);
|
|
3705
|
+
useEffect15(() => {
|
|
3678
3706
|
client.getAppConfig().then((cfg) => {
|
|
3679
3707
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
3680
3708
|
setUiConfig(cfg);
|
|
@@ -3766,7 +3794,7 @@ function ManagedInner({
|
|
|
3766
3794
|
children
|
|
3767
3795
|
}) {
|
|
3768
3796
|
const managedDisconnect = useDisconnect();
|
|
3769
|
-
const disconnect =
|
|
3797
|
+
const disconnect = useCallback21(async () => {
|
|
3770
3798
|
client.setToken(null);
|
|
3771
3799
|
await managedDisconnect?.();
|
|
3772
3800
|
}, [client, managedDisconnect]);
|
|
@@ -3807,7 +3835,7 @@ function ExternalWalletProvider({
|
|
|
3807
3835
|
pushEnabled,
|
|
3808
3836
|
children
|
|
3809
3837
|
}) {
|
|
3810
|
-
const disconnect =
|
|
3838
|
+
const disconnect = useCallback21(async () => {
|
|
3811
3839
|
client.setToken(null);
|
|
3812
3840
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
3813
3841
|
});
|
|
@@ -4128,7 +4156,7 @@ var styles5 = StyleSheet6.create({
|
|
|
4128
4156
|
});
|
|
4129
4157
|
|
|
4130
4158
|
// src/ui/UserProfileSheet.tsx
|
|
4131
|
-
import { useState as
|
|
4159
|
+
import { useState as useState24, useEffect as useEffect16, useRef as useRef7, useCallback as useCallback22, useMemo as useMemo5 } from "react";
|
|
4132
4160
|
import {
|
|
4133
4161
|
View as View7,
|
|
4134
4162
|
Text as Text7,
|
|
@@ -4161,29 +4189,29 @@ function UserProfileSheet({
|
|
|
4161
4189
|
const push = usePushNotifications();
|
|
4162
4190
|
const overlayOpacity = useRef7(new Animated2.Value(0)).current;
|
|
4163
4191
|
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
|
-
|
|
4192
|
+
const [avatarStyle, setAvatarStyle] = useState24(parsed.style);
|
|
4193
|
+
const [avatarSeed, setAvatarSeed] = useState24(parsed.seed);
|
|
4194
|
+
const [bgColor, setBgColor] = useState24(parsed.bg);
|
|
4195
|
+
const [saving, setSaving] = useState24(false);
|
|
4196
|
+
const [error, setError] = useState24(null);
|
|
4197
|
+
useEffect16(() => {
|
|
4170
4198
|
const p = parseAvatarUrl(user.avatar);
|
|
4171
4199
|
setAvatarStyle(p.style);
|
|
4172
4200
|
setAvatarSeed(p.seed);
|
|
4173
4201
|
setBgColor(p.bg);
|
|
4174
4202
|
}, [user.avatar]);
|
|
4175
|
-
|
|
4203
|
+
useEffect16(() => {
|
|
4176
4204
|
Animated2.timing(overlayOpacity, {
|
|
4177
4205
|
toValue: visible ? 1 : 0,
|
|
4178
4206
|
duration: 250,
|
|
4179
4207
|
useNativeDriver: true
|
|
4180
4208
|
}).start();
|
|
4181
4209
|
}, [visible, overlayOpacity]);
|
|
4182
|
-
|
|
4210
|
+
useEffect16(() => {
|
|
4183
4211
|
if (visible) setError(null);
|
|
4184
4212
|
}, [visible]);
|
|
4185
4213
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4186
|
-
const saveAvatar =
|
|
4214
|
+
const saveAvatar = useCallback22(async (newUrl) => {
|
|
4187
4215
|
setSaving(true);
|
|
4188
4216
|
setError(null);
|
|
4189
4217
|
try {
|
|
@@ -4196,16 +4224,16 @@ function UserProfileSheet({
|
|
|
4196
4224
|
setSaving(false);
|
|
4197
4225
|
}
|
|
4198
4226
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4199
|
-
const handleStyleChange =
|
|
4227
|
+
const handleStyleChange = useCallback22((style) => {
|
|
4200
4228
|
setAvatarStyle(style);
|
|
4201
4229
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4202
4230
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4203
|
-
const handleShuffle =
|
|
4231
|
+
const handleShuffle = useCallback22(() => {
|
|
4204
4232
|
const newSeed = generateSeed();
|
|
4205
4233
|
setAvatarSeed(newSeed);
|
|
4206
4234
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4207
4235
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4208
|
-
const handleBgChange =
|
|
4236
|
+
const handleBgChange = useCallback22((color) => {
|
|
4209
4237
|
setBgColor(color);
|
|
4210
4238
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4211
4239
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4485,7 +4513,7 @@ var styles6 = StyleSheet7.create({
|
|
|
4485
4513
|
});
|
|
4486
4514
|
|
|
4487
4515
|
// src/ui/game/GamePoster.tsx
|
|
4488
|
-
import { useState as
|
|
4516
|
+
import { useState as useState25 } from "react";
|
|
4489
4517
|
import { StyleSheet as StyleSheet8, View as View8, Text as Text8 } from "react-native";
|
|
4490
4518
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4491
4519
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4535,7 +4563,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4535
4563
|
] });
|
|
4536
4564
|
}
|
|
4537
4565
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4538
|
-
const [failed, setFailed] =
|
|
4566
|
+
const [failed, setFailed] = useState25(false);
|
|
4539
4567
|
if (!url || failed) {
|
|
4540
4568
|
return /* @__PURE__ */ jsx10(View8, { style: [styles7.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4541
4569
|
}
|
|
@@ -4715,7 +4743,7 @@ var styles8 = StyleSheet9.create({
|
|
|
4715
4743
|
});
|
|
4716
4744
|
|
|
4717
4745
|
// src/ui/game/PickWinnerCard.tsx
|
|
4718
|
-
import { useState as
|
|
4746
|
+
import { useState as useState26, useMemo as useMemo7 } from "react";
|
|
4719
4747
|
import { StyleSheet as StyleSheet10, View as View10, Text as Text10, TouchableOpacity as TouchableOpacity7 } from "react-native";
|
|
4720
4748
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4721
4749
|
function PickWinnerCard({
|
|
@@ -4786,7 +4814,7 @@ function TeamOption({
|
|
|
4786
4814
|
ImageComponent,
|
|
4787
4815
|
t
|
|
4788
4816
|
}) {
|
|
4789
|
-
const [imgFailed, setImgFailed] =
|
|
4817
|
+
const [imgFailed, setImgFailed] = useState26(false);
|
|
4790
4818
|
const Img = ImageComponent || __require("react-native").Image;
|
|
4791
4819
|
const showImage = imageUrl && !imgFailed;
|
|
4792
4820
|
return /* @__PURE__ */ jsxs9(
|
|
@@ -4827,7 +4855,7 @@ var styles9 = StyleSheet10.create({
|
|
|
4827
4855
|
});
|
|
4828
4856
|
|
|
4829
4857
|
// src/ui/game/PlayersCard.tsx
|
|
4830
|
-
import { useState as
|
|
4858
|
+
import { useState as useState27 } from "react";
|
|
4831
4859
|
import { StyleSheet as StyleSheet11, View as View11, Text as Text11 } from "react-native";
|
|
4832
4860
|
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
4833
4861
|
function truncateWallet(addr, chars) {
|
|
@@ -4876,7 +4904,7 @@ function BettorRow({
|
|
|
4876
4904
|
ImageComponent,
|
|
4877
4905
|
t
|
|
4878
4906
|
}) {
|
|
4879
|
-
const [imgFailed, setImgFailed] =
|
|
4907
|
+
const [imgFailed, setImgFailed] = useState27(false);
|
|
4880
4908
|
const Img = ImageComponent || __require("react-native").Image;
|
|
4881
4909
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
4882
4910
|
return /* @__PURE__ */ jsxs10(View11, { style: [styles10.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -4955,7 +4983,7 @@ var styles11 = StyleSheet12.create({
|
|
|
4955
4983
|
});
|
|
4956
4984
|
|
|
4957
4985
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
4958
|
-
import { useState as
|
|
4986
|
+
import { useState as useState28, useEffect as useEffect17, useRef as useRef8, useCallback as useCallback23 } from "react";
|
|
4959
4987
|
import {
|
|
4960
4988
|
View as View13,
|
|
4961
4989
|
Text as Text13,
|
|
@@ -4992,18 +5020,18 @@ function CreateCustomGameSheet({
|
|
|
4992
5020
|
const t = useDubsTheme();
|
|
4993
5021
|
const { wallet } = useDubs();
|
|
4994
5022
|
const mutation = useCreateCustomGame();
|
|
4995
|
-
const [selectedAmount, setSelectedAmount] =
|
|
4996
|
-
const [customAmount, setCustomAmount] =
|
|
4997
|
-
const [isCustom, setIsCustom] =
|
|
5023
|
+
const [selectedAmount, setSelectedAmount] = useState28(null);
|
|
5024
|
+
const [customAmount, setCustomAmount] = useState28("");
|
|
5025
|
+
const [isCustom, setIsCustom] = useState28(false);
|
|
4998
5026
|
const overlayOpacity = useRef8(new Animated3.Value(0)).current;
|
|
4999
|
-
|
|
5027
|
+
useEffect17(() => {
|
|
5000
5028
|
Animated3.timing(overlayOpacity, {
|
|
5001
5029
|
toValue: visible ? 1 : 0,
|
|
5002
5030
|
duration: 250,
|
|
5003
5031
|
useNativeDriver: true
|
|
5004
5032
|
}).start();
|
|
5005
5033
|
}, [visible, overlayOpacity]);
|
|
5006
|
-
|
|
5034
|
+
useEffect17(() => {
|
|
5007
5035
|
if (visible) {
|
|
5008
5036
|
setSelectedAmount(defaultAmount ?? null);
|
|
5009
5037
|
setCustomAmount("");
|
|
@@ -5011,7 +5039,7 @@ function CreateCustomGameSheet({
|
|
|
5011
5039
|
mutation.reset();
|
|
5012
5040
|
}
|
|
5013
5041
|
}, [visible]);
|
|
5014
|
-
|
|
5042
|
+
useEffect17(() => {
|
|
5015
5043
|
if (mutation.status === "success" && mutation.data) {
|
|
5016
5044
|
onSuccess?.(mutation.data);
|
|
5017
5045
|
const timer = setTimeout(() => {
|
|
@@ -5020,23 +5048,23 @@ function CreateCustomGameSheet({
|
|
|
5020
5048
|
return () => clearTimeout(timer);
|
|
5021
5049
|
}
|
|
5022
5050
|
}, [mutation.status, mutation.data]);
|
|
5023
|
-
|
|
5051
|
+
useEffect17(() => {
|
|
5024
5052
|
if (mutation.status === "error" && mutation.error) {
|
|
5025
5053
|
onError?.(mutation.error);
|
|
5026
5054
|
}
|
|
5027
5055
|
}, [mutation.status, mutation.error]);
|
|
5028
|
-
const handlePresetSelect =
|
|
5056
|
+
const handlePresetSelect = useCallback23((amount) => {
|
|
5029
5057
|
setSelectedAmount(amount);
|
|
5030
5058
|
setIsCustom(false);
|
|
5031
5059
|
setCustomAmount("");
|
|
5032
5060
|
onAmountChange?.(amount);
|
|
5033
5061
|
}, [onAmountChange]);
|
|
5034
|
-
const handleCustomSelect =
|
|
5062
|
+
const handleCustomSelect = useCallback23(() => {
|
|
5035
5063
|
setIsCustom(true);
|
|
5036
5064
|
setSelectedAmount(null);
|
|
5037
5065
|
onAmountChange?.(null);
|
|
5038
5066
|
}, [onAmountChange]);
|
|
5039
|
-
const handleCustomAmountChange =
|
|
5067
|
+
const handleCustomAmountChange = useCallback23((text) => {
|
|
5040
5068
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
5041
5069
|
setCustomAmount(cleaned);
|
|
5042
5070
|
const parsed = parseFloat(cleaned);
|
|
@@ -5051,7 +5079,7 @@ function CreateCustomGameSheet({
|
|
|
5051
5079
|
const winnerTakes = pot * (1 - fee / 100);
|
|
5052
5080
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5053
5081
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
5054
|
-
const handleCreate =
|
|
5082
|
+
const handleCreate = useCallback23(async () => {
|
|
5055
5083
|
if (!finalAmount || !wallet.publicKey) return;
|
|
5056
5084
|
try {
|
|
5057
5085
|
await mutation.execute({
|
|
@@ -5320,7 +5348,7 @@ var styles12 = StyleSheet13.create({
|
|
|
5320
5348
|
});
|
|
5321
5349
|
|
|
5322
5350
|
// src/ui/game/JoinGameSheet.tsx
|
|
5323
|
-
import { useState as
|
|
5351
|
+
import { useState as useState30, useEffect as useEffect18, useRef as useRef10, useCallback as useCallback25, useMemo as useMemo9 } from "react";
|
|
5324
5352
|
import {
|
|
5325
5353
|
View as View16,
|
|
5326
5354
|
Text as Text16,
|
|
@@ -5530,7 +5558,7 @@ var styles13 = StyleSheet14.create({
|
|
|
5530
5558
|
});
|
|
5531
5559
|
|
|
5532
5560
|
// src/ui/game/TeamButton.tsx
|
|
5533
|
-
import { useState as
|
|
5561
|
+
import { useState as useState29 } from "react";
|
|
5534
5562
|
import { View as View15, Text as Text15, TouchableOpacity as TouchableOpacity10, StyleSheet as StyleSheet15 } from "react-native";
|
|
5535
5563
|
import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5536
5564
|
function TeamButton({
|
|
@@ -5544,7 +5572,7 @@ function TeamButton({
|
|
|
5544
5572
|
ImageComponent,
|
|
5545
5573
|
t
|
|
5546
5574
|
}) {
|
|
5547
|
-
const [imgFailed, setImgFailed] =
|
|
5575
|
+
const [imgFailed, setImgFailed] = useState29(false);
|
|
5548
5576
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5549
5577
|
const showImage = imageUrl && !imgFailed;
|
|
5550
5578
|
return /* @__PURE__ */ jsxs14(
|
|
@@ -5635,6 +5663,7 @@ function JoinGameSheet({
|
|
|
5635
5663
|
shortName,
|
|
5636
5664
|
homeColor = "#3B82F6",
|
|
5637
5665
|
awayColor = "#EF4444",
|
|
5666
|
+
drawColor = "#F59E0B",
|
|
5638
5667
|
onSuccess,
|
|
5639
5668
|
onError,
|
|
5640
5669
|
onTeamSelect,
|
|
@@ -5647,20 +5676,20 @@ function JoinGameSheet({
|
|
|
5647
5676
|
const { wallet } = useDubs();
|
|
5648
5677
|
const mutation = useJoinGame();
|
|
5649
5678
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
5650
|
-
const [selectedTeam, setSelectedTeam] =
|
|
5651
|
-
const [wager, setWager] =
|
|
5652
|
-
const [showSuccess, setShowSuccess] =
|
|
5679
|
+
const [selectedTeam, setSelectedTeam] = useState30(null);
|
|
5680
|
+
const [wager, setWager] = useState30(game.buyIn);
|
|
5681
|
+
const [showSuccess, setShowSuccess] = useState30(false);
|
|
5653
5682
|
const overlayOpacity = useRef10(new Animated4.Value(0)).current;
|
|
5654
5683
|
const successScale = useRef10(new Animated4.Value(0)).current;
|
|
5655
5684
|
const successOpacity = useRef10(new Animated4.Value(0)).current;
|
|
5656
|
-
|
|
5685
|
+
useEffect18(() => {
|
|
5657
5686
|
Animated4.timing(overlayOpacity, {
|
|
5658
5687
|
toValue: visible ? 1 : 0,
|
|
5659
5688
|
duration: 250,
|
|
5660
5689
|
useNativeDriver: true
|
|
5661
5690
|
}).start();
|
|
5662
5691
|
}, [visible, overlayOpacity]);
|
|
5663
|
-
|
|
5692
|
+
useEffect18(() => {
|
|
5664
5693
|
if (visible) {
|
|
5665
5694
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
5666
5695
|
setWager(game.buyIn);
|
|
@@ -5670,7 +5699,7 @@ function JoinGameSheet({
|
|
|
5670
5699
|
mutation.reset();
|
|
5671
5700
|
}
|
|
5672
5701
|
}, [visible]);
|
|
5673
|
-
|
|
5702
|
+
useEffect18(() => {
|
|
5674
5703
|
if (mutation.status === "success" && mutation.data) {
|
|
5675
5704
|
setShowSuccess(true);
|
|
5676
5705
|
onSuccess?.(mutation.data);
|
|
@@ -5687,7 +5716,7 @@ function JoinGameSheet({
|
|
|
5687
5716
|
return () => clearTimeout(timer);
|
|
5688
5717
|
}
|
|
5689
5718
|
}, [mutation.status, mutation.data]);
|
|
5690
|
-
|
|
5719
|
+
useEffect18(() => {
|
|
5691
5720
|
if (mutation.status === "error" && mutation.error) {
|
|
5692
5721
|
onError?.(mutation.error);
|
|
5693
5722
|
}
|
|
@@ -5697,18 +5726,29 @@ function JoinGameSheet({
|
|
|
5697
5726
|
const totalPool = game.totalPool || 0;
|
|
5698
5727
|
const homePool = game.homePool || 0;
|
|
5699
5728
|
const awayPool = game.awayPool || 0;
|
|
5729
|
+
const drawPool = game.drawPool || 0;
|
|
5700
5730
|
const buyIn = game.buyIn;
|
|
5731
|
+
const drawBettors = bettors.filter((b) => b.team === "draw");
|
|
5732
|
+
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
5733
|
const poolAfterJoin = totalPool + wager;
|
|
5702
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = useMemo9(() => {
|
|
5734
|
+
const { homeOdds, awayOdds, drawOdds, homeBets, awayBets, drawBets } = useMemo9(() => {
|
|
5735
|
+
const homeBetsCount = bettors.filter((b) => b.team === "home").length;
|
|
5736
|
+
const awayBetsCount = bettors.filter((b) => b.team === "away").length;
|
|
5737
|
+
const drawBetsCount = bettors.filter((b) => b.team === "draw").length;
|
|
5703
5738
|
const newPool = totalPool + wager;
|
|
5739
|
+
const newHome = homePool + (selectedTeam === "home" ? wager : 0);
|
|
5740
|
+
const newAway = awayPool + (selectedTeam === "away" ? wager : 0);
|
|
5741
|
+
const newDraw = drawPool + (selectedTeam === "draw" ? wager : 0);
|
|
5704
5742
|
return {
|
|
5705
|
-
homeOdds:
|
|
5706
|
-
awayOdds:
|
|
5707
|
-
|
|
5708
|
-
|
|
5743
|
+
homeOdds: newHome > 0 ? (newPool / newHome).toFixed(2) : "\u2014",
|
|
5744
|
+
awayOdds: newAway > 0 ? (newPool / newAway).toFixed(2) : "\u2014",
|
|
5745
|
+
drawOdds: newDraw > 0 ? (newPool / newDraw).toFixed(2) : "\u2014",
|
|
5746
|
+
homeBets: homeBetsCount,
|
|
5747
|
+
awayBets: awayBetsCount,
|
|
5748
|
+
drawBets: drawBetsCount
|
|
5709
5749
|
};
|
|
5710
|
-
}, [totalPool, homePool, awayPool, bettors, wager, selectedTeam]);
|
|
5711
|
-
const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : "\u2014";
|
|
5750
|
+
}, [totalPool, homePool, awayPool, drawPool, bettors, wager, selectedTeam]);
|
|
5751
|
+
const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : selectedTeam === "draw" ? drawOdds : "\u2014";
|
|
5712
5752
|
const potentialWinnings = selectedOdds !== "\u2014" ? formatSol(parseFloat(selectedOdds) * wager) : "\u2014";
|
|
5713
5753
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
5714
5754
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
@@ -5720,7 +5760,7 @@ function JoinGameSheet({
|
|
|
5720
5760
|
const alreadyJoined = myBet !== null;
|
|
5721
5761
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5722
5762
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
5723
|
-
const handleJoin =
|
|
5763
|
+
const handleJoin = useCallback25(async () => {
|
|
5724
5764
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
5725
5765
|
try {
|
|
5726
5766
|
await mutation.execute({
|
|
@@ -5817,11 +5857,26 @@ function JoinGameSheet({
|
|
|
5817
5857
|
t
|
|
5818
5858
|
}
|
|
5819
5859
|
)
|
|
5820
|
-
] })
|
|
5860
|
+
] }),
|
|
5861
|
+
hasDrawOption && /* @__PURE__ */ jsx18(View16, { style: styles15.drawRow, children: /* @__PURE__ */ jsx18(
|
|
5862
|
+
TeamButton,
|
|
5863
|
+
{
|
|
5864
|
+
name: "Draw",
|
|
5865
|
+
odds: drawOdds,
|
|
5866
|
+
bets: drawBets,
|
|
5867
|
+
color: drawColor,
|
|
5868
|
+
selected: selectedTeam === "draw",
|
|
5869
|
+
onPress: () => {
|
|
5870
|
+
setSelectedTeam("draw");
|
|
5871
|
+
onTeamSelect?.("draw");
|
|
5872
|
+
},
|
|
5873
|
+
t
|
|
5874
|
+
}
|
|
5875
|
+
) })
|
|
5821
5876
|
] }),
|
|
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 }),
|
|
5877
|
+
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: [
|
|
5878
|
+
/* @__PURE__ */ jsx18(Text16, { style: [styles15.myBetLabel, { color: myBet.team === "home" ? homeColor : myBet.team === "away" ? awayColor : drawColor }], children: "YOUR BET" }),
|
|
5879
|
+
/* @__PURE__ */ jsx18(Text16, { style: [styles15.myBetTeam, { color: t.text }], children: myBet.team === "home" ? homeName : myBet.team === "away" ? awayName : "Draw" }),
|
|
5825
5880
|
/* @__PURE__ */ jsxs15(Text16, { style: [styles15.myBetAmount, { color: t.textMuted }], children: [
|
|
5826
5881
|
formatSol(myBet.amount),
|
|
5827
5882
|
" SOL"
|
|
@@ -6020,6 +6075,9 @@ var styles15 = StyleSheet16.create({
|
|
|
6020
6075
|
flexDirection: "row",
|
|
6021
6076
|
gap: 12
|
|
6022
6077
|
},
|
|
6078
|
+
drawRow: {
|
|
6079
|
+
marginTop: 8
|
|
6080
|
+
},
|
|
6023
6081
|
summaryCard: {
|
|
6024
6082
|
marginTop: 20,
|
|
6025
6083
|
borderRadius: 16,
|
|
@@ -6095,7 +6153,7 @@ var styles15 = StyleSheet16.create({
|
|
|
6095
6153
|
});
|
|
6096
6154
|
|
|
6097
6155
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
6098
|
-
import { useState as
|
|
6156
|
+
import { useState as useState31, useEffect as useEffect19, useRef as useRef11, useCallback as useCallback26 } from "react";
|
|
6099
6157
|
import {
|
|
6100
6158
|
View as View17,
|
|
6101
6159
|
Text as Text17,
|
|
@@ -6129,15 +6187,15 @@ function ClaimPrizeSheet({
|
|
|
6129
6187
|
const overlayOpacity = useRef11(new Animated5.Value(0)).current;
|
|
6130
6188
|
const celebrationScale = useRef11(new Animated5.Value(0)).current;
|
|
6131
6189
|
const celebrationOpacity = useRef11(new Animated5.Value(0)).current;
|
|
6132
|
-
const [showCelebration, setShowCelebration] =
|
|
6133
|
-
|
|
6190
|
+
const [showCelebration, setShowCelebration] = useState31(false);
|
|
6191
|
+
useEffect19(() => {
|
|
6134
6192
|
Animated5.timing(overlayOpacity, {
|
|
6135
6193
|
toValue: visible ? 1 : 0,
|
|
6136
6194
|
duration: 250,
|
|
6137
6195
|
useNativeDriver: true
|
|
6138
6196
|
}).start();
|
|
6139
6197
|
}, [visible, overlayOpacity]);
|
|
6140
|
-
|
|
6198
|
+
useEffect19(() => {
|
|
6141
6199
|
if (visible) {
|
|
6142
6200
|
mutation.reset();
|
|
6143
6201
|
setShowCelebration(false);
|
|
@@ -6145,7 +6203,7 @@ function ClaimPrizeSheet({
|
|
|
6145
6203
|
celebrationOpacity.setValue(0);
|
|
6146
6204
|
}
|
|
6147
6205
|
}, [visible]);
|
|
6148
|
-
|
|
6206
|
+
useEffect19(() => {
|
|
6149
6207
|
if (mutation.status === "success" && mutation.data) {
|
|
6150
6208
|
setShowCelebration(true);
|
|
6151
6209
|
Animated5.parallel([
|
|
@@ -6168,14 +6226,14 @@ function ClaimPrizeSheet({
|
|
|
6168
6226
|
return () => clearTimeout(timer);
|
|
6169
6227
|
}
|
|
6170
6228
|
}, [mutation.status, mutation.data]);
|
|
6171
|
-
|
|
6229
|
+
useEffect19(() => {
|
|
6172
6230
|
if (mutation.status === "error" && mutation.error) {
|
|
6173
6231
|
onError?.(mutation.error);
|
|
6174
6232
|
}
|
|
6175
6233
|
}, [mutation.status, mutation.error]);
|
|
6176
6234
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6177
6235
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
6178
|
-
const handleClaim =
|
|
6236
|
+
const handleClaim = useCallback26(async () => {
|
|
6179
6237
|
if (!wallet.publicKey) return;
|
|
6180
6238
|
try {
|
|
6181
6239
|
await mutation.execute({
|
|
@@ -6408,7 +6466,7 @@ var styles16 = StyleSheet17.create({
|
|
|
6408
6466
|
});
|
|
6409
6467
|
|
|
6410
6468
|
// src/ui/game/ClaimButton.tsx
|
|
6411
|
-
import { useState as
|
|
6469
|
+
import { useState as useState32, useMemo as useMemo10, useCallback as useCallback27 } from "react";
|
|
6412
6470
|
import { StyleSheet as StyleSheet18, Text as Text18, TouchableOpacity as TouchableOpacity13 } from "react-native";
|
|
6413
6471
|
import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6414
6472
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -6416,7 +6474,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6416
6474
|
const { wallet } = useDubs();
|
|
6417
6475
|
const game = useGame(gameId);
|
|
6418
6476
|
const claimStatus = useHasClaimed(gameId);
|
|
6419
|
-
const [sheetVisible, setSheetVisible] =
|
|
6477
|
+
const [sheetVisible, setSheetVisible] = useState32(false);
|
|
6420
6478
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
6421
6479
|
const myBet = useMemo10(() => {
|
|
6422
6480
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
@@ -6427,7 +6485,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6427
6485
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
6428
6486
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
6429
6487
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
6430
|
-
const handleSuccess =
|
|
6488
|
+
const handleSuccess = useCallback27(
|
|
6431
6489
|
(result) => {
|
|
6432
6490
|
claimStatus.refetch();
|
|
6433
6491
|
onSuccess?.(result);
|
|
@@ -6514,7 +6572,7 @@ var styles17 = StyleSheet18.create({
|
|
|
6514
6572
|
});
|
|
6515
6573
|
|
|
6516
6574
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
6517
|
-
import { useEffect as
|
|
6575
|
+
import { useEffect as useEffect20, useRef as useRef12, useCallback as useCallback28 } from "react";
|
|
6518
6576
|
import {
|
|
6519
6577
|
View as View18,
|
|
6520
6578
|
Text as Text19,
|
|
@@ -6546,19 +6604,19 @@ function EnterArcadePoolSheet({
|
|
|
6546
6604
|
const { wallet } = useDubs();
|
|
6547
6605
|
const mutation = useEnterArcadePool();
|
|
6548
6606
|
const overlayOpacity = useRef12(new Animated6.Value(0)).current;
|
|
6549
|
-
|
|
6607
|
+
useEffect20(() => {
|
|
6550
6608
|
Animated6.timing(overlayOpacity, {
|
|
6551
6609
|
toValue: visible ? 1 : 0,
|
|
6552
6610
|
duration: 250,
|
|
6553
6611
|
useNativeDriver: true
|
|
6554
6612
|
}).start();
|
|
6555
6613
|
}, [visible, overlayOpacity]);
|
|
6556
|
-
|
|
6614
|
+
useEffect20(() => {
|
|
6557
6615
|
if (visible) {
|
|
6558
6616
|
mutation.reset();
|
|
6559
6617
|
}
|
|
6560
6618
|
}, [visible]);
|
|
6561
|
-
|
|
6619
|
+
useEffect20(() => {
|
|
6562
6620
|
if (mutation.status === "success" && mutation.data) {
|
|
6563
6621
|
onSuccess?.(mutation.data);
|
|
6564
6622
|
const timer = setTimeout(() => {
|
|
@@ -6567,7 +6625,7 @@ function EnterArcadePoolSheet({
|
|
|
6567
6625
|
return () => clearTimeout(timer);
|
|
6568
6626
|
}
|
|
6569
6627
|
}, [mutation.status, mutation.data]);
|
|
6570
|
-
|
|
6628
|
+
useEffect20(() => {
|
|
6571
6629
|
if (mutation.status === "error" && mutation.error) {
|
|
6572
6630
|
onError?.(mutation.error);
|
|
6573
6631
|
}
|
|
@@ -6579,7 +6637,7 @@ function EnterArcadePoolSheet({
|
|
|
6579
6637
|
const potSol = (pool.buy_in_lamports * Number(totalBuyIns) / 1e9).toFixed(4);
|
|
6580
6638
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6581
6639
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
6582
|
-
const handleJoin =
|
|
6640
|
+
const handleJoin = useCallback28(async () => {
|
|
6583
6641
|
if (!wallet.publicKey) return;
|
|
6584
6642
|
try {
|
|
6585
6643
|
await mutation.execute(pool.id);
|
|
@@ -6730,7 +6788,7 @@ var styles18 = StyleSheet19.create({
|
|
|
6730
6788
|
});
|
|
6731
6789
|
|
|
6732
6790
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
6733
|
-
import { useEffect as
|
|
6791
|
+
import { useEffect as useEffect21, useRef as useRef13 } from "react";
|
|
6734
6792
|
import {
|
|
6735
6793
|
View as View19,
|
|
6736
6794
|
Text as Text20,
|
|
@@ -6759,14 +6817,14 @@ function ArcadeLeaderboardSheet({
|
|
|
6759
6817
|
const t = useDubsTheme();
|
|
6760
6818
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
6761
6819
|
const overlayOpacity = useRef13(new Animated7.Value(0)).current;
|
|
6762
|
-
|
|
6820
|
+
useEffect21(() => {
|
|
6763
6821
|
Animated7.timing(overlayOpacity, {
|
|
6764
6822
|
toValue: visible ? 1 : 0,
|
|
6765
6823
|
duration: 250,
|
|
6766
6824
|
useNativeDriver: true
|
|
6767
6825
|
}).start();
|
|
6768
6826
|
}, [visible, overlayOpacity]);
|
|
6769
|
-
|
|
6827
|
+
useEffect21(() => {
|
|
6770
6828
|
if (visible) refetch();
|
|
6771
6829
|
}, [visible]);
|
|
6772
6830
|
const renderItem = ({ item, index }) => {
|
|
@@ -6913,7 +6971,7 @@ var styles19 = StyleSheet20.create({
|
|
|
6913
6971
|
});
|
|
6914
6972
|
|
|
6915
6973
|
// src/ui/game/CreateGameSheet.tsx
|
|
6916
|
-
import { useState as
|
|
6974
|
+
import { useState as useState34, useEffect as useEffect22, useRef as useRef14, useCallback as useCallback29 } from "react";
|
|
6917
6975
|
import {
|
|
6918
6976
|
View as View20,
|
|
6919
6977
|
Text as Text21,
|
|
@@ -6952,20 +7010,20 @@ function CreateGameSheet({
|
|
|
6952
7010
|
const t = useDubsTheme();
|
|
6953
7011
|
const { wallet } = useDubs();
|
|
6954
7012
|
const mutation = useCreateGame();
|
|
6955
|
-
const [selectedTeam, setSelectedTeam] =
|
|
6956
|
-
const [wager, setWager] =
|
|
6957
|
-
const [showSuccess, setShowSuccess] =
|
|
7013
|
+
const [selectedTeam, setSelectedTeam] = useState34(null);
|
|
7014
|
+
const [wager, setWager] = useState34(0.01);
|
|
7015
|
+
const [showSuccess, setShowSuccess] = useState34(false);
|
|
6958
7016
|
const overlayOpacity = useRef14(new Animated8.Value(0)).current;
|
|
6959
7017
|
const successScale = useRef14(new Animated8.Value(0)).current;
|
|
6960
7018
|
const successOpacity = useRef14(new Animated8.Value(0)).current;
|
|
6961
|
-
|
|
7019
|
+
useEffect22(() => {
|
|
6962
7020
|
Animated8.timing(overlayOpacity, {
|
|
6963
7021
|
toValue: visible ? 1 : 0,
|
|
6964
7022
|
duration: 250,
|
|
6965
7023
|
useNativeDriver: true
|
|
6966
7024
|
}).start();
|
|
6967
7025
|
}, [visible]);
|
|
6968
|
-
|
|
7026
|
+
useEffect22(() => {
|
|
6969
7027
|
if (visible) {
|
|
6970
7028
|
setSelectedTeam(null);
|
|
6971
7029
|
setWager(0.01);
|
|
@@ -6975,7 +7033,7 @@ function CreateGameSheet({
|
|
|
6975
7033
|
mutation.reset();
|
|
6976
7034
|
}
|
|
6977
7035
|
}, [visible]);
|
|
6978
|
-
|
|
7036
|
+
useEffect22(() => {
|
|
6979
7037
|
if (mutation.status === "success" && mutation.data) {
|
|
6980
7038
|
setShowSuccess(true);
|
|
6981
7039
|
onSuccess?.(mutation.data);
|
|
@@ -6992,7 +7050,7 @@ function CreateGameSheet({
|
|
|
6992
7050
|
return () => clearTimeout(timer);
|
|
6993
7051
|
}
|
|
6994
7052
|
}, [mutation.status, mutation.data]);
|
|
6995
|
-
|
|
7053
|
+
useEffect22(() => {
|
|
6996
7054
|
if (mutation.status === "error" && mutation.error) {
|
|
6997
7055
|
onError?.(mutation.error);
|
|
6998
7056
|
}
|
|
@@ -7002,7 +7060,7 @@ function CreateGameSheet({
|
|
|
7002
7060
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
7003
7061
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7004
7062
|
const canCreate = selectedTeam !== null && !isMutating && mutation.status !== "success";
|
|
7005
|
-
const handleCreate =
|
|
7063
|
+
const handleCreate = useCallback29(async () => {
|
|
7006
7064
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
7007
7065
|
try {
|
|
7008
7066
|
await mutation.execute({
|
|
@@ -7202,6 +7260,7 @@ export {
|
|
|
7202
7260
|
useGame,
|
|
7203
7261
|
useGames,
|
|
7204
7262
|
useHasClaimed,
|
|
7263
|
+
useHighlights,
|
|
7205
7264
|
useJoinGame,
|
|
7206
7265
|
useNetworkGames,
|
|
7207
7266
|
usePushNotifications,
|