@vechain/vechain-kit 2.0.0-rc.11 → 2.0.0-rc.12

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.cjs CHANGED
@@ -48,10 +48,10 @@ var fa6 = require('react-icons/fa6');
48
48
  var si = require('react-icons/si');
49
49
  var bi = require('react-icons/bi');
50
50
  var go = require('react-icons/go');
51
- var sdkNetwork = require('@vechain/sdk-network');
52
51
  var react$1 = require('@emotion/react');
53
52
  var createCache = require('@emotion/cache');
54
53
  var anatomy = require('@chakra-ui/anatomy');
54
+ var sdkNetwork = require('@vechain/sdk-network');
55
55
 
56
56
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
57
57
 
@@ -337,6 +337,7 @@ var en_default = {
337
337
  "Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.": "Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.",
338
338
  "Manage your login methods and passkeys": "Manage your login methods and passkeys",
339
339
  "Manage your preferences for currency, language, and appearance.": "Manage your preferences for currency, language, and appearance.",
340
+ "Minimum {{symbol}} transfer is {{min}}": "Minimum {{symbol}} transfer is {{min}}",
340
341
  "Mobile browser may block the login window.": "Mobile browser may block the login window.",
341
342
  More: "More",
342
343
  "Multiclause Transaction temporary disabled": "Multiclause Transaction temporary disabled",
@@ -907,6 +908,7 @@ var de_default = {
907
908
  "Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.": "Verwalten Sie die Sicherheitseinstellungen Ihrer eingebetteten Wallet: Verwalten Sie Ihre Anmeldemethoden, f\xFCgen Sie einen Zugangsschl\xFCssel hinzu oder sichern Sie Ihre Wallet, um nie den Zugriff auf Ihre Assets zu verlieren.",
908
909
  "Manage your login methods and passkeys": "Verwalten Sie Ihre Anmeldemethoden und Zugangsschl\xFCssel",
909
910
  "Manage your preferences for currency, language, and appearance.": "Verwalten Sie Ihre Einstellungen f\xFCr W\xE4hrung, Sprache und Erscheinungsbild.",
911
+ "Minimum {{symbol}} transfer is {{min}}": "Die Mindest\xFCbertragung von {{symbol}} betr\xE4gt {{min}}",
910
912
  "Mobile browser may block the login window.": "Mobiler Browser kann das Anmeldefenster blockieren.",
911
913
  More: "Mehr",
912
914
  "Multiclause Transaction temporary disabled": "Multiclause-Transaktion vor\xFCbergehend deaktiviert",
@@ -1477,6 +1479,7 @@ var it_default = {
1477
1479
  "Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.": "Gestisci le impostazioni di sicurezza del tuo portafoglio integrato: gestisci i tuoi metodi di accesso, aggiungi una chiave di accesso o esegui il backup del portafoglio per non perdere mai l'accesso ai tuoi beni.",
1478
1480
  "Manage your login methods and passkeys": "Gestisci i tuoi metodi di accesso e chiavi di accesso",
1479
1481
  "Manage your preferences for currency, language, and appearance.": "Gestisci le tue preferenze per valuta, lingua e aspetto.",
1482
+ "Minimum {{symbol}} transfer is {{min}}": "Il trasferimento minimo di {{symbol}} \xE8 {{min}}",
1480
1483
  "Mobile browser may block the login window.": "Il browser mobile potrebbe bloccare la finestra di accesso.",
1481
1484
  More: "Altro",
1482
1485
  "Multiclause Transaction temporary disabled": "Transazione multiclausola temporaneamente disabilitata",
@@ -2047,6 +2050,7 @@ var fr_default = {
2047
2050
  "Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.": "G\xE9rez les param\xE8tres de s\xE9curit\xE9 de votre portefeuille int\xE9gr\xE9 : g\xE9rez vos m\xE9thodes de connexion, ajoutez une cl\xE9 d'acc\xE8s ou sauvegardez votre portefeuille pour ne jamais perdre l'acc\xE8s \xE0 vos actifs.",
2048
2051
  "Manage your login methods and passkeys": "G\xE9rez vos m\xE9thodes de connexion et cl\xE9s d'acc\xE8s",
2049
2052
  "Manage your preferences for currency, language, and appearance.": "G\xE9rez vos pr\xE9f\xE9rences de devise, de langue et d'apparence.",
2053
+ "Minimum {{symbol}} transfer is {{min}}": "Le transfert minimum {{symbol}} est {{min}}",
2050
2054
  "Mobile browser may block the login window.": "Le navigateur mobile peut bloquer la fen\xEAtre de connexion.",
2051
2055
  More: "Plus",
2052
2056
  "Multiclause Transaction temporary disabled": "Transaction \xE0 clauses multiples temporairement d\xE9sactiv\xE9e",
@@ -2617,6 +2621,7 @@ var es_default = {
2617
2621
  "Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.": "Administra la configuraci\xF3n de seguridad de tu billetera integrada: gestiona tus m\xE9todos de inicio de sesi\xF3n, a\xF1ade una clave de acceso o realiza una copia de seguridad de tu billetera para no perder nunca el acceso a tus activos.",
2618
2622
  "Manage your login methods and passkeys": "Gestiona tus m\xE9todos de inicio de sesi\xF3n y claves de acceso",
2619
2623
  "Manage your preferences for currency, language, and appearance.": "Administra tus preferencias de moneda, idioma y apariencia.",
2624
+ "Minimum {{symbol}} transfer is {{min}}": "La transferencia m\xEDnima de {{symbol}} es {{min}}",
2620
2625
  "Mobile browser may block the login window.": "El navegador m\xF3vil puede bloquear la ventana de inicio de sesi\xF3n.",
2621
2626
  More: "M\xE1s",
2622
2627
  "Multiclause Transaction temporary disabled": "Transacci\xF3n con m\xFAltiples cl\xE1usulas temporalmente deshabilitada",
@@ -3187,6 +3192,7 @@ var zh_default = {
3187
3192
  "Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.": "\u7BA1\u7406\u60A8\u7684\u5D4C\u5165\u5F0F\u94B1\u5305\u7684\u5B89\u5168\u8BBE\u7F6E\uFF1A\u5904\u7406\u60A8\u7684\u767B\u5F55\u65B9\u6CD5\uFF0C\u6DFB\u52A0\u5BC6\u7801\u94A5\u5319\u6216\u5907\u4EFD\u60A8\u7684\u94B1\u5305\uFF0C\u4EE5\u514D\u5931\u53BB\u5BF9\u8D44\u4EA7\u7684\u8BBF\u95EE\u3002",
3188
3193
  "Manage your login methods and passkeys": "\u7BA1\u7406\u60A8\u7684\u767B\u5F55\u65B9\u5F0F\u548C\u901A\u884C\u5BC6\u94A5",
3189
3194
  "Manage your preferences for currency, language, and appearance.": "\u7BA1\u7406\u60A8\u5BF9\u8D27\u5E01\u3001\u8BED\u8A00\u548C\u5916\u89C2\u7684\u504F\u597D\u3002",
3195
+ "Minimum {{symbol}} transfer is {{min}}": "{{symbol}}\u7684\u6700\u5C0F\u8F6C\u8D26\u91D1\u989D\u4E3A{{min}}",
3190
3196
  "Mobile browser may block the login window.": "\u79FB\u52A8\u6D4F\u89C8\u5668\u53EF\u80FD\u4F1A\u963B\u6B62\u767B\u5F55\u7A97\u53E3\u3002",
3191
3197
  More: "\u66F4\u591A",
3192
3198
  "Multiclause Transaction temporary disabled": "\u591A\u6761\u6B3E\u4EA4\u6613\u6682\u65F6\u7981\u7528",
@@ -3757,6 +3763,7 @@ var ja_default = {
3757
3763
  "Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.": "\u57CB\u3081\u8FBC\u307F\u30A6\u30A9\u30EC\u30C3\u30C8\u306E\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u8A2D\u5B9A\u3092\u7BA1\u7406\u3057\u307E\u3059: \u30ED\u30B0\u30A4\u30F3\u65B9\u6CD5\u3092\u51E6\u7406\u3057\u305F\u308A\u3001\u30D1\u30B9\u30AD\u30FC\u3092\u8FFD\u52A0\u3057\u305F\u308A\u3001\u8CC7\u7523\u3078\u306E\u30A2\u30AF\u30BB\u30B9\u3092\u5931\u308F\u306A\u3044\u3088\u3046\u306B\u30A6\u30A9\u30EC\u30C3\u30C8\u3092\u30D0\u30C3\u30AF\u30A2\u30C3\u30D7\u3057\u305F\u308A\u3057\u307E\u3059\u3002",
3758
3764
  "Manage your login methods and passkeys": "\u30ED\u30B0\u30A4\u30F3\u65B9\u6CD5\u3068\u30D1\u30B9\u30AD\u30FC\u3092\u7BA1\u7406\u3059\u308B",
3759
3765
  "Manage your preferences for currency, language, and appearance.": "\u901A\u8CA8\u3001\u8A00\u8A9E\u3001\u5916\u89B3\u306E\u8A2D\u5B9A\u3092\u7BA1\u7406\u3057\u307E\u3059\u3002",
3766
+ "Minimum {{symbol}} transfer is {{min}}": "\u6700\u5C0F{{symbol}}\u8EE2\u9001\u91CF\u306F{{min}}\u3067\u3059",
3760
3767
  "Mobile browser may block the login window.": "\u30E2\u30D0\u30A4\u30EB\u30D6\u30E9\u30A6\u30B6\u306F\u30ED\u30B0\u30A4\u30F3\u30A6\u30A3\u30F3\u30C9\u30A6\u3092\u30D6\u30ED\u30C3\u30AF\u3059\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002",
3761
3768
  More: "\u3082\u3063\u3068\u898B\u308B",
3762
3769
  "Multiclause Transaction temporary disabled": "\u8907\u6570\u6761\u9805\u306E\u30C8\u30E9\u30F3\u30B6\u30AF\u30B7\u30E7\u30F3\u306F\u4E00\u6642\u7684\u306B\u7121\u52B9\u5316\u3055\u308C\u3066\u3044\u307E\u3059\u3002",
@@ -4858,7 +4865,7 @@ var AddressDisplay = ({
4858
4865
 
4859
4866
  // package.json
4860
4867
  var package_default = {
4861
- version: "2.0.0-rc.11"};
4868
+ version: "2.0.0-rc.12"};
4862
4869
  var VersionFooter = ({ ...props }) => {
4863
4870
  const { darkMode: isDark } = useVeChainKitConfig();
4864
4871
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4976,7 +4983,7 @@ var BaseModal = ({
4976
4983
  isCloseable = true
4977
4984
  }) => {
4978
4985
  const [isDesktop] = react.useMediaQuery("(min-width: 768px)");
4979
- const { darkMode } = useVeChainKitConfig();
4986
+ const { portalRootRef } = useVechainKitThemeConfig();
4980
4987
  const modalContentProps = isDesktop ? {} : {
4981
4988
  position: "fixed",
4982
4989
  bottom: "0",
@@ -4987,7 +4994,7 @@ var BaseModal = ({
4987
4994
  overflowX: "hidden",
4988
4995
  scrollBehavior: "smooth"
4989
4996
  };
4990
- return /* @__PURE__ */ jsxRuntime.jsx(VechainKitThemeProvider, { darkMode, children: /* @__PURE__ */ jsxRuntime.jsxs(
4997
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4991
4998
  react.Modal,
4992
4999
  {
4993
5000
  motionPreset,
@@ -4999,7 +5006,7 @@ var BaseModal = ({
4999
5006
  blockScrollOnMount,
5000
5007
  closeOnOverlayClick: closeOnOverlayClick && isCloseable,
5001
5008
  preserveScrollBarGap: true,
5002
- portalProps: { containerRef: void 0 },
5009
+ portalProps: { containerRef: portalRootRef },
5003
5010
  trapFocus: !allowExternalFocus,
5004
5011
  autoFocus: !allowExternalFocus,
5005
5012
  children: [
@@ -5015,7 +5022,7 @@ var BaseModal = ({
5015
5022
  )
5016
5023
  ]
5017
5024
  }
5018
- ) });
5025
+ );
5019
5026
  };
5020
5027
 
5021
5028
  // src/utils/currencyUtils.ts
@@ -9761,7 +9768,7 @@ var SendTokenContent = ({
9761
9768
  onBack: parentOnBack = () => setCurrentContent("main")
9762
9769
  }) => {
9763
9770
  const { t } = reactI18next.useTranslation();
9764
- const { darkMode: isDark } = useVeChainKitConfig();
9771
+ const { darkMode: isDark, feeDelegation } = useVeChainKitConfig();
9765
9772
  const { currentCurrency } = useCurrency();
9766
9773
  const { exchangeRates } = useTokenPrices();
9767
9774
  const [selectedToken, setSelectedToken] = React10.useState(
@@ -9865,6 +9872,30 @@ var SendTokenContent = ({
9865
9872
  }
9866
9873
  if (selectedToken) {
9867
9874
  const numericAmount = ethers.parseEther(data.amount);
9875
+ const minB3tr = feeDelegation?.b3trTransfers?.minAmountInEther;
9876
+ if (selectedToken.symbol === "B3TR" && typeof minB3tr === "number" && minB3tr > 0) {
9877
+ try {
9878
+ const minWei = ethers.parseEther(String(minB3tr));
9879
+ if (numericAmount < minWei) {
9880
+ setError("amount", {
9881
+ type: "manual",
9882
+ message: t(
9883
+ "Minimum {{symbol}} transfer is {{min}}",
9884
+ {
9885
+ symbol: selectedToken.symbol,
9886
+ min: minB3tr
9887
+ }
9888
+ )
9889
+ });
9890
+ Analytics.send.flow("review", {
9891
+ tokenSymbol: selectedToken.symbol,
9892
+ error: "Below minimum amount"
9893
+ });
9894
+ return;
9895
+ }
9896
+ } catch {
9897
+ }
9898
+ }
9868
9899
  if (numericAmount > ethers.parseEther(selectedToken.balance)) {
9869
9900
  setError("amount", {
9870
9901
  type: "manual",
@@ -9960,9 +9991,22 @@ var SendTokenContent = ({
9960
9991
  validate: (value) => {
9961
9992
  if (!value) return true;
9962
9993
  const numericValue = parseFloat(value);
9963
- return !isNaN(numericValue) || t(
9964
- "Please enter a valid number"
9965
- );
9994
+ if (isNaN(numericValue)) {
9995
+ return t(
9996
+ "Please enter a valid number"
9997
+ );
9998
+ }
9999
+ const minB3tr = feeDelegation?.b3trTransfers?.minAmountInEther;
10000
+ if (selectedToken?.symbol === "B3TR" && typeof minB3tr === "number" && minB3tr > 0 && numericValue < minB3tr) {
10001
+ return t(
10002
+ "Minimum {{symbol}} transfer is {{min}}",
10003
+ {
10004
+ symbol: selectedToken.symbol,
10005
+ min: minB3tr
10006
+ }
10007
+ );
10008
+ }
10009
+ return true;
9966
10010
  }
9967
10011
  }),
9968
10012
  onChange: (e) => {
@@ -10060,8 +10104,7 @@ var SendTokenContent = ({
10060
10104
  color: isDark ? "whiteAlpha.700" : "blackAlpha.700",
10061
10105
  children: [
10062
10106
  /* @__PURE__ */ jsxRuntime.jsxs(react.Text, { opacity: 0.5, children: [
10063
- "\u2248",
10064
- " ",
10107
+ "\u2248 ",
10065
10108
  formattedValue
10066
10109
  ] }),
10067
10110
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -15613,7 +15656,7 @@ var TransactionToast = ({
15613
15656
  }) => {
15614
15657
  const { darkMode: isDark } = useVeChainKitConfig();
15615
15658
  if (!isOpen) return null;
15616
- return /* @__PURE__ */ jsxRuntime.jsx(VechainKitThemeProvider, { darkMode: isDark, children: /* @__PURE__ */ jsxRuntime.jsx(
15659
+ return /* @__PURE__ */ jsxRuntime.jsx(
15617
15660
  react.Box,
15618
15661
  {
15619
15662
  position: "fixed",
@@ -15638,7 +15681,7 @@ var TransactionToast = ({
15638
15681
  }
15639
15682
  )
15640
15683
  }
15641
- ) });
15684
+ );
15642
15685
  };
15643
15686
  var LoginLoadingModal = ({
15644
15687
  isOpen,
@@ -16416,199 +16459,613 @@ var UpgradeSmartAccountModal = ({ isOpen, onClose, style }) => {
16416
16459
  }
16417
16460
  );
16418
16461
  };
16419
- var ModalContext = React10.createContext(null);
16420
- var useModal = () => {
16421
- const context = React10.useContext(ModalContext);
16422
- if (!context) {
16423
- throw new Error("useModal must be used within ModalProvider");
16424
- }
16425
- return context;
16426
- };
16427
- var ModalProvider = ({ children }) => {
16428
- const [isConnectModalOpen, setIsConnectModalOpen] = React10.useState(false);
16429
- const { setSource, connect } = dappKitReact.useWallet();
16430
- const openConnectModal = React10.useCallback(() => {
16431
- if (chunkM6WTSZ5C_cjs.isBrowser() && window.vechain && window.vechain.isInAppBrowser) {
16432
- setSource("veworld");
16433
- connect();
16434
- } else {
16435
- setIsConnectModalOpen(true);
16436
- }
16437
- }, []);
16438
- const closeConnectModal = React10.useCallback(
16439
- () => setIsConnectModalOpen(false),
16440
- []
16441
- );
16442
- const [isAccountModalOpen, setIsAccountModalOpen] = React10.useState(false);
16443
- const openAccountModal = React10.useCallback(
16444
- (content) => {
16445
- setAccountModalContent(content ?? "main");
16446
- setIsAccountModalOpen(true);
16462
+ var { definePartsStyle, defineMultiStyleConfig } = react.createMultiStyleConfigHelpers(anatomy.modalAnatomy.keys);
16463
+ var getModalVariants = (darkMode) => ({
16464
+ vechainKitBase: definePartsStyle({
16465
+ dialog: {
16466
+ scrollbarWidth: "none",
16467
+ overflow: "scroll",
16468
+ overflowX: "hidden",
16469
+ maxHeight: "550px",
16470
+ borderRadius: "24px",
16471
+ backgroundColor: darkMode ? "#1f1f1e" : "white"
16447
16472
  },
16448
- []
16449
- );
16450
- const closeAccountModal = React10.useCallback(
16451
- () => setIsAccountModalOpen(false),
16452
- []
16453
- );
16454
- const [isTransactionModalOpen, setIsTransactionModalOpen] = React10.useState(false);
16455
- const openTransactionModal = React10.useCallback(
16456
- () => setIsTransactionModalOpen(true),
16457
- []
16458
- );
16459
- const closeTransactionModal = React10.useCallback(
16460
- () => setIsTransactionModalOpen(false),
16461
- []
16462
- );
16463
- const [isTransactionToastOpen, setIsTransactionToastOpen] = React10.useState(false);
16464
- const openTransactionToast = React10.useCallback(
16465
- () => setIsTransactionToastOpen(true),
16466
- []
16467
- );
16468
- const closeTransactionToast = React10.useCallback(
16469
- () => setIsTransactionToastOpen(false),
16470
- []
16471
- );
16472
- const [isUpgradeSmartAccountModalOpen, setIsUpgradeSmartAccountModalOpen] = React10.useState(false);
16473
- const [upgradeSmartAccountModalStyle, setUpgradeSmartAccountModalStyle] = React10.useState(void 0);
16474
- const openUpgradeSmartAccountModal = React10.useCallback(
16475
- (style) => {
16476
- setUpgradeSmartAccountModalStyle(style);
16477
- setIsUpgradeSmartAccountModalOpen(true);
16473
+ closeButton: {
16474
+ borderRadius: "50%"
16478
16475
  },
16479
- []
16480
- );
16481
- const closeUpgradeSmartAccountModal = React10.useCallback(
16482
- () => setIsUpgradeSmartAccountModalOpen(false),
16483
- []
16484
- );
16485
- const [accountModalContent, setAccountModalContent] = React10.useState("main");
16486
- return /* @__PURE__ */ jsxRuntime.jsxs(
16487
- ModalContext.Provider,
16488
- {
16489
- value: {
16490
- openConnectModal,
16491
- closeConnectModal,
16492
- isConnectModalOpen,
16493
- openAccountModal,
16494
- closeAccountModal,
16495
- isAccountModalOpen,
16496
- setAccountModalContent,
16497
- accountModalContent,
16498
- openTransactionModal,
16499
- closeTransactionModal,
16500
- isTransactionModalOpen,
16501
- openTransactionToast,
16502
- closeTransactionToast,
16503
- isTransactionToastOpen,
16504
- openUpgradeSmartAccountModal,
16505
- closeUpgradeSmartAccountModal,
16506
- isUpgradeSmartAccountModalOpen
16507
- },
16508
- children: [
16509
- children,
16510
- /* @__PURE__ */ jsxRuntime.jsx(
16511
- ConnectModal,
16512
- {
16513
- isOpen: isConnectModalOpen,
16514
- onClose: closeConnectModal
16515
- }
16516
- ),
16517
- /* @__PURE__ */ jsxRuntime.jsx(
16518
- AccountModal,
16519
- {
16520
- isOpen: isAccountModalOpen,
16521
- onClose: closeAccountModal,
16522
- initialContent: accountModalContent
16523
- }
16524
- ),
16525
- /* @__PURE__ */ jsxRuntime.jsx(
16526
- UpgradeSmartAccountModal,
16527
- {
16528
- isOpen: isUpgradeSmartAccountModalOpen,
16529
- onClose: closeUpgradeSmartAccountModal,
16530
- style: upgradeSmartAccountModalStyle
16531
- }
16532
- )
16533
- ]
16476
+ header: {
16477
+ w: "full",
16478
+ color: darkMode ? "#dfdfdd" : "#2e2e2e",
16479
+ fontSize: "md",
16480
+ fontWeight: "700",
16481
+ textAlign: "center"
16534
16482
  }
16535
- );
16536
- };
16537
- var useConnectModal = () => {
16538
- const { loginMethods } = useVeChainKitConfig();
16539
- const hasOnlyDappKit = loginMethods?.length === 1 && loginMethods[0].method === "dappkit";
16540
- const { openConnectModal, closeConnectModal, isConnectModalOpen } = useModal();
16541
- const { open: openDappKit, close: closeDappKit } = dappKitReact.useWalletModal();
16542
- return {
16543
- open: hasOnlyDappKit ? openDappKit : openConnectModal,
16544
- close: hasOnlyDappKit ? closeDappKit : closeConnectModal,
16545
- isOpen: hasOnlyDappKit ? false : isConnectModalOpen
16546
- };
16547
- };
16548
- var ConnectModalProvider = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
16549
- var useAccountModal = () => {
16550
- const {
16551
- openAccountModal: open,
16552
- closeAccountModal: close,
16553
- isAccountModalOpen: isOpen
16554
- } = useModal();
16555
- return { open: () => open(), close, isOpen };
16556
- };
16557
- var AccountModalProvider = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
16558
- var useTransactionModal = () => {
16559
- const {
16560
- openTransactionModal: open,
16561
- closeTransactionModal: close,
16562
- isTransactionModalOpen: isOpen
16563
- } = useModal();
16564
- return { open, close, isOpen };
16565
- };
16566
- var TransactionModalProvider = ({
16567
- children
16568
- }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
16569
- var useTransactionToast = () => {
16570
- const {
16571
- openTransactionToast: open,
16572
- closeTransactionToast: close,
16573
- isTransactionToastOpen: isOpen
16574
- } = useModal();
16575
- return { open, close, isOpen };
16576
- };
16577
- var TransactionToastProvider = ({
16578
- children
16579
- }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
16580
- var useWalletModal2 = () => {
16581
- const { connection } = useWallet();
16582
- const {
16583
- openConnectModal,
16584
- closeConnectModal,
16585
- isConnectModalOpen,
16586
- openAccountModal,
16587
- closeAccountModal,
16588
- isAccountModalOpen
16589
- } = useModal();
16590
- const open = () => {
16591
- if (connection.isConnected) {
16592
- openAccountModal();
16593
- } else {
16594
- openConnectModal();
16483
+ })
16484
+ });
16485
+ var getModalTheme = (darkMode) => defineMultiStyleConfig({
16486
+ variants: getModalVariants(darkMode),
16487
+ defaultProps: {
16488
+ variant: "vechainKitBase"
16489
+ }
16490
+ });
16491
+ var { definePartsStyle: definePartsStyle2, defineMultiStyleConfig: defineMultiStyleConfig2 } = react.createMultiStyleConfigHelpers(anatomy.cardAnatomy.keys);
16492
+ var getCardVariants = (darkMode) => ({
16493
+ vechainKitBase: definePartsStyle2({
16494
+ container: {
16495
+ backgroundColor: darkMode ? "#1c1c1b" : "#f5f5f5",
16496
+ borderRadius: "14px",
16497
+ width: "full",
16498
+ border: "none"
16499
+ },
16500
+ body: {
16501
+ p: 5,
16502
+ width: "full"
16503
+ },
16504
+ header: {
16505
+ p: 5,
16506
+ width: "full",
16507
+ borderRadius: "14px 14px 0 0"
16508
+ },
16509
+ footer: {
16510
+ width: "full",
16511
+ borderRadius: "0 0 14px 14px"
16595
16512
  }
16596
- };
16597
- const close = () => {
16598
- if (isAccountModalOpen) {
16599
- closeAccountModal();
16513
+ }),
16514
+ featureAnnouncement: definePartsStyle2({
16515
+ body: {
16516
+ backgroundColor: darkMode ? "#ffffff0a" : "blackAlpha.50",
16517
+ borderRadius: "12px",
16518
+ color: darkMode ? "#ffffff12" : "blackAlpha.200"
16519
+ },
16520
+ container: {
16521
+ borderRadius: "12px",
16522
+ backgroundColor: "transparent"
16600
16523
  }
16601
- if (isConnectModalOpen) {
16602
- closeConnectModal();
16524
+ }),
16525
+ vechainKitAppCard: definePartsStyle2({
16526
+ body: {
16527
+ height: "full",
16528
+ borderRadius: "12px",
16529
+ backgroundColor: darkMode ? "#1f1f1e" : "white",
16530
+ border: darkMode ? "1px solid #2d2d2d" : "1px solid #eaeaea"
16531
+ },
16532
+ container: {
16533
+ height: "150px",
16534
+ borderRadius: "12px",
16535
+ backgroundColor: "transparent"
16603
16536
  }
16604
- };
16605
- const isOpen = isConnectModalOpen || isAccountModalOpen;
16606
- return { open, close, isOpen };
16607
- };
16608
- var WalletModalProvider = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
16609
- var useChooseNameModal = () => {
16610
- const {
16611
- openAccountModal,
16537
+ })
16538
+ });
16539
+ var getCardTheme = (darkMode) => defineMultiStyleConfig2({
16540
+ variants: getCardVariants(darkMode),
16541
+ defaultProps: {
16542
+ variant: "vechainKitBase"
16543
+ // default is solid
16544
+ }
16545
+ });
16546
+ var baseStyle = react.defineStyle({
16547
+ borderRadius: "12px"
16548
+ });
16549
+ var variants = {
16550
+ loginIn: react.defineStyle(() => ({
16551
+ bg: "white",
16552
+ color: "#1a1a1a",
16553
+ fontSize: "14px",
16554
+ fontWeight: "400",
16555
+ border: "1px solid #ebebeb",
16556
+ py: 6,
16557
+ px: 3,
16558
+ borderRadius: 16,
16559
+ _hover: {
16560
+ bg: "#eaeaea"
16561
+ },
16562
+ _dark: {
16563
+ bg: "transparent",
16564
+ color: "white",
16565
+ _hover: {
16566
+ bg: "#2a2a2a"
16567
+ },
16568
+ border: "1px solid #ffffff1a"
16569
+ }
16570
+ })),
16571
+ loginWithVechain: react.defineStyle(() => ({
16572
+ bg: "#1a1a1a",
16573
+ color: "white",
16574
+ fontSize: "14px",
16575
+ fontWeight: "400",
16576
+ py: 6,
16577
+ px: 3,
16578
+ borderRadius: 16,
16579
+ border: "1px solid #5e5e5e",
16580
+ _hover: {
16581
+ bg: "#2a2a2a"
16582
+ },
16583
+ _dark: {
16584
+ bg: "white",
16585
+ color: "#1a1a1a",
16586
+ _hover: {
16587
+ bg: "#eaeaea"
16588
+ },
16589
+ border: "1px solid #ffffff1a"
16590
+ },
16591
+ transition: "all 0.2s"
16592
+ })),
16593
+ vechainKitSelector: react.defineStyle(({ colorMode }) => ({
16594
+ bg: "transparent",
16595
+ border: `1px solid ${colorMode === "dark" ? "#ffffff29" : "#ebebeb"}`,
16596
+ _hover: {
16597
+ borderColor: colorMode === "dark" ? "#ffffff50" : "#dedede",
16598
+ bg: colorMode === "dark" ? "whiteAlpha.50" : "blackAlpha.50"
16599
+ },
16600
+ _active: {
16601
+ transform: "scale(0.98)"
16602
+ },
16603
+ transition: "all 0.2s"
16604
+ })),
16605
+ vechainKitPrimary: react.defineStyle(() => ({
16606
+ fontSize: "md",
16607
+ px: 4,
16608
+ width: "full",
16609
+ height: "60px",
16610
+ borderRadius: "xl",
16611
+ bg: "#2B6CB0",
16612
+ color: "white",
16613
+ _hover: {
16614
+ bg: "#2C5282",
16615
+ _disabled: {
16616
+ bg: "#2B6CB0"
16617
+ }
16618
+ },
16619
+ _dark: {
16620
+ bg: "#3182CE",
16621
+ _hover: {
16622
+ bg: "#2B6CB0"
16623
+ }
16624
+ },
16625
+ transition: "all 0.2s"
16626
+ })),
16627
+ vechainKitSecondary: react.defineStyle(({ colorMode }) => ({
16628
+ fontSize: "md",
16629
+ px: 4,
16630
+ width: "full",
16631
+ height: "60px",
16632
+ borderRadius: "xl",
16633
+ backgroundColor: colorMode === "dark" ? "#ffffff0a" : "blackAlpha.50",
16634
+ _hover: {
16635
+ backgroundColor: colorMode === "dark" ? "#ffffff12" : "blackAlpha.200"
16636
+ },
16637
+ border: "1px solid",
16638
+ borderColor: "gray.200",
16639
+ color: "blackAlpha.900",
16640
+ _dark: {
16641
+ borderColor: "whiteAlpha.200",
16642
+ color: "whiteAlpha.900"
16643
+ },
16644
+ transition: "all 0.2s"
16645
+ })),
16646
+ vechainKitLogout: react.defineStyle(({ colorMode }) => ({
16647
+ width: "full",
16648
+ minHeight: "50px",
16649
+ height: "fit-content",
16650
+ borderRadius: "xl",
16651
+ p: 0,
16652
+ backgroundColor: colorMode === "dark" ? "rgba(254, 178, 178, 0.12)" : "red.50",
16653
+ _hover: {
16654
+ backgroundColor: colorMode === "dark" ? "rgba(254, 178, 178, 0.37)" : "red.200",
16655
+ color: colorMode === "dark" ? "red.50" : "red.900"
16656
+ },
16657
+ transition: "all 0.2s",
16658
+ color: colorMode === "dark" ? "red.200" : "red.900"
16659
+ })),
16660
+ mainContentButton: react.defineStyle(({ colorMode }) => ({
16661
+ width: "100%",
16662
+ backgroundColor: colorMode === "dark" ? "#ffffff0a" : "blackAlpha.50",
16663
+ borderRadius: "xl",
16664
+ p: 3,
16665
+ cursor: "pointer",
16666
+ _hover: {
16667
+ backgroundColor: colorMode === "dark" ? "#ffffff12" : "blackAlpha.200"
16668
+ }
16669
+ })),
16670
+ actionButton: react.defineStyle(({ colorMode }) => ({
16671
+ width: "full",
16672
+ minHeight: "50px",
16673
+ height: "fit-content",
16674
+ backgroundColor: colorMode === "dark" ? "#ffffff0a" : "blackAlpha.50",
16675
+ borderRadius: "xl",
16676
+ p: 0,
16677
+ _hover: {
16678
+ backgroundColor: colorMode === "dark" ? "#ffffff12" : "blackAlpha.200"
16679
+ },
16680
+ transition: "all 0.2s"
16681
+ }))
16682
+ };
16683
+ var buttonTheme = react.defineStyleConfig({
16684
+ baseStyle,
16685
+ variants
16686
+ });
16687
+ var { definePartsStyle: definePartsStyle3, defineMultiStyleConfig: defineMultiStyleConfig3 } = react.createMultiStyleConfigHelpers(anatomy.popoverAnatomy.keys);
16688
+ var getPopoverVariants = (darkMode) => ({
16689
+ vechainKitBase: definePartsStyle3({
16690
+ popper: {
16691
+ zIndex: 1e3
16692
+ },
16693
+ content: {
16694
+ borderRadius: "24px",
16695
+ border: "none",
16696
+ backgroundColor: darkMode ? "#1f1f1e" : "white",
16697
+ boxShadow: "0px 4px 16px rgba(0, 0, 0, 0.12)",
16698
+ minWidth: "380px"
16699
+ },
16700
+ body: {
16701
+ padding: "16px"
16702
+ }
16703
+ })
16704
+ });
16705
+ var getPopoverTheme = (darkMode) => defineMultiStyleConfig3({
16706
+ variants: getPopoverVariants(darkMode),
16707
+ defaultProps: {
16708
+ variant: "vechainKitBase"
16709
+ }
16710
+ });
16711
+
16712
+ // src/theme/theme.tsx
16713
+ var getThemeConfig = (darkMode) => ({
16714
+ useSystemColorMode: false,
16715
+ disableTransitionOnChange: false,
16716
+ // @ts-ignore
16717
+ components: {
16718
+ Modal: getModalTheme(darkMode),
16719
+ Card: getCardTheme(darkMode),
16720
+ Button: buttonTheme,
16721
+ Popover: getPopoverTheme(darkMode)
16722
+ },
16723
+ // COMPLETELY disable global styles to prevent any conflicts
16724
+ styles: {
16725
+ global: () => ({})
16726
+ // empty object = no global styles injected
16727
+ },
16728
+ // only defining the semantic tokens we need, scoped to our components
16729
+ semanticTokens: {
16730
+ colors: {
16731
+ "chakra-body-text": {
16732
+ _light: "#1A202C",
16733
+ _dark: "#F7FAFC"
16734
+ },
16735
+ "chakra-body-bg": {
16736
+ _light: "#FFFFFF",
16737
+ _dark: "#1A202C"
16738
+ },
16739
+ "chakra-border-color": {
16740
+ _light: "#E2E8F0",
16741
+ _dark: "#2D3748"
16742
+ },
16743
+ "chakra-placeholder-color": {
16744
+ _light: "#A0AEC0",
16745
+ _dark: "#718096"
16746
+ }
16747
+ },
16748
+ config: {
16749
+ cssVarPrefix: "vechain-kit"
16750
+ // consistent naming across all components
16751
+ }
16752
+ },
16753
+ // minimal foundations to prevent global style injection
16754
+ fonts: react.theme.fonts,
16755
+ colors: react.theme.colors,
16756
+ space: react.theme.space
16757
+ });
16758
+ var getVechainKitTheme = (darkMode) => {
16759
+ const theme = react.extendTheme(getThemeConfig(darkMode));
16760
+ theme.styles.global = () => ({});
16761
+ if (theme.__cssVars) {
16762
+ theme.__cssVars.global = () => ({});
16763
+ }
16764
+ return theme;
16765
+ };
16766
+ var { ToastContainer } = react.createStandaloneToast();
16767
+ var createVeChainKitCache = () => {
16768
+ return createCache__default.default({
16769
+ key: "vechain-kit",
16770
+ // consistent with our layer and class names
16771
+ prepend: true
16772
+ // CSS layers will be handled via Global component injection
16773
+ });
16774
+ };
16775
+ var LayerSetup = () => {
16776
+ return /* @__PURE__ */ jsxRuntime.jsx(
16777
+ react$1.Global,
16778
+ {
16779
+ styles: react$1.css`
16780
+ /* define CSS layers with proper priority order */
16781
+ @layer vechain-kit, host-app;
16782
+
16783
+ /* All vechain-kit styles go in the vechain-kit layer */
16784
+ @layer vechain-kit {
16785
+ /* scope all Chakra styles to vechain-kit-root */
16786
+ .vechain-kit-root {
16787
+ /* vechain-kit styles are contained here */
16788
+ }
16789
+ }
16790
+ `
16791
+ }
16792
+ );
16793
+ };
16794
+ var EnsureChakraProvider = ({
16795
+ children,
16796
+ theme
16797
+ }) => {
16798
+ const cache = React10.useMemo(() => createVeChainKitCache(), []);
16799
+ return /* @__PURE__ */ jsxRuntime.jsxs(react$1.CacheProvider, { value: cache, children: [
16800
+ /* @__PURE__ */ jsxRuntime.jsx(LayerSetup, {}),
16801
+ /* @__PURE__ */ jsxRuntime.jsx(
16802
+ react.ChakraProvider,
16803
+ {
16804
+ theme,
16805
+ resetCSS: false,
16806
+ portalZIndex: void 0,
16807
+ children
16808
+ }
16809
+ )
16810
+ ] });
16811
+ };
16812
+ var EnsureColorModeScript = ({ darkMode }) => {
16813
+ try {
16814
+ const existingScript = chunkM6WTSZ5C_cjs.safeQuerySelector("[data-chakra-color-mode]");
16815
+ if (existingScript) {
16816
+ return null;
16817
+ }
16818
+ } catch (e) {
16819
+ console.error(e);
16820
+ }
16821
+ return /* @__PURE__ */ jsxRuntime.jsx(react.ColorModeScript, { initialColorMode: darkMode ? "dark" : "light" });
16822
+ };
16823
+ var VechainKitThemeContext = React10.createContext({
16824
+ portalRootRef: void 0
16825
+ });
16826
+ var useVechainKitThemeConfig = () => {
16827
+ const context = React10.useContext(VechainKitThemeContext);
16828
+ if (!context) {
16829
+ throw new Error(
16830
+ "useVechainKitTheme must be used within a VechainKitThemeProvider"
16831
+ );
16832
+ }
16833
+ return context;
16834
+ };
16835
+ var VechainKitThemeProvider = ({
16836
+ children,
16837
+ darkMode = false
16838
+ }) => {
16839
+ const portalRootRef = React10.useRef(null);
16840
+ const theme = React10.useMemo(
16841
+ () => ({
16842
+ ...getVechainKitTheme(darkMode),
16843
+ config: {
16844
+ ...getVechainKitTheme(darkMode).config,
16845
+ initialColorMode: darkMode ? "dark" : "light"
16846
+ }
16847
+ }),
16848
+ [darkMode]
16849
+ );
16850
+ return /* @__PURE__ */ jsxRuntime.jsxs(VechainKitThemeContext.Provider, { value: { portalRootRef }, children: [
16851
+ /* @__PURE__ */ jsxRuntime.jsx(EnsureColorModeScript, { darkMode }),
16852
+ /* @__PURE__ */ jsxRuntime.jsx(EnsureChakraProvider, { theme, children: /* @__PURE__ */ jsxRuntime.jsx(
16853
+ react.Box,
16854
+ {
16855
+ id: "vechain-kit-root",
16856
+ ref: portalRootRef,
16857
+ bg: "transparent",
16858
+ borderRadius: "12px",
16859
+ sx: {
16860
+ bg: darkMode ? "#1A202C" : "#FFFFFF",
16861
+ color: darkMode ? "#F7FAFC" : "#1A202C",
16862
+ borderColor: darkMode ? "#2D3748" : "#E2E8F0",
16863
+ "input::placeholder": {
16864
+ color: darkMode ? "#718096" : "#A0AEC0"
16865
+ }
16866
+ },
16867
+ children
16868
+ }
16869
+ ) }),
16870
+ /* @__PURE__ */ jsxRuntime.jsx(ToastContainer, {})
16871
+ ] });
16872
+ };
16873
+ var ModalContext = React10.createContext(null);
16874
+ var useModal = () => {
16875
+ const context = React10.useContext(ModalContext);
16876
+ if (!context) {
16877
+ throw new Error("useModal must be used within ModalProvider");
16878
+ }
16879
+ return context;
16880
+ };
16881
+ var ModalProvider = ({ children }) => {
16882
+ const { darkMode } = useVeChainKitConfig();
16883
+ const [isConnectModalOpen, setIsConnectModalOpen] = React10.useState(false);
16884
+ const { setSource, connect } = dappKitReact.useWallet();
16885
+ const openConnectModal = React10.useCallback(() => {
16886
+ if (chunkM6WTSZ5C_cjs.isBrowser() && window.vechain && window.vechain.isInAppBrowser) {
16887
+ setSource("veworld");
16888
+ connect();
16889
+ } else {
16890
+ setIsConnectModalOpen(true);
16891
+ }
16892
+ }, []);
16893
+ const closeConnectModal = React10.useCallback(
16894
+ () => setIsConnectModalOpen(false),
16895
+ []
16896
+ );
16897
+ const [isAccountModalOpen, setIsAccountModalOpen] = React10.useState(false);
16898
+ const openAccountModal = React10.useCallback(
16899
+ (content) => {
16900
+ setAccountModalContent(content ?? "main");
16901
+ setIsAccountModalOpen(true);
16902
+ },
16903
+ []
16904
+ );
16905
+ const closeAccountModal = React10.useCallback(
16906
+ () => setIsAccountModalOpen(false),
16907
+ []
16908
+ );
16909
+ const [isTransactionModalOpen, setIsTransactionModalOpen] = React10.useState(false);
16910
+ const openTransactionModal = React10.useCallback(
16911
+ () => setIsTransactionModalOpen(true),
16912
+ []
16913
+ );
16914
+ const closeTransactionModal = React10.useCallback(
16915
+ () => setIsTransactionModalOpen(false),
16916
+ []
16917
+ );
16918
+ const [isTransactionToastOpen, setIsTransactionToastOpen] = React10.useState(false);
16919
+ const openTransactionToast = React10.useCallback(
16920
+ () => setIsTransactionToastOpen(true),
16921
+ []
16922
+ );
16923
+ const closeTransactionToast = React10.useCallback(
16924
+ () => setIsTransactionToastOpen(false),
16925
+ []
16926
+ );
16927
+ const [isUpgradeSmartAccountModalOpen, setIsUpgradeSmartAccountModalOpen] = React10.useState(false);
16928
+ const [upgradeSmartAccountModalStyle, setUpgradeSmartAccountModalStyle] = React10.useState(void 0);
16929
+ const openUpgradeSmartAccountModal = React10.useCallback(
16930
+ (style) => {
16931
+ setUpgradeSmartAccountModalStyle(style);
16932
+ setIsUpgradeSmartAccountModalOpen(true);
16933
+ },
16934
+ []
16935
+ );
16936
+ const closeUpgradeSmartAccountModal = React10.useCallback(
16937
+ () => setIsUpgradeSmartAccountModalOpen(false),
16938
+ []
16939
+ );
16940
+ const [accountModalContent, setAccountModalContent] = React10.useState("main");
16941
+ return /* @__PURE__ */ jsxRuntime.jsxs(
16942
+ ModalContext.Provider,
16943
+ {
16944
+ value: {
16945
+ openConnectModal,
16946
+ closeConnectModal,
16947
+ isConnectModalOpen,
16948
+ openAccountModal,
16949
+ closeAccountModal,
16950
+ isAccountModalOpen,
16951
+ setAccountModalContent,
16952
+ accountModalContent,
16953
+ openTransactionModal,
16954
+ closeTransactionModal,
16955
+ isTransactionModalOpen,
16956
+ openTransactionToast,
16957
+ closeTransactionToast,
16958
+ isTransactionToastOpen,
16959
+ openUpgradeSmartAccountModal,
16960
+ closeUpgradeSmartAccountModal,
16961
+ isUpgradeSmartAccountModalOpen
16962
+ },
16963
+ children: [
16964
+ children,
16965
+ /* @__PURE__ */ jsxRuntime.jsxs(VechainKitThemeProvider, { darkMode, children: [
16966
+ /* @__PURE__ */ jsxRuntime.jsx(
16967
+ ConnectModal,
16968
+ {
16969
+ isOpen: isConnectModalOpen,
16970
+ onClose: closeConnectModal
16971
+ }
16972
+ ),
16973
+ /* @__PURE__ */ jsxRuntime.jsx(
16974
+ AccountModal,
16975
+ {
16976
+ isOpen: isAccountModalOpen,
16977
+ onClose: closeAccountModal,
16978
+ initialContent: accountModalContent
16979
+ }
16980
+ ),
16981
+ /* @__PURE__ */ jsxRuntime.jsx(
16982
+ UpgradeSmartAccountModal,
16983
+ {
16984
+ isOpen: isUpgradeSmartAccountModalOpen,
16985
+ onClose: closeUpgradeSmartAccountModal,
16986
+ style: upgradeSmartAccountModalStyle
16987
+ }
16988
+ )
16989
+ ] })
16990
+ ]
16991
+ }
16992
+ );
16993
+ };
16994
+ var useConnectModal = () => {
16995
+ const { loginMethods } = useVeChainKitConfig();
16996
+ const hasOnlyDappKit = loginMethods?.length === 1 && loginMethods[0].method === "dappkit";
16997
+ const { openConnectModal, closeConnectModal, isConnectModalOpen } = useModal();
16998
+ const { open: openDappKit, close: closeDappKit } = dappKitReact.useWalletModal();
16999
+ return {
17000
+ open: hasOnlyDappKit ? openDappKit : openConnectModal,
17001
+ close: hasOnlyDappKit ? closeDappKit : closeConnectModal,
17002
+ isOpen: hasOnlyDappKit ? false : isConnectModalOpen
17003
+ };
17004
+ };
17005
+ var ConnectModalProvider = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
17006
+ var useAccountModal = () => {
17007
+ const {
17008
+ openAccountModal: open,
17009
+ closeAccountModal: close,
17010
+ isAccountModalOpen: isOpen
17011
+ } = useModal();
17012
+ return { open: () => open(), close, isOpen };
17013
+ };
17014
+ var AccountModalProvider = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
17015
+ var useTransactionModal = () => {
17016
+ const {
17017
+ openTransactionModal: open,
17018
+ closeTransactionModal: close,
17019
+ isTransactionModalOpen: isOpen
17020
+ } = useModal();
17021
+ return { open, close, isOpen };
17022
+ };
17023
+ var TransactionModalProvider = ({
17024
+ children
17025
+ }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
17026
+ var useTransactionToast = () => {
17027
+ const {
17028
+ openTransactionToast: open,
17029
+ closeTransactionToast: close,
17030
+ isTransactionToastOpen: isOpen
17031
+ } = useModal();
17032
+ return { open, close, isOpen };
17033
+ };
17034
+ var TransactionToastProvider = ({
17035
+ children
17036
+ }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
17037
+ var useWalletModal2 = () => {
17038
+ const { connection } = useWallet();
17039
+ const {
17040
+ openConnectModal,
17041
+ closeConnectModal,
17042
+ isConnectModalOpen,
17043
+ openAccountModal,
17044
+ closeAccountModal,
17045
+ isAccountModalOpen
17046
+ } = useModal();
17047
+ const open = () => {
17048
+ if (connection.isConnected) {
17049
+ openAccountModal();
17050
+ } else {
17051
+ openConnectModal();
17052
+ }
17053
+ };
17054
+ const close = () => {
17055
+ if (isAccountModalOpen) {
17056
+ closeAccountModal();
17057
+ }
17058
+ if (isConnectModalOpen) {
17059
+ closeConnectModal();
17060
+ }
17061
+ };
17062
+ const isOpen = isConnectModalOpen || isAccountModalOpen;
17063
+ return { open, close, isOpen };
17064
+ };
17065
+ var WalletModalProvider = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
17066
+ var useChooseNameModal = () => {
17067
+ const {
17068
+ openAccountModal,
16612
17069
  closeAccountModal,
16613
17070
  isAccountModalOpen,
16614
17071
  setAccountModalContent
@@ -19167,7 +19624,7 @@ var useLegalDocuments = () => {
19167
19624
  };
19168
19625
  var LegalDocumentsProvider = ({ children }) => {
19169
19626
  const { connection, account, disconnect } = useWallet();
19170
- const { legalDocuments } = useVeChainKitConfig();
19627
+ const { darkMode, legalDocuments } = useVeChainKitConfig();
19171
19628
  const [storedAgreements, setStoredAgreements] = useSyncableLocalStorage(LEGAL_DOCS_LOCAL_STORAGE_KEY, []);
19172
19629
  const [optionalRejected, setOptionalRejected] = useSyncableLocalStorage(LEGAL_DOCS_OPTIONAL_REJECT_LOCAL_STORAGE_KEY, []);
19173
19630
  const [showTermsModal, setShowTermsModal] = React10.useState(false);
@@ -19355,7 +19812,7 @@ var LegalDocumentsProvider = ({ children }) => {
19355
19812
  },
19356
19813
  children: [
19357
19814
  children,
19358
- /* @__PURE__ */ jsxRuntime.jsx(
19815
+ /* @__PURE__ */ jsxRuntime.jsx(VechainKitThemeProvider, { darkMode, children: /* @__PURE__ */ jsxRuntime.jsx(
19359
19816
  LegalDocumentsModal,
19360
19817
  {
19361
19818
  isOpen: showTermsModal,
@@ -19364,7 +19821,7 @@ var LegalDocumentsProvider = ({ children }) => {
19364
19821
  } : handleLogout,
19365
19822
  onlyOptionalDocuments
19366
19823
  }
19367
- )
19824
+ ) })
19368
19825
  ]
19369
19826
  }
19370
19827
  );
@@ -19604,756 +20061,358 @@ var PrivyWalletProvider = ({
19604
20061
  // set the Privy wallet address as the owner of the smart account
19605
20062
  )
19606
20063
  );
19607
- }
19608
- dataToSign.forEach((data, index) => {
19609
- clauses.push(
19610
- sdkCore.Clause.callFunction(
19611
- sdkCore.Address.of(smartAccount.address ?? ""),
19612
- sdkCore.ABIContract.ofAbi(chunkEESC6JDT_cjs.SimpleAccountABI).getFunction(
19613
- "executeWithAuthorization"
19614
- ),
19615
- [
19616
- data.message.to,
19617
- BigInt(data.message.value),
19618
- data.message.data,
19619
- BigInt(data.message.validAfter),
19620
- BigInt(data.message.validBefore),
19621
- signatures[index]
19622
- ]
19623
- )
19624
- );
19625
- });
19626
- }
19627
- const gasResult = await thor.gas.estimateGas(
19628
- clauses,
19629
- connectedWallet.address ?? "",
19630
- {
19631
- gasPadding: 1
19632
- }
19633
- );
19634
- const parsedGasLimit = Math.max(
19635
- gasResult.totalGas,
19636
- suggestedMaxGas ?? 0
19637
- );
19638
- const txBody = await thor.transactions.buildTransactionBody(
19639
- clauses,
19640
- parsedGasLimit,
19641
- { isDelegated: true }
19642
- );
19643
- const wallet = new sdkNetwork.ProviderInternalBaseWallet(
19644
- [
19645
- {
19646
- privateKey: Buffer.from(
19647
- chunkM6WTSZ5C_cjs.randomTransactionUser.privateKey.slice(2),
19648
- "hex"
19649
- ),
19650
- address: chunkM6WTSZ5C_cjs.randomTransactionUser.address
19651
- }
19652
- ],
19653
- { gasPayer: { gasPayerServiceUrl: delegatorUrl } }
19654
- );
19655
- const providerWithDelegationEnabled = new sdkNetwork.VeChainProvider(
19656
- thor,
19657
- wallet,
19658
- true
19659
- );
19660
- const signer = await providerWithDelegationEnabled.getSigner(
19661
- chunkM6WTSZ5C_cjs.randomTransactionUser.address
19662
- );
19663
- const txInput = sdkNetwork.signerUtils.transactionBodyToTransactionRequestInput(
19664
- txBody,
19665
- chunkM6WTSZ5C_cjs.randomTransactionUser.address
19666
- );
19667
- const rawDelegateSigned = await signer.signTransaction(txInput);
19668
- const { id } = await fetch(`${nodeUrl}/transactions`, {
19669
- method: "POST",
19670
- headers: {
19671
- "content-type": "application/json"
19672
- },
19673
- body: JSON.stringify({
19674
- raw: rawDelegateSigned
19675
- })
19676
- }).then((res) => res.json());
19677
- return id;
19678
- };
19679
- const signMessage = async (message) => {
19680
- if (connection.isConnectedWithCrossApp) {
19681
- return await signMessageWithCrossApp(message);
19682
- }
19683
- return (await signMessagePrivy({
19684
- message
19685
- })).signature;
19686
- };
19687
- const signTypedData = async (data) => {
19688
- if (connection.isConnectedWithCrossApp) {
19689
- const mutableData = {
19690
- ...data,
19691
- address: connectedWallet?.address,
19692
- types: Object.fromEntries(
19693
- Object.entries(data.types).map(([k, v]) => [k, [...v]])
19694
- )
19695
- };
19696
- return await signTypedDataWithCrossApp(mutableData);
19697
- }
19698
- return (await signTypedDataPrivy(data)).signature;
19699
- };
19700
- return /* @__PURE__ */ jsxRuntime.jsx(
19701
- PrivyWalletProviderContext.Provider,
19702
- {
19703
- value: {
19704
- accountFactory: chunkM6WTSZ5C_cjs.getConfig(network.type).accountFactoryAddress,
19705
- sendTransaction,
19706
- signMessage,
19707
- signTypedData,
19708
- exportWallet,
19709
- delegateAllTransactions
19710
- },
19711
- children
19712
- }
19713
- );
19714
- };
19715
- var usePrivyWalletProvider = () => {
19716
- const context = React10.useContext(PrivyWalletProviderContext);
19717
- if (!context) {
19718
- throw new Error(
19719
- "usePrivyWalletProvider must be used within a PrivyWalletProvider"
19720
- );
19721
- }
19722
- return context;
19723
- };
19724
- var VeChainKitContext = React10.createContext(null);
19725
- var useVeChainKitConfig = () => {
19726
- const context = React10.useContext(VeChainKitContext);
19727
- if (!context) {
19728
- throw new Error("useVeChainKitConfig must be used within VeChainKit");
19729
- }
19730
- return context;
19731
- };
19732
- var validateConfig = (props) => {
19733
- const errors = [];
19734
- const requiresFeeDelegation = props.privy !== void 0 || props.loginMethods?.some(
19735
- (method7) => method7.method === "vechain" || method7.method === "ecosystem"
19736
- );
19737
- if (requiresFeeDelegation) {
19738
- if (!props.feeDelegation) {
19739
- errors.push(
19740
- "feeDelegation configuration is required when using Privy or vechain login method"
19741
- );
19742
- } else {
19743
- if (!props.feeDelegation || !props.feeDelegation.delegatorUrl) {
19744
- errors.push(
19745
- "feeDelegation.delegatorUrl is required when using Privy or vechain login method"
19746
- );
19747
- }
19748
- }
19749
- }
19750
- if (!props.network) {
19751
- errors.push("network configuration is required");
19752
- } else {
19753
- if (!props.network.type) {
19754
- errors.push("network.type is required");
19755
- }
19756
- if (!["main", "test", "solo"].includes(props.network.type)) {
19757
- errors.push('network.type must be either "main", "test" or "solo"');
19758
- }
19759
- }
19760
- if (props.loginMethods) {
19761
- if (!props.privy) {
19762
- const invalidMethods = props.loginMethods.filter(
19763
- (method7) => ["email", "google", "passkey", "more"].includes(method7.method)
19764
- );
19765
- if (invalidMethods.length > 0) {
19766
- errors.push(
19767
- `Login methods ${invalidMethods.map((m) => `"${m.method}"`).join(", ")} require Privy configuration. Please either remove these methods or configure the privy prop.`
19768
- );
19769
- }
19770
- }
19771
- }
19772
- if (props?.legalDocuments) {
19773
- if (props.legalDocuments.termsAndConditions) {
19774
- props.legalDocuments.termsAndConditions.forEach((term) => {
19775
- if (!chunkM6WTSZ5C_cjs.isValidUrl(term.url)) {
19776
- errors.push(
19777
- `legalDocuments.termsAndConditions.url is invalid: ${term.url}`
19778
- );
19779
- }
19780
- });
19781
- }
19782
- if (props.legalDocuments.privacyPolicy) {
19783
- props.legalDocuments.privacyPolicy.forEach((term) => {
19784
- if (!chunkM6WTSZ5C_cjs.isValidUrl(term.url)) {
19785
- errors.push(
19786
- `legalDocuments.privacyPolicy.url is invalid: ${term.url}`
19787
- );
19788
- }
19789
- });
19790
- }
19791
- if (props.legalDocuments.cookiePolicy) {
19792
- props.legalDocuments.cookiePolicy.forEach((term) => {
19793
- if (!chunkM6WTSZ5C_cjs.isValidUrl(term.url)) {
19794
- errors.push(
19795
- `legalDocuments.cookiePolicy.url is invalid: ${term.url}`
19796
- );
19797
- }
19798
- });
19799
- }
19800
- }
19801
- if (errors.length > 0) {
19802
- throw new Error(
19803
- "VeChainKit Configuration Error:\n" + errors.join("\n")
19804
- );
19805
- }
19806
- return props;
19807
- };
19808
- var VeChainKitProvider = (props) => {
19809
- const validatedProps = validateConfig(props);
19810
- const {
19811
- children,
19812
- privy,
19813
- feeDelegation,
19814
- dappKit,
19815
- loginModalUI,
19816
- loginMethods,
19817
- darkMode = false,
19818
- i18n: i18nConfig,
19819
- language = "en",
19820
- network,
19821
- allowCustomTokens,
19822
- legalDocuments,
19823
- defaultCurrency = "usd"
19824
- } = validatedProps;
19825
- const validatedLoginMethods = loginMethods;
19826
- const allowedEcosystemApps = React10.useMemo(() => {
19827
- const userEcosystemMethods = validatedLoginMethods?.find(
19828
- (method7) => method7.method === "ecosystem"
19829
- );
19830
- return userEcosystemMethods?.allowedApps ?? chunkM6WTSZ5C_cjs.DEFAULT_PRIVY_ECOSYSTEM_APPS.map((app) => app.id);
19831
- }, [validatedLoginMethods]);
19832
- let privyAppId, privyClientId;
19833
- if (!privy) {
19834
- privyAppId = "clzdb5k0b02b9qvzjm6jpknsc";
19835
- privyClientId = "client-WY2oy87y6KNrHFnpXuwVsiFMkwPZKTYpExtjvUQuMbCMF";
19836
- } else {
19837
- privyAppId = privy.appId;
19838
- privyClientId = privy.clientId;
19839
- }
19840
- React10.useEffect(() => {
19841
- initializeI18n(i18n_default);
19842
- if (language) {
19843
- i18n_default.changeLanguage(language);
19844
- }
19845
- if (i18nConfig) {
19846
- Object.keys(i18nConfig).forEach((lang) => {
19847
- i18n_default.addResourceBundle(
19848
- lang,
19849
- "translation",
19850
- i18nConfig[lang],
19851
- true,
19852
- true
19853
- );
20064
+ }
20065
+ dataToSign.forEach((data, index) => {
20066
+ clauses.push(
20067
+ sdkCore.Clause.callFunction(
20068
+ sdkCore.Address.of(smartAccount.address ?? ""),
20069
+ sdkCore.ABIContract.ofAbi(chunkEESC6JDT_cjs.SimpleAccountABI).getFunction(
20070
+ "executeWithAuthorization"
20071
+ ),
20072
+ [
20073
+ data.message.to,
20074
+ BigInt(data.message.value),
20075
+ data.message.data,
20076
+ BigInt(data.message.validAfter),
20077
+ BigInt(data.message.validBefore),
20078
+ signatures[index]
20079
+ ]
20080
+ )
20081
+ );
19854
20082
  });
19855
20083
  }
19856
- }, [language, i18nConfig]);
19857
- React10.useEffect(() => {
19858
- chunkM6WTSZ5C_cjs.setLocalStorageItem(chunkM6WTSZ5C_cjs.VECHAIN_KIT_STORAGE_KEYS.NETWORK, network.type);
19859
- }, [network]);
19860
- return /* @__PURE__ */ jsxRuntime.jsxs(EnsureQueryClient, { children: [
19861
- /* @__PURE__ */ jsxRuntime.jsx(reactQueryDevtools.ReactQueryDevtools, { initialIsOpen: false }),
19862
- /* @__PURE__ */ jsxRuntime.jsx(PrivyCrossAppProvider, { privyEcosystemAppIDS: allowedEcosystemApps, children: /* @__PURE__ */ jsxRuntime.jsx(
19863
- VeChainKitContext.Provider,
20084
+ const gasResult = await thor.gas.estimateGas(
20085
+ clauses,
20086
+ connectedWallet.address ?? "",
19864
20087
  {
19865
- value: {
19866
- privy,
19867
- privyEcosystemAppIDS: allowedEcosystemApps,
19868
- feeDelegation,
19869
- dappKit,
19870
- loginModalUI,
19871
- loginMethods: validatedLoginMethods,
19872
- darkMode,
19873
- i18n: i18nConfig,
19874
- language,
19875
- network,
19876
- allowCustomTokens,
19877
- legalDocuments,
19878
- defaultCurrency
19879
- },
19880
- children: /* @__PURE__ */ jsxRuntime.jsx(
19881
- reactAuth.PrivyProvider,
19882
- {
19883
- appId: privyAppId,
19884
- clientId: privyClientId,
19885
- config: {
19886
- // loginMethods: privy?.loginMethods,
19887
- loginMethodsAndOrder: {
19888
- primary: privy?.loginMethods.slice(0, 4) ?? [],
19889
- overflow: privy?.loginMethods.slice(4) ?? []
19890
- },
19891
- externalWallets: {
19892
- walletConnect: {
19893
- enabled: false
19894
- }
19895
- },
19896
- appearance: {
19897
- theme: darkMode ? "dark" : "light",
19898
- accentColor: privy?.appearance.accentColor ?? (darkMode ? "#3182CE" : "#2B6CB0"),
19899
- loginMessage: privy?.appearance.loginMessage,
19900
- logo: privy?.appearance.logo
19901
- },
19902
- embeddedWallets: {
19903
- createOnLogin: privy?.embeddedWallets?.createOnLogin ?? "all-users"
19904
- },
19905
- passkeys: {
19906
- shouldUnlinkOnUnenrollMfa: false
19907
- }
19908
- },
19909
- children: /* @__PURE__ */ jsxRuntime.jsx(
19910
- dappKitReact.DAppKitProvider,
19911
- {
19912
- node: network.nodeUrl ?? chunkM6WTSZ5C_cjs.getConfig(network.type).nodeUrl,
19913
- i18n: i18nConfig,
19914
- language,
19915
- logLevel: dappKit.logLevel,
19916
- modalParent: dappKit.modalParent,
19917
- onSourceClick: dappKit.onSourceClick,
19918
- usePersistence: dappKit.usePersistence ?? true,
19919
- allowedWallets: dappKit.allowedWallets,
19920
- walletConnectOptions: dappKit.walletConnectOptions,
19921
- themeMode: darkMode ? "DARK" : "LIGHT",
19922
- themeVariables: {
19923
- "--vdk-modal-z-index": "10000",
19924
- "--vdk-modal-width": "22rem",
19925
- "--vdk-modal-backdrop-filter": "blur(3px)",
19926
- "--vdk-border-dark-source-card": `1px solid ${"#ffffff0a"}`,
19927
- "--vdk-border-light-source-card": `1px solid ${"#ebebeb"}`,
19928
- // Dark mode colors
19929
- "--vdk-color-dark-primary": "transparent",
19930
- "--vdk-color-dark-primary-hover": "rgba(255, 255, 255, 0.05)",
19931
- "--vdk-color-dark-primary-active": "rgba(255, 255, 255, 0.1)",
19932
- "--vdk-color-dark-secondary": "#1f1f1e",
19933
- // Light mode colors
19934
- "--vdk-color-light-primary": "#ffffff",
19935
- "--vdk-color-light-primary-hover": "#f8f8f8",
19936
- "--vdk-color-light-primary-active": "#f0f0f0",
19937
- "--vdk-color-light-secondary": "white",
19938
- // Font settings - using system fonts instead of Chakra variables
19939
- "--vdk-font-family": 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
19940
- "--vdk-font-size-medium": "14px",
19941
- "--vdk-font-size-large": "16px",
19942
- "--vdk-font-weight-medium": "500"
19943
- },
19944
- children: /* @__PURE__ */ jsxRuntime.jsx(
19945
- PrivyWalletProvider,
19946
- {
19947
- nodeUrl: network.nodeUrl ?? chunkM6WTSZ5C_cjs.getConfig(network.type).nodeUrl,
19948
- delegatorUrl: feeDelegation?.delegatorUrl ?? "",
19949
- delegateAllTransactions: feeDelegation?.delegateAllTransactions ?? false,
19950
- children: /* @__PURE__ */ jsxRuntime.jsx(ModalProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(LegalDocumentsProvider, { children }) })
19951
- }
19952
- )
19953
- }
19954
- )
19955
- }
19956
- )
20088
+ gasPadding: 1
19957
20089
  }
19958
- ) })
19959
- ] });
19960
- };
19961
- var { definePartsStyle, defineMultiStyleConfig } = react.createMultiStyleConfigHelpers(anatomy.modalAnatomy.keys);
19962
- var variants = {
19963
- vechainKitBase: (props) => definePartsStyle({
19964
- dialog: {
19965
- scrollbarWidth: "none",
19966
- overflow: "scroll",
19967
- overflowX: "hidden",
19968
- maxHeight: "550px",
19969
- borderRadius: "24px",
19970
- backgroundColor: props.colorMode === "dark" ? "#1f1f1e" : "white"
19971
- },
19972
- closeButton: {
19973
- borderRadius: "50%"
19974
- },
19975
- header: {
19976
- w: "full",
19977
- color: props.colorMode === "dark" ? "#dfdfdd" : "#2e2e2e",
19978
- fontSize: "md",
19979
- fontWeight: "700",
19980
- textAlign: "center"
19981
- }
19982
- }),
19983
- vechainKitTransactionToast: (props) => definePartsStyle({
19984
- dialog: {
19985
- borderRadius: "15px",
19986
- position: "fixed",
19987
- bottom: "10px",
19988
- left: "10px",
19989
- mimHeight: "70px",
19990
- minWidth: "300px",
19991
- maxWidth: "400px",
19992
- width: "fit-content",
19993
- pointerEvents: "auto",
19994
- boxShadow: "0px 0px 10px 0px rgba(0, 0, 0, 0.1)",
19995
- py: "10px",
19996
- backgroundColor: props.colorMode === "dark" ? "#1f1f1e" : "white"
19997
- },
19998
- closeButton: {
19999
- borderRadius: "50%",
20000
- width: "25px",
20001
- height: "25px",
20002
- size: "10px"
20003
- }
20004
- })
20005
- };
20006
- var modalTheme = defineMultiStyleConfig({
20007
- variants,
20008
- defaultProps: {
20009
- variant: "vechainKitBase"
20010
- }
20011
- });
20012
- var { definePartsStyle: definePartsStyle2, defineMultiStyleConfig: defineMultiStyleConfig2 } = react.createMultiStyleConfigHelpers(anatomy.cardAnatomy.keys);
20013
- var variants2 = {
20014
- vechainKitBase: (props) => definePartsStyle2({
20015
- container: {
20016
- backgroundColor: props.colorMode === "dark" ? "#1c1c1b" : "#f5f5f5",
20017
- borderRadius: "14px",
20018
- width: "full",
20019
- border: "none"
20020
- },
20021
- body: {
20022
- p: 5,
20023
- width: "full"
20024
- },
20025
- header: {
20026
- p: 5,
20027
- width: "full",
20028
- borderRadius: "14px 14px 0 0"
20029
- },
20030
- footer: {
20031
- width: "full",
20032
- borderRadius: "0 0 14px 14px"
20033
- }
20034
- }),
20035
- featureAnnouncement: (props) => definePartsStyle2({
20036
- body: {
20037
- backgroundColor: props.colorMode === "dark" ? "#ffffff0a" : "blackAlpha.50",
20038
- borderRadius: "12px",
20039
- color: props.colorMode === "dark" ? "#ffffff12" : "blackAlpha.200"
20040
- },
20041
- container: {
20042
- borderRadius: "12px",
20043
- backgroundColor: "transparent"
20044
- }
20045
- }),
20046
- vechainKitAppCard: (props) => definePartsStyle2({
20047
- body: {
20048
- height: "full",
20049
- borderRadius: "12px",
20050
- backgroundColor: props.colorMode === "dark" ? "#1f1f1e" : "white",
20051
- border: props.colorMode === "dark" ? "1px solid #2d2d2d" : "1px solid #eaeaea"
20052
- },
20053
- container: {
20054
- height: "150px",
20055
- borderRadius: "12px",
20056
- backgroundColor: "transparent"
20057
- }
20058
- })
20059
- };
20060
- var cardTheme = defineMultiStyleConfig2({
20061
- variants: variants2,
20062
- defaultProps: {
20063
- variant: "vechainKitBase"
20064
- // default is solid
20065
- }
20066
- });
20067
- var baseStyle = react.defineStyle({
20068
- borderRadius: "12px"
20069
- });
20070
- var variants3 = {
20071
- loginIn: react.defineStyle(() => ({
20072
- bg: "white",
20073
- color: "#1a1a1a",
20074
- fontSize: "14px",
20075
- fontWeight: "400",
20076
- border: "1px solid #ebebeb",
20077
- py: 6,
20078
- px: 3,
20079
- borderRadius: 16,
20080
- _hover: {
20081
- bg: "#eaeaea"
20082
- },
20083
- _dark: {
20084
- bg: "transparent",
20085
- color: "white",
20086
- _hover: {
20087
- bg: "#2a2a2a"
20090
+ );
20091
+ const parsedGasLimit = Math.max(
20092
+ gasResult.totalGas,
20093
+ suggestedMaxGas ?? 0
20094
+ );
20095
+ const txBody = await thor.transactions.buildTransactionBody(
20096
+ clauses,
20097
+ parsedGasLimit,
20098
+ { isDelegated: true }
20099
+ );
20100
+ const wallet = new sdkNetwork.ProviderInternalBaseWallet(
20101
+ [
20102
+ {
20103
+ privateKey: Buffer.from(
20104
+ chunkM6WTSZ5C_cjs.randomTransactionUser.privateKey.slice(2),
20105
+ "hex"
20106
+ ),
20107
+ address: chunkM6WTSZ5C_cjs.randomTransactionUser.address
20108
+ }
20109
+ ],
20110
+ { gasPayer: { gasPayerServiceUrl: delegatorUrl } }
20111
+ );
20112
+ const providerWithDelegationEnabled = new sdkNetwork.VeChainProvider(
20113
+ thor,
20114
+ wallet,
20115
+ true
20116
+ );
20117
+ const signer = await providerWithDelegationEnabled.getSigner(
20118
+ chunkM6WTSZ5C_cjs.randomTransactionUser.address
20119
+ );
20120
+ const txInput = sdkNetwork.signerUtils.transactionBodyToTransactionRequestInput(
20121
+ txBody,
20122
+ chunkM6WTSZ5C_cjs.randomTransactionUser.address
20123
+ );
20124
+ const rawDelegateSigned = await signer.signTransaction(txInput);
20125
+ const { id } = await fetch(`${nodeUrl}/transactions`, {
20126
+ method: "POST",
20127
+ headers: {
20128
+ "content-type": "application/json"
20088
20129
  },
20089
- border: "1px solid #ffffff1a"
20130
+ body: JSON.stringify({
20131
+ raw: rawDelegateSigned
20132
+ })
20133
+ }).then((res) => res.json());
20134
+ return id;
20135
+ };
20136
+ const signMessage = async (message) => {
20137
+ if (connection.isConnectedWithCrossApp) {
20138
+ return await signMessageWithCrossApp(message);
20090
20139
  }
20091
- })),
20092
- loginWithVechain: react.defineStyle(() => ({
20093
- bg: "#1a1a1a",
20094
- color: "white",
20095
- fontSize: "14px",
20096
- fontWeight: "400",
20097
- py: 6,
20098
- px: 3,
20099
- borderRadius: 16,
20100
- border: "1px solid #5e5e5e",
20101
- _hover: {
20102
- bg: "#2a2a2a"
20103
- },
20104
- _dark: {
20105
- bg: "white",
20106
- color: "#1a1a1a",
20107
- _hover: {
20108
- bg: "#eaeaea"
20140
+ return (await signMessagePrivy({
20141
+ message
20142
+ })).signature;
20143
+ };
20144
+ const signTypedData = async (data) => {
20145
+ if (connection.isConnectedWithCrossApp) {
20146
+ const mutableData = {
20147
+ ...data,
20148
+ address: connectedWallet?.address,
20149
+ types: Object.fromEntries(
20150
+ Object.entries(data.types).map(([k, v]) => [k, [...v]])
20151
+ )
20152
+ };
20153
+ return await signTypedDataWithCrossApp(mutableData);
20154
+ }
20155
+ return (await signTypedDataPrivy(data)).signature;
20156
+ };
20157
+ return /* @__PURE__ */ jsxRuntime.jsx(
20158
+ PrivyWalletProviderContext.Provider,
20159
+ {
20160
+ value: {
20161
+ accountFactory: chunkM6WTSZ5C_cjs.getConfig(network.type).accountFactoryAddress,
20162
+ sendTransaction,
20163
+ signMessage,
20164
+ signTypedData,
20165
+ exportWallet,
20166
+ delegateAllTransactions
20109
20167
  },
20110
- border: "1px solid #ffffff1a"
20111
- },
20112
- transition: "all 0.2s"
20113
- })),
20114
- vechainKitSelector: react.defineStyle(({ colorMode }) => ({
20115
- bg: "transparent",
20116
- border: `1px solid ${colorMode === "dark" ? "#ffffff29" : "#ebebeb"}`,
20117
- _hover: {
20118
- borderColor: colorMode === "dark" ? "#ffffff50" : "#dedede",
20119
- bg: colorMode === "dark" ? "whiteAlpha.50" : "blackAlpha.50"
20120
- },
20121
- _active: {
20122
- transform: "scale(0.98)"
20123
- },
20124
- transition: "all 0.2s"
20125
- })),
20126
- vechainKitPrimary: react.defineStyle(() => ({
20127
- fontSize: "md",
20128
- px: 4,
20129
- width: "full",
20130
- height: "60px",
20131
- borderRadius: "xl",
20132
- bg: "#2B6CB0",
20133
- color: "white",
20134
- _hover: {
20135
- bg: "#2C5282",
20136
- _disabled: {
20137
- bg: "#2B6CB0"
20138
- }
20139
- },
20140
- _dark: {
20141
- bg: "#3182CE",
20142
- _hover: {
20143
- bg: "#2B6CB0"
20144
- }
20145
- },
20146
- transition: "all 0.2s"
20147
- })),
20148
- vechainKitSecondary: react.defineStyle(({ colorMode }) => ({
20149
- fontSize: "md",
20150
- px: 4,
20151
- width: "full",
20152
- height: "60px",
20153
- borderRadius: "xl",
20154
- backgroundColor: colorMode === "dark" ? "#ffffff0a" : "blackAlpha.50",
20155
- _hover: {
20156
- backgroundColor: colorMode === "dark" ? "#ffffff12" : "blackAlpha.200"
20157
- },
20158
- border: "1px solid",
20159
- borderColor: "gray.200",
20160
- color: "blackAlpha.900",
20161
- _dark: {
20162
- borderColor: "whiteAlpha.200",
20163
- color: "whiteAlpha.900"
20164
- },
20165
- transition: "all 0.2s"
20166
- })),
20167
- vechainKitLogout: react.defineStyle(({ colorMode }) => ({
20168
- width: "full",
20169
- minHeight: "50px",
20170
- height: "fit-content",
20171
- borderRadius: "xl",
20172
- p: 0,
20173
- backgroundColor: colorMode === "dark" ? "rgba(254, 178, 178, 0.12)" : "red.50",
20174
- _hover: {
20175
- backgroundColor: colorMode === "dark" ? "rgba(254, 178, 178, 0.37)" : "red.200",
20176
- color: colorMode === "dark" ? "red.50" : "red.900"
20177
- },
20178
- transition: "all 0.2s",
20179
- color: colorMode === "dark" ? "red.200" : "red.900"
20180
- })),
20181
- mainContentButton: react.defineStyle(({ colorMode }) => ({
20182
- width: "100%",
20183
- backgroundColor: colorMode === "dark" ? "#ffffff0a" : "blackAlpha.50",
20184
- borderRadius: "xl",
20185
- p: 3,
20186
- cursor: "pointer",
20187
- _hover: {
20188
- backgroundColor: colorMode === "dark" ? "#ffffff12" : "blackAlpha.200"
20168
+ children
20189
20169
  }
20190
- })),
20191
- actionButton: react.defineStyle(({ colorMode }) => ({
20192
- width: "full",
20193
- minHeight: "50px",
20194
- height: "fit-content",
20195
- backgroundColor: colorMode === "dark" ? "#ffffff0a" : "blackAlpha.50",
20196
- borderRadius: "xl",
20197
- p: 0,
20198
- _hover: {
20199
- backgroundColor: colorMode === "dark" ? "#ffffff12" : "blackAlpha.200"
20200
- },
20201
- transition: "all 0.2s"
20202
- }))
20170
+ );
20203
20171
  };
20204
- var buttonTheme = react.defineStyleConfig({
20205
- baseStyle,
20206
- variants: variants3
20207
- });
20208
- var { definePartsStyle: definePartsStyle3, defineMultiStyleConfig: defineMultiStyleConfig3 } = react.createMultiStyleConfigHelpers(anatomy.popoverAnatomy.keys);
20209
- var variants4 = {
20210
- vechainKitBase: (props) => definePartsStyle3({
20211
- popper: {
20212
- zIndex: 1e3
20213
- },
20214
- content: {
20215
- borderRadius: "24px",
20216
- border: "none",
20217
- backgroundColor: props.colorMode === "dark" ? "#1f1f1e" : "white",
20218
- boxShadow: "0px 4px 16px rgba(0, 0, 0, 0.12)",
20219
- minWidth: "380px"
20220
- },
20221
- body: {
20222
- padding: "16px"
20223
- }
20224
- })
20172
+ var usePrivyWalletProvider = () => {
20173
+ const context = React10.useContext(PrivyWalletProviderContext);
20174
+ if (!context) {
20175
+ throw new Error(
20176
+ "usePrivyWalletProvider must be used within a PrivyWalletProvider"
20177
+ );
20178
+ }
20179
+ return context;
20225
20180
  };
20226
- var popoverTheme = defineMultiStyleConfig3({
20227
- variants: variants4,
20228
- defaultProps: {
20229
- variant: "vechainKitBase"
20181
+ var VeChainKitContext = React10.createContext(null);
20182
+ var useVeChainKitConfig = () => {
20183
+ const context = React10.useContext(VeChainKitContext);
20184
+ if (!context) {
20185
+ throw new Error("useVeChainKitConfig must be used within VeChainKit");
20230
20186
  }
20231
- });
20232
-
20233
- // src/theme/theme.tsx
20234
- var themeConfig = {
20235
- useSystemColorMode: false,
20236
- disableTransitionOnChange: false,
20237
- // @ts-ignore
20238
- components: {
20239
- Modal: modalTheme,
20240
- Card: cardTheme,
20241
- Button: buttonTheme,
20242
- Popover: popoverTheme
20243
- },
20244
- cssVarPrefix: "vechain-kit",
20245
- // consistent naming across all components
20246
- // COMPLETELY disable global styles to prevent any conflicts
20247
- styles: {
20248
- global: () => ({})
20249
- // empty object = no global styles injected
20250
- },
20251
- // only defining the semantic tokens we need, scoped to our components
20252
- semanticTokens: {
20253
- colors: {
20254
- "chakra-body-text": {
20255
- _light: "#1A202C",
20256
- _dark: "#F7FAFC"
20257
- },
20258
- "chakra-body-bg": {
20259
- _light: "#FFFFFF",
20260
- _dark: "#1A202C"
20261
- },
20262
- "chakra-border-color": {
20263
- _light: "#E2E8F0",
20264
- _dark: "#2D3748"
20265
- },
20266
- "chakra-placeholder-color": {
20267
- _light: "#A0AEC0",
20268
- _dark: "#718096"
20187
+ return context;
20188
+ };
20189
+ var validateConfig = (props) => {
20190
+ const errors = [];
20191
+ const requiresFeeDelegation = props.privy !== void 0 || props.loginMethods?.some(
20192
+ (method7) => method7.method === "vechain" || method7.method === "ecosystem"
20193
+ );
20194
+ if (requiresFeeDelegation) {
20195
+ if (!props.feeDelegation) {
20196
+ errors.push(
20197
+ "feeDelegation configuration is required when using Privy or vechain login method"
20198
+ );
20199
+ } else {
20200
+ if (!props.feeDelegation || !props.feeDelegation.delegatorUrl) {
20201
+ errors.push(
20202
+ "feeDelegation.delegatorUrl is required when using Privy or vechain login method"
20203
+ );
20204
+ }
20205
+ }
20206
+ }
20207
+ if (!props.network) {
20208
+ errors.push("network configuration is required");
20209
+ } else {
20210
+ if (!props.network.type) {
20211
+ errors.push("network.type is required");
20212
+ }
20213
+ if (!["main", "test", "solo"].includes(props.network.type)) {
20214
+ errors.push('network.type must be either "main", "test" or "solo"');
20215
+ }
20216
+ }
20217
+ if (props.loginMethods) {
20218
+ if (!props.privy) {
20219
+ const invalidMethods = props.loginMethods.filter(
20220
+ (method7) => ["email", "google", "passkey", "more"].includes(method7.method)
20221
+ );
20222
+ if (invalidMethods.length > 0) {
20223
+ errors.push(
20224
+ `Login methods ${invalidMethods.map((m) => `"${m.method}"`).join(", ")} require Privy configuration. Please either remove these methods or configure the privy prop.`
20225
+ );
20269
20226
  }
20270
20227
  }
20271
- },
20272
- // minimal foundations to prevent global style injection
20273
- fonts: react.theme.fonts,
20274
- colors: react.theme.colors,
20275
- space: react.theme.space
20276
- };
20277
- var VechainKitTheme = react.extendTheme(themeConfig);
20278
- VechainKitTheme.styles.global = () => ({});
20279
- if (VechainKitTheme.__cssVars) {
20280
- VechainKitTheme.__cssVars.global = () => ({});
20281
- }
20282
- var { ToastContainer } = react.createStandaloneToast();
20283
- var createVeChainKitCache = () => {
20284
- return createCache__default.default({
20285
- key: "vechain-kit",
20286
- // consistent with our layer and class names
20287
- prepend: true
20288
- // CSS layers will be handled via Global component injection
20289
- });
20290
- };
20291
- var LayerSetup = () => {
20292
- return /* @__PURE__ */ jsxRuntime.jsx(
20293
- react$1.Global,
20294
- {
20295
- styles: react$1.css`
20296
- /* define CSS layers with proper priority order */
20297
- @layer vechain-kit, host-app;
20298
-
20299
- /* All vechain-kit styles go in the vechain-kit layer */
20300
- @layer vechain-kit {
20301
- /* scope all Chakra styles to vechain-kit-root */
20302
- .vechain-kit-root {
20303
- /* vechain-kit styles are contained here */
20304
- }
20305
- }
20306
- `
20228
+ }
20229
+ if (props?.legalDocuments) {
20230
+ if (props.legalDocuments.termsAndConditions) {
20231
+ props.legalDocuments.termsAndConditions.forEach((term) => {
20232
+ if (!chunkM6WTSZ5C_cjs.isValidUrl(term.url)) {
20233
+ errors.push(
20234
+ `legalDocuments.termsAndConditions.url is invalid: ${term.url}`
20235
+ );
20236
+ }
20237
+ });
20307
20238
  }
20308
- );
20309
- };
20310
- var EnsureChakraProvider = ({
20311
- children,
20312
- theme
20313
- }) => {
20314
- const cache = React10.useMemo(() => createVeChainKitCache(), []);
20315
- return /* @__PURE__ */ jsxRuntime.jsxs(react$1.CacheProvider, { value: cache, children: [
20316
- /* @__PURE__ */ jsxRuntime.jsx(LayerSetup, {}),
20317
- /* @__PURE__ */ jsxRuntime.jsx(
20318
- react.ChakraProvider,
20319
- {
20320
- theme,
20321
- resetCSS: false,
20322
- portalZIndex: void 0,
20323
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "vechain-kit-root", children })
20324
- }
20325
- )
20326
- ] });
20327
- };
20328
- var EnsureColorModeScript = ({ darkMode }) => {
20329
- try {
20330
- const existingScript = chunkM6WTSZ5C_cjs.safeQuerySelector("[data-chakra-color-mode]");
20331
- if (existingScript) {
20332
- return null;
20239
+ if (props.legalDocuments.privacyPolicy) {
20240
+ props.legalDocuments.privacyPolicy.forEach((term) => {
20241
+ if (!chunkM6WTSZ5C_cjs.isValidUrl(term.url)) {
20242
+ errors.push(
20243
+ `legalDocuments.privacyPolicy.url is invalid: ${term.url}`
20244
+ );
20245
+ }
20246
+ });
20247
+ }
20248
+ if (props.legalDocuments.cookiePolicy) {
20249
+ props.legalDocuments.cookiePolicy.forEach((term) => {
20250
+ if (!chunkM6WTSZ5C_cjs.isValidUrl(term.url)) {
20251
+ errors.push(
20252
+ `legalDocuments.cookiePolicy.url is invalid: ${term.url}`
20253
+ );
20254
+ }
20255
+ });
20333
20256
  }
20334
- } catch (e) {
20335
- console.error(e);
20336
20257
  }
20337
- return /* @__PURE__ */ jsxRuntime.jsx(react.ColorModeScript, { initialColorMode: darkMode ? "dark" : "light" });
20258
+ if (errors.length > 0) {
20259
+ throw new Error(
20260
+ "VeChainKit Configuration Error:\n" + errors.join("\n")
20261
+ );
20262
+ }
20263
+ return props;
20338
20264
  };
20339
- var VechainKitThemeProvider = ({
20340
- children,
20341
- darkMode = false
20342
- }) => {
20343
- const theme = React10.useMemo(
20344
- () => ({
20345
- ...VechainKitTheme,
20346
- config: {
20347
- ...VechainKitTheme.config,
20348
- initialColorMode: darkMode ? "dark" : "light"
20265
+ var VeChainKitProvider = (props) => {
20266
+ const validatedProps = validateConfig(props);
20267
+ const {
20268
+ children,
20269
+ privy,
20270
+ feeDelegation,
20271
+ dappKit,
20272
+ loginModalUI,
20273
+ loginMethods,
20274
+ darkMode = false,
20275
+ i18n: i18nConfig,
20276
+ language = "en",
20277
+ network,
20278
+ allowCustomTokens,
20279
+ legalDocuments,
20280
+ defaultCurrency = "usd"
20281
+ } = validatedProps;
20282
+ const validatedLoginMethods = loginMethods;
20283
+ const allowedEcosystemApps = React10.useMemo(() => {
20284
+ const userEcosystemMethods = validatedLoginMethods?.find(
20285
+ (method7) => method7.method === "ecosystem"
20286
+ );
20287
+ return userEcosystemMethods?.allowedApps ?? chunkM6WTSZ5C_cjs.DEFAULT_PRIVY_ECOSYSTEM_APPS.map((app) => app.id);
20288
+ }, [validatedLoginMethods]);
20289
+ let privyAppId, privyClientId;
20290
+ if (!privy) {
20291
+ privyAppId = "clzdb5k0b02b9qvzjm6jpknsc";
20292
+ privyClientId = "client-WY2oy87y6KNrHFnpXuwVsiFMkwPZKTYpExtjvUQuMbCMF";
20293
+ } else {
20294
+ privyAppId = privy.appId;
20295
+ privyClientId = privy.clientId;
20296
+ }
20297
+ React10.useEffect(() => {
20298
+ initializeI18n(i18n_default);
20299
+ if (language) {
20300
+ i18n_default.changeLanguage(language);
20301
+ }
20302
+ if (i18nConfig) {
20303
+ Object.keys(i18nConfig).forEach((lang) => {
20304
+ i18n_default.addResourceBundle(
20305
+ lang,
20306
+ "translation",
20307
+ i18nConfig[lang],
20308
+ true,
20309
+ true
20310
+ );
20311
+ });
20312
+ }
20313
+ }, [language, i18nConfig]);
20314
+ React10.useEffect(() => {
20315
+ chunkM6WTSZ5C_cjs.setLocalStorageItem(chunkM6WTSZ5C_cjs.VECHAIN_KIT_STORAGE_KEYS.NETWORK, network.type);
20316
+ }, [network]);
20317
+ return /* @__PURE__ */ jsxRuntime.jsxs(EnsureQueryClient, { children: [
20318
+ /* @__PURE__ */ jsxRuntime.jsx(reactQueryDevtools.ReactQueryDevtools, { initialIsOpen: false }),
20319
+ /* @__PURE__ */ jsxRuntime.jsx(PrivyCrossAppProvider, { privyEcosystemAppIDS: allowedEcosystemApps, children: /* @__PURE__ */ jsxRuntime.jsx(
20320
+ VeChainKitContext.Provider,
20321
+ {
20322
+ value: {
20323
+ privy,
20324
+ privyEcosystemAppIDS: allowedEcosystemApps,
20325
+ feeDelegation,
20326
+ dappKit,
20327
+ loginModalUI,
20328
+ loginMethods: validatedLoginMethods,
20329
+ darkMode,
20330
+ i18n: i18nConfig,
20331
+ language,
20332
+ network,
20333
+ allowCustomTokens,
20334
+ legalDocuments,
20335
+ defaultCurrency
20336
+ },
20337
+ children: /* @__PURE__ */ jsxRuntime.jsx(
20338
+ reactAuth.PrivyProvider,
20339
+ {
20340
+ appId: privyAppId,
20341
+ clientId: privyClientId,
20342
+ config: {
20343
+ // loginMethods: privy?.loginMethods,
20344
+ loginMethodsAndOrder: {
20345
+ primary: privy?.loginMethods.slice(0, 4) ?? [],
20346
+ overflow: privy?.loginMethods.slice(4) ?? []
20347
+ },
20348
+ externalWallets: {
20349
+ walletConnect: {
20350
+ enabled: false
20351
+ }
20352
+ },
20353
+ appearance: {
20354
+ theme: darkMode ? "dark" : "light",
20355
+ accentColor: privy?.appearance.accentColor ?? (darkMode ? "#3182CE" : "#2B6CB0"),
20356
+ loginMessage: privy?.appearance.loginMessage,
20357
+ logo: privy?.appearance.logo
20358
+ },
20359
+ embeddedWallets: {
20360
+ createOnLogin: privy?.embeddedWallets?.createOnLogin ?? "all-users"
20361
+ },
20362
+ passkeys: {
20363
+ shouldUnlinkOnUnenrollMfa: false
20364
+ }
20365
+ },
20366
+ children: /* @__PURE__ */ jsxRuntime.jsx(
20367
+ dappKitReact.DAppKitProvider,
20368
+ {
20369
+ node: network.nodeUrl ?? chunkM6WTSZ5C_cjs.getConfig(network.type).nodeUrl,
20370
+ i18n: i18nConfig,
20371
+ language,
20372
+ logLevel: dappKit.logLevel,
20373
+ modalParent: dappKit.modalParent,
20374
+ onSourceClick: dappKit.onSourceClick,
20375
+ usePersistence: dappKit.usePersistence ?? true,
20376
+ allowedWallets: dappKit.allowedWallets,
20377
+ walletConnectOptions: dappKit.walletConnectOptions,
20378
+ themeMode: darkMode ? "DARK" : "LIGHT",
20379
+ themeVariables: {
20380
+ "--vdk-modal-z-index": "10000",
20381
+ "--vdk-modal-width": "22rem",
20382
+ "--vdk-modal-backdrop-filter": "blur(3px)",
20383
+ "--vdk-border-dark-source-card": `1px solid ${"#ffffff0a"}`,
20384
+ "--vdk-border-light-source-card": `1px solid ${"#ebebeb"}`,
20385
+ // Dark mode colors
20386
+ "--vdk-color-dark-primary": "transparent",
20387
+ "--vdk-color-dark-primary-hover": "rgba(255, 255, 255, 0.05)",
20388
+ "--vdk-color-dark-primary-active": "rgba(255, 255, 255, 0.1)",
20389
+ "--vdk-color-dark-secondary": "#1f1f1e",
20390
+ // Light mode colors
20391
+ "--vdk-color-light-primary": "#ffffff",
20392
+ "--vdk-color-light-primary-hover": "#f8f8f8",
20393
+ "--vdk-color-light-primary-active": "#f0f0f0",
20394
+ "--vdk-color-light-secondary": "white",
20395
+ // Font settings - using system fonts instead of Chakra variables
20396
+ "--vdk-font-family": 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
20397
+ "--vdk-font-size-medium": "14px",
20398
+ "--vdk-font-size-large": "16px",
20399
+ "--vdk-font-weight-medium": "500"
20400
+ },
20401
+ children: /* @__PURE__ */ jsxRuntime.jsx(
20402
+ PrivyWalletProvider,
20403
+ {
20404
+ nodeUrl: network.nodeUrl ?? chunkM6WTSZ5C_cjs.getConfig(network.type).nodeUrl,
20405
+ delegatorUrl: feeDelegation?.delegatorUrl ?? "",
20406
+ delegateAllTransactions: feeDelegation?.delegateAllTransactions ?? false,
20407
+ children: /* @__PURE__ */ jsxRuntime.jsx(ModalProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(LegalDocumentsProvider, { children }) })
20408
+ }
20409
+ )
20410
+ }
20411
+ )
20412
+ }
20413
+ )
20349
20414
  }
20350
- }),
20351
- [darkMode]
20352
- );
20353
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
20354
- /* @__PURE__ */ jsxRuntime.jsx(EnsureColorModeScript, { darkMode }),
20355
- /* @__PURE__ */ jsxRuntime.jsx(EnsureChakraProvider, { theme, children }),
20356
- /* @__PURE__ */ jsxRuntime.jsx(ToastContainer, {})
20415
+ ) })
20357
20416
  ] });
20358
20417
  };
20359
20418
 
@@ -20700,6 +20759,7 @@ exports.useUpgradeSmartAccountModal = useUpgradeSmartAccountModal;
20700
20759
  exports.useUploadImages = useUploadImages;
20701
20760
  exports.useVeChainKitConfig = useVeChainKitConfig;
20702
20761
  exports.useVechainDomain = useVechainDomain;
20762
+ exports.useVechainKitThemeConfig = useVechainKitThemeConfig;
20703
20763
  exports.useWallet = useWallet;
20704
20764
  exports.useWalletMetadata = useWalletMetadata;
20705
20765
  exports.useWalletModal = useWalletModal2;