@dubsdotapp/expo 0.5.30 → 0.5.32
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 +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +264 -223
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +213 -173
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +17 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useCredits.ts +48 -0
- package/src/index.ts +3 -0
- package/src/types.ts +15 -0
package/dist/index.mjs
CHANGED
|
@@ -603,6 +603,16 @@ var DubsClient = class {
|
|
|
603
603
|
);
|
|
604
604
|
return { round: res.round, lastWinner: res.lastWinner };
|
|
605
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* List the authenticated user's active promo credits — codes that
|
|
608
|
+
* have been reserved to them but not yet used in a game. Includes
|
|
609
|
+
* streak-milestone unlocks (auto-minted at each 1000-dub crossing)
|
|
610
|
+
* and any manually-reserved Twitter giveaway codes.
|
|
611
|
+
*/
|
|
612
|
+
async getCredits() {
|
|
613
|
+
const res = await this.request("GET", "/me/credits");
|
|
614
|
+
return { credits: res.credits, totalLamports: res.totalLamports, totalSOL: res.totalSOL };
|
|
615
|
+
}
|
|
606
616
|
/** Get current round entries with odds */
|
|
607
617
|
async getJackpotEntries() {
|
|
608
618
|
const res = await this.request(
|
|
@@ -824,7 +834,7 @@ function createSecureStoreStorage() {
|
|
|
824
834
|
}
|
|
825
835
|
|
|
826
836
|
// src/provider.tsx
|
|
827
|
-
import { createContext as createContext4, useContext as useContext4, useMemo as useMemo3, useCallback as
|
|
837
|
+
import { createContext as createContext4, useContext as useContext4, useMemo as useMemo3, useCallback as useCallback26, useState as useState28, useEffect as useEffect19 } from "react";
|
|
828
838
|
|
|
829
839
|
// src/ui/theme.ts
|
|
830
840
|
import { createContext, useContext } from "react";
|
|
@@ -1889,7 +1899,7 @@ function ManagedWalletProvider({
|
|
|
1889
1899
|
}
|
|
1890
1900
|
|
|
1891
1901
|
// src/ui/AuthGate.tsx
|
|
1892
|
-
import React2, { useState as
|
|
1902
|
+
import React2, { useState as useState27, useEffect as useEffect18, useRef as useRef6, useCallback as useCallback25 } from "react";
|
|
1893
1903
|
import {
|
|
1894
1904
|
View as View3,
|
|
1895
1905
|
Text as Text3,
|
|
@@ -3259,6 +3269,35 @@ function useEnterJackpot() {
|
|
|
3259
3269
|
return { execute, status, error, data, reset };
|
|
3260
3270
|
}
|
|
3261
3271
|
|
|
3272
|
+
// src/hooks/useCredits.ts
|
|
3273
|
+
import { useState as useState26, useEffect as useEffect17, useCallback as useCallback24 } from "react";
|
|
3274
|
+
function useCredits() {
|
|
3275
|
+
const { client } = useDubs();
|
|
3276
|
+
const [credits, setCredits] = useState26([]);
|
|
3277
|
+
const [totalLamports, setTotalLamports] = useState26(0);
|
|
3278
|
+
const [totalSOL, setTotalSOL] = useState26(0);
|
|
3279
|
+
const [loading, setLoading] = useState26(false);
|
|
3280
|
+
const [error, setError] = useState26(null);
|
|
3281
|
+
const fetch2 = useCallback24(async () => {
|
|
3282
|
+
setLoading(true);
|
|
3283
|
+
setError(null);
|
|
3284
|
+
try {
|
|
3285
|
+
const result = await client.getCredits();
|
|
3286
|
+
setCredits(result.credits);
|
|
3287
|
+
setTotalLamports(result.totalLamports);
|
|
3288
|
+
setTotalSOL(result.totalSOL);
|
|
3289
|
+
} catch (err) {
|
|
3290
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
3291
|
+
} finally {
|
|
3292
|
+
setLoading(false);
|
|
3293
|
+
}
|
|
3294
|
+
}, [client]);
|
|
3295
|
+
useEffect17(() => {
|
|
3296
|
+
fetch2();
|
|
3297
|
+
}, [fetch2]);
|
|
3298
|
+
return { credits, totalLamports, totalSOL, loading, error, refetch: fetch2 };
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3262
3301
|
// src/ui/AvatarEditor.tsx
|
|
3263
3302
|
import {
|
|
3264
3303
|
View as View2,
|
|
@@ -3427,11 +3466,11 @@ function AuthGate({
|
|
|
3427
3466
|
}) {
|
|
3428
3467
|
const { client, pushEnabled, uiConfig } = useDubs();
|
|
3429
3468
|
const auth = useAuth();
|
|
3430
|
-
const [phase, setPhase] =
|
|
3431
|
-
const [registrationPhase, setRegistrationPhase] =
|
|
3432
|
-
const [showPushSetup, setShowPushSetup] =
|
|
3433
|
-
const [isRestoredSession, setIsRestoredSession] =
|
|
3434
|
-
|
|
3469
|
+
const [phase, setPhase] = useState27("init");
|
|
3470
|
+
const [registrationPhase, setRegistrationPhase] = useState27(false);
|
|
3471
|
+
const [showPushSetup, setShowPushSetup] = useState27(false);
|
|
3472
|
+
const [isRestoredSession, setIsRestoredSession] = useState27(false);
|
|
3473
|
+
useEffect18(() => {
|
|
3435
3474
|
let cancelled = false;
|
|
3436
3475
|
(async () => {
|
|
3437
3476
|
try {
|
|
@@ -3458,23 +3497,23 @@ function AuthGate({
|
|
|
3458
3497
|
cancelled = true;
|
|
3459
3498
|
};
|
|
3460
3499
|
}, []);
|
|
3461
|
-
|
|
3500
|
+
useEffect18(() => {
|
|
3462
3501
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
3463
3502
|
}, [auth.status]);
|
|
3464
|
-
|
|
3503
|
+
useEffect18(() => {
|
|
3465
3504
|
if (pushEnabled && uiConfig.pushConfigured?.android && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
3466
3505
|
setShowPushSetup(true);
|
|
3467
3506
|
}
|
|
3468
3507
|
}, [pushEnabled, uiConfig.pushConfigured?.android, auth.status, registrationPhase, isRestoredSession]);
|
|
3469
|
-
|
|
3508
|
+
useEffect18(() => {
|
|
3470
3509
|
if (auth.token) onSaveToken(auth.token);
|
|
3471
3510
|
}, [auth.token]);
|
|
3472
|
-
const retry =
|
|
3511
|
+
const retry = useCallback25(() => {
|
|
3473
3512
|
setRegistrationPhase(false);
|
|
3474
3513
|
auth.reset();
|
|
3475
3514
|
auth.authenticate();
|
|
3476
3515
|
}, [auth]);
|
|
3477
|
-
const handleRegister =
|
|
3516
|
+
const handleRegister = useCallback25(
|
|
3478
3517
|
(username, referralCode, avatarUrl) => {
|
|
3479
3518
|
auth.register(username, referralCode, avatarUrl);
|
|
3480
3519
|
},
|
|
@@ -3594,20 +3633,20 @@ function DefaultRegistrationScreen({
|
|
|
3594
3633
|
const t = useDubsTheme();
|
|
3595
3634
|
const accent = accentColor || t.accent;
|
|
3596
3635
|
const push = usePushNotifications();
|
|
3597
|
-
const [step, setStep] =
|
|
3598
|
-
const [avatarSeed, setAvatarSeed] =
|
|
3599
|
-
const [avatarStyle, setAvatarStyle] =
|
|
3600
|
-
const [avatarBg, setAvatarBg] =
|
|
3601
|
-
const [showStyles, setShowStyles] =
|
|
3602
|
-
const [username, setUsername] =
|
|
3603
|
-
const [referralCode, setReferralCode] =
|
|
3604
|
-
const [checking, setChecking] =
|
|
3605
|
-
const [availability, setAvailability] =
|
|
3636
|
+
const [step, setStep] = useState27(0);
|
|
3637
|
+
const [avatarSeed, setAvatarSeed] = useState27(generateSeed);
|
|
3638
|
+
const [avatarStyle, setAvatarStyle] = useState27("adventurer");
|
|
3639
|
+
const [avatarBg, setAvatarBg] = useState27("1a1a2e");
|
|
3640
|
+
const [showStyles, setShowStyles] = useState27(false);
|
|
3641
|
+
const [username, setUsername] = useState27("");
|
|
3642
|
+
const [referralCode, setReferralCode] = useState27("");
|
|
3643
|
+
const [checking, setChecking] = useState27(false);
|
|
3644
|
+
const [availability, setAvailability] = useState27(null);
|
|
3606
3645
|
const debounceRef = useRef6(null);
|
|
3607
3646
|
const fadeAnim = useRef6(new Animated.Value(1)).current;
|
|
3608
3647
|
const slideAnim = useRef6(new Animated.Value(0)).current;
|
|
3609
3648
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3610
|
-
|
|
3649
|
+
useEffect18(() => {
|
|
3611
3650
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3612
3651
|
const trimmed = username.trim();
|
|
3613
3652
|
if (trimmed.length < 3) {
|
|
@@ -3630,7 +3669,7 @@ function DefaultRegistrationScreen({
|
|
|
3630
3669
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3631
3670
|
};
|
|
3632
3671
|
}, [username, client]);
|
|
3633
|
-
const animateToStep =
|
|
3672
|
+
const animateToStep = useCallback25((newStep) => {
|
|
3634
3673
|
const dir = newStep > step ? 1 : -1;
|
|
3635
3674
|
Keyboard.dismiss();
|
|
3636
3675
|
Animated.parallel([
|
|
@@ -3829,7 +3868,7 @@ function DefaultRegistrationScreen({
|
|
|
3829
3868
|
)
|
|
3830
3869
|
] })
|
|
3831
3870
|
] });
|
|
3832
|
-
|
|
3871
|
+
useEffect18(() => {
|
|
3833
3872
|
if (pushStepActive && step !== 3) {
|
|
3834
3873
|
animateToStep(3);
|
|
3835
3874
|
}
|
|
@@ -3924,7 +3963,7 @@ function DefaultRegistrationScreen({
|
|
|
3924
3963
|
function PushTokenRestorer() {
|
|
3925
3964
|
const push = usePushNotifications();
|
|
3926
3965
|
const restored = useRef6(false);
|
|
3927
|
-
|
|
3966
|
+
useEffect18(() => {
|
|
3928
3967
|
if (restored.current) return;
|
|
3929
3968
|
restored.current = true;
|
|
3930
3969
|
push.restoreIfGranted();
|
|
@@ -4030,9 +4069,9 @@ function DubsProvider({
|
|
|
4030
4069
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
4031
4070
|
const client = useMemo3(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
4032
4071
|
const storage = useMemo3(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
4033
|
-
const [uiConfig, setUiConfig] =
|
|
4034
|
-
const [resolvedNetwork, setResolvedNetwork] =
|
|
4035
|
-
|
|
4072
|
+
const [uiConfig, setUiConfig] = useState28(null);
|
|
4073
|
+
const [resolvedNetwork, setResolvedNetwork] = useState28(network);
|
|
4074
|
+
useEffect19(() => {
|
|
4036
4075
|
client.getAppConfig().then((cfg) => {
|
|
4037
4076
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
4038
4077
|
setUiConfig(cfg);
|
|
@@ -4124,7 +4163,7 @@ function ManagedInner({
|
|
|
4124
4163
|
children
|
|
4125
4164
|
}) {
|
|
4126
4165
|
const managedDisconnect = useDisconnect();
|
|
4127
|
-
const disconnect =
|
|
4166
|
+
const disconnect = useCallback26(async () => {
|
|
4128
4167
|
client.setToken(null);
|
|
4129
4168
|
await managedDisconnect?.();
|
|
4130
4169
|
}, [client, managedDisconnect]);
|
|
@@ -4165,7 +4204,7 @@ function ExternalWalletProvider({
|
|
|
4165
4204
|
pushEnabled,
|
|
4166
4205
|
children
|
|
4167
4206
|
}) {
|
|
4168
|
-
const disconnect =
|
|
4207
|
+
const disconnect = useCallback26(async () => {
|
|
4169
4208
|
client.setToken(null);
|
|
4170
4209
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
4171
4210
|
});
|
|
@@ -4486,7 +4525,7 @@ var styles5 = StyleSheet6.create({
|
|
|
4486
4525
|
});
|
|
4487
4526
|
|
|
4488
4527
|
// src/ui/UserProfileSheet.tsx
|
|
4489
|
-
import { useState as
|
|
4528
|
+
import { useState as useState29, useEffect as useEffect20, useRef as useRef7, useCallback as useCallback27, useMemo as useMemo5 } from "react";
|
|
4490
4529
|
import {
|
|
4491
4530
|
View as View7,
|
|
4492
4531
|
Text as Text7,
|
|
@@ -4519,29 +4558,29 @@ function UserProfileSheet({
|
|
|
4519
4558
|
const push = usePushNotifications();
|
|
4520
4559
|
const overlayOpacity = useRef7(new Animated2.Value(0)).current;
|
|
4521
4560
|
const parsed = useMemo5(() => parseAvatarUrl(user.avatar), [user.avatar]);
|
|
4522
|
-
const [avatarStyle, setAvatarStyle] =
|
|
4523
|
-
const [avatarSeed, setAvatarSeed] =
|
|
4524
|
-
const [bgColor, setBgColor] =
|
|
4525
|
-
const [saving, setSaving] =
|
|
4526
|
-
const [error, setError] =
|
|
4527
|
-
|
|
4561
|
+
const [avatarStyle, setAvatarStyle] = useState29(parsed.style);
|
|
4562
|
+
const [avatarSeed, setAvatarSeed] = useState29(parsed.seed);
|
|
4563
|
+
const [bgColor, setBgColor] = useState29(parsed.bg);
|
|
4564
|
+
const [saving, setSaving] = useState29(false);
|
|
4565
|
+
const [error, setError] = useState29(null);
|
|
4566
|
+
useEffect20(() => {
|
|
4528
4567
|
const p = parseAvatarUrl(user.avatar);
|
|
4529
4568
|
setAvatarStyle(p.style);
|
|
4530
4569
|
setAvatarSeed(p.seed);
|
|
4531
4570
|
setBgColor(p.bg);
|
|
4532
4571
|
}, [user.avatar]);
|
|
4533
|
-
|
|
4572
|
+
useEffect20(() => {
|
|
4534
4573
|
Animated2.timing(overlayOpacity, {
|
|
4535
4574
|
toValue: visible ? 1 : 0,
|
|
4536
4575
|
duration: 250,
|
|
4537
4576
|
useNativeDriver: true
|
|
4538
4577
|
}).start();
|
|
4539
4578
|
}, [visible, overlayOpacity]);
|
|
4540
|
-
|
|
4579
|
+
useEffect20(() => {
|
|
4541
4580
|
if (visible) setError(null);
|
|
4542
4581
|
}, [visible]);
|
|
4543
4582
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4544
|
-
const saveAvatar =
|
|
4583
|
+
const saveAvatar = useCallback27(async (newUrl) => {
|
|
4545
4584
|
setSaving(true);
|
|
4546
4585
|
setError(null);
|
|
4547
4586
|
try {
|
|
@@ -4554,16 +4593,16 @@ function UserProfileSheet({
|
|
|
4554
4593
|
setSaving(false);
|
|
4555
4594
|
}
|
|
4556
4595
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4557
|
-
const handleStyleChange =
|
|
4596
|
+
const handleStyleChange = useCallback27((style) => {
|
|
4558
4597
|
setAvatarStyle(style);
|
|
4559
4598
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4560
4599
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4561
|
-
const handleShuffle =
|
|
4600
|
+
const handleShuffle = useCallback27(() => {
|
|
4562
4601
|
const newSeed = generateSeed();
|
|
4563
4602
|
setAvatarSeed(newSeed);
|
|
4564
4603
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4565
4604
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4566
|
-
const handleBgChange =
|
|
4605
|
+
const handleBgChange = useCallback27((color) => {
|
|
4567
4606
|
setBgColor(color);
|
|
4568
4607
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4569
4608
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4843,7 +4882,7 @@ var styles6 = StyleSheet7.create({
|
|
|
4843
4882
|
});
|
|
4844
4883
|
|
|
4845
4884
|
// src/ui/game/GamePoster.tsx
|
|
4846
|
-
import { useState as
|
|
4885
|
+
import { useState as useState30 } from "react";
|
|
4847
4886
|
import { StyleSheet as StyleSheet8, View as View8, Text as Text8 } from "react-native";
|
|
4848
4887
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4849
4888
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4893,7 +4932,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4893
4932
|
] });
|
|
4894
4933
|
}
|
|
4895
4934
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4896
|
-
const [failed, setFailed] =
|
|
4935
|
+
const [failed, setFailed] = useState30(false);
|
|
4897
4936
|
if (!url || failed) {
|
|
4898
4937
|
return /* @__PURE__ */ jsx10(View8, { style: [styles7.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4899
4938
|
}
|
|
@@ -5073,7 +5112,7 @@ var styles8 = StyleSheet9.create({
|
|
|
5073
5112
|
});
|
|
5074
5113
|
|
|
5075
5114
|
// src/ui/game/PickWinnerCard.tsx
|
|
5076
|
-
import { useState as
|
|
5115
|
+
import { useState as useState31, useMemo as useMemo7 } from "react";
|
|
5077
5116
|
import { StyleSheet as StyleSheet10, View as View10, Text as Text10, TouchableOpacity as TouchableOpacity7 } from "react-native";
|
|
5078
5117
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
5079
5118
|
function PickWinnerCard({
|
|
@@ -5144,7 +5183,7 @@ function TeamOption({
|
|
|
5144
5183
|
ImageComponent,
|
|
5145
5184
|
t
|
|
5146
5185
|
}) {
|
|
5147
|
-
const [imgFailed, setImgFailed] =
|
|
5186
|
+
const [imgFailed, setImgFailed] = useState31(false);
|
|
5148
5187
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5149
5188
|
const showImage = imageUrl && !imgFailed;
|
|
5150
5189
|
return /* @__PURE__ */ jsxs9(
|
|
@@ -5185,7 +5224,7 @@ var styles9 = StyleSheet10.create({
|
|
|
5185
5224
|
});
|
|
5186
5225
|
|
|
5187
5226
|
// src/ui/game/PlayersCard.tsx
|
|
5188
|
-
import { useState as
|
|
5227
|
+
import { useState as useState32 } from "react";
|
|
5189
5228
|
import { StyleSheet as StyleSheet11, View as View11, Text as Text11 } from "react-native";
|
|
5190
5229
|
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5191
5230
|
function truncateWallet(addr, chars) {
|
|
@@ -5234,7 +5273,7 @@ function BettorRow({
|
|
|
5234
5273
|
ImageComponent,
|
|
5235
5274
|
t
|
|
5236
5275
|
}) {
|
|
5237
|
-
const [imgFailed, setImgFailed] =
|
|
5276
|
+
const [imgFailed, setImgFailed] = useState32(false);
|
|
5238
5277
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5239
5278
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
5240
5279
|
return /* @__PURE__ */ jsxs10(View11, { style: [styles10.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -5313,7 +5352,7 @@ var styles11 = StyleSheet12.create({
|
|
|
5313
5352
|
});
|
|
5314
5353
|
|
|
5315
5354
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
5316
|
-
import { useState as
|
|
5355
|
+
import { useState as useState33, useEffect as useEffect21, useRef as useRef8, useCallback as useCallback28 } from "react";
|
|
5317
5356
|
import {
|
|
5318
5357
|
View as View13,
|
|
5319
5358
|
Text as Text13,
|
|
@@ -5350,18 +5389,18 @@ function CreateCustomGameSheet({
|
|
|
5350
5389
|
const t = useDubsTheme();
|
|
5351
5390
|
const { wallet } = useDubs();
|
|
5352
5391
|
const mutation = useCreateCustomGame();
|
|
5353
|
-
const [selectedAmount, setSelectedAmount] =
|
|
5354
|
-
const [customAmount, setCustomAmount] =
|
|
5355
|
-
const [isCustom, setIsCustom] =
|
|
5392
|
+
const [selectedAmount, setSelectedAmount] = useState33(null);
|
|
5393
|
+
const [customAmount, setCustomAmount] = useState33("");
|
|
5394
|
+
const [isCustom, setIsCustom] = useState33(false);
|
|
5356
5395
|
const overlayOpacity = useRef8(new Animated3.Value(0)).current;
|
|
5357
|
-
|
|
5396
|
+
useEffect21(() => {
|
|
5358
5397
|
Animated3.timing(overlayOpacity, {
|
|
5359
5398
|
toValue: visible ? 1 : 0,
|
|
5360
5399
|
duration: 250,
|
|
5361
5400
|
useNativeDriver: true
|
|
5362
5401
|
}).start();
|
|
5363
5402
|
}, [visible, overlayOpacity]);
|
|
5364
|
-
|
|
5403
|
+
useEffect21(() => {
|
|
5365
5404
|
if (visible) {
|
|
5366
5405
|
setSelectedAmount(defaultAmount ?? null);
|
|
5367
5406
|
setCustomAmount("");
|
|
@@ -5369,7 +5408,7 @@ function CreateCustomGameSheet({
|
|
|
5369
5408
|
mutation.reset();
|
|
5370
5409
|
}
|
|
5371
5410
|
}, [visible]);
|
|
5372
|
-
|
|
5411
|
+
useEffect21(() => {
|
|
5373
5412
|
if (mutation.status === "success" && mutation.data) {
|
|
5374
5413
|
onSuccess?.(mutation.data);
|
|
5375
5414
|
const timer = setTimeout(() => {
|
|
@@ -5378,23 +5417,23 @@ function CreateCustomGameSheet({
|
|
|
5378
5417
|
return () => clearTimeout(timer);
|
|
5379
5418
|
}
|
|
5380
5419
|
}, [mutation.status, mutation.data]);
|
|
5381
|
-
|
|
5420
|
+
useEffect21(() => {
|
|
5382
5421
|
if (mutation.status === "error" && mutation.error) {
|
|
5383
5422
|
onError?.(mutation.error);
|
|
5384
5423
|
}
|
|
5385
5424
|
}, [mutation.status, mutation.error]);
|
|
5386
|
-
const handlePresetSelect =
|
|
5425
|
+
const handlePresetSelect = useCallback28((amount) => {
|
|
5387
5426
|
setSelectedAmount(amount);
|
|
5388
5427
|
setIsCustom(false);
|
|
5389
5428
|
setCustomAmount("");
|
|
5390
5429
|
onAmountChange?.(amount);
|
|
5391
5430
|
}, [onAmountChange]);
|
|
5392
|
-
const handleCustomSelect =
|
|
5431
|
+
const handleCustomSelect = useCallback28(() => {
|
|
5393
5432
|
setIsCustom(true);
|
|
5394
5433
|
setSelectedAmount(null);
|
|
5395
5434
|
onAmountChange?.(null);
|
|
5396
5435
|
}, [onAmountChange]);
|
|
5397
|
-
const handleCustomAmountChange =
|
|
5436
|
+
const handleCustomAmountChange = useCallback28((text) => {
|
|
5398
5437
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
5399
5438
|
setCustomAmount(cleaned);
|
|
5400
5439
|
const parsed = parseFloat(cleaned);
|
|
@@ -5409,7 +5448,7 @@ function CreateCustomGameSheet({
|
|
|
5409
5448
|
const winnerTakes = pot * (1 - fee / 100);
|
|
5410
5449
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5411
5450
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
5412
|
-
const handleCreate =
|
|
5451
|
+
const handleCreate = useCallback28(async () => {
|
|
5413
5452
|
if (!finalAmount || !wallet.publicKey) return;
|
|
5414
5453
|
try {
|
|
5415
5454
|
await mutation.execute({
|
|
@@ -5678,7 +5717,7 @@ var styles12 = StyleSheet13.create({
|
|
|
5678
5717
|
});
|
|
5679
5718
|
|
|
5680
5719
|
// src/ui/game/JoinGameSheet.tsx
|
|
5681
|
-
import { useState as
|
|
5720
|
+
import { useState as useState35, useEffect as useEffect22, useRef as useRef10, useCallback as useCallback30, useMemo as useMemo9 } from "react";
|
|
5682
5721
|
import {
|
|
5683
5722
|
View as View16,
|
|
5684
5723
|
Text as Text16,
|
|
@@ -5888,7 +5927,7 @@ var styles13 = StyleSheet14.create({
|
|
|
5888
5927
|
});
|
|
5889
5928
|
|
|
5890
5929
|
// src/ui/game/TeamButton.tsx
|
|
5891
|
-
import { useState as
|
|
5930
|
+
import { useState as useState34 } from "react";
|
|
5892
5931
|
import { View as View15, Text as Text15, TouchableOpacity as TouchableOpacity10, StyleSheet as StyleSheet15 } from "react-native";
|
|
5893
5932
|
import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5894
5933
|
function TeamButton({
|
|
@@ -5902,7 +5941,7 @@ function TeamButton({
|
|
|
5902
5941
|
ImageComponent,
|
|
5903
5942
|
t
|
|
5904
5943
|
}) {
|
|
5905
|
-
const [imgFailed, setImgFailed] =
|
|
5944
|
+
const [imgFailed, setImgFailed] = useState34(false);
|
|
5906
5945
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5907
5946
|
const showImage = imageUrl && !imgFailed;
|
|
5908
5947
|
return /* @__PURE__ */ jsxs14(
|
|
@@ -6006,20 +6045,20 @@ function JoinGameSheet({
|
|
|
6006
6045
|
const { wallet } = useDubs();
|
|
6007
6046
|
const mutation = useJoinGame();
|
|
6008
6047
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
6009
|
-
const [selectedTeam, setSelectedTeam] =
|
|
6010
|
-
const [wager, setWager] =
|
|
6011
|
-
const [showSuccess, setShowSuccess] =
|
|
6048
|
+
const [selectedTeam, setSelectedTeam] = useState35(null);
|
|
6049
|
+
const [wager, setWager] = useState35(game.buyIn);
|
|
6050
|
+
const [showSuccess, setShowSuccess] = useState35(false);
|
|
6012
6051
|
const overlayOpacity = useRef10(new Animated4.Value(0)).current;
|
|
6013
6052
|
const successScale = useRef10(new Animated4.Value(0)).current;
|
|
6014
6053
|
const successOpacity = useRef10(new Animated4.Value(0)).current;
|
|
6015
|
-
|
|
6054
|
+
useEffect22(() => {
|
|
6016
6055
|
Animated4.timing(overlayOpacity, {
|
|
6017
6056
|
toValue: visible ? 1 : 0,
|
|
6018
6057
|
duration: 250,
|
|
6019
6058
|
useNativeDriver: true
|
|
6020
6059
|
}).start();
|
|
6021
6060
|
}, [visible, overlayOpacity]);
|
|
6022
|
-
|
|
6061
|
+
useEffect22(() => {
|
|
6023
6062
|
if (visible) {
|
|
6024
6063
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
6025
6064
|
setWager(game.buyIn);
|
|
@@ -6029,7 +6068,7 @@ function JoinGameSheet({
|
|
|
6029
6068
|
mutation.reset();
|
|
6030
6069
|
}
|
|
6031
6070
|
}, [visible]);
|
|
6032
|
-
|
|
6071
|
+
useEffect22(() => {
|
|
6033
6072
|
if (mutation.status === "success" && mutation.data) {
|
|
6034
6073
|
setShowSuccess(true);
|
|
6035
6074
|
onSuccess?.(mutation.data);
|
|
@@ -6046,7 +6085,7 @@ function JoinGameSheet({
|
|
|
6046
6085
|
return () => clearTimeout(timer);
|
|
6047
6086
|
}
|
|
6048
6087
|
}, [mutation.status, mutation.data]);
|
|
6049
|
-
|
|
6088
|
+
useEffect22(() => {
|
|
6050
6089
|
if (mutation.status === "error" && mutation.error) {
|
|
6051
6090
|
onError?.(mutation.error);
|
|
6052
6091
|
}
|
|
@@ -6090,7 +6129,7 @@ function JoinGameSheet({
|
|
|
6090
6129
|
const alreadyJoined = myBet !== null;
|
|
6091
6130
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6092
6131
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
6093
|
-
const handleJoin =
|
|
6132
|
+
const handleJoin = useCallback30(async () => {
|
|
6094
6133
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
6095
6134
|
try {
|
|
6096
6135
|
await mutation.execute({
|
|
@@ -6353,7 +6392,7 @@ function PickRow({
|
|
|
6353
6392
|
ImageComponent,
|
|
6354
6393
|
t
|
|
6355
6394
|
}) {
|
|
6356
|
-
const [imgFailed, setImgFailed] =
|
|
6395
|
+
const [imgFailed, setImgFailed] = useState35(false);
|
|
6357
6396
|
const Img = ImageComponent || __require("react-native").Image;
|
|
6358
6397
|
const showImage = imageUrl && !imgFailed;
|
|
6359
6398
|
return /* @__PURE__ */ jsxs15(
|
|
@@ -6646,7 +6685,7 @@ var styles15 = StyleSheet16.create({
|
|
|
6646
6685
|
});
|
|
6647
6686
|
|
|
6648
6687
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
6649
|
-
import { useState as
|
|
6688
|
+
import { useState as useState36, useEffect as useEffect23, useRef as useRef11, useCallback as useCallback31 } from "react";
|
|
6650
6689
|
import {
|
|
6651
6690
|
View as View17,
|
|
6652
6691
|
Text as Text17,
|
|
@@ -6680,15 +6719,15 @@ function ClaimPrizeSheet({
|
|
|
6680
6719
|
const overlayOpacity = useRef11(new Animated5.Value(0)).current;
|
|
6681
6720
|
const celebrationScale = useRef11(new Animated5.Value(0)).current;
|
|
6682
6721
|
const celebrationOpacity = useRef11(new Animated5.Value(0)).current;
|
|
6683
|
-
const [showCelebration, setShowCelebration] =
|
|
6684
|
-
|
|
6722
|
+
const [showCelebration, setShowCelebration] = useState36(false);
|
|
6723
|
+
useEffect23(() => {
|
|
6685
6724
|
Animated5.timing(overlayOpacity, {
|
|
6686
6725
|
toValue: visible ? 1 : 0,
|
|
6687
6726
|
duration: 250,
|
|
6688
6727
|
useNativeDriver: true
|
|
6689
6728
|
}).start();
|
|
6690
6729
|
}, [visible, overlayOpacity]);
|
|
6691
|
-
|
|
6730
|
+
useEffect23(() => {
|
|
6692
6731
|
if (visible) {
|
|
6693
6732
|
mutation.reset();
|
|
6694
6733
|
setShowCelebration(false);
|
|
@@ -6696,7 +6735,7 @@ function ClaimPrizeSheet({
|
|
|
6696
6735
|
celebrationOpacity.setValue(0);
|
|
6697
6736
|
}
|
|
6698
6737
|
}, [visible]);
|
|
6699
|
-
|
|
6738
|
+
useEffect23(() => {
|
|
6700
6739
|
if (mutation.status === "success" && mutation.data) {
|
|
6701
6740
|
setShowCelebration(true);
|
|
6702
6741
|
Animated5.parallel([
|
|
@@ -6719,14 +6758,14 @@ function ClaimPrizeSheet({
|
|
|
6719
6758
|
return () => clearTimeout(timer);
|
|
6720
6759
|
}
|
|
6721
6760
|
}, [mutation.status, mutation.data]);
|
|
6722
|
-
|
|
6761
|
+
useEffect23(() => {
|
|
6723
6762
|
if (mutation.status === "error" && mutation.error) {
|
|
6724
6763
|
onError?.(mutation.error);
|
|
6725
6764
|
}
|
|
6726
6765
|
}, [mutation.status, mutation.error]);
|
|
6727
6766
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6728
6767
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
6729
|
-
const handleClaim =
|
|
6768
|
+
const handleClaim = useCallback31(async () => {
|
|
6730
6769
|
if (!wallet.publicKey) return;
|
|
6731
6770
|
try {
|
|
6732
6771
|
await mutation.execute({
|
|
@@ -6959,7 +6998,7 @@ var styles16 = StyleSheet17.create({
|
|
|
6959
6998
|
});
|
|
6960
6999
|
|
|
6961
7000
|
// src/ui/game/ClaimButton.tsx
|
|
6962
|
-
import { useState as
|
|
7001
|
+
import { useState as useState37, useMemo as useMemo10, useCallback as useCallback32 } from "react";
|
|
6963
7002
|
import { StyleSheet as StyleSheet18, Text as Text18, TouchableOpacity as TouchableOpacity13 } from "react-native";
|
|
6964
7003
|
import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6965
7004
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -6967,7 +7006,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6967
7006
|
const { wallet } = useDubs();
|
|
6968
7007
|
const game = useGame(gameId);
|
|
6969
7008
|
const claimStatus = useHasClaimed(gameId);
|
|
6970
|
-
const [sheetVisible, setSheetVisible] =
|
|
7009
|
+
const [sheetVisible, setSheetVisible] = useState37(false);
|
|
6971
7010
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
6972
7011
|
const myBet = useMemo10(() => {
|
|
6973
7012
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
@@ -6978,7 +7017,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6978
7017
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
6979
7018
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
6980
7019
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
6981
|
-
const handleSuccess =
|
|
7020
|
+
const handleSuccess = useCallback32(
|
|
6982
7021
|
(result) => {
|
|
6983
7022
|
claimStatus.refetch();
|
|
6984
7023
|
onSuccess?.(result);
|
|
@@ -7065,7 +7104,7 @@ var styles17 = StyleSheet18.create({
|
|
|
7065
7104
|
});
|
|
7066
7105
|
|
|
7067
7106
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
7068
|
-
import { useEffect as
|
|
7107
|
+
import { useEffect as useEffect24, useRef as useRef12, useCallback as useCallback33 } from "react";
|
|
7069
7108
|
import {
|
|
7070
7109
|
View as View18,
|
|
7071
7110
|
Text as Text19,
|
|
@@ -7097,19 +7136,19 @@ function EnterArcadePoolSheet({
|
|
|
7097
7136
|
const { wallet } = useDubs();
|
|
7098
7137
|
const mutation = useEnterArcadePool();
|
|
7099
7138
|
const overlayOpacity = useRef12(new Animated6.Value(0)).current;
|
|
7100
|
-
|
|
7139
|
+
useEffect24(() => {
|
|
7101
7140
|
Animated6.timing(overlayOpacity, {
|
|
7102
7141
|
toValue: visible ? 1 : 0,
|
|
7103
7142
|
duration: 250,
|
|
7104
7143
|
useNativeDriver: true
|
|
7105
7144
|
}).start();
|
|
7106
7145
|
}, [visible, overlayOpacity]);
|
|
7107
|
-
|
|
7146
|
+
useEffect24(() => {
|
|
7108
7147
|
if (visible) {
|
|
7109
7148
|
mutation.reset();
|
|
7110
7149
|
}
|
|
7111
7150
|
}, [visible]);
|
|
7112
|
-
|
|
7151
|
+
useEffect24(() => {
|
|
7113
7152
|
if (mutation.status === "success" && mutation.data) {
|
|
7114
7153
|
onSuccess?.(mutation.data);
|
|
7115
7154
|
const timer = setTimeout(() => {
|
|
@@ -7118,7 +7157,7 @@ function EnterArcadePoolSheet({
|
|
|
7118
7157
|
return () => clearTimeout(timer);
|
|
7119
7158
|
}
|
|
7120
7159
|
}, [mutation.status, mutation.data]);
|
|
7121
|
-
|
|
7160
|
+
useEffect24(() => {
|
|
7122
7161
|
if (mutation.status === "error" && mutation.error) {
|
|
7123
7162
|
onError?.(mutation.error);
|
|
7124
7163
|
}
|
|
@@ -7130,7 +7169,7 @@ function EnterArcadePoolSheet({
|
|
|
7130
7169
|
const potSol = (pool.buy_in_lamports * Number(totalBuyIns) / 1e9).toFixed(4);
|
|
7131
7170
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7132
7171
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
7133
|
-
const handleJoin =
|
|
7172
|
+
const handleJoin = useCallback33(async () => {
|
|
7134
7173
|
if (!wallet.publicKey) return;
|
|
7135
7174
|
try {
|
|
7136
7175
|
await mutation.execute(pool.id);
|
|
@@ -7281,7 +7320,7 @@ var styles18 = StyleSheet19.create({
|
|
|
7281
7320
|
});
|
|
7282
7321
|
|
|
7283
7322
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
7284
|
-
import { useEffect as
|
|
7323
|
+
import { useEffect as useEffect25, useRef as useRef13 } from "react";
|
|
7285
7324
|
import {
|
|
7286
7325
|
View as View19,
|
|
7287
7326
|
Text as Text20,
|
|
@@ -7310,14 +7349,14 @@ function ArcadeLeaderboardSheet({
|
|
|
7310
7349
|
const t = useDubsTheme();
|
|
7311
7350
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
7312
7351
|
const overlayOpacity = useRef13(new Animated7.Value(0)).current;
|
|
7313
|
-
|
|
7352
|
+
useEffect25(() => {
|
|
7314
7353
|
Animated7.timing(overlayOpacity, {
|
|
7315
7354
|
toValue: visible ? 1 : 0,
|
|
7316
7355
|
duration: 250,
|
|
7317
7356
|
useNativeDriver: true
|
|
7318
7357
|
}).start();
|
|
7319
7358
|
}, [visible, overlayOpacity]);
|
|
7320
|
-
|
|
7359
|
+
useEffect25(() => {
|
|
7321
7360
|
if (visible) refetch();
|
|
7322
7361
|
}, [visible]);
|
|
7323
7362
|
const renderItem = ({ item, index }) => {
|
|
@@ -7464,7 +7503,7 @@ var styles19 = StyleSheet20.create({
|
|
|
7464
7503
|
});
|
|
7465
7504
|
|
|
7466
7505
|
// src/ui/game/CreateGameSheet.tsx
|
|
7467
|
-
import { useState as
|
|
7506
|
+
import { useState as useState39, useEffect as useEffect26, useRef as useRef14, useCallback as useCallback34 } from "react";
|
|
7468
7507
|
import {
|
|
7469
7508
|
View as View20,
|
|
7470
7509
|
Text as Text21,
|
|
@@ -7503,20 +7542,20 @@ function CreateGameSheet({
|
|
|
7503
7542
|
const t = useDubsTheme();
|
|
7504
7543
|
const { wallet } = useDubs();
|
|
7505
7544
|
const mutation = useCreateGame();
|
|
7506
|
-
const [selectedTeam, setSelectedTeam] =
|
|
7507
|
-
const [wager, setWager] =
|
|
7508
|
-
const [showSuccess, setShowSuccess] =
|
|
7545
|
+
const [selectedTeam, setSelectedTeam] = useState39(null);
|
|
7546
|
+
const [wager, setWager] = useState39(0.01);
|
|
7547
|
+
const [showSuccess, setShowSuccess] = useState39(false);
|
|
7509
7548
|
const overlayOpacity = useRef14(new Animated8.Value(0)).current;
|
|
7510
7549
|
const successScale = useRef14(new Animated8.Value(0)).current;
|
|
7511
7550
|
const successOpacity = useRef14(new Animated8.Value(0)).current;
|
|
7512
|
-
|
|
7551
|
+
useEffect26(() => {
|
|
7513
7552
|
Animated8.timing(overlayOpacity, {
|
|
7514
7553
|
toValue: visible ? 1 : 0,
|
|
7515
7554
|
duration: 250,
|
|
7516
7555
|
useNativeDriver: true
|
|
7517
7556
|
}).start();
|
|
7518
7557
|
}, [visible]);
|
|
7519
|
-
|
|
7558
|
+
useEffect26(() => {
|
|
7520
7559
|
if (visible) {
|
|
7521
7560
|
setSelectedTeam(null);
|
|
7522
7561
|
setWager(0.01);
|
|
@@ -7526,7 +7565,7 @@ function CreateGameSheet({
|
|
|
7526
7565
|
mutation.reset();
|
|
7527
7566
|
}
|
|
7528
7567
|
}, [visible]);
|
|
7529
|
-
|
|
7568
|
+
useEffect26(() => {
|
|
7530
7569
|
if (mutation.status === "success" && mutation.data) {
|
|
7531
7570
|
setShowSuccess(true);
|
|
7532
7571
|
onSuccess?.(mutation.data);
|
|
@@ -7543,7 +7582,7 @@ function CreateGameSheet({
|
|
|
7543
7582
|
return () => clearTimeout(timer);
|
|
7544
7583
|
}
|
|
7545
7584
|
}, [mutation.status, mutation.data]);
|
|
7546
|
-
|
|
7585
|
+
useEffect26(() => {
|
|
7547
7586
|
if (mutation.status === "error" && mutation.error) {
|
|
7548
7587
|
onError?.(mutation.error);
|
|
7549
7588
|
}
|
|
@@ -7553,7 +7592,7 @@ function CreateGameSheet({
|
|
|
7553
7592
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
7554
7593
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7555
7594
|
const canCreate = selectedTeam !== null && !isMutating && mutation.status !== "success";
|
|
7556
|
-
const handleCreate =
|
|
7595
|
+
const handleCreate = useCallback34(async () => {
|
|
7557
7596
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
7558
7597
|
try {
|
|
7559
7598
|
await mutation.execute({
|
|
@@ -7701,7 +7740,7 @@ var styles20 = StyleSheet21.create({
|
|
|
7701
7740
|
});
|
|
7702
7741
|
|
|
7703
7742
|
// src/ui/jackpot/JackpotCard.tsx
|
|
7704
|
-
import { useEffect as
|
|
7743
|
+
import { useEffect as useEffect27, useRef as useRef15 } from "react";
|
|
7705
7744
|
import {
|
|
7706
7745
|
View as View21,
|
|
7707
7746
|
Text as Text22,
|
|
@@ -7726,7 +7765,7 @@ function truncateWallet2(addr) {
|
|
|
7726
7765
|
function JackpotCard({ round, lastWinner, entries, onPress, style }) {
|
|
7727
7766
|
const shimmerAnim = useRef15(new Animated9.Value(-1)).current;
|
|
7728
7767
|
const pulseAnim = useRef15(new Animated9.Value(0.4)).current;
|
|
7729
|
-
|
|
7768
|
+
useEffect27(() => {
|
|
7730
7769
|
const shimmer = Animated9.loop(
|
|
7731
7770
|
Animated9.sequence([
|
|
7732
7771
|
Animated9.timing(shimmerAnim, { toValue: 1, duration: 4e3, useNativeDriver: true }),
|
|
@@ -8085,7 +8124,7 @@ var styles21 = StyleSheet22.create({
|
|
|
8085
8124
|
});
|
|
8086
8125
|
|
|
8087
8126
|
// src/ui/jackpot/JackpotSheet.tsx
|
|
8088
|
-
import { useState as
|
|
8127
|
+
import { useState as useState40, useEffect as useEffect28, useRef as useRef16, useCallback as useCallback35 } from "react";
|
|
8089
8128
|
import {
|
|
8090
8129
|
View as View22,
|
|
8091
8130
|
Text as Text23,
|
|
@@ -8132,17 +8171,17 @@ function JackpotSheet({
|
|
|
8132
8171
|
const { wallet, client } = useDubs();
|
|
8133
8172
|
const { round, lastWinner, refetch } = useJackpot();
|
|
8134
8173
|
const mutation = useEnterJackpot();
|
|
8135
|
-
const [betAmount, setBetAmount] =
|
|
8136
|
-
const [entries, setEntries] =
|
|
8174
|
+
const [betAmount, setBetAmount] = useState40("0.1");
|
|
8175
|
+
const [entries, setEntries] = useState40([]);
|
|
8137
8176
|
const overlayOpacity = useRef16(new Animated10.Value(0)).current;
|
|
8138
|
-
|
|
8177
|
+
useEffect28(() => {
|
|
8139
8178
|
Animated10.timing(overlayOpacity, {
|
|
8140
8179
|
toValue: visible ? 1 : 0,
|
|
8141
8180
|
duration: 250,
|
|
8142
8181
|
useNativeDriver: true
|
|
8143
8182
|
}).start();
|
|
8144
8183
|
}, [visible, overlayOpacity]);
|
|
8145
|
-
|
|
8184
|
+
useEffect28(() => {
|
|
8146
8185
|
if (visible) {
|
|
8147
8186
|
mutation.reset();
|
|
8148
8187
|
setBetAmount("0.1");
|
|
@@ -8151,7 +8190,7 @@ function JackpotSheet({
|
|
|
8151
8190
|
});
|
|
8152
8191
|
}
|
|
8153
8192
|
}, [visible]);
|
|
8154
|
-
|
|
8193
|
+
useEffect28(() => {
|
|
8155
8194
|
if (mutation.status === "success" && mutation.data) {
|
|
8156
8195
|
onSuccess?.(mutation.data);
|
|
8157
8196
|
refetch();
|
|
@@ -8161,7 +8200,7 @@ function JackpotSheet({
|
|
|
8161
8200
|
return () => clearTimeout(timer);
|
|
8162
8201
|
}
|
|
8163
8202
|
}, [mutation.status, mutation.data]);
|
|
8164
|
-
|
|
8203
|
+
useEffect28(() => {
|
|
8165
8204
|
if (mutation.status === "error" && mutation.error) {
|
|
8166
8205
|
onError?.(mutation.error);
|
|
8167
8206
|
}
|
|
@@ -8173,14 +8212,14 @@ function JackpotSheet({
|
|
|
8173
8212
|
const userOdds = totalWeight > 0 ? (entryLamports / (totalWeight + entryLamports) * 100).toFixed(1) : entries.length === 0 ? "100.0" : "0.0";
|
|
8174
8213
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
8175
8214
|
const canEnter = !isMutating && mutation.status !== "success" && round?.status === "Open" && betSol >= minEntry;
|
|
8176
|
-
const handleQuickAdd =
|
|
8215
|
+
const handleQuickAdd = useCallback35((amount) => {
|
|
8177
8216
|
setBetAmount((prev) => {
|
|
8178
8217
|
const current = parseFloat(prev) || 0;
|
|
8179
8218
|
const next = Math.min(current + amount, maxEntry);
|
|
8180
8219
|
return next.toFixed(2);
|
|
8181
8220
|
});
|
|
8182
8221
|
}, [maxEntry]);
|
|
8183
|
-
const handleEnter =
|
|
8222
|
+
const handleEnter = useCallback35(async () => {
|
|
8184
8223
|
if (!wallet.publicKey || entryLamports < 1e4) return;
|
|
8185
8224
|
try {
|
|
8186
8225
|
await mutation.execute(entryLamports);
|
|
@@ -8699,7 +8738,7 @@ var styles22 = StyleSheet23.create({
|
|
|
8699
8738
|
});
|
|
8700
8739
|
|
|
8701
8740
|
// src/ui/jackpot/JackpotWidget.tsx
|
|
8702
|
-
import { useState as
|
|
8741
|
+
import { useState as useState41, useEffect as useEffect29 } from "react";
|
|
8703
8742
|
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
8704
8743
|
function JackpotWidget({
|
|
8705
8744
|
style,
|
|
@@ -8708,11 +8747,11 @@ function JackpotWidget({
|
|
|
8708
8747
|
onEntry,
|
|
8709
8748
|
onError
|
|
8710
8749
|
}) {
|
|
8711
|
-
const [sheetVisible, setSheetVisible] =
|
|
8750
|
+
const [sheetVisible, setSheetVisible] = useState41(false);
|
|
8712
8751
|
const { round, lastWinner } = useJackpot();
|
|
8713
8752
|
const { client } = useDubs();
|
|
8714
|
-
const [entries, setEntries] =
|
|
8715
|
-
|
|
8753
|
+
const [entries, setEntries] = useState41([]);
|
|
8754
|
+
useEffect29(() => {
|
|
8716
8755
|
client.getJackpotEntries().then((res) => setEntries(res.entries)).catch(() => {
|
|
8717
8756
|
});
|
|
8718
8757
|
}, [client, round?.entryCount]);
|
|
@@ -8746,7 +8785,7 @@ function JackpotWidget({
|
|
|
8746
8785
|
}
|
|
8747
8786
|
|
|
8748
8787
|
// src/chat/provider.tsx
|
|
8749
|
-
import { createContext as createContext5, useContext as useContext5, useEffect as
|
|
8788
|
+
import { createContext as createContext5, useContext as useContext5, useEffect as useEffect30, useRef as useRef17, useState as useState42, useCallback as useCallback36, useMemo as useMemo11 } from "react";
|
|
8750
8789
|
import { AppState } from "react-native";
|
|
8751
8790
|
|
|
8752
8791
|
// src/chat/socket.ts
|
|
@@ -8860,18 +8899,18 @@ var ChatContext = createContext5(null);
|
|
|
8860
8899
|
function ChatProvider({ children, autoConnect = true }) {
|
|
8861
8900
|
const { client } = useDubs();
|
|
8862
8901
|
const socketRef = useRef17(new ChatSocket());
|
|
8863
|
-
const [status, setStatus] =
|
|
8864
|
-
const [messages, setMessages] =
|
|
8865
|
-
const [onlineUsers, setOnlineUsers] =
|
|
8866
|
-
const [onlineCount, setOnlineCount] =
|
|
8867
|
-
const [unreadCount, setUnreadCount] =
|
|
8868
|
-
const [conversations, setConversations] =
|
|
8869
|
-
const [friends, setFriends] =
|
|
8870
|
-
const [pendingRequests, setPendingRequests] =
|
|
8871
|
-
const [sentFriendRequests, setSentFriendRequests] =
|
|
8872
|
-
const [whatsNewPosts, setWhatsNewPosts] =
|
|
8873
|
-
const [whatsNewUnreadCount, setWhatsNewUnreadCount] =
|
|
8874
|
-
const refreshMessages =
|
|
8902
|
+
const [status, setStatus] = useState42("disconnected");
|
|
8903
|
+
const [messages, setMessages] = useState42([]);
|
|
8904
|
+
const [onlineUsers, setOnlineUsers] = useState42([]);
|
|
8905
|
+
const [onlineCount, setOnlineCount] = useState42(0);
|
|
8906
|
+
const [unreadCount, setUnreadCount] = useState42(0);
|
|
8907
|
+
const [conversations, setConversations] = useState42([]);
|
|
8908
|
+
const [friends, setFriends] = useState42([]);
|
|
8909
|
+
const [pendingRequests, setPendingRequests] = useState42([]);
|
|
8910
|
+
const [sentFriendRequests, setSentFriendRequests] = useState42([]);
|
|
8911
|
+
const [whatsNewPosts, setWhatsNewPosts] = useState42([]);
|
|
8912
|
+
const [whatsNewUnreadCount, setWhatsNewUnreadCount] = useState42(0);
|
|
8913
|
+
const refreshMessages = useCallback36(async () => {
|
|
8875
8914
|
try {
|
|
8876
8915
|
const res = await client.getChatMessages({ limit: 30 });
|
|
8877
8916
|
setMessages([...res.messages].reverse());
|
|
@@ -8879,35 +8918,35 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8879
8918
|
console.error("[Dubs:ChatProvider] Failed to load messages:", err);
|
|
8880
8919
|
}
|
|
8881
8920
|
}, [client]);
|
|
8882
|
-
const refreshConversations =
|
|
8921
|
+
const refreshConversations = useCallback36(async () => {
|
|
8883
8922
|
try {
|
|
8884
8923
|
const res = await client.getConversations();
|
|
8885
8924
|
setConversations(res.conversations);
|
|
8886
8925
|
} catch (_) {
|
|
8887
8926
|
}
|
|
8888
8927
|
}, [client]);
|
|
8889
|
-
const refreshFriends =
|
|
8928
|
+
const refreshFriends = useCallback36(async () => {
|
|
8890
8929
|
try {
|
|
8891
8930
|
const res = await client.getFriends();
|
|
8892
8931
|
setFriends(res.friends);
|
|
8893
8932
|
} catch (_) {
|
|
8894
8933
|
}
|
|
8895
8934
|
}, [client]);
|
|
8896
|
-
const refreshPendingRequests =
|
|
8935
|
+
const refreshPendingRequests = useCallback36(async () => {
|
|
8897
8936
|
try {
|
|
8898
8937
|
const res = await client.getPendingFriendRequests();
|
|
8899
8938
|
setPendingRequests(res.requests);
|
|
8900
8939
|
} catch (_) {
|
|
8901
8940
|
}
|
|
8902
8941
|
}, [client]);
|
|
8903
|
-
const refreshSentFriendRequests =
|
|
8942
|
+
const refreshSentFriendRequests = useCallback36(async () => {
|
|
8904
8943
|
try {
|
|
8905
8944
|
const res = await client.getSentFriendRequests();
|
|
8906
8945
|
setSentFriendRequests(res.requests);
|
|
8907
8946
|
} catch (_) {
|
|
8908
8947
|
}
|
|
8909
8948
|
}, [client]);
|
|
8910
|
-
const refreshWhatsNew =
|
|
8949
|
+
const refreshWhatsNew = useCallback36(async () => {
|
|
8911
8950
|
try {
|
|
8912
8951
|
const res = await client.getWhatsNewPosts();
|
|
8913
8952
|
setWhatsNewPosts(res.posts);
|
|
@@ -8916,7 +8955,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8916
8955
|
} catch (_) {
|
|
8917
8956
|
}
|
|
8918
8957
|
}, [client]);
|
|
8919
|
-
|
|
8958
|
+
useEffect30(() => {
|
|
8920
8959
|
const token = client.getToken();
|
|
8921
8960
|
if (!autoConnect || !token) return;
|
|
8922
8961
|
const chatSocket = socketRef.current;
|
|
@@ -8994,7 +9033,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8994
9033
|
chatSocket.disconnect();
|
|
8995
9034
|
};
|
|
8996
9035
|
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8997
|
-
|
|
9036
|
+
useEffect30(() => {
|
|
8998
9037
|
const handleAppState = (nextState) => {
|
|
8999
9038
|
if (nextState === "active") {
|
|
9000
9039
|
const chatSocket = socketRef.current;
|
|
@@ -9056,14 +9095,14 @@ function useChatContext() {
|
|
|
9056
9095
|
}
|
|
9057
9096
|
|
|
9058
9097
|
// src/chat/hooks.ts
|
|
9059
|
-
import { useState as
|
|
9098
|
+
import { useState as useState43, useCallback as useCallback37, useEffect as useEffect31, useRef as useRef18 } from "react";
|
|
9060
9099
|
function useChatStatus() {
|
|
9061
9100
|
return useChatContext().status;
|
|
9062
9101
|
}
|
|
9063
9102
|
function useChatMessages() {
|
|
9064
9103
|
const { messages, refreshMessages } = useChatContext();
|
|
9065
|
-
const [loading, setLoading] =
|
|
9066
|
-
const refetch =
|
|
9104
|
+
const [loading, setLoading] = useState43(false);
|
|
9105
|
+
const refetch = useCallback37(async () => {
|
|
9067
9106
|
setLoading(true);
|
|
9068
9107
|
await refreshMessages();
|
|
9069
9108
|
setLoading(false);
|
|
@@ -9073,13 +9112,13 @@ function useChatMessages() {
|
|
|
9073
9112
|
function useSendMessage() {
|
|
9074
9113
|
const { socket } = useChatContext();
|
|
9075
9114
|
const { client } = useDubs();
|
|
9076
|
-
const send =
|
|
9115
|
+
const send = useCallback37(
|
|
9077
9116
|
(params) => {
|
|
9078
9117
|
socket.sendMessage(params);
|
|
9079
9118
|
},
|
|
9080
9119
|
[socket]
|
|
9081
9120
|
);
|
|
9082
|
-
const sendViaREST =
|
|
9121
|
+
const sendViaREST = useCallback37(
|
|
9083
9122
|
async (params) => {
|
|
9084
9123
|
await client.sendChatMessage(params);
|
|
9085
9124
|
},
|
|
@@ -9096,8 +9135,8 @@ function useUnreadCount() {
|
|
|
9096
9135
|
}
|
|
9097
9136
|
function useConversations() {
|
|
9098
9137
|
const { conversations, refreshConversations } = useChatContext();
|
|
9099
|
-
const [loading, setLoading] =
|
|
9100
|
-
const refetch =
|
|
9138
|
+
const [loading, setLoading] = useState43(false);
|
|
9139
|
+
const refetch = useCallback37(async () => {
|
|
9101
9140
|
setLoading(true);
|
|
9102
9141
|
await refreshConversations();
|
|
9103
9142
|
setLoading(false);
|
|
@@ -9107,10 +9146,10 @@ function useConversations() {
|
|
|
9107
9146
|
function useDirectMessages(recipientWallet) {
|
|
9108
9147
|
const { client } = useDubs();
|
|
9109
9148
|
const { socket, refreshConversations } = useChatContext();
|
|
9110
|
-
const [messages, setMessages] =
|
|
9111
|
-
const [otherUser, setOtherUser] =
|
|
9112
|
-
const [loading, setLoading] =
|
|
9113
|
-
const refetch =
|
|
9149
|
+
const [messages, setMessages] = useState43([]);
|
|
9150
|
+
const [otherUser, setOtherUser] = useState43(null);
|
|
9151
|
+
const [loading, setLoading] = useState43(true);
|
|
9152
|
+
const refetch = useCallback37(async () => {
|
|
9114
9153
|
try {
|
|
9115
9154
|
setLoading(true);
|
|
9116
9155
|
const res = await client.getConversation(recipientWallet);
|
|
@@ -9122,7 +9161,7 @@ function useDirectMessages(recipientWallet) {
|
|
|
9122
9161
|
setLoading(false);
|
|
9123
9162
|
}
|
|
9124
9163
|
}, [client, recipientWallet]);
|
|
9125
|
-
|
|
9164
|
+
useEffect31(() => {
|
|
9126
9165
|
refetch();
|
|
9127
9166
|
socket.joinDM(recipientWallet);
|
|
9128
9167
|
return () => {
|
|
@@ -9131,7 +9170,7 @@ function useDirectMessages(recipientWallet) {
|
|
|
9131
9170
|
}, [recipientWallet, refetch, socket]);
|
|
9132
9171
|
const socketRef = useRef18(socket);
|
|
9133
9172
|
socketRef.current = socket;
|
|
9134
|
-
|
|
9173
|
+
useEffect31(() => {
|
|
9135
9174
|
const currentSocket = socketRef.current;
|
|
9136
9175
|
const prevListeners = currentSocket.listeners;
|
|
9137
9176
|
const originalOnDMNew = prevListeners?.onDMNewMessage;
|
|
@@ -9154,13 +9193,13 @@ function useDirectMessages(recipientWallet) {
|
|
|
9154
9193
|
}
|
|
9155
9194
|
});
|
|
9156
9195
|
}, [recipientWallet]);
|
|
9157
|
-
const send =
|
|
9196
|
+
const send = useCallback37(
|
|
9158
9197
|
(message) => {
|
|
9159
9198
|
socket.sendDM({ recipientWallet, message });
|
|
9160
9199
|
},
|
|
9161
9200
|
[socket, recipientWallet]
|
|
9162
9201
|
);
|
|
9163
|
-
const sendViaREST =
|
|
9202
|
+
const sendViaREST = useCallback37(
|
|
9164
9203
|
async (message) => {
|
|
9165
9204
|
await client.sendDirectMessage({ recipientWallet, message });
|
|
9166
9205
|
await refetch();
|
|
@@ -9168,15 +9207,15 @@ function useDirectMessages(recipientWallet) {
|
|
|
9168
9207
|
},
|
|
9169
9208
|
[client, recipientWallet, refetch, refreshConversations]
|
|
9170
9209
|
);
|
|
9171
|
-
const markRead =
|
|
9210
|
+
const markRead = useCallback37(() => {
|
|
9172
9211
|
socket.markDMRead(recipientWallet);
|
|
9173
9212
|
}, [socket, recipientWallet]);
|
|
9174
9213
|
return { messages, loading, otherUser, send, sendViaREST, markRead, refetch };
|
|
9175
9214
|
}
|
|
9176
9215
|
function useFriends() {
|
|
9177
9216
|
const { friends, refreshFriends } = useChatContext();
|
|
9178
|
-
const [loading, setLoading] =
|
|
9179
|
-
const refetch =
|
|
9217
|
+
const [loading, setLoading] = useState43(false);
|
|
9218
|
+
const refetch = useCallback37(async () => {
|
|
9180
9219
|
setLoading(true);
|
|
9181
9220
|
await refreshFriends();
|
|
9182
9221
|
setLoading(false);
|
|
@@ -9185,8 +9224,8 @@ function useFriends() {
|
|
|
9185
9224
|
}
|
|
9186
9225
|
function useFriendRequests() {
|
|
9187
9226
|
const { pendingRequests, refreshPendingRequests } = useChatContext();
|
|
9188
|
-
const [loading, setLoading] =
|
|
9189
|
-
const refetch =
|
|
9227
|
+
const [loading, setLoading] = useState43(false);
|
|
9228
|
+
const refetch = useCallback37(async () => {
|
|
9190
9229
|
setLoading(true);
|
|
9191
9230
|
await refreshPendingRequests();
|
|
9192
9231
|
setLoading(false);
|
|
@@ -9195,8 +9234,8 @@ function useFriendRequests() {
|
|
|
9195
9234
|
}
|
|
9196
9235
|
function useSentFriendRequests() {
|
|
9197
9236
|
const { sentFriendRequests, refreshSentFriendRequests } = useChatContext();
|
|
9198
|
-
const [loading, setLoading] =
|
|
9199
|
-
const refetch =
|
|
9237
|
+
const [loading, setLoading] = useState43(false);
|
|
9238
|
+
const refetch = useCallback37(async () => {
|
|
9200
9239
|
setLoading(true);
|
|
9201
9240
|
await refreshSentFriendRequests();
|
|
9202
9241
|
setLoading(false);
|
|
@@ -9206,8 +9245,8 @@ function useSentFriendRequests() {
|
|
|
9206
9245
|
function useCancelFriendRequest() {
|
|
9207
9246
|
const { client } = useDubs();
|
|
9208
9247
|
const { refreshSentFriendRequests } = useChatContext();
|
|
9209
|
-
const [loading, setLoading] =
|
|
9210
|
-
const cancel =
|
|
9248
|
+
const [loading, setLoading] = useState43(false);
|
|
9249
|
+
const cancel = useCallback37(
|
|
9211
9250
|
async (requestId) => {
|
|
9212
9251
|
setLoading(true);
|
|
9213
9252
|
try {
|
|
@@ -9223,9 +9262,9 @@ function useCancelFriendRequest() {
|
|
|
9223
9262
|
}
|
|
9224
9263
|
function useSearchUsers() {
|
|
9225
9264
|
const { client } = useDubs();
|
|
9226
|
-
const [results, setResults] =
|
|
9227
|
-
const [loading, setLoading] =
|
|
9228
|
-
const search =
|
|
9265
|
+
const [results, setResults] = useState43([]);
|
|
9266
|
+
const [loading, setLoading] = useState43(false);
|
|
9267
|
+
const search = useCallback37(
|
|
9229
9268
|
async (query) => {
|
|
9230
9269
|
setLoading(true);
|
|
9231
9270
|
try {
|
|
@@ -9239,14 +9278,14 @@ function useSearchUsers() {
|
|
|
9239
9278
|
},
|
|
9240
9279
|
[client]
|
|
9241
9280
|
);
|
|
9242
|
-
const clear =
|
|
9281
|
+
const clear = useCallback37(() => setResults([]), []);
|
|
9243
9282
|
return { results, loading, search, clear };
|
|
9244
9283
|
}
|
|
9245
9284
|
function useSendFriendRequest() {
|
|
9246
9285
|
const { client } = useDubs();
|
|
9247
9286
|
const { refreshPendingRequests } = useChatContext();
|
|
9248
|
-
const [loading, setLoading] =
|
|
9249
|
-
const send =
|
|
9287
|
+
const [loading, setLoading] = useState43(false);
|
|
9288
|
+
const send = useCallback37(
|
|
9250
9289
|
async (targetUserId) => {
|
|
9251
9290
|
setLoading(true);
|
|
9252
9291
|
try {
|
|
@@ -9262,8 +9301,8 @@ function useSendFriendRequest() {
|
|
|
9262
9301
|
function useRespondToFriendRequest() {
|
|
9263
9302
|
const { client } = useDubs();
|
|
9264
9303
|
const { refreshFriends, refreshPendingRequests } = useChatContext();
|
|
9265
|
-
const [loading, setLoading] =
|
|
9266
|
-
const accept =
|
|
9304
|
+
const [loading, setLoading] = useState43(false);
|
|
9305
|
+
const accept = useCallback37(
|
|
9267
9306
|
async (requestId) => {
|
|
9268
9307
|
setLoading(true);
|
|
9269
9308
|
try {
|
|
@@ -9275,7 +9314,7 @@ function useRespondToFriendRequest() {
|
|
|
9275
9314
|
},
|
|
9276
9315
|
[client, refreshFriends, refreshPendingRequests]
|
|
9277
9316
|
);
|
|
9278
|
-
const reject =
|
|
9317
|
+
const reject = useCallback37(
|
|
9279
9318
|
async (requestId) => {
|
|
9280
9319
|
setLoading(true);
|
|
9281
9320
|
try {
|
|
@@ -9292,8 +9331,8 @@ function useRespondToFriendRequest() {
|
|
|
9292
9331
|
function useWhatsNew() {
|
|
9293
9332
|
const { client } = useDubs();
|
|
9294
9333
|
const { whatsNewPosts, whatsNewUnreadCount, refreshWhatsNew } = useChatContext();
|
|
9295
|
-
const [loading, setLoading] =
|
|
9296
|
-
const refetch =
|
|
9334
|
+
const [loading, setLoading] = useState43(false);
|
|
9335
|
+
const refetch = useCallback37(async () => {
|
|
9297
9336
|
setLoading(true);
|
|
9298
9337
|
try {
|
|
9299
9338
|
await refreshWhatsNew();
|
|
@@ -9301,7 +9340,7 @@ function useWhatsNew() {
|
|
|
9301
9340
|
setLoading(false);
|
|
9302
9341
|
}
|
|
9303
9342
|
}, [refreshWhatsNew]);
|
|
9304
|
-
const markRead =
|
|
9343
|
+
const markRead = useCallback37(
|
|
9305
9344
|
async (postIds) => {
|
|
9306
9345
|
if (postIds.length === 0) return;
|
|
9307
9346
|
try {
|
|
@@ -9313,7 +9352,7 @@ function useWhatsNew() {
|
|
|
9313
9352
|
},
|
|
9314
9353
|
[client, refreshWhatsNew]
|
|
9315
9354
|
);
|
|
9316
|
-
const markAllRead =
|
|
9355
|
+
const markAllRead = useCallback37(async () => {
|
|
9317
9356
|
try {
|
|
9318
9357
|
await client.markAllWhatsNewRead();
|
|
9319
9358
|
await refreshWhatsNew();
|
|
@@ -9387,6 +9426,7 @@ export {
|
|
|
9387
9426
|
useConversations,
|
|
9388
9427
|
useCreateCustomGame,
|
|
9389
9428
|
useCreateGame,
|
|
9429
|
+
useCredits,
|
|
9390
9430
|
useDirectMessages,
|
|
9391
9431
|
useDubs,
|
|
9392
9432
|
useDubsTheme,
|