@dubsdotapp/expo 0.5.29 → 0.5.31
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 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +243 -230
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +193 -180
- 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 +1 -0
- package/src/types.ts +15 -0
- package/src/ui/game/JoinGameSheet.tsx +14 -7
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,9 @@ 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
|
+
|
|
3262
3275
|
// src/ui/AvatarEditor.tsx
|
|
3263
3276
|
import {
|
|
3264
3277
|
View as View2,
|
|
@@ -3427,11 +3440,11 @@ function AuthGate({
|
|
|
3427
3440
|
}) {
|
|
3428
3441
|
const { client, pushEnabled, uiConfig } = useDubs();
|
|
3429
3442
|
const auth = useAuth();
|
|
3430
|
-
const [phase, setPhase] =
|
|
3431
|
-
const [registrationPhase, setRegistrationPhase] =
|
|
3432
|
-
const [showPushSetup, setShowPushSetup] =
|
|
3433
|
-
const [isRestoredSession, setIsRestoredSession] =
|
|
3434
|
-
|
|
3443
|
+
const [phase, setPhase] = useState27("init");
|
|
3444
|
+
const [registrationPhase, setRegistrationPhase] = useState27(false);
|
|
3445
|
+
const [showPushSetup, setShowPushSetup] = useState27(false);
|
|
3446
|
+
const [isRestoredSession, setIsRestoredSession] = useState27(false);
|
|
3447
|
+
useEffect18(() => {
|
|
3435
3448
|
let cancelled = false;
|
|
3436
3449
|
(async () => {
|
|
3437
3450
|
try {
|
|
@@ -3458,23 +3471,23 @@ function AuthGate({
|
|
|
3458
3471
|
cancelled = true;
|
|
3459
3472
|
};
|
|
3460
3473
|
}, []);
|
|
3461
|
-
|
|
3474
|
+
useEffect18(() => {
|
|
3462
3475
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
3463
3476
|
}, [auth.status]);
|
|
3464
|
-
|
|
3477
|
+
useEffect18(() => {
|
|
3465
3478
|
if (pushEnabled && uiConfig.pushConfigured?.android && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
3466
3479
|
setShowPushSetup(true);
|
|
3467
3480
|
}
|
|
3468
3481
|
}, [pushEnabled, uiConfig.pushConfigured?.android, auth.status, registrationPhase, isRestoredSession]);
|
|
3469
|
-
|
|
3482
|
+
useEffect18(() => {
|
|
3470
3483
|
if (auth.token) onSaveToken(auth.token);
|
|
3471
3484
|
}, [auth.token]);
|
|
3472
|
-
const retry =
|
|
3485
|
+
const retry = useCallback25(() => {
|
|
3473
3486
|
setRegistrationPhase(false);
|
|
3474
3487
|
auth.reset();
|
|
3475
3488
|
auth.authenticate();
|
|
3476
3489
|
}, [auth]);
|
|
3477
|
-
const handleRegister =
|
|
3490
|
+
const handleRegister = useCallback25(
|
|
3478
3491
|
(username, referralCode, avatarUrl) => {
|
|
3479
3492
|
auth.register(username, referralCode, avatarUrl);
|
|
3480
3493
|
},
|
|
@@ -3594,20 +3607,20 @@ function DefaultRegistrationScreen({
|
|
|
3594
3607
|
const t = useDubsTheme();
|
|
3595
3608
|
const accent = accentColor || t.accent;
|
|
3596
3609
|
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] =
|
|
3610
|
+
const [step, setStep] = useState27(0);
|
|
3611
|
+
const [avatarSeed, setAvatarSeed] = useState27(generateSeed);
|
|
3612
|
+
const [avatarStyle, setAvatarStyle] = useState27("adventurer");
|
|
3613
|
+
const [avatarBg, setAvatarBg] = useState27("1a1a2e");
|
|
3614
|
+
const [showStyles, setShowStyles] = useState27(false);
|
|
3615
|
+
const [username, setUsername] = useState27("");
|
|
3616
|
+
const [referralCode, setReferralCode] = useState27("");
|
|
3617
|
+
const [checking, setChecking] = useState27(false);
|
|
3618
|
+
const [availability, setAvailability] = useState27(null);
|
|
3606
3619
|
const debounceRef = useRef6(null);
|
|
3607
3620
|
const fadeAnim = useRef6(new Animated.Value(1)).current;
|
|
3608
3621
|
const slideAnim = useRef6(new Animated.Value(0)).current;
|
|
3609
3622
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3610
|
-
|
|
3623
|
+
useEffect18(() => {
|
|
3611
3624
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3612
3625
|
const trimmed = username.trim();
|
|
3613
3626
|
if (trimmed.length < 3) {
|
|
@@ -3630,7 +3643,7 @@ function DefaultRegistrationScreen({
|
|
|
3630
3643
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3631
3644
|
};
|
|
3632
3645
|
}, [username, client]);
|
|
3633
|
-
const animateToStep =
|
|
3646
|
+
const animateToStep = useCallback25((newStep) => {
|
|
3634
3647
|
const dir = newStep > step ? 1 : -1;
|
|
3635
3648
|
Keyboard.dismiss();
|
|
3636
3649
|
Animated.parallel([
|
|
@@ -3829,7 +3842,7 @@ function DefaultRegistrationScreen({
|
|
|
3829
3842
|
)
|
|
3830
3843
|
] })
|
|
3831
3844
|
] });
|
|
3832
|
-
|
|
3845
|
+
useEffect18(() => {
|
|
3833
3846
|
if (pushStepActive && step !== 3) {
|
|
3834
3847
|
animateToStep(3);
|
|
3835
3848
|
}
|
|
@@ -3924,7 +3937,7 @@ function DefaultRegistrationScreen({
|
|
|
3924
3937
|
function PushTokenRestorer() {
|
|
3925
3938
|
const push = usePushNotifications();
|
|
3926
3939
|
const restored = useRef6(false);
|
|
3927
|
-
|
|
3940
|
+
useEffect18(() => {
|
|
3928
3941
|
if (restored.current) return;
|
|
3929
3942
|
restored.current = true;
|
|
3930
3943
|
push.restoreIfGranted();
|
|
@@ -4030,9 +4043,9 @@ function DubsProvider({
|
|
|
4030
4043
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
4031
4044
|
const client = useMemo3(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
4032
4045
|
const storage = useMemo3(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
4033
|
-
const [uiConfig, setUiConfig] =
|
|
4034
|
-
const [resolvedNetwork, setResolvedNetwork] =
|
|
4035
|
-
|
|
4046
|
+
const [uiConfig, setUiConfig] = useState28(null);
|
|
4047
|
+
const [resolvedNetwork, setResolvedNetwork] = useState28(network);
|
|
4048
|
+
useEffect19(() => {
|
|
4036
4049
|
client.getAppConfig().then((cfg) => {
|
|
4037
4050
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
4038
4051
|
setUiConfig(cfg);
|
|
@@ -4124,7 +4137,7 @@ function ManagedInner({
|
|
|
4124
4137
|
children
|
|
4125
4138
|
}) {
|
|
4126
4139
|
const managedDisconnect = useDisconnect();
|
|
4127
|
-
const disconnect =
|
|
4140
|
+
const disconnect = useCallback26(async () => {
|
|
4128
4141
|
client.setToken(null);
|
|
4129
4142
|
await managedDisconnect?.();
|
|
4130
4143
|
}, [client, managedDisconnect]);
|
|
@@ -4165,7 +4178,7 @@ function ExternalWalletProvider({
|
|
|
4165
4178
|
pushEnabled,
|
|
4166
4179
|
children
|
|
4167
4180
|
}) {
|
|
4168
|
-
const disconnect =
|
|
4181
|
+
const disconnect = useCallback26(async () => {
|
|
4169
4182
|
client.setToken(null);
|
|
4170
4183
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
4171
4184
|
});
|
|
@@ -4486,7 +4499,7 @@ var styles5 = StyleSheet6.create({
|
|
|
4486
4499
|
});
|
|
4487
4500
|
|
|
4488
4501
|
// src/ui/UserProfileSheet.tsx
|
|
4489
|
-
import { useState as
|
|
4502
|
+
import { useState as useState29, useEffect as useEffect20, useRef as useRef7, useCallback as useCallback27, useMemo as useMemo5 } from "react";
|
|
4490
4503
|
import {
|
|
4491
4504
|
View as View7,
|
|
4492
4505
|
Text as Text7,
|
|
@@ -4519,29 +4532,29 @@ function UserProfileSheet({
|
|
|
4519
4532
|
const push = usePushNotifications();
|
|
4520
4533
|
const overlayOpacity = useRef7(new Animated2.Value(0)).current;
|
|
4521
4534
|
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
|
-
|
|
4535
|
+
const [avatarStyle, setAvatarStyle] = useState29(parsed.style);
|
|
4536
|
+
const [avatarSeed, setAvatarSeed] = useState29(parsed.seed);
|
|
4537
|
+
const [bgColor, setBgColor] = useState29(parsed.bg);
|
|
4538
|
+
const [saving, setSaving] = useState29(false);
|
|
4539
|
+
const [error, setError] = useState29(null);
|
|
4540
|
+
useEffect20(() => {
|
|
4528
4541
|
const p = parseAvatarUrl(user.avatar);
|
|
4529
4542
|
setAvatarStyle(p.style);
|
|
4530
4543
|
setAvatarSeed(p.seed);
|
|
4531
4544
|
setBgColor(p.bg);
|
|
4532
4545
|
}, [user.avatar]);
|
|
4533
|
-
|
|
4546
|
+
useEffect20(() => {
|
|
4534
4547
|
Animated2.timing(overlayOpacity, {
|
|
4535
4548
|
toValue: visible ? 1 : 0,
|
|
4536
4549
|
duration: 250,
|
|
4537
4550
|
useNativeDriver: true
|
|
4538
4551
|
}).start();
|
|
4539
4552
|
}, [visible, overlayOpacity]);
|
|
4540
|
-
|
|
4553
|
+
useEffect20(() => {
|
|
4541
4554
|
if (visible) setError(null);
|
|
4542
4555
|
}, [visible]);
|
|
4543
4556
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4544
|
-
const saveAvatar =
|
|
4557
|
+
const saveAvatar = useCallback27(async (newUrl) => {
|
|
4545
4558
|
setSaving(true);
|
|
4546
4559
|
setError(null);
|
|
4547
4560
|
try {
|
|
@@ -4554,16 +4567,16 @@ function UserProfileSheet({
|
|
|
4554
4567
|
setSaving(false);
|
|
4555
4568
|
}
|
|
4556
4569
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4557
|
-
const handleStyleChange =
|
|
4570
|
+
const handleStyleChange = useCallback27((style) => {
|
|
4558
4571
|
setAvatarStyle(style);
|
|
4559
4572
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4560
4573
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4561
|
-
const handleShuffle =
|
|
4574
|
+
const handleShuffle = useCallback27(() => {
|
|
4562
4575
|
const newSeed = generateSeed();
|
|
4563
4576
|
setAvatarSeed(newSeed);
|
|
4564
4577
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4565
4578
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4566
|
-
const handleBgChange =
|
|
4579
|
+
const handleBgChange = useCallback27((color) => {
|
|
4567
4580
|
setBgColor(color);
|
|
4568
4581
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4569
4582
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4843,7 +4856,7 @@ var styles6 = StyleSheet7.create({
|
|
|
4843
4856
|
});
|
|
4844
4857
|
|
|
4845
4858
|
// src/ui/game/GamePoster.tsx
|
|
4846
|
-
import { useState as
|
|
4859
|
+
import { useState as useState30 } from "react";
|
|
4847
4860
|
import { StyleSheet as StyleSheet8, View as View8, Text as Text8 } from "react-native";
|
|
4848
4861
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4849
4862
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4893,7 +4906,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4893
4906
|
] });
|
|
4894
4907
|
}
|
|
4895
4908
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4896
|
-
const [failed, setFailed] =
|
|
4909
|
+
const [failed, setFailed] = useState30(false);
|
|
4897
4910
|
if (!url || failed) {
|
|
4898
4911
|
return /* @__PURE__ */ jsx10(View8, { style: [styles7.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4899
4912
|
}
|
|
@@ -5073,7 +5086,7 @@ var styles8 = StyleSheet9.create({
|
|
|
5073
5086
|
});
|
|
5074
5087
|
|
|
5075
5088
|
// src/ui/game/PickWinnerCard.tsx
|
|
5076
|
-
import { useState as
|
|
5089
|
+
import { useState as useState31, useMemo as useMemo7 } from "react";
|
|
5077
5090
|
import { StyleSheet as StyleSheet10, View as View10, Text as Text10, TouchableOpacity as TouchableOpacity7 } from "react-native";
|
|
5078
5091
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
5079
5092
|
function PickWinnerCard({
|
|
@@ -5144,7 +5157,7 @@ function TeamOption({
|
|
|
5144
5157
|
ImageComponent,
|
|
5145
5158
|
t
|
|
5146
5159
|
}) {
|
|
5147
|
-
const [imgFailed, setImgFailed] =
|
|
5160
|
+
const [imgFailed, setImgFailed] = useState31(false);
|
|
5148
5161
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5149
5162
|
const showImage = imageUrl && !imgFailed;
|
|
5150
5163
|
return /* @__PURE__ */ jsxs9(
|
|
@@ -5185,7 +5198,7 @@ var styles9 = StyleSheet10.create({
|
|
|
5185
5198
|
});
|
|
5186
5199
|
|
|
5187
5200
|
// src/ui/game/PlayersCard.tsx
|
|
5188
|
-
import { useState as
|
|
5201
|
+
import { useState as useState32 } from "react";
|
|
5189
5202
|
import { StyleSheet as StyleSheet11, View as View11, Text as Text11 } from "react-native";
|
|
5190
5203
|
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5191
5204
|
function truncateWallet(addr, chars) {
|
|
@@ -5234,7 +5247,7 @@ function BettorRow({
|
|
|
5234
5247
|
ImageComponent,
|
|
5235
5248
|
t
|
|
5236
5249
|
}) {
|
|
5237
|
-
const [imgFailed, setImgFailed] =
|
|
5250
|
+
const [imgFailed, setImgFailed] = useState32(false);
|
|
5238
5251
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5239
5252
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
5240
5253
|
return /* @__PURE__ */ jsxs10(View11, { style: [styles10.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -5313,7 +5326,7 @@ var styles11 = StyleSheet12.create({
|
|
|
5313
5326
|
});
|
|
5314
5327
|
|
|
5315
5328
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
5316
|
-
import { useState as
|
|
5329
|
+
import { useState as useState33, useEffect as useEffect21, useRef as useRef8, useCallback as useCallback28 } from "react";
|
|
5317
5330
|
import {
|
|
5318
5331
|
View as View13,
|
|
5319
5332
|
Text as Text13,
|
|
@@ -5350,18 +5363,18 @@ function CreateCustomGameSheet({
|
|
|
5350
5363
|
const t = useDubsTheme();
|
|
5351
5364
|
const { wallet } = useDubs();
|
|
5352
5365
|
const mutation = useCreateCustomGame();
|
|
5353
|
-
const [selectedAmount, setSelectedAmount] =
|
|
5354
|
-
const [customAmount, setCustomAmount] =
|
|
5355
|
-
const [isCustom, setIsCustom] =
|
|
5366
|
+
const [selectedAmount, setSelectedAmount] = useState33(null);
|
|
5367
|
+
const [customAmount, setCustomAmount] = useState33("");
|
|
5368
|
+
const [isCustom, setIsCustom] = useState33(false);
|
|
5356
5369
|
const overlayOpacity = useRef8(new Animated3.Value(0)).current;
|
|
5357
|
-
|
|
5370
|
+
useEffect21(() => {
|
|
5358
5371
|
Animated3.timing(overlayOpacity, {
|
|
5359
5372
|
toValue: visible ? 1 : 0,
|
|
5360
5373
|
duration: 250,
|
|
5361
5374
|
useNativeDriver: true
|
|
5362
5375
|
}).start();
|
|
5363
5376
|
}, [visible, overlayOpacity]);
|
|
5364
|
-
|
|
5377
|
+
useEffect21(() => {
|
|
5365
5378
|
if (visible) {
|
|
5366
5379
|
setSelectedAmount(defaultAmount ?? null);
|
|
5367
5380
|
setCustomAmount("");
|
|
@@ -5369,7 +5382,7 @@ function CreateCustomGameSheet({
|
|
|
5369
5382
|
mutation.reset();
|
|
5370
5383
|
}
|
|
5371
5384
|
}, [visible]);
|
|
5372
|
-
|
|
5385
|
+
useEffect21(() => {
|
|
5373
5386
|
if (mutation.status === "success" && mutation.data) {
|
|
5374
5387
|
onSuccess?.(mutation.data);
|
|
5375
5388
|
const timer = setTimeout(() => {
|
|
@@ -5378,23 +5391,23 @@ function CreateCustomGameSheet({
|
|
|
5378
5391
|
return () => clearTimeout(timer);
|
|
5379
5392
|
}
|
|
5380
5393
|
}, [mutation.status, mutation.data]);
|
|
5381
|
-
|
|
5394
|
+
useEffect21(() => {
|
|
5382
5395
|
if (mutation.status === "error" && mutation.error) {
|
|
5383
5396
|
onError?.(mutation.error);
|
|
5384
5397
|
}
|
|
5385
5398
|
}, [mutation.status, mutation.error]);
|
|
5386
|
-
const handlePresetSelect =
|
|
5399
|
+
const handlePresetSelect = useCallback28((amount) => {
|
|
5387
5400
|
setSelectedAmount(amount);
|
|
5388
5401
|
setIsCustom(false);
|
|
5389
5402
|
setCustomAmount("");
|
|
5390
5403
|
onAmountChange?.(amount);
|
|
5391
5404
|
}, [onAmountChange]);
|
|
5392
|
-
const handleCustomSelect =
|
|
5405
|
+
const handleCustomSelect = useCallback28(() => {
|
|
5393
5406
|
setIsCustom(true);
|
|
5394
5407
|
setSelectedAmount(null);
|
|
5395
5408
|
onAmountChange?.(null);
|
|
5396
5409
|
}, [onAmountChange]);
|
|
5397
|
-
const handleCustomAmountChange =
|
|
5410
|
+
const handleCustomAmountChange = useCallback28((text) => {
|
|
5398
5411
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
5399
5412
|
setCustomAmount(cleaned);
|
|
5400
5413
|
const parsed = parseFloat(cleaned);
|
|
@@ -5409,7 +5422,7 @@ function CreateCustomGameSheet({
|
|
|
5409
5422
|
const winnerTakes = pot * (1 - fee / 100);
|
|
5410
5423
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5411
5424
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
5412
|
-
const handleCreate =
|
|
5425
|
+
const handleCreate = useCallback28(async () => {
|
|
5413
5426
|
if (!finalAmount || !wallet.publicKey) return;
|
|
5414
5427
|
try {
|
|
5415
5428
|
await mutation.execute({
|
|
@@ -5678,7 +5691,7 @@ var styles12 = StyleSheet13.create({
|
|
|
5678
5691
|
});
|
|
5679
5692
|
|
|
5680
5693
|
// src/ui/game/JoinGameSheet.tsx
|
|
5681
|
-
import { useState as
|
|
5694
|
+
import { useState as useState35, useEffect as useEffect22, useRef as useRef10, useCallback as useCallback30, useMemo as useMemo9 } from "react";
|
|
5682
5695
|
import {
|
|
5683
5696
|
View as View16,
|
|
5684
5697
|
Text as Text16,
|
|
@@ -5888,7 +5901,7 @@ var styles13 = StyleSheet14.create({
|
|
|
5888
5901
|
});
|
|
5889
5902
|
|
|
5890
5903
|
// src/ui/game/TeamButton.tsx
|
|
5891
|
-
import { useState as
|
|
5904
|
+
import { useState as useState34 } from "react";
|
|
5892
5905
|
import { View as View15, Text as Text15, TouchableOpacity as TouchableOpacity10, StyleSheet as StyleSheet15 } from "react-native";
|
|
5893
5906
|
import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5894
5907
|
function TeamButton({
|
|
@@ -5902,7 +5915,7 @@ function TeamButton({
|
|
|
5902
5915
|
ImageComponent,
|
|
5903
5916
|
t
|
|
5904
5917
|
}) {
|
|
5905
|
-
const [imgFailed, setImgFailed] =
|
|
5918
|
+
const [imgFailed, setImgFailed] = useState34(false);
|
|
5906
5919
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5907
5920
|
const showImage = imageUrl && !imgFailed;
|
|
5908
5921
|
return /* @__PURE__ */ jsxs14(
|
|
@@ -6006,20 +6019,20 @@ function JoinGameSheet({
|
|
|
6006
6019
|
const { wallet } = useDubs();
|
|
6007
6020
|
const mutation = useJoinGame();
|
|
6008
6021
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
6009
|
-
const [selectedTeam, setSelectedTeam] =
|
|
6010
|
-
const [wager, setWager] =
|
|
6011
|
-
const [showSuccess, setShowSuccess] =
|
|
6022
|
+
const [selectedTeam, setSelectedTeam] = useState35(null);
|
|
6023
|
+
const [wager, setWager] = useState35(game.buyIn);
|
|
6024
|
+
const [showSuccess, setShowSuccess] = useState35(false);
|
|
6012
6025
|
const overlayOpacity = useRef10(new Animated4.Value(0)).current;
|
|
6013
6026
|
const successScale = useRef10(new Animated4.Value(0)).current;
|
|
6014
6027
|
const successOpacity = useRef10(new Animated4.Value(0)).current;
|
|
6015
|
-
|
|
6028
|
+
useEffect22(() => {
|
|
6016
6029
|
Animated4.timing(overlayOpacity, {
|
|
6017
6030
|
toValue: visible ? 1 : 0,
|
|
6018
6031
|
duration: 250,
|
|
6019
6032
|
useNativeDriver: true
|
|
6020
6033
|
}).start();
|
|
6021
6034
|
}, [visible, overlayOpacity]);
|
|
6022
|
-
|
|
6035
|
+
useEffect22(() => {
|
|
6023
6036
|
if (visible) {
|
|
6024
6037
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
6025
6038
|
setWager(game.buyIn);
|
|
@@ -6029,7 +6042,7 @@ function JoinGameSheet({
|
|
|
6029
6042
|
mutation.reset();
|
|
6030
6043
|
}
|
|
6031
6044
|
}, [visible]);
|
|
6032
|
-
|
|
6045
|
+
useEffect22(() => {
|
|
6033
6046
|
if (mutation.status === "success" && mutation.data) {
|
|
6034
6047
|
setShowSuccess(true);
|
|
6035
6048
|
onSuccess?.(mutation.data);
|
|
@@ -6046,7 +6059,7 @@ function JoinGameSheet({
|
|
|
6046
6059
|
return () => clearTimeout(timer);
|
|
6047
6060
|
}
|
|
6048
6061
|
}, [mutation.status, mutation.data]);
|
|
6049
|
-
|
|
6062
|
+
useEffect22(() => {
|
|
6050
6063
|
if (mutation.status === "error" && mutation.error) {
|
|
6051
6064
|
onError?.(mutation.error);
|
|
6052
6065
|
}
|
|
@@ -6066,18 +6079,18 @@ function JoinGameSheet({
|
|
|
6066
6079
|
const awayBetsCount = bettors.filter((b) => b.team === "away").length;
|
|
6067
6080
|
const drawBetsCount = bettors.filter((b) => b.team === "draw").length;
|
|
6068
6081
|
const newPool = totalPool + wager;
|
|
6069
|
-
const
|
|
6070
|
-
const
|
|
6071
|
-
const
|
|
6082
|
+
const homeWith = homePool + wager;
|
|
6083
|
+
const awayWith = awayPool + wager;
|
|
6084
|
+
const drawWith = drawPool + wager;
|
|
6072
6085
|
return {
|
|
6073
|
-
homeOdds:
|
|
6074
|
-
awayOdds:
|
|
6075
|
-
drawOdds:
|
|
6086
|
+
homeOdds: homeWith > 0 ? (newPool / homeWith).toFixed(2) : "\u2014",
|
|
6087
|
+
awayOdds: awayWith > 0 ? (newPool / awayWith).toFixed(2) : "\u2014",
|
|
6088
|
+
drawOdds: drawWith > 0 ? (newPool / drawWith).toFixed(2) : "\u2014",
|
|
6076
6089
|
homeBets: homeBetsCount,
|
|
6077
6090
|
awayBets: awayBetsCount,
|
|
6078
6091
|
drawBets: drawBetsCount
|
|
6079
6092
|
};
|
|
6080
|
-
}, [totalPool, homePool, awayPool, drawPool, bettors, wager
|
|
6093
|
+
}, [totalPool, homePool, awayPool, drawPool, bettors, wager]);
|
|
6081
6094
|
const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : selectedTeam === "draw" ? drawOdds : "\u2014";
|
|
6082
6095
|
const potentialWinnings = selectedOdds !== "\u2014" ? formatSol(parseFloat(selectedOdds) * wager) : "\u2014";
|
|
6083
6096
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
@@ -6090,7 +6103,7 @@ function JoinGameSheet({
|
|
|
6090
6103
|
const alreadyJoined = myBet !== null;
|
|
6091
6104
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6092
6105
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
6093
|
-
const handleJoin =
|
|
6106
|
+
const handleJoin = useCallback30(async () => {
|
|
6094
6107
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
6095
6108
|
try {
|
|
6096
6109
|
await mutation.execute({
|
|
@@ -6353,7 +6366,7 @@ function PickRow({
|
|
|
6353
6366
|
ImageComponent,
|
|
6354
6367
|
t
|
|
6355
6368
|
}) {
|
|
6356
|
-
const [imgFailed, setImgFailed] =
|
|
6369
|
+
const [imgFailed, setImgFailed] = useState35(false);
|
|
6357
6370
|
const Img = ImageComponent || __require("react-native").Image;
|
|
6358
6371
|
const showImage = imageUrl && !imgFailed;
|
|
6359
6372
|
return /* @__PURE__ */ jsxs15(
|
|
@@ -6646,7 +6659,7 @@ var styles15 = StyleSheet16.create({
|
|
|
6646
6659
|
});
|
|
6647
6660
|
|
|
6648
6661
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
6649
|
-
import { useState as
|
|
6662
|
+
import { useState as useState36, useEffect as useEffect23, useRef as useRef11, useCallback as useCallback31 } from "react";
|
|
6650
6663
|
import {
|
|
6651
6664
|
View as View17,
|
|
6652
6665
|
Text as Text17,
|
|
@@ -6680,15 +6693,15 @@ function ClaimPrizeSheet({
|
|
|
6680
6693
|
const overlayOpacity = useRef11(new Animated5.Value(0)).current;
|
|
6681
6694
|
const celebrationScale = useRef11(new Animated5.Value(0)).current;
|
|
6682
6695
|
const celebrationOpacity = useRef11(new Animated5.Value(0)).current;
|
|
6683
|
-
const [showCelebration, setShowCelebration] =
|
|
6684
|
-
|
|
6696
|
+
const [showCelebration, setShowCelebration] = useState36(false);
|
|
6697
|
+
useEffect23(() => {
|
|
6685
6698
|
Animated5.timing(overlayOpacity, {
|
|
6686
6699
|
toValue: visible ? 1 : 0,
|
|
6687
6700
|
duration: 250,
|
|
6688
6701
|
useNativeDriver: true
|
|
6689
6702
|
}).start();
|
|
6690
6703
|
}, [visible, overlayOpacity]);
|
|
6691
|
-
|
|
6704
|
+
useEffect23(() => {
|
|
6692
6705
|
if (visible) {
|
|
6693
6706
|
mutation.reset();
|
|
6694
6707
|
setShowCelebration(false);
|
|
@@ -6696,7 +6709,7 @@ function ClaimPrizeSheet({
|
|
|
6696
6709
|
celebrationOpacity.setValue(0);
|
|
6697
6710
|
}
|
|
6698
6711
|
}, [visible]);
|
|
6699
|
-
|
|
6712
|
+
useEffect23(() => {
|
|
6700
6713
|
if (mutation.status === "success" && mutation.data) {
|
|
6701
6714
|
setShowCelebration(true);
|
|
6702
6715
|
Animated5.parallel([
|
|
@@ -6719,14 +6732,14 @@ function ClaimPrizeSheet({
|
|
|
6719
6732
|
return () => clearTimeout(timer);
|
|
6720
6733
|
}
|
|
6721
6734
|
}, [mutation.status, mutation.data]);
|
|
6722
|
-
|
|
6735
|
+
useEffect23(() => {
|
|
6723
6736
|
if (mutation.status === "error" && mutation.error) {
|
|
6724
6737
|
onError?.(mutation.error);
|
|
6725
6738
|
}
|
|
6726
6739
|
}, [mutation.status, mutation.error]);
|
|
6727
6740
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6728
6741
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
6729
|
-
const handleClaim =
|
|
6742
|
+
const handleClaim = useCallback31(async () => {
|
|
6730
6743
|
if (!wallet.publicKey) return;
|
|
6731
6744
|
try {
|
|
6732
6745
|
await mutation.execute({
|
|
@@ -6959,7 +6972,7 @@ var styles16 = StyleSheet17.create({
|
|
|
6959
6972
|
});
|
|
6960
6973
|
|
|
6961
6974
|
// src/ui/game/ClaimButton.tsx
|
|
6962
|
-
import { useState as
|
|
6975
|
+
import { useState as useState37, useMemo as useMemo10, useCallback as useCallback32 } from "react";
|
|
6963
6976
|
import { StyleSheet as StyleSheet18, Text as Text18, TouchableOpacity as TouchableOpacity13 } from "react-native";
|
|
6964
6977
|
import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6965
6978
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -6967,7 +6980,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6967
6980
|
const { wallet } = useDubs();
|
|
6968
6981
|
const game = useGame(gameId);
|
|
6969
6982
|
const claimStatus = useHasClaimed(gameId);
|
|
6970
|
-
const [sheetVisible, setSheetVisible] =
|
|
6983
|
+
const [sheetVisible, setSheetVisible] = useState37(false);
|
|
6971
6984
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
6972
6985
|
const myBet = useMemo10(() => {
|
|
6973
6986
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
@@ -6978,7 +6991,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
6978
6991
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
6979
6992
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
6980
6993
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
6981
|
-
const handleSuccess =
|
|
6994
|
+
const handleSuccess = useCallback32(
|
|
6982
6995
|
(result) => {
|
|
6983
6996
|
claimStatus.refetch();
|
|
6984
6997
|
onSuccess?.(result);
|
|
@@ -7065,7 +7078,7 @@ var styles17 = StyleSheet18.create({
|
|
|
7065
7078
|
});
|
|
7066
7079
|
|
|
7067
7080
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
7068
|
-
import { useEffect as
|
|
7081
|
+
import { useEffect as useEffect24, useRef as useRef12, useCallback as useCallback33 } from "react";
|
|
7069
7082
|
import {
|
|
7070
7083
|
View as View18,
|
|
7071
7084
|
Text as Text19,
|
|
@@ -7097,19 +7110,19 @@ function EnterArcadePoolSheet({
|
|
|
7097
7110
|
const { wallet } = useDubs();
|
|
7098
7111
|
const mutation = useEnterArcadePool();
|
|
7099
7112
|
const overlayOpacity = useRef12(new Animated6.Value(0)).current;
|
|
7100
|
-
|
|
7113
|
+
useEffect24(() => {
|
|
7101
7114
|
Animated6.timing(overlayOpacity, {
|
|
7102
7115
|
toValue: visible ? 1 : 0,
|
|
7103
7116
|
duration: 250,
|
|
7104
7117
|
useNativeDriver: true
|
|
7105
7118
|
}).start();
|
|
7106
7119
|
}, [visible, overlayOpacity]);
|
|
7107
|
-
|
|
7120
|
+
useEffect24(() => {
|
|
7108
7121
|
if (visible) {
|
|
7109
7122
|
mutation.reset();
|
|
7110
7123
|
}
|
|
7111
7124
|
}, [visible]);
|
|
7112
|
-
|
|
7125
|
+
useEffect24(() => {
|
|
7113
7126
|
if (mutation.status === "success" && mutation.data) {
|
|
7114
7127
|
onSuccess?.(mutation.data);
|
|
7115
7128
|
const timer = setTimeout(() => {
|
|
@@ -7118,7 +7131,7 @@ function EnterArcadePoolSheet({
|
|
|
7118
7131
|
return () => clearTimeout(timer);
|
|
7119
7132
|
}
|
|
7120
7133
|
}, [mutation.status, mutation.data]);
|
|
7121
|
-
|
|
7134
|
+
useEffect24(() => {
|
|
7122
7135
|
if (mutation.status === "error" && mutation.error) {
|
|
7123
7136
|
onError?.(mutation.error);
|
|
7124
7137
|
}
|
|
@@ -7130,7 +7143,7 @@ function EnterArcadePoolSheet({
|
|
|
7130
7143
|
const potSol = (pool.buy_in_lamports * Number(totalBuyIns) / 1e9).toFixed(4);
|
|
7131
7144
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7132
7145
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
7133
|
-
const handleJoin =
|
|
7146
|
+
const handleJoin = useCallback33(async () => {
|
|
7134
7147
|
if (!wallet.publicKey) return;
|
|
7135
7148
|
try {
|
|
7136
7149
|
await mutation.execute(pool.id);
|
|
@@ -7281,7 +7294,7 @@ var styles18 = StyleSheet19.create({
|
|
|
7281
7294
|
});
|
|
7282
7295
|
|
|
7283
7296
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
7284
|
-
import { useEffect as
|
|
7297
|
+
import { useEffect as useEffect25, useRef as useRef13 } from "react";
|
|
7285
7298
|
import {
|
|
7286
7299
|
View as View19,
|
|
7287
7300
|
Text as Text20,
|
|
@@ -7310,14 +7323,14 @@ function ArcadeLeaderboardSheet({
|
|
|
7310
7323
|
const t = useDubsTheme();
|
|
7311
7324
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
7312
7325
|
const overlayOpacity = useRef13(new Animated7.Value(0)).current;
|
|
7313
|
-
|
|
7326
|
+
useEffect25(() => {
|
|
7314
7327
|
Animated7.timing(overlayOpacity, {
|
|
7315
7328
|
toValue: visible ? 1 : 0,
|
|
7316
7329
|
duration: 250,
|
|
7317
7330
|
useNativeDriver: true
|
|
7318
7331
|
}).start();
|
|
7319
7332
|
}, [visible, overlayOpacity]);
|
|
7320
|
-
|
|
7333
|
+
useEffect25(() => {
|
|
7321
7334
|
if (visible) refetch();
|
|
7322
7335
|
}, [visible]);
|
|
7323
7336
|
const renderItem = ({ item, index }) => {
|
|
@@ -7464,7 +7477,7 @@ var styles19 = StyleSheet20.create({
|
|
|
7464
7477
|
});
|
|
7465
7478
|
|
|
7466
7479
|
// src/ui/game/CreateGameSheet.tsx
|
|
7467
|
-
import { useState as
|
|
7480
|
+
import { useState as useState39, useEffect as useEffect26, useRef as useRef14, useCallback as useCallback34 } from "react";
|
|
7468
7481
|
import {
|
|
7469
7482
|
View as View20,
|
|
7470
7483
|
Text as Text21,
|
|
@@ -7503,20 +7516,20 @@ function CreateGameSheet({
|
|
|
7503
7516
|
const t = useDubsTheme();
|
|
7504
7517
|
const { wallet } = useDubs();
|
|
7505
7518
|
const mutation = useCreateGame();
|
|
7506
|
-
const [selectedTeam, setSelectedTeam] =
|
|
7507
|
-
const [wager, setWager] =
|
|
7508
|
-
const [showSuccess, setShowSuccess] =
|
|
7519
|
+
const [selectedTeam, setSelectedTeam] = useState39(null);
|
|
7520
|
+
const [wager, setWager] = useState39(0.01);
|
|
7521
|
+
const [showSuccess, setShowSuccess] = useState39(false);
|
|
7509
7522
|
const overlayOpacity = useRef14(new Animated8.Value(0)).current;
|
|
7510
7523
|
const successScale = useRef14(new Animated8.Value(0)).current;
|
|
7511
7524
|
const successOpacity = useRef14(new Animated8.Value(0)).current;
|
|
7512
|
-
|
|
7525
|
+
useEffect26(() => {
|
|
7513
7526
|
Animated8.timing(overlayOpacity, {
|
|
7514
7527
|
toValue: visible ? 1 : 0,
|
|
7515
7528
|
duration: 250,
|
|
7516
7529
|
useNativeDriver: true
|
|
7517
7530
|
}).start();
|
|
7518
7531
|
}, [visible]);
|
|
7519
|
-
|
|
7532
|
+
useEffect26(() => {
|
|
7520
7533
|
if (visible) {
|
|
7521
7534
|
setSelectedTeam(null);
|
|
7522
7535
|
setWager(0.01);
|
|
@@ -7526,7 +7539,7 @@ function CreateGameSheet({
|
|
|
7526
7539
|
mutation.reset();
|
|
7527
7540
|
}
|
|
7528
7541
|
}, [visible]);
|
|
7529
|
-
|
|
7542
|
+
useEffect26(() => {
|
|
7530
7543
|
if (mutation.status === "success" && mutation.data) {
|
|
7531
7544
|
setShowSuccess(true);
|
|
7532
7545
|
onSuccess?.(mutation.data);
|
|
@@ -7543,7 +7556,7 @@ function CreateGameSheet({
|
|
|
7543
7556
|
return () => clearTimeout(timer);
|
|
7544
7557
|
}
|
|
7545
7558
|
}, [mutation.status, mutation.data]);
|
|
7546
|
-
|
|
7559
|
+
useEffect26(() => {
|
|
7547
7560
|
if (mutation.status === "error" && mutation.error) {
|
|
7548
7561
|
onError?.(mutation.error);
|
|
7549
7562
|
}
|
|
@@ -7553,7 +7566,7 @@ function CreateGameSheet({
|
|
|
7553
7566
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
7554
7567
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
7555
7568
|
const canCreate = selectedTeam !== null && !isMutating && mutation.status !== "success";
|
|
7556
|
-
const handleCreate =
|
|
7569
|
+
const handleCreate = useCallback34(async () => {
|
|
7557
7570
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
7558
7571
|
try {
|
|
7559
7572
|
await mutation.execute({
|
|
@@ -7701,7 +7714,7 @@ var styles20 = StyleSheet21.create({
|
|
|
7701
7714
|
});
|
|
7702
7715
|
|
|
7703
7716
|
// src/ui/jackpot/JackpotCard.tsx
|
|
7704
|
-
import { useEffect as
|
|
7717
|
+
import { useEffect as useEffect27, useRef as useRef15 } from "react";
|
|
7705
7718
|
import {
|
|
7706
7719
|
View as View21,
|
|
7707
7720
|
Text as Text22,
|
|
@@ -7726,7 +7739,7 @@ function truncateWallet2(addr) {
|
|
|
7726
7739
|
function JackpotCard({ round, lastWinner, entries, onPress, style }) {
|
|
7727
7740
|
const shimmerAnim = useRef15(new Animated9.Value(-1)).current;
|
|
7728
7741
|
const pulseAnim = useRef15(new Animated9.Value(0.4)).current;
|
|
7729
|
-
|
|
7742
|
+
useEffect27(() => {
|
|
7730
7743
|
const shimmer = Animated9.loop(
|
|
7731
7744
|
Animated9.sequence([
|
|
7732
7745
|
Animated9.timing(shimmerAnim, { toValue: 1, duration: 4e3, useNativeDriver: true }),
|
|
@@ -8085,7 +8098,7 @@ var styles21 = StyleSheet22.create({
|
|
|
8085
8098
|
});
|
|
8086
8099
|
|
|
8087
8100
|
// src/ui/jackpot/JackpotSheet.tsx
|
|
8088
|
-
import { useState as
|
|
8101
|
+
import { useState as useState40, useEffect as useEffect28, useRef as useRef16, useCallback as useCallback35 } from "react";
|
|
8089
8102
|
import {
|
|
8090
8103
|
View as View22,
|
|
8091
8104
|
Text as Text23,
|
|
@@ -8132,17 +8145,17 @@ function JackpotSheet({
|
|
|
8132
8145
|
const { wallet, client } = useDubs();
|
|
8133
8146
|
const { round, lastWinner, refetch } = useJackpot();
|
|
8134
8147
|
const mutation = useEnterJackpot();
|
|
8135
|
-
const [betAmount, setBetAmount] =
|
|
8136
|
-
const [entries, setEntries] =
|
|
8148
|
+
const [betAmount, setBetAmount] = useState40("0.1");
|
|
8149
|
+
const [entries, setEntries] = useState40([]);
|
|
8137
8150
|
const overlayOpacity = useRef16(new Animated10.Value(0)).current;
|
|
8138
|
-
|
|
8151
|
+
useEffect28(() => {
|
|
8139
8152
|
Animated10.timing(overlayOpacity, {
|
|
8140
8153
|
toValue: visible ? 1 : 0,
|
|
8141
8154
|
duration: 250,
|
|
8142
8155
|
useNativeDriver: true
|
|
8143
8156
|
}).start();
|
|
8144
8157
|
}, [visible, overlayOpacity]);
|
|
8145
|
-
|
|
8158
|
+
useEffect28(() => {
|
|
8146
8159
|
if (visible) {
|
|
8147
8160
|
mutation.reset();
|
|
8148
8161
|
setBetAmount("0.1");
|
|
@@ -8151,7 +8164,7 @@ function JackpotSheet({
|
|
|
8151
8164
|
});
|
|
8152
8165
|
}
|
|
8153
8166
|
}, [visible]);
|
|
8154
|
-
|
|
8167
|
+
useEffect28(() => {
|
|
8155
8168
|
if (mutation.status === "success" && mutation.data) {
|
|
8156
8169
|
onSuccess?.(mutation.data);
|
|
8157
8170
|
refetch();
|
|
@@ -8161,7 +8174,7 @@ function JackpotSheet({
|
|
|
8161
8174
|
return () => clearTimeout(timer);
|
|
8162
8175
|
}
|
|
8163
8176
|
}, [mutation.status, mutation.data]);
|
|
8164
|
-
|
|
8177
|
+
useEffect28(() => {
|
|
8165
8178
|
if (mutation.status === "error" && mutation.error) {
|
|
8166
8179
|
onError?.(mutation.error);
|
|
8167
8180
|
}
|
|
@@ -8173,14 +8186,14 @@ function JackpotSheet({
|
|
|
8173
8186
|
const userOdds = totalWeight > 0 ? (entryLamports / (totalWeight + entryLamports) * 100).toFixed(1) : entries.length === 0 ? "100.0" : "0.0";
|
|
8174
8187
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
8175
8188
|
const canEnter = !isMutating && mutation.status !== "success" && round?.status === "Open" && betSol >= minEntry;
|
|
8176
|
-
const handleQuickAdd =
|
|
8189
|
+
const handleQuickAdd = useCallback35((amount) => {
|
|
8177
8190
|
setBetAmount((prev) => {
|
|
8178
8191
|
const current = parseFloat(prev) || 0;
|
|
8179
8192
|
const next = Math.min(current + amount, maxEntry);
|
|
8180
8193
|
return next.toFixed(2);
|
|
8181
8194
|
});
|
|
8182
8195
|
}, [maxEntry]);
|
|
8183
|
-
const handleEnter =
|
|
8196
|
+
const handleEnter = useCallback35(async () => {
|
|
8184
8197
|
if (!wallet.publicKey || entryLamports < 1e4) return;
|
|
8185
8198
|
try {
|
|
8186
8199
|
await mutation.execute(entryLamports);
|
|
@@ -8699,7 +8712,7 @@ var styles22 = StyleSheet23.create({
|
|
|
8699
8712
|
});
|
|
8700
8713
|
|
|
8701
8714
|
// src/ui/jackpot/JackpotWidget.tsx
|
|
8702
|
-
import { useState as
|
|
8715
|
+
import { useState as useState41, useEffect as useEffect29 } from "react";
|
|
8703
8716
|
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
8704
8717
|
function JackpotWidget({
|
|
8705
8718
|
style,
|
|
@@ -8708,11 +8721,11 @@ function JackpotWidget({
|
|
|
8708
8721
|
onEntry,
|
|
8709
8722
|
onError
|
|
8710
8723
|
}) {
|
|
8711
|
-
const [sheetVisible, setSheetVisible] =
|
|
8724
|
+
const [sheetVisible, setSheetVisible] = useState41(false);
|
|
8712
8725
|
const { round, lastWinner } = useJackpot();
|
|
8713
8726
|
const { client } = useDubs();
|
|
8714
|
-
const [entries, setEntries] =
|
|
8715
|
-
|
|
8727
|
+
const [entries, setEntries] = useState41([]);
|
|
8728
|
+
useEffect29(() => {
|
|
8716
8729
|
client.getJackpotEntries().then((res) => setEntries(res.entries)).catch(() => {
|
|
8717
8730
|
});
|
|
8718
8731
|
}, [client, round?.entryCount]);
|
|
@@ -8746,7 +8759,7 @@ function JackpotWidget({
|
|
|
8746
8759
|
}
|
|
8747
8760
|
|
|
8748
8761
|
// src/chat/provider.tsx
|
|
8749
|
-
import { createContext as createContext5, useContext as useContext5, useEffect as
|
|
8762
|
+
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
8763
|
import { AppState } from "react-native";
|
|
8751
8764
|
|
|
8752
8765
|
// src/chat/socket.ts
|
|
@@ -8860,18 +8873,18 @@ var ChatContext = createContext5(null);
|
|
|
8860
8873
|
function ChatProvider({ children, autoConnect = true }) {
|
|
8861
8874
|
const { client } = useDubs();
|
|
8862
8875
|
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 =
|
|
8876
|
+
const [status, setStatus] = useState42("disconnected");
|
|
8877
|
+
const [messages, setMessages] = useState42([]);
|
|
8878
|
+
const [onlineUsers, setOnlineUsers] = useState42([]);
|
|
8879
|
+
const [onlineCount, setOnlineCount] = useState42(0);
|
|
8880
|
+
const [unreadCount, setUnreadCount] = useState42(0);
|
|
8881
|
+
const [conversations, setConversations] = useState42([]);
|
|
8882
|
+
const [friends, setFriends] = useState42([]);
|
|
8883
|
+
const [pendingRequests, setPendingRequests] = useState42([]);
|
|
8884
|
+
const [sentFriendRequests, setSentFriendRequests] = useState42([]);
|
|
8885
|
+
const [whatsNewPosts, setWhatsNewPosts] = useState42([]);
|
|
8886
|
+
const [whatsNewUnreadCount, setWhatsNewUnreadCount] = useState42(0);
|
|
8887
|
+
const refreshMessages = useCallback36(async () => {
|
|
8875
8888
|
try {
|
|
8876
8889
|
const res = await client.getChatMessages({ limit: 30 });
|
|
8877
8890
|
setMessages([...res.messages].reverse());
|
|
@@ -8879,35 +8892,35 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8879
8892
|
console.error("[Dubs:ChatProvider] Failed to load messages:", err);
|
|
8880
8893
|
}
|
|
8881
8894
|
}, [client]);
|
|
8882
|
-
const refreshConversations =
|
|
8895
|
+
const refreshConversations = useCallback36(async () => {
|
|
8883
8896
|
try {
|
|
8884
8897
|
const res = await client.getConversations();
|
|
8885
8898
|
setConversations(res.conversations);
|
|
8886
8899
|
} catch (_) {
|
|
8887
8900
|
}
|
|
8888
8901
|
}, [client]);
|
|
8889
|
-
const refreshFriends =
|
|
8902
|
+
const refreshFriends = useCallback36(async () => {
|
|
8890
8903
|
try {
|
|
8891
8904
|
const res = await client.getFriends();
|
|
8892
8905
|
setFriends(res.friends);
|
|
8893
8906
|
} catch (_) {
|
|
8894
8907
|
}
|
|
8895
8908
|
}, [client]);
|
|
8896
|
-
const refreshPendingRequests =
|
|
8909
|
+
const refreshPendingRequests = useCallback36(async () => {
|
|
8897
8910
|
try {
|
|
8898
8911
|
const res = await client.getPendingFriendRequests();
|
|
8899
8912
|
setPendingRequests(res.requests);
|
|
8900
8913
|
} catch (_) {
|
|
8901
8914
|
}
|
|
8902
8915
|
}, [client]);
|
|
8903
|
-
const refreshSentFriendRequests =
|
|
8916
|
+
const refreshSentFriendRequests = useCallback36(async () => {
|
|
8904
8917
|
try {
|
|
8905
8918
|
const res = await client.getSentFriendRequests();
|
|
8906
8919
|
setSentFriendRequests(res.requests);
|
|
8907
8920
|
} catch (_) {
|
|
8908
8921
|
}
|
|
8909
8922
|
}, [client]);
|
|
8910
|
-
const refreshWhatsNew =
|
|
8923
|
+
const refreshWhatsNew = useCallback36(async () => {
|
|
8911
8924
|
try {
|
|
8912
8925
|
const res = await client.getWhatsNewPosts();
|
|
8913
8926
|
setWhatsNewPosts(res.posts);
|
|
@@ -8916,7 +8929,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8916
8929
|
} catch (_) {
|
|
8917
8930
|
}
|
|
8918
8931
|
}, [client]);
|
|
8919
|
-
|
|
8932
|
+
useEffect30(() => {
|
|
8920
8933
|
const token = client.getToken();
|
|
8921
8934
|
if (!autoConnect || !token) return;
|
|
8922
8935
|
const chatSocket = socketRef.current;
|
|
@@ -8994,7 +9007,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8994
9007
|
chatSocket.disconnect();
|
|
8995
9008
|
};
|
|
8996
9009
|
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8997
|
-
|
|
9010
|
+
useEffect30(() => {
|
|
8998
9011
|
const handleAppState = (nextState) => {
|
|
8999
9012
|
if (nextState === "active") {
|
|
9000
9013
|
const chatSocket = socketRef.current;
|
|
@@ -9056,14 +9069,14 @@ function useChatContext() {
|
|
|
9056
9069
|
}
|
|
9057
9070
|
|
|
9058
9071
|
// src/chat/hooks.ts
|
|
9059
|
-
import { useState as
|
|
9072
|
+
import { useState as useState43, useCallback as useCallback37, useEffect as useEffect31, useRef as useRef18 } from "react";
|
|
9060
9073
|
function useChatStatus() {
|
|
9061
9074
|
return useChatContext().status;
|
|
9062
9075
|
}
|
|
9063
9076
|
function useChatMessages() {
|
|
9064
9077
|
const { messages, refreshMessages } = useChatContext();
|
|
9065
|
-
const [loading, setLoading] =
|
|
9066
|
-
const refetch =
|
|
9078
|
+
const [loading, setLoading] = useState43(false);
|
|
9079
|
+
const refetch = useCallback37(async () => {
|
|
9067
9080
|
setLoading(true);
|
|
9068
9081
|
await refreshMessages();
|
|
9069
9082
|
setLoading(false);
|
|
@@ -9073,13 +9086,13 @@ function useChatMessages() {
|
|
|
9073
9086
|
function useSendMessage() {
|
|
9074
9087
|
const { socket } = useChatContext();
|
|
9075
9088
|
const { client } = useDubs();
|
|
9076
|
-
const send =
|
|
9089
|
+
const send = useCallback37(
|
|
9077
9090
|
(params) => {
|
|
9078
9091
|
socket.sendMessage(params);
|
|
9079
9092
|
},
|
|
9080
9093
|
[socket]
|
|
9081
9094
|
);
|
|
9082
|
-
const sendViaREST =
|
|
9095
|
+
const sendViaREST = useCallback37(
|
|
9083
9096
|
async (params) => {
|
|
9084
9097
|
await client.sendChatMessage(params);
|
|
9085
9098
|
},
|
|
@@ -9096,8 +9109,8 @@ function useUnreadCount() {
|
|
|
9096
9109
|
}
|
|
9097
9110
|
function useConversations() {
|
|
9098
9111
|
const { conversations, refreshConversations } = useChatContext();
|
|
9099
|
-
const [loading, setLoading] =
|
|
9100
|
-
const refetch =
|
|
9112
|
+
const [loading, setLoading] = useState43(false);
|
|
9113
|
+
const refetch = useCallback37(async () => {
|
|
9101
9114
|
setLoading(true);
|
|
9102
9115
|
await refreshConversations();
|
|
9103
9116
|
setLoading(false);
|
|
@@ -9107,10 +9120,10 @@ function useConversations() {
|
|
|
9107
9120
|
function useDirectMessages(recipientWallet) {
|
|
9108
9121
|
const { client } = useDubs();
|
|
9109
9122
|
const { socket, refreshConversations } = useChatContext();
|
|
9110
|
-
const [messages, setMessages] =
|
|
9111
|
-
const [otherUser, setOtherUser] =
|
|
9112
|
-
const [loading, setLoading] =
|
|
9113
|
-
const refetch =
|
|
9123
|
+
const [messages, setMessages] = useState43([]);
|
|
9124
|
+
const [otherUser, setOtherUser] = useState43(null);
|
|
9125
|
+
const [loading, setLoading] = useState43(true);
|
|
9126
|
+
const refetch = useCallback37(async () => {
|
|
9114
9127
|
try {
|
|
9115
9128
|
setLoading(true);
|
|
9116
9129
|
const res = await client.getConversation(recipientWallet);
|
|
@@ -9122,7 +9135,7 @@ function useDirectMessages(recipientWallet) {
|
|
|
9122
9135
|
setLoading(false);
|
|
9123
9136
|
}
|
|
9124
9137
|
}, [client, recipientWallet]);
|
|
9125
|
-
|
|
9138
|
+
useEffect31(() => {
|
|
9126
9139
|
refetch();
|
|
9127
9140
|
socket.joinDM(recipientWallet);
|
|
9128
9141
|
return () => {
|
|
@@ -9131,7 +9144,7 @@ function useDirectMessages(recipientWallet) {
|
|
|
9131
9144
|
}, [recipientWallet, refetch, socket]);
|
|
9132
9145
|
const socketRef = useRef18(socket);
|
|
9133
9146
|
socketRef.current = socket;
|
|
9134
|
-
|
|
9147
|
+
useEffect31(() => {
|
|
9135
9148
|
const currentSocket = socketRef.current;
|
|
9136
9149
|
const prevListeners = currentSocket.listeners;
|
|
9137
9150
|
const originalOnDMNew = prevListeners?.onDMNewMessage;
|
|
@@ -9154,13 +9167,13 @@ function useDirectMessages(recipientWallet) {
|
|
|
9154
9167
|
}
|
|
9155
9168
|
});
|
|
9156
9169
|
}, [recipientWallet]);
|
|
9157
|
-
const send =
|
|
9170
|
+
const send = useCallback37(
|
|
9158
9171
|
(message) => {
|
|
9159
9172
|
socket.sendDM({ recipientWallet, message });
|
|
9160
9173
|
},
|
|
9161
9174
|
[socket, recipientWallet]
|
|
9162
9175
|
);
|
|
9163
|
-
const sendViaREST =
|
|
9176
|
+
const sendViaREST = useCallback37(
|
|
9164
9177
|
async (message) => {
|
|
9165
9178
|
await client.sendDirectMessage({ recipientWallet, message });
|
|
9166
9179
|
await refetch();
|
|
@@ -9168,15 +9181,15 @@ function useDirectMessages(recipientWallet) {
|
|
|
9168
9181
|
},
|
|
9169
9182
|
[client, recipientWallet, refetch, refreshConversations]
|
|
9170
9183
|
);
|
|
9171
|
-
const markRead =
|
|
9184
|
+
const markRead = useCallback37(() => {
|
|
9172
9185
|
socket.markDMRead(recipientWallet);
|
|
9173
9186
|
}, [socket, recipientWallet]);
|
|
9174
9187
|
return { messages, loading, otherUser, send, sendViaREST, markRead, refetch };
|
|
9175
9188
|
}
|
|
9176
9189
|
function useFriends() {
|
|
9177
9190
|
const { friends, refreshFriends } = useChatContext();
|
|
9178
|
-
const [loading, setLoading] =
|
|
9179
|
-
const refetch =
|
|
9191
|
+
const [loading, setLoading] = useState43(false);
|
|
9192
|
+
const refetch = useCallback37(async () => {
|
|
9180
9193
|
setLoading(true);
|
|
9181
9194
|
await refreshFriends();
|
|
9182
9195
|
setLoading(false);
|
|
@@ -9185,8 +9198,8 @@ function useFriends() {
|
|
|
9185
9198
|
}
|
|
9186
9199
|
function useFriendRequests() {
|
|
9187
9200
|
const { pendingRequests, refreshPendingRequests } = useChatContext();
|
|
9188
|
-
const [loading, setLoading] =
|
|
9189
|
-
const refetch =
|
|
9201
|
+
const [loading, setLoading] = useState43(false);
|
|
9202
|
+
const refetch = useCallback37(async () => {
|
|
9190
9203
|
setLoading(true);
|
|
9191
9204
|
await refreshPendingRequests();
|
|
9192
9205
|
setLoading(false);
|
|
@@ -9195,8 +9208,8 @@ function useFriendRequests() {
|
|
|
9195
9208
|
}
|
|
9196
9209
|
function useSentFriendRequests() {
|
|
9197
9210
|
const { sentFriendRequests, refreshSentFriendRequests } = useChatContext();
|
|
9198
|
-
const [loading, setLoading] =
|
|
9199
|
-
const refetch =
|
|
9211
|
+
const [loading, setLoading] = useState43(false);
|
|
9212
|
+
const refetch = useCallback37(async () => {
|
|
9200
9213
|
setLoading(true);
|
|
9201
9214
|
await refreshSentFriendRequests();
|
|
9202
9215
|
setLoading(false);
|
|
@@ -9206,8 +9219,8 @@ function useSentFriendRequests() {
|
|
|
9206
9219
|
function useCancelFriendRequest() {
|
|
9207
9220
|
const { client } = useDubs();
|
|
9208
9221
|
const { refreshSentFriendRequests } = useChatContext();
|
|
9209
|
-
const [loading, setLoading] =
|
|
9210
|
-
const cancel =
|
|
9222
|
+
const [loading, setLoading] = useState43(false);
|
|
9223
|
+
const cancel = useCallback37(
|
|
9211
9224
|
async (requestId) => {
|
|
9212
9225
|
setLoading(true);
|
|
9213
9226
|
try {
|
|
@@ -9223,9 +9236,9 @@ function useCancelFriendRequest() {
|
|
|
9223
9236
|
}
|
|
9224
9237
|
function useSearchUsers() {
|
|
9225
9238
|
const { client } = useDubs();
|
|
9226
|
-
const [results, setResults] =
|
|
9227
|
-
const [loading, setLoading] =
|
|
9228
|
-
const search =
|
|
9239
|
+
const [results, setResults] = useState43([]);
|
|
9240
|
+
const [loading, setLoading] = useState43(false);
|
|
9241
|
+
const search = useCallback37(
|
|
9229
9242
|
async (query) => {
|
|
9230
9243
|
setLoading(true);
|
|
9231
9244
|
try {
|
|
@@ -9239,14 +9252,14 @@ function useSearchUsers() {
|
|
|
9239
9252
|
},
|
|
9240
9253
|
[client]
|
|
9241
9254
|
);
|
|
9242
|
-
const clear =
|
|
9255
|
+
const clear = useCallback37(() => setResults([]), []);
|
|
9243
9256
|
return { results, loading, search, clear };
|
|
9244
9257
|
}
|
|
9245
9258
|
function useSendFriendRequest() {
|
|
9246
9259
|
const { client } = useDubs();
|
|
9247
9260
|
const { refreshPendingRequests } = useChatContext();
|
|
9248
|
-
const [loading, setLoading] =
|
|
9249
|
-
const send =
|
|
9261
|
+
const [loading, setLoading] = useState43(false);
|
|
9262
|
+
const send = useCallback37(
|
|
9250
9263
|
async (targetUserId) => {
|
|
9251
9264
|
setLoading(true);
|
|
9252
9265
|
try {
|
|
@@ -9262,8 +9275,8 @@ function useSendFriendRequest() {
|
|
|
9262
9275
|
function useRespondToFriendRequest() {
|
|
9263
9276
|
const { client } = useDubs();
|
|
9264
9277
|
const { refreshFriends, refreshPendingRequests } = useChatContext();
|
|
9265
|
-
const [loading, setLoading] =
|
|
9266
|
-
const accept =
|
|
9278
|
+
const [loading, setLoading] = useState43(false);
|
|
9279
|
+
const accept = useCallback37(
|
|
9267
9280
|
async (requestId) => {
|
|
9268
9281
|
setLoading(true);
|
|
9269
9282
|
try {
|
|
@@ -9275,7 +9288,7 @@ function useRespondToFriendRequest() {
|
|
|
9275
9288
|
},
|
|
9276
9289
|
[client, refreshFriends, refreshPendingRequests]
|
|
9277
9290
|
);
|
|
9278
|
-
const reject =
|
|
9291
|
+
const reject = useCallback37(
|
|
9279
9292
|
async (requestId) => {
|
|
9280
9293
|
setLoading(true);
|
|
9281
9294
|
try {
|
|
@@ -9292,8 +9305,8 @@ function useRespondToFriendRequest() {
|
|
|
9292
9305
|
function useWhatsNew() {
|
|
9293
9306
|
const { client } = useDubs();
|
|
9294
9307
|
const { whatsNewPosts, whatsNewUnreadCount, refreshWhatsNew } = useChatContext();
|
|
9295
|
-
const [loading, setLoading] =
|
|
9296
|
-
const refetch =
|
|
9308
|
+
const [loading, setLoading] = useState43(false);
|
|
9309
|
+
const refetch = useCallback37(async () => {
|
|
9297
9310
|
setLoading(true);
|
|
9298
9311
|
try {
|
|
9299
9312
|
await refreshWhatsNew();
|
|
@@ -9301,7 +9314,7 @@ function useWhatsNew() {
|
|
|
9301
9314
|
setLoading(false);
|
|
9302
9315
|
}
|
|
9303
9316
|
}, [refreshWhatsNew]);
|
|
9304
|
-
const markRead =
|
|
9317
|
+
const markRead = useCallback37(
|
|
9305
9318
|
async (postIds) => {
|
|
9306
9319
|
if (postIds.length === 0) return;
|
|
9307
9320
|
try {
|
|
@@ -9313,7 +9326,7 @@ function useWhatsNew() {
|
|
|
9313
9326
|
},
|
|
9314
9327
|
[client, refreshWhatsNew]
|
|
9315
9328
|
);
|
|
9316
|
-
const markAllRead =
|
|
9329
|
+
const markAllRead = useCallback37(async () => {
|
|
9317
9330
|
try {
|
|
9318
9331
|
await client.markAllWhatsNewRead();
|
|
9319
9332
|
await refreshWhatsNew();
|