@dubsdotapp/expo 0.2.39 → 0.2.41

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.mjs CHANGED
@@ -504,11 +504,61 @@ function createSecureStoreStorage() {
504
504
  }
505
505
 
506
506
  // src/provider.tsx
507
- import { createContext as createContext3, useContext as useContext3, useMemo, useCallback as useCallback12, useState as useState13, useEffect as useEffect8 } from "react";
507
+ import { createContext as createContext4, useContext as useContext4, useMemo, useCallback as useCallback12, useState as useState13, useEffect as useEffect8 } from "react";
508
+
509
+ // src/ui/theme.ts
510
+ import { createContext, useContext } from "react";
511
+ import { useColorScheme } from "react-native";
512
+ var dark = {
513
+ background: "#08080D",
514
+ surface: "#111118",
515
+ surfaceActive: "#7C3AED",
516
+ border: "#1A1A24",
517
+ text: "#FFFFFF",
518
+ textSecondary: "#E0E0EE",
519
+ textMuted: "#666666",
520
+ textDim: "#555555",
521
+ accent: "#7C3AED",
522
+ success: "#22C55E",
523
+ live: "#EF4444",
524
+ errorText: "#F87171",
525
+ errorBg: "#1A0A0A",
526
+ errorBorder: "#3A1515"
527
+ };
528
+ var light = {
529
+ background: "#FFFFFF",
530
+ surface: "#F0F0F5",
531
+ surfaceActive: "#7C3AED",
532
+ border: "#E0E0E8",
533
+ text: "#111118",
534
+ textSecondary: "#333333",
535
+ textMuted: "#888888",
536
+ textDim: "#999999",
537
+ accent: "#7C3AED",
538
+ success: "#16A34A",
539
+ live: "#DC2626",
540
+ errorText: "#DC2626",
541
+ errorBg: "#FEF2F2",
542
+ errorBorder: "#FECACA"
543
+ };
544
+ var ThemeOverrideContext = createContext({});
545
+ var ThemeOverrideProvider = ThemeOverrideContext.Provider;
546
+ function useDubsTheme() {
547
+ const scheme = useColorScheme();
548
+ const base = scheme === "light" ? light : dark;
549
+ const overrides = useContext(ThemeOverrideContext);
550
+ if (Object.keys(overrides).length === 0) return base;
551
+ return { ...base, ...overrides };
552
+ }
553
+ function mergeTheme(base, overrides) {
554
+ return { ...base, ...overrides };
555
+ }
556
+
557
+ // src/provider.tsx
508
558
  import { Connection as Connection2 } from "@solana/web3.js";
509
559
 
510
560
  // src/managed-wallet.tsx
511
- import { createContext, useContext, useState, useEffect, useRef, useCallback } from "react";
561
+ import { createContext as createContext2, useContext as useContext2, useState, useEffect, useRef, useCallback } from "react";
512
562
  import { Platform } from "react-native";
513
563
 
514
564
  // src/wallet/mwa-adapter.ts
@@ -1126,50 +1176,6 @@ import {
1126
1176
  StyleSheet,
1127
1177
  Image
1128
1178
  } from "react-native";
1129
-
1130
- // src/ui/theme.ts
1131
- import { useColorScheme } from "react-native";
1132
- var dark = {
1133
- background: "#08080D",
1134
- surface: "#111118",
1135
- surfaceActive: "#7C3AED",
1136
- border: "#1A1A24",
1137
- text: "#FFFFFF",
1138
- textSecondary: "#E0E0EE",
1139
- textMuted: "#666666",
1140
- textDim: "#555555",
1141
- accent: "#7C3AED",
1142
- success: "#22C55E",
1143
- live: "#EF4444",
1144
- errorText: "#F87171",
1145
- errorBg: "#1A0A0A",
1146
- errorBorder: "#3A1515"
1147
- };
1148
- var light = {
1149
- background: "#FFFFFF",
1150
- surface: "#F0F0F5",
1151
- surfaceActive: "#7C3AED",
1152
- border: "#E0E0E8",
1153
- text: "#111118",
1154
- textSecondary: "#333333",
1155
- textMuted: "#888888",
1156
- textDim: "#999999",
1157
- accent: "#7C3AED",
1158
- success: "#16A34A",
1159
- live: "#DC2626",
1160
- errorText: "#DC2626",
1161
- errorBg: "#FEF2F2",
1162
- errorBorder: "#FECACA"
1163
- };
1164
- function useDubsTheme() {
1165
- const scheme = useColorScheme();
1166
- return scheme === "light" ? light : dark;
1167
- }
1168
- function mergeTheme(base, overrides) {
1169
- return { ...base, ...overrides };
1170
- }
1171
-
1172
- // src/ui/ConnectWalletScreen.tsx
1173
1179
  import { jsx, jsxs } from "react/jsx-runtime";
1174
1180
  function ConnectWalletScreen({
1175
1181
  onConnect,
@@ -1322,9 +1328,9 @@ function getOrCreatePhantomAdapter(config) {
1322
1328
  }
1323
1329
  return phantomSingleton;
1324
1330
  }
1325
- var DisconnectContext = createContext(null);
1331
+ var DisconnectContext = createContext2(null);
1326
1332
  function useDisconnect() {
1327
- return useContext(DisconnectContext);
1333
+ return useContext2(DisconnectContext);
1328
1334
  }
1329
1335
  function ManagedWalletProvider({
1330
1336
  appName,
@@ -1990,12 +1996,12 @@ function useHasClaimed(gameId) {
1990
1996
  }
1991
1997
 
1992
1998
  // src/hooks/useAuth.ts
1993
- import { useState as useState11, useCallback as useCallback10, useRef as useRef2, useContext as useContext2 } from "react";
1999
+ import { useState as useState11, useCallback as useCallback10, useRef as useRef2, useContext as useContext3 } from "react";
1994
2000
  import bs583 from "bs58";
1995
2001
 
1996
2002
  // src/auth-context.ts
1997
- import { createContext as createContext2 } from "react";
1998
- var AuthContext = createContext2(null);
2003
+ import { createContext as createContext3 } from "react";
2004
+ var AuthContext = createContext3(null);
1999
2005
 
2000
2006
  // src/utils/device.ts
2001
2007
  import { Platform as Platform2 } from "react-native";
@@ -2046,7 +2052,7 @@ async function getDeviceInfo() {
2046
2052
 
2047
2053
  // src/hooks/useAuth.ts
2048
2054
  function useAuth() {
2049
- const sharedAuth = useContext2(AuthContext);
2055
+ const sharedAuth = useContext3(AuthContext);
2050
2056
  const { client, wallet } = useDubs();
2051
2057
  const [status, setStatus] = useState11("idle");
2052
2058
  const [user, setUser] = useState11(null);
@@ -2667,7 +2673,7 @@ var s = StyleSheet2.create({
2667
2673
 
2668
2674
  // src/provider.tsx
2669
2675
  import { jsx as jsx4 } from "react/jsx-runtime";
2670
- var DubsContext = createContext3(null);
2676
+ var DubsContext = createContext4(null);
2671
2677
  function DubsProvider({
2672
2678
  apiKey,
2673
2679
  children,
@@ -2703,8 +2709,12 @@ function DubsProvider({
2703
2709
  });
2704
2710
  }, [client]);
2705
2711
  if (uiConfig === null) return null;
2712
+ const themeOverrides = {};
2713
+ if (uiConfig.accentColor) {
2714
+ themeOverrides.accent = uiConfig.accentColor;
2715
+ }
2706
2716
  if (externalWallet) {
2707
- return /* @__PURE__ */ jsx4(
2717
+ return /* @__PURE__ */ jsx4(ThemeOverrideProvider, { value: themeOverrides, children: /* @__PURE__ */ jsx4(
2708
2718
  ExternalWalletProvider,
2709
2719
  {
2710
2720
  client,
@@ -2721,9 +2731,9 @@ function DubsProvider({
2721
2731
  uiConfig,
2722
2732
  children
2723
2733
  }
2724
- );
2734
+ ) });
2725
2735
  }
2726
- return /* @__PURE__ */ jsx4(
2736
+ return /* @__PURE__ */ jsx4(ThemeOverrideProvider, { value: themeOverrides, children: /* @__PURE__ */ jsx4(
2727
2737
  ManagedWalletProvider,
2728
2738
  {
2729
2739
  appName: uiConfig.appName || appName,
@@ -2753,7 +2763,7 @@ function DubsProvider({
2753
2763
  }
2754
2764
  )
2755
2765
  }
2756
- );
2766
+ ) });
2757
2767
  }
2758
2768
  function ManagedInner({
2759
2769
  client,
@@ -2841,14 +2851,14 @@ function ExternalWalletProvider({
2841
2851
  ) });
2842
2852
  }
2843
2853
  function useDubs() {
2844
- const ctx = useContext3(DubsContext);
2854
+ const ctx = useContext4(DubsContext);
2845
2855
  if (!ctx) {
2846
2856
  throw new Error("useDubs must be used within a <DubsProvider>");
2847
2857
  }
2848
2858
  return ctx;
2849
2859
  }
2850
2860
  function useAppConfig() {
2851
- const ctx = useContext3(DubsContext);
2861
+ const ctx = useContext4(DubsContext);
2852
2862
  return ctx?.uiConfig || {};
2853
2863
  }
2854
2864
 
@@ -3520,7 +3530,7 @@ function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }) {
3520
3530
  /* @__PURE__ */ jsx11(
3521
3531
  TouchableOpacity5,
3522
3532
  {
3523
- style: [styles8.button, { backgroundColor: selectedTeam ? "#22D3EE" : t.border }],
3533
+ style: [styles8.button, { backgroundColor: selectedTeam ? t.accent : t.border }],
3524
3534
  disabled: !selectedTeam || isJoining,
3525
3535
  onPress: onJoin,
3526
3536
  activeOpacity: 0.8,
@@ -4465,7 +4475,7 @@ function ClaimPrizeSheet({
4465
4475
  {
4466
4476
  style: [
4467
4477
  styles11.ctaButton,
4468
- { backgroundColor: canClaim ? t.success : t.border }
4478
+ { backgroundColor: canClaim ? t.accent : t.border }
4469
4479
  ],
4470
4480
  disabled: !canClaim,
4471
4481
  onPress: handleClaim,
@@ -4612,8 +4622,112 @@ var styles11 = StyleSheet12.create({
4612
4622
  fontSize: 13
4613
4623
  }
4614
4624
  });
4625
+
4626
+ // src/ui/game/ClaimButton.tsx
4627
+ import { useState as useState20, useMemo as useMemo7, useCallback as useCallback16 } from "react";
4628
+ import { StyleSheet as StyleSheet13, Text as Text13, TouchableOpacity as TouchableOpacity9 } from "react-native";
4629
+ import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
4630
+ function ClaimButton({ gameId, style, onSuccess, onError }) {
4631
+ const t = useDubsTheme();
4632
+ const { wallet } = useDubs();
4633
+ const game = useGame(gameId);
4634
+ const claimStatus = useHasClaimed(gameId);
4635
+ const [sheetVisible, setSheetVisible] = useState20(false);
4636
+ const walletAddress = wallet.publicKey?.toBase58() ?? null;
4637
+ const myBet = useMemo7(() => {
4638
+ if (!walletAddress || !game.data?.bettors) return null;
4639
+ return game.data.bettors.find((b) => b.wallet === walletAddress) ?? null;
4640
+ }, [walletAddress, game.data?.bettors]);
4641
+ const isResolved = game.data?.isResolved ?? false;
4642
+ const isRefund = isResolved && game.data?.winnerSide === null;
4643
+ const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
4644
+ const isEligible = myBet != null && isResolved && (isWinner || isRefund);
4645
+ const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
4646
+ const handleSuccess = useCallback16(
4647
+ (result) => {
4648
+ claimStatus.refetch();
4649
+ onSuccess?.(result);
4650
+ },
4651
+ [claimStatus.refetch, onSuccess]
4652
+ // eslint-disable-line react-hooks/exhaustive-deps
4653
+ );
4654
+ if (game.loading || claimStatus.loading || !game.data || !walletAddress || !isEligible) {
4655
+ return null;
4656
+ }
4657
+ const label = isRefund ? "Refund" : "Prize";
4658
+ if (claimStatus.hasClaimed) {
4659
+ return /* @__PURE__ */ jsx15(
4660
+ TouchableOpacity9,
4661
+ {
4662
+ style: [styles12.badge, { borderColor: t.accent }, style],
4663
+ activeOpacity: 1,
4664
+ disabled: true,
4665
+ children: /* @__PURE__ */ jsxs13(Text13, { style: [styles12.badgeText, { color: t.accent }], children: [
4666
+ label,
4667
+ " Claimed!"
4668
+ ] })
4669
+ }
4670
+ );
4671
+ }
4672
+ return /* @__PURE__ */ jsxs13(Fragment4, { children: [
4673
+ /* @__PURE__ */ jsx15(
4674
+ TouchableOpacity9,
4675
+ {
4676
+ style: [styles12.button, { backgroundColor: t.accent }, style],
4677
+ activeOpacity: 0.8,
4678
+ onPress: () => setSheetVisible(true),
4679
+ children: /* @__PURE__ */ jsxs13(Text13, { style: styles12.buttonText, children: [
4680
+ "Claim ",
4681
+ label,
4682
+ " \u2014 ",
4683
+ prizeAmount,
4684
+ " SOL"
4685
+ ] })
4686
+ }
4687
+ ),
4688
+ /* @__PURE__ */ jsx15(
4689
+ ClaimPrizeSheet,
4690
+ {
4691
+ visible: sheetVisible,
4692
+ onDismiss: () => setSheetVisible(false),
4693
+ gameId,
4694
+ prizeAmount,
4695
+ isRefund,
4696
+ onSuccess: handleSuccess,
4697
+ onError
4698
+ }
4699
+ )
4700
+ ] });
4701
+ }
4702
+ var styles12 = StyleSheet13.create({
4703
+ button: {
4704
+ height: 52,
4705
+ borderRadius: 14,
4706
+ justifyContent: "center",
4707
+ alignItems: "center",
4708
+ paddingHorizontal: 20
4709
+ },
4710
+ buttonText: {
4711
+ color: "#FFFFFF",
4712
+ fontSize: 16,
4713
+ fontWeight: "700"
4714
+ },
4715
+ badge: {
4716
+ height: 52,
4717
+ borderRadius: 14,
4718
+ borderWidth: 2,
4719
+ justifyContent: "center",
4720
+ alignItems: "center",
4721
+ paddingHorizontal: 20
4722
+ },
4723
+ badgeText: {
4724
+ fontSize: 16,
4725
+ fontWeight: "700"
4726
+ }
4727
+ });
4615
4728
  export {
4616
4729
  AuthGate,
4730
+ ClaimButton,
4617
4731
  ClaimPrizeSheet,
4618
4732
  ConnectWalletScreen,
4619
4733
  CreateCustomGameSheet,