@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.js
CHANGED
|
@@ -83,6 +83,7 @@ __export(index_exports, {
|
|
|
83
83
|
useGame: () => useGame,
|
|
84
84
|
useGames: () => useGames,
|
|
85
85
|
useHasClaimed: () => useHasClaimed,
|
|
86
|
+
useHighlights: () => useHighlights,
|
|
86
87
|
useJoinGame: () => useJoinGame,
|
|
87
88
|
useNetworkGames: () => useNetworkGames,
|
|
88
89
|
usePushNotifications: () => usePushNotifications,
|
|
@@ -731,7 +732,7 @@ function createSecureStoreStorage() {
|
|
|
731
732
|
}
|
|
732
733
|
|
|
733
734
|
// src/provider.tsx
|
|
734
|
-
var
|
|
735
|
+
var import_react25 = require("react");
|
|
735
736
|
|
|
736
737
|
// src/ui/theme.ts
|
|
737
738
|
var import_react = require("react");
|
|
@@ -1789,7 +1790,7 @@ function ManagedWalletProvider({
|
|
|
1789
1790
|
}
|
|
1790
1791
|
|
|
1791
1792
|
// src/ui/AuthGate.tsx
|
|
1792
|
-
var
|
|
1793
|
+
var import_react24 = __toESM(require("react"));
|
|
1793
1794
|
var import_react_native8 = require("react-native");
|
|
1794
1795
|
|
|
1795
1796
|
// src/hooks/useEvents.ts
|
|
@@ -2479,25 +2480,53 @@ function useUFCFighterDetail(athleteId) {
|
|
|
2479
2480
|
return { data, loading, error, refetch: fetchData };
|
|
2480
2481
|
}
|
|
2481
2482
|
|
|
2482
|
-
// src/hooks/
|
|
2483
|
+
// src/hooks/useHighlights.ts
|
|
2483
2484
|
var import_react16 = require("react");
|
|
2485
|
+
function useHighlights(league, limit = 8) {
|
|
2486
|
+
const { client } = useDubs();
|
|
2487
|
+
const [data, setData] = (0, import_react16.useState)(null);
|
|
2488
|
+
const [loading, setLoading] = (0, import_react16.useState)(true);
|
|
2489
|
+
const [error, setError] = (0, import_react16.useState)(null);
|
|
2490
|
+
const fetchData = (0, import_react16.useCallback)(async () => {
|
|
2491
|
+
setLoading(true);
|
|
2492
|
+
setError(null);
|
|
2493
|
+
try {
|
|
2494
|
+
const qs = new URLSearchParams();
|
|
2495
|
+
if (league) qs.set("league", league);
|
|
2496
|
+
qs.set("limit", String(limit));
|
|
2497
|
+
const res = await client.request("GET", `/highlights?${qs.toString()}`);
|
|
2498
|
+
setData(res.videos || []);
|
|
2499
|
+
} catch (err) {
|
|
2500
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
2501
|
+
} finally {
|
|
2502
|
+
setLoading(false);
|
|
2503
|
+
}
|
|
2504
|
+
}, [client, league, limit]);
|
|
2505
|
+
(0, import_react16.useEffect)(() => {
|
|
2506
|
+
fetchData();
|
|
2507
|
+
}, [fetchData]);
|
|
2508
|
+
return { data, loading, error, refetch: fetchData };
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
// src/hooks/usePushNotifications.ts
|
|
2512
|
+
var import_react17 = require("react");
|
|
2484
2513
|
var import_react_native6 = require("react-native");
|
|
2485
2514
|
function usePushNotifications() {
|
|
2486
2515
|
const { client, appName, pushEnabled } = useDubs();
|
|
2487
|
-
const channelId = (0,
|
|
2488
|
-
const [hasPermission, setHasPermission] = (0,
|
|
2489
|
-
const [pushToken, setPushToken] = (0,
|
|
2490
|
-
const [loading, setLoading] = (0,
|
|
2491
|
-
const [error, setError] = (0,
|
|
2492
|
-
const registering = (0,
|
|
2493
|
-
const getNotificationsModule = (0,
|
|
2516
|
+
const channelId = (0, import_react17.useMemo)(() => appName.toLowerCase().replace(/[^a-z0-9-]/g, ""), [appName]);
|
|
2517
|
+
const [hasPermission, setHasPermission] = (0, import_react17.useState)(false);
|
|
2518
|
+
const [pushToken, setPushToken] = (0, import_react17.useState)(null);
|
|
2519
|
+
const [loading, setLoading] = (0, import_react17.useState)(false);
|
|
2520
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
2521
|
+
const registering = (0, import_react17.useRef)(false);
|
|
2522
|
+
const getNotificationsModule = (0, import_react17.useCallback)(() => {
|
|
2494
2523
|
try {
|
|
2495
2524
|
return require("expo-notifications");
|
|
2496
2525
|
} catch {
|
|
2497
2526
|
return null;
|
|
2498
2527
|
}
|
|
2499
2528
|
}, []);
|
|
2500
|
-
const getDeviceName = (0,
|
|
2529
|
+
const getDeviceName = (0, import_react17.useCallback)(() => {
|
|
2501
2530
|
try {
|
|
2502
2531
|
const Device = require("expo-device");
|
|
2503
2532
|
return Device.deviceName || null;
|
|
@@ -2505,7 +2534,7 @@ function usePushNotifications() {
|
|
|
2505
2534
|
return null;
|
|
2506
2535
|
}
|
|
2507
2536
|
}, []);
|
|
2508
|
-
const setupAndroidChannels = (0,
|
|
2537
|
+
const setupAndroidChannels = (0, import_react17.useCallback)((Notifications) => {
|
|
2509
2538
|
if (import_react_native6.Platform.OS === "android") {
|
|
2510
2539
|
Notifications.setNotificationChannelAsync(channelId || "default", {
|
|
2511
2540
|
name: appName || "Default",
|
|
@@ -2515,7 +2544,7 @@ function usePushNotifications() {
|
|
|
2515
2544
|
});
|
|
2516
2545
|
}
|
|
2517
2546
|
}, [channelId, appName]);
|
|
2518
|
-
const registerTokenWithServer = (0,
|
|
2547
|
+
const registerTokenWithServer = (0, import_react17.useCallback)(async (token) => {
|
|
2519
2548
|
const deviceName = getDeviceName();
|
|
2520
2549
|
await client.registerPushToken({
|
|
2521
2550
|
token,
|
|
@@ -2523,7 +2552,7 @@ function usePushNotifications() {
|
|
|
2523
2552
|
deviceName: deviceName || void 0
|
|
2524
2553
|
});
|
|
2525
2554
|
}, [client, getDeviceName]);
|
|
2526
|
-
const register = (0,
|
|
2555
|
+
const register = (0, import_react17.useCallback)(async () => {
|
|
2527
2556
|
if (!pushEnabled) return false;
|
|
2528
2557
|
if (registering.current) return false;
|
|
2529
2558
|
registering.current = true;
|
|
@@ -2564,7 +2593,7 @@ function usePushNotifications() {
|
|
|
2564
2593
|
return false;
|
|
2565
2594
|
}
|
|
2566
2595
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2567
|
-
const unregister = (0,
|
|
2596
|
+
const unregister = (0, import_react17.useCallback)(async () => {
|
|
2568
2597
|
if (!pushToken) return;
|
|
2569
2598
|
try {
|
|
2570
2599
|
await client.unregisterPushToken(pushToken);
|
|
@@ -2573,7 +2602,7 @@ function usePushNotifications() {
|
|
|
2573
2602
|
console.error("[usePushNotifications] Unregister error:", err);
|
|
2574
2603
|
}
|
|
2575
2604
|
}, [client, pushToken]);
|
|
2576
|
-
const restoreIfGranted = (0,
|
|
2605
|
+
const restoreIfGranted = (0, import_react17.useCallback)(async () => {
|
|
2577
2606
|
if (!pushEnabled) return;
|
|
2578
2607
|
try {
|
|
2579
2608
|
const Notifications = getNotificationsModule();
|
|
@@ -2591,8 +2620,8 @@ function usePushNotifications() {
|
|
|
2591
2620
|
console.log("[usePushNotifications] Restore skipped:", err instanceof Error ? err.message : err);
|
|
2592
2621
|
}
|
|
2593
2622
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2594
|
-
const didMount = (0,
|
|
2595
|
-
(0,
|
|
2623
|
+
const didMount = (0, import_react17.useRef)(false);
|
|
2624
|
+
(0, import_react17.useEffect)(() => {
|
|
2596
2625
|
if (didMount.current) return;
|
|
2597
2626
|
didMount.current = true;
|
|
2598
2627
|
const Notifications = getNotificationsModule();
|
|
@@ -2622,13 +2651,13 @@ function usePushNotifications() {
|
|
|
2622
2651
|
}
|
|
2623
2652
|
|
|
2624
2653
|
// src/hooks/useArcadePools.ts
|
|
2625
|
-
var
|
|
2654
|
+
var import_react18 = require("react");
|
|
2626
2655
|
function useArcadePools(gameSlug) {
|
|
2627
2656
|
const { client } = useDubs();
|
|
2628
|
-
const [pools, setPools] = (0,
|
|
2629
|
-
const [loading, setLoading] = (0,
|
|
2630
|
-
const [error, setError] = (0,
|
|
2631
|
-
const fetch2 = (0,
|
|
2657
|
+
const [pools, setPools] = (0, import_react18.useState)([]);
|
|
2658
|
+
const [loading, setLoading] = (0, import_react18.useState)(false);
|
|
2659
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
2660
|
+
const fetch2 = (0, import_react18.useCallback)(async () => {
|
|
2632
2661
|
setLoading(true);
|
|
2633
2662
|
setError(null);
|
|
2634
2663
|
try {
|
|
@@ -2640,22 +2669,22 @@ function useArcadePools(gameSlug) {
|
|
|
2640
2669
|
setLoading(false);
|
|
2641
2670
|
}
|
|
2642
2671
|
}, [client, gameSlug]);
|
|
2643
|
-
(0,
|
|
2672
|
+
(0, import_react18.useEffect)(() => {
|
|
2644
2673
|
fetch2();
|
|
2645
2674
|
}, [fetch2]);
|
|
2646
2675
|
return { pools, loading, error, refetch: fetch2 };
|
|
2647
2676
|
}
|
|
2648
2677
|
|
|
2649
2678
|
// src/hooks/useArcadePool.ts
|
|
2650
|
-
var
|
|
2679
|
+
var import_react19 = require("react");
|
|
2651
2680
|
function useArcadePool(poolId) {
|
|
2652
2681
|
const { client } = useDubs();
|
|
2653
|
-
const [pool, setPool] = (0,
|
|
2654
|
-
const [stats, setStats] = (0,
|
|
2655
|
-
const [leaderboard, setLeaderboard] = (0,
|
|
2656
|
-
const [loading, setLoading] = (0,
|
|
2657
|
-
const [error, setError] = (0,
|
|
2658
|
-
const fetch2 = (0,
|
|
2682
|
+
const [pool, setPool] = (0, import_react19.useState)(null);
|
|
2683
|
+
const [stats, setStats] = (0, import_react19.useState)(null);
|
|
2684
|
+
const [leaderboard, setLeaderboard] = (0, import_react19.useState)([]);
|
|
2685
|
+
const [loading, setLoading] = (0, import_react19.useState)(false);
|
|
2686
|
+
const [error, setError] = (0, import_react19.useState)(null);
|
|
2687
|
+
const fetch2 = (0, import_react19.useCallback)(async () => {
|
|
2659
2688
|
if (!poolId) return;
|
|
2660
2689
|
setLoading(true);
|
|
2661
2690
|
setError(null);
|
|
@@ -2673,22 +2702,22 @@ function useArcadePool(poolId) {
|
|
|
2673
2702
|
setLoading(false);
|
|
2674
2703
|
}
|
|
2675
2704
|
}, [client, poolId]);
|
|
2676
|
-
(0,
|
|
2705
|
+
(0, import_react19.useEffect)(() => {
|
|
2677
2706
|
fetch2();
|
|
2678
2707
|
}, [fetch2]);
|
|
2679
2708
|
return { pool, stats, leaderboard, loading, error, refetch: fetch2 };
|
|
2680
2709
|
}
|
|
2681
2710
|
|
|
2682
2711
|
// src/hooks/useArcadeGame.ts
|
|
2683
|
-
var
|
|
2712
|
+
var import_react20 = require("react");
|
|
2684
2713
|
function useArcadeGame(poolId, maxLives = 3) {
|
|
2685
2714
|
const { client } = useDubs();
|
|
2686
2715
|
const { user } = useAuth();
|
|
2687
|
-
const [entry, setEntry] = (0,
|
|
2688
|
-
const [loading, setLoading] = (0,
|
|
2689
|
-
const [error, setError] = (0,
|
|
2716
|
+
const [entry, setEntry] = (0, import_react20.useState)(null);
|
|
2717
|
+
const [loading, setLoading] = (0, import_react20.useState)(false);
|
|
2718
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
2690
2719
|
const walletAddress = user?.walletAddress || "";
|
|
2691
|
-
const refreshEntry = (0,
|
|
2720
|
+
const refreshEntry = (0, import_react20.useCallback)(async () => {
|
|
2692
2721
|
if (!poolId || !walletAddress) return;
|
|
2693
2722
|
setLoading(true);
|
|
2694
2723
|
setError(null);
|
|
@@ -2705,7 +2734,7 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2705
2734
|
setLoading(false);
|
|
2706
2735
|
}
|
|
2707
2736
|
}, [client, poolId, walletAddress]);
|
|
2708
|
-
const startAttempt = (0,
|
|
2737
|
+
const startAttempt = (0, import_react20.useCallback)(async () => {
|
|
2709
2738
|
if (!poolId || !walletAddress) throw new Error("Not ready");
|
|
2710
2739
|
setError(null);
|
|
2711
2740
|
try {
|
|
@@ -2717,7 +2746,7 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2717
2746
|
throw e;
|
|
2718
2747
|
}
|
|
2719
2748
|
}, [client, poolId, walletAddress]);
|
|
2720
|
-
const submitScore = (0,
|
|
2749
|
+
const submitScore = (0, import_react20.useCallback)(async (sessionToken, score, durationMs) => {
|
|
2721
2750
|
if (!poolId || !walletAddress) throw new Error("Not ready");
|
|
2722
2751
|
setError(null);
|
|
2723
2752
|
try {
|
|
@@ -2754,19 +2783,19 @@ function useArcadeGame(poolId, maxLives = 3) {
|
|
|
2754
2783
|
}
|
|
2755
2784
|
|
|
2756
2785
|
// src/hooks/useEnterArcadePool.ts
|
|
2757
|
-
var
|
|
2786
|
+
var import_react21 = require("react");
|
|
2758
2787
|
function useEnterArcadePool() {
|
|
2759
2788
|
const { client, wallet, connection } = useDubs();
|
|
2760
2789
|
const { user } = useAuth();
|
|
2761
|
-
const [status, setStatus] = (0,
|
|
2762
|
-
const [error, setError] = (0,
|
|
2763
|
-
const [data, setData] = (0,
|
|
2764
|
-
const reset = (0,
|
|
2790
|
+
const [status, setStatus] = (0, import_react21.useState)("idle");
|
|
2791
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
2792
|
+
const [data, setData] = (0, import_react21.useState)(null);
|
|
2793
|
+
const reset = (0, import_react21.useCallback)(() => {
|
|
2765
2794
|
setStatus("idle");
|
|
2766
2795
|
setError(null);
|
|
2767
2796
|
setData(null);
|
|
2768
2797
|
}, []);
|
|
2769
|
-
const execute = (0,
|
|
2798
|
+
const execute = (0, import_react21.useCallback)(async (poolId) => {
|
|
2770
2799
|
if (!wallet.publicKey) throw new Error("Wallet not connected");
|
|
2771
2800
|
const walletAddress = wallet.publicKey.toBase58();
|
|
2772
2801
|
setStatus("building");
|
|
@@ -2814,7 +2843,7 @@ function useEnterArcadePool() {
|
|
|
2814
2843
|
}
|
|
2815
2844
|
|
|
2816
2845
|
// src/hooks/useArcadeCountdown.ts
|
|
2817
|
-
var
|
|
2846
|
+
var import_react22 = require("react");
|
|
2818
2847
|
function formatCountdown(ms) {
|
|
2819
2848
|
if (ms <= 0) return "Ended";
|
|
2820
2849
|
const s2 = Math.floor(ms / 1e3);
|
|
@@ -2827,9 +2856,9 @@ function formatCountdown(ms) {
|
|
|
2827
2856
|
return `${s2}s`;
|
|
2828
2857
|
}
|
|
2829
2858
|
function useArcadeCountdown(nextResolution) {
|
|
2830
|
-
const [now, setNow] = (0,
|
|
2831
|
-
const intervalRef = (0,
|
|
2832
|
-
(0,
|
|
2859
|
+
const [now, setNow] = (0, import_react22.useState)(Date.now());
|
|
2860
|
+
const intervalRef = (0, import_react22.useRef)(null);
|
|
2861
|
+
(0, import_react22.useEffect)(() => {
|
|
2833
2862
|
if (!nextResolution) return;
|
|
2834
2863
|
intervalRef.current = setInterval(() => setNow(Date.now()), 1e3);
|
|
2835
2864
|
return () => {
|
|
@@ -2858,7 +2887,7 @@ function useArcadeCountdown(nextResolution) {
|
|
|
2858
2887
|
}
|
|
2859
2888
|
|
|
2860
2889
|
// src/hooks/useArcadeBridge.ts
|
|
2861
|
-
var
|
|
2890
|
+
var import_react23 = require("react");
|
|
2862
2891
|
var PROTOCOL_VERSION = "1.0";
|
|
2863
2892
|
function useArcadeBridge({
|
|
2864
2893
|
canPlay,
|
|
@@ -2868,14 +2897,14 @@ function useArcadeBridge({
|
|
|
2868
2897
|
onScoreSubmitted,
|
|
2869
2898
|
onError
|
|
2870
2899
|
}) {
|
|
2871
|
-
const webviewRef = (0,
|
|
2872
|
-
const sessionTokenRef = (0,
|
|
2873
|
-
const gameStartTimeRef = (0,
|
|
2874
|
-
const canPlayRef = (0,
|
|
2900
|
+
const webviewRef = (0, import_react23.useRef)(null);
|
|
2901
|
+
const sessionTokenRef = (0, import_react23.useRef)(null);
|
|
2902
|
+
const gameStartTimeRef = (0, import_react23.useRef)(0);
|
|
2903
|
+
const canPlayRef = (0, import_react23.useRef)(canPlay);
|
|
2875
2904
|
canPlayRef.current = canPlay;
|
|
2876
|
-
const [lastResult, setLastResult] = (0,
|
|
2877
|
-
const [bridgeLoading, setBridgeLoading] = (0,
|
|
2878
|
-
const injectSession = (0,
|
|
2905
|
+
const [lastResult, setLastResult] = (0, import_react23.useState)(null);
|
|
2906
|
+
const [bridgeLoading, setBridgeLoading] = (0, import_react23.useState)(false);
|
|
2907
|
+
const injectSession = (0, import_react23.useCallback)((token, attemptNumber) => {
|
|
2879
2908
|
webviewRef.current?.injectJavaScript(`
|
|
2880
2909
|
window.ARCADE_SESSION_TOKEN = ${JSON.stringify(token)};
|
|
2881
2910
|
window.ARCADE_ATTEMPT_NUMBER = ${attemptNumber};
|
|
@@ -2884,7 +2913,7 @@ function useArcadeBridge({
|
|
|
2884
2913
|
true;
|
|
2885
2914
|
`);
|
|
2886
2915
|
}, []);
|
|
2887
|
-
const triggerPlay = (0,
|
|
2916
|
+
const triggerPlay = (0, import_react23.useCallback)(async () => {
|
|
2888
2917
|
if (!canPlay) return;
|
|
2889
2918
|
setBridgeLoading(true);
|
|
2890
2919
|
try {
|
|
@@ -2901,7 +2930,7 @@ function useArcadeBridge({
|
|
|
2901
2930
|
setBridgeLoading(false);
|
|
2902
2931
|
}
|
|
2903
2932
|
}, [canPlay, startAttempt, injectSession, onPlayStarted, onError]);
|
|
2904
|
-
const handleMessage = (0,
|
|
2933
|
+
const handleMessage = (0, import_react23.useCallback)(
|
|
2905
2934
|
async (event) => {
|
|
2906
2935
|
let data;
|
|
2907
2936
|
try {
|
|
@@ -3107,11 +3136,11 @@ function AuthGate({
|
|
|
3107
3136
|
}) {
|
|
3108
3137
|
const { client, pushEnabled } = useDubs();
|
|
3109
3138
|
const auth = useAuth();
|
|
3110
|
-
const [phase, setPhase] = (0,
|
|
3111
|
-
const [registrationPhase, setRegistrationPhase] = (0,
|
|
3112
|
-
const [showPushSetup, setShowPushSetup] = (0,
|
|
3113
|
-
const [isRestoredSession, setIsRestoredSession] = (0,
|
|
3114
|
-
(0,
|
|
3139
|
+
const [phase, setPhase] = (0, import_react24.useState)("init");
|
|
3140
|
+
const [registrationPhase, setRegistrationPhase] = (0, import_react24.useState)(false);
|
|
3141
|
+
const [showPushSetup, setShowPushSetup] = (0, import_react24.useState)(false);
|
|
3142
|
+
const [isRestoredSession, setIsRestoredSession] = (0, import_react24.useState)(false);
|
|
3143
|
+
(0, import_react24.useEffect)(() => {
|
|
3115
3144
|
let cancelled = false;
|
|
3116
3145
|
(async () => {
|
|
3117
3146
|
try {
|
|
@@ -3138,23 +3167,23 @@ function AuthGate({
|
|
|
3138
3167
|
cancelled = true;
|
|
3139
3168
|
};
|
|
3140
3169
|
}, []);
|
|
3141
|
-
(0,
|
|
3170
|
+
(0, import_react24.useEffect)(() => {
|
|
3142
3171
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
3143
3172
|
}, [auth.status]);
|
|
3144
|
-
(0,
|
|
3173
|
+
(0, import_react24.useEffect)(() => {
|
|
3145
3174
|
if (pushEnabled && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
3146
3175
|
setShowPushSetup(true);
|
|
3147
3176
|
}
|
|
3148
3177
|
}, [pushEnabled, auth.status, registrationPhase, isRestoredSession]);
|
|
3149
|
-
(0,
|
|
3178
|
+
(0, import_react24.useEffect)(() => {
|
|
3150
3179
|
if (auth.token) onSaveToken(auth.token);
|
|
3151
3180
|
}, [auth.token]);
|
|
3152
|
-
const retry = (0,
|
|
3181
|
+
const retry = (0, import_react24.useCallback)(() => {
|
|
3153
3182
|
setRegistrationPhase(false);
|
|
3154
3183
|
auth.reset();
|
|
3155
3184
|
auth.authenticate();
|
|
3156
3185
|
}, [auth]);
|
|
3157
|
-
const handleRegister = (0,
|
|
3186
|
+
const handleRegister = (0, import_react24.useCallback)(
|
|
3158
3187
|
(username, referralCode, avatarUrl) => {
|
|
3159
3188
|
auth.register(username, referralCode, avatarUrl);
|
|
3160
3189
|
},
|
|
@@ -3254,7 +3283,7 @@ function DefaultErrorScreen({ error, onRetry, appName, accentColor }) {
|
|
|
3254
3283
|
function StepIndicator({ currentStep }) {
|
|
3255
3284
|
const t = useDubsTheme();
|
|
3256
3285
|
const steps = [0, 1, 2, 3];
|
|
3257
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react24.default.Fragment, { children: [
|
|
3258
3287
|
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: [s.stepLine, { backgroundColor: i <= currentStep ? t.success : t.border }] }),
|
|
3259
3288
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3260
3289
|
import_react_native8.View,
|
|
@@ -3278,20 +3307,20 @@ function DefaultRegistrationScreen({
|
|
|
3278
3307
|
}) {
|
|
3279
3308
|
const t = useDubsTheme();
|
|
3280
3309
|
const accent = accentColor || t.accent;
|
|
3281
|
-
const [step, setStep] = (0,
|
|
3282
|
-
const [avatarSeed, setAvatarSeed] = (0,
|
|
3283
|
-
const [avatarStyle, setAvatarStyle] = (0,
|
|
3284
|
-
const [avatarBg, setAvatarBg] = (0,
|
|
3285
|
-
const [showStyles, setShowStyles] = (0,
|
|
3286
|
-
const [username, setUsername] = (0,
|
|
3287
|
-
const [referralCode, setReferralCode] = (0,
|
|
3288
|
-
const [checking, setChecking] = (0,
|
|
3289
|
-
const [availability, setAvailability] = (0,
|
|
3290
|
-
const debounceRef = (0,
|
|
3291
|
-
const fadeAnim = (0,
|
|
3292
|
-
const slideAnim = (0,
|
|
3310
|
+
const [step, setStep] = (0, import_react24.useState)(0);
|
|
3311
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react24.useState)(generateSeed);
|
|
3312
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react24.useState)("adventurer");
|
|
3313
|
+
const [avatarBg, setAvatarBg] = (0, import_react24.useState)("1a1a2e");
|
|
3314
|
+
const [showStyles, setShowStyles] = (0, import_react24.useState)(false);
|
|
3315
|
+
const [username, setUsername] = (0, import_react24.useState)("");
|
|
3316
|
+
const [referralCode, setReferralCode] = (0, import_react24.useState)("");
|
|
3317
|
+
const [checking, setChecking] = (0, import_react24.useState)(false);
|
|
3318
|
+
const [availability, setAvailability] = (0, import_react24.useState)(null);
|
|
3319
|
+
const debounceRef = (0, import_react24.useRef)(null);
|
|
3320
|
+
const fadeAnim = (0, import_react24.useRef)(new import_react_native8.Animated.Value(1)).current;
|
|
3321
|
+
const slideAnim = (0, import_react24.useRef)(new import_react_native8.Animated.Value(0)).current;
|
|
3293
3322
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3294
|
-
(0,
|
|
3323
|
+
(0, import_react24.useEffect)(() => {
|
|
3295
3324
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3296
3325
|
const trimmed = username.trim();
|
|
3297
3326
|
if (trimmed.length < 3) {
|
|
@@ -3314,7 +3343,7 @@ function DefaultRegistrationScreen({
|
|
|
3314
3343
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3315
3344
|
};
|
|
3316
3345
|
}, [username, client]);
|
|
3317
|
-
const animateToStep = (0,
|
|
3346
|
+
const animateToStep = (0, import_react24.useCallback)((newStep) => {
|
|
3318
3347
|
const dir = newStep > step ? 1 : -1;
|
|
3319
3348
|
import_react_native8.Keyboard.dismiss();
|
|
3320
3349
|
import_react_native8.Animated.parallel([
|
|
@@ -3553,8 +3582,8 @@ function DefaultRegistrationScreen({
|
|
|
3553
3582
|
}
|
|
3554
3583
|
function PushTokenRestorer() {
|
|
3555
3584
|
const push = usePushNotifications();
|
|
3556
|
-
const restored = (0,
|
|
3557
|
-
(0,
|
|
3585
|
+
const restored = (0, import_react24.useRef)(false);
|
|
3586
|
+
(0, import_react24.useEffect)(() => {
|
|
3558
3587
|
if (restored.current) return;
|
|
3559
3588
|
restored.current = true;
|
|
3560
3589
|
push.restoreIfGranted();
|
|
@@ -3569,9 +3598,9 @@ function PushSetupScreen({
|
|
|
3569
3598
|
const t = useDubsTheme();
|
|
3570
3599
|
const accent = accentColor || t.accent;
|
|
3571
3600
|
const push = usePushNotifications();
|
|
3572
|
-
const fadeAnim = (0,
|
|
3573
|
-
const slideAnim = (0,
|
|
3574
|
-
(0,
|
|
3601
|
+
const fadeAnim = (0, import_react24.useRef)(new import_react_native8.Animated.Value(0)).current;
|
|
3602
|
+
const slideAnim = (0, import_react24.useRef)(new import_react_native8.Animated.Value(30)).current;
|
|
3603
|
+
(0, import_react24.useEffect)(() => {
|
|
3575
3604
|
import_react_native8.Animated.parallel([
|
|
3576
3605
|
import_react_native8.Animated.timing(fadeAnim, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
3577
3606
|
import_react_native8.Animated.timing(slideAnim, { toValue: 0, duration: 300, useNativeDriver: true })
|
|
@@ -3707,7 +3736,7 @@ var s = import_react_native8.StyleSheet.create({
|
|
|
3707
3736
|
|
|
3708
3737
|
// src/provider.tsx
|
|
3709
3738
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3710
|
-
var DubsContext = (0,
|
|
3739
|
+
var DubsContext = (0, import_react25.createContext)(null);
|
|
3711
3740
|
function DubsProvider({
|
|
3712
3741
|
apiKey,
|
|
3713
3742
|
children,
|
|
@@ -3729,11 +3758,11 @@ function DubsProvider({
|
|
|
3729
3758
|
const config = NETWORK_CONFIG[network];
|
|
3730
3759
|
const baseUrl = baseUrlOverride || config.baseUrl;
|
|
3731
3760
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
3732
|
-
const client = (0,
|
|
3733
|
-
const storage = (0,
|
|
3734
|
-
const [uiConfig, setUiConfig] = (0,
|
|
3735
|
-
const [resolvedNetwork, setResolvedNetwork] = (0,
|
|
3736
|
-
(0,
|
|
3761
|
+
const client = (0, import_react25.useMemo)(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
3762
|
+
const storage = (0, import_react25.useMemo)(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
3763
|
+
const [uiConfig, setUiConfig] = (0, import_react25.useState)(null);
|
|
3764
|
+
const [resolvedNetwork, setResolvedNetwork] = (0, import_react25.useState)(network);
|
|
3765
|
+
(0, import_react25.useEffect)(() => {
|
|
3737
3766
|
client.getAppConfig().then((cfg) => {
|
|
3738
3767
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
3739
3768
|
setUiConfig(cfg);
|
|
@@ -3749,7 +3778,7 @@ function DubsProvider({
|
|
|
3749
3778
|
const resolvedConfig = NETWORK_CONFIG[resolvedNetwork];
|
|
3750
3779
|
const resolvedRpcUrl = rpcUrlOverride || resolvedConfig.rpcUrl;
|
|
3751
3780
|
const cluster = resolvedConfig.cluster;
|
|
3752
|
-
const connection = (0,
|
|
3781
|
+
const connection = (0, import_react25.useMemo)(() => new import_web34.Connection(resolvedRpcUrl, { commitment: "confirmed" }), [resolvedRpcUrl]);
|
|
3753
3782
|
if (uiConfig === null) return null;
|
|
3754
3783
|
const themeOverrides = {};
|
|
3755
3784
|
if (uiConfig.accentColor) {
|
|
@@ -3825,11 +3854,11 @@ function ManagedInner({
|
|
|
3825
3854
|
children
|
|
3826
3855
|
}) {
|
|
3827
3856
|
const managedDisconnect = useDisconnect();
|
|
3828
|
-
const disconnect = (0,
|
|
3857
|
+
const disconnect = (0, import_react25.useCallback)(async () => {
|
|
3829
3858
|
client.setToken(null);
|
|
3830
3859
|
await managedDisconnect?.();
|
|
3831
3860
|
}, [client, managedDisconnect]);
|
|
3832
|
-
const value = (0,
|
|
3861
|
+
const value = (0, import_react25.useMemo)(
|
|
3833
3862
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
3834
3863
|
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
3835
3864
|
);
|
|
@@ -3866,13 +3895,13 @@ function ExternalWalletProvider({
|
|
|
3866
3895
|
pushEnabled,
|
|
3867
3896
|
children
|
|
3868
3897
|
}) {
|
|
3869
|
-
const disconnect = (0,
|
|
3898
|
+
const disconnect = (0, import_react25.useCallback)(async () => {
|
|
3870
3899
|
client.setToken(null);
|
|
3871
3900
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
3872
3901
|
});
|
|
3873
3902
|
await wallet.disconnect?.();
|
|
3874
3903
|
}, [client, storage, wallet]);
|
|
3875
|
-
const value = (0,
|
|
3904
|
+
const value = (0, import_react25.useMemo)(
|
|
3876
3905
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
3877
3906
|
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
3878
3907
|
);
|
|
@@ -3897,14 +3926,14 @@ function ExternalWalletProvider({
|
|
|
3897
3926
|
) });
|
|
3898
3927
|
}
|
|
3899
3928
|
function useDubs() {
|
|
3900
|
-
const ctx = (0,
|
|
3929
|
+
const ctx = (0, import_react25.useContext)(DubsContext);
|
|
3901
3930
|
if (!ctx) {
|
|
3902
3931
|
throw new Error("useDubs must be used within a <DubsProvider>");
|
|
3903
3932
|
}
|
|
3904
3933
|
return ctx;
|
|
3905
3934
|
}
|
|
3906
3935
|
function useAppConfig() {
|
|
3907
|
-
const ctx = (0,
|
|
3936
|
+
const ctx = (0, import_react25.useContext)(DubsContext);
|
|
3908
3937
|
return ctx?.uiConfig || {};
|
|
3909
3938
|
}
|
|
3910
3939
|
|
|
@@ -3962,7 +3991,7 @@ var styles3 = import_react_native9.StyleSheet.create({
|
|
|
3962
3991
|
});
|
|
3963
3992
|
|
|
3964
3993
|
// src/ui/UserProfileCard.tsx
|
|
3965
|
-
var
|
|
3994
|
+
var import_react26 = require("react");
|
|
3966
3995
|
var import_react_native10 = require("react-native");
|
|
3967
3996
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3968
3997
|
function truncateAddress(address, chars = 4) {
|
|
@@ -3982,7 +4011,7 @@ function UserProfileCard({
|
|
|
3982
4011
|
memberSince
|
|
3983
4012
|
}) {
|
|
3984
4013
|
const t = useDubsTheme();
|
|
3985
|
-
const imageUri = (0,
|
|
4014
|
+
const imageUri = (0, import_react26.useMemo)(
|
|
3986
4015
|
() => ensurePngAvatar(avatarUrl) || `https://api.dicebear.com/9.x/avataaars/png?seed=${walletAddress}&size=128`,
|
|
3987
4016
|
[avatarUrl, walletAddress]
|
|
3988
4017
|
);
|
|
@@ -4175,7 +4204,7 @@ var styles5 = import_react_native11.StyleSheet.create({
|
|
|
4175
4204
|
});
|
|
4176
4205
|
|
|
4177
4206
|
// src/ui/UserProfileSheet.tsx
|
|
4178
|
-
var
|
|
4207
|
+
var import_react27 = require("react");
|
|
4179
4208
|
var import_react_native12 = require("react-native");
|
|
4180
4209
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4181
4210
|
function truncateAddress3(address, chars = 4) {
|
|
@@ -4193,31 +4222,31 @@ function UserProfileSheet({
|
|
|
4193
4222
|
const { client } = useDubs();
|
|
4194
4223
|
const { refreshUser } = useAuth();
|
|
4195
4224
|
const push = usePushNotifications();
|
|
4196
|
-
const overlayOpacity = (0,
|
|
4197
|
-
const parsed = (0,
|
|
4198
|
-
const [avatarStyle, setAvatarStyle] = (0,
|
|
4199
|
-
const [avatarSeed, setAvatarSeed] = (0,
|
|
4200
|
-
const [bgColor, setBgColor] = (0,
|
|
4201
|
-
const [saving, setSaving] = (0,
|
|
4202
|
-
const [error, setError] = (0,
|
|
4203
|
-
(0,
|
|
4225
|
+
const overlayOpacity = (0, import_react27.useRef)(new import_react_native12.Animated.Value(0)).current;
|
|
4226
|
+
const parsed = (0, import_react27.useMemo)(() => parseAvatarUrl(user.avatar), [user.avatar]);
|
|
4227
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react27.useState)(parsed.style);
|
|
4228
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react27.useState)(parsed.seed);
|
|
4229
|
+
const [bgColor, setBgColor] = (0, import_react27.useState)(parsed.bg);
|
|
4230
|
+
const [saving, setSaving] = (0, import_react27.useState)(false);
|
|
4231
|
+
const [error, setError] = (0, import_react27.useState)(null);
|
|
4232
|
+
(0, import_react27.useEffect)(() => {
|
|
4204
4233
|
const p = parseAvatarUrl(user.avatar);
|
|
4205
4234
|
setAvatarStyle(p.style);
|
|
4206
4235
|
setAvatarSeed(p.seed);
|
|
4207
4236
|
setBgColor(p.bg);
|
|
4208
4237
|
}, [user.avatar]);
|
|
4209
|
-
(0,
|
|
4238
|
+
(0, import_react27.useEffect)(() => {
|
|
4210
4239
|
import_react_native12.Animated.timing(overlayOpacity, {
|
|
4211
4240
|
toValue: visible ? 1 : 0,
|
|
4212
4241
|
duration: 250,
|
|
4213
4242
|
useNativeDriver: true
|
|
4214
4243
|
}).start();
|
|
4215
4244
|
}, [visible, overlayOpacity]);
|
|
4216
|
-
(0,
|
|
4245
|
+
(0, import_react27.useEffect)(() => {
|
|
4217
4246
|
if (visible) setError(null);
|
|
4218
4247
|
}, [visible]);
|
|
4219
4248
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4220
|
-
const saveAvatar = (0,
|
|
4249
|
+
const saveAvatar = (0, import_react27.useCallback)(async (newUrl) => {
|
|
4221
4250
|
setSaving(true);
|
|
4222
4251
|
setError(null);
|
|
4223
4252
|
try {
|
|
@@ -4230,16 +4259,16 @@ function UserProfileSheet({
|
|
|
4230
4259
|
setSaving(false);
|
|
4231
4260
|
}
|
|
4232
4261
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4233
|
-
const handleStyleChange = (0,
|
|
4262
|
+
const handleStyleChange = (0, import_react27.useCallback)((style) => {
|
|
4234
4263
|
setAvatarStyle(style);
|
|
4235
4264
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4236
4265
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4237
|
-
const handleShuffle = (0,
|
|
4266
|
+
const handleShuffle = (0, import_react27.useCallback)(() => {
|
|
4238
4267
|
const newSeed = generateSeed();
|
|
4239
4268
|
setAvatarSeed(newSeed);
|
|
4240
4269
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4241
4270
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4242
|
-
const handleBgChange = (0,
|
|
4271
|
+
const handleBgChange = (0, import_react27.useCallback)((color) => {
|
|
4243
4272
|
setBgColor(color);
|
|
4244
4273
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4245
4274
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4519,7 +4548,7 @@ var styles6 = import_react_native12.StyleSheet.create({
|
|
|
4519
4548
|
});
|
|
4520
4549
|
|
|
4521
4550
|
// src/ui/game/GamePoster.tsx
|
|
4522
|
-
var
|
|
4551
|
+
var import_react28 = require("react");
|
|
4523
4552
|
var import_react_native13 = require("react-native");
|
|
4524
4553
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4525
4554
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4569,7 +4598,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4569
4598
|
] });
|
|
4570
4599
|
}
|
|
4571
4600
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4572
|
-
const [failed, setFailed] = (0,
|
|
4601
|
+
const [failed, setFailed] = (0, import_react28.useState)(false);
|
|
4573
4602
|
if (!url || failed) {
|
|
4574
4603
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native13.View, { style: [styles7.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4575
4604
|
}
|
|
@@ -4670,7 +4699,7 @@ var styles7 = import_react_native13.StyleSheet.create({
|
|
|
4670
4699
|
});
|
|
4671
4700
|
|
|
4672
4701
|
// src/ui/game/LivePoolsCard.tsx
|
|
4673
|
-
var
|
|
4702
|
+
var import_react29 = require("react");
|
|
4674
4703
|
var import_react_native14 = require("react-native");
|
|
4675
4704
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
4676
4705
|
function LivePoolsCard({
|
|
@@ -4686,7 +4715,7 @@ function LivePoolsCard({
|
|
|
4686
4715
|
const homePool = game.homePool || 0;
|
|
4687
4716
|
const awayPool = game.awayPool || 0;
|
|
4688
4717
|
const totalPool = game.totalPool || 0;
|
|
4689
|
-
const { homePercent, awayPercent, homeOdds, awayOdds } = (0,
|
|
4718
|
+
const { homePercent, awayPercent, homeOdds, awayOdds } = (0, import_react29.useMemo)(() => {
|
|
4690
4719
|
return {
|
|
4691
4720
|
homePercent: totalPool > 0 ? homePool / totalPool * 100 : 50,
|
|
4692
4721
|
awayPercent: totalPool > 0 ? awayPool / totalPool * 100 : 50,
|
|
@@ -4749,7 +4778,7 @@ var styles8 = import_react_native14.StyleSheet.create({
|
|
|
4749
4778
|
});
|
|
4750
4779
|
|
|
4751
4780
|
// src/ui/game/PickWinnerCard.tsx
|
|
4752
|
-
var
|
|
4781
|
+
var import_react30 = require("react");
|
|
4753
4782
|
var import_react_native15 = require("react-native");
|
|
4754
4783
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
4755
4784
|
function PickWinnerCard({
|
|
@@ -4767,7 +4796,7 @@ function PickWinnerCard({
|
|
|
4767
4796
|
const totalPool = game.totalPool || 0;
|
|
4768
4797
|
const homePool = game.homePool || 0;
|
|
4769
4798
|
const awayPool = game.awayPool || 0;
|
|
4770
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
4799
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react30.useMemo)(() => ({
|
|
4771
4800
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
4772
4801
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
4773
4802
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -4820,7 +4849,7 @@ function TeamOption({
|
|
|
4820
4849
|
ImageComponent,
|
|
4821
4850
|
t
|
|
4822
4851
|
}) {
|
|
4823
|
-
const [imgFailed, setImgFailed] = (0,
|
|
4852
|
+
const [imgFailed, setImgFailed] = (0, import_react30.useState)(false);
|
|
4824
4853
|
const Img = ImageComponent || require("react-native").Image;
|
|
4825
4854
|
const showImage = imageUrl && !imgFailed;
|
|
4826
4855
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -4861,7 +4890,7 @@ var styles9 = import_react_native15.StyleSheet.create({
|
|
|
4861
4890
|
});
|
|
4862
4891
|
|
|
4863
4892
|
// src/ui/game/PlayersCard.tsx
|
|
4864
|
-
var
|
|
4893
|
+
var import_react31 = require("react");
|
|
4865
4894
|
var import_react_native16 = require("react-native");
|
|
4866
4895
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
4867
4896
|
function truncateWallet(addr, chars) {
|
|
@@ -4910,7 +4939,7 @@ function BettorRow({
|
|
|
4910
4939
|
ImageComponent,
|
|
4911
4940
|
t
|
|
4912
4941
|
}) {
|
|
4913
|
-
const [imgFailed, setImgFailed] = (0,
|
|
4942
|
+
const [imgFailed, setImgFailed] = (0, import_react31.useState)(false);
|
|
4914
4943
|
const Img = ImageComponent || require("react-native").Image;
|
|
4915
4944
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
4916
4945
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: [styles10.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -4937,7 +4966,7 @@ var styles10 = import_react_native16.StyleSheet.create({
|
|
|
4937
4966
|
});
|
|
4938
4967
|
|
|
4939
4968
|
// src/ui/game/JoinGameButton.tsx
|
|
4940
|
-
var
|
|
4969
|
+
var import_react32 = require("react");
|
|
4941
4970
|
var import_react_native17 = require("react-native");
|
|
4942
4971
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4943
4972
|
var STATUS_LABELS = {
|
|
@@ -4948,7 +4977,7 @@ var STATUS_LABELS = {
|
|
|
4948
4977
|
};
|
|
4949
4978
|
function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }) {
|
|
4950
4979
|
const t = useDubsTheme();
|
|
4951
|
-
const alreadyJoined = (0,
|
|
4980
|
+
const alreadyJoined = (0, import_react32.useMemo)(() => {
|
|
4952
4981
|
if (!walletAddress) return false;
|
|
4953
4982
|
return (game.bettors || []).some((b) => b.wallet === walletAddress);
|
|
4954
4983
|
}, [game.bettors, walletAddress]);
|
|
@@ -4989,7 +5018,7 @@ var styles11 = import_react_native17.StyleSheet.create({
|
|
|
4989
5018
|
});
|
|
4990
5019
|
|
|
4991
5020
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
4992
|
-
var
|
|
5021
|
+
var import_react33 = require("react");
|
|
4993
5022
|
var import_react_native18 = require("react-native");
|
|
4994
5023
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4995
5024
|
var STATUS_LABELS2 = {
|
|
@@ -5015,18 +5044,18 @@ function CreateCustomGameSheet({
|
|
|
5015
5044
|
const t = useDubsTheme();
|
|
5016
5045
|
const { wallet } = useDubs();
|
|
5017
5046
|
const mutation = useCreateCustomGame();
|
|
5018
|
-
const [selectedAmount, setSelectedAmount] = (0,
|
|
5019
|
-
const [customAmount, setCustomAmount] = (0,
|
|
5020
|
-
const [isCustom, setIsCustom] = (0,
|
|
5021
|
-
const overlayOpacity = (0,
|
|
5022
|
-
(0,
|
|
5047
|
+
const [selectedAmount, setSelectedAmount] = (0, import_react33.useState)(null);
|
|
5048
|
+
const [customAmount, setCustomAmount] = (0, import_react33.useState)("");
|
|
5049
|
+
const [isCustom, setIsCustom] = (0, import_react33.useState)(false);
|
|
5050
|
+
const overlayOpacity = (0, import_react33.useRef)(new import_react_native18.Animated.Value(0)).current;
|
|
5051
|
+
(0, import_react33.useEffect)(() => {
|
|
5023
5052
|
import_react_native18.Animated.timing(overlayOpacity, {
|
|
5024
5053
|
toValue: visible ? 1 : 0,
|
|
5025
5054
|
duration: 250,
|
|
5026
5055
|
useNativeDriver: true
|
|
5027
5056
|
}).start();
|
|
5028
5057
|
}, [visible, overlayOpacity]);
|
|
5029
|
-
(0,
|
|
5058
|
+
(0, import_react33.useEffect)(() => {
|
|
5030
5059
|
if (visible) {
|
|
5031
5060
|
setSelectedAmount(defaultAmount ?? null);
|
|
5032
5061
|
setCustomAmount("");
|
|
@@ -5034,7 +5063,7 @@ function CreateCustomGameSheet({
|
|
|
5034
5063
|
mutation.reset();
|
|
5035
5064
|
}
|
|
5036
5065
|
}, [visible]);
|
|
5037
|
-
(0,
|
|
5066
|
+
(0, import_react33.useEffect)(() => {
|
|
5038
5067
|
if (mutation.status === "success" && mutation.data) {
|
|
5039
5068
|
onSuccess?.(mutation.data);
|
|
5040
5069
|
const timer = setTimeout(() => {
|
|
@@ -5043,23 +5072,23 @@ function CreateCustomGameSheet({
|
|
|
5043
5072
|
return () => clearTimeout(timer);
|
|
5044
5073
|
}
|
|
5045
5074
|
}, [mutation.status, mutation.data]);
|
|
5046
|
-
(0,
|
|
5075
|
+
(0, import_react33.useEffect)(() => {
|
|
5047
5076
|
if (mutation.status === "error" && mutation.error) {
|
|
5048
5077
|
onError?.(mutation.error);
|
|
5049
5078
|
}
|
|
5050
5079
|
}, [mutation.status, mutation.error]);
|
|
5051
|
-
const handlePresetSelect = (0,
|
|
5080
|
+
const handlePresetSelect = (0, import_react33.useCallback)((amount) => {
|
|
5052
5081
|
setSelectedAmount(amount);
|
|
5053
5082
|
setIsCustom(false);
|
|
5054
5083
|
setCustomAmount("");
|
|
5055
5084
|
onAmountChange?.(amount);
|
|
5056
5085
|
}, [onAmountChange]);
|
|
5057
|
-
const handleCustomSelect = (0,
|
|
5086
|
+
const handleCustomSelect = (0, import_react33.useCallback)(() => {
|
|
5058
5087
|
setIsCustom(true);
|
|
5059
5088
|
setSelectedAmount(null);
|
|
5060
5089
|
onAmountChange?.(null);
|
|
5061
5090
|
}, [onAmountChange]);
|
|
5062
|
-
const handleCustomAmountChange = (0,
|
|
5091
|
+
const handleCustomAmountChange = (0, import_react33.useCallback)((text) => {
|
|
5063
5092
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
5064
5093
|
setCustomAmount(cleaned);
|
|
5065
5094
|
const parsed = parseFloat(cleaned);
|
|
@@ -5074,7 +5103,7 @@ function CreateCustomGameSheet({
|
|
|
5074
5103
|
const winnerTakes = pot * (1 - fee / 100);
|
|
5075
5104
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5076
5105
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
5077
|
-
const handleCreate = (0,
|
|
5106
|
+
const handleCreate = (0, import_react33.useCallback)(async () => {
|
|
5078
5107
|
if (!finalAmount || !wallet.publicKey) return;
|
|
5079
5108
|
try {
|
|
5080
5109
|
await mutation.execute({
|
|
@@ -5343,11 +5372,11 @@ var styles12 = import_react_native18.StyleSheet.create({
|
|
|
5343
5372
|
});
|
|
5344
5373
|
|
|
5345
5374
|
// src/ui/game/JoinGameSheet.tsx
|
|
5346
|
-
var
|
|
5375
|
+
var import_react36 = require("react");
|
|
5347
5376
|
var import_react_native21 = require("react-native");
|
|
5348
5377
|
|
|
5349
5378
|
// src/ui/game/SolSlider.tsx
|
|
5350
|
-
var
|
|
5379
|
+
var import_react34 = require("react");
|
|
5351
5380
|
var import_react_native19 = require("react-native");
|
|
5352
5381
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
5353
5382
|
var THUMB_SIZE = 32;
|
|
@@ -5366,9 +5395,9 @@ function SolSlider({
|
|
|
5366
5395
|
}) {
|
|
5367
5396
|
const t = useDubsTheme();
|
|
5368
5397
|
const accent = accentColor || t.accent;
|
|
5369
|
-
const trackRef = (0,
|
|
5370
|
-
const trackWidth = (0,
|
|
5371
|
-
const lastTickValue = (0,
|
|
5398
|
+
const trackRef = (0, import_react34.useRef)(null);
|
|
5399
|
+
const trackWidth = (0, import_react34.useRef)(0);
|
|
5400
|
+
const lastTickValue = (0, import_react34.useRef)(value);
|
|
5372
5401
|
const clamp = (v) => {
|
|
5373
5402
|
const stepped = Math.round(v / step) * step;
|
|
5374
5403
|
return Math.max(min, Math.min(max, parseFloat(stepped.toFixed(4))));
|
|
@@ -5381,7 +5410,7 @@ function SolSlider({
|
|
|
5381
5410
|
const ratio2 = Math.max(0, Math.min(1, x / trackWidth.current));
|
|
5382
5411
|
return clamp(min + ratio2 * (max - min));
|
|
5383
5412
|
};
|
|
5384
|
-
const panResponder = (0,
|
|
5413
|
+
const panResponder = (0, import_react34.useRef)(
|
|
5385
5414
|
import_react_native19.PanResponder.create({
|
|
5386
5415
|
onStartShouldSetPanResponder: () => !disabled,
|
|
5387
5416
|
onMoveShouldSetPanResponder: () => !disabled,
|
|
@@ -5536,7 +5565,7 @@ var styles13 = import_react_native19.StyleSheet.create({
|
|
|
5536
5565
|
});
|
|
5537
5566
|
|
|
5538
5567
|
// src/ui/game/TeamButton.tsx
|
|
5539
|
-
var
|
|
5568
|
+
var import_react35 = require("react");
|
|
5540
5569
|
var import_react_native20 = require("react-native");
|
|
5541
5570
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
5542
5571
|
function TeamButton({
|
|
@@ -5550,7 +5579,7 @@ function TeamButton({
|
|
|
5550
5579
|
ImageComponent,
|
|
5551
5580
|
t
|
|
5552
5581
|
}) {
|
|
5553
|
-
const [imgFailed, setImgFailed] = (0,
|
|
5582
|
+
const [imgFailed, setImgFailed] = (0, import_react35.useState)(false);
|
|
5554
5583
|
const Img = ImageComponent || require("react-native").Image;
|
|
5555
5584
|
const showImage = imageUrl && !imgFailed;
|
|
5556
5585
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
@@ -5641,6 +5670,7 @@ function JoinGameSheet({
|
|
|
5641
5670
|
shortName,
|
|
5642
5671
|
homeColor = "#3B82F6",
|
|
5643
5672
|
awayColor = "#EF4444",
|
|
5673
|
+
drawColor = "#F59E0B",
|
|
5644
5674
|
onSuccess,
|
|
5645
5675
|
onError,
|
|
5646
5676
|
onTeamSelect,
|
|
@@ -5653,20 +5683,20 @@ function JoinGameSheet({
|
|
|
5653
5683
|
const { wallet } = useDubs();
|
|
5654
5684
|
const mutation = useJoinGame();
|
|
5655
5685
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
5656
|
-
const [selectedTeam, setSelectedTeam] = (0,
|
|
5657
|
-
const [wager, setWager] = (0,
|
|
5658
|
-
const [showSuccess, setShowSuccess] = (0,
|
|
5659
|
-
const overlayOpacity = (0,
|
|
5660
|
-
const successScale = (0,
|
|
5661
|
-
const successOpacity = (0,
|
|
5662
|
-
(0,
|
|
5686
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react36.useState)(null);
|
|
5687
|
+
const [wager, setWager] = (0, import_react36.useState)(game.buyIn);
|
|
5688
|
+
const [showSuccess, setShowSuccess] = (0, import_react36.useState)(false);
|
|
5689
|
+
const overlayOpacity = (0, import_react36.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
5690
|
+
const successScale = (0, import_react36.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
5691
|
+
const successOpacity = (0, import_react36.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
5692
|
+
(0, import_react36.useEffect)(() => {
|
|
5663
5693
|
import_react_native21.Animated.timing(overlayOpacity, {
|
|
5664
5694
|
toValue: visible ? 1 : 0,
|
|
5665
5695
|
duration: 250,
|
|
5666
5696
|
useNativeDriver: true
|
|
5667
5697
|
}).start();
|
|
5668
5698
|
}, [visible, overlayOpacity]);
|
|
5669
|
-
(0,
|
|
5699
|
+
(0, import_react36.useEffect)(() => {
|
|
5670
5700
|
if (visible) {
|
|
5671
5701
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
5672
5702
|
setWager(game.buyIn);
|
|
@@ -5676,7 +5706,7 @@ function JoinGameSheet({
|
|
|
5676
5706
|
mutation.reset();
|
|
5677
5707
|
}
|
|
5678
5708
|
}, [visible]);
|
|
5679
|
-
(0,
|
|
5709
|
+
(0, import_react36.useEffect)(() => {
|
|
5680
5710
|
if (mutation.status === "success" && mutation.data) {
|
|
5681
5711
|
setShowSuccess(true);
|
|
5682
5712
|
onSuccess?.(mutation.data);
|
|
@@ -5693,7 +5723,7 @@ function JoinGameSheet({
|
|
|
5693
5723
|
return () => clearTimeout(timer);
|
|
5694
5724
|
}
|
|
5695
5725
|
}, [mutation.status, mutation.data]);
|
|
5696
|
-
(0,
|
|
5726
|
+
(0, import_react36.useEffect)(() => {
|
|
5697
5727
|
if (mutation.status === "error" && mutation.error) {
|
|
5698
5728
|
onError?.(mutation.error);
|
|
5699
5729
|
}
|
|
@@ -5703,22 +5733,33 @@ function JoinGameSheet({
|
|
|
5703
5733
|
const totalPool = game.totalPool || 0;
|
|
5704
5734
|
const homePool = game.homePool || 0;
|
|
5705
5735
|
const awayPool = game.awayPool || 0;
|
|
5736
|
+
const drawPool = game.drawPool || 0;
|
|
5706
5737
|
const buyIn = game.buyIn;
|
|
5738
|
+
const drawBettors = bettors.filter((b) => b.team === "draw");
|
|
5739
|
+
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));
|
|
5707
5740
|
const poolAfterJoin = totalPool + wager;
|
|
5708
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
5741
|
+
const { homeOdds, awayOdds, drawOdds, homeBets, awayBets, drawBets } = (0, import_react36.useMemo)(() => {
|
|
5742
|
+
const homeBetsCount = bettors.filter((b) => b.team === "home").length;
|
|
5743
|
+
const awayBetsCount = bettors.filter((b) => b.team === "away").length;
|
|
5744
|
+
const drawBetsCount = bettors.filter((b) => b.team === "draw").length;
|
|
5709
5745
|
const newPool = totalPool + wager;
|
|
5746
|
+
const newHome = homePool + (selectedTeam === "home" ? wager : 0);
|
|
5747
|
+
const newAway = awayPool + (selectedTeam === "away" ? wager : 0);
|
|
5748
|
+
const newDraw = drawPool + (selectedTeam === "draw" ? wager : 0);
|
|
5710
5749
|
return {
|
|
5711
|
-
homeOdds:
|
|
5712
|
-
awayOdds:
|
|
5713
|
-
|
|
5714
|
-
|
|
5750
|
+
homeOdds: newHome > 0 ? (newPool / newHome).toFixed(2) : "\u2014",
|
|
5751
|
+
awayOdds: newAway > 0 ? (newPool / newAway).toFixed(2) : "\u2014",
|
|
5752
|
+
drawOdds: newDraw > 0 ? (newPool / newDraw).toFixed(2) : "\u2014",
|
|
5753
|
+
homeBets: homeBetsCount,
|
|
5754
|
+
awayBets: awayBetsCount,
|
|
5755
|
+
drawBets: drawBetsCount
|
|
5715
5756
|
};
|
|
5716
|
-
}, [totalPool, homePool, awayPool, bettors, wager, selectedTeam]);
|
|
5717
|
-
const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : "\u2014";
|
|
5757
|
+
}, [totalPool, homePool, awayPool, drawPool, bettors, wager, selectedTeam]);
|
|
5758
|
+
const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : selectedTeam === "draw" ? drawOdds : "\u2014";
|
|
5718
5759
|
const potentialWinnings = selectedOdds !== "\u2014" ? formatSol(parseFloat(selectedOdds) * wager) : "\u2014";
|
|
5719
5760
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
5720
5761
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
5721
|
-
const myBet = (0,
|
|
5762
|
+
const myBet = (0, import_react36.useMemo)(() => {
|
|
5722
5763
|
if (!wallet.publicKey) return null;
|
|
5723
5764
|
const addr = wallet.publicKey.toBase58();
|
|
5724
5765
|
return bettors.find((b) => b.wallet === addr) ?? null;
|
|
@@ -5726,7 +5767,7 @@ function JoinGameSheet({
|
|
|
5726
5767
|
const alreadyJoined = myBet !== null;
|
|
5727
5768
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5728
5769
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
5729
|
-
const handleJoin = (0,
|
|
5770
|
+
const handleJoin = (0, import_react36.useCallback)(async () => {
|
|
5730
5771
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
5731
5772
|
try {
|
|
5732
5773
|
await mutation.execute({
|
|
@@ -5823,11 +5864,26 @@ function JoinGameSheet({
|
|
|
5823
5864
|
t
|
|
5824
5865
|
}
|
|
5825
5866
|
)
|
|
5826
|
-
] })
|
|
5867
|
+
] }),
|
|
5868
|
+
hasDrawOption && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native21.View, { style: styles15.drawRow, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
5869
|
+
TeamButton,
|
|
5870
|
+
{
|
|
5871
|
+
name: "Draw",
|
|
5872
|
+
odds: drawOdds,
|
|
5873
|
+
bets: drawBets,
|
|
5874
|
+
color: drawColor,
|
|
5875
|
+
selected: selectedTeam === "draw",
|
|
5876
|
+
onPress: () => {
|
|
5877
|
+
setSelectedTeam("draw");
|
|
5878
|
+
onTeamSelect?.("draw");
|
|
5879
|
+
},
|
|
5880
|
+
t
|
|
5881
|
+
}
|
|
5882
|
+
) })
|
|
5827
5883
|
] }),
|
|
5828
|
-
alreadyJoined && myBet && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native21.View, { style: [styles15.myBetCard, { backgroundColor: (myBet.team === "home" ? homeColor : awayColor) + "15", borderColor: myBet.team === "home" ? homeColor : awayColor }], children: [
|
|
5829
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native21.Text, { style: [styles15.myBetLabel, { color: myBet.team === "home" ? homeColor : awayColor }], children: "YOUR BET" }),
|
|
5830
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native21.Text, { style: [styles15.myBetTeam, { color: t.text }], children: myBet.team === "home" ? homeName : awayName }),
|
|
5884
|
+
alreadyJoined && myBet && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native21.View, { 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: [
|
|
5885
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native21.Text, { style: [styles15.myBetLabel, { color: myBet.team === "home" ? homeColor : myBet.team === "away" ? awayColor : drawColor }], children: "YOUR BET" }),
|
|
5886
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native21.Text, { style: [styles15.myBetTeam, { color: t.text }], children: myBet.team === "home" ? homeName : myBet.team === "away" ? awayName : "Draw" }),
|
|
5831
5887
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native21.Text, { style: [styles15.myBetAmount, { color: t.textMuted }], children: [
|
|
5832
5888
|
formatSol(myBet.amount),
|
|
5833
5889
|
" SOL"
|
|
@@ -6026,6 +6082,9 @@ var styles15 = import_react_native21.StyleSheet.create({
|
|
|
6026
6082
|
flexDirection: "row",
|
|
6027
6083
|
gap: 12
|
|
6028
6084
|
},
|
|
6085
|
+
drawRow: {
|
|
6086
|
+
marginTop: 8
|
|
6087
|
+
},
|
|
6029
6088
|
summaryCard: {
|
|
6030
6089
|
marginTop: 20,
|
|
6031
6090
|
borderRadius: 16,
|
|
@@ -6101,7 +6160,7 @@ var styles15 = import_react_native21.StyleSheet.create({
|
|
|
6101
6160
|
});
|
|
6102
6161
|
|
|
6103
6162
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
6104
|
-
var
|
|
6163
|
+
var import_react37 = require("react");
|
|
6105
6164
|
var import_react_native22 = require("react-native");
|
|
6106
6165
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
6107
6166
|
var STATUS_LABELS4 = {
|
|
@@ -6122,18 +6181,18 @@ function ClaimPrizeSheet({
|
|
|
6122
6181
|
const t = useDubsTheme();
|
|
6123
6182
|
const { wallet } = useDubs();
|
|
6124
6183
|
const mutation = useClaim();
|
|
6125
|
-
const overlayOpacity = (0,
|
|
6126
|
-
const celebrationScale = (0,
|
|
6127
|
-
const celebrationOpacity = (0,
|
|
6128
|
-
const [showCelebration, setShowCelebration] = (0,
|
|
6129
|
-
(0,
|
|
6184
|
+
const overlayOpacity = (0, import_react37.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6185
|
+
const celebrationScale = (0, import_react37.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6186
|
+
const celebrationOpacity = (0, import_react37.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6187
|
+
const [showCelebration, setShowCelebration] = (0, import_react37.useState)(false);
|
|
6188
|
+
(0, import_react37.useEffect)(() => {
|
|
6130
6189
|
import_react_native22.Animated.timing(overlayOpacity, {
|
|
6131
6190
|
toValue: visible ? 1 : 0,
|
|
6132
6191
|
duration: 250,
|
|
6133
6192
|
useNativeDriver: true
|
|
6134
6193
|
}).start();
|
|
6135
6194
|
}, [visible, overlayOpacity]);
|
|
6136
|
-
(0,
|
|
6195
|
+
(0, import_react37.useEffect)(() => {
|
|
6137
6196
|
if (visible) {
|
|
6138
6197
|
mutation.reset();
|
|
6139
6198
|
setShowCelebration(false);
|
|
@@ -6141,7 +6200,7 @@ function ClaimPrizeSheet({
|
|
|
6141
6200
|
celebrationOpacity.setValue(0);
|
|
6142
6201
|
}
|
|
6143
6202
|
}, [visible]);
|
|
6144
|
-
(0,
|
|
6203
|
+
(0, import_react37.useEffect)(() => {
|
|
6145
6204
|
if (mutation.status === "success" && mutation.data) {
|
|
6146
6205
|
setShowCelebration(true);
|
|
6147
6206
|
import_react_native22.Animated.parallel([
|
|
@@ -6164,14 +6223,14 @@ function ClaimPrizeSheet({
|
|
|
6164
6223
|
return () => clearTimeout(timer);
|
|
6165
6224
|
}
|
|
6166
6225
|
}, [mutation.status, mutation.data]);
|
|
6167
|
-
(0,
|
|
6226
|
+
(0, import_react37.useEffect)(() => {
|
|
6168
6227
|
if (mutation.status === "error" && mutation.error) {
|
|
6169
6228
|
onError?.(mutation.error);
|
|
6170
6229
|
}
|
|
6171
6230
|
}, [mutation.status, mutation.error]);
|
|
6172
6231
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6173
6232
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
6174
|
-
const handleClaim = (0,
|
|
6233
|
+
const handleClaim = (0, import_react37.useCallback)(async () => {
|
|
6175
6234
|
if (!wallet.publicKey) return;
|
|
6176
6235
|
try {
|
|
6177
6236
|
await mutation.execute({
|
|
@@ -6404,7 +6463,7 @@ var styles16 = import_react_native22.StyleSheet.create({
|
|
|
6404
6463
|
});
|
|
6405
6464
|
|
|
6406
6465
|
// src/ui/game/ClaimButton.tsx
|
|
6407
|
-
var
|
|
6466
|
+
var import_react38 = require("react");
|
|
6408
6467
|
var import_react_native23 = require("react-native");
|
|
6409
6468
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
6410
6469
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -6412,9 +6471,9 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6412
6471
|
const { wallet } = useDubs();
|
|
6413
6472
|
const game = useGame(gameId);
|
|
6414
6473
|
const claimStatus = useHasClaimed(gameId);
|
|
6415
|
-
const [sheetVisible, setSheetVisible] = (0,
|
|
6474
|
+
const [sheetVisible, setSheetVisible] = (0, import_react38.useState)(false);
|
|
6416
6475
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
6417
|
-
const myBet = (0,
|
|
6476
|
+
const myBet = (0, import_react38.useMemo)(() => {
|
|
6418
6477
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
6419
6478
|
return game.data.bettors.find((b) => b.wallet === walletAddress) ?? null;
|
|
6420
6479
|
}, [walletAddress, game.data?.bettors]);
|
|
@@ -6423,7 +6482,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6423
6482
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
6424
6483
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
6425
6484
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
6426
|
-
const handleSuccess = (0,
|
|
6485
|
+
const handleSuccess = (0, import_react38.useCallback)(
|
|
6427
6486
|
(result) => {
|
|
6428
6487
|
claimStatus.refetch();
|
|
6429
6488
|
onSuccess?.(result);
|
|
@@ -6510,7 +6569,7 @@ var styles17 = import_react_native23.StyleSheet.create({
|
|
|
6510
6569
|
});
|
|
6511
6570
|
|
|
6512
6571
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
6513
|
-
var
|
|
6572
|
+
var import_react39 = require("react");
|
|
6514
6573
|
var import_react_native24 = require("react-native");
|
|
6515
6574
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
6516
6575
|
var STATUS_LABELS5 = {
|
|
@@ -6531,20 +6590,20 @@ function EnterArcadePoolSheet({
|
|
|
6531
6590
|
const t = useDubsTheme();
|
|
6532
6591
|
const { wallet } = useDubs();
|
|
6533
6592
|
const mutation = useEnterArcadePool();
|
|
6534
|
-
const overlayOpacity = (0,
|
|
6535
|
-
(0,
|
|
6593
|
+
const overlayOpacity = (0, import_react39.useRef)(new import_react_native24.Animated.Value(0)).current;
|
|
6594
|
+
(0, import_react39.useEffect)(() => {
|
|
6536
6595
|
import_react_native24.Animated.timing(overlayOpacity, {
|
|
6537
6596
|
toValue: visible ? 1 : 0,
|
|
6538
6597
|
duration: 250,
|
|
6539
6598
|
useNativeDriver: true
|
|
6540
6599
|
}).start();
|
|
6541
6600
|
}, [visible, overlayOpacity]);
|
|
6542
|
-
(0,
|
|
6601
|
+
(0, import_react39.useEffect)(() => {
|
|
6543
6602
|
if (visible) {
|
|
6544
6603
|
mutation.reset();
|
|
6545
6604
|
}
|
|
6546
6605
|
}, [visible]);
|
|
6547
|
-
(0,
|
|
6606
|
+
(0, import_react39.useEffect)(() => {
|
|
6548
6607
|
if (mutation.status === "success" && mutation.data) {
|
|
6549
6608
|
onSuccess?.(mutation.data);
|
|
6550
6609
|
const timer = setTimeout(() => {
|
|
@@ -6553,7 +6612,7 @@ function EnterArcadePoolSheet({
|
|
|
6553
6612
|
return () => clearTimeout(timer);
|
|
6554
6613
|
}
|
|
6555
6614
|
}, [mutation.status, mutation.data]);
|
|
6556
|
-
(0,
|
|
6615
|
+
(0, import_react39.useEffect)(() => {
|
|
6557
6616
|
if (mutation.status === "error" && mutation.error) {
|
|
6558
6617
|
onError?.(mutation.error);
|
|
6559
6618
|
}
|
|
@@ -6565,7 +6624,7 @@ function EnterArcadePoolSheet({
|
|
|
6565
6624
|
const potSol = (pool.buy_in_lamports * Number(totalBuyIns) / 1e9).toFixed(4);
|
|
6566
6625
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6567
6626
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
6568
|
-
const handleJoin = (0,
|
|
6627
|
+
const handleJoin = (0, import_react39.useCallback)(async () => {
|
|
6569
6628
|
if (!wallet.publicKey) return;
|
|
6570
6629
|
try {
|
|
6571
6630
|
await mutation.execute(pool.id);
|
|
@@ -6716,7 +6775,7 @@ var styles18 = import_react_native24.StyleSheet.create({
|
|
|
6716
6775
|
});
|
|
6717
6776
|
|
|
6718
6777
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
6719
|
-
var
|
|
6778
|
+
var import_react40 = require("react");
|
|
6720
6779
|
var import_react_native25 = require("react-native");
|
|
6721
6780
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
6722
6781
|
function RankLabel({ index }) {
|
|
@@ -6733,15 +6792,15 @@ function ArcadeLeaderboardSheet({
|
|
|
6733
6792
|
}) {
|
|
6734
6793
|
const t = useDubsTheme();
|
|
6735
6794
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
6736
|
-
const overlayOpacity = (0,
|
|
6737
|
-
(0,
|
|
6795
|
+
const overlayOpacity = (0, import_react40.useRef)(new import_react_native25.Animated.Value(0)).current;
|
|
6796
|
+
(0, import_react40.useEffect)(() => {
|
|
6738
6797
|
import_react_native25.Animated.timing(overlayOpacity, {
|
|
6739
6798
|
toValue: visible ? 1 : 0,
|
|
6740
6799
|
duration: 250,
|
|
6741
6800
|
useNativeDriver: true
|
|
6742
6801
|
}).start();
|
|
6743
6802
|
}, [visible, overlayOpacity]);
|
|
6744
|
-
(0,
|
|
6803
|
+
(0, import_react40.useEffect)(() => {
|
|
6745
6804
|
if (visible) refetch();
|
|
6746
6805
|
}, [visible]);
|
|
6747
6806
|
const renderItem = ({ item, index }) => {
|
|
@@ -6888,7 +6947,7 @@ var styles19 = import_react_native25.StyleSheet.create({
|
|
|
6888
6947
|
});
|
|
6889
6948
|
|
|
6890
6949
|
// src/ui/game/CreateGameSheet.tsx
|
|
6891
|
-
var
|
|
6950
|
+
var import_react41 = require("react");
|
|
6892
6951
|
var import_react_native26 = require("react-native");
|
|
6893
6952
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6894
6953
|
var STATUS_LABELS6 = {
|
|
@@ -6917,20 +6976,20 @@ function CreateGameSheet({
|
|
|
6917
6976
|
const t = useDubsTheme();
|
|
6918
6977
|
const { wallet } = useDubs();
|
|
6919
6978
|
const mutation = useCreateGame();
|
|
6920
|
-
const [selectedTeam, setSelectedTeam] = (0,
|
|
6921
|
-
const [wager, setWager] = (0,
|
|
6922
|
-
const [showSuccess, setShowSuccess] = (0,
|
|
6923
|
-
const overlayOpacity = (0,
|
|
6924
|
-
const successScale = (0,
|
|
6925
|
-
const successOpacity = (0,
|
|
6926
|
-
(0,
|
|
6979
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react41.useState)(null);
|
|
6980
|
+
const [wager, setWager] = (0, import_react41.useState)(0.01);
|
|
6981
|
+
const [showSuccess, setShowSuccess] = (0, import_react41.useState)(false);
|
|
6982
|
+
const overlayOpacity = (0, import_react41.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
6983
|
+
const successScale = (0, import_react41.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
6984
|
+
const successOpacity = (0, import_react41.useRef)(new import_react_native26.Animated.Value(0)).current;
|
|
6985
|
+
(0, import_react41.useEffect)(() => {
|
|
6927
6986
|
import_react_native26.Animated.timing(overlayOpacity, {
|
|
6928
6987
|
toValue: visible ? 1 : 0,
|
|
6929
6988
|
duration: 250,
|
|
6930
6989
|
useNativeDriver: true
|
|
6931
6990
|
}).start();
|
|
6932
6991
|
}, [visible]);
|
|
6933
|
-
(0,
|
|
6992
|
+
(0, import_react41.useEffect)(() => {
|
|
6934
6993
|
if (visible) {
|
|
6935
6994
|
setSelectedTeam(null);
|
|
6936
6995
|
setWager(0.01);
|
|
@@ -6940,7 +6999,7 @@ function CreateGameSheet({
|
|
|
6940
6999
|
mutation.reset();
|
|
6941
7000
|
}
|
|
6942
7001
|
}, [visible]);
|
|
6943
|
-
(0,
|
|
7002
|
+
(0, import_react41.useEffect)(() => {
|
|
6944
7003
|
if (mutation.status === "success" && mutation.data) {
|
|
6945
7004
|
setShowSuccess(true);
|
|
6946
7005
|
onSuccess?.(mutation.data);
|
|
@@ -6957,7 +7016,7 @@ function CreateGameSheet({
|
|
|
6957
7016
|
return () => clearTimeout(timer);
|
|
6958
7017
|
}
|
|
6959
7018
|
}, [mutation.status, mutation.data]);
|
|
6960
|
-
(0,
|
|
7019
|
+
(0, import_react41.useEffect)(() => {
|
|
6961
7020
|
if (mutation.status === "error" && mutation.error) {
|
|
6962
7021
|
onError?.(mutation.error);
|
|
6963
7022
|
}
|
|
@@ -6967,7 +7026,7 @@ function CreateGameSheet({
|
|
|
6967
7026
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
6968
7027
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6969
7028
|
const canCreate = selectedTeam !== null && !isMutating && mutation.status !== "success";
|
|
6970
|
-
const handleCreate = (0,
|
|
7029
|
+
const handleCreate = (0, import_react41.useCallback)(async () => {
|
|
6971
7030
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
6972
7031
|
try {
|
|
6973
7032
|
await mutation.execute({
|
|
@@ -7168,6 +7227,7 @@ var styles20 = import_react_native26.StyleSheet.create({
|
|
|
7168
7227
|
useGame,
|
|
7169
7228
|
useGames,
|
|
7170
7229
|
useHasClaimed,
|
|
7230
|
+
useHighlights,
|
|
7171
7231
|
useJoinGame,
|
|
7172
7232
|
useNetworkGames,
|
|
7173
7233
|
usePushNotifications,
|