@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.cjs CHANGED
@@ -739,7 +739,7 @@ var require_dist = __commonJS({
739
739
  var index_exports = {};
740
740
  __export(index_exports, {
741
741
  CofheProvider: () => CofheProvider,
742
- ETH_ADDRESS: () => ETH_ADDRESS,
742
+ ETH_ADDRESS_LOWERCASE: () => ETH_ADDRESS_LOWERCASE,
743
743
  FheTypesList: () => FheTypesList,
744
744
  FnxEncryptInput: () => FnxEncryptInput,
745
745
  FnxFloatingButtonWithProvider: () => FnxFloatingButtonWithProvider,
@@ -748,8 +748,8 @@ __export(index_exports, {
748
748
  TransactionActionType: () => TransactionActionType,
749
749
  TransactionStatus: () => TransactionStatus,
750
750
  actionToString: () => actionToString,
751
- createCofhesdkClient: () => import_web3.createCofhesdkClient,
752
- createCofhesdkConfig: () => createCofhesdkConfig,
751
+ createCofheClient: () => import_web3.createCofheClient,
752
+ createCofheConfig: () => createCofheConfig,
753
753
  encryptedValueToString: () => encryptedValueToString,
754
754
  fheTypeToString: () => fheTypeToString,
755
755
  formatRelativeTime: () => formatRelativeTime,
@@ -831,7 +831,53 @@ var cn = (...classes) => {
831
831
  var viemChains = __toESM(require("viem/chains"), 1);
832
832
 
833
833
  // src/types/token.ts
834
- var ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
834
+ var import_chains = require("@cofhe/sdk/chains");
835
+ var ETH_ADDRESS_LOWERCASE = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
836
+ var WETH_SEPOLIA_TOKEN = {
837
+ chainId: 11155111,
838
+ address: "0x87A3effB84CBE1E4caB6Ab430139eC41d156D55A",
839
+ name: "Redact eETH",
840
+ symbol: "eETH",
841
+ decimals: 18,
842
+ logoURI: "https://storage.googleapis.com/cofhesdk/token-icons/eth.webp",
843
+ extensions: {
844
+ fhenix: {
845
+ confidentialityType: "wrapped",
846
+ confidentialValueType: "uint128",
847
+ erc20Pair: {
848
+ address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
849
+ symbol: "ETH",
850
+ decimals: 18,
851
+ logoURI: "https://storage.googleapis.com/cofhesdk/token-icons/eth.webp"
852
+ }
853
+ }
854
+ }
855
+ };
856
+ var WETH_BASE_SEPOLIA_TOKEN = {
857
+ chainId: 84532,
858
+ address: "0xbED96aa98a49FeA71fcC55d755b915cF022a9159",
859
+ name: "Redact eETH",
860
+ symbol: "eETH",
861
+ decimals: 18,
862
+ logoURI: "https://storage.googleapis.com/cofhesdk/token-icons/eth.webp",
863
+ extensions: {
864
+ coingeckoId: "eeth",
865
+ fhenix: {
866
+ confidentialityType: "wrapped",
867
+ confidentialValueType: "uint128",
868
+ erc20Pair: {
869
+ address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
870
+ symbol: "ETH",
871
+ decimals: 18,
872
+ logoURI: "https://storage.googleapis.com/cofhesdk/token-icons/eth.webp"
873
+ }
874
+ }
875
+ }
876
+ };
877
+ var DEFAULT_TOKEN_BY_CHAIN_ID = {
878
+ [import_chains.sepolia.id]: WETH_SEPOLIA_TOKEN,
879
+ [import_chains.baseSepolia.id]: WETH_BASE_SEPOLIA_TOKEN
880
+ };
835
881
 
836
882
  // src/utils/utils.ts
837
883
  var import_react2 = require("react");
@@ -862,7 +908,7 @@ var getBlockExplorerTokenUrl = (chainId, tokenAddress) => {
862
908
  };
863
909
  var isEthPair = (erc20Pair) => {
864
910
  if (!erc20Pair) return false;
865
- return erc20Pair.address.toLowerCase() === ETH_ADDRESS.toLowerCase();
911
+ return erc20Pair.address.toLowerCase() === ETH_ADDRESS_LOWERCASE;
866
912
  };
867
913
  var isWrappedEthToken = (token) => {
868
914
  if (token.extensions.fhenix.confidentialityType !== "wrapped") return false;
@@ -1403,7 +1449,7 @@ var import_react5 = require("react");
1403
1449
  var import_react_error_boundary = require("react-error-boundary");
1404
1450
  function useIsCofheErrorActive() {
1405
1451
  const errorBoundaryContext = (0, import_react5.useContext)(import_react_error_boundary.ErrorBoundaryContext);
1406
- return errorBoundaryContext?.error instanceof import_sdk2.CofhesdkError;
1452
+ return errorBoundaryContext?.error instanceof import_sdk2.CofheError;
1407
1453
  }
1408
1454
 
1409
1455
  // src/hooks/useCofheReadContract.ts
@@ -1778,16 +1824,12 @@ function getTokenContractConfig(confidentialityType) {
1778
1824
  return CONFIDENTIAL_ABIS[confidentialityType];
1779
1825
  }
1780
1826
 
1781
- // src/hooks/useCofheTokenPublicBalance.ts
1782
- var import_react_query4 = require("@tanstack/react-query");
1783
- var import_viem5 = require("viem");
1784
-
1785
1827
  // src/hooks/useCofheTokenLists.ts
1786
1828
  var import_react_query3 = require("@tanstack/react-query");
1787
1829
  var import_react6 = require("react");
1788
1830
  function useCofheTokenLists({ chainId }, queryOptions) {
1789
1831
  const widgetConfig = useCofheContext().client.config.react;
1790
- const tokensListsUrls = chainId ? widgetConfig.tokenLists[chainId] : [];
1832
+ const tokensListsUrls = chainId ? widgetConfig.tokenLists?.[chainId] : [];
1791
1833
  const queriesOptions = tokensListsUrls?.map((url) => ({
1792
1834
  cacheTime: Infinity,
1793
1835
  staleTime: Infinity,
@@ -1843,6 +1885,10 @@ function useCofheToken({ chainId: _chainId, address }, metdataQueryOptions) {
1843
1885
  return tokenFromList;
1844
1886
  }
1845
1887
 
1888
+ // src/hooks/useCofheTokenPublicBalance.ts
1889
+ var import_react_query4 = require("@tanstack/react-query");
1890
+ var import_viem5 = require("viem");
1891
+
1846
1892
  // src/constants/erc20ABIs.ts
1847
1893
  var import_viem4 = require("viem");
1848
1894
  var ERC20_BALANCE_OF_ABI = (0, import_viem4.parseAbi)(["function balanceOf(address owner) view returns (uint256)"]);
@@ -1917,7 +1963,7 @@ function createPublicTokenBalanceQueryOptions(params) {
1917
1963
  (0, import_ts_essentials2.assert)(tokenAddress, "Token address is required to fetch token balance");
1918
1964
  (0, import_ts_essentials2.assert)(publicClient, "PublicClient is required to fetch token balance");
1919
1965
  (0, import_ts_essentials2.assert)(accountAddress, "Account address is required to fetch token balance");
1920
- const isNativeToken = tokenAddress.toLowerCase() === ETH_ADDRESS.toLowerCase();
1966
+ const isNativeToken = tokenAddress.toLowerCase() === ETH_ADDRESS_LOWERCASE;
1921
1967
  const balance = isNativeToken ? publicClient.getBalance({
1922
1968
  address: accountAddress
1923
1969
  }) : publicClient.readContract({
@@ -2902,6 +2948,14 @@ function useHandleInvalidations() {
2902
2948
  const { upsert: upsertDecryptionWatcher, byKey } = useDecryptionWatchersStore();
2903
2949
  console.log("Scheduled invalidations store:", byKey);
2904
2950
  const handleInvalidations = (tx) => {
2951
+ invalidatePublicTokenBalanceQueries(
2952
+ {
2953
+ tokenAddress: ETH_ADDRESS_LOWERCASE,
2954
+ chainId: tx.chainId,
2955
+ accountAddress: tx.account
2956
+ },
2957
+ queryClient
2958
+ );
2905
2959
  if (tx.actionType === "shieldSend" /* ShieldSend */) {
2906
2960
  invalidateConfidentialTokenBalanceQueries(tx.token, queryClient);
2907
2961
  } else if (tx.actionType === "shield" /* Shield */) {
@@ -3303,14 +3357,14 @@ function useCofheDecrypt({
3303
3357
  queryKey: ["decryptCiphertext", input?.ctHash.toString(), input?.utype],
3304
3358
  queryFn: async () => {
3305
3359
  (0, import_ts_essentials8.assert)(input, "input is guaranteed to be defined by enabled condition");
3306
- return client.decryptHandle(input.ctHash, input.utype).decrypt();
3360
+ return client.decryptForView(input.ctHash, input.utype).execute();
3307
3361
  },
3308
3362
  meta: {
3309
3363
  persist: true
3310
3364
  },
3311
3365
  ...restQueryOptions,
3312
3366
  retry: (failureCount, error) => {
3313
- if (error instanceof import_sdk4.CofhesdkError) return false;
3367
+ if (error instanceof import_sdk4.CofheError) return false;
3314
3368
  return failureCount < 3;
3315
3369
  }
3316
3370
  });
@@ -3505,13 +3559,13 @@ function useCofheEncrypt(options) {
3505
3559
  handleStepStateChange(key, step, context);
3506
3560
  externalOnStepChange?.(step, context);
3507
3561
  };
3508
- builder.setStepCallback(combinedOnStepChange);
3562
+ builder.onStep(combinedOnStepChange);
3509
3563
  if (hasEncryptInputsOptions(variables)) {
3510
3564
  if (variables.account) builder.setAccount(variables.account);
3511
3565
  if (variables.chainId) builder.setChainId(variables.chainId);
3512
3566
  if (variables.securityZone) builder.setSecurityZone(variables.securityZone);
3513
3567
  }
3514
- return builder.encrypt();
3568
+ return builder.execute();
3515
3569
  }
3516
3570
  });
3517
3571
  return {
@@ -3691,7 +3745,7 @@ function useCofheTokenShield(options) {
3691
3745
  let hash;
3692
3746
  if (confidentialityType === "wrapped") {
3693
3747
  const erc20PairAddress = input.token.extensions.fhenix.erc20Pair?.address;
3694
- const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS.toLowerCase();
3748
+ const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS_LOWERCASE;
3695
3749
  if (isEth) {
3696
3750
  hash = await walletClient.writeContract({
3697
3751
  address: tokenAddress,
@@ -5030,16 +5084,27 @@ var useCofheConnect = (options) => {
5030
5084
  var useCofheAutoConnect = ({ walletClient, publicClient }) => {
5031
5085
  const client = useCofheClient();
5032
5086
  const connectMutationFn = useCofheConnect().mutate;
5087
+ const supportedChainIds = (0, import_react33.useMemo)(() => {
5088
+ return new Set(client.config.supportedChains.map((chain) => chain.id));
5089
+ }, [client.config.supportedChains]);
5090
+ const disconnectIfConnected = (0, import_react33.useCallback)(() => {
5091
+ if (client.connected || client.connecting) {
5092
+ client.disconnect();
5093
+ }
5094
+ }, [client]);
5033
5095
  (0, import_react33.useEffect)(() => {
5034
5096
  if (!publicClient || !walletClient) {
5035
- if (client.connected || client.connecting) {
5036
- client.disconnect();
5037
- }
5097
+ disconnectIfConnected();
5098
+ return;
5099
+ }
5100
+ const chainId = walletClient.chain?.id ?? publicClient.chain?.id;
5101
+ if (chainId !== void 0 && !supportedChainIds.has(chainId)) {
5102
+ disconnectIfConnected();
5038
5103
  return;
5039
5104
  }
5040
5105
  if (client.connecting) return;
5041
5106
  connectMutationFn({ publicClient, walletClient });
5042
- }, [publicClient, walletClient, client, client.connected, client.connecting, connectMutationFn]);
5107
+ }, [publicClient, walletClient, client, connectMutationFn, supportedChainIds, disconnectIfConnected]);
5043
5108
  };
5044
5109
 
5045
5110
  // src/hooks/useReschedulableTimeout.ts
@@ -5146,7 +5211,7 @@ function parseCoingeckoSimplePriceUsd({
5146
5211
  }
5147
5212
  function isNativeTokenAddress(address) {
5148
5213
  if (!address) return false;
5149
- return address.toLowerCase() === ETH_ADDRESS.toLowerCase();
5214
+ return address.toLowerCase() === ETH_ADDRESS_LOWERCASE;
5150
5215
  }
5151
5216
  var TMP_WBTC_ON_MAINNET = {
5152
5217
  chainId: 1,
@@ -5757,7 +5822,7 @@ var AddressButton = ({ address, className, icon, showCopyIcon = true }) => {
5757
5822
  };
5758
5823
 
5759
5824
  // src/components/FnxFloatingButton/components/ConnectedChainIndicator.tsx
5760
- var import_chains = require("@cofhe/sdk/chains");
5825
+ var import_chains2 = require("@cofhe/sdk/chains");
5761
5826
 
5762
5827
  // src/assets/chains/11155111.svg
5763
5828
  var import_jsx_runtime12 = require("react/jsx-runtime");
@@ -5794,7 +5859,7 @@ var ChainIcon = ({ chainId, className }) => {
5794
5859
  var import_jsx_runtime15 = require("react/jsx-runtime");
5795
5860
  var ConnectedChainIndicator = () => {
5796
5861
  const chainId = useCofheChainId();
5797
- const chain = chainId ? (0, import_chains.getChainById)(chainId) : void 0;
5862
+ const chain = chainId ? (0, import_chains2.getChainById)(chainId) : void 0;
5798
5863
  const currentNetwork = chain?.name || "Eth";
5799
5864
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
5800
5865
  "div",
@@ -5990,26 +6055,40 @@ var CofheTokenPublicBalance = ({
5990
6055
  function useCofhePinnedTokenAddress() {
5991
6056
  const widgetConfig = useCofheContext().client.config.react;
5992
6057
  const chainId = useCofheChainId();
5993
- const pinnedTokenAddress = chainId ? widgetConfig.pinnedTokens[chainId?.toString()] : void 0;
6058
+ const pinnedTokenAddress = chainId ? widgetConfig.pinnedTokens?.[chainId?.toString()] : void 0;
5994
6059
  return pinnedTokenAddress;
5995
6060
  }
5996
6061
 
6062
+ // src/hooks/useCofhePinnedToken.ts
6063
+ function useCofhePinnedToken({ enabled } = {}) {
6064
+ const pinnedTokenAddress = useCofhePinnedTokenAddress();
6065
+ const token = useCofheToken(
6066
+ {
6067
+ address: pinnedTokenAddress
6068
+ },
6069
+ {
6070
+ // only fetch metadata if pinned token address is defined
6071
+ enabled: enabled !== false && !!pinnedTokenAddress
6072
+ }
6073
+ );
6074
+ return token;
6075
+ }
6076
+
5997
6077
  // src/components/FnxFloatingButton/pages/MainPage/AssetCard.tsx
5998
6078
  var import_jsx_runtime21 = require("react/jsx-runtime");
5999
6079
  var AssetCard = () => {
6000
6080
  const { navigateTo } = usePortalNavigation();
6001
- const pinnedTokenAddress = useCofhePinnedTokenAddress();
6002
- const tokenFromList = useCofheToken({
6003
- address: pinnedTokenAddress
6004
- });
6081
+ const pinnedToken = useCofhePinnedToken();
6082
+ const chainId = useCofheChainId();
6083
+ const fallbackToken = chainId ? DEFAULT_TOKEN_BY_CHAIN_ID[chainId] : void 0;
6084
+ const token = pinnedToken ?? fallbackToken;
6005
6085
  const handleClick = () => {
6006
- if (!tokenFromList) throw new Error("Token not found in token list");
6007
- if (pinnedTokenAddress) {
6086
+ if (token) {
6008
6087
  navigateTo("tokeninfo" /* TokenInfo */, {
6009
- pageProps: { token: tokenFromList }
6088
+ pageProps: { token }
6010
6089
  });
6011
6090
  } else {
6012
- alert("Native token info navigation is not implemented yet.");
6091
+ throw new Error("No token found for AssetCard. No pinned token and no fallback token for current chain.");
6013
6092
  }
6014
6093
  };
6015
6094
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -6019,14 +6098,14 @@ var AssetCard = () => {
6019
6098
  className: cn("fnx-card-bg p-4 cursor-pointer", "hover:opacity-90 transition-opacity", "border fnx-card-border"),
6020
6099
  children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center justify-between", children: [
6021
6100
  /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-3 flex-1", children: [
6022
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TokenIcon, { logoURI: tokenFromList?.logoURI, alt: tokenFromList?.symbol, size: "md" }),
6023
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h3", { className: "text-lg font-bold fnx-text-primary", children: tokenFromList?.symbol }) })
6101
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TokenIcon, { logoURI: token?.logoURI, alt: token?.symbol, size: "md" }),
6102
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h3", { className: "text-lg font-bold fnx-text-primary", children: token?.symbol }) })
6024
6103
  ] }),
6025
6104
  /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-2", children: [
6026
6105
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex flex-col items-end", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
6027
6106
  CofheTokenConfidentialBalance,
6028
6107
  {
6029
- token: tokenFromList,
6108
+ token,
6030
6109
  showSymbol: false,
6031
6110
  size: "xl",
6032
6111
  decimalPrecision: 5,
@@ -6046,23 +6125,6 @@ var import_io2 = require("react-icons/io");
6046
6125
  var import_ai = require("react-icons/ai");
6047
6126
  var import_tb3 = require("react-icons/tb");
6048
6127
  var import_fa = require("react-icons/fa");
6049
-
6050
- // src/hooks/useCofhePinnedToken.ts
6051
- function useCofhePinnedToken({ enabled } = {}) {
6052
- const pinnedTokenAddress = useCofhePinnedTokenAddress();
6053
- const token = useCofheToken(
6054
- {
6055
- address: pinnedTokenAddress
6056
- },
6057
- {
6058
- // only fetch metadata if pinned token address is defined
6059
- enabled: enabled !== false && !!pinnedTokenAddress
6060
- }
6061
- );
6062
- return token;
6063
- }
6064
-
6065
- // src/components/FnxFloatingButton/pages/MainPage/BottomNavigation.tsx
6066
6128
  var import_ts_essentials19 = __toESM(require_dist(), 1);
6067
6129
 
6068
6130
  // src/components/FnxFloatingButton/components/ActionButton.tsx
@@ -6442,7 +6504,10 @@ var navItems = [...baseNavItems, ...!isProduction() ? [debugNavItem] : []];
6442
6504
  var BottomNavigation = () => {
6443
6505
  const { navigateTo } = usePortalNavigation();
6444
6506
  const { openPortal } = usePortalUI();
6445
- const defaultToken = useCofhePinnedToken();
6507
+ const pinnedToken = useCofhePinnedToken();
6508
+ const chainId = useCofheChainId();
6509
+ const fallbackToken = chainId ? DEFAULT_TOKEN_BY_CHAIN_ID[chainId] : void 0;
6510
+ const defaultToken = pinnedToken ?? fallbackToken;
6446
6511
  const handleNavClick = (page) => {
6447
6512
  openPortal();
6448
6513
  if (page === "portfolio" /* Portfolio */) {
@@ -7353,7 +7418,7 @@ var ImportPermitPage = () => {
7353
7418
  };
7354
7419
 
7355
7420
  // src/components/FnxFloatingButton/pages/TokenInfoPage.tsx
7356
- var import_chains2 = require("@cofhe/sdk/chains");
7421
+ var import_chains3 = require("@cofhe/sdk/chains");
7357
7422
  var import_react53 = require("react");
7358
7423
  var import_ArrowBack6 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
7359
7424
 
@@ -7529,7 +7594,7 @@ var import_jsx_runtime47 = require("react/jsx-runtime");
7529
7594
  var TokenInfoPage = ({ token }) => {
7530
7595
  const { navigateBack, navigateTo } = usePortalNavigation();
7531
7596
  const { data: chartPoints } = useCoingeckoContractMarketChartRange({
7532
- ...token.chainId === import_chains2.sepolia.id ? {
7597
+ ...token.chainId === import_chains3.sepolia.id ? {
7533
7598
  chainId: TMP_WBTC_ON_MAINNET.chainId,
7534
7599
  contractAddress: TMP_WBTC_ON_MAINNET.address
7535
7600
  } : {
@@ -7794,6 +7859,7 @@ var SendPage = ({ token: _token }) => {
7794
7859
  var import_ArrowBack8 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
7795
7860
  var import_KeyboardArrowDown = __toESM(require("@mui/icons-material/KeyboardArrowDown"), 1);
7796
7861
  var import_tb4 = require("react-icons/tb");
7862
+ var import_lu2 = require("react-icons/lu");
7797
7863
  var import_react56 = require("react");
7798
7864
  var import_viem21 = require("viem");
7799
7865
  var import_ts_essentials21 = __toESM(require_dist(), 1);
@@ -7830,8 +7896,37 @@ function useLifecycleStore() {
7830
7896
  setStatus
7831
7897
  };
7832
7898
  }
7899
+ function TxHashWithActions({ hash, chainId }) {
7900
+ const href = chainId ? getBlockExplorerTxUrl(chainId, hash) : void 0;
7901
+ const ellipsed = truncateHash(hash);
7902
+ const handleOpenExplorer = () => {
7903
+ if (href) {
7904
+ window.open(href, "_blank", "noopener,noreferrer");
7905
+ }
7906
+ };
7907
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "inline-flex items-center gap-1.5 align-baseline", children: [
7908
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "font-mono", children: ellipsed }),
7909
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(CopyButton, { text: hash, size: 14 }),
7910
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
7911
+ "button",
7912
+ {
7913
+ type: "button",
7914
+ onClick: handleOpenExplorer,
7915
+ disabled: !href,
7916
+ "aria-label": "Open transaction in explorer",
7917
+ title: href ? "Open in explorer" : "Explorer not available for this chain",
7918
+ className: cn(
7919
+ "fnx-text-primary opacity-50 hover:opacity-100 transition-opacity cursor-pointer",
7920
+ !href && "cursor-default opacity-30"
7921
+ ),
7922
+ children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lu2.LuExternalLink, { style: { width: 14, height: 14 } })
7923
+ }
7924
+ )
7925
+ ] });
7926
+ }
7833
7927
  function useClaimUnshieldedWithLifecycle() {
7834
7928
  const { setError, setStatus, error, status } = useLifecycleStore();
7929
+ const chainId = useCofheChainId();
7835
7930
  const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
7836
7931
  const claimUnshield = useCofheTokenClaimUnshielded({
7837
7932
  onMutate: () => {
@@ -7840,7 +7935,11 @@ function useClaimUnshieldedWithLifecycle() {
7840
7935
  },
7841
7936
  onSuccess: (hash) => {
7842
7937
  setStatus({
7843
- message: `Claim transaction sent! Hash: ${truncateHash(hash)}. Waiting for confirmation...`,
7938
+ message: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
7939
+ "Claim transaction sent! Hash: ",
7940
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash, chainId }),
7941
+ " Waiting for confirmation..."
7942
+ ] }),
7844
7943
  type: "info"
7845
7944
  });
7846
7945
  },
@@ -7856,11 +7955,19 @@ function useClaimUnshieldedWithLifecycle() {
7856
7955
  onceMined: (transaction) => {
7857
7956
  if (transaction.status === "confirmed") {
7858
7957
  setStatus({
7859
- message: `Claim transaction confirmed! Hash: ${truncateHash(transaction.hash)}`,
7958
+ message: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
7959
+ "Claim transaction confirmed! Hash: ",
7960
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash: transaction.hash, chainId })
7961
+ ] }),
7860
7962
  type: "success"
7861
7963
  });
7862
7964
  } else if (transaction.status === "failed") {
7863
- setError(`Claim transaction failed! Hash: ${truncateHash(transaction.hash)}`);
7965
+ setError(
7966
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
7967
+ "Claim transaction failed! Hash: ",
7968
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash: transaction.hash, chainId })
7969
+ ] })
7970
+ );
7864
7971
  setStatus(null);
7865
7972
  }
7866
7973
  scheduleStatusClear();
@@ -7875,6 +7982,7 @@ function useClaimUnshieldedWithLifecycle() {
7875
7982
  }
7876
7983
  function useShieldWithLifecycle(token) {
7877
7984
  const account = useCofheAccount();
7985
+ const chainId = useCofheChainId();
7878
7986
  const [shieldAmount, setShieldAmount] = (0, import_react56.useState)("");
7879
7987
  const { setError, setStatus, error, status } = useLifecycleStore();
7880
7988
  const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
@@ -7885,7 +7993,11 @@ function useShieldWithLifecycle(token) {
7885
7993
  },
7886
7994
  onSuccess: (hash) => {
7887
7995
  setStatus({
7888
- message: `Shield transaction sent! Hash: ${truncateHash(hash)}. Waiting for confirmation...`,
7996
+ message: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
7997
+ "Shield transaction sent! Hash: ",
7998
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash, chainId }),
7999
+ " Waiting for confirmation..."
8000
+ ] }),
7889
8001
  type: "info"
7890
8002
  });
7891
8003
  setShieldAmount("");
@@ -7902,11 +8014,19 @@ function useShieldWithLifecycle(token) {
7902
8014
  onceMined: (transaction) => {
7903
8015
  if (transaction.status === "confirmed") {
7904
8016
  setStatus({
7905
- message: `Shield transaction confirmed! Hash: ${truncateHash(transaction.hash)}`,
8017
+ message: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
8018
+ "Shield transaction confirmed! Hash: ",
8019
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash: transaction.hash, chainId })
8020
+ ] }),
7906
8021
  type: "success"
7907
8022
  });
7908
8023
  } else if (transaction.status === "failed") {
7909
- setError(`Shield transaction failed! Hash: ${truncateHash(transaction.hash)}`);
8024
+ setError(
8025
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
8026
+ "Shield transaction failed! Hash: ",
8027
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash: transaction.hash, chainId })
8028
+ ] })
8029
+ );
7910
8030
  setStatus(null);
7911
8031
  }
7912
8032
  scheduleStatusClear();
@@ -7948,6 +8068,7 @@ function useShieldWithLifecycle(token) {
7948
8068
  }
7949
8069
  function useUnshieldWithLifecycle(token) {
7950
8070
  const account = useCofheAccount();
8071
+ const chainId = useCofheChainId();
7951
8072
  const { setError, setStatus, error, status } = useLifecycleStore();
7952
8073
  const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
7953
8074
  const [unshieldAmount, setUnshieldAmount] = (0, import_react56.useState)("");
@@ -7960,7 +8081,11 @@ function useUnshieldWithLifecycle(token) {
7960
8081
  },
7961
8082
  onTransactionSubmitSuccess: (hash) => {
7962
8083
  setStatus({
7963
- message: `Unshield transaction sent! Hash: ${truncateHash(hash)}. Waiting for confirmation...`,
8084
+ message: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
8085
+ "Unshield transaction sent! Hash: ",
8086
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash, chainId }),
8087
+ " Waiting for confirmation..."
8088
+ ] }),
7964
8089
  type: "info"
7965
8090
  });
7966
8091
  setUnshieldAmount("");
@@ -7974,11 +8099,20 @@ function useUnshieldWithLifecycle(token) {
7974
8099
  onceMined: (transaction) => {
7975
8100
  if (transaction.status === "confirmed") {
7976
8101
  setStatus({
7977
- message: `Unshield transaction confirmed! Hash: ${truncateHash(transaction.hash)}. Now waiting for decryption...`,
8102
+ message: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
8103
+ "Unshield transaction confirmed! Hash: ",
8104
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash: transaction.hash, chainId }),
8105
+ " Now waiting for decryption..."
8106
+ ] }),
7978
8107
  type: "success"
7979
8108
  });
7980
8109
  } else if (transaction.status === "failed") {
7981
- setError(`Unshield transaction failed! Hash: ${truncateHash(transaction.hash)}`);
8110
+ setError(
8111
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
8112
+ "Unshield transaction failed! Hash: ",
8113
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TxHashWithActions, { hash: transaction.hash, chainId })
8114
+ ] })
8115
+ );
7982
8116
  setStatus(null);
7983
8117
  }
7984
8118
  },
@@ -8086,10 +8220,7 @@ function ClaimingSection({ token }) {
8086
8220
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(StatusAndError, { status: claimingStatus, error: claimingError })
8087
8221
  ] });
8088
8222
  }
8089
- function StatusAndError({
8090
- status,
8091
- error
8092
- }) {
8223
+ function StatusAndError({ status, error }) {
8093
8224
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
8094
8225
  error && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-2", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "text-xs text-red-800 dark:text-red-200", children: error }) }),
8095
8226
  status && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
@@ -8699,7 +8830,7 @@ var import_ArrowBack11 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
8699
8830
 
8700
8831
  // src/components/FnxFloatingButton/components/TokenRow.tsx
8701
8832
  var import_KeyboardArrowRight3 = __toESM(require("@mui/icons-material/KeyboardArrowRight"), 1);
8702
- var import_chains3 = require("@cofhe/sdk/chains");
8833
+ var import_chains4 = require("@cofhe/sdk/chains");
8703
8834
  var import_jsx_runtime52 = require("react/jsx-runtime");
8704
8835
  var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
8705
8836
  const account = useCofheAccount();
@@ -8714,7 +8845,7 @@ var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
8714
8845
  );
8715
8846
  const { data: publicBalance } = useCofheTokenPublicBalance({ token, accountAddress: account });
8716
8847
  const { data: price } = useCoingeckoUsdPrice(
8717
- token.chainId === import_chains3.sepolia.id ? {
8848
+ token.chainId === import_chains4.sepolia.id ? {
8718
8849
  chainId: TMP_WBTC_ON_MAINNET.chainId,
8719
8850
  tokenAddress: TMP_WBTC_ON_MAINNET.address
8720
8851
  } : {
@@ -9466,7 +9597,7 @@ var addressSchema = import_zod.z.string().refine((val) => (0, import_viem23.isAd
9466
9597
  }).refine((val) => val !== import_viem23.zeroAddress, {
9467
9598
  error: "Must not be zeroAddress"
9468
9599
  }).transform((val) => (0, import_viem23.getAddress)(val));
9469
- var CofhesdkReactConfigSchema = import_zod.z.object({
9600
+ var CofheReactConfigSchema = import_zod.z.object({
9470
9601
  shareablePermits: import_zod.z.boolean().optional().default(false),
9471
9602
  enableShieldUnshield: import_zod.z.boolean().optional().default(true),
9472
9603
  autogeneratePermits: import_zod.z.boolean().optional().default(true),
@@ -9482,30 +9613,20 @@ var CofhesdkReactConfigSchema = import_zod.z.object({
9482
9613
  ]),
9483
9614
  defaultPermitExpirationSeconds: import_zod.z.number().optional().default(604800),
9484
9615
  // 1 week
9485
- pinnedTokens: import_zod.z.record(import_zod.z.string(), addressSchema).optional().default({
9486
- 11155111: "0x87A3effB84CBE1E4caB6Ab430139eC41d156D55A",
9487
- // sepolia weth
9488
- 84532: "0xbED96aa98a49FeA71fcC55d755b915cF022a9159"
9489
- // base sepolia weth
9490
- // 421613: '0x980b62da83eff3d4576c647993b0c1d7faf17c73', // arbitrum sepolia weth
9491
- }),
9492
- tokenLists: import_zod.z.record(import_zod.z.string(), import_zod.z.array(import_zod.z.string())).optional().default({
9493
- 11155111: ["https://storage.googleapis.com/cofhesdk/sepolia.json"],
9494
- 84532: ["https://storage.googleapis.com/cofhesdk/base-sepolia.json"]
9495
- // 421613: ['https://tokens.cofhe.io/arbitrum-sepolia.json'],
9496
- }).transform((lists) => lists),
9616
+ pinnedTokens: import_zod.z.record(import_zod.z.string(), addressSchema).optional(),
9617
+ tokenLists: import_zod.z.record(import_zod.z.string(), import_zod.z.array(import_zod.z.string())).transform((lists) => lists).optional(),
9497
9618
  position: import_zod.z.enum(["bottom-right", "bottom-left", "top-right", "top-left"]).optional().default("bottom-right"),
9498
9619
  initialTheme: import_zod.z.enum(["dark", "light"]).optional().default("light")
9499
9620
  });
9500
- function createCofhesdkConfig(config) {
9621
+ function createCofheConfig(config) {
9501
9622
  const { react: reactConfigInput = {}, ...webConfig } = config;
9502
- const webClientConfig = (0, import_web.createCofhesdkConfig)({
9623
+ const webClientConfig = (0, import_web.createCofheConfig)({
9503
9624
  environment: "react",
9504
9625
  ...webConfig
9505
9626
  });
9506
- const reactConfigResult = CofhesdkReactConfigSchema.safeParse(reactConfigInput);
9627
+ const reactConfigResult = CofheReactConfigSchema.safeParse(reactConfigInput);
9507
9628
  if (!reactConfigResult.success) {
9508
- throw new Error(`Invalid cofhesdk react configuration: ${import_zod.z.prettifyError(reactConfigResult.error)}`, {
9629
+ throw new Error(`Invalid cofhe react configuration: ${import_zod.z.prettifyError(reactConfigResult.error)}`, {
9509
9630
  cause: reactConfigResult.error
9510
9631
  });
9511
9632
  }
@@ -9516,7 +9637,7 @@ function createCofhesdkConfig(config) {
9516
9637
  }
9517
9638
 
9518
9639
  // src/providers/CofheProvider.tsx
9519
- var import_chains4 = require("@cofhe/sdk/chains");
9640
+ var import_chains5 = require("@cofhe/sdk/chains");
9520
9641
  var import_ts_essentials23 = __toESM(require_dist(), 1);
9521
9642
  var import_jsx_runtime66 = require("react/jsx-runtime");
9522
9643
  var CofheContext = (0, import_react64.createContext)(void 0);
@@ -9524,23 +9645,20 @@ function CofheProvider(props) {
9524
9645
  const { children, queryClient, publicClient, walletClient } = props;
9525
9646
  const config = (0, import_react64.useMemo)(() => {
9526
9647
  if (props.config) return props.config;
9527
- if (props.cofhesdkClient) {
9528
- (0, import_ts_essentials23.assert)(config.environment === "react", "Provided cofhesdkClient must have react config");
9529
- return props.cofhesdkClient.config;
9530
- }
9531
- return createCofhesdkConfig({ supportedChains: Object.values(import_chains4.chains) });
9532
- }, [props.config, props.cofhesdkClient]);
9533
- const cofhesdkClient = (0, import_react64.useMemo)(
9534
- () => props.cofhesdkClient ?? (0, import_web2.createCofhesdkClient)(config),
9535
- [props.cofhesdkClient, config]
9536
- );
9648
+ if (props.cofheClient) {
9649
+ (0, import_ts_essentials23.assert)(config.environment === "react", "Provided cofheClient must have react config");
9650
+ return props.cofheClient.config;
9651
+ }
9652
+ return createCofheConfig({ supportedChains: Object.values(import_chains5.chains) });
9653
+ }, [props.config, props.cofheClient]);
9654
+ const cofheClient = (0, import_react64.useMemo)(() => props.cofheClient ?? (0, import_web2.createCofheClient)(config), [props.cofheClient, config]);
9537
9655
  const [position, setPosition] = (0, import_react64.useState)(config.react.position);
9538
9656
  const [theme, setTheme] = (0, import_react64.useState)(config.react.initialTheme);
9539
9657
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
9540
9658
  CofheContext.Provider,
9541
9659
  {
9542
9660
  value: {
9543
- client: cofhesdkClient,
9661
+ client: cofheClient,
9544
9662
  state: {
9545
9663
  position,
9546
9664
  setPosition,
@@ -9887,7 +10005,7 @@ var import_web3 = require("@cofhe/sdk/web");
9887
10005
  // Annotate the CommonJS export names for ESM import in node:
9888
10006
  0 && (module.exports = {
9889
10007
  CofheProvider,
9890
- ETH_ADDRESS,
10008
+ ETH_ADDRESS_LOWERCASE,
9891
10009
  FheTypesList,
9892
10010
  FnxEncryptInput,
9893
10011
  FnxFloatingButtonWithProvider,
@@ -9896,8 +10014,8 @@ var import_web3 = require("@cofhe/sdk/web");
9896
10014
  TransactionActionType,
9897
10015
  TransactionStatus,
9898
10016
  actionToString,
9899
- createCofhesdkClient,
9900
- createCofhesdkConfig,
10017
+ createCofheClient,
10018
+ createCofheConfig,
9901
10019
  encryptedValueToString,
9902
10020
  fheTypeToString,
9903
10021
  formatRelativeTime,