@cofhe/react 0.0.0-beta-20260417095940 → 0.0.0-beta-20260420143138

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
@@ -837,6 +837,65 @@ var viemChains = __toESM(require("viem/chains"), 1);
837
837
  // src/types/token.ts
838
838
  var import_chains = require("@cofhe/sdk/chains");
839
839
  var ETH_ADDRESS_LOWERCASE = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
840
+ var TOKEN_CONFIDENTIALITY_SUPPORT = {
841
+ wrapped: {
842
+ enabled: true,
843
+ publicBalanceSource: "erc20Pair",
844
+ operations: {
845
+ confidentialBalance: true,
846
+ transfer: true,
847
+ publicBalance: true,
848
+ shield: true,
849
+ unshield: true,
850
+ claim: true,
851
+ claimable: true
852
+ }
853
+ },
854
+ pure: {
855
+ enabled: false,
856
+ publicBalanceSource: null,
857
+ operations: {
858
+ confidentialBalance: false,
859
+ transfer: false,
860
+ publicBalance: false,
861
+ shield: false,
862
+ unshield: false,
863
+ claim: false,
864
+ claimable: false
865
+ }
866
+ },
867
+ dual: {
868
+ enabled: false,
869
+ publicBalanceSource: "token",
870
+ operations: {
871
+ confidentialBalance: false,
872
+ transfer: false,
873
+ publicBalance: false,
874
+ shield: false,
875
+ unshield: false,
876
+ claim: false,
877
+ claimable: false
878
+ }
879
+ }
880
+ };
881
+ var TOKEN_CONFIDENTIALITY_TYPES = Object.keys(TOKEN_CONFIDENTIALITY_SUPPORT);
882
+ function isTokenConfidentialityType(value) {
883
+ return typeof value === "string" && value in TOKEN_CONFIDENTIALITY_SUPPORT;
884
+ }
885
+ function isSupportedTokenConfidentialityType(value) {
886
+ return isTokenConfidentialityType(value) && TOKEN_CONFIDENTIALITY_SUPPORT[value].enabled;
887
+ }
888
+ function isTokenOperationSupported(type, operation) {
889
+ return isTokenConfidentialityType(type) && TOKEN_CONFIDENTIALITY_SUPPORT[type].operations[operation];
890
+ }
891
+ function getPublicBalanceSourceType(type) {
892
+ if (!isTokenConfidentialityType(type)) return null;
893
+ return TOKEN_CONFIDENTIALITY_SUPPORT[type].publicBalanceSource;
894
+ }
895
+ function assertTokenOperationSupported(type, operation) {
896
+ if (isTokenOperationSupported(type, operation)) return;
897
+ throw new Error(`${operation} not supported for confidentialityType: ${type ?? "undefined"}`);
898
+ }
840
899
  var WETH_SEPOLIA_TOKEN = {
841
900
  chainId: 11155111,
842
901
  address: "0x87A3effB84CBE1E4caB6Ab430139eC41d156D55A",
@@ -915,7 +974,7 @@ var isEthPair = (erc20Pair) => {
915
974
  return erc20Pair.address.toLowerCase() === ETH_ADDRESS_LOWERCASE;
916
975
  };
917
976
  var isWrappedEthToken = (token) => {
918
- if (token.extensions.fhenix.confidentialityType !== "wrapped") return false;
977
+ if (!isSupportedTokenConfidentialityType(token.extensions.fhenix.confidentialityType)) return false;
919
978
  return isEthPair(token.extensions.fhenix.erc20Pair);
920
979
  };
921
980
  var FheTypesList = [
@@ -1666,249 +1725,222 @@ function useCofheReadContract(params, queryOptions) {
1666
1725
  // src/hooks/useTrackPendingTransactions.ts
1667
1726
  var import_react_query8 = require("@tanstack/react-query");
1668
1727
 
1669
- // src/constants/confidentialTokenABIs.ts
1728
+ // src/constants/confidentialTokenWrapped.ts
1670
1729
  var import_viem4 = require("viem");
1671
- var ERC20_ALLOWANCE_ABI = (0, import_viem4.parseAbi)([
1672
- "function allowance(address owner, address spender) view returns (uint256)"
1673
- ]);
1674
- var ERC20_APPROVE_ABI = (0, import_viem4.parseAbi)(["function approve(address spender, uint256 amount) returns (bool)"]);
1675
- var CONFIDENTIAL_TYPE_WRAPPED_ABI = [
1676
- {
1677
- inputs: [
1678
- {
1679
- internalType: "address",
1680
- name: "account",
1681
- type: "address"
1682
- }
1683
- ],
1684
- name: "encBalanceOf",
1685
- outputs: [
1686
- {
1687
- internalType: "euint128",
1688
- name: "",
1689
- type: "uint256"
1690
- }
1691
- ],
1692
- stateMutability: "view",
1693
- type: "function"
1694
- }
1695
- ];
1696
- var CONFIDENTIAL_TYPE_PURE_ABI = (0, import_viem4.parseAbi)([
1697
- "function confidentialBalanceOf(address account) view returns (uint256)"
1698
- ]);
1699
- var CONFIDENTIAL_TYPE_DUAL_ABI = (0, import_viem4.parseAbi)([
1700
- "function confidentialBalanceOf(address account) view returns (uint256)"
1701
- ]);
1702
- var CONFIDENTIAL_ABIS = {
1703
- wrapped: {
1704
- abi: CONFIDENTIAL_TYPE_WRAPPED_ABI,
1705
- functionName: "encBalanceOf"
1706
- },
1707
- pure: {
1708
- abi: CONFIDENTIAL_TYPE_PURE_ABI,
1709
- functionName: "confidentialBalanceOf"
1730
+ var wrappedErc20ApprovalContracts = {
1731
+ allowance: {
1732
+ abi: (0, import_viem4.parseAbi)(["function allowance(address owner, address spender) view returns (uint256)"]),
1733
+ functionName: "allowance"
1710
1734
  },
1711
- dual: {
1712
- abi: CONFIDENTIAL_TYPE_DUAL_ABI,
1713
- functionName: "confidentialBalanceOf"
1735
+ approve: {
1736
+ abi: (0, import_viem4.parseAbi)(["function approve(address spender, uint256 amount) returns (bool)"]),
1737
+ functionName: "approve"
1714
1738
  }
1715
1739
  };
1716
- var WRAPPED_TRANSFER_ABI = [
1717
- {
1718
- inputs: [
1719
- {
1720
- internalType: "address",
1721
- name: "to",
1722
- type: "address"
1723
- },
1740
+ var WRAPPED_TOKEN_CONTRACTS = {
1741
+ confidentialBalance: {
1742
+ abi: [
1724
1743
  {
1725
- components: [
1744
+ inputs: [
1745
+ {
1746
+ internalType: "address",
1747
+ name: "account",
1748
+ type: "address"
1749
+ }
1750
+ ],
1751
+ name: "encBalanceOf",
1752
+ outputs: [
1726
1753
  {
1727
- internalType: "uint256",
1728
- name: "ctHash",
1754
+ internalType: "euint128",
1755
+ name: "",
1729
1756
  type: "uint256"
1730
- },
1757
+ }
1758
+ ],
1759
+ stateMutability: "view",
1760
+ type: "function"
1761
+ }
1762
+ ],
1763
+ functionName: "encBalanceOf"
1764
+ },
1765
+ confidentialTransfer: {
1766
+ abi: [
1767
+ {
1768
+ inputs: [
1731
1769
  {
1732
- internalType: "uint8",
1733
- name: "securityZone",
1734
- type: "uint8"
1770
+ internalType: "address",
1771
+ name: "to",
1772
+ type: "address"
1735
1773
  },
1736
1774
  {
1737
- internalType: "uint8",
1738
- name: "utype",
1739
- type: "uint8"
1740
- },
1775
+ components: [
1776
+ {
1777
+ internalType: "uint256",
1778
+ name: "ctHash",
1779
+ type: "uint256"
1780
+ },
1781
+ {
1782
+ internalType: "uint8",
1783
+ name: "securityZone",
1784
+ type: "uint8"
1785
+ },
1786
+ {
1787
+ internalType: "uint8",
1788
+ name: "utype",
1789
+ type: "uint8"
1790
+ },
1791
+ {
1792
+ internalType: "bytes",
1793
+ name: "signature",
1794
+ type: "bytes"
1795
+ }
1796
+ ],
1797
+ internalType: "struct InEuint128",
1798
+ name: "inValue",
1799
+ type: "tuple"
1800
+ }
1801
+ ],
1802
+ name: "encTransfer",
1803
+ outputs: [
1741
1804
  {
1742
- internalType: "bytes",
1743
- name: "signature",
1744
- type: "bytes"
1805
+ internalType: "euint128",
1806
+ name: "transferred",
1807
+ type: "uint256"
1745
1808
  }
1746
1809
  ],
1747
- internalType: "struct InEuint128",
1748
- name: "inValue",
1749
- type: "tuple"
1750
- }
1751
- ],
1752
- name: "encTransfer",
1753
- outputs: [
1754
- {
1755
- internalType: "euint128",
1756
- name: "transferred",
1757
- type: "uint256"
1758
- }
1759
- ],
1760
- stateMutability: "nonpayable",
1761
- type: "function"
1762
- }
1763
- ];
1764
- var PURE_TRANSFER_ABI = [
1765
- {
1766
- name: "confidentialTransfer",
1767
- type: "function",
1768
- stateMutability: "nonpayable",
1769
- inputs: [
1770
- { name: "to", type: "address" },
1771
- {
1772
- name: "inValue",
1773
- type: "tuple",
1774
- components: [
1775
- { name: "ctHash", type: "uint256" },
1776
- { name: "securityZone", type: "uint8" },
1777
- { name: "utype", type: "uint8" },
1778
- { name: "signature", type: "bytes" }
1779
- ]
1810
+ stateMutability: "nonpayable",
1811
+ type: "function"
1780
1812
  }
1781
1813
  ],
1782
- outputs: [{ name: "transferred", type: "uint256" }]
1783
- }
1784
- ];
1785
- var DUAL_TRANSFER_ABI = [
1786
- {
1787
- name: "TBD_DUAL_FUNCTION_NAME",
1788
- type: "function",
1789
- stateMutability: "nonpayable",
1790
- inputs: [
1791
- { name: "to", type: "address" },
1792
- {
1793
- name: "inValue",
1794
- type: "tuple",
1795
- components: [
1796
- { name: "ctHash", type: "uint256" },
1797
- { name: "securityZone", type: "uint8" },
1798
- { name: "utype", type: "uint8" },
1799
- { name: "signature", type: "bytes" }
1800
- ]
1801
- }
1802
- ],
1803
- outputs: [{ name: "transferred", type: "uint256" }]
1804
- }
1805
- ];
1806
- var TRANSFER_ABIS = {
1807
- wrapped: {
1808
- abi: WRAPPED_TRANSFER_ABI,
1809
1814
  functionName: "encTransfer"
1810
1815
  },
1811
- pure: {
1812
- abi: PURE_TRANSFER_ABI,
1813
- functionName: "confidentialTransfer"
1816
+ shield: {
1817
+ approval: wrappedErc20ApprovalContracts,
1818
+ erc20: {
1819
+ abi: (0, import_viem4.parseAbi)(["function encrypt(address to, uint128 value) public"]),
1820
+ functionName: "encrypt"
1821
+ },
1822
+ native: {
1823
+ abi: (0, import_viem4.parseAbi)(["function encryptETH(address to) public payable"]),
1824
+ functionName: "encryptETH"
1825
+ },
1826
+ wrappedPair: {
1827
+ abi: (0, import_viem4.parseAbi)(["function encryptWETH(address to, uint128 value) public"]),
1828
+ functionName: "encryptWETH"
1829
+ }
1814
1830
  },
1815
- dual: {
1816
- // Placeholder for dual type
1817
- abi: DUAL_TRANSFER_ABI,
1818
- functionName: "TBD_DUAL_FUNCTION_NAME"
1831
+ unshield: {
1832
+ abi: (0, import_viem4.parseAbi)(["function decrypt(address to, uint128 value) public"]),
1833
+ functionName: "decrypt"
1834
+ },
1835
+ claims: {
1836
+ single: {
1837
+ abi: (0, import_viem4.parseAbi)(["function claimDecrypted(uint256 ctHash) public"]),
1838
+ functionName: "claimDecrypted"
1839
+ },
1840
+ all: {
1841
+ abi: (0, import_viem4.parseAbi)(["function claimAllDecrypted() public"]),
1842
+ functionName: "claimAllDecrypted"
1843
+ },
1844
+ query: {
1845
+ abi: [
1846
+ {
1847
+ inputs: [{ name: "user", type: "address" }],
1848
+ name: "getUserClaims",
1849
+ outputs: [
1850
+ {
1851
+ components: [
1852
+ { name: "ctHash", type: "uint256" },
1853
+ { name: "requestedAmount", type: "uint128" },
1854
+ { name: "decryptedAmount", type: "uint128" },
1855
+ { name: "decrypted", type: "bool" },
1856
+ { name: "to", type: "address" },
1857
+ { name: "claimed", type: "bool" }
1858
+ ],
1859
+ name: "",
1860
+ type: "tuple[]"
1861
+ }
1862
+ ],
1863
+ stateMutability: "view",
1864
+ type: "function"
1865
+ }
1866
+ ],
1867
+ functionName: "getUserClaims"
1868
+ }
1819
1869
  }
1820
1870
  };
1821
- var DUAL_SHIELD_ABI = (0, import_viem4.parseAbi)(["function shield(uint256 amount) public"]);
1822
- var DUAL_UNSHIELD_ABI = (0, import_viem4.parseAbi)(["function unshield(uint64 amount) public"]);
1823
- var DUAL_CLAIM_UNSHIELD_ABI = (0, import_viem4.parseAbi)(["function claimUnshielded() public"]);
1824
- var DUAL_GET_UNSHIELD_CLAIM_ABI = [
1825
- {
1826
- name: "getUserUnshieldClaim",
1827
- type: "function",
1828
- stateMutability: "view",
1829
- inputs: [{ name: "user", type: "address" }],
1830
- outputs: [
1831
- {
1832
- name: "",
1833
- type: "tuple",
1834
- components: [
1835
- { name: "ctHash", type: "uint256" },
1836
- { name: "requestedAmount", type: "uint64" },
1837
- { name: "decryptedAmount", type: "uint64" },
1838
- { name: "decrypted", type: "bool" },
1839
- { name: "claimed", type: "bool" }
1840
- ]
1841
- }
1842
- ]
1871
+
1872
+ // src/constants/confidentialTokenABIs.ts
1873
+ function getRequiredContractConfig(configs, confidentialityType, operation) {
1874
+ const config = configs[confidentialityType];
1875
+ if (!config) {
1876
+ throw new Error(`${operation} config is not defined for confidentialityType: ${confidentialityType}`);
1843
1877
  }
1844
- ];
1845
- var WRAPPED_ENCRYPT_ABI = (0, import_viem4.parseAbi)(["function encrypt(address to, uint128 value) public"]);
1846
- var WRAPPED_DECRYPT_ABI = (0, import_viem4.parseAbi)(["function decrypt(address to, uint128 value) public"]);
1847
- var WRAPPED_CLAIM_DECRYPTED_ABI = (0, import_viem4.parseAbi)(["function claimDecrypted(uint256 ctHash) public"]);
1848
- var WRAPPED_CLAIM_ALL_DECRYPTED_ABI = (0, import_viem4.parseAbi)(["function claimAllDecrypted() public"]);
1849
- var WRAPPED_GET_USER_CLAIMS_ABI = [
1850
- {
1851
- inputs: [{ name: "user", type: "address" }],
1852
- name: "getUserClaims",
1853
- outputs: [
1854
- {
1855
- components: [
1856
- { name: "ctHash", type: "uint256" },
1857
- { name: "requestedAmount", type: "uint128" },
1858
- { name: "decryptedAmount", type: "uint128" },
1859
- { name: "decrypted", type: "bool" },
1860
- { name: "to", type: "address" },
1861
- { name: "claimed", type: "bool" }
1862
- ],
1863
- name: "",
1864
- type: "tuple[]"
1865
- }
1866
- ],
1867
- stateMutability: "view",
1868
- type: "function"
1878
+ return config;
1879
+ }
1880
+ var TOKEN_CONFIDENTIALITY_CONTRACTS = {
1881
+ wrapped: WRAPPED_TOKEN_CONTRACTS
1882
+ };
1883
+ function getDefaultShieldApprovalContracts() {
1884
+ return WRAPPED_TOKEN_CONTRACTS.shield.approval;
1885
+ }
1886
+ function getContractsForType(confidentialityType) {
1887
+ return getRequiredContractConfig(TOKEN_CONFIDENTIALITY_CONTRACTS, confidentialityType, "token contracts");
1888
+ }
1889
+ function getTokenContractConfig(confidentialityType) {
1890
+ return getContractsForType(confidentialityType).confidentialBalance;
1891
+ }
1892
+ function getTransferContractConfig(confidentialityType) {
1893
+ return getContractsForType(confidentialityType).confidentialTransfer;
1894
+ }
1895
+ function getShieldContractConfig(confidentialityType) {
1896
+ const contracts = getContractsForType(confidentialityType).shield;
1897
+ if (!contracts) {
1898
+ throw new Error(`shield config is not defined for confidentialityType: ${confidentialityType}`);
1869
1899
  }
1870
- ];
1871
- var WRAPPED_ETH_ENCRYPT_ETH_ABI = (0, import_viem4.parseAbi)(["function encryptETH(address to) public payable"]);
1872
- var WRAPPED_ETH_ENCRYPT_WETH_ABI = (0, import_viem4.parseAbi)(["function encryptWETH(address to, uint128 value) public"]);
1873
- var SHIELD_ABIS = {
1874
- dual: {
1875
- abi: DUAL_SHIELD_ABI,
1876
- functionName: "shield"
1877
- },
1878
- wrapped: {
1879
- // TBD - needs approval flow and underlying token reference
1880
- abi: WRAPPED_ENCRYPT_ABI,
1881
- functionName: "encrypt"
1900
+ return contracts.erc20;
1901
+ }
1902
+ function getShieldAllowanceContractConfig() {
1903
+ return getDefaultShieldApprovalContracts().allowance;
1904
+ }
1905
+ function getShieldApproveContractConfig() {
1906
+ return getDefaultShieldApprovalContracts().approve;
1907
+ }
1908
+ function getShieldEthContractConfig(confidentialityType) {
1909
+ const contracts = getContractsForType(confidentialityType).shield;
1910
+ if (!contracts) {
1911
+ throw new Error(`shield ETH config is not defined for confidentialityType: ${confidentialityType}`);
1882
1912
  }
1883
- };
1884
- var UNSHIELD_ABIS = {
1885
- dual: {
1886
- abi: DUAL_UNSHIELD_ABI,
1887
- functionName: "unshield"
1888
- },
1889
- wrapped: {
1890
- // TBD - needs claim flow
1891
- abi: WRAPPED_DECRYPT_ABI,
1892
- functionName: "decrypt"
1913
+ return contracts.native;
1914
+ }
1915
+ function getUnshieldContractConfig(confidentialityType) {
1916
+ const contracts = getContractsForType(confidentialityType).unshield;
1917
+ if (!contracts) {
1918
+ throw new Error(`unshield config is not defined for confidentialityType: ${confidentialityType}`);
1893
1919
  }
1894
- };
1895
- var CLAIM_ABIS = {
1896
- dual: {
1897
- abi: DUAL_CLAIM_UNSHIELD_ABI,
1898
- functionName: "claimUnshielded"
1899
- },
1900
- wrapped: {
1901
- abi: WRAPPED_CLAIM_ALL_DECRYPTED_ABI,
1902
- functionName: "claimAllDecrypted"
1920
+ return contracts;
1921
+ }
1922
+ function getClaimContractConfig(confidentialityType) {
1923
+ const contracts = getContractsForType(confidentialityType).claims;
1924
+ if (!contracts) {
1925
+ throw new Error(`claim config is not defined for confidentialityType: ${confidentialityType}`);
1903
1926
  }
1904
- };
1905
- function getTokenContractConfig(confidentialityType) {
1906
- return CONFIDENTIAL_ABIS[confidentialityType];
1927
+ return contracts.all;
1928
+ }
1929
+ function getClaimableContractConfig(confidentialityType) {
1930
+ const contracts = getContractsForType(confidentialityType).claims;
1931
+ if (!contracts) {
1932
+ throw new Error(`claimable config is not defined for confidentialityType: ${confidentialityType}`);
1933
+ }
1934
+ return contracts.query;
1907
1935
  }
1908
1936
 
1909
1937
  // src/hooks/useCofheTokenLists.ts
1910
1938
  var import_react_query3 = require("@tanstack/react-query");
1911
1939
  var import_react5 = require("react");
1940
+ function isSupportedToken(token) {
1941
+ const confidentialityType = token.extensions?.fhenix?.confidentialityType;
1942
+ return isSupportedTokenConfidentialityType(confidentialityType);
1943
+ }
1912
1944
  function useCofheTokenLists({ chainId }, queryOptions) {
1913
1945
  const widgetConfig = useCofheContext().client.config.react;
1914
1946
  const tokensListsUrls = chainId ? widgetConfig.tokenLists?.[chainId] : [];
@@ -1930,7 +1962,7 @@ function useCofheTokenLists({ chainId }, queryOptions) {
1930
1962
  select: (data) => {
1931
1963
  return {
1932
1964
  ...data,
1933
- tokens: data.tokens.filter((token) => token.chainId === chainId)
1965
+ tokens: data.tokens.filter((token) => token.chainId === chainId && isSupportedToken(token))
1934
1966
  };
1935
1967
  },
1936
1968
  ...queryOptions
@@ -2022,7 +2054,8 @@ function constructPublicTokenBalanceQueryKeyForInvalidation({
2022
2054
  function getPublicTokenBalanceSource(token) {
2023
2055
  const confidentialityType = token?.extensions.fhenix.confidentialityType;
2024
2056
  const underlyingErc20 = token?.extensions.fhenix.erc20Pair;
2025
- const tokenToFetchBalanceFrom = confidentialityType === "wrapped" ? underlyingErc20 : confidentialityType === "dual" ? token : void 0;
2057
+ const publicBalanceSourceType = getPublicBalanceSourceType(confidentialityType);
2058
+ const tokenToFetchBalanceFrom = publicBalanceSourceType === "erc20Pair" ? underlyingErc20 : publicBalanceSourceType === "token" ? token : void 0;
2026
2059
  if (!tokenToFetchBalanceFrom) return void 0;
2027
2060
  return {
2028
2061
  address: tokenToFetchBalanceFrom.address,
@@ -2280,7 +2313,7 @@ var DEFAULT_UNSHIELD_CLAIM_SUMMARY = {
2280
2313
  hasPending: false
2281
2314
  };
2282
2315
  function isTokenConfidentialityTypeClaimable(type) {
2283
- return type === "dual" || type === "wrapped";
2316
+ return isTokenOperationSupported(type, "claimable");
2284
2317
  }
2285
2318
  async function fetchUnshieldClaimsSummary({
2286
2319
  publicClient,
@@ -2290,58 +2323,36 @@ async function fetchUnshieldClaimsSummary({
2290
2323
  queryKey,
2291
2324
  signal
2292
2325
  }) {
2293
- if (confidentialityType === "dual") {
2294
- const claim = await decryptionAwareReadContract({
2295
- publicClient,
2296
- queryKey,
2297
- signal,
2298
- readContractParams: {
2299
- address: token.address,
2300
- abi: DUAL_GET_UNSHIELD_CLAIM_ABI,
2301
- functionName: "getUserUnshieldClaim",
2302
- args: [accountAddress]
2303
- }
2304
- });
2305
- if (claim.ctHash === 0n || claim.claimed) return DEFAULT_UNSHIELD_CLAIM_SUMMARY;
2306
- return {
2307
- claimableAmount: claim.decrypted ? claim.decryptedAmount : 0n,
2308
- pendingAmount: claim.decrypted ? 0n : claim.requestedAmount,
2309
- hasClaimable: claim.decrypted && claim.decryptedAmount > 0n,
2310
- hasPending: !claim.decrypted
2311
- };
2312
- }
2313
- if (confidentialityType === "wrapped") {
2314
- const result = await decryptionAwareReadContract({
2315
- publicClient,
2316
- queryKey,
2317
- signal,
2318
- readContractParams: {
2319
- address: token.address,
2320
- abi: WRAPPED_GET_USER_CLAIMS_ABI,
2321
- functionName: "getUserClaims",
2322
- args: [accountAddress]
2326
+ const contractConfig = getClaimableContractConfig(confidentialityType);
2327
+ const result = await decryptionAwareReadContract({
2328
+ publicClient,
2329
+ queryKey,
2330
+ signal,
2331
+ readContractParams: {
2332
+ address: token.address,
2333
+ abi: contractConfig.abi,
2334
+ functionName: contractConfig.functionName,
2335
+ args: [accountAddress]
2336
+ }
2337
+ });
2338
+ const claims = result.filter((c) => !c.claimed);
2339
+ const { claimableAmount, pendingAmount } = claims.reduce(
2340
+ (acc, claim) => {
2341
+ if (claim.decrypted) {
2342
+ acc.claimableAmount += claim.decryptedAmount;
2343
+ } else {
2344
+ acc.pendingAmount += claim.requestedAmount;
2323
2345
  }
2324
- });
2325
- const claims = result.filter((c) => !c.claimed);
2326
- const { claimableAmount, pendingAmount } = claims.reduce(
2327
- (acc, claim) => {
2328
- if (claim.decrypted) {
2329
- acc.claimableAmount += claim.decryptedAmount;
2330
- } else {
2331
- acc.pendingAmount += claim.requestedAmount;
2332
- }
2333
- return acc;
2334
- },
2335
- { claimableAmount: 0n, pendingAmount: 0n }
2336
- );
2337
- return {
2338
- claimableAmount,
2339
- pendingAmount,
2340
- hasClaimable: claimableAmount > 0n,
2341
- hasPending: pendingAmount > 0n
2342
- };
2343
- }
2344
- return DEFAULT_UNSHIELD_CLAIM_SUMMARY;
2346
+ return acc;
2347
+ },
2348
+ { claimableAmount: 0n, pendingAmount: 0n }
2349
+ );
2350
+ return {
2351
+ claimableAmount,
2352
+ pendingAmount,
2353
+ hasClaimable: claimableAmount > 0n,
2354
+ hasPending: pendingAmount > 0n
2355
+ };
2345
2356
  }
2346
2357
  function useCofheTokenClaimable({ accountAddress: account, token }, queryOptions) {
2347
2358
  const publicClient = useCofhePublicClient();
@@ -2432,12 +2443,15 @@ function createTokenAllowanceQueryOptions(params) {
2432
2443
  (0, import_ts_essentials4.assert)(tokenAddress, "Token address is required to fetch token allowance");
2433
2444
  (0, import_ts_essentials4.assert)(ownerAddress, "Owner address is required to fetch token allowance");
2434
2445
  (0, import_ts_essentials4.assert)(spenderAddress, "Spender address is required to fetch token allowance");
2435
- return publicClient.readContract({
2446
+ const allowanceContract = getShieldAllowanceContractConfig();
2447
+ const allowance = await publicClient.readContract({
2436
2448
  address: tokenAddress,
2437
- abi: ERC20_ALLOWANCE_ABI,
2438
- functionName: "allowance",
2449
+ abi: allowanceContract.abi,
2450
+ functionName: allowanceContract.functionName,
2439
2451
  args: [ownerAddress, spenderAddress]
2440
2452
  });
2453
+ (0, import_ts_essentials4.assert)(typeof allowance === "bigint", "Token allowance must resolve to bigint");
2454
+ return allowance;
2441
2455
  },
2442
2456
  enabled,
2443
2457
  refetchOnMount: false,
@@ -2761,7 +2775,7 @@ var CopyButton = ({ text, size = 14, className }) => {
2761
2775
  setCopied(true);
2762
2776
  setTimeout(() => setCopied(false), 800);
2763
2777
  } catch (err) {
2764
- console.error("Failed to copy address:", err);
2778
+ cofheLogger.error("Failed to copy address:", err);
2765
2779
  }
2766
2780
  };
2767
2781
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -2944,7 +2958,7 @@ function useTransactionGlobalToastsLifecycle() {
2944
2958
  }
2945
2959
  }
2946
2960
  }
2947
- console.error("____ Transaction submission failed for type:", transactionType, "with error:", error);
2961
+ cofheLogger.error("____ Transaction submission failed for type:", transactionType, "with error:", error);
2948
2962
  addToast(
2949
2963
  {
2950
2964
  variant: "error",
@@ -2989,7 +3003,7 @@ function useTransactionGlobalToastsLifecycle() {
2989
3003
  },
2990
3004
  // 2.b. tx receipt fetch failed
2991
3005
  onWatchReceiptFailure: (error, transaction) => {
2992
- console.error("____ Transaction receipt fetch failed for tx:", transaction, "with error:", error);
3006
+ cofheLogger.error("____ Transaction receipt fetch failed for tx:", transaction, "with error:", error);
2993
3007
  addToast(
2994
3008
  {
2995
3009
  variant: "error",
@@ -3194,7 +3208,7 @@ function useHandleInvalidations() {
3194
3208
  );
3195
3209
  }
3196
3210
  } else {
3197
- console.warn("No invalidation logic for transaction action type:", tx.actionType);
3211
+ cofheLogger.warn("No invalidation logic for transaction action type:", tx.actionType);
3198
3212
  }
3199
3213
  };
3200
3214
  return handleInvalidations;
@@ -3940,7 +3954,8 @@ function useCofheTokenTransfer(writeMutationOptions) {
3940
3954
  encryptAmountAndSendToken: ({ input, encryptionOptions }) => {
3941
3955
  const { token, to, amount, userAddress } = input;
3942
3956
  const { input: _ignoredInput, ...encryptionOpts } = encryptionOptions ?? {};
3943
- const contractConfig = TRANSFER_ABIS[token.extensions.fhenix.confidentialityType];
3957
+ assertTokenOperationSupported(token.extensions.fhenix.confidentialityType, "transfer");
3958
+ const contractConfig = getTransferContractConfig(token.extensions.fhenix.confidentialityType);
3944
3959
  return encryptAndWrite({
3945
3960
  params: {
3946
3961
  address: token.address,
@@ -3999,30 +4014,16 @@ function getCofheTokenShieldCallArgs(params) {
3999
4014
  if (!confidentialityType) {
4000
4015
  throw new Error("confidentialityType is required in token extensions");
4001
4016
  }
4002
- if (confidentialityType !== "dual" && confidentialityType !== "wrapped") {
4003
- throw new Error(`Shield not supported for confidentialityType: ${confidentialityType}`);
4004
- }
4005
- if (confidentialityType === "dual") {
4006
- const contractConfig = SHIELD_ABIS.dual;
4007
- return {
4008
- main: {
4009
- address: tokenAddress,
4010
- abi: contractConfig.abi,
4011
- functionName: contractConfig.functionName,
4012
- args: [amount],
4013
- account,
4014
- chain: void 0
4015
- }
4016
- };
4017
- }
4017
+ assertTokenOperationSupported(confidentialityType, "shield");
4018
4018
  const erc20PairAddress = token.extensions.fhenix.erc20Pair?.address;
4019
4019
  const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS_LOWERCASE;
4020
4020
  if (isEth) {
4021
+ const contractConfig = getShieldEthContractConfig(confidentialityType);
4021
4022
  return {
4022
4023
  main: {
4023
4024
  address: tokenAddress,
4024
- abi: WRAPPED_ETH_ENCRYPT_ETH_ABI,
4025
- functionName: "encryptETH",
4025
+ abi: contractConfig.abi,
4026
+ functionName: contractConfig.functionName,
4026
4027
  args: [account],
4027
4028
  value: amount,
4028
4029
  account,
@@ -4036,16 +4037,14 @@ function getCofheTokenShieldCallArgs(params) {
4036
4037
  return {
4037
4038
  approval: {
4038
4039
  address: erc20PairAddress,
4039
- abi: ERC20_APPROVE_ABI,
4040
- functionName: "approve",
4040
+ ...getShieldApproveContractConfig(),
4041
4041
  args: [tokenAddress, amount],
4042
4042
  account,
4043
4043
  chain: void 0
4044
4044
  },
4045
4045
  main: {
4046
+ ...getShieldContractConfig(confidentialityType),
4046
4047
  address: tokenAddress,
4047
- abi: WRAPPED_ENCRYPT_ABI,
4048
- functionName: "encrypt",
4049
4048
  args: [account, amount],
4050
4049
  account,
4051
4050
  chain: void 0
@@ -4075,47 +4074,35 @@ function useCofheTokenShield(options) {
4075
4074
  if (!walletClient.account) {
4076
4075
  throw new Error("Wallet account is required for token shield");
4077
4076
  }
4078
- if (confidentialityType !== "dual" && confidentialityType !== "wrapped") {
4079
- throw new Error(`Shield not supported for confidentialityType: ${confidentialityType}`);
4080
- }
4077
+ assertTokenOperationSupported(confidentialityType, "shield");
4081
4078
  let hash;
4082
- if (confidentialityType === "wrapped") {
4083
- const erc20PairAddress = input.token.extensions.fhenix.erc20Pair?.address;
4084
- const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS_LOWERCASE;
4085
- if (isEth) {
4086
- const { request } = await publicClient.simulateContract({
4087
- address: tokenAddress,
4088
- abi: WRAPPED_ETH_ENCRYPT_ETH_ABI,
4089
- functionName: "encryptETH",
4090
- args: [walletClient.account.address],
4091
- value: input.amount,
4092
- account: walletClient.account
4093
- });
4094
- hash = await walletClient.writeContract({ ...request, chain: void 0 });
4095
- } else {
4096
- if (!erc20PairAddress) {
4097
- throw new Error("erc20Pair address is required for wrapped ERC20 tokens");
4098
- }
4099
- input.onStatusChange?.("Please confirm shield in wallet...");
4100
- const { request: encryptRequest } = await publicClient.simulateContract({
4101
- address: tokenAddress,
4102
- abi: WRAPPED_ENCRYPT_ABI,
4103
- functionName: "encrypt",
4104
- args: [walletClient.account.address, input.amount],
4105
- account: walletClient.account
4106
- });
4107
- hash = await walletClient.writeContract({ ...encryptRequest, chain: void 0 });
4108
- }
4109
- } else {
4110
- const contractConfig = SHIELD_ABIS.dual;
4079
+ const erc20PairAddress = input.token.extensions.fhenix.erc20Pair?.address;
4080
+ const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS_LOWERCASE;
4081
+ if (isEth) {
4082
+ const contractConfig = getShieldEthContractConfig(confidentialityType);
4111
4083
  const { request } = await publicClient.simulateContract({
4112
4084
  address: tokenAddress,
4113
4085
  abi: contractConfig.abi,
4114
4086
  functionName: contractConfig.functionName,
4115
- args: [input.amount],
4087
+ args: [walletClient.account.address],
4088
+ value: input.amount,
4116
4089
  account: walletClient.account
4117
4090
  });
4118
4091
  hash = await walletClient.writeContract({ ...request, chain: void 0 });
4092
+ } else {
4093
+ if (!erc20PairAddress) {
4094
+ throw new Error("erc20Pair address is required for wrapped ERC20 tokens");
4095
+ }
4096
+ input.onStatusChange?.("Please confirm shield in wallet...");
4097
+ const contractConfig = getShieldContractConfig(confidentialityType);
4098
+ const { request: encryptRequest } = await publicClient.simulateContract({
4099
+ address: tokenAddress,
4100
+ abi: contractConfig.abi,
4101
+ functionName: contractConfig.functionName,
4102
+ args: [walletClient.account.address, input.amount],
4103
+ account: walletClient.account
4104
+ });
4105
+ hash = await walletClient.writeContract({ ...encryptRequest, chain: void 0 });
4119
4106
  }
4120
4107
  return hash;
4121
4108
  },
@@ -4245,29 +4232,13 @@ function getCofheTokenUnshieldCallArgs(params) {
4245
4232
  if (!confidentialityType) {
4246
4233
  throw new Error("confidentialityType is required in token extensions");
4247
4234
  }
4248
- if (confidentialityType !== "dual" && confidentialityType !== "wrapped") {
4249
- throw new Error(`Unshield not supported for confidentialityType: ${confidentialityType}`);
4250
- }
4251
- const contractConfig = UNSHIELD_ABIS[confidentialityType];
4252
- if (!contractConfig) {
4253
- throw new Error(`Unsupported confidentialityType for unshield: ${confidentialityType}`);
4254
- }
4255
- if (confidentialityType === "wrapped") {
4256
- return {
4257
- address: tokenAddress,
4258
- abi: contractConfig.abi,
4259
- functionName: contractConfig.functionName,
4260
- args: [account, rawAmount],
4261
- account,
4262
- chain: void 0
4263
- };
4264
- }
4265
- const amount = BigInt.asUintN(64, rawAmount);
4235
+ assertTokenOperationSupported(confidentialityType, "unshield");
4236
+ const contractConfig = getUnshieldContractConfig(confidentialityType);
4266
4237
  return {
4267
4238
  address: tokenAddress,
4268
4239
  abi: contractConfig.abi,
4269
4240
  functionName: contractConfig.functionName,
4270
- args: [amount],
4241
+ args: [account, rawAmount],
4271
4242
  account,
4272
4243
  chain: void 0
4273
4244
  };
@@ -4295,35 +4266,18 @@ function useCofheTokenUnshieldMutation(options) {
4295
4266
  if (!walletClient.account) {
4296
4267
  throw new Error("Wallet account is required for token unshield");
4297
4268
  }
4298
- if (confidentialityType !== "dual" && confidentialityType !== "wrapped") {
4299
- throw new Error(`Unshield not supported for confidentialityType: ${confidentialityType}`);
4300
- }
4301
- const contractConfig = UNSHIELD_ABIS[confidentialityType];
4302
- if (!contractConfig) {
4303
- throw new Error(`Unsupported confidentialityType for unshield: ${confidentialityType}`);
4304
- }
4269
+ assertTokenOperationSupported(confidentialityType, "unshield");
4270
+ const contractConfig = getUnshieldContractConfig(confidentialityType);
4305
4271
  let hash;
4306
4272
  input.onStatusChange?.("Please confirm in wallet...");
4307
- if (confidentialityType === "wrapped") {
4308
- const { request } = await publicClient.simulateContract({
4309
- address: tokenAddress,
4310
- abi: contractConfig.abi,
4311
- functionName: contractConfig.functionName,
4312
- args: [walletClient.account.address, input.amount],
4313
- account: walletClient.account
4314
- });
4315
- hash = await walletClient.writeContract({ ...request, chain: void 0 });
4316
- } else {
4317
- const amount = BigInt.asUintN(64, input.amount);
4318
- const { request } = await publicClient.simulateContract({
4319
- address: tokenAddress,
4320
- abi: contractConfig.abi,
4321
- functionName: contractConfig.functionName,
4322
- args: [amount],
4323
- account: walletClient.account
4324
- });
4325
- hash = await walletClient.writeContract({ ...request, chain: void 0 });
4326
- }
4273
+ const { request } = await publicClient.simulateContract({
4274
+ address: tokenAddress,
4275
+ abi: contractConfig.abi,
4276
+ functionName: contractConfig.functionName,
4277
+ args: [walletClient.account.address, input.amount],
4278
+ account: walletClient.account
4279
+ });
4280
+ hash = await walletClient.writeContract({ ...request, chain: void 0 });
4327
4281
  return hash;
4328
4282
  },
4329
4283
  onError: (error, variables, onMutateResult, context) => {
@@ -4380,13 +4334,8 @@ function getCofheTokenClaimUnshieldedCallArgs(params) {
4380
4334
  if (!confidentialityType) {
4381
4335
  throw new Error("confidentialityType is required in token extensions");
4382
4336
  }
4383
- if (confidentialityType !== "dual" && confidentialityType !== "wrapped") {
4384
- throw new Error(`Claim not supported for confidentialityType: ${confidentialityType}`);
4385
- }
4386
- const contractConfig = CLAIM_ABIS[confidentialityType];
4387
- if (!contractConfig) {
4388
- throw new Error(`Unsupported confidentialityType for claim: ${confidentialityType}`);
4389
- }
4337
+ assertTokenOperationSupported(confidentialityType, "claim");
4338
+ const contractConfig = getClaimContractConfig(confidentialityType);
4390
4339
  return {
4391
4340
  address: tokenAddress,
4392
4341
  abi: contractConfig.abi,
@@ -4419,13 +4368,8 @@ function useCofheTokenClaimUnshielded(options) {
4419
4368
  if (!walletClient.account) {
4420
4369
  throw new Error("Wallet account is required for claim");
4421
4370
  }
4422
- if (confidentialityType !== "dual" && confidentialityType !== "wrapped") {
4423
- throw new Error(`Claim not supported for confidentialityType: ${confidentialityType}`);
4424
- }
4425
- const contractConfig = CLAIM_ABIS[confidentialityType];
4426
- if (!contractConfig) {
4427
- throw new Error(`Unsupported confidentialityType for claim: ${confidentialityType}`);
4428
- }
4371
+ assertTokenOperationSupported(confidentialityType, "claim");
4372
+ const contractConfig = getClaimContractConfig(confidentialityType);
4429
4373
  const { request } = await publicClient.simulateContract({
4430
4374
  address: tokenAddress,
4431
4375
  abi: contractConfig.abi,
@@ -5255,7 +5199,7 @@ function useReceivePermit({ onSuccess, onError } = {}) {
5255
5199
  setImportedPermit(permit);
5256
5200
  setErrorMsg(null);
5257
5201
  } catch (e) {
5258
- console.error("Error parsing pasted permit data", e);
5202
+ cofheLogger.error("Error parsing pasted permit data", e);
5259
5203
  setImportedPermit(null);
5260
5204
  setErrorMsg(`Invalid permit data. Expected JSON.`);
5261
5205
  }
@@ -6226,7 +6170,7 @@ var AddressButton = ({ address, className, icon, showCopyIcon = true }) => {
6226
6170
  setCopied(true);
6227
6171
  setTimeout(() => setCopied(false), 2e3);
6228
6172
  } catch (err) {
6229
- console.error("Failed to copy address:", err);
6173
+ cofheLogger.error("Failed to copy address:", err);
6230
6174
  }
6231
6175
  };
6232
6176
  const truncatedAddress = truncateAddress(address) || "Not connected";
@@ -7793,7 +7737,7 @@ var ImportPermitPage = () => {
7793
7737
  title: "Failed to import permit",
7794
7738
  description: error.message
7795
7739
  });
7796
- console.error("Error importing permit", error);
7740
+ cofheLogger.error("Error importing permit", error);
7797
7741
  }
7798
7742
  });
7799
7743
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
@@ -8125,7 +8069,7 @@ var SendPage = ({ token: _token }) => {
8125
8069
  onError: (error2) => {
8126
8070
  const errorMessage = cofheHumanizeViemError(error2) ?? (error2 instanceof Error ? error2.message : "Failed to send tokens");
8127
8071
  setError(errorMessage);
8128
- console.error("Send tx submit error:", error2);
8072
+ cofheLogger.error("Send tx submit error:", error2);
8129
8073
  },
8130
8074
  onMutate: () => {
8131
8075
  setError(null);
@@ -8396,7 +8340,7 @@ function useClaimUnshieldedWithLifecycle() {
8396
8340
  const errorMessage = cofheHumanizeViemError(error2) ?? (error2 instanceof Error ? error2.message : "Failed to claim unshielded tokens");
8397
8341
  setError(errorMessage);
8398
8342
  setStatus(null);
8399
- console.error("Claim tx submit error:", error2);
8343
+ cofheLogger.error("Claim tx submit error:", error2);
8400
8344
  }
8401
8345
  });
8402
8346
  const { isMining: isClaimingMining } = useOnceTransactionMined({
@@ -8455,7 +8399,7 @@ function useShieldWithLifecycle(token) {
8455
8399
  const errorMessage = cofheHumanizeViemError(error2) ?? (error2 instanceof Error ? error2.message : "Failed to shield tokens");
8456
8400
  setError(errorMessage);
8457
8401
  setStatus(null);
8458
- console.error("Shield tx submit error:", error2);
8402
+ cofheLogger.error("Shield tx submit error:", error2);
8459
8403
  }
8460
8404
  });
8461
8405
  const { tokenApprove, isApprovingMining } = useApproveWithLifecycle({
@@ -8604,7 +8548,7 @@ function useUnshieldWithLifecycle(token) {
8604
8548
  const errorMessage = cofheHumanizeViemError(error2) ?? (error2 instanceof Error ? error2.message : "Failed to unshield tokens");
8605
8549
  setError(errorMessage);
8606
8550
  setStatus(null);
8607
- console.error("Unshield tx submit error:", error2);
8551
+ cofheLogger.error("Unshield tx submit error:", error2);
8608
8552
  },
8609
8553
  onceMined: (transaction) => {
8610
8554
  if (transaction.status === "confirmed") {
@@ -8674,7 +8618,6 @@ function useUnshieldWithLifecycle(token) {
8674
8618
  primaryIcon: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_tb4.TbShieldMinus, { className: "w-3 h-3" })
8675
8619
  };
8676
8620
  }
8677
- var shieldableTypes = /* @__PURE__ */ new Set(["dual", "wrapped"]);
8678
8621
  var ShieldPageV2 = ({ token: _token, defaultMode }) => {
8679
8622
  const [mode, setMode] = (0, import_react55.useState)(defaultMode ?? "shield");
8680
8623
  const [overriddenToken, setOverriddenToken] = (0, import_react55.useState)(null);
@@ -8800,9 +8743,15 @@ var ShieldAndUnshieldPageView = ({
8800
8743
  }) => {
8801
8744
  const { navigateBack } = usePortalNavigation();
8802
8745
  const { openModal } = usePortalModals();
8803
- const isShieldableToken = shieldableTypes.has(token.extensions.fhenix.confidentialityType);
8746
+ const isShieldableToken = isTokenOperationSupported(token.extensions.fhenix.confidentialityType, "shield");
8804
8747
  const { tokensWithExistingEncryptedBalance } = useCofheTokensWithExistingEncryptedBalances();
8805
8748
  const { tokensWithPublicBalances } = useTokensWithPublicBalances();
8749
+ const selectableTokens = (0, import_react55.useMemo)(
8750
+ () => (mode === "unshield" ? tokensWithExistingEncryptedBalance : tokensWithPublicBalances).filter(
8751
+ (candidate) => isTokenOperationSupported(candidate.extensions.fhenix.confidentialityType, mode)
8752
+ ),
8753
+ [mode, tokensWithExistingEncryptedBalance, tokensWithPublicBalances]
8754
+ );
8806
8755
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
8807
8756
  PageContainer,
8808
8757
  {
@@ -8823,7 +8772,7 @@ var ShieldAndUnshieldPageView = ({
8823
8772
  {
8824
8773
  onClick: () => openModal("tokenList" /* TokenList */, {
8825
8774
  balanceType: mode === "shield" ? "public" /* Public */ : "confidential" /* Confidential */,
8826
- tokens: mode === "unshield" ? tokensWithExistingEncryptedBalance : tokensWithPublicBalances,
8775
+ tokens: selectableTokens,
8827
8776
  title: mode === "shield" ? "Select token to shield" : "Select token to unshield",
8828
8777
  onSelectToken: (token2) => setToken(token2)
8829
8778
  }),
@@ -8944,7 +8893,7 @@ function useApproveWithLifecycle({
8944
8893
  const errorMessage = cofheHumanizeViemError(error) ?? (error instanceof Error ? error.message : "Failed to approve tokens");
8945
8894
  setError(errorMessage);
8946
8895
  setStatus(null);
8947
- console.error("Approve tx submit error:", error);
8896
+ cofheLogger.error("Approve tx submit error:", error);
8948
8897
  }
8949
8898
  });
8950
8899
  const { isMining: isApprovingMining } = useOnceTransactionMined({
@@ -10477,7 +10426,7 @@ var CofheEncryptInput = ({
10477
10426
  setCopySuccess(false);
10478
10427
  }, 2e3);
10479
10428
  } catch (error) {
10480
- console.error("Failed to copy to clipboard:", error);
10429
+ cofheLogger.error("Failed to copy to clipboard:", error);
10481
10430
  }
10482
10431
  };
10483
10432
  const handleTypeSelect = async (type) => {
@@ -10496,13 +10445,13 @@ var CofheEncryptInput = ({
10496
10445
  onEncryptComplete?.(data);
10497
10446
  } catch (error) {
10498
10447
  const errorMessage2 = error instanceof Error ? error.message : "Encryption failed";
10499
- console.error("Encryption failed:", error);
10448
+ cofheLogger.error("Encryption failed:", error);
10500
10449
  onEncryptError?.(errorMessage2);
10501
10450
  }
10502
10451
  })();
10503
10452
  } catch (error) {
10504
10453
  const errorMessage2 = error instanceof Error ? error.message : "Encryption setup failed";
10505
- console.error("Encryption setup failed:", error);
10454
+ cofheLogger.error("Encryption setup failed:", error);
10506
10455
  onEncryptError?.(errorMessage2);
10507
10456
  }
10508
10457
  }