@dubsdotapp/expo 0.2.43 → 0.2.45
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 +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +123 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +11 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUFCFightCard.ts +29 -0
- package/src/index.ts +5 -0
- package/src/types.ts +36 -0
package/dist/index.mjs
CHANGED
|
@@ -212,6 +212,14 @@ var DubsClient = class {
|
|
|
212
212
|
);
|
|
213
213
|
return res.match;
|
|
214
214
|
}
|
|
215
|
+
// ── UFC ──
|
|
216
|
+
async getUFCFightCard() {
|
|
217
|
+
const res = await this.request(
|
|
218
|
+
"GET",
|
|
219
|
+
"/ufc/fightcard"
|
|
220
|
+
);
|
|
221
|
+
return res.events;
|
|
222
|
+
}
|
|
215
223
|
// ── Game Lifecycle ──
|
|
216
224
|
async validateEvent(id) {
|
|
217
225
|
const res = await this.request(
|
|
@@ -504,7 +512,7 @@ function createSecureStoreStorage() {
|
|
|
504
512
|
}
|
|
505
513
|
|
|
506
514
|
// src/provider.tsx
|
|
507
|
-
import { createContext as createContext4, useContext as useContext4, useMemo, useCallback as
|
|
515
|
+
import { createContext as createContext4, useContext as useContext4, useMemo, useCallback as useCallback13, useState as useState14, useEffect as useEffect9 } from "react";
|
|
508
516
|
|
|
509
517
|
// src/ui/theme.ts
|
|
510
518
|
import { createContext, useContext } from "react";
|
|
@@ -1545,7 +1553,7 @@ function ManagedWalletProvider({
|
|
|
1545
1553
|
}
|
|
1546
1554
|
|
|
1547
1555
|
// src/ui/AuthGate.tsx
|
|
1548
|
-
import React2, { useState as
|
|
1556
|
+
import React2, { useState as useState13, useEffect as useEffect8, useRef as useRef3, useCallback as useCallback12 } from "react";
|
|
1549
1557
|
import {
|
|
1550
1558
|
View as View2,
|
|
1551
1559
|
Text as Text2,
|
|
@@ -2169,6 +2177,31 @@ function useAuth() {
|
|
|
2169
2177
|
};
|
|
2170
2178
|
}
|
|
2171
2179
|
|
|
2180
|
+
// src/hooks/useUFCFightCard.ts
|
|
2181
|
+
import { useState as useState12, useEffect as useEffect7, useCallback as useCallback11 } from "react";
|
|
2182
|
+
function useUFCFightCard() {
|
|
2183
|
+
const { client } = useDubs();
|
|
2184
|
+
const [data, setData] = useState12(null);
|
|
2185
|
+
const [loading, setLoading] = useState12(true);
|
|
2186
|
+
const [error, setError] = useState12(null);
|
|
2187
|
+
const fetchData = useCallback11(async () => {
|
|
2188
|
+
setLoading(true);
|
|
2189
|
+
setError(null);
|
|
2190
|
+
try {
|
|
2191
|
+
const result = await client.getUFCFightCard();
|
|
2192
|
+
setData(result);
|
|
2193
|
+
} catch (err) {
|
|
2194
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
2195
|
+
} finally {
|
|
2196
|
+
setLoading(false);
|
|
2197
|
+
}
|
|
2198
|
+
}, [client]);
|
|
2199
|
+
useEffect7(() => {
|
|
2200
|
+
fetchData();
|
|
2201
|
+
}, [fetchData]);
|
|
2202
|
+
return { data, loading, error, refetch: fetchData };
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2172
2205
|
// src/ui/AuthGate.tsx
|
|
2173
2206
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2174
2207
|
var DICEBEAR_STYLES = [
|
|
@@ -2197,9 +2230,9 @@ function AuthGate({
|
|
|
2197
2230
|
}) {
|
|
2198
2231
|
const { client } = useDubs();
|
|
2199
2232
|
const auth = useAuth();
|
|
2200
|
-
const [phase, setPhase] =
|
|
2201
|
-
const [registrationPhase, setRegistrationPhase] =
|
|
2202
|
-
|
|
2233
|
+
const [phase, setPhase] = useState13("init");
|
|
2234
|
+
const [registrationPhase, setRegistrationPhase] = useState13(false);
|
|
2235
|
+
useEffect8(() => {
|
|
2203
2236
|
let cancelled = false;
|
|
2204
2237
|
(async () => {
|
|
2205
2238
|
try {
|
|
@@ -2225,18 +2258,18 @@ function AuthGate({
|
|
|
2225
2258
|
cancelled = true;
|
|
2226
2259
|
};
|
|
2227
2260
|
}, []);
|
|
2228
|
-
|
|
2261
|
+
useEffect8(() => {
|
|
2229
2262
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
2230
2263
|
}, [auth.status]);
|
|
2231
|
-
|
|
2264
|
+
useEffect8(() => {
|
|
2232
2265
|
if (auth.token) onSaveToken(auth.token);
|
|
2233
2266
|
}, [auth.token]);
|
|
2234
|
-
const retry =
|
|
2267
|
+
const retry = useCallback12(() => {
|
|
2235
2268
|
setRegistrationPhase(false);
|
|
2236
2269
|
auth.reset();
|
|
2237
2270
|
auth.authenticate();
|
|
2238
2271
|
}, [auth]);
|
|
2239
|
-
const handleRegister =
|
|
2272
|
+
const handleRegister = useCallback12(
|
|
2240
2273
|
(username, referralCode, avatarUrl) => {
|
|
2241
2274
|
auth.register(username, referralCode, avatarUrl);
|
|
2242
2275
|
},
|
|
@@ -2339,19 +2372,19 @@ function DefaultRegistrationScreen({
|
|
|
2339
2372
|
}) {
|
|
2340
2373
|
const t = useDubsTheme();
|
|
2341
2374
|
const accent = accentColor || t.accent;
|
|
2342
|
-
const [step, setStep] =
|
|
2343
|
-
const [avatarSeed, setAvatarSeed] =
|
|
2344
|
-
const [avatarStyle, setAvatarStyle] =
|
|
2345
|
-
const [showStyles, setShowStyles] =
|
|
2346
|
-
const [username, setUsername] =
|
|
2347
|
-
const [referralCode, setReferralCode] =
|
|
2348
|
-
const [checking, setChecking] =
|
|
2349
|
-
const [availability, setAvailability] =
|
|
2375
|
+
const [step, setStep] = useState13(0);
|
|
2376
|
+
const [avatarSeed, setAvatarSeed] = useState13(generateSeed);
|
|
2377
|
+
const [avatarStyle, setAvatarStyle] = useState13("adventurer");
|
|
2378
|
+
const [showStyles, setShowStyles] = useState13(false);
|
|
2379
|
+
const [username, setUsername] = useState13("");
|
|
2380
|
+
const [referralCode, setReferralCode] = useState13("");
|
|
2381
|
+
const [checking, setChecking] = useState13(false);
|
|
2382
|
+
const [availability, setAvailability] = useState13(null);
|
|
2350
2383
|
const debounceRef = useRef3(null);
|
|
2351
2384
|
const fadeAnim = useRef3(new Animated.Value(1)).current;
|
|
2352
2385
|
const slideAnim = useRef3(new Animated.Value(0)).current;
|
|
2353
2386
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed);
|
|
2354
|
-
|
|
2387
|
+
useEffect8(() => {
|
|
2355
2388
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2356
2389
|
const trimmed = username.trim();
|
|
2357
2390
|
if (trimmed.length < 3) {
|
|
@@ -2374,7 +2407,7 @@ function DefaultRegistrationScreen({
|
|
|
2374
2407
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2375
2408
|
};
|
|
2376
2409
|
}, [username, client]);
|
|
2377
|
-
const animateToStep =
|
|
2410
|
+
const animateToStep = useCallback12((newStep) => {
|
|
2378
2411
|
const dir = newStep > step ? 1 : -1;
|
|
2379
2412
|
Keyboard.dismiss();
|
|
2380
2413
|
Animated.parallel([
|
|
@@ -2698,8 +2731,8 @@ function DubsProvider({
|
|
|
2698
2731
|
const client = useMemo(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
2699
2732
|
const connection = useMemo(() => new Connection2(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
|
|
2700
2733
|
const storage = useMemo(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
2701
|
-
const [uiConfig, setUiConfig] =
|
|
2702
|
-
|
|
2734
|
+
const [uiConfig, setUiConfig] = useState14(null);
|
|
2735
|
+
useEffect9(() => {
|
|
2703
2736
|
client.getAppConfig().then((config2) => {
|
|
2704
2737
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(config2));
|
|
2705
2738
|
setUiConfig(config2);
|
|
@@ -2780,7 +2813,7 @@ function ManagedInner({
|
|
|
2780
2813
|
children
|
|
2781
2814
|
}) {
|
|
2782
2815
|
const managedDisconnect = useDisconnect();
|
|
2783
|
-
const disconnect =
|
|
2816
|
+
const disconnect = useCallback13(async () => {
|
|
2784
2817
|
client.setToken(null);
|
|
2785
2818
|
await managedDisconnect?.();
|
|
2786
2819
|
}, [client, managedDisconnect]);
|
|
@@ -2820,7 +2853,7 @@ function ExternalWalletProvider({
|
|
|
2820
2853
|
uiConfig,
|
|
2821
2854
|
children
|
|
2822
2855
|
}) {
|
|
2823
|
-
const disconnect =
|
|
2856
|
+
const disconnect = useCallback13(async () => {
|
|
2824
2857
|
client.setToken(null);
|
|
2825
2858
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
2826
2859
|
});
|
|
@@ -3083,7 +3116,7 @@ var styles3 = StyleSheet4.create({
|
|
|
3083
3116
|
});
|
|
3084
3117
|
|
|
3085
3118
|
// src/ui/game/GamePoster.tsx
|
|
3086
|
-
import { useState as
|
|
3119
|
+
import { useState as useState15 } from "react";
|
|
3087
3120
|
import { StyleSheet as StyleSheet5, View as View5, Text as Text5 } from "react-native";
|
|
3088
3121
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3089
3122
|
function computeCountdown(lockTimestamp) {
|
|
@@ -3133,7 +3166,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
3133
3166
|
] });
|
|
3134
3167
|
}
|
|
3135
3168
|
function TeamLogoInternal({ url, size, Img }) {
|
|
3136
|
-
const [failed, setFailed] =
|
|
3169
|
+
const [failed, setFailed] = useState15(false);
|
|
3137
3170
|
if (!url || failed) {
|
|
3138
3171
|
return /* @__PURE__ */ jsx7(View5, { style: [styles4.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
3139
3172
|
}
|
|
@@ -3313,7 +3346,7 @@ var styles5 = StyleSheet6.create({
|
|
|
3313
3346
|
});
|
|
3314
3347
|
|
|
3315
3348
|
// src/ui/game/PickWinnerCard.tsx
|
|
3316
|
-
import { useState as
|
|
3349
|
+
import { useState as useState16, useMemo as useMemo4 } from "react";
|
|
3317
3350
|
import { StyleSheet as StyleSheet7, View as View7, Text as Text7, TouchableOpacity as TouchableOpacity4 } from "react-native";
|
|
3318
3351
|
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3319
3352
|
function PickWinnerCard({
|
|
@@ -3384,7 +3417,7 @@ function TeamOption({
|
|
|
3384
3417
|
ImageComponent,
|
|
3385
3418
|
t
|
|
3386
3419
|
}) {
|
|
3387
|
-
const [imgFailed, setImgFailed] =
|
|
3420
|
+
const [imgFailed, setImgFailed] = useState16(false);
|
|
3388
3421
|
const Img = ImageComponent || __require("react-native").Image;
|
|
3389
3422
|
const showImage = imageUrl && !imgFailed;
|
|
3390
3423
|
return /* @__PURE__ */ jsxs7(
|
|
@@ -3425,7 +3458,7 @@ var styles6 = StyleSheet7.create({
|
|
|
3425
3458
|
});
|
|
3426
3459
|
|
|
3427
3460
|
// src/ui/game/PlayersCard.tsx
|
|
3428
|
-
import { useState as
|
|
3461
|
+
import { useState as useState17 } from "react";
|
|
3429
3462
|
import { StyleSheet as StyleSheet8, View as View8, Text as Text8 } from "react-native";
|
|
3430
3463
|
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3431
3464
|
function truncateWallet(addr, chars) {
|
|
@@ -3474,7 +3507,7 @@ function BettorRow({
|
|
|
3474
3507
|
ImageComponent,
|
|
3475
3508
|
t
|
|
3476
3509
|
}) {
|
|
3477
|
-
const [imgFailed, setImgFailed] =
|
|
3510
|
+
const [imgFailed, setImgFailed] = useState17(false);
|
|
3478
3511
|
const Img = ImageComponent || __require("react-native").Image;
|
|
3479
3512
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
3480
3513
|
return /* @__PURE__ */ jsxs8(View8, { style: [styles7.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -3553,7 +3586,7 @@ var styles8 = StyleSheet9.create({
|
|
|
3553
3586
|
});
|
|
3554
3587
|
|
|
3555
3588
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
3556
|
-
import { useState as
|
|
3589
|
+
import { useState as useState18, useEffect as useEffect10, useRef as useRef4, useCallback as useCallback14 } from "react";
|
|
3557
3590
|
import {
|
|
3558
3591
|
View as View10,
|
|
3559
3592
|
Text as Text10,
|
|
@@ -3589,18 +3622,18 @@ function CreateCustomGameSheet({
|
|
|
3589
3622
|
const t = useDubsTheme();
|
|
3590
3623
|
const { wallet } = useDubs();
|
|
3591
3624
|
const mutation = useCreateCustomGame();
|
|
3592
|
-
const [selectedAmount, setSelectedAmount] =
|
|
3593
|
-
const [customAmount, setCustomAmount] =
|
|
3594
|
-
const [isCustom, setIsCustom] =
|
|
3625
|
+
const [selectedAmount, setSelectedAmount] = useState18(null);
|
|
3626
|
+
const [customAmount, setCustomAmount] = useState18("");
|
|
3627
|
+
const [isCustom, setIsCustom] = useState18(false);
|
|
3595
3628
|
const overlayOpacity = useRef4(new Animated2.Value(0)).current;
|
|
3596
|
-
|
|
3629
|
+
useEffect10(() => {
|
|
3597
3630
|
Animated2.timing(overlayOpacity, {
|
|
3598
3631
|
toValue: visible ? 1 : 0,
|
|
3599
3632
|
duration: 250,
|
|
3600
3633
|
useNativeDriver: true
|
|
3601
3634
|
}).start();
|
|
3602
3635
|
}, [visible, overlayOpacity]);
|
|
3603
|
-
|
|
3636
|
+
useEffect10(() => {
|
|
3604
3637
|
if (visible) {
|
|
3605
3638
|
setSelectedAmount(defaultAmount ?? null);
|
|
3606
3639
|
setCustomAmount("");
|
|
@@ -3608,7 +3641,7 @@ function CreateCustomGameSheet({
|
|
|
3608
3641
|
mutation.reset();
|
|
3609
3642
|
}
|
|
3610
3643
|
}, [visible]);
|
|
3611
|
-
|
|
3644
|
+
useEffect10(() => {
|
|
3612
3645
|
if (mutation.status === "success" && mutation.data) {
|
|
3613
3646
|
onSuccess?.(mutation.data);
|
|
3614
3647
|
const timer = setTimeout(() => {
|
|
@@ -3617,23 +3650,23 @@ function CreateCustomGameSheet({
|
|
|
3617
3650
|
return () => clearTimeout(timer);
|
|
3618
3651
|
}
|
|
3619
3652
|
}, [mutation.status, mutation.data]);
|
|
3620
|
-
|
|
3653
|
+
useEffect10(() => {
|
|
3621
3654
|
if (mutation.status === "error" && mutation.error) {
|
|
3622
3655
|
onError?.(mutation.error);
|
|
3623
3656
|
}
|
|
3624
3657
|
}, [mutation.status, mutation.error]);
|
|
3625
|
-
const handlePresetSelect =
|
|
3658
|
+
const handlePresetSelect = useCallback14((amount) => {
|
|
3626
3659
|
setSelectedAmount(amount);
|
|
3627
3660
|
setIsCustom(false);
|
|
3628
3661
|
setCustomAmount("");
|
|
3629
3662
|
onAmountChange?.(amount);
|
|
3630
3663
|
}, [onAmountChange]);
|
|
3631
|
-
const handleCustomSelect =
|
|
3664
|
+
const handleCustomSelect = useCallback14(() => {
|
|
3632
3665
|
setIsCustom(true);
|
|
3633
3666
|
setSelectedAmount(null);
|
|
3634
3667
|
onAmountChange?.(null);
|
|
3635
3668
|
}, [onAmountChange]);
|
|
3636
|
-
const handleCustomAmountChange =
|
|
3669
|
+
const handleCustomAmountChange = useCallback14((text) => {
|
|
3637
3670
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
3638
3671
|
setCustomAmount(cleaned);
|
|
3639
3672
|
const parsed = parseFloat(cleaned);
|
|
@@ -3647,7 +3680,7 @@ function CreateCustomGameSheet({
|
|
|
3647
3680
|
const winnerTakes = pot * (1 - fee / 100);
|
|
3648
3681
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
3649
3682
|
const canCreate = effectiveAmount !== null && effectiveAmount > 0 && !isMutating && mutation.status !== "success";
|
|
3650
|
-
const handleCreate =
|
|
3683
|
+
const handleCreate = useCallback14(async () => {
|
|
3651
3684
|
if (!effectiveAmount || !wallet.publicKey) return;
|
|
3652
3685
|
try {
|
|
3653
3686
|
await mutation.execute({
|
|
@@ -3916,7 +3949,7 @@ var styles9 = StyleSheet10.create({
|
|
|
3916
3949
|
});
|
|
3917
3950
|
|
|
3918
3951
|
// src/ui/game/JoinGameSheet.tsx
|
|
3919
|
-
import { useState as
|
|
3952
|
+
import { useState as useState19, useEffect as useEffect11, useRef as useRef5, useCallback as useCallback15, useMemo as useMemo6 } from "react";
|
|
3920
3953
|
import {
|
|
3921
3954
|
View as View11,
|
|
3922
3955
|
Text as Text11,
|
|
@@ -3951,22 +3984,22 @@ function JoinGameSheet({
|
|
|
3951
3984
|
const { wallet } = useDubs();
|
|
3952
3985
|
const mutation = useJoinGame();
|
|
3953
3986
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
3954
|
-
const [selectedTeam, setSelectedTeam] =
|
|
3987
|
+
const [selectedTeam, setSelectedTeam] = useState19(null);
|
|
3955
3988
|
const overlayOpacity = useRef5(new Animated3.Value(0)).current;
|
|
3956
|
-
|
|
3989
|
+
useEffect11(() => {
|
|
3957
3990
|
Animated3.timing(overlayOpacity, {
|
|
3958
3991
|
toValue: visible ? 1 : 0,
|
|
3959
3992
|
duration: 250,
|
|
3960
3993
|
useNativeDriver: true
|
|
3961
3994
|
}).start();
|
|
3962
3995
|
}, [visible, overlayOpacity]);
|
|
3963
|
-
|
|
3996
|
+
useEffect11(() => {
|
|
3964
3997
|
if (visible) {
|
|
3965
3998
|
setSelectedTeam(isCustomGame ? "away" : null);
|
|
3966
3999
|
mutation.reset();
|
|
3967
4000
|
}
|
|
3968
4001
|
}, [visible]);
|
|
3969
|
-
|
|
4002
|
+
useEffect11(() => {
|
|
3970
4003
|
if (mutation.status === "success" && mutation.data) {
|
|
3971
4004
|
onSuccess?.(mutation.data);
|
|
3972
4005
|
const timer = setTimeout(() => {
|
|
@@ -3975,7 +4008,7 @@ function JoinGameSheet({
|
|
|
3975
4008
|
return () => clearTimeout(timer);
|
|
3976
4009
|
}
|
|
3977
4010
|
}, [mutation.status, mutation.data]);
|
|
3978
|
-
|
|
4011
|
+
useEffect11(() => {
|
|
3979
4012
|
if (mutation.status === "error" && mutation.error) {
|
|
3980
4013
|
onError?.(mutation.error);
|
|
3981
4014
|
}
|
|
@@ -4005,7 +4038,7 @@ function JoinGameSheet({
|
|
|
4005
4038
|
}, [bettors, wallet.publicKey]);
|
|
4006
4039
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4007
4040
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
4008
|
-
const handleJoin =
|
|
4041
|
+
const handleJoin = useCallback15(async () => {
|
|
4009
4042
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
4010
4043
|
try {
|
|
4011
4044
|
await mutation.execute({
|
|
@@ -4134,7 +4167,7 @@ function TeamButton({
|
|
|
4134
4167
|
ImageComponent,
|
|
4135
4168
|
t
|
|
4136
4169
|
}) {
|
|
4137
|
-
const [imgFailed, setImgFailed] =
|
|
4170
|
+
const [imgFailed, setImgFailed] = useState19(false);
|
|
4138
4171
|
const Img = ImageComponent || __require("react-native").Image;
|
|
4139
4172
|
const showImage = imageUrl && !imgFailed;
|
|
4140
4173
|
return /* @__PURE__ */ jsxs11(
|
|
@@ -4311,7 +4344,7 @@ var styles10 = StyleSheet11.create({
|
|
|
4311
4344
|
});
|
|
4312
4345
|
|
|
4313
4346
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
4314
|
-
import { useState as
|
|
4347
|
+
import { useState as useState20, useEffect as useEffect12, useRef as useRef6, useCallback as useCallback16 } from "react";
|
|
4315
4348
|
import {
|
|
4316
4349
|
View as View12,
|
|
4317
4350
|
Text as Text12,
|
|
@@ -4345,15 +4378,15 @@ function ClaimPrizeSheet({
|
|
|
4345
4378
|
const overlayOpacity = useRef6(new Animated4.Value(0)).current;
|
|
4346
4379
|
const celebrationScale = useRef6(new Animated4.Value(0)).current;
|
|
4347
4380
|
const celebrationOpacity = useRef6(new Animated4.Value(0)).current;
|
|
4348
|
-
const [showCelebration, setShowCelebration] =
|
|
4349
|
-
|
|
4381
|
+
const [showCelebration, setShowCelebration] = useState20(false);
|
|
4382
|
+
useEffect12(() => {
|
|
4350
4383
|
Animated4.timing(overlayOpacity, {
|
|
4351
4384
|
toValue: visible ? 1 : 0,
|
|
4352
4385
|
duration: 250,
|
|
4353
4386
|
useNativeDriver: true
|
|
4354
4387
|
}).start();
|
|
4355
4388
|
}, [visible, overlayOpacity]);
|
|
4356
|
-
|
|
4389
|
+
useEffect12(() => {
|
|
4357
4390
|
if (visible) {
|
|
4358
4391
|
mutation.reset();
|
|
4359
4392
|
setShowCelebration(false);
|
|
@@ -4361,7 +4394,7 @@ function ClaimPrizeSheet({
|
|
|
4361
4394
|
celebrationOpacity.setValue(0);
|
|
4362
4395
|
}
|
|
4363
4396
|
}, [visible]);
|
|
4364
|
-
|
|
4397
|
+
useEffect12(() => {
|
|
4365
4398
|
if (mutation.status === "success" && mutation.data) {
|
|
4366
4399
|
setShowCelebration(true);
|
|
4367
4400
|
Animated4.parallel([
|
|
@@ -4384,14 +4417,14 @@ function ClaimPrizeSheet({
|
|
|
4384
4417
|
return () => clearTimeout(timer);
|
|
4385
4418
|
}
|
|
4386
4419
|
}, [mutation.status, mutation.data]);
|
|
4387
|
-
|
|
4420
|
+
useEffect12(() => {
|
|
4388
4421
|
if (mutation.status === "error" && mutation.error) {
|
|
4389
4422
|
onError?.(mutation.error);
|
|
4390
4423
|
}
|
|
4391
4424
|
}, [mutation.status, mutation.error]);
|
|
4392
4425
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4393
4426
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
4394
|
-
const handleClaim =
|
|
4427
|
+
const handleClaim = useCallback16(async () => {
|
|
4395
4428
|
if (!wallet.publicKey) return;
|
|
4396
4429
|
try {
|
|
4397
4430
|
await mutation.execute({
|
|
@@ -4624,7 +4657,7 @@ var styles11 = StyleSheet12.create({
|
|
|
4624
4657
|
});
|
|
4625
4658
|
|
|
4626
4659
|
// src/ui/game/ClaimButton.tsx
|
|
4627
|
-
import { useState as
|
|
4660
|
+
import { useState as useState21, useMemo as useMemo7, useCallback as useCallback17 } from "react";
|
|
4628
4661
|
import { StyleSheet as StyleSheet13, Text as Text13, TouchableOpacity as TouchableOpacity9 } from "react-native";
|
|
4629
4662
|
import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4630
4663
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -4632,7 +4665,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
4632
4665
|
const { wallet } = useDubs();
|
|
4633
4666
|
const game = useGame(gameId);
|
|
4634
4667
|
const claimStatus = useHasClaimed(gameId);
|
|
4635
|
-
const [sheetVisible, setSheetVisible] =
|
|
4668
|
+
const [sheetVisible, setSheetVisible] = useState21(false);
|
|
4636
4669
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
4637
4670
|
const myBet = useMemo7(() => {
|
|
4638
4671
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
@@ -4643,7 +4676,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
4643
4676
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
4644
4677
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
4645
4678
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
4646
|
-
const handleSuccess =
|
|
4679
|
+
const handleSuccess = useCallback17(
|
|
4647
4680
|
(result) => {
|
|
4648
4681
|
claimStatus.refetch();
|
|
4649
4682
|
onSuccess?.(result);
|
|
@@ -4770,6 +4803,7 @@ export {
|
|
|
4770
4803
|
useGames,
|
|
4771
4804
|
useHasClaimed,
|
|
4772
4805
|
useJoinGame,
|
|
4773
|
-
useNetworkGames
|
|
4806
|
+
useNetworkGames,
|
|
4807
|
+
useUFCFightCard
|
|
4774
4808
|
};
|
|
4775
4809
|
//# sourceMappingURL=index.mjs.map
|