@dubsdotapp/expo 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +168 -122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -85
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useArcadeCountdown.ts +71 -0
- package/src/index.ts +2 -0
- package/src/types.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ __export(index_exports, {
|
|
|
64
64
|
parseSolanaError: () => parseSolanaError,
|
|
65
65
|
signAndSendBase64Transaction: () => signAndSendBase64Transaction,
|
|
66
66
|
useAppConfig: () => useAppConfig,
|
|
67
|
+
useArcadeCountdown: () => useArcadeCountdown,
|
|
67
68
|
useArcadeGame: () => useArcadeGame,
|
|
68
69
|
useArcadePool: () => useArcadePool,
|
|
69
70
|
useArcadePools: () => useArcadePools,
|
|
@@ -717,7 +718,7 @@ function createSecureStoreStorage() {
|
|
|
717
718
|
}
|
|
718
719
|
|
|
719
720
|
// src/provider.tsx
|
|
720
|
-
var
|
|
721
|
+
var import_react23 = require("react");
|
|
721
722
|
|
|
722
723
|
// src/ui/theme.ts
|
|
723
724
|
var import_react = require("react");
|
|
@@ -1775,7 +1776,7 @@ function ManagedWalletProvider({
|
|
|
1775
1776
|
}
|
|
1776
1777
|
|
|
1777
1778
|
// src/ui/AuthGate.tsx
|
|
1778
|
-
var
|
|
1779
|
+
var import_react22 = __toESM(require("react"));
|
|
1779
1780
|
var import_react_native8 = require("react-native");
|
|
1780
1781
|
|
|
1781
1782
|
// src/hooks/useEvents.ts
|
|
@@ -2797,6 +2798,50 @@ function useEnterArcadePool() {
|
|
|
2797
2798
|
return { execute, status, error, data, reset };
|
|
2798
2799
|
}
|
|
2799
2800
|
|
|
2801
|
+
// src/hooks/useArcadeCountdown.ts
|
|
2802
|
+
var import_react21 = require("react");
|
|
2803
|
+
function formatCountdown(ms) {
|
|
2804
|
+
if (ms <= 0) return "Ended";
|
|
2805
|
+
const s2 = Math.floor(ms / 1e3);
|
|
2806
|
+
const m = Math.floor(s2 / 60);
|
|
2807
|
+
const h = Math.floor(m / 60);
|
|
2808
|
+
const d = Math.floor(h / 24);
|
|
2809
|
+
if (d > 0) return `${d}d ${h % 24}h ${m % 60}m`;
|
|
2810
|
+
if (h > 0) return `${h}h ${m % 60}m ${s2 % 60}s`;
|
|
2811
|
+
if (m > 0) return `${m}m ${s2 % 60}s`;
|
|
2812
|
+
return `${s2}s`;
|
|
2813
|
+
}
|
|
2814
|
+
function useArcadeCountdown(nextResolution) {
|
|
2815
|
+
const [now, setNow] = (0, import_react21.useState)(Date.now());
|
|
2816
|
+
const intervalRef = (0, import_react21.useRef)(null);
|
|
2817
|
+
(0, import_react21.useEffect)(() => {
|
|
2818
|
+
if (!nextResolution) return;
|
|
2819
|
+
intervalRef.current = setInterval(() => setNow(Date.now()), 1e3);
|
|
2820
|
+
return () => {
|
|
2821
|
+
if (intervalRef.current) clearInterval(intervalRef.current);
|
|
2822
|
+
};
|
|
2823
|
+
}, [nextResolution]);
|
|
2824
|
+
if (!nextResolution) {
|
|
2825
|
+
return { totalMs: 0, days: 0, hours: 0, minutes: 0, seconds: 0, formatted: "--", isExpired: false };
|
|
2826
|
+
}
|
|
2827
|
+
const target = new Date(nextResolution).getTime();
|
|
2828
|
+
const totalMs = Math.max(0, target - now);
|
|
2829
|
+
const totalSec = Math.floor(totalMs / 1e3);
|
|
2830
|
+
const days = Math.floor(totalSec / 86400);
|
|
2831
|
+
const hours = Math.floor(totalSec % 86400 / 3600);
|
|
2832
|
+
const minutes = Math.floor(totalSec % 3600 / 60);
|
|
2833
|
+
const seconds = totalSec % 60;
|
|
2834
|
+
return {
|
|
2835
|
+
totalMs,
|
|
2836
|
+
days,
|
|
2837
|
+
hours,
|
|
2838
|
+
minutes,
|
|
2839
|
+
seconds,
|
|
2840
|
+
formatted: formatCountdown(totalMs),
|
|
2841
|
+
isExpired: totalMs <= 0
|
|
2842
|
+
};
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2800
2845
|
// src/ui/AvatarEditor.tsx
|
|
2801
2846
|
var import_react_native7 = require("react-native");
|
|
2802
2847
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -2957,11 +3002,11 @@ function AuthGate({
|
|
|
2957
3002
|
}) {
|
|
2958
3003
|
const { client, pushEnabled } = useDubs();
|
|
2959
3004
|
const auth = useAuth();
|
|
2960
|
-
const [phase, setPhase] = (0,
|
|
2961
|
-
const [registrationPhase, setRegistrationPhase] = (0,
|
|
2962
|
-
const [showPushSetup, setShowPushSetup] = (0,
|
|
2963
|
-
const [isRestoredSession, setIsRestoredSession] = (0,
|
|
2964
|
-
(0,
|
|
3005
|
+
const [phase, setPhase] = (0, import_react22.useState)("init");
|
|
3006
|
+
const [registrationPhase, setRegistrationPhase] = (0, import_react22.useState)(false);
|
|
3007
|
+
const [showPushSetup, setShowPushSetup] = (0, import_react22.useState)(false);
|
|
3008
|
+
const [isRestoredSession, setIsRestoredSession] = (0, import_react22.useState)(false);
|
|
3009
|
+
(0, import_react22.useEffect)(() => {
|
|
2965
3010
|
let cancelled = false;
|
|
2966
3011
|
(async () => {
|
|
2967
3012
|
try {
|
|
@@ -2988,23 +3033,23 @@ function AuthGate({
|
|
|
2988
3033
|
cancelled = true;
|
|
2989
3034
|
};
|
|
2990
3035
|
}, []);
|
|
2991
|
-
(0,
|
|
3036
|
+
(0, import_react22.useEffect)(() => {
|
|
2992
3037
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
2993
3038
|
}, [auth.status]);
|
|
2994
|
-
(0,
|
|
3039
|
+
(0, import_react22.useEffect)(() => {
|
|
2995
3040
|
if (pushEnabled && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
2996
3041
|
setShowPushSetup(true);
|
|
2997
3042
|
}
|
|
2998
3043
|
}, [pushEnabled, auth.status, registrationPhase, isRestoredSession]);
|
|
2999
|
-
(0,
|
|
3044
|
+
(0, import_react22.useEffect)(() => {
|
|
3000
3045
|
if (auth.token) onSaveToken(auth.token);
|
|
3001
3046
|
}, [auth.token]);
|
|
3002
|
-
const retry = (0,
|
|
3047
|
+
const retry = (0, import_react22.useCallback)(() => {
|
|
3003
3048
|
setRegistrationPhase(false);
|
|
3004
3049
|
auth.reset();
|
|
3005
3050
|
auth.authenticate();
|
|
3006
3051
|
}, [auth]);
|
|
3007
|
-
const handleRegister = (0,
|
|
3052
|
+
const handleRegister = (0, import_react22.useCallback)(
|
|
3008
3053
|
(username, referralCode, avatarUrl) => {
|
|
3009
3054
|
auth.register(username, referralCode, avatarUrl);
|
|
3010
3055
|
},
|
|
@@ -3096,7 +3141,7 @@ function DefaultErrorScreen({ error, onRetry, appName, accentColor }) {
|
|
|
3096
3141
|
function StepIndicator({ currentStep }) {
|
|
3097
3142
|
const t = useDubsTheme();
|
|
3098
3143
|
const steps = [0, 1, 2, 3];
|
|
3099
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3144
|
+
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_react22.default.Fragment, { children: [
|
|
3100
3145
|
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native8.View, { style: [s.stepLine, { backgroundColor: i <= currentStep ? t.success : t.border }] }),
|
|
3101
3146
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3102
3147
|
import_react_native8.View,
|
|
@@ -3120,20 +3165,20 @@ function DefaultRegistrationScreen({
|
|
|
3120
3165
|
}) {
|
|
3121
3166
|
const t = useDubsTheme();
|
|
3122
3167
|
const accent = accentColor || t.accent;
|
|
3123
|
-
const [step, setStep] = (0,
|
|
3124
|
-
const [avatarSeed, setAvatarSeed] = (0,
|
|
3125
|
-
const [avatarStyle, setAvatarStyle] = (0,
|
|
3126
|
-
const [avatarBg, setAvatarBg] = (0,
|
|
3127
|
-
const [showStyles, setShowStyles] = (0,
|
|
3128
|
-
const [username, setUsername] = (0,
|
|
3129
|
-
const [referralCode, setReferralCode] = (0,
|
|
3130
|
-
const [checking, setChecking] = (0,
|
|
3131
|
-
const [availability, setAvailability] = (0,
|
|
3132
|
-
const debounceRef = (0,
|
|
3133
|
-
const fadeAnim = (0,
|
|
3134
|
-
const slideAnim = (0,
|
|
3168
|
+
const [step, setStep] = (0, import_react22.useState)(0);
|
|
3169
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react22.useState)(generateSeed);
|
|
3170
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react22.useState)("adventurer");
|
|
3171
|
+
const [avatarBg, setAvatarBg] = (0, import_react22.useState)("1a1a2e");
|
|
3172
|
+
const [showStyles, setShowStyles] = (0, import_react22.useState)(false);
|
|
3173
|
+
const [username, setUsername] = (0, import_react22.useState)("");
|
|
3174
|
+
const [referralCode, setReferralCode] = (0, import_react22.useState)("");
|
|
3175
|
+
const [checking, setChecking] = (0, import_react22.useState)(false);
|
|
3176
|
+
const [availability, setAvailability] = (0, import_react22.useState)(null);
|
|
3177
|
+
const debounceRef = (0, import_react22.useRef)(null);
|
|
3178
|
+
const fadeAnim = (0, import_react22.useRef)(new import_react_native8.Animated.Value(1)).current;
|
|
3179
|
+
const slideAnim = (0, import_react22.useRef)(new import_react_native8.Animated.Value(0)).current;
|
|
3135
3180
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3136
|
-
(0,
|
|
3181
|
+
(0, import_react22.useEffect)(() => {
|
|
3137
3182
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3138
3183
|
const trimmed = username.trim();
|
|
3139
3184
|
if (trimmed.length < 3) {
|
|
@@ -3156,7 +3201,7 @@ function DefaultRegistrationScreen({
|
|
|
3156
3201
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3157
3202
|
};
|
|
3158
3203
|
}, [username, client]);
|
|
3159
|
-
const animateToStep = (0,
|
|
3204
|
+
const animateToStep = (0, import_react22.useCallback)((newStep) => {
|
|
3160
3205
|
const dir = newStep > step ? 1 : -1;
|
|
3161
3206
|
import_react_native8.Keyboard.dismiss();
|
|
3162
3207
|
import_react_native8.Animated.parallel([
|
|
@@ -3395,8 +3440,8 @@ function DefaultRegistrationScreen({
|
|
|
3395
3440
|
}
|
|
3396
3441
|
function PushTokenRestorer() {
|
|
3397
3442
|
const push = usePushNotifications();
|
|
3398
|
-
const restored = (0,
|
|
3399
|
-
(0,
|
|
3443
|
+
const restored = (0, import_react22.useRef)(false);
|
|
3444
|
+
(0, import_react22.useEffect)(() => {
|
|
3400
3445
|
if (restored.current) return;
|
|
3401
3446
|
restored.current = true;
|
|
3402
3447
|
push.restoreIfGranted();
|
|
@@ -3411,9 +3456,9 @@ function PushSetupScreen({
|
|
|
3411
3456
|
const t = useDubsTheme();
|
|
3412
3457
|
const accent = accentColor || t.accent;
|
|
3413
3458
|
const push = usePushNotifications();
|
|
3414
|
-
const fadeAnim = (0,
|
|
3415
|
-
const slideAnim = (0,
|
|
3416
|
-
(0,
|
|
3459
|
+
const fadeAnim = (0, import_react22.useRef)(new import_react_native8.Animated.Value(0)).current;
|
|
3460
|
+
const slideAnim = (0, import_react22.useRef)(new import_react_native8.Animated.Value(30)).current;
|
|
3461
|
+
(0, import_react22.useEffect)(() => {
|
|
3417
3462
|
import_react_native8.Animated.parallel([
|
|
3418
3463
|
import_react_native8.Animated.timing(fadeAnim, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
3419
3464
|
import_react_native8.Animated.timing(slideAnim, { toValue: 0, duration: 300, useNativeDriver: true })
|
|
@@ -3549,7 +3594,7 @@ var s = import_react_native8.StyleSheet.create({
|
|
|
3549
3594
|
|
|
3550
3595
|
// src/provider.tsx
|
|
3551
3596
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3552
|
-
var DubsContext = (0,
|
|
3597
|
+
var DubsContext = (0, import_react23.createContext)(null);
|
|
3553
3598
|
function DubsProvider({
|
|
3554
3599
|
apiKey,
|
|
3555
3600
|
children,
|
|
@@ -3571,11 +3616,11 @@ function DubsProvider({
|
|
|
3571
3616
|
const config = NETWORK_CONFIG[network];
|
|
3572
3617
|
const baseUrl = baseUrlOverride || config.baseUrl;
|
|
3573
3618
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
3574
|
-
const client = (0,
|
|
3575
|
-
const storage = (0,
|
|
3576
|
-
const [uiConfig, setUiConfig] = (0,
|
|
3577
|
-
const [resolvedNetwork, setResolvedNetwork] = (0,
|
|
3578
|
-
(0,
|
|
3619
|
+
const client = (0, import_react23.useMemo)(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
3620
|
+
const storage = (0, import_react23.useMemo)(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
3621
|
+
const [uiConfig, setUiConfig] = (0, import_react23.useState)(null);
|
|
3622
|
+
const [resolvedNetwork, setResolvedNetwork] = (0, import_react23.useState)(network);
|
|
3623
|
+
(0, import_react23.useEffect)(() => {
|
|
3579
3624
|
client.getAppConfig().then((cfg) => {
|
|
3580
3625
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
3581
3626
|
setUiConfig(cfg);
|
|
@@ -3591,7 +3636,7 @@ function DubsProvider({
|
|
|
3591
3636
|
const resolvedConfig = NETWORK_CONFIG[resolvedNetwork];
|
|
3592
3637
|
const resolvedRpcUrl = rpcUrlOverride || resolvedConfig.rpcUrl;
|
|
3593
3638
|
const cluster = resolvedConfig.cluster;
|
|
3594
|
-
const connection = (0,
|
|
3639
|
+
const connection = (0, import_react23.useMemo)(() => new import_web34.Connection(resolvedRpcUrl, { commitment: "confirmed" }), [resolvedRpcUrl]);
|
|
3595
3640
|
if (uiConfig === null) return null;
|
|
3596
3641
|
const themeOverrides = {};
|
|
3597
3642
|
if (uiConfig.accentColor) {
|
|
@@ -3667,11 +3712,11 @@ function ManagedInner({
|
|
|
3667
3712
|
children
|
|
3668
3713
|
}) {
|
|
3669
3714
|
const managedDisconnect = useDisconnect();
|
|
3670
|
-
const disconnect = (0,
|
|
3715
|
+
const disconnect = (0, import_react23.useCallback)(async () => {
|
|
3671
3716
|
client.setToken(null);
|
|
3672
3717
|
await managedDisconnect?.();
|
|
3673
3718
|
}, [client, managedDisconnect]);
|
|
3674
|
-
const value = (0,
|
|
3719
|
+
const value = (0, import_react23.useMemo)(
|
|
3675
3720
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
3676
3721
|
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
3677
3722
|
);
|
|
@@ -3708,13 +3753,13 @@ function ExternalWalletProvider({
|
|
|
3708
3753
|
pushEnabled,
|
|
3709
3754
|
children
|
|
3710
3755
|
}) {
|
|
3711
|
-
const disconnect = (0,
|
|
3756
|
+
const disconnect = (0, import_react23.useCallback)(async () => {
|
|
3712
3757
|
client.setToken(null);
|
|
3713
3758
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
3714
3759
|
});
|
|
3715
3760
|
await wallet.disconnect?.();
|
|
3716
3761
|
}, [client, storage, wallet]);
|
|
3717
|
-
const value = (0,
|
|
3762
|
+
const value = (0, import_react23.useMemo)(
|
|
3718
3763
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
3719
3764
|
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
3720
3765
|
);
|
|
@@ -3739,19 +3784,19 @@ function ExternalWalletProvider({
|
|
|
3739
3784
|
) });
|
|
3740
3785
|
}
|
|
3741
3786
|
function useDubs() {
|
|
3742
|
-
const ctx = (0,
|
|
3787
|
+
const ctx = (0, import_react23.useContext)(DubsContext);
|
|
3743
3788
|
if (!ctx) {
|
|
3744
3789
|
throw new Error("useDubs must be used within a <DubsProvider>");
|
|
3745
3790
|
}
|
|
3746
3791
|
return ctx;
|
|
3747
3792
|
}
|
|
3748
3793
|
function useAppConfig() {
|
|
3749
|
-
const ctx = (0,
|
|
3794
|
+
const ctx = (0, import_react23.useContext)(DubsContext);
|
|
3750
3795
|
return ctx?.uiConfig || {};
|
|
3751
3796
|
}
|
|
3752
3797
|
|
|
3753
3798
|
// src/ui/UserProfileCard.tsx
|
|
3754
|
-
var
|
|
3799
|
+
var import_react24 = require("react");
|
|
3755
3800
|
var import_react_native9 = require("react-native");
|
|
3756
3801
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3757
3802
|
function truncateAddress(address, chars = 4) {
|
|
@@ -3771,7 +3816,7 @@ function UserProfileCard({
|
|
|
3771
3816
|
memberSince
|
|
3772
3817
|
}) {
|
|
3773
3818
|
const t = useDubsTheme();
|
|
3774
|
-
const imageUri = (0,
|
|
3819
|
+
const imageUri = (0, import_react24.useMemo)(
|
|
3775
3820
|
() => ensurePngAvatar(avatarUrl) || `https://api.dicebear.com/9.x/avataaars/png?seed=${walletAddress}&size=128`,
|
|
3776
3821
|
[avatarUrl, walletAddress]
|
|
3777
3822
|
);
|
|
@@ -3964,7 +4009,7 @@ var styles4 = import_react_native10.StyleSheet.create({
|
|
|
3964
4009
|
});
|
|
3965
4010
|
|
|
3966
4011
|
// src/ui/UserProfileSheet.tsx
|
|
3967
|
-
var
|
|
4012
|
+
var import_react25 = require("react");
|
|
3968
4013
|
var import_react_native11 = require("react-native");
|
|
3969
4014
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3970
4015
|
function truncateAddress3(address, chars = 4) {
|
|
@@ -3982,31 +4027,31 @@ function UserProfileSheet({
|
|
|
3982
4027
|
const { client } = useDubs();
|
|
3983
4028
|
const { refreshUser } = useAuth();
|
|
3984
4029
|
const push = usePushNotifications();
|
|
3985
|
-
const overlayOpacity = (0,
|
|
3986
|
-
const parsed = (0,
|
|
3987
|
-
const [avatarStyle, setAvatarStyle] = (0,
|
|
3988
|
-
const [avatarSeed, setAvatarSeed] = (0,
|
|
3989
|
-
const [bgColor, setBgColor] = (0,
|
|
3990
|
-
const [saving, setSaving] = (0,
|
|
3991
|
-
const [error, setError] = (0,
|
|
3992
|
-
(0,
|
|
4030
|
+
const overlayOpacity = (0, import_react25.useRef)(new import_react_native11.Animated.Value(0)).current;
|
|
4031
|
+
const parsed = (0, import_react25.useMemo)(() => parseAvatarUrl(user.avatar), [user.avatar]);
|
|
4032
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react25.useState)(parsed.style);
|
|
4033
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react25.useState)(parsed.seed);
|
|
4034
|
+
const [bgColor, setBgColor] = (0, import_react25.useState)(parsed.bg);
|
|
4035
|
+
const [saving, setSaving] = (0, import_react25.useState)(false);
|
|
4036
|
+
const [error, setError] = (0, import_react25.useState)(null);
|
|
4037
|
+
(0, import_react25.useEffect)(() => {
|
|
3993
4038
|
const p = parseAvatarUrl(user.avatar);
|
|
3994
4039
|
setAvatarStyle(p.style);
|
|
3995
4040
|
setAvatarSeed(p.seed);
|
|
3996
4041
|
setBgColor(p.bg);
|
|
3997
4042
|
}, [user.avatar]);
|
|
3998
|
-
(0,
|
|
4043
|
+
(0, import_react25.useEffect)(() => {
|
|
3999
4044
|
import_react_native11.Animated.timing(overlayOpacity, {
|
|
4000
4045
|
toValue: visible ? 1 : 0,
|
|
4001
4046
|
duration: 250,
|
|
4002
4047
|
useNativeDriver: true
|
|
4003
4048
|
}).start();
|
|
4004
4049
|
}, [visible, overlayOpacity]);
|
|
4005
|
-
(0,
|
|
4050
|
+
(0, import_react25.useEffect)(() => {
|
|
4006
4051
|
if (visible) setError(null);
|
|
4007
4052
|
}, [visible]);
|
|
4008
4053
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4009
|
-
const saveAvatar = (0,
|
|
4054
|
+
const saveAvatar = (0, import_react25.useCallback)(async (newUrl) => {
|
|
4010
4055
|
setSaving(true);
|
|
4011
4056
|
setError(null);
|
|
4012
4057
|
try {
|
|
@@ -4019,16 +4064,16 @@ function UserProfileSheet({
|
|
|
4019
4064
|
setSaving(false);
|
|
4020
4065
|
}
|
|
4021
4066
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4022
|
-
const handleStyleChange = (0,
|
|
4067
|
+
const handleStyleChange = (0, import_react25.useCallback)((style) => {
|
|
4023
4068
|
setAvatarStyle(style);
|
|
4024
4069
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4025
4070
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4026
|
-
const handleShuffle = (0,
|
|
4071
|
+
const handleShuffle = (0, import_react25.useCallback)(() => {
|
|
4027
4072
|
const newSeed = generateSeed();
|
|
4028
4073
|
setAvatarSeed(newSeed);
|
|
4029
4074
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4030
4075
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4031
|
-
const handleBgChange = (0,
|
|
4076
|
+
const handleBgChange = (0, import_react25.useCallback)((color) => {
|
|
4032
4077
|
setBgColor(color);
|
|
4033
4078
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4034
4079
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4308,7 +4353,7 @@ var styles5 = import_react_native11.StyleSheet.create({
|
|
|
4308
4353
|
});
|
|
4309
4354
|
|
|
4310
4355
|
// src/ui/game/GamePoster.tsx
|
|
4311
|
-
var
|
|
4356
|
+
var import_react26 = require("react");
|
|
4312
4357
|
var import_react_native12 = require("react-native");
|
|
4313
4358
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4314
4359
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4358,7 +4403,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4358
4403
|
] });
|
|
4359
4404
|
}
|
|
4360
4405
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4361
|
-
const [failed, setFailed] = (0,
|
|
4406
|
+
const [failed, setFailed] = (0, import_react26.useState)(false);
|
|
4362
4407
|
if (!url || failed) {
|
|
4363
4408
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.View, { style: [styles6.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4364
4409
|
}
|
|
@@ -4459,7 +4504,7 @@ var styles6 = import_react_native12.StyleSheet.create({
|
|
|
4459
4504
|
});
|
|
4460
4505
|
|
|
4461
4506
|
// src/ui/game/LivePoolsCard.tsx
|
|
4462
|
-
var
|
|
4507
|
+
var import_react27 = require("react");
|
|
4463
4508
|
var import_react_native13 = require("react-native");
|
|
4464
4509
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4465
4510
|
function LivePoolsCard({
|
|
@@ -4475,7 +4520,7 @@ function LivePoolsCard({
|
|
|
4475
4520
|
const homePool = game.homePool || 0;
|
|
4476
4521
|
const awayPool = game.awayPool || 0;
|
|
4477
4522
|
const totalPool = game.totalPool || 0;
|
|
4478
|
-
const { homePercent, awayPercent, homeOdds, awayOdds } = (0,
|
|
4523
|
+
const { homePercent, awayPercent, homeOdds, awayOdds } = (0, import_react27.useMemo)(() => {
|
|
4479
4524
|
return {
|
|
4480
4525
|
homePercent: totalPool > 0 ? homePool / totalPool * 100 : 50,
|
|
4481
4526
|
awayPercent: totalPool > 0 ? awayPool / totalPool * 100 : 50,
|
|
@@ -4538,7 +4583,7 @@ var styles7 = import_react_native13.StyleSheet.create({
|
|
|
4538
4583
|
});
|
|
4539
4584
|
|
|
4540
4585
|
// src/ui/game/PickWinnerCard.tsx
|
|
4541
|
-
var
|
|
4586
|
+
var import_react28 = require("react");
|
|
4542
4587
|
var import_react_native14 = require("react-native");
|
|
4543
4588
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
4544
4589
|
function PickWinnerCard({
|
|
@@ -4556,7 +4601,7 @@ function PickWinnerCard({
|
|
|
4556
4601
|
const totalPool = game.totalPool || 0;
|
|
4557
4602
|
const homePool = game.homePool || 0;
|
|
4558
4603
|
const awayPool = game.awayPool || 0;
|
|
4559
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
4604
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react28.useMemo)(() => ({
|
|
4560
4605
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
4561
4606
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
4562
4607
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -4609,7 +4654,7 @@ function TeamOption({
|
|
|
4609
4654
|
ImageComponent,
|
|
4610
4655
|
t
|
|
4611
4656
|
}) {
|
|
4612
|
-
const [imgFailed, setImgFailed] = (0,
|
|
4657
|
+
const [imgFailed, setImgFailed] = (0, import_react28.useState)(false);
|
|
4613
4658
|
const Img = ImageComponent || require("react-native").Image;
|
|
4614
4659
|
const showImage = imageUrl && !imgFailed;
|
|
4615
4660
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
@@ -4650,7 +4695,7 @@ var styles8 = import_react_native14.StyleSheet.create({
|
|
|
4650
4695
|
});
|
|
4651
4696
|
|
|
4652
4697
|
// src/ui/game/PlayersCard.tsx
|
|
4653
|
-
var
|
|
4698
|
+
var import_react29 = require("react");
|
|
4654
4699
|
var import_react_native15 = require("react-native");
|
|
4655
4700
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
4656
4701
|
function truncateWallet(addr, chars) {
|
|
@@ -4699,7 +4744,7 @@ function BettorRow({
|
|
|
4699
4744
|
ImageComponent,
|
|
4700
4745
|
t
|
|
4701
4746
|
}) {
|
|
4702
|
-
const [imgFailed, setImgFailed] = (0,
|
|
4747
|
+
const [imgFailed, setImgFailed] = (0, import_react29.useState)(false);
|
|
4703
4748
|
const Img = ImageComponent || require("react-native").Image;
|
|
4704
4749
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
4705
4750
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native15.View, { style: [styles9.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -4726,7 +4771,7 @@ var styles9 = import_react_native15.StyleSheet.create({
|
|
|
4726
4771
|
});
|
|
4727
4772
|
|
|
4728
4773
|
// src/ui/game/JoinGameButton.tsx
|
|
4729
|
-
var
|
|
4774
|
+
var import_react30 = require("react");
|
|
4730
4775
|
var import_react_native16 = require("react-native");
|
|
4731
4776
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
4732
4777
|
var STATUS_LABELS = {
|
|
@@ -4737,7 +4782,7 @@ var STATUS_LABELS = {
|
|
|
4737
4782
|
};
|
|
4738
4783
|
function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }) {
|
|
4739
4784
|
const t = useDubsTheme();
|
|
4740
|
-
const alreadyJoined = (0,
|
|
4785
|
+
const alreadyJoined = (0, import_react30.useMemo)(() => {
|
|
4741
4786
|
if (!walletAddress) return false;
|
|
4742
4787
|
return (game.bettors || []).some((b) => b.wallet === walletAddress);
|
|
4743
4788
|
}, [game.bettors, walletAddress]);
|
|
@@ -4778,7 +4823,7 @@ var styles10 = import_react_native16.StyleSheet.create({
|
|
|
4778
4823
|
});
|
|
4779
4824
|
|
|
4780
4825
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
4781
|
-
var
|
|
4826
|
+
var import_react31 = require("react");
|
|
4782
4827
|
var import_react_native17 = require("react-native");
|
|
4783
4828
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4784
4829
|
var STATUS_LABELS2 = {
|
|
@@ -4804,18 +4849,18 @@ function CreateCustomGameSheet({
|
|
|
4804
4849
|
const t = useDubsTheme();
|
|
4805
4850
|
const { wallet } = useDubs();
|
|
4806
4851
|
const mutation = useCreateCustomGame();
|
|
4807
|
-
const [selectedAmount, setSelectedAmount] = (0,
|
|
4808
|
-
const [customAmount, setCustomAmount] = (0,
|
|
4809
|
-
const [isCustom, setIsCustom] = (0,
|
|
4810
|
-
const overlayOpacity = (0,
|
|
4811
|
-
(0,
|
|
4852
|
+
const [selectedAmount, setSelectedAmount] = (0, import_react31.useState)(null);
|
|
4853
|
+
const [customAmount, setCustomAmount] = (0, import_react31.useState)("");
|
|
4854
|
+
const [isCustom, setIsCustom] = (0, import_react31.useState)(false);
|
|
4855
|
+
const overlayOpacity = (0, import_react31.useRef)(new import_react_native17.Animated.Value(0)).current;
|
|
4856
|
+
(0, import_react31.useEffect)(() => {
|
|
4812
4857
|
import_react_native17.Animated.timing(overlayOpacity, {
|
|
4813
4858
|
toValue: visible ? 1 : 0,
|
|
4814
4859
|
duration: 250,
|
|
4815
4860
|
useNativeDriver: true
|
|
4816
4861
|
}).start();
|
|
4817
4862
|
}, [visible, overlayOpacity]);
|
|
4818
|
-
(0,
|
|
4863
|
+
(0, import_react31.useEffect)(() => {
|
|
4819
4864
|
if (visible) {
|
|
4820
4865
|
setSelectedAmount(defaultAmount ?? null);
|
|
4821
4866
|
setCustomAmount("");
|
|
@@ -4823,7 +4868,7 @@ function CreateCustomGameSheet({
|
|
|
4823
4868
|
mutation.reset();
|
|
4824
4869
|
}
|
|
4825
4870
|
}, [visible]);
|
|
4826
|
-
(0,
|
|
4871
|
+
(0, import_react31.useEffect)(() => {
|
|
4827
4872
|
if (mutation.status === "success" && mutation.data) {
|
|
4828
4873
|
onSuccess?.(mutation.data);
|
|
4829
4874
|
const timer = setTimeout(() => {
|
|
@@ -4832,23 +4877,23 @@ function CreateCustomGameSheet({
|
|
|
4832
4877
|
return () => clearTimeout(timer);
|
|
4833
4878
|
}
|
|
4834
4879
|
}, [mutation.status, mutation.data]);
|
|
4835
|
-
(0,
|
|
4880
|
+
(0, import_react31.useEffect)(() => {
|
|
4836
4881
|
if (mutation.status === "error" && mutation.error) {
|
|
4837
4882
|
onError?.(mutation.error);
|
|
4838
4883
|
}
|
|
4839
4884
|
}, [mutation.status, mutation.error]);
|
|
4840
|
-
const handlePresetSelect = (0,
|
|
4885
|
+
const handlePresetSelect = (0, import_react31.useCallback)((amount) => {
|
|
4841
4886
|
setSelectedAmount(amount);
|
|
4842
4887
|
setIsCustom(false);
|
|
4843
4888
|
setCustomAmount("");
|
|
4844
4889
|
onAmountChange?.(amount);
|
|
4845
4890
|
}, [onAmountChange]);
|
|
4846
|
-
const handleCustomSelect = (0,
|
|
4891
|
+
const handleCustomSelect = (0, import_react31.useCallback)(() => {
|
|
4847
4892
|
setIsCustom(true);
|
|
4848
4893
|
setSelectedAmount(null);
|
|
4849
4894
|
onAmountChange?.(null);
|
|
4850
4895
|
}, [onAmountChange]);
|
|
4851
|
-
const handleCustomAmountChange = (0,
|
|
4896
|
+
const handleCustomAmountChange = (0, import_react31.useCallback)((text) => {
|
|
4852
4897
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
4853
4898
|
setCustomAmount(cleaned);
|
|
4854
4899
|
const parsed = parseFloat(cleaned);
|
|
@@ -4863,7 +4908,7 @@ function CreateCustomGameSheet({
|
|
|
4863
4908
|
const winnerTakes = pot * (1 - fee / 100);
|
|
4864
4909
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4865
4910
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
4866
|
-
const handleCreate = (0,
|
|
4911
|
+
const handleCreate = (0, import_react31.useCallback)(async () => {
|
|
4867
4912
|
if (!finalAmount || !wallet.publicKey) return;
|
|
4868
4913
|
try {
|
|
4869
4914
|
await mutation.execute({
|
|
@@ -5132,7 +5177,7 @@ var styles11 = import_react_native17.StyleSheet.create({
|
|
|
5132
5177
|
});
|
|
5133
5178
|
|
|
5134
5179
|
// src/ui/game/JoinGameSheet.tsx
|
|
5135
|
-
var
|
|
5180
|
+
var import_react32 = require("react");
|
|
5136
5181
|
var import_react_native18 = require("react-native");
|
|
5137
5182
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5138
5183
|
var STATUS_LABELS3 = {
|
|
@@ -5158,22 +5203,22 @@ function JoinGameSheet({
|
|
|
5158
5203
|
const { wallet } = useDubs();
|
|
5159
5204
|
const mutation = useJoinGame();
|
|
5160
5205
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
5161
|
-
const [selectedTeam, setSelectedTeam] = (0,
|
|
5162
|
-
const overlayOpacity = (0,
|
|
5163
|
-
(0,
|
|
5206
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react32.useState)(null);
|
|
5207
|
+
const overlayOpacity = (0, import_react32.useRef)(new import_react_native18.Animated.Value(0)).current;
|
|
5208
|
+
(0, import_react32.useEffect)(() => {
|
|
5164
5209
|
import_react_native18.Animated.timing(overlayOpacity, {
|
|
5165
5210
|
toValue: visible ? 1 : 0,
|
|
5166
5211
|
duration: 250,
|
|
5167
5212
|
useNativeDriver: true
|
|
5168
5213
|
}).start();
|
|
5169
5214
|
}, [visible, overlayOpacity]);
|
|
5170
|
-
(0,
|
|
5215
|
+
(0, import_react32.useEffect)(() => {
|
|
5171
5216
|
if (visible) {
|
|
5172
5217
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
5173
5218
|
mutation.reset();
|
|
5174
5219
|
}
|
|
5175
5220
|
}, [visible]);
|
|
5176
|
-
(0,
|
|
5221
|
+
(0, import_react32.useEffect)(() => {
|
|
5177
5222
|
if (mutation.status === "success" && mutation.data) {
|
|
5178
5223
|
onSuccess?.(mutation.data);
|
|
5179
5224
|
const timer = setTimeout(() => {
|
|
@@ -5182,7 +5227,7 @@ function JoinGameSheet({
|
|
|
5182
5227
|
return () => clearTimeout(timer);
|
|
5183
5228
|
}
|
|
5184
5229
|
}, [mutation.status, mutation.data]);
|
|
5185
|
-
(0,
|
|
5230
|
+
(0, import_react32.useEffect)(() => {
|
|
5186
5231
|
if (mutation.status === "error" && mutation.error) {
|
|
5187
5232
|
onError?.(mutation.error);
|
|
5188
5233
|
}
|
|
@@ -5193,7 +5238,7 @@ function JoinGameSheet({
|
|
|
5193
5238
|
const homePool = game.homePool || 0;
|
|
5194
5239
|
const awayPool = game.awayPool || 0;
|
|
5195
5240
|
const buyIn = game.buyIn;
|
|
5196
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
5241
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react32.useMemo)(() => ({
|
|
5197
5242
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
5198
5243
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
5199
5244
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -5205,14 +5250,14 @@ function JoinGameSheet({
|
|
|
5205
5250
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
5206
5251
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
5207
5252
|
const selectedName = selectedTeam === "home" ? homeName : selectedTeam === "away" ? awayName : "\u2014";
|
|
5208
|
-
const alreadyJoined = (0,
|
|
5253
|
+
const alreadyJoined = (0, import_react32.useMemo)(() => {
|
|
5209
5254
|
if (!wallet.publicKey) return false;
|
|
5210
5255
|
const addr = wallet.publicKey.toBase58();
|
|
5211
5256
|
return bettors.some((b) => b.wallet === addr);
|
|
5212
5257
|
}, [bettors, wallet.publicKey]);
|
|
5213
5258
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5214
5259
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
5215
|
-
const handleJoin = (0,
|
|
5260
|
+
const handleJoin = (0, import_react32.useCallback)(async () => {
|
|
5216
5261
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
5217
5262
|
try {
|
|
5218
5263
|
await mutation.execute({
|
|
@@ -5356,7 +5401,7 @@ function TeamButton({
|
|
|
5356
5401
|
ImageComponent,
|
|
5357
5402
|
t
|
|
5358
5403
|
}) {
|
|
5359
|
-
const [imgFailed, setImgFailed] = (0,
|
|
5404
|
+
const [imgFailed, setImgFailed] = (0, import_react32.useState)(false);
|
|
5360
5405
|
const Img = ImageComponent || require("react-native").Image;
|
|
5361
5406
|
const showImage = imageUrl && !imgFailed;
|
|
5362
5407
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
@@ -5533,7 +5578,7 @@ var styles12 = import_react_native18.StyleSheet.create({
|
|
|
5533
5578
|
});
|
|
5534
5579
|
|
|
5535
5580
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
5536
|
-
var
|
|
5581
|
+
var import_react33 = require("react");
|
|
5537
5582
|
var import_react_native19 = require("react-native");
|
|
5538
5583
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
5539
5584
|
var STATUS_LABELS4 = {
|
|
@@ -5554,18 +5599,18 @@ function ClaimPrizeSheet({
|
|
|
5554
5599
|
const t = useDubsTheme();
|
|
5555
5600
|
const { wallet } = useDubs();
|
|
5556
5601
|
const mutation = useClaim();
|
|
5557
|
-
const overlayOpacity = (0,
|
|
5558
|
-
const celebrationScale = (0,
|
|
5559
|
-
const celebrationOpacity = (0,
|
|
5560
|
-
const [showCelebration, setShowCelebration] = (0,
|
|
5561
|
-
(0,
|
|
5602
|
+
const overlayOpacity = (0, import_react33.useRef)(new import_react_native19.Animated.Value(0)).current;
|
|
5603
|
+
const celebrationScale = (0, import_react33.useRef)(new import_react_native19.Animated.Value(0)).current;
|
|
5604
|
+
const celebrationOpacity = (0, import_react33.useRef)(new import_react_native19.Animated.Value(0)).current;
|
|
5605
|
+
const [showCelebration, setShowCelebration] = (0, import_react33.useState)(false);
|
|
5606
|
+
(0, import_react33.useEffect)(() => {
|
|
5562
5607
|
import_react_native19.Animated.timing(overlayOpacity, {
|
|
5563
5608
|
toValue: visible ? 1 : 0,
|
|
5564
5609
|
duration: 250,
|
|
5565
5610
|
useNativeDriver: true
|
|
5566
5611
|
}).start();
|
|
5567
5612
|
}, [visible, overlayOpacity]);
|
|
5568
|
-
(0,
|
|
5613
|
+
(0, import_react33.useEffect)(() => {
|
|
5569
5614
|
if (visible) {
|
|
5570
5615
|
mutation.reset();
|
|
5571
5616
|
setShowCelebration(false);
|
|
@@ -5573,7 +5618,7 @@ function ClaimPrizeSheet({
|
|
|
5573
5618
|
celebrationOpacity.setValue(0);
|
|
5574
5619
|
}
|
|
5575
5620
|
}, [visible]);
|
|
5576
|
-
(0,
|
|
5621
|
+
(0, import_react33.useEffect)(() => {
|
|
5577
5622
|
if (mutation.status === "success" && mutation.data) {
|
|
5578
5623
|
setShowCelebration(true);
|
|
5579
5624
|
import_react_native19.Animated.parallel([
|
|
@@ -5596,14 +5641,14 @@ function ClaimPrizeSheet({
|
|
|
5596
5641
|
return () => clearTimeout(timer);
|
|
5597
5642
|
}
|
|
5598
5643
|
}, [mutation.status, mutation.data]);
|
|
5599
|
-
(0,
|
|
5644
|
+
(0, import_react33.useEffect)(() => {
|
|
5600
5645
|
if (mutation.status === "error" && mutation.error) {
|
|
5601
5646
|
onError?.(mutation.error);
|
|
5602
5647
|
}
|
|
5603
5648
|
}, [mutation.status, mutation.error]);
|
|
5604
5649
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5605
5650
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
5606
|
-
const handleClaim = (0,
|
|
5651
|
+
const handleClaim = (0, import_react33.useCallback)(async () => {
|
|
5607
5652
|
if (!wallet.publicKey) return;
|
|
5608
5653
|
try {
|
|
5609
5654
|
await mutation.execute({
|
|
@@ -5836,7 +5881,7 @@ var styles13 = import_react_native19.StyleSheet.create({
|
|
|
5836
5881
|
});
|
|
5837
5882
|
|
|
5838
5883
|
// src/ui/game/ClaimButton.tsx
|
|
5839
|
-
var
|
|
5884
|
+
var import_react34 = require("react");
|
|
5840
5885
|
var import_react_native20 = require("react-native");
|
|
5841
5886
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
5842
5887
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -5844,9 +5889,9 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5844
5889
|
const { wallet } = useDubs();
|
|
5845
5890
|
const game = useGame(gameId);
|
|
5846
5891
|
const claimStatus = useHasClaimed(gameId);
|
|
5847
|
-
const [sheetVisible, setSheetVisible] = (0,
|
|
5892
|
+
const [sheetVisible, setSheetVisible] = (0, import_react34.useState)(false);
|
|
5848
5893
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
5849
|
-
const myBet = (0,
|
|
5894
|
+
const myBet = (0, import_react34.useMemo)(() => {
|
|
5850
5895
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
5851
5896
|
return game.data.bettors.find((b) => b.wallet === walletAddress) ?? null;
|
|
5852
5897
|
}, [walletAddress, game.data?.bettors]);
|
|
@@ -5855,7 +5900,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5855
5900
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
5856
5901
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
5857
5902
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
5858
|
-
const handleSuccess = (0,
|
|
5903
|
+
const handleSuccess = (0, import_react34.useCallback)(
|
|
5859
5904
|
(result) => {
|
|
5860
5905
|
claimStatus.refetch();
|
|
5861
5906
|
onSuccess?.(result);
|
|
@@ -5942,7 +5987,7 @@ var styles14 = import_react_native20.StyleSheet.create({
|
|
|
5942
5987
|
});
|
|
5943
5988
|
|
|
5944
5989
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
5945
|
-
var
|
|
5990
|
+
var import_react35 = require("react");
|
|
5946
5991
|
var import_react_native21 = require("react-native");
|
|
5947
5992
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
5948
5993
|
var STATUS_LABELS5 = {
|
|
@@ -5963,20 +6008,20 @@ function EnterArcadePoolSheet({
|
|
|
5963
6008
|
const t = useDubsTheme();
|
|
5964
6009
|
const { wallet } = useDubs();
|
|
5965
6010
|
const mutation = useEnterArcadePool();
|
|
5966
|
-
const overlayOpacity = (0,
|
|
5967
|
-
(0,
|
|
6011
|
+
const overlayOpacity = (0, import_react35.useRef)(new import_react_native21.Animated.Value(0)).current;
|
|
6012
|
+
(0, import_react35.useEffect)(() => {
|
|
5968
6013
|
import_react_native21.Animated.timing(overlayOpacity, {
|
|
5969
6014
|
toValue: visible ? 1 : 0,
|
|
5970
6015
|
duration: 250,
|
|
5971
6016
|
useNativeDriver: true
|
|
5972
6017
|
}).start();
|
|
5973
6018
|
}, [visible, overlayOpacity]);
|
|
5974
|
-
(0,
|
|
6019
|
+
(0, import_react35.useEffect)(() => {
|
|
5975
6020
|
if (visible) {
|
|
5976
6021
|
mutation.reset();
|
|
5977
6022
|
}
|
|
5978
6023
|
}, [visible]);
|
|
5979
|
-
(0,
|
|
6024
|
+
(0, import_react35.useEffect)(() => {
|
|
5980
6025
|
if (mutation.status === "success" && mutation.data) {
|
|
5981
6026
|
onSuccess?.(mutation.data);
|
|
5982
6027
|
const timer = setTimeout(() => {
|
|
@@ -5985,7 +6030,7 @@ function EnterArcadePoolSheet({
|
|
|
5985
6030
|
return () => clearTimeout(timer);
|
|
5986
6031
|
}
|
|
5987
6032
|
}, [mutation.status, mutation.data]);
|
|
5988
|
-
(0,
|
|
6033
|
+
(0, import_react35.useEffect)(() => {
|
|
5989
6034
|
if (mutation.status === "error" && mutation.error) {
|
|
5990
6035
|
onError?.(mutation.error);
|
|
5991
6036
|
}
|
|
@@ -5996,7 +6041,7 @@ function EnterArcadePoolSheet({
|
|
|
5996
6041
|
const potSol = (pool.buy_in_lamports * Number(totalPlayers) / 1e9).toFixed(4);
|
|
5997
6042
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5998
6043
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
5999
|
-
const handleJoin = (0,
|
|
6044
|
+
const handleJoin = (0, import_react35.useCallback)(async () => {
|
|
6000
6045
|
if (!wallet.publicKey) return;
|
|
6001
6046
|
try {
|
|
6002
6047
|
await mutation.execute(pool.id);
|
|
@@ -6147,7 +6192,7 @@ var styles15 = import_react_native21.StyleSheet.create({
|
|
|
6147
6192
|
});
|
|
6148
6193
|
|
|
6149
6194
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
6150
|
-
var
|
|
6195
|
+
var import_react36 = require("react");
|
|
6151
6196
|
var import_react_native22 = require("react-native");
|
|
6152
6197
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
6153
6198
|
function RankLabel({ index }) {
|
|
@@ -6164,15 +6209,15 @@ function ArcadeLeaderboardSheet({
|
|
|
6164
6209
|
}) {
|
|
6165
6210
|
const t = useDubsTheme();
|
|
6166
6211
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
6167
|
-
const overlayOpacity = (0,
|
|
6168
|
-
(0,
|
|
6212
|
+
const overlayOpacity = (0, import_react36.useRef)(new import_react_native22.Animated.Value(0)).current;
|
|
6213
|
+
(0, import_react36.useEffect)(() => {
|
|
6169
6214
|
import_react_native22.Animated.timing(overlayOpacity, {
|
|
6170
6215
|
toValue: visible ? 1 : 0,
|
|
6171
6216
|
duration: 250,
|
|
6172
6217
|
useNativeDriver: true
|
|
6173
6218
|
}).start();
|
|
6174
6219
|
}, [visible, overlayOpacity]);
|
|
6175
|
-
(0,
|
|
6220
|
+
(0, import_react36.useEffect)(() => {
|
|
6176
6221
|
if (visible) refetch();
|
|
6177
6222
|
}, [visible]);
|
|
6178
6223
|
const renderItem = ({ item, index }) => {
|
|
@@ -6353,6 +6398,7 @@ var styles16 = import_react_native22.StyleSheet.create({
|
|
|
6353
6398
|
parseSolanaError,
|
|
6354
6399
|
signAndSendBase64Transaction,
|
|
6355
6400
|
useAppConfig,
|
|
6401
|
+
useArcadeCountdown,
|
|
6356
6402
|
useArcadeGame,
|
|
6357
6403
|
useArcadePool,
|
|
6358
6404
|
useArcadePools,
|