@cofhe/react 0.2.1 → 0.3.0

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.js CHANGED
@@ -730,7 +730,7 @@ var require_dist = __commonJS({
730
730
  });
731
731
 
732
732
  // src/providers/CofheProvider.tsx
733
- import { createContext as createContext4, useContext as useContext5, useMemo as useMemo32, useState as useState15 } from "react";
733
+ import { createContext as createContext4, useContext as useContext5, useMemo as useMemo33, useState as useState15 } from "react";
734
734
 
735
735
  // src/providers/QueryProvider.tsx
736
736
  import { QueryClient } from "@tanstack/react-query";
@@ -754,7 +754,7 @@ var QueryProvider = ({
754
754
  };
755
755
 
756
756
  // src/providers/CofheProvider.tsx
757
- import { createCofhesdkClient } from "@cofhe/sdk/web";
757
+ import { createCofheClient } from "@cofhe/sdk/web";
758
758
 
759
759
  // src/utils/cn.ts
760
760
  var cn = (...classes) => {
@@ -765,7 +765,53 @@ var cn = (...classes) => {
765
765
  import * as viemChains from "viem/chains";
766
766
 
767
767
  // src/types/token.ts
768
- var ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
768
+ import { baseSepolia, sepolia } from "@cofhe/sdk/chains";
769
+ var ETH_ADDRESS_LOWERCASE = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
770
+ var WETH_SEPOLIA_TOKEN = {
771
+ chainId: 11155111,
772
+ address: "0x87A3effB84CBE1E4caB6Ab430139eC41d156D55A",
773
+ name: "Redact eETH",
774
+ symbol: "eETH",
775
+ decimals: 18,
776
+ logoURI: "https://storage.googleapis.com/cofhesdk/token-icons/eth.webp",
777
+ extensions: {
778
+ fhenix: {
779
+ confidentialityType: "wrapped",
780
+ confidentialValueType: "uint128",
781
+ erc20Pair: {
782
+ address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
783
+ symbol: "ETH",
784
+ decimals: 18,
785
+ logoURI: "https://storage.googleapis.com/cofhesdk/token-icons/eth.webp"
786
+ }
787
+ }
788
+ }
789
+ };
790
+ var WETH_BASE_SEPOLIA_TOKEN = {
791
+ chainId: 84532,
792
+ address: "0xbED96aa98a49FeA71fcC55d755b915cF022a9159",
793
+ name: "Redact eETH",
794
+ symbol: "eETH",
795
+ decimals: 18,
796
+ logoURI: "https://storage.googleapis.com/cofhesdk/token-icons/eth.webp",
797
+ extensions: {
798
+ coingeckoId: "eeth",
799
+ fhenix: {
800
+ confidentialityType: "wrapped",
801
+ confidentialValueType: "uint128",
802
+ erc20Pair: {
803
+ address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
804
+ symbol: "ETH",
805
+ decimals: 18,
806
+ logoURI: "https://storage.googleapis.com/cofhesdk/token-icons/eth.webp"
807
+ }
808
+ }
809
+ }
810
+ };
811
+ var DEFAULT_TOKEN_BY_CHAIN_ID = {
812
+ [sepolia.id]: WETH_SEPOLIA_TOKEN,
813
+ [baseSepolia.id]: WETH_BASE_SEPOLIA_TOKEN
814
+ };
769
815
 
770
816
  // src/utils/utils.ts
771
817
  import { isValidElement } from "react";
@@ -796,7 +842,7 @@ var getBlockExplorerTokenUrl = (chainId, tokenAddress) => {
796
842
  };
797
843
  var isEthPair = (erc20Pair) => {
798
844
  if (!erc20Pair) return false;
799
- return erc20Pair.address.toLowerCase() === ETH_ADDRESS.toLowerCase();
845
+ return erc20Pair.address.toLowerCase() === ETH_ADDRESS_LOWERCASE;
800
846
  };
801
847
  var isWrappedEthToken = (token) => {
802
848
  if (token.extensions.fhenix.confidentialityType !== "wrapped") return false;
@@ -1332,12 +1378,12 @@ var useCofheSelectPermit = ({ onSuccess, onError } = {}) => {
1332
1378
  var import_ts_essentials = __toESM(require_dist(), 1);
1333
1379
 
1334
1380
  // src/hooks/useIsCofheErrorActive.ts
1335
- import { CofhesdkError } from "@cofhe/sdk";
1381
+ import { CofheError } from "@cofhe/sdk";
1336
1382
  import { useContext as useContext2 } from "react";
1337
1383
  import { ErrorBoundaryContext } from "react-error-boundary";
1338
1384
  function useIsCofheErrorActive() {
1339
1385
  const errorBoundaryContext = useContext2(ErrorBoundaryContext);
1340
- return errorBoundaryContext?.error instanceof CofhesdkError;
1386
+ return errorBoundaryContext?.error instanceof CofheError;
1341
1387
  }
1342
1388
 
1343
1389
  // src/hooks/useCofheReadContract.ts
@@ -1712,16 +1758,12 @@ function getTokenContractConfig(confidentialityType) {
1712
1758
  return CONFIDENTIAL_ABIS[confidentialityType];
1713
1759
  }
1714
1760
 
1715
- // src/hooks/useCofheTokenPublicBalance.ts
1716
- import "@tanstack/react-query";
1717
- import "viem";
1718
-
1719
1761
  // src/hooks/useCofheTokenLists.ts
1720
1762
  import "@tanstack/react-query";
1721
1763
  import { useMemo as useMemo4 } from "react";
1722
1764
  function useCofheTokenLists({ chainId }, queryOptions) {
1723
1765
  const widgetConfig = useCofheContext().client.config.react;
1724
- const tokensListsUrls = chainId ? widgetConfig.tokenLists[chainId] : [];
1766
+ const tokensListsUrls = chainId ? widgetConfig.tokenLists?.[chainId] : [];
1725
1767
  const queriesOptions = tokensListsUrls?.map((url) => ({
1726
1768
  cacheTime: Infinity,
1727
1769
  staleTime: Infinity,
@@ -1777,6 +1819,10 @@ function useCofheToken({ chainId: _chainId, address }, metdataQueryOptions) {
1777
1819
  return tokenFromList;
1778
1820
  }
1779
1821
 
1822
+ // src/hooks/useCofheTokenPublicBalance.ts
1823
+ import "@tanstack/react-query";
1824
+ import "viem";
1825
+
1780
1826
  // src/constants/erc20ABIs.ts
1781
1827
  import { parseAbi as parseAbi2 } from "viem";
1782
1828
  var ERC20_BALANCE_OF_ABI = parseAbi2(["function balanceOf(address owner) view returns (uint256)"]);
@@ -1851,7 +1897,7 @@ function createPublicTokenBalanceQueryOptions(params) {
1851
1897
  (0, import_ts_essentials2.assert)(tokenAddress, "Token address is required to fetch token balance");
1852
1898
  (0, import_ts_essentials2.assert)(publicClient, "PublicClient is required to fetch token balance");
1853
1899
  (0, import_ts_essentials2.assert)(accountAddress, "Account address is required to fetch token balance");
1854
- const isNativeToken = tokenAddress.toLowerCase() === ETH_ADDRESS.toLowerCase();
1900
+ const isNativeToken = tokenAddress.toLowerCase() === ETH_ADDRESS_LOWERCASE;
1855
1901
  const balance = isNativeToken ? publicClient.getBalance({
1856
1902
  address: accountAddress
1857
1903
  }) : publicClient.readContract({
@@ -2836,6 +2882,14 @@ function useHandleInvalidations() {
2836
2882
  const { upsert: upsertDecryptionWatcher, byKey } = useDecryptionWatchersStore();
2837
2883
  console.log("Scheduled invalidations store:", byKey);
2838
2884
  const handleInvalidations = (tx) => {
2885
+ invalidatePublicTokenBalanceQueries(
2886
+ {
2887
+ tokenAddress: ETH_ADDRESS_LOWERCASE,
2888
+ chainId: tx.chainId,
2889
+ accountAddress: tx.account
2890
+ },
2891
+ queryClient
2892
+ );
2839
2893
  if (tx.actionType === "shieldSend" /* ShieldSend */) {
2840
2894
  invalidateConfidentialTokenBalanceQueries(tx.token, queryClient);
2841
2895
  } else if (tx.actionType === "shield" /* Shield */) {
@@ -3223,7 +3277,7 @@ import "viem";
3223
3277
  import { FheTypes as FheTypes2 } from "@cofhe/sdk";
3224
3278
 
3225
3279
  // src/hooks/useCofheDecrypt.ts
3226
- import { CofhesdkError as CofhesdkError2 } from "@cofhe/sdk";
3280
+ import { CofheError as CofheError2 } from "@cofhe/sdk";
3227
3281
  var import_ts_essentials8 = __toESM(require_dist(), 1);
3228
3282
  function useCofheDecrypt({
3229
3283
  input
@@ -3237,14 +3291,14 @@ function useCofheDecrypt({
3237
3291
  queryKey: ["decryptCiphertext", input?.ctHash.toString(), input?.utype],
3238
3292
  queryFn: async () => {
3239
3293
  (0, import_ts_essentials8.assert)(input, "input is guaranteed to be defined by enabled condition");
3240
- return client.decryptHandle(input.ctHash, input.utype).decrypt();
3294
+ return client.decryptForView(input.ctHash, input.utype).execute();
3241
3295
  },
3242
3296
  meta: {
3243
3297
  persist: true
3244
3298
  },
3245
3299
  ...restQueryOptions,
3246
3300
  retry: (failureCount, error) => {
3247
- if (error instanceof CofhesdkError2) return false;
3301
+ if (error instanceof CofheError2) return false;
3248
3302
  return failureCount < 3;
3249
3303
  }
3250
3304
  });
@@ -3442,13 +3496,13 @@ function useCofheEncrypt(options) {
3442
3496
  handleStepStateChange(key, step, context);
3443
3497
  externalOnStepChange?.(step, context);
3444
3498
  };
3445
- builder.setStepCallback(combinedOnStepChange);
3499
+ builder.onStep(combinedOnStepChange);
3446
3500
  if (hasEncryptInputsOptions(variables)) {
3447
3501
  if (variables.account) builder.setAccount(variables.account);
3448
3502
  if (variables.chainId) builder.setChainId(variables.chainId);
3449
3503
  if (variables.securityZone) builder.setSecurityZone(variables.securityZone);
3450
3504
  }
3451
- return builder.encrypt();
3505
+ return builder.execute();
3452
3506
  }
3453
3507
  });
3454
3508
  return {
@@ -3628,7 +3682,7 @@ function useCofheTokenShield(options) {
3628
3682
  let hash;
3629
3683
  if (confidentialityType === "wrapped") {
3630
3684
  const erc20PairAddress = input.token.extensions.fhenix.erc20Pair?.address;
3631
- const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS.toLowerCase();
3685
+ const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS_LOWERCASE;
3632
3686
  if (isEth) {
3633
3687
  hash = await walletClient.writeContract({
3634
3688
  address: tokenAddress,
@@ -4872,7 +4926,7 @@ var usePermitDetailsAndActions = (permitHash) => {
4872
4926
  };
4873
4927
 
4874
4928
  // src/hooks/useCofheAutoConnect.ts
4875
- import { useEffect as useEffect7 } from "react";
4929
+ import { useCallback as useCallback11, useEffect as useEffect7, useMemo as useMemo21 } from "react";
4876
4930
 
4877
4931
  // src/providers/internalQueryHooks.ts
4878
4932
  import {
@@ -4971,16 +5025,27 @@ var useCofheConnect = (options) => {
4971
5025
  var useCofheAutoConnect = ({ walletClient, publicClient }) => {
4972
5026
  const client = useCofheClient();
4973
5027
  const connectMutationFn = useCofheConnect().mutate;
5028
+ const supportedChainIds = useMemo21(() => {
5029
+ return new Set(client.config.supportedChains.map((chain) => chain.id));
5030
+ }, [client.config.supportedChains]);
5031
+ const disconnectIfConnected = useCallback11(() => {
5032
+ if (client.connected || client.connecting) {
5033
+ client.disconnect();
5034
+ }
5035
+ }, [client]);
4974
5036
  useEffect7(() => {
4975
5037
  if (!publicClient || !walletClient) {
4976
- if (client.connected || client.connecting) {
4977
- client.disconnect();
4978
- }
5038
+ disconnectIfConnected();
5039
+ return;
5040
+ }
5041
+ const chainId = walletClient.chain?.id ?? publicClient.chain?.id;
5042
+ if (chainId !== void 0 && !supportedChainIds.has(chainId)) {
5043
+ disconnectIfConnected();
4979
5044
  return;
4980
5045
  }
4981
5046
  if (client.connecting) return;
4982
5047
  connectMutationFn({ publicClient, walletClient });
4983
- }, [publicClient, walletClient, client, client.connected, client.connecting, connectMutationFn]);
5048
+ }, [publicClient, walletClient, client, connectMutationFn, supportedChainIds, disconnectIfConnected]);
4984
5049
  };
4985
5050
 
4986
5051
  // src/hooks/useReschedulableTimeout.ts
@@ -5087,7 +5152,7 @@ function parseCoingeckoSimplePriceUsd({
5087
5152
  }
5088
5153
  function isNativeTokenAddress(address) {
5089
5154
  if (!address) return false;
5090
- return address.toLowerCase() === ETH_ADDRESS.toLowerCase();
5155
+ return address.toLowerCase() === ETH_ADDRESS_LOWERCASE;
5091
5156
  }
5092
5157
  var TMP_WBTC_ON_MAINNET = {
5093
5158
  chainId: 1,
@@ -5496,7 +5561,7 @@ var StatusBarSection = ({ children }) => {
5496
5561
  // src/components/FnxFloatingButton/StatusBarContent.tsx
5497
5562
  import { MdOutlineSettings } from "react-icons/md";
5498
5563
  import { IoIosCheckmarkCircleOutline, IoIosCloseCircleOutline } from "react-icons/io";
5499
- import { useMemo as useMemo21 } from "react";
5564
+ import { useMemo as useMemo22 } from "react";
5500
5565
 
5501
5566
  // src/components/primitives/AnimatedZStack.tsx
5502
5567
  import React from "react";
@@ -5647,7 +5712,7 @@ function sortStatuses(a, b) {
5647
5712
  }
5648
5713
  var StatusBarContent = () => {
5649
5714
  const { statuses } = usePortalStatuses();
5650
- const sortedStatuses = useMemo21(() => statuses.sort(sortStatuses), [statuses]);
5715
+ const sortedStatuses = useMemo22(() => statuses.sort(sortStatuses), [statuses]);
5651
5716
  return /* @__PURE__ */ jsxs4(AnimatedZStack, { children: [
5652
5717
  /* @__PURE__ */ jsx10(ConnectionStatus, {}),
5653
5718
  sortedStatuses.map((status) => /* @__PURE__ */ jsx10(ActiveStatusContent, { status }, status.id))
@@ -5655,7 +5720,7 @@ var StatusBarContent = () => {
5655
5720
  };
5656
5721
 
5657
5722
  // src/components/FnxFloatingButton/ContentSection.tsx
5658
- import { useEffect as useEffect12, useMemo as useMemo31, useRef as useRef8 } from "react";
5723
+ import { useEffect as useEffect12, useMemo as useMemo32, useRef as useRef8 } from "react";
5659
5724
 
5660
5725
  // src/components/FnxFloatingButton/pages/MainPage/WalletHeader.tsx
5661
5726
  import { MdOutlineAccountBalanceWallet } from "react-icons/md";
@@ -5931,26 +5996,40 @@ var CofheTokenPublicBalance = ({
5931
5996
  function useCofhePinnedTokenAddress() {
5932
5997
  const widgetConfig = useCofheContext().client.config.react;
5933
5998
  const chainId = useCofheChainId();
5934
- const pinnedTokenAddress = chainId ? widgetConfig.pinnedTokens[chainId?.toString()] : void 0;
5999
+ const pinnedTokenAddress = chainId ? widgetConfig.pinnedTokens?.[chainId?.toString()] : void 0;
5935
6000
  return pinnedTokenAddress;
5936
6001
  }
5937
6002
 
6003
+ // src/hooks/useCofhePinnedToken.ts
6004
+ function useCofhePinnedToken({ enabled } = {}) {
6005
+ const pinnedTokenAddress = useCofhePinnedTokenAddress();
6006
+ const token = useCofheToken(
6007
+ {
6008
+ address: pinnedTokenAddress
6009
+ },
6010
+ {
6011
+ // only fetch metadata if pinned token address is defined
6012
+ enabled: enabled !== false && !!pinnedTokenAddress
6013
+ }
6014
+ );
6015
+ return token;
6016
+ }
6017
+
5938
6018
  // src/components/FnxFloatingButton/pages/MainPage/AssetCard.tsx
5939
6019
  import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
5940
6020
  var AssetCard = () => {
5941
6021
  const { navigateTo } = usePortalNavigation();
5942
- const pinnedTokenAddress = useCofhePinnedTokenAddress();
5943
- const tokenFromList = useCofheToken({
5944
- address: pinnedTokenAddress
5945
- });
6022
+ const pinnedToken = useCofhePinnedToken();
6023
+ const chainId = useCofheChainId();
6024
+ const fallbackToken = chainId ? DEFAULT_TOKEN_BY_CHAIN_ID[chainId] : void 0;
6025
+ const token = pinnedToken ?? fallbackToken;
5946
6026
  const handleClick = () => {
5947
- if (!tokenFromList) throw new Error("Token not found in token list");
5948
- if (pinnedTokenAddress) {
6027
+ if (token) {
5949
6028
  navigateTo("tokeninfo" /* TokenInfo */, {
5950
- pageProps: { token: tokenFromList }
6029
+ pageProps: { token }
5951
6030
  });
5952
6031
  } else {
5953
- alert("Native token info navigation is not implemented yet.");
6032
+ throw new Error("No token found for AssetCard. No pinned token and no fallback token for current chain.");
5954
6033
  }
5955
6034
  };
5956
6035
  return /* @__PURE__ */ jsx21(
@@ -5960,14 +6039,14 @@ var AssetCard = () => {
5960
6039
  className: cn("fnx-card-bg p-4 cursor-pointer", "hover:opacity-90 transition-opacity", "border fnx-card-border"),
5961
6040
  children: /* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between", children: [
5962
6041
  /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-3 flex-1", children: [
5963
- /* @__PURE__ */ jsx21(TokenIcon, { logoURI: tokenFromList?.logoURI, alt: tokenFromList?.symbol, size: "md" }),
5964
- /* @__PURE__ */ jsx21("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx21("h3", { className: "text-lg font-bold fnx-text-primary", children: tokenFromList?.symbol }) })
6042
+ /* @__PURE__ */ jsx21(TokenIcon, { logoURI: token?.logoURI, alt: token?.symbol, size: "md" }),
6043
+ /* @__PURE__ */ jsx21("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx21("h3", { className: "text-lg font-bold fnx-text-primary", children: token?.symbol }) })
5965
6044
  ] }),
5966
6045
  /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
5967
6046
  /* @__PURE__ */ jsx21("div", { className: "flex flex-col items-end", children: /* @__PURE__ */ jsx21(
5968
6047
  CofheTokenConfidentialBalance,
5969
6048
  {
5970
- token: tokenFromList,
6049
+ token,
5971
6050
  showSymbol: false,
5972
6051
  size: "xl",
5973
6052
  decimalPrecision: 5,
@@ -5987,23 +6066,6 @@ import { IoMdKey } from "react-icons/io";
5987
6066
  import { AiOutlinePieChart } from "react-icons/ai";
5988
6067
  import { TbShieldPlus as TbShieldPlus2 } from "react-icons/tb";
5989
6068
  import { FaBug } from "react-icons/fa";
5990
-
5991
- // src/hooks/useCofhePinnedToken.ts
5992
- function useCofhePinnedToken({ enabled } = {}) {
5993
- const pinnedTokenAddress = useCofhePinnedTokenAddress();
5994
- const token = useCofheToken(
5995
- {
5996
- address: pinnedTokenAddress
5997
- },
5998
- {
5999
- // only fetch metadata if pinned token address is defined
6000
- enabled: enabled !== false && !!pinnedTokenAddress
6001
- }
6002
- );
6003
- return token;
6004
- }
6005
-
6006
- // src/components/FnxFloatingButton/pages/MainPage/BottomNavigation.tsx
6007
6069
  var import_ts_essentials19 = __toESM(require_dist(), 1);
6008
6070
 
6009
6071
  // src/components/FnxFloatingButton/components/ActionButton.tsx
@@ -6171,7 +6233,7 @@ var Button = ({
6171
6233
  };
6172
6234
 
6173
6235
  // src/components/FnxFloatingButton/components/TokenPriceChart.tsx
6174
- import { useId, useMemo as useMemo22 } from "react";
6236
+ import { useId, useMemo as useMemo23 } from "react";
6175
6237
  import {
6176
6238
  Area,
6177
6239
  AreaChart,
@@ -6211,7 +6273,7 @@ var themeClasses = {
6211
6273
  };
6212
6274
  var TokenPriceChart = ({ points, className, height = 150 }) => {
6213
6275
  const gradientId = useId();
6214
- const { start, mid, end } = useMemo22(() => {
6276
+ const { start, mid, end } = useMemo23(() => {
6215
6277
  if (!points.length) {
6216
6278
  const now = Date.now();
6217
6279
  return { start: now - 24 * 36e5, mid: now - 12 * 36e5, end: now };
@@ -6390,7 +6452,10 @@ var navItems = [...baseNavItems, ...!isProduction() ? [debugNavItem] : []];
6390
6452
  var BottomNavigation = () => {
6391
6453
  const { navigateTo } = usePortalNavigation();
6392
6454
  const { openPortal } = usePortalUI();
6393
- const defaultToken = useCofhePinnedToken();
6455
+ const pinnedToken = useCofhePinnedToken();
6456
+ const chainId = useCofheChainId();
6457
+ const fallbackToken = chainId ? DEFAULT_TOKEN_BY_CHAIN_ID[chainId] : void 0;
6458
+ const defaultToken = pinnedToken ?? fallbackToken;
6394
6459
  const handleNavClick = (page) => {
6395
6460
  openPortal();
6396
6461
  if (page === "portfolio" /* Portfolio */) {
@@ -6494,19 +6559,19 @@ import { FaKey, FaDownload, FaPlus } from "react-icons/fa";
6494
6559
  import "react";
6495
6560
 
6496
6561
  // src/components/FnxFloatingButton/Accordion.tsx
6497
- import { createContext as createContext3, useCallback as useCallback11, useContext as useContext4, useMemo as useMemo23, useState as useState9 } from "react";
6562
+ import { createContext as createContext3, useCallback as useCallback12, useContext as useContext4, useMemo as useMemo24, useState as useState9 } from "react";
6498
6563
  import { FaChevronDown, FaChevronUp } from "react-icons/fa6";
6499
6564
  import { jsx as jsx31, jsxs as jsxs20 } from "react/jsx-runtime";
6500
6565
  var AccordionContext = createContext3(void 0);
6501
6566
  var Accordion = ({ children, defaultActiveId = null }) => {
6502
6567
  const [activeId, setActiveId] = useState9(defaultActiveId);
6503
- const handleToggle = useCallback11(
6568
+ const handleToggle = useCallback12(
6504
6569
  (id) => {
6505
6570
  setActiveId(activeId === id ? null : id);
6506
6571
  },
6507
6572
  [activeId]
6508
6573
  );
6509
- const contextValue = useMemo23(
6574
+ const contextValue = useMemo24(
6510
6575
  () => ({
6511
6576
  activeId,
6512
6577
  toggle: handleToggle
@@ -6622,7 +6687,7 @@ import { zeroAddress as zeroAddress2 } from "viem";
6622
6687
  import "@cofhe/sdk/permits";
6623
6688
 
6624
6689
  // src/components/StripedBackground.tsx
6625
- import { useMemo as useMemo24 } from "react";
6690
+ import { useMemo as useMemo25 } from "react";
6626
6691
  import { jsx as jsx34 } from "react/jsx-runtime";
6627
6692
  function StripedBackground({
6628
6693
  stripeColor = "rgba(255,255,255,0.18)",
@@ -6631,7 +6696,7 @@ function StripedBackground({
6631
6696
  style,
6632
6697
  children
6633
6698
  }) {
6634
- const bgImage = useMemo24(() => {
6699
+ const bgImage = useMemo25(() => {
6635
6700
  return `repeating-linear-gradient(
6636
6701
  45deg,
6637
6702
  ${stripeColor} 0px,
@@ -6668,7 +6733,7 @@ var PermitStripedBackground = ({ variant, className, children }) => {
6668
6733
  };
6669
6734
 
6670
6735
  // src/components/FnxFloatingButton/components/PermitCard.tsx
6671
- import { useMemo as useMemo25 } from "react";
6736
+ import { useMemo as useMemo26 } from "react";
6672
6737
  import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs22 } from "react/jsx-runtime";
6673
6738
  var PermitTypeLabel = {
6674
6739
  self: "Self",
@@ -6686,7 +6751,7 @@ var BasePermitCard = ({
6686
6751
  }) => {
6687
6752
  const activePermitHash = useCofheActivePermitHash();
6688
6753
  const expirationInfo = formatExpirationLabel(permit.expiration);
6689
- const metadataTags = useMemo25(() => {
6754
+ const metadataTags = useMemo26(() => {
6690
6755
  const isActivePermit = permit.hash === activePermitHash;
6691
6756
  const tags = [];
6692
6757
  if (expirationInfo.expired) tags.push("expired");
@@ -7301,12 +7366,12 @@ var ImportPermitPage = () => {
7301
7366
  };
7302
7367
 
7303
7368
  // src/components/FnxFloatingButton/pages/TokenInfoPage.tsx
7304
- import { sepolia } from "@cofhe/sdk/chains";
7305
- import { useMemo as useMemo28 } from "react";
7369
+ import { sepolia as sepolia2 } from "@cofhe/sdk/chains";
7370
+ import { useMemo as useMemo29 } from "react";
7306
7371
  import ArrowBackIcon6 from "@mui/icons-material/ArrowBack";
7307
7372
 
7308
7373
  // src/components/FnxFloatingButton/pages/TokenInfoBalanceChart.tsx
7309
- import { useMemo as useMemo26 } from "react";
7374
+ import { useMemo as useMemo27 } from "react";
7310
7375
  import LockIcon from "@mui/icons-material/Lock";
7311
7376
  import PublicIcon from "@mui/icons-material/Public";
7312
7377
  import { Fragment as Fragment7, jsx as jsx45, jsxs as jsxs30 } from "react/jsx-runtime";
@@ -7324,7 +7389,7 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
7324
7389
  token
7325
7390
  });
7326
7391
  const isFetchingBalances = isFetchingConfidentialBalance || isFetchingPublicBalance;
7327
- const balancePercents = useMemo26(() => {
7392
+ const balancePercents = useMemo27(() => {
7328
7393
  if (!confidentialBalance && !publicBalance) return;
7329
7394
  const confidentialUnit = confidentialBalance?.unit ?? null;
7330
7395
  const publicUnit = publicBalance?.unit ?? null;
@@ -7336,7 +7401,7 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
7336
7401
  publicPct
7337
7402
  };
7338
7403
  }, [confidentialBalance, publicBalance]);
7339
- const price = useMemo26(() => {
7404
+ const price = useMemo27(() => {
7340
7405
  const lastPoint = chartPoints?.[chartPoints.length - 1];
7341
7406
  const firstPoint = chartPoints?.[0];
7342
7407
  if (!lastPoint || !firstPoint) return;
@@ -7411,7 +7476,7 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
7411
7476
  };
7412
7477
 
7413
7478
  // src/components/FnxFloatingButton/pages/TokenInfoTransactionHistory.tsx
7414
- import { useMemo as useMemo27 } from "react";
7479
+ import { useMemo as useMemo28 } from "react";
7415
7480
  import { formatUnits as formatUnits2 } from "viem";
7416
7481
  import { jsx as jsx46, jsxs as jsxs31 } from "react/jsx-runtime";
7417
7482
  var TokenInfoTransactionHistoryHeader = ({ token }) => {
@@ -7434,7 +7499,7 @@ var TokenInfoTransactionHistory = ({ token, priceUsd }) => {
7434
7499
  account,
7435
7500
  filter: (tx) => tx.token.address.toLowerCase() === token.address.toLowerCase()
7436
7501
  });
7437
- const activity = useMemo27(() => {
7502
+ const activity = useMemo28(() => {
7438
7503
  return tokenTxs.slice().sort((a, b) => b.timestamp - a.timestamp).map((tx) => {
7439
7504
  const amountToken = parseFloat(formatUnits2(tx.tokenAmount, tx.token.decimals));
7440
7505
  const amountUsd = typeof priceUsd === "number" && Number.isFinite(amountToken) ? amountToken * priceUsd : void 0;
@@ -7477,7 +7542,7 @@ import { Fragment as Fragment8, jsx as jsx47, jsxs as jsxs32 } from "react/jsx-r
7477
7542
  var TokenInfoPage = ({ token }) => {
7478
7543
  const { navigateBack, navigateTo } = usePortalNavigation();
7479
7544
  const { data: chartPoints } = useCoingeckoContractMarketChartRange({
7480
- ...token.chainId === sepolia.id ? {
7545
+ ...token.chainId === sepolia2.id ? {
7481
7546
  chainId: TMP_WBTC_ON_MAINNET.chainId,
7482
7547
  contractAddress: TMP_WBTC_ON_MAINNET.address
7483
7548
  } : {
@@ -7486,7 +7551,7 @@ var TokenInfoPage = ({ token }) => {
7486
7551
  },
7487
7552
  rangeMs: 24 * 36e5
7488
7553
  });
7489
- const priceUsd = useMemo28(() => {
7554
+ const priceUsd = useMemo29(() => {
7490
7555
  const lastPoint = chartPoints?.[chartPoints.length - 1];
7491
7556
  return lastPoint?.value;
7492
7557
  }, [chartPoints]);
@@ -7540,7 +7605,7 @@ var TokenInfoPage = ({ token }) => {
7540
7605
  };
7541
7606
 
7542
7607
  // src/components/FnxFloatingButton/pages/SendPage.tsx
7543
- import { useState as useState10, useMemo as useMemo29 } from "react";
7608
+ import { useState as useState10, useMemo as useMemo30 } from "react";
7544
7609
  import ArrowBackIcon7 from "@mui/icons-material/ArrowBack";
7545
7610
  import KeyboardArrowRightIcon2 from "@mui/icons-material/KeyboardArrowRight";
7546
7611
  import { isAddress as isAddress2, maxUint128 } from "viem";
@@ -7591,7 +7656,7 @@ var SendPage = ({ token: _token }) => {
7591
7656
  token,
7592
7657
  accountAddress: account
7593
7658
  });
7594
- const encryptionProgressLabel = useMemo29(() => lastStep?.step && getStepConfig(lastStep).label, [lastStep]);
7659
+ const encryptionProgressLabel = useMemo30(() => lastStep?.step && getStepConfig(lastStep).label, [lastStep]);
7595
7660
  const [amount, setAmount] = useState10("");
7596
7661
  const [recipientAddress, setRecipientAddress] = useState10("");
7597
7662
  const [error, setError] = useState10(null);
@@ -7742,15 +7807,16 @@ var SendPage = ({ token: _token }) => {
7742
7807
  import ArrowBackIcon8 from "@mui/icons-material/ArrowBack";
7743
7808
  import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
7744
7809
  import { TbShieldPlus as TbShieldPlus3, TbShieldMinus as TbShieldMinus2 } from "react-icons/tb";
7810
+ import { LuExternalLink as LuExternalLink2 } from "react-icons/lu";
7745
7811
  import { useState as useState11 } from "react";
7746
7812
  import { parseUnits } from "viem";
7747
7813
  var import_ts_essentials21 = __toESM(require_dist(), 1);
7748
7814
 
7749
7815
  // src/hooks/useIsUnshieldingMining.ts
7750
- import { useCallback as useCallback12 } from "react";
7816
+ import { useCallback as useCallback13 } from "react";
7751
7817
  function useIsUnshieldingMining(token) {
7752
7818
  const account = useCofheAccount();
7753
- const filter3 = useCallback12(
7819
+ const filter3 = useCallback13(
7754
7820
  (tx) => {
7755
7821
  return tx.token.address === token.address && tx.actionType === "unshield" /* Unshield */ && tx.status === "pending" /* Pending */;
7756
7822
  },
@@ -7778,8 +7844,37 @@ function useLifecycleStore() {
7778
7844
  setStatus
7779
7845
  };
7780
7846
  }
7847
+ function TxHashWithActions({ hash, chainId }) {
7848
+ const href = chainId ? getBlockExplorerTxUrl(chainId, hash) : void 0;
7849
+ const ellipsed = truncateHash(hash);
7850
+ const handleOpenExplorer = () => {
7851
+ if (href) {
7852
+ window.open(href, "_blank", "noopener,noreferrer");
7853
+ }
7854
+ };
7855
+ return /* @__PURE__ */ jsxs34("span", { className: "inline-flex items-center gap-1.5 align-baseline", children: [
7856
+ /* @__PURE__ */ jsx49("span", { className: "font-mono", children: ellipsed }),
7857
+ /* @__PURE__ */ jsx49(CopyButton, { text: hash, size: 14 }),
7858
+ /* @__PURE__ */ jsx49(
7859
+ "button",
7860
+ {
7861
+ type: "button",
7862
+ onClick: handleOpenExplorer,
7863
+ disabled: !href,
7864
+ "aria-label": "Open transaction in explorer",
7865
+ title: href ? "Open in explorer" : "Explorer not available for this chain",
7866
+ className: cn(
7867
+ "fnx-text-primary opacity-50 hover:opacity-100 transition-opacity cursor-pointer",
7868
+ !href && "cursor-default opacity-30"
7869
+ ),
7870
+ children: /* @__PURE__ */ jsx49(LuExternalLink2, { style: { width: 14, height: 14 } })
7871
+ }
7872
+ )
7873
+ ] });
7874
+ }
7781
7875
  function useClaimUnshieldedWithLifecycle() {
7782
7876
  const { setError, setStatus, error, status } = useLifecycleStore();
7877
+ const chainId = useCofheChainId();
7783
7878
  const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
7784
7879
  const claimUnshield = useCofheTokenClaimUnshielded({
7785
7880
  onMutate: () => {
@@ -7788,7 +7883,11 @@ function useClaimUnshieldedWithLifecycle() {
7788
7883
  },
7789
7884
  onSuccess: (hash) => {
7790
7885
  setStatus({
7791
- message: `Claim transaction sent! Hash: ${truncateHash(hash)}. Waiting for confirmation...`,
7886
+ message: /* @__PURE__ */ jsxs34(Fragment10, { children: [
7887
+ "Claim transaction sent! Hash: ",
7888
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash, chainId }),
7889
+ " Waiting for confirmation..."
7890
+ ] }),
7792
7891
  type: "info"
7793
7892
  });
7794
7893
  },
@@ -7804,11 +7903,19 @@ function useClaimUnshieldedWithLifecycle() {
7804
7903
  onceMined: (transaction) => {
7805
7904
  if (transaction.status === "confirmed") {
7806
7905
  setStatus({
7807
- message: `Claim transaction confirmed! Hash: ${truncateHash(transaction.hash)}`,
7906
+ message: /* @__PURE__ */ jsxs34(Fragment10, { children: [
7907
+ "Claim transaction confirmed! Hash: ",
7908
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash: transaction.hash, chainId })
7909
+ ] }),
7808
7910
  type: "success"
7809
7911
  });
7810
7912
  } else if (transaction.status === "failed") {
7811
- setError(`Claim transaction failed! Hash: ${truncateHash(transaction.hash)}`);
7913
+ setError(
7914
+ /* @__PURE__ */ jsxs34(Fragment10, { children: [
7915
+ "Claim transaction failed! Hash: ",
7916
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash: transaction.hash, chainId })
7917
+ ] })
7918
+ );
7812
7919
  setStatus(null);
7813
7920
  }
7814
7921
  scheduleStatusClear();
@@ -7823,6 +7930,7 @@ function useClaimUnshieldedWithLifecycle() {
7823
7930
  }
7824
7931
  function useShieldWithLifecycle(token) {
7825
7932
  const account = useCofheAccount();
7933
+ const chainId = useCofheChainId();
7826
7934
  const [shieldAmount, setShieldAmount] = useState11("");
7827
7935
  const { setError, setStatus, error, status } = useLifecycleStore();
7828
7936
  const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
@@ -7833,7 +7941,11 @@ function useShieldWithLifecycle(token) {
7833
7941
  },
7834
7942
  onSuccess: (hash) => {
7835
7943
  setStatus({
7836
- message: `Shield transaction sent! Hash: ${truncateHash(hash)}. Waiting for confirmation...`,
7944
+ message: /* @__PURE__ */ jsxs34(Fragment10, { children: [
7945
+ "Shield transaction sent! Hash: ",
7946
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash, chainId }),
7947
+ " Waiting for confirmation..."
7948
+ ] }),
7837
7949
  type: "info"
7838
7950
  });
7839
7951
  setShieldAmount("");
@@ -7850,11 +7962,19 @@ function useShieldWithLifecycle(token) {
7850
7962
  onceMined: (transaction) => {
7851
7963
  if (transaction.status === "confirmed") {
7852
7964
  setStatus({
7853
- message: `Shield transaction confirmed! Hash: ${truncateHash(transaction.hash)}`,
7965
+ message: /* @__PURE__ */ jsxs34(Fragment10, { children: [
7966
+ "Shield transaction confirmed! Hash: ",
7967
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash: transaction.hash, chainId })
7968
+ ] }),
7854
7969
  type: "success"
7855
7970
  });
7856
7971
  } else if (transaction.status === "failed") {
7857
- setError(`Shield transaction failed! Hash: ${truncateHash(transaction.hash)}`);
7972
+ setError(
7973
+ /* @__PURE__ */ jsxs34(Fragment10, { children: [
7974
+ "Shield transaction failed! Hash: ",
7975
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash: transaction.hash, chainId })
7976
+ ] })
7977
+ );
7858
7978
  setStatus(null);
7859
7979
  }
7860
7980
  scheduleStatusClear();
@@ -7896,6 +8016,7 @@ function useShieldWithLifecycle(token) {
7896
8016
  }
7897
8017
  function useUnshieldWithLifecycle(token) {
7898
8018
  const account = useCofheAccount();
8019
+ const chainId = useCofheChainId();
7899
8020
  const { setError, setStatus, error, status } = useLifecycleStore();
7900
8021
  const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
7901
8022
  const [unshieldAmount, setUnshieldAmount] = useState11("");
@@ -7908,7 +8029,11 @@ function useUnshieldWithLifecycle(token) {
7908
8029
  },
7909
8030
  onTransactionSubmitSuccess: (hash) => {
7910
8031
  setStatus({
7911
- message: `Unshield transaction sent! Hash: ${truncateHash(hash)}. Waiting for confirmation...`,
8032
+ message: /* @__PURE__ */ jsxs34(Fragment10, { children: [
8033
+ "Unshield transaction sent! Hash: ",
8034
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash, chainId }),
8035
+ " Waiting for confirmation..."
8036
+ ] }),
7912
8037
  type: "info"
7913
8038
  });
7914
8039
  setUnshieldAmount("");
@@ -7922,11 +8047,20 @@ function useUnshieldWithLifecycle(token) {
7922
8047
  onceMined: (transaction) => {
7923
8048
  if (transaction.status === "confirmed") {
7924
8049
  setStatus({
7925
- message: `Unshield transaction confirmed! Hash: ${truncateHash(transaction.hash)}. Now waiting for decryption...`,
8050
+ message: /* @__PURE__ */ jsxs34(Fragment10, { children: [
8051
+ "Unshield transaction confirmed! Hash: ",
8052
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash: transaction.hash, chainId }),
8053
+ " Now waiting for decryption..."
8054
+ ] }),
7926
8055
  type: "success"
7927
8056
  });
7928
8057
  } else if (transaction.status === "failed") {
7929
- setError(`Unshield transaction failed! Hash: ${truncateHash(transaction.hash)}`);
8058
+ setError(
8059
+ /* @__PURE__ */ jsxs34(Fragment10, { children: [
8060
+ "Unshield transaction failed! Hash: ",
8061
+ /* @__PURE__ */ jsx49(TxHashWithActions, { hash: transaction.hash, chainId })
8062
+ ] })
8063
+ );
7930
8064
  setStatus(null);
7931
8065
  }
7932
8066
  },
@@ -8034,10 +8168,7 @@ function ClaimingSection({ token }) {
8034
8168
  /* @__PURE__ */ jsx49(StatusAndError, { status: claimingStatus, error: claimingError })
8035
8169
  ] });
8036
8170
  }
8037
- function StatusAndError({
8038
- status,
8039
- error
8040
- }) {
8171
+ function StatusAndError({ status, error }) {
8041
8172
  return /* @__PURE__ */ jsxs34(Fragment10, { children: [
8042
8173
  error && /* @__PURE__ */ jsx49("div", { className: "bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-2", children: /* @__PURE__ */ jsx49("p", { className: "text-xs text-red-800 dark:text-red-200", children: error }) }),
8043
8174
  status && /* @__PURE__ */ jsx49(
@@ -8647,7 +8778,7 @@ import ArrowBackIcon11 from "@mui/icons-material/ArrowBack";
8647
8778
 
8648
8779
  // src/components/FnxFloatingButton/components/TokenRow.tsx
8649
8780
  import KeyboardArrowRightIcon3 from "@mui/icons-material/KeyboardArrowRight";
8650
- import { sepolia as sepolia2 } from "@cofhe/sdk/chains";
8781
+ import { sepolia as sepolia3 } from "@cofhe/sdk/chains";
8651
8782
  import { jsx as jsx52, jsxs as jsxs37 } from "react/jsx-runtime";
8652
8783
  var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
8653
8784
  const account = useCofheAccount();
@@ -8662,7 +8793,7 @@ var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
8662
8793
  );
8663
8794
  const { data: publicBalance } = useCofheTokenPublicBalance({ token, accountAddress: account });
8664
8795
  const { data: price } = useCoingeckoUsdPrice(
8665
- token.chainId === sepolia2.id ? {
8796
+ token.chainId === sepolia3.id ? {
8666
8797
  chainId: TMP_WBTC_ON_MAINNET.chainId,
8667
8798
  tokenAddress: TMP_WBTC_ON_MAINNET.address
8668
8799
  } : {
@@ -8826,7 +8957,7 @@ var PortfolioPage = () => {
8826
8957
 
8827
8958
  // src/components/FnxFloatingButton/pages/ClaimableTokens.tsx
8828
8959
  import ArrowBackIcon13 from "@mui/icons-material/ArrowBack";
8829
- import { useMemo as useMemo30 } from "react";
8960
+ import { useMemo as useMemo31 } from "react";
8830
8961
  var import_ts_essentials22 = __toESM(require_dist(), 1);
8831
8962
  import { jsx as jsx55, jsxs as jsxs40 } from "react/jsx-runtime";
8832
8963
  function ClaimableTokens() {
@@ -8839,7 +8970,7 @@ function ClaimableTokens() {
8839
8970
  const chainId = useCofheChainId();
8840
8971
  const allTokens = useCofheTokens(chainId);
8841
8972
  const claimMutation = useCofheTokenClaimUnshielded();
8842
- const rows = useMemo30(() => {
8973
+ const rows = useMemo31(() => {
8843
8974
  const byLower = new Map(allTokens.map((t) => [t.address.toLowerCase(), t]));
8844
8975
  return Object.entries(claimableByTokenAddress).filter(([_t, amount]) => amount > 0n).map(([tokenAddress, claimableAmount]) => {
8845
8976
  const token = byLower.get(tokenAddress.toLowerCase());
@@ -8989,7 +9120,7 @@ var ExampleInfoPage = ({ onClose }) => {
8989
9120
  // src/components/FnxFloatingButton/modals/PermitDetailsModal.tsx
8990
9121
  import { FaCheck as FaCheck2, FaRegCopy as FaRegCopy2 } from "react-icons/fa6";
8991
9122
  import CloseIcon4 from "@mui/icons-material/Close";
8992
- import { useCallback as useCallback13, useState as useState14 } from "react";
9123
+ import { useCallback as useCallback14, useState as useState14 } from "react";
8993
9124
  import { jsx as jsx58, jsxs as jsxs43 } from "react/jsx-runtime";
8994
9125
  var PermitTypeLabel2 = {
8995
9126
  self: "Self",
@@ -9019,14 +9150,14 @@ var PermitDetailsModal = ({ hash, onClose }) => {
9019
9150
  } = usePermitDetailsAndActions(hash);
9020
9151
  const { openModal } = usePortalModals();
9021
9152
  const [confirmDelete, setConfirmDelete] = useState14(false);
9022
- const handlePermitSelect = useCallback13(() => {
9153
+ const handlePermitSelect = useCallback14(() => {
9023
9154
  handleSelectActivePermit();
9024
9155
  onClose();
9025
9156
  }, [handleSelectActivePermit, onClose]);
9026
- const handlePermitShare = useCallback13(() => {
9157
+ const handlePermitShare = useCallback14(() => {
9027
9158
  handleCopySharablePermitData();
9028
9159
  }, [handleCopySharablePermitData]);
9029
- const handlePermitDelete = useCallback13(async () => {
9160
+ const handlePermitDelete = useCallback14(async () => {
9030
9161
  if (!confirmDelete) {
9031
9162
  setConfirmDelete(true);
9032
9163
  return;
@@ -9233,7 +9364,7 @@ var MeasuredContentRenderer = ({ children, id, isModal, onModalOverlayClick }) =
9233
9364
  ] });
9234
9365
  };
9235
9366
  var ContentRenderer = ({ page }) => {
9236
- const content = useMemo31(() => {
9367
+ const content = useMemo32(() => {
9237
9368
  const PageComp = pages[page.page];
9238
9369
  const props = page.props ?? {};
9239
9370
  return /* @__PURE__ */ jsx62(PageComp, { ...props });
@@ -9241,7 +9372,7 @@ var ContentRenderer = ({ page }) => {
9241
9372
  return /* @__PURE__ */ jsx62(MeasuredContentRenderer, { id: "content", children: content });
9242
9373
  };
9243
9374
  var ModalRenderer = ({ modal }) => {
9244
- const content = useMemo31(() => {
9375
+ const content = useMemo32(() => {
9245
9376
  const ModalComp = modals[modal.modal];
9246
9377
  return /* @__PURE__ */ jsx62(ModalComp, { ...modal });
9247
9378
  }, [modal]);
@@ -9407,14 +9538,14 @@ var FnxFloatingButtonWithProvider = (props) => {
9407
9538
  // src/config.ts
9408
9539
  import { z } from "zod";
9409
9540
  import "@cofhe/sdk";
9410
- import { createCofhesdkConfig as createCofhesdkConfigWeb } from "@cofhe/sdk/web";
9541
+ import { createCofheConfig as createCofheConfigWeb } from "@cofhe/sdk/web";
9411
9542
  import { getAddress, isAddress as isAddress3, zeroAddress as zeroAddress3 } from "viem";
9412
9543
  var addressSchema = z.string().refine((val) => isAddress3(val), {
9413
9544
  error: "Invalid address"
9414
9545
  }).refine((val) => val !== zeroAddress3, {
9415
9546
  error: "Must not be zeroAddress"
9416
9547
  }).transform((val) => getAddress(val));
9417
- var CofhesdkReactConfigSchema = z.object({
9548
+ var CofheReactConfigSchema = z.object({
9418
9549
  shareablePermits: z.boolean().optional().default(false),
9419
9550
  enableShieldUnshield: z.boolean().optional().default(true),
9420
9551
  autogeneratePermits: z.boolean().optional().default(true),
@@ -9430,30 +9561,20 @@ var CofhesdkReactConfigSchema = z.object({
9430
9561
  ]),
9431
9562
  defaultPermitExpirationSeconds: z.number().optional().default(604800),
9432
9563
  // 1 week
9433
- pinnedTokens: z.record(z.string(), addressSchema).optional().default({
9434
- 11155111: "0x87A3effB84CBE1E4caB6Ab430139eC41d156D55A",
9435
- // sepolia weth
9436
- 84532: "0xbED96aa98a49FeA71fcC55d755b915cF022a9159"
9437
- // base sepolia weth
9438
- // 421613: '0x980b62da83eff3d4576c647993b0c1d7faf17c73', // arbitrum sepolia weth
9439
- }),
9440
- tokenLists: z.record(z.string(), z.array(z.string())).optional().default({
9441
- 11155111: ["https://storage.googleapis.com/cofhesdk/sepolia.json"],
9442
- 84532: ["https://storage.googleapis.com/cofhesdk/base-sepolia.json"]
9443
- // 421613: ['https://tokens.cofhe.io/arbitrum-sepolia.json'],
9444
- }).transform((lists) => lists),
9564
+ pinnedTokens: z.record(z.string(), addressSchema).optional(),
9565
+ tokenLists: z.record(z.string(), z.array(z.string())).transform((lists) => lists).optional(),
9445
9566
  position: z.enum(["bottom-right", "bottom-left", "top-right", "top-left"]).optional().default("bottom-right"),
9446
9567
  initialTheme: z.enum(["dark", "light"]).optional().default("light")
9447
9568
  });
9448
- function createCofhesdkConfig(config) {
9569
+ function createCofheConfig(config) {
9449
9570
  const { react: reactConfigInput = {}, ...webConfig } = config;
9450
- const webClientConfig = createCofhesdkConfigWeb({
9571
+ const webClientConfig = createCofheConfigWeb({
9451
9572
  environment: "react",
9452
9573
  ...webConfig
9453
9574
  });
9454
- const reactConfigResult = CofhesdkReactConfigSchema.safeParse(reactConfigInput);
9575
+ const reactConfigResult = CofheReactConfigSchema.safeParse(reactConfigInput);
9455
9576
  if (!reactConfigResult.success) {
9456
- throw new Error(`Invalid cofhesdk react configuration: ${z.prettifyError(reactConfigResult.error)}`, {
9577
+ throw new Error(`Invalid cofhe react configuration: ${z.prettifyError(reactConfigResult.error)}`, {
9457
9578
  cause: reactConfigResult.error
9458
9579
  });
9459
9580
  }
@@ -9470,25 +9591,22 @@ import { jsx as jsx66, jsxs as jsxs51 } from "react/jsx-runtime";
9470
9591
  var CofheContext = createContext4(void 0);
9471
9592
  function CofheProvider(props) {
9472
9593
  const { children, queryClient, publicClient, walletClient } = props;
9473
- const config = useMemo32(() => {
9594
+ const config = useMemo33(() => {
9474
9595
  if (props.config) return props.config;
9475
- if (props.cofhesdkClient) {
9476
- (0, import_ts_essentials23.assert)(config.environment === "react", "Provided cofhesdkClient must have react config");
9477
- return props.cofhesdkClient.config;
9478
- }
9479
- return createCofhesdkConfig({ supportedChains: Object.values(chains) });
9480
- }, [props.config, props.cofhesdkClient]);
9481
- const cofhesdkClient = useMemo32(
9482
- () => props.cofhesdkClient ?? createCofhesdkClient(config),
9483
- [props.cofhesdkClient, config]
9484
- );
9596
+ if (props.cofheClient) {
9597
+ (0, import_ts_essentials23.assert)(config.environment === "react", "Provided cofheClient must have react config");
9598
+ return props.cofheClient.config;
9599
+ }
9600
+ return createCofheConfig({ supportedChains: Object.values(chains) });
9601
+ }, [props.config, props.cofheClient]);
9602
+ const cofheClient = useMemo33(() => props.cofheClient ?? createCofheClient(config), [props.cofheClient, config]);
9485
9603
  const [position, setPosition] = useState15(config.react.position);
9486
9604
  const [theme, setTheme] = useState15(config.react.initialTheme);
9487
9605
  return /* @__PURE__ */ jsx66(
9488
9606
  CofheContext.Provider,
9489
9607
  {
9490
9608
  value: {
9491
- client: cofhesdkClient,
9609
+ client: cofheClient,
9492
9610
  state: {
9493
9611
  position,
9494
9612
  setPosition,
@@ -9516,7 +9634,7 @@ function useCofheContext() {
9516
9634
  }
9517
9635
 
9518
9636
  // src/components/FnxEncryptInput.tsx
9519
- import { useState as useState16, useRef as useRef10, useEffect as useEffect14, useMemo as useMemo33 } from "react";
9637
+ import { useState as useState16, useRef as useRef10, useEffect as useEffect14, useMemo as useMemo34 } from "react";
9520
9638
  import SecurityIcon from "@mui/icons-material/Security";
9521
9639
  import KeyboardArrowDownIcon2 from "@mui/icons-material/KeyboardArrowDown";
9522
9640
  import ContentCopyIcon from "@mui/icons-material/ContentCopy";
@@ -9554,7 +9672,7 @@ var FnxEncryptInput = ({
9554
9672
  isEncrypting,
9555
9673
  stepsState: { lastStep: lastEncryptionStep }
9556
9674
  } = useCofheEncrypt();
9557
- const { progress: encryptionProgress, label: encryptionProgressLabel } = useMemo33(() => {
9675
+ const { progress: encryptionProgress, label: encryptionProgressLabel } = useMemo34(() => {
9558
9676
  return lastEncryptionStep ? getStepConfig(lastEncryptionStep) : {
9559
9677
  progress: void 0,
9560
9678
  label: void 0
@@ -9831,10 +9949,10 @@ var FnxEncryptInput = ({
9831
9949
  };
9832
9950
 
9833
9951
  // src/index.ts
9834
- import { createCofhesdkClient as createCofhesdkClient2 } from "@cofhe/sdk/web";
9952
+ import { createCofheClient as createCofheClient2 } from "@cofhe/sdk/web";
9835
9953
  export {
9836
9954
  CofheProvider,
9837
- ETH_ADDRESS,
9955
+ ETH_ADDRESS_LOWERCASE,
9838
9956
  FheTypesList,
9839
9957
  FnxEncryptInput,
9840
9958
  FnxFloatingButtonWithProvider,
@@ -9843,8 +9961,8 @@ export {
9843
9961
  TransactionActionType,
9844
9962
  TransactionStatus,
9845
9963
  actionToString,
9846
- createCofhesdkClient2 as createCofhesdkClient,
9847
- createCofhesdkConfig,
9964
+ createCofheClient2 as createCofheClient,
9965
+ createCofheConfig,
9848
9966
  encryptedValueToString,
9849
9967
  fheTypeToString,
9850
9968
  formatRelativeTime,