@dubsdotapp/expo 0.2.43 → 0.2.44
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 +32 -1
- package/dist/index.d.ts +32 -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 +34 -0
package/dist/index.js
CHANGED
|
@@ -71,7 +71,8 @@ __export(index_exports, {
|
|
|
71
71
|
useGames: () => useGames,
|
|
72
72
|
useHasClaimed: () => useHasClaimed,
|
|
73
73
|
useJoinGame: () => useJoinGame,
|
|
74
|
-
useNetworkGames: () => useNetworkGames
|
|
74
|
+
useNetworkGames: () => useNetworkGames,
|
|
75
|
+
useUFCFightCard: () => useUFCFightCard
|
|
75
76
|
});
|
|
76
77
|
module.exports = __toCommonJS(index_exports);
|
|
77
78
|
|
|
@@ -282,6 +283,14 @@ var DubsClient = class {
|
|
|
282
283
|
);
|
|
283
284
|
return res.match;
|
|
284
285
|
}
|
|
286
|
+
// ── UFC ──
|
|
287
|
+
async getUFCFightCard() {
|
|
288
|
+
const res = await this.request(
|
|
289
|
+
"GET",
|
|
290
|
+
"/ufc/fightcard"
|
|
291
|
+
);
|
|
292
|
+
return res.events;
|
|
293
|
+
}
|
|
285
294
|
// ── Game Lifecycle ──
|
|
286
295
|
async validateEvent(id) {
|
|
287
296
|
const res = await this.request(
|
|
@@ -574,7 +583,7 @@ function createSecureStoreStorage() {
|
|
|
574
583
|
}
|
|
575
584
|
|
|
576
585
|
// src/provider.tsx
|
|
577
|
-
var
|
|
586
|
+
var import_react16 = require("react");
|
|
578
587
|
|
|
579
588
|
// src/ui/theme.ts
|
|
580
589
|
var import_react = require("react");
|
|
@@ -1608,7 +1617,7 @@ function ManagedWalletProvider({
|
|
|
1608
1617
|
}
|
|
1609
1618
|
|
|
1610
1619
|
// src/ui/AuthGate.tsx
|
|
1611
|
-
var
|
|
1620
|
+
var import_react15 = __toESM(require("react"));
|
|
1612
1621
|
var import_react_native6 = require("react-native");
|
|
1613
1622
|
|
|
1614
1623
|
// src/hooks/useEvents.ts
|
|
@@ -2219,6 +2228,31 @@ function useAuth() {
|
|
|
2219
2228
|
};
|
|
2220
2229
|
}
|
|
2221
2230
|
|
|
2231
|
+
// src/hooks/useUFCFightCard.ts
|
|
2232
|
+
var import_react14 = require("react");
|
|
2233
|
+
function useUFCFightCard() {
|
|
2234
|
+
const { client } = useDubs();
|
|
2235
|
+
const [data, setData] = (0, import_react14.useState)(null);
|
|
2236
|
+
const [loading, setLoading] = (0, import_react14.useState)(true);
|
|
2237
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
2238
|
+
const fetchData = (0, import_react14.useCallback)(async () => {
|
|
2239
|
+
setLoading(true);
|
|
2240
|
+
setError(null);
|
|
2241
|
+
try {
|
|
2242
|
+
const result = await client.getUFCFightCard();
|
|
2243
|
+
setData(result);
|
|
2244
|
+
} catch (err) {
|
|
2245
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
2246
|
+
} finally {
|
|
2247
|
+
setLoading(false);
|
|
2248
|
+
}
|
|
2249
|
+
}, [client]);
|
|
2250
|
+
(0, import_react14.useEffect)(() => {
|
|
2251
|
+
fetchData();
|
|
2252
|
+
}, [fetchData]);
|
|
2253
|
+
return { data, loading, error, refetch: fetchData };
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2222
2256
|
// src/ui/AuthGate.tsx
|
|
2223
2257
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2224
2258
|
var DICEBEAR_STYLES = [
|
|
@@ -2247,9 +2281,9 @@ function AuthGate({
|
|
|
2247
2281
|
}) {
|
|
2248
2282
|
const { client } = useDubs();
|
|
2249
2283
|
const auth = useAuth();
|
|
2250
|
-
const [phase, setPhase] = (0,
|
|
2251
|
-
const [registrationPhase, setRegistrationPhase] = (0,
|
|
2252
|
-
(0,
|
|
2284
|
+
const [phase, setPhase] = (0, import_react15.useState)("init");
|
|
2285
|
+
const [registrationPhase, setRegistrationPhase] = (0, import_react15.useState)(false);
|
|
2286
|
+
(0, import_react15.useEffect)(() => {
|
|
2253
2287
|
let cancelled = false;
|
|
2254
2288
|
(async () => {
|
|
2255
2289
|
try {
|
|
@@ -2275,18 +2309,18 @@ function AuthGate({
|
|
|
2275
2309
|
cancelled = true;
|
|
2276
2310
|
};
|
|
2277
2311
|
}, []);
|
|
2278
|
-
(0,
|
|
2312
|
+
(0, import_react15.useEffect)(() => {
|
|
2279
2313
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
2280
2314
|
}, [auth.status]);
|
|
2281
|
-
(0,
|
|
2315
|
+
(0, import_react15.useEffect)(() => {
|
|
2282
2316
|
if (auth.token) onSaveToken(auth.token);
|
|
2283
2317
|
}, [auth.token]);
|
|
2284
|
-
const retry = (0,
|
|
2318
|
+
const retry = (0, import_react15.useCallback)(() => {
|
|
2285
2319
|
setRegistrationPhase(false);
|
|
2286
2320
|
auth.reset();
|
|
2287
2321
|
auth.authenticate();
|
|
2288
2322
|
}, [auth]);
|
|
2289
|
-
const handleRegister = (0,
|
|
2323
|
+
const handleRegister = (0, import_react15.useCallback)(
|
|
2290
2324
|
(username, referralCode, avatarUrl) => {
|
|
2291
2325
|
auth.register(username, referralCode, avatarUrl);
|
|
2292
2326
|
},
|
|
@@ -2365,7 +2399,7 @@ function DefaultErrorScreen({ error, onRetry, appName, accentColor }) {
|
|
|
2365
2399
|
function StepIndicator({ currentStep }) {
|
|
2366
2400
|
const t = useDubsTheme();
|
|
2367
2401
|
const steps = [0, 1, 2, 3];
|
|
2368
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react15.default.Fragment, { children: [
|
|
2369
2403
|
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [s.stepLine, { backgroundColor: i <= currentStep ? t.success : t.border }] }),
|
|
2370
2404
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2371
2405
|
import_react_native6.View,
|
|
@@ -2389,19 +2423,19 @@ function DefaultRegistrationScreen({
|
|
|
2389
2423
|
}) {
|
|
2390
2424
|
const t = useDubsTheme();
|
|
2391
2425
|
const accent = accentColor || t.accent;
|
|
2392
|
-
const [step, setStep] = (0,
|
|
2393
|
-
const [avatarSeed, setAvatarSeed] = (0,
|
|
2394
|
-
const [avatarStyle, setAvatarStyle] = (0,
|
|
2395
|
-
const [showStyles, setShowStyles] = (0,
|
|
2396
|
-
const [username, setUsername] = (0,
|
|
2397
|
-
const [referralCode, setReferralCode] = (0,
|
|
2398
|
-
const [checking, setChecking] = (0,
|
|
2399
|
-
const [availability, setAvailability] = (0,
|
|
2400
|
-
const debounceRef = (0,
|
|
2401
|
-
const fadeAnim = (0,
|
|
2402
|
-
const slideAnim = (0,
|
|
2426
|
+
const [step, setStep] = (0, import_react15.useState)(0);
|
|
2427
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react15.useState)(generateSeed);
|
|
2428
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react15.useState)("adventurer");
|
|
2429
|
+
const [showStyles, setShowStyles] = (0, import_react15.useState)(false);
|
|
2430
|
+
const [username, setUsername] = (0, import_react15.useState)("");
|
|
2431
|
+
const [referralCode, setReferralCode] = (0, import_react15.useState)("");
|
|
2432
|
+
const [checking, setChecking] = (0, import_react15.useState)(false);
|
|
2433
|
+
const [availability, setAvailability] = (0, import_react15.useState)(null);
|
|
2434
|
+
const debounceRef = (0, import_react15.useRef)(null);
|
|
2435
|
+
const fadeAnim = (0, import_react15.useRef)(new import_react_native6.Animated.Value(1)).current;
|
|
2436
|
+
const slideAnim = (0, import_react15.useRef)(new import_react_native6.Animated.Value(0)).current;
|
|
2403
2437
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed);
|
|
2404
|
-
(0,
|
|
2438
|
+
(0, import_react15.useEffect)(() => {
|
|
2405
2439
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2406
2440
|
const trimmed = username.trim();
|
|
2407
2441
|
if (trimmed.length < 3) {
|
|
@@ -2424,7 +2458,7 @@ function DefaultRegistrationScreen({
|
|
|
2424
2458
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2425
2459
|
};
|
|
2426
2460
|
}, [username, client]);
|
|
2427
|
-
const animateToStep = (0,
|
|
2461
|
+
const animateToStep = (0, import_react15.useCallback)((newStep) => {
|
|
2428
2462
|
const dir = newStep > step ? 1 : -1;
|
|
2429
2463
|
import_react_native6.Keyboard.dismiss();
|
|
2430
2464
|
import_react_native6.Animated.parallel([
|
|
@@ -2723,7 +2757,7 @@ var s = import_react_native6.StyleSheet.create({
|
|
|
2723
2757
|
|
|
2724
2758
|
// src/provider.tsx
|
|
2725
2759
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2726
|
-
var DubsContext = (0,
|
|
2760
|
+
var DubsContext = (0, import_react16.createContext)(null);
|
|
2727
2761
|
function DubsProvider({
|
|
2728
2762
|
apiKey,
|
|
2729
2763
|
children,
|
|
@@ -2745,11 +2779,11 @@ function DubsProvider({
|
|
|
2745
2779
|
const baseUrl = baseUrlOverride || config.baseUrl;
|
|
2746
2780
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
2747
2781
|
const cluster = config.cluster;
|
|
2748
|
-
const client = (0,
|
|
2749
|
-
const connection = (0,
|
|
2750
|
-
const storage = (0,
|
|
2751
|
-
const [uiConfig, setUiConfig] = (0,
|
|
2752
|
-
(0,
|
|
2782
|
+
const client = (0, import_react16.useMemo)(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
2783
|
+
const connection = (0, import_react16.useMemo)(() => new import_web34.Connection(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
|
|
2784
|
+
const storage = (0, import_react16.useMemo)(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
2785
|
+
const [uiConfig, setUiConfig] = (0, import_react16.useState)(null);
|
|
2786
|
+
(0, import_react16.useEffect)(() => {
|
|
2753
2787
|
client.getAppConfig().then((config2) => {
|
|
2754
2788
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(config2));
|
|
2755
2789
|
setUiConfig(config2);
|
|
@@ -2830,11 +2864,11 @@ function ManagedInner({
|
|
|
2830
2864
|
children
|
|
2831
2865
|
}) {
|
|
2832
2866
|
const managedDisconnect = useDisconnect();
|
|
2833
|
-
const disconnect = (0,
|
|
2867
|
+
const disconnect = (0, import_react16.useCallback)(async () => {
|
|
2834
2868
|
client.setToken(null);
|
|
2835
2869
|
await managedDisconnect?.();
|
|
2836
2870
|
}, [client, managedDisconnect]);
|
|
2837
|
-
const value = (0,
|
|
2871
|
+
const value = (0, import_react16.useMemo)(
|
|
2838
2872
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig }),
|
|
2839
2873
|
[client, wallet, connection, appName, network, disconnect, uiConfig]
|
|
2840
2874
|
);
|
|
@@ -2870,13 +2904,13 @@ function ExternalWalletProvider({
|
|
|
2870
2904
|
uiConfig,
|
|
2871
2905
|
children
|
|
2872
2906
|
}) {
|
|
2873
|
-
const disconnect = (0,
|
|
2907
|
+
const disconnect = (0, import_react16.useCallback)(async () => {
|
|
2874
2908
|
client.setToken(null);
|
|
2875
2909
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
2876
2910
|
});
|
|
2877
2911
|
await wallet.disconnect?.();
|
|
2878
2912
|
}, [client, storage, wallet]);
|
|
2879
|
-
const value = (0,
|
|
2913
|
+
const value = (0, import_react16.useMemo)(
|
|
2880
2914
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig }),
|
|
2881
2915
|
[client, wallet, connection, appName, network, disconnect, uiConfig]
|
|
2882
2916
|
);
|
|
@@ -2901,19 +2935,19 @@ function ExternalWalletProvider({
|
|
|
2901
2935
|
) });
|
|
2902
2936
|
}
|
|
2903
2937
|
function useDubs() {
|
|
2904
|
-
const ctx = (0,
|
|
2938
|
+
const ctx = (0, import_react16.useContext)(DubsContext);
|
|
2905
2939
|
if (!ctx) {
|
|
2906
2940
|
throw new Error("useDubs must be used within a <DubsProvider>");
|
|
2907
2941
|
}
|
|
2908
2942
|
return ctx;
|
|
2909
2943
|
}
|
|
2910
2944
|
function useAppConfig() {
|
|
2911
|
-
const ctx = (0,
|
|
2945
|
+
const ctx = (0, import_react16.useContext)(DubsContext);
|
|
2912
2946
|
return ctx?.uiConfig || {};
|
|
2913
2947
|
}
|
|
2914
2948
|
|
|
2915
2949
|
// src/ui/UserProfileCard.tsx
|
|
2916
|
-
var
|
|
2950
|
+
var import_react17 = require("react");
|
|
2917
2951
|
var import_react_native7 = require("react-native");
|
|
2918
2952
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2919
2953
|
function truncateAddress(address, chars = 4) {
|
|
@@ -2933,7 +2967,7 @@ function UserProfileCard({
|
|
|
2933
2967
|
memberSince
|
|
2934
2968
|
}) {
|
|
2935
2969
|
const t = useDubsTheme();
|
|
2936
|
-
const imageUri = (0,
|
|
2970
|
+
const imageUri = (0, import_react17.useMemo)(
|
|
2937
2971
|
() => avatarUrl || `https://api.dicebear.com/9.x/avataaars/png?seed=${walletAddress}&size=128`,
|
|
2938
2972
|
[avatarUrl, walletAddress]
|
|
2939
2973
|
);
|
|
@@ -3126,7 +3160,7 @@ var styles3 = import_react_native8.StyleSheet.create({
|
|
|
3126
3160
|
});
|
|
3127
3161
|
|
|
3128
3162
|
// src/ui/game/GamePoster.tsx
|
|
3129
|
-
var
|
|
3163
|
+
var import_react18 = require("react");
|
|
3130
3164
|
var import_react_native9 = require("react-native");
|
|
3131
3165
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3132
3166
|
function computeCountdown(lockTimestamp) {
|
|
@@ -3176,7 +3210,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
3176
3210
|
] });
|
|
3177
3211
|
}
|
|
3178
3212
|
function TeamLogoInternal({ url, size, Img }) {
|
|
3179
|
-
const [failed, setFailed] = (0,
|
|
3213
|
+
const [failed, setFailed] = (0, import_react18.useState)(false);
|
|
3180
3214
|
if (!url || failed) {
|
|
3181
3215
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native9.View, { style: [styles4.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
3182
3216
|
}
|
|
@@ -3277,7 +3311,7 @@ var styles4 = import_react_native9.StyleSheet.create({
|
|
|
3277
3311
|
});
|
|
3278
3312
|
|
|
3279
3313
|
// src/ui/game/LivePoolsCard.tsx
|
|
3280
|
-
var
|
|
3314
|
+
var import_react19 = require("react");
|
|
3281
3315
|
var import_react_native10 = require("react-native");
|
|
3282
3316
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3283
3317
|
function LivePoolsCard({
|
|
@@ -3293,7 +3327,7 @@ function LivePoolsCard({
|
|
|
3293
3327
|
const homePool = game.homePool || 0;
|
|
3294
3328
|
const awayPool = game.awayPool || 0;
|
|
3295
3329
|
const totalPool = game.totalPool || 0;
|
|
3296
|
-
const { homePercent, awayPercent, homeOdds, awayOdds } = (0,
|
|
3330
|
+
const { homePercent, awayPercent, homeOdds, awayOdds } = (0, import_react19.useMemo)(() => {
|
|
3297
3331
|
return {
|
|
3298
3332
|
homePercent: totalPool > 0 ? homePool / totalPool * 100 : 50,
|
|
3299
3333
|
awayPercent: totalPool > 0 ? awayPool / totalPool * 100 : 50,
|
|
@@ -3356,7 +3390,7 @@ var styles5 = import_react_native10.StyleSheet.create({
|
|
|
3356
3390
|
});
|
|
3357
3391
|
|
|
3358
3392
|
// src/ui/game/PickWinnerCard.tsx
|
|
3359
|
-
var
|
|
3393
|
+
var import_react20 = require("react");
|
|
3360
3394
|
var import_react_native11 = require("react-native");
|
|
3361
3395
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3362
3396
|
function PickWinnerCard({
|
|
@@ -3374,7 +3408,7 @@ function PickWinnerCard({
|
|
|
3374
3408
|
const totalPool = game.totalPool || 0;
|
|
3375
3409
|
const homePool = game.homePool || 0;
|
|
3376
3410
|
const awayPool = game.awayPool || 0;
|
|
3377
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
3411
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react20.useMemo)(() => ({
|
|
3378
3412
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
3379
3413
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
3380
3414
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -3427,7 +3461,7 @@ function TeamOption({
|
|
|
3427
3461
|
ImageComponent,
|
|
3428
3462
|
t
|
|
3429
3463
|
}) {
|
|
3430
|
-
const [imgFailed, setImgFailed] = (0,
|
|
3464
|
+
const [imgFailed, setImgFailed] = (0, import_react20.useState)(false);
|
|
3431
3465
|
const Img = ImageComponent || require("react-native").Image;
|
|
3432
3466
|
const showImage = imageUrl && !imgFailed;
|
|
3433
3467
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
@@ -3468,7 +3502,7 @@ var styles6 = import_react_native11.StyleSheet.create({
|
|
|
3468
3502
|
});
|
|
3469
3503
|
|
|
3470
3504
|
// src/ui/game/PlayersCard.tsx
|
|
3471
|
-
var
|
|
3505
|
+
var import_react21 = require("react");
|
|
3472
3506
|
var import_react_native12 = require("react-native");
|
|
3473
3507
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3474
3508
|
function truncateWallet(addr, chars) {
|
|
@@ -3517,7 +3551,7 @@ function BettorRow({
|
|
|
3517
3551
|
ImageComponent,
|
|
3518
3552
|
t
|
|
3519
3553
|
}) {
|
|
3520
|
-
const [imgFailed, setImgFailed] = (0,
|
|
3554
|
+
const [imgFailed, setImgFailed] = (0, import_react21.useState)(false);
|
|
3521
3555
|
const Img = ImageComponent || require("react-native").Image;
|
|
3522
3556
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
3523
3557
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native12.View, { style: [styles7.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -3544,7 +3578,7 @@ var styles7 = import_react_native12.StyleSheet.create({
|
|
|
3544
3578
|
});
|
|
3545
3579
|
|
|
3546
3580
|
// src/ui/game/JoinGameButton.tsx
|
|
3547
|
-
var
|
|
3581
|
+
var import_react22 = require("react");
|
|
3548
3582
|
var import_react_native13 = require("react-native");
|
|
3549
3583
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3550
3584
|
var STATUS_LABELS = {
|
|
@@ -3555,7 +3589,7 @@ var STATUS_LABELS = {
|
|
|
3555
3589
|
};
|
|
3556
3590
|
function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }) {
|
|
3557
3591
|
const t = useDubsTheme();
|
|
3558
|
-
const alreadyJoined = (0,
|
|
3592
|
+
const alreadyJoined = (0, import_react22.useMemo)(() => {
|
|
3559
3593
|
if (!walletAddress) return false;
|
|
3560
3594
|
return (game.bettors || []).some((b) => b.wallet === walletAddress);
|
|
3561
3595
|
}, [game.bettors, walletAddress]);
|
|
@@ -3596,7 +3630,7 @@ var styles8 = import_react_native13.StyleSheet.create({
|
|
|
3596
3630
|
});
|
|
3597
3631
|
|
|
3598
3632
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
3599
|
-
var
|
|
3633
|
+
var import_react23 = require("react");
|
|
3600
3634
|
var import_react_native14 = require("react-native");
|
|
3601
3635
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3602
3636
|
var STATUS_LABELS2 = {
|
|
@@ -3621,18 +3655,18 @@ function CreateCustomGameSheet({
|
|
|
3621
3655
|
const t = useDubsTheme();
|
|
3622
3656
|
const { wallet } = useDubs();
|
|
3623
3657
|
const mutation = useCreateCustomGame();
|
|
3624
|
-
const [selectedAmount, setSelectedAmount] = (0,
|
|
3625
|
-
const [customAmount, setCustomAmount] = (0,
|
|
3626
|
-
const [isCustom, setIsCustom] = (0,
|
|
3627
|
-
const overlayOpacity = (0,
|
|
3628
|
-
(0,
|
|
3658
|
+
const [selectedAmount, setSelectedAmount] = (0, import_react23.useState)(null);
|
|
3659
|
+
const [customAmount, setCustomAmount] = (0, import_react23.useState)("");
|
|
3660
|
+
const [isCustom, setIsCustom] = (0, import_react23.useState)(false);
|
|
3661
|
+
const overlayOpacity = (0, import_react23.useRef)(new import_react_native14.Animated.Value(0)).current;
|
|
3662
|
+
(0, import_react23.useEffect)(() => {
|
|
3629
3663
|
import_react_native14.Animated.timing(overlayOpacity, {
|
|
3630
3664
|
toValue: visible ? 1 : 0,
|
|
3631
3665
|
duration: 250,
|
|
3632
3666
|
useNativeDriver: true
|
|
3633
3667
|
}).start();
|
|
3634
3668
|
}, [visible, overlayOpacity]);
|
|
3635
|
-
(0,
|
|
3669
|
+
(0, import_react23.useEffect)(() => {
|
|
3636
3670
|
if (visible) {
|
|
3637
3671
|
setSelectedAmount(defaultAmount ?? null);
|
|
3638
3672
|
setCustomAmount("");
|
|
@@ -3640,7 +3674,7 @@ function CreateCustomGameSheet({
|
|
|
3640
3674
|
mutation.reset();
|
|
3641
3675
|
}
|
|
3642
3676
|
}, [visible]);
|
|
3643
|
-
(0,
|
|
3677
|
+
(0, import_react23.useEffect)(() => {
|
|
3644
3678
|
if (mutation.status === "success" && mutation.data) {
|
|
3645
3679
|
onSuccess?.(mutation.data);
|
|
3646
3680
|
const timer = setTimeout(() => {
|
|
@@ -3649,23 +3683,23 @@ function CreateCustomGameSheet({
|
|
|
3649
3683
|
return () => clearTimeout(timer);
|
|
3650
3684
|
}
|
|
3651
3685
|
}, [mutation.status, mutation.data]);
|
|
3652
|
-
(0,
|
|
3686
|
+
(0, import_react23.useEffect)(() => {
|
|
3653
3687
|
if (mutation.status === "error" && mutation.error) {
|
|
3654
3688
|
onError?.(mutation.error);
|
|
3655
3689
|
}
|
|
3656
3690
|
}, [mutation.status, mutation.error]);
|
|
3657
|
-
const handlePresetSelect = (0,
|
|
3691
|
+
const handlePresetSelect = (0, import_react23.useCallback)((amount) => {
|
|
3658
3692
|
setSelectedAmount(amount);
|
|
3659
3693
|
setIsCustom(false);
|
|
3660
3694
|
setCustomAmount("");
|
|
3661
3695
|
onAmountChange?.(amount);
|
|
3662
3696
|
}, [onAmountChange]);
|
|
3663
|
-
const handleCustomSelect = (0,
|
|
3697
|
+
const handleCustomSelect = (0, import_react23.useCallback)(() => {
|
|
3664
3698
|
setIsCustom(true);
|
|
3665
3699
|
setSelectedAmount(null);
|
|
3666
3700
|
onAmountChange?.(null);
|
|
3667
3701
|
}, [onAmountChange]);
|
|
3668
|
-
const handleCustomAmountChange = (0,
|
|
3702
|
+
const handleCustomAmountChange = (0, import_react23.useCallback)((text) => {
|
|
3669
3703
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
3670
3704
|
setCustomAmount(cleaned);
|
|
3671
3705
|
const parsed = parseFloat(cleaned);
|
|
@@ -3679,7 +3713,7 @@ function CreateCustomGameSheet({
|
|
|
3679
3713
|
const winnerTakes = pot * (1 - fee / 100);
|
|
3680
3714
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
3681
3715
|
const canCreate = effectiveAmount !== null && effectiveAmount > 0 && !isMutating && mutation.status !== "success";
|
|
3682
|
-
const handleCreate = (0,
|
|
3716
|
+
const handleCreate = (0, import_react23.useCallback)(async () => {
|
|
3683
3717
|
if (!effectiveAmount || !wallet.publicKey) return;
|
|
3684
3718
|
try {
|
|
3685
3719
|
await mutation.execute({
|
|
@@ -3948,7 +3982,7 @@ var styles9 = import_react_native14.StyleSheet.create({
|
|
|
3948
3982
|
});
|
|
3949
3983
|
|
|
3950
3984
|
// src/ui/game/JoinGameSheet.tsx
|
|
3951
|
-
var
|
|
3985
|
+
var import_react24 = require("react");
|
|
3952
3986
|
var import_react_native15 = require("react-native");
|
|
3953
3987
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3954
3988
|
var STATUS_LABELS3 = {
|
|
@@ -3973,22 +4007,22 @@ function JoinGameSheet({
|
|
|
3973
4007
|
const { wallet } = useDubs();
|
|
3974
4008
|
const mutation = useJoinGame();
|
|
3975
4009
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
3976
|
-
const [selectedTeam, setSelectedTeam] = (0,
|
|
3977
|
-
const overlayOpacity = (0,
|
|
3978
|
-
(0,
|
|
4010
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react24.useState)(null);
|
|
4011
|
+
const overlayOpacity = (0, import_react24.useRef)(new import_react_native15.Animated.Value(0)).current;
|
|
4012
|
+
(0, import_react24.useEffect)(() => {
|
|
3979
4013
|
import_react_native15.Animated.timing(overlayOpacity, {
|
|
3980
4014
|
toValue: visible ? 1 : 0,
|
|
3981
4015
|
duration: 250,
|
|
3982
4016
|
useNativeDriver: true
|
|
3983
4017
|
}).start();
|
|
3984
4018
|
}, [visible, overlayOpacity]);
|
|
3985
|
-
(0,
|
|
4019
|
+
(0, import_react24.useEffect)(() => {
|
|
3986
4020
|
if (visible) {
|
|
3987
4021
|
setSelectedTeam(isCustomGame ? "away" : null);
|
|
3988
4022
|
mutation.reset();
|
|
3989
4023
|
}
|
|
3990
4024
|
}, [visible]);
|
|
3991
|
-
(0,
|
|
4025
|
+
(0, import_react24.useEffect)(() => {
|
|
3992
4026
|
if (mutation.status === "success" && mutation.data) {
|
|
3993
4027
|
onSuccess?.(mutation.data);
|
|
3994
4028
|
const timer = setTimeout(() => {
|
|
@@ -3997,7 +4031,7 @@ function JoinGameSheet({
|
|
|
3997
4031
|
return () => clearTimeout(timer);
|
|
3998
4032
|
}
|
|
3999
4033
|
}, [mutation.status, mutation.data]);
|
|
4000
|
-
(0,
|
|
4034
|
+
(0, import_react24.useEffect)(() => {
|
|
4001
4035
|
if (mutation.status === "error" && mutation.error) {
|
|
4002
4036
|
onError?.(mutation.error);
|
|
4003
4037
|
}
|
|
@@ -4008,7 +4042,7 @@ function JoinGameSheet({
|
|
|
4008
4042
|
const homePool = game.homePool || 0;
|
|
4009
4043
|
const awayPool = game.awayPool || 0;
|
|
4010
4044
|
const buyIn = game.buyIn;
|
|
4011
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
4045
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react24.useMemo)(() => ({
|
|
4012
4046
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
4013
4047
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
4014
4048
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -4020,14 +4054,14 @@ function JoinGameSheet({
|
|
|
4020
4054
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
4021
4055
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
4022
4056
|
const selectedName = selectedTeam === "home" ? homeName : selectedTeam === "away" ? awayName : "\u2014";
|
|
4023
|
-
const alreadyJoined = (0,
|
|
4057
|
+
const alreadyJoined = (0, import_react24.useMemo)(() => {
|
|
4024
4058
|
if (!wallet.publicKey) return false;
|
|
4025
4059
|
const addr = wallet.publicKey.toBase58();
|
|
4026
4060
|
return bettors.some((b) => b.wallet === addr);
|
|
4027
4061
|
}, [bettors, wallet.publicKey]);
|
|
4028
4062
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4029
4063
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
4030
|
-
const handleJoin = (0,
|
|
4064
|
+
const handleJoin = (0, import_react24.useCallback)(async () => {
|
|
4031
4065
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
4032
4066
|
try {
|
|
4033
4067
|
await mutation.execute({
|
|
@@ -4156,7 +4190,7 @@ function TeamButton({
|
|
|
4156
4190
|
ImageComponent,
|
|
4157
4191
|
t
|
|
4158
4192
|
}) {
|
|
4159
|
-
const [imgFailed, setImgFailed] = (0,
|
|
4193
|
+
const [imgFailed, setImgFailed] = (0, import_react24.useState)(false);
|
|
4160
4194
|
const Img = ImageComponent || require("react-native").Image;
|
|
4161
4195
|
const showImage = imageUrl && !imgFailed;
|
|
4162
4196
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
@@ -4333,7 +4367,7 @@ var styles10 = import_react_native15.StyleSheet.create({
|
|
|
4333
4367
|
});
|
|
4334
4368
|
|
|
4335
4369
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
4336
|
-
var
|
|
4370
|
+
var import_react25 = require("react");
|
|
4337
4371
|
var import_react_native16 = require("react-native");
|
|
4338
4372
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4339
4373
|
var STATUS_LABELS4 = {
|
|
@@ -4354,18 +4388,18 @@ function ClaimPrizeSheet({
|
|
|
4354
4388
|
const t = useDubsTheme();
|
|
4355
4389
|
const { wallet } = useDubs();
|
|
4356
4390
|
const mutation = useClaim();
|
|
4357
|
-
const overlayOpacity = (0,
|
|
4358
|
-
const celebrationScale = (0,
|
|
4359
|
-
const celebrationOpacity = (0,
|
|
4360
|
-
const [showCelebration, setShowCelebration] = (0,
|
|
4361
|
-
(0,
|
|
4391
|
+
const overlayOpacity = (0, import_react25.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4392
|
+
const celebrationScale = (0, import_react25.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4393
|
+
const celebrationOpacity = (0, import_react25.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4394
|
+
const [showCelebration, setShowCelebration] = (0, import_react25.useState)(false);
|
|
4395
|
+
(0, import_react25.useEffect)(() => {
|
|
4362
4396
|
import_react_native16.Animated.timing(overlayOpacity, {
|
|
4363
4397
|
toValue: visible ? 1 : 0,
|
|
4364
4398
|
duration: 250,
|
|
4365
4399
|
useNativeDriver: true
|
|
4366
4400
|
}).start();
|
|
4367
4401
|
}, [visible, overlayOpacity]);
|
|
4368
|
-
(0,
|
|
4402
|
+
(0, import_react25.useEffect)(() => {
|
|
4369
4403
|
if (visible) {
|
|
4370
4404
|
mutation.reset();
|
|
4371
4405
|
setShowCelebration(false);
|
|
@@ -4373,7 +4407,7 @@ function ClaimPrizeSheet({
|
|
|
4373
4407
|
celebrationOpacity.setValue(0);
|
|
4374
4408
|
}
|
|
4375
4409
|
}, [visible]);
|
|
4376
|
-
(0,
|
|
4410
|
+
(0, import_react25.useEffect)(() => {
|
|
4377
4411
|
if (mutation.status === "success" && mutation.data) {
|
|
4378
4412
|
setShowCelebration(true);
|
|
4379
4413
|
import_react_native16.Animated.parallel([
|
|
@@ -4396,14 +4430,14 @@ function ClaimPrizeSheet({
|
|
|
4396
4430
|
return () => clearTimeout(timer);
|
|
4397
4431
|
}
|
|
4398
4432
|
}, [mutation.status, mutation.data]);
|
|
4399
|
-
(0,
|
|
4433
|
+
(0, import_react25.useEffect)(() => {
|
|
4400
4434
|
if (mutation.status === "error" && mutation.error) {
|
|
4401
4435
|
onError?.(mutation.error);
|
|
4402
4436
|
}
|
|
4403
4437
|
}, [mutation.status, mutation.error]);
|
|
4404
4438
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4405
4439
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
4406
|
-
const handleClaim = (0,
|
|
4440
|
+
const handleClaim = (0, import_react25.useCallback)(async () => {
|
|
4407
4441
|
if (!wallet.publicKey) return;
|
|
4408
4442
|
try {
|
|
4409
4443
|
await mutation.execute({
|
|
@@ -4636,7 +4670,7 @@ var styles11 = import_react_native16.StyleSheet.create({
|
|
|
4636
4670
|
});
|
|
4637
4671
|
|
|
4638
4672
|
// src/ui/game/ClaimButton.tsx
|
|
4639
|
-
var
|
|
4673
|
+
var import_react26 = require("react");
|
|
4640
4674
|
var import_react_native17 = require("react-native");
|
|
4641
4675
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4642
4676
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -4644,9 +4678,9 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
4644
4678
|
const { wallet } = useDubs();
|
|
4645
4679
|
const game = useGame(gameId);
|
|
4646
4680
|
const claimStatus = useHasClaimed(gameId);
|
|
4647
|
-
const [sheetVisible, setSheetVisible] = (0,
|
|
4681
|
+
const [sheetVisible, setSheetVisible] = (0, import_react26.useState)(false);
|
|
4648
4682
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
4649
|
-
const myBet = (0,
|
|
4683
|
+
const myBet = (0, import_react26.useMemo)(() => {
|
|
4650
4684
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
4651
4685
|
return game.data.bettors.find((b) => b.wallet === walletAddress) ?? null;
|
|
4652
4686
|
}, [walletAddress, game.data?.bettors]);
|
|
@@ -4655,7 +4689,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
4655
4689
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
4656
4690
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
4657
4691
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
4658
|
-
const handleSuccess = (0,
|
|
4692
|
+
const handleSuccess = (0, import_react26.useCallback)(
|
|
4659
4693
|
(result) => {
|
|
4660
4694
|
claimStatus.refetch();
|
|
4661
4695
|
onSuccess?.(result);
|
|
@@ -4783,6 +4817,7 @@ var styles12 = import_react_native17.StyleSheet.create({
|
|
|
4783
4817
|
useGames,
|
|
4784
4818
|
useHasClaimed,
|
|
4785
4819
|
useJoinGame,
|
|
4786
|
-
useNetworkGames
|
|
4820
|
+
useNetworkGames,
|
|
4821
|
+
useUFCFightCard
|
|
4787
4822
|
});
|
|
4788
4823
|
//# sourceMappingURL=index.js.map
|