@cofhe/react 0.0.0-beta-20260417095940 → 0.0.0-beta-20260421064638
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 +1075 -678
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +10 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +92 -48
- package/dist/index.d.ts +92 -48
- package/dist/index.js +1005 -608
- package/dist/index.js.map +1 -1
- package/dist/styles.css +10 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -800,7 +800,7 @@ __export(index_exports, {
|
|
|
800
800
|
module.exports = __toCommonJS(index_exports);
|
|
801
801
|
|
|
802
802
|
// src/providers/CofheProvider.tsx
|
|
803
|
-
var
|
|
803
|
+
var import_react64 = require("react");
|
|
804
804
|
|
|
805
805
|
// src/providers/QueryProvider.tsx
|
|
806
806
|
var import_react_query = require("@tanstack/react-query");
|
|
@@ -837,6 +837,78 @@ 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
|
+
label: "Wrapped confidential token",
|
|
844
|
+
confidentialValueType: "uint128",
|
|
845
|
+
publicBalanceSource: "erc20Pair",
|
|
846
|
+
operations: {
|
|
847
|
+
confidentialBalance: true,
|
|
848
|
+
transfer: true,
|
|
849
|
+
publicBalance: true,
|
|
850
|
+
shield: true,
|
|
851
|
+
unshield: true,
|
|
852
|
+
claim: true,
|
|
853
|
+
claimable: true
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
pure: {
|
|
857
|
+
enabled: false,
|
|
858
|
+
label: "Pure confidential token",
|
|
859
|
+
confidentialValueType: "uint64",
|
|
860
|
+
publicBalanceSource: null,
|
|
861
|
+
operations: {
|
|
862
|
+
confidentialBalance: false,
|
|
863
|
+
transfer: false,
|
|
864
|
+
publicBalance: false,
|
|
865
|
+
shield: false,
|
|
866
|
+
unshield: false,
|
|
867
|
+
claim: false,
|
|
868
|
+
claimable: false
|
|
869
|
+
}
|
|
870
|
+
},
|
|
871
|
+
dual: {
|
|
872
|
+
enabled: false,
|
|
873
|
+
label: "Dual-balance confidential token",
|
|
874
|
+
confidentialValueType: "uint64",
|
|
875
|
+
publicBalanceSource: "token",
|
|
876
|
+
operations: {
|
|
877
|
+
confidentialBalance: false,
|
|
878
|
+
transfer: false,
|
|
879
|
+
publicBalance: false,
|
|
880
|
+
shield: false,
|
|
881
|
+
unshield: false,
|
|
882
|
+
claim: false,
|
|
883
|
+
claimable: false
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
var TOKEN_CONFIDENTIALITY_TYPES = Object.keys(TOKEN_CONFIDENTIALITY_SUPPORT);
|
|
888
|
+
function isTokenConfidentialityType(value) {
|
|
889
|
+
return typeof value === "string" && value in TOKEN_CONFIDENTIALITY_SUPPORT;
|
|
890
|
+
}
|
|
891
|
+
function isSupportedTokenConfidentialityType(value) {
|
|
892
|
+
return isTokenConfidentialityType(value) && TOKEN_CONFIDENTIALITY_SUPPORT[value].enabled;
|
|
893
|
+
}
|
|
894
|
+
function isTokenOperationSupported(type, operation) {
|
|
895
|
+
return isTokenConfidentialityType(type) && TOKEN_CONFIDENTIALITY_SUPPORT[type].operations[operation];
|
|
896
|
+
}
|
|
897
|
+
function getPublicBalanceSourceType(type) {
|
|
898
|
+
if (!isTokenConfidentialityType(type)) return null;
|
|
899
|
+
return TOKEN_CONFIDENTIALITY_SUPPORT[type].publicBalanceSource;
|
|
900
|
+
}
|
|
901
|
+
function getTokenConfidentialityLabel(type) {
|
|
902
|
+
if (!isTokenConfidentialityType(type)) return null;
|
|
903
|
+
return TOKEN_CONFIDENTIALITY_SUPPORT[type].label;
|
|
904
|
+
}
|
|
905
|
+
function getTokenConfidentialValueType(type) {
|
|
906
|
+
return TOKEN_CONFIDENTIALITY_SUPPORT[type].confidentialValueType;
|
|
907
|
+
}
|
|
908
|
+
function assertTokenOperationSupported(type, operation) {
|
|
909
|
+
if (isTokenOperationSupported(type, operation)) return;
|
|
910
|
+
throw new Error(`${operation} not supported for confidentialityType: ${type ?? "undefined"}`);
|
|
911
|
+
}
|
|
840
912
|
var WETH_SEPOLIA_TOKEN = {
|
|
841
913
|
chainId: 11155111,
|
|
842
914
|
address: "0x87A3effB84CBE1E4caB6Ab430139eC41d156D55A",
|
|
@@ -915,7 +987,7 @@ var isEthPair = (erc20Pair) => {
|
|
|
915
987
|
return erc20Pair.address.toLowerCase() === ETH_ADDRESS_LOWERCASE;
|
|
916
988
|
};
|
|
917
989
|
var isWrappedEthToken = (token) => {
|
|
918
|
-
if (token.extensions.fhenix.confidentialityType
|
|
990
|
+
if (!isSupportedTokenConfidentialityType(token.extensions.fhenix.confidentialityType)) return false;
|
|
919
991
|
return isEthPair(token.extensions.fhenix.erc20Pair);
|
|
920
992
|
};
|
|
921
993
|
var FheTypesList = [
|
|
@@ -1666,249 +1738,471 @@ function useCofheReadContract(params, queryOptions) {
|
|
|
1666
1738
|
// src/hooks/useTrackPendingTransactions.ts
|
|
1667
1739
|
var import_react_query8 = require("@tanstack/react-query");
|
|
1668
1740
|
|
|
1669
|
-
// src/constants/
|
|
1741
|
+
// src/constants/confidentialTokenWrapped.ts
|
|
1670
1742
|
var import_viem4 = require("viem");
|
|
1671
|
-
var
|
|
1672
|
-
|
|
1673
|
-
])
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
{
|
|
1677
|
-
|
|
1743
|
+
var wrappedErc20ApprovalContracts = {
|
|
1744
|
+
allowance: {
|
|
1745
|
+
abi: (0, import_viem4.parseAbi)(["function allowance(address owner, address spender) view returns (uint256)"]),
|
|
1746
|
+
functionName: "allowance"
|
|
1747
|
+
},
|
|
1748
|
+
approve: {
|
|
1749
|
+
abi: (0, import_viem4.parseAbi)(["function approve(address spender, uint256 amount) returns (bool)"]),
|
|
1750
|
+
functionName: "approve"
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
var WRAPPED_TOKEN_CONTRACTS = {
|
|
1754
|
+
detection: {
|
|
1755
|
+
abi: [
|
|
1678
1756
|
{
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1757
|
+
inputs: [
|
|
1758
|
+
{
|
|
1759
|
+
internalType: "address",
|
|
1760
|
+
name: "account",
|
|
1761
|
+
type: "address"
|
|
1762
|
+
}
|
|
1763
|
+
],
|
|
1764
|
+
name: "encBalanceOf",
|
|
1765
|
+
outputs: [
|
|
1766
|
+
{
|
|
1767
|
+
internalType: "euint128",
|
|
1768
|
+
name: "",
|
|
1769
|
+
type: "uint256"
|
|
1770
|
+
}
|
|
1771
|
+
],
|
|
1772
|
+
stateMutability: "view",
|
|
1773
|
+
type: "function"
|
|
1682
1774
|
}
|
|
1683
1775
|
],
|
|
1684
|
-
|
|
1685
|
-
|
|
1776
|
+
functionName: "encBalanceOf",
|
|
1777
|
+
args: [import_viem4.zeroAddress]
|
|
1778
|
+
},
|
|
1779
|
+
confidentialBalance: {
|
|
1780
|
+
abi: [
|
|
1686
1781
|
{
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1782
|
+
inputs: [
|
|
1783
|
+
{
|
|
1784
|
+
internalType: "address",
|
|
1785
|
+
name: "account",
|
|
1786
|
+
type: "address"
|
|
1787
|
+
}
|
|
1788
|
+
],
|
|
1789
|
+
name: "encBalanceOf",
|
|
1790
|
+
outputs: [
|
|
1791
|
+
{
|
|
1792
|
+
internalType: "euint128",
|
|
1793
|
+
name: "",
|
|
1794
|
+
type: "uint256"
|
|
1795
|
+
}
|
|
1796
|
+
],
|
|
1797
|
+
stateMutability: "view",
|
|
1798
|
+
type: "function"
|
|
1690
1799
|
}
|
|
1691
1800
|
],
|
|
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
1801
|
functionName: "encBalanceOf"
|
|
1706
1802
|
},
|
|
1707
|
-
|
|
1708
|
-
abi:
|
|
1709
|
-
functionName: "confidentialBalanceOf"
|
|
1710
|
-
},
|
|
1711
|
-
dual: {
|
|
1712
|
-
abi: CONFIDENTIAL_TYPE_DUAL_ABI,
|
|
1713
|
-
functionName: "confidentialBalanceOf"
|
|
1714
|
-
}
|
|
1715
|
-
};
|
|
1716
|
-
var WRAPPED_TRANSFER_ABI = [
|
|
1717
|
-
{
|
|
1718
|
-
inputs: [
|
|
1803
|
+
confidentialTransfer: {
|
|
1804
|
+
abi: [
|
|
1719
1805
|
{
|
|
1720
|
-
|
|
1721
|
-
name: "to",
|
|
1722
|
-
type: "address"
|
|
1723
|
-
},
|
|
1724
|
-
{
|
|
1725
|
-
components: [
|
|
1806
|
+
inputs: [
|
|
1726
1807
|
{
|
|
1727
|
-
internalType: "
|
|
1728
|
-
name: "
|
|
1729
|
-
type: "
|
|
1808
|
+
internalType: "address",
|
|
1809
|
+
name: "to",
|
|
1810
|
+
type: "address"
|
|
1730
1811
|
},
|
|
1731
1812
|
{
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1813
|
+
components: [
|
|
1814
|
+
{
|
|
1815
|
+
internalType: "uint256",
|
|
1816
|
+
name: "ctHash",
|
|
1817
|
+
type: "uint256"
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
internalType: "uint8",
|
|
1821
|
+
name: "securityZone",
|
|
1822
|
+
type: "uint8"
|
|
1823
|
+
},
|
|
1824
|
+
{
|
|
1825
|
+
internalType: "uint8",
|
|
1826
|
+
name: "utype",
|
|
1827
|
+
type: "uint8"
|
|
1828
|
+
},
|
|
1829
|
+
{
|
|
1830
|
+
internalType: "bytes",
|
|
1831
|
+
name: "signature",
|
|
1832
|
+
type: "bytes"
|
|
1833
|
+
}
|
|
1834
|
+
],
|
|
1835
|
+
internalType: "struct InEuint128",
|
|
1836
|
+
name: "inValue",
|
|
1837
|
+
type: "tuple"
|
|
1838
|
+
}
|
|
1839
|
+
],
|
|
1840
|
+
name: "encTransfer",
|
|
1841
|
+
outputs: [
|
|
1741
1842
|
{
|
|
1742
|
-
internalType: "
|
|
1743
|
-
name: "
|
|
1744
|
-
type: "
|
|
1843
|
+
internalType: "euint128",
|
|
1844
|
+
name: "transferred",
|
|
1845
|
+
type: "uint256"
|
|
1745
1846
|
}
|
|
1746
1847
|
],
|
|
1747
|
-
|
|
1748
|
-
|
|
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
|
-
]
|
|
1848
|
+
stateMutability: "nonpayable",
|
|
1849
|
+
type: "function"
|
|
1780
1850
|
}
|
|
1781
1851
|
],
|
|
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
1852
|
functionName: "encTransfer"
|
|
1810
1853
|
},
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1854
|
+
shield: {
|
|
1855
|
+
approval: wrappedErc20ApprovalContracts,
|
|
1856
|
+
erc20: {
|
|
1857
|
+
abi: (0, import_viem4.parseAbi)(["function encrypt(address to, uint128 value) public"]),
|
|
1858
|
+
functionName: "encrypt"
|
|
1859
|
+
},
|
|
1860
|
+
native: {
|
|
1861
|
+
abi: (0, import_viem4.parseAbi)(["function encryptETH(address to) public payable"]),
|
|
1862
|
+
functionName: "encryptETH"
|
|
1863
|
+
},
|
|
1864
|
+
wrappedPair: {
|
|
1865
|
+
abi: (0, import_viem4.parseAbi)(["function encryptWETH(address to, uint128 value) public"]),
|
|
1866
|
+
functionName: "encryptWETH"
|
|
1867
|
+
}
|
|
1814
1868
|
},
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1869
|
+
unshield: {
|
|
1870
|
+
abi: (0, import_viem4.parseAbi)(["function decrypt(address to, uint128 value) public"]),
|
|
1871
|
+
functionName: "decrypt"
|
|
1872
|
+
},
|
|
1873
|
+
claims: {
|
|
1874
|
+
single: {
|
|
1875
|
+
abi: (0, import_viem4.parseAbi)(["function claimDecrypted(uint256 ctHash) public"]),
|
|
1876
|
+
functionName: "claimDecrypted"
|
|
1877
|
+
},
|
|
1878
|
+
all: {
|
|
1879
|
+
abi: (0, import_viem4.parseAbi)(["function claimAllDecrypted() public"]),
|
|
1880
|
+
functionName: "claimAllDecrypted"
|
|
1881
|
+
},
|
|
1882
|
+
query: {
|
|
1883
|
+
abi: [
|
|
1884
|
+
{
|
|
1885
|
+
inputs: [{ name: "user", type: "address" }],
|
|
1886
|
+
name: "getUserClaims",
|
|
1887
|
+
outputs: [
|
|
1888
|
+
{
|
|
1889
|
+
components: [
|
|
1890
|
+
{ name: "ctHash", type: "uint256" },
|
|
1891
|
+
{ name: "requestedAmount", type: "uint128" },
|
|
1892
|
+
{ name: "decryptedAmount", type: "uint128" },
|
|
1893
|
+
{ name: "decrypted", type: "bool" },
|
|
1894
|
+
{ name: "to", type: "address" },
|
|
1895
|
+
{ name: "claimed", type: "bool" }
|
|
1896
|
+
],
|
|
1897
|
+
name: "",
|
|
1898
|
+
type: "tuple[]"
|
|
1899
|
+
}
|
|
1900
|
+
],
|
|
1901
|
+
stateMutability: "view",
|
|
1902
|
+
type: "function"
|
|
1903
|
+
}
|
|
1904
|
+
],
|
|
1905
|
+
functionName: "getUserClaims"
|
|
1906
|
+
}
|
|
1819
1907
|
}
|
|
1820
1908
|
};
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
{
|
|
1826
|
-
|
|
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
|
-
]
|
|
1909
|
+
|
|
1910
|
+
// src/constants/confidentialTokenABIs.ts
|
|
1911
|
+
function getRequiredContractConfig(configs, confidentialityType, operation) {
|
|
1912
|
+
const config = configs[confidentialityType];
|
|
1913
|
+
if (!config) {
|
|
1914
|
+
throw new Error(`${operation} config is not defined for confidentialityType: ${confidentialityType}`);
|
|
1843
1915
|
}
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
var
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1916
|
+
return config;
|
|
1917
|
+
}
|
|
1918
|
+
var TOKEN_CONFIDENTIALITY_CONTRACTS = {
|
|
1919
|
+
wrapped: WRAPPED_TOKEN_CONTRACTS
|
|
1920
|
+
};
|
|
1921
|
+
function getDefaultShieldApprovalContracts() {
|
|
1922
|
+
return WRAPPED_TOKEN_CONTRACTS.shield.approval;
|
|
1923
|
+
}
|
|
1924
|
+
function getContractsForType(confidentialityType) {
|
|
1925
|
+
return getRequiredContractConfig(TOKEN_CONFIDENTIALITY_CONTRACTS, confidentialityType, "token contracts");
|
|
1926
|
+
}
|
|
1927
|
+
function getTokenContractConfig(confidentialityType) {
|
|
1928
|
+
return getContractsForType(confidentialityType).confidentialBalance;
|
|
1929
|
+
}
|
|
1930
|
+
function getSupportedTokenDetectionConfigs() {
|
|
1931
|
+
return TOKEN_CONFIDENTIALITY_TYPES.filter(
|
|
1932
|
+
(confidentialityType) => isSupportedTokenConfidentialityType(confidentialityType)
|
|
1933
|
+
).map((confidentialityType) => ({
|
|
1934
|
+
confidentialityType,
|
|
1935
|
+
probe: getContractsForType(confidentialityType).detection,
|
|
1936
|
+
confidentialValueType: getTokenConfidentialValueType(confidentialityType)
|
|
1937
|
+
}));
|
|
1938
|
+
}
|
|
1939
|
+
function getTransferContractConfig(confidentialityType) {
|
|
1940
|
+
return getContractsForType(confidentialityType).confidentialTransfer;
|
|
1941
|
+
}
|
|
1942
|
+
function getShieldContractConfig(confidentialityType) {
|
|
1943
|
+
const contracts = getContractsForType(confidentialityType).shield;
|
|
1944
|
+
if (!contracts) {
|
|
1945
|
+
throw new Error(`shield config is not defined for confidentialityType: ${confidentialityType}`);
|
|
1869
1946
|
}
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1947
|
+
return contracts.erc20;
|
|
1948
|
+
}
|
|
1949
|
+
function getShieldAllowanceContractConfig() {
|
|
1950
|
+
return getDefaultShieldApprovalContracts().allowance;
|
|
1951
|
+
}
|
|
1952
|
+
function getShieldApproveContractConfig() {
|
|
1953
|
+
return getDefaultShieldApprovalContracts().approve;
|
|
1954
|
+
}
|
|
1955
|
+
function getShieldEthContractConfig(confidentialityType) {
|
|
1956
|
+
const contracts = getContractsForType(confidentialityType).shield;
|
|
1957
|
+
if (!contracts) {
|
|
1958
|
+
throw new Error(`shield ETH config is not defined for confidentialityType: ${confidentialityType}`);
|
|
1882
1959
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
wrapped: {
|
|
1890
|
-
// TBD - needs claim flow
|
|
1891
|
-
abi: WRAPPED_DECRYPT_ABI,
|
|
1892
|
-
functionName: "decrypt"
|
|
1960
|
+
return contracts.native;
|
|
1961
|
+
}
|
|
1962
|
+
function getUnshieldContractConfig(confidentialityType) {
|
|
1963
|
+
const contracts = getContractsForType(confidentialityType).unshield;
|
|
1964
|
+
if (!contracts) {
|
|
1965
|
+
throw new Error(`unshield config is not defined for confidentialityType: ${confidentialityType}`);
|
|
1893
1966
|
}
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
wrapped: {
|
|
1901
|
-
abi: WRAPPED_CLAIM_ALL_DECRYPTED_ABI,
|
|
1902
|
-
functionName: "claimAllDecrypted"
|
|
1967
|
+
return contracts;
|
|
1968
|
+
}
|
|
1969
|
+
function getClaimContractConfig(confidentialityType) {
|
|
1970
|
+
const contracts = getContractsForType(confidentialityType).claims;
|
|
1971
|
+
if (!contracts) {
|
|
1972
|
+
throw new Error(`claim config is not defined for confidentialityType: ${confidentialityType}`);
|
|
1903
1973
|
}
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1974
|
+
return contracts.all;
|
|
1975
|
+
}
|
|
1976
|
+
function getClaimableContractConfig(confidentialityType) {
|
|
1977
|
+
const contracts = getContractsForType(confidentialityType).claims;
|
|
1978
|
+
if (!contracts) {
|
|
1979
|
+
throw new Error(`claimable config is not defined for confidentialityType: ${confidentialityType}`);
|
|
1980
|
+
}
|
|
1981
|
+
return contracts.query;
|
|
1907
1982
|
}
|
|
1908
1983
|
|
|
1909
1984
|
// src/hooks/useCofheTokenLists.ts
|
|
1910
1985
|
var import_react_query3 = require("@tanstack/react-query");
|
|
1911
1986
|
var import_react5 = require("react");
|
|
1987
|
+
|
|
1988
|
+
// src/stores/customTokensStore.ts
|
|
1989
|
+
var import_zustand2 = require("zustand");
|
|
1990
|
+
var import_middleware2 = require("zustand/middleware");
|
|
1991
|
+
var useCustomTokensStore = (0, import_zustand2.create)()(
|
|
1992
|
+
(0, import_middleware2.persist)(
|
|
1993
|
+
(set) => ({
|
|
1994
|
+
customTokensByChainId: {},
|
|
1995
|
+
addCustomToken: (token) => {
|
|
1996
|
+
set((state) => {
|
|
1997
|
+
const chainKey = token.chainId.toString();
|
|
1998
|
+
const existing = state.customTokensByChainId[chainKey] ?? [];
|
|
1999
|
+
const normalizedAddress = token.address.toLowerCase();
|
|
2000
|
+
return {
|
|
2001
|
+
customTokensByChainId: {
|
|
2002
|
+
...state.customTokensByChainId,
|
|
2003
|
+
[chainKey]: [token, ...existing.filter((item) => item.address.toLowerCase() !== normalizedAddress)]
|
|
2004
|
+
}
|
|
2005
|
+
};
|
|
2006
|
+
});
|
|
2007
|
+
},
|
|
2008
|
+
removeCustomToken: ({ chainId, address }) => {
|
|
2009
|
+
set((state) => {
|
|
2010
|
+
const chainKey = chainId.toString();
|
|
2011
|
+
const existing = state.customTokensByChainId[chainKey] ?? [];
|
|
2012
|
+
const filtered = existing.filter((item) => item.address.toLowerCase() !== address.toLowerCase());
|
|
2013
|
+
if (filtered.length === existing.length) {
|
|
2014
|
+
return state;
|
|
2015
|
+
}
|
|
2016
|
+
const next = { ...state.customTokensByChainId };
|
|
2017
|
+
if (filtered.length === 0) {
|
|
2018
|
+
delete next[chainKey];
|
|
2019
|
+
} else {
|
|
2020
|
+
next[chainKey] = filtered;
|
|
2021
|
+
}
|
|
2022
|
+
return {
|
|
2023
|
+
customTokensByChainId: next
|
|
2024
|
+
};
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
}),
|
|
2028
|
+
{
|
|
2029
|
+
name: "cofhesdk-react-custom-tokens",
|
|
2030
|
+
storage: (0, import_middleware2.createJSONStorage)(() => localStorage)
|
|
2031
|
+
}
|
|
2032
|
+
)
|
|
2033
|
+
);
|
|
2034
|
+
|
|
2035
|
+
// src/hooks/useResolvedCofheToken.ts
|
|
2036
|
+
var import_viem6 = require("viem");
|
|
2037
|
+
|
|
2038
|
+
// src/constants/erc20ABIs.ts
|
|
2039
|
+
var import_viem5 = require("viem");
|
|
2040
|
+
var ERC20_BALANCE_OF_ABI = (0, import_viem5.parseAbi)(["function balanceOf(address owner) view returns (uint256)"]);
|
|
2041
|
+
var ERC20_DECIMALS_ABI = (0, import_viem5.parseAbi)(["function decimals() view returns (uint8)"]);
|
|
2042
|
+
var ERC20_SYMBOL_ABI = (0, import_viem5.parseAbi)(["function symbol() view returns (string)"]);
|
|
2043
|
+
var ERC20_NAME_ABI = (0, import_viem5.parseAbi)(["function name() view returns (string)"]);
|
|
2044
|
+
|
|
2045
|
+
// src/hooks/useResolvedCofheToken.ts
|
|
2046
|
+
var SUPPORTED_TOKEN_DETECTION_CONFIGS = getSupportedTokenDetectionConfigs();
|
|
2047
|
+
var TOKEN_PAIR_GETTER_ABIS = {
|
|
2048
|
+
token: (0, import_viem6.parseAbi)(["function token() view returns (address)"]),
|
|
2049
|
+
underlying: (0, import_viem6.parseAbi)(["function underlying() view returns (address)"]),
|
|
2050
|
+
underlyingToken: (0, import_viem6.parseAbi)(["function underlyingToken() view returns (address)"]),
|
|
2051
|
+
asset: (0, import_viem6.parseAbi)(["function asset() view returns (address)"]),
|
|
2052
|
+
erc20: (0, import_viem6.parseAbi)(["function erc20() view returns (address)"]),
|
|
2053
|
+
erc20Token: (0, import_viem6.parseAbi)(["function erc20Token() view returns (address)"])
|
|
2054
|
+
};
|
|
2055
|
+
var PAIR_GETTER_ENTRIES = [
|
|
2056
|
+
["token", TOKEN_PAIR_GETTER_ABIS.token],
|
|
2057
|
+
["underlying", TOKEN_PAIR_GETTER_ABIS.underlying],
|
|
2058
|
+
["underlyingToken", TOKEN_PAIR_GETTER_ABIS.underlyingToken],
|
|
2059
|
+
["asset", TOKEN_PAIR_GETTER_ABIS.asset],
|
|
2060
|
+
["erc20", TOKEN_PAIR_GETTER_ABIS.erc20],
|
|
2061
|
+
["erc20Token", TOKEN_PAIR_GETTER_ABIS.erc20Token]
|
|
2062
|
+
];
|
|
2063
|
+
function pickUnderlyingPairAddress(results, tokenAddress) {
|
|
2064
|
+
for (const result of results) {
|
|
2065
|
+
if (!result || typeof result !== "object") continue;
|
|
2066
|
+
const typedResult = result;
|
|
2067
|
+
if (typedResult.status !== "success") continue;
|
|
2068
|
+
const candidate = typedResult.result;
|
|
2069
|
+
if (typeof candidate !== "string" || !(0, import_viem6.isAddress)(candidate)) continue;
|
|
2070
|
+
if (candidate.toLowerCase() === import_viem6.zeroAddress) continue;
|
|
2071
|
+
if (candidate.toLowerCase() === tokenAddress.toLowerCase()) continue;
|
|
2072
|
+
return candidate;
|
|
2073
|
+
}
|
|
2074
|
+
return void 0;
|
|
2075
|
+
}
|
|
2076
|
+
function useResolvedCofheToken({ chainId: _chainId, address }, queryOptions) {
|
|
2077
|
+
const publicClient = useCofhePublicClient();
|
|
2078
|
+
const cofheChainId = useCofheChainId();
|
|
2079
|
+
const chainId = _chainId ?? cofheChainId;
|
|
2080
|
+
return useInternalQuery({
|
|
2081
|
+
queryKey: ["resolvedCofheToken", chainId, address?.toLowerCase()],
|
|
2082
|
+
queryFn: async () => {
|
|
2083
|
+
if (!publicClient) {
|
|
2084
|
+
throw new Error("PublicClient is required to resolve a token");
|
|
2085
|
+
}
|
|
2086
|
+
if (!chainId || !address) {
|
|
2087
|
+
return void 0;
|
|
2088
|
+
}
|
|
2089
|
+
const metadataResults = await publicClient.multicall({
|
|
2090
|
+
contracts: [
|
|
2091
|
+
{
|
|
2092
|
+
address,
|
|
2093
|
+
abi: ERC20_DECIMALS_ABI,
|
|
2094
|
+
functionName: "decimals"
|
|
2095
|
+
},
|
|
2096
|
+
{
|
|
2097
|
+
address,
|
|
2098
|
+
abi: ERC20_SYMBOL_ABI,
|
|
2099
|
+
functionName: "symbol"
|
|
2100
|
+
},
|
|
2101
|
+
{
|
|
2102
|
+
address,
|
|
2103
|
+
abi: ERC20_NAME_ABI,
|
|
2104
|
+
functionName: "name"
|
|
2105
|
+
}
|
|
2106
|
+
]
|
|
2107
|
+
});
|
|
2108
|
+
const decimals = metadataResults[0].result;
|
|
2109
|
+
const symbol = metadataResults[1].result;
|
|
2110
|
+
const name = metadataResults[2].result;
|
|
2111
|
+
if (decimals == null || symbol == null || name == null) {
|
|
2112
|
+
throw new Error("Failed to fetch token metadata");
|
|
2113
|
+
}
|
|
2114
|
+
const [supportedType, pairGetterResults] = await Promise.all([
|
|
2115
|
+
Promise.all(
|
|
2116
|
+
SUPPORTED_TOKEN_DETECTION_CONFIGS.map(async (entry) => {
|
|
2117
|
+
const detected = await publicClient.readContract({
|
|
2118
|
+
address,
|
|
2119
|
+
abi: entry.probe.abi,
|
|
2120
|
+
functionName: entry.probe.functionName,
|
|
2121
|
+
args: entry.probe.args
|
|
2122
|
+
}).then(() => true).catch(() => false);
|
|
2123
|
+
return detected ? entry : null;
|
|
2124
|
+
})
|
|
2125
|
+
).then((entries) => entries.find((entry) => entry != null) ?? null),
|
|
2126
|
+
publicClient.multicall({
|
|
2127
|
+
contracts: PAIR_GETTER_ENTRIES.map(([, abi]) => ({
|
|
2128
|
+
address,
|
|
2129
|
+
abi,
|
|
2130
|
+
functionName: abi[0].name
|
|
2131
|
+
})),
|
|
2132
|
+
allowFailure: true
|
|
2133
|
+
})
|
|
2134
|
+
]);
|
|
2135
|
+
if (!supportedType) {
|
|
2136
|
+
throw new Error("Address is not a supported CoFHE token");
|
|
2137
|
+
}
|
|
2138
|
+
const confidentialityType = supportedType.confidentialityType;
|
|
2139
|
+
const extensions = {
|
|
2140
|
+
fhenix: {
|
|
2141
|
+
confidentialityType,
|
|
2142
|
+
confidentialValueType: supportedType.confidentialValueType
|
|
2143
|
+
}
|
|
2144
|
+
};
|
|
2145
|
+
if (confidentialityType === "wrapped") {
|
|
2146
|
+
const pairAddress = pickUnderlyingPairAddress(pairGetterResults, address);
|
|
2147
|
+
if (pairAddress) {
|
|
2148
|
+
if (pairAddress.toLowerCase() === ETH_ADDRESS_LOWERCASE) {
|
|
2149
|
+
extensions.fhenix.erc20Pair = {
|
|
2150
|
+
address: ETH_ADDRESS_LOWERCASE,
|
|
2151
|
+
symbol: "ETH",
|
|
2152
|
+
decimals: 18
|
|
2153
|
+
};
|
|
2154
|
+
} else {
|
|
2155
|
+
const pairMetadata = await publicClient.multicall({
|
|
2156
|
+
contracts: [
|
|
2157
|
+
{
|
|
2158
|
+
address: pairAddress,
|
|
2159
|
+
abi: ERC20_DECIMALS_ABI,
|
|
2160
|
+
functionName: "decimals"
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
address: pairAddress,
|
|
2164
|
+
abi: ERC20_SYMBOL_ABI,
|
|
2165
|
+
functionName: "symbol"
|
|
2166
|
+
}
|
|
2167
|
+
],
|
|
2168
|
+
allowFailure: true
|
|
2169
|
+
});
|
|
2170
|
+
const pairDecimals = pairMetadata[0]?.status === "success" ? pairMetadata[0].result : void 0;
|
|
2171
|
+
const pairSymbol = pairMetadata[1]?.status === "success" ? pairMetadata[1].result : void 0;
|
|
2172
|
+
if (pairDecimals != null && pairSymbol != null) {
|
|
2173
|
+
extensions.fhenix.erc20Pair = {
|
|
2174
|
+
address: pairAddress,
|
|
2175
|
+
symbol: pairSymbol,
|
|
2176
|
+
decimals: pairDecimals
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
return {
|
|
2183
|
+
chainId,
|
|
2184
|
+
address,
|
|
2185
|
+
decimals,
|
|
2186
|
+
symbol,
|
|
2187
|
+
name,
|
|
2188
|
+
extensions
|
|
2189
|
+
};
|
|
2190
|
+
},
|
|
2191
|
+
enabled: (queryOptions?.enabled ?? true) && !!publicClient && !!chainId && !!address,
|
|
2192
|
+
staleTime: Infinity,
|
|
2193
|
+
...queryOptions
|
|
2194
|
+
});
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
// src/hooks/useCofheTokenLists.ts
|
|
2198
|
+
function isSupportedToken(token) {
|
|
2199
|
+
const confidentialityType = token.extensions?.fhenix?.confidentialityType;
|
|
2200
|
+
return isSupportedTokenConfidentialityType(confidentialityType);
|
|
2201
|
+
}
|
|
2202
|
+
function getCustomTokensForChain(customTokensByChainId, chainId) {
|
|
2203
|
+
if (!chainId) return [];
|
|
2204
|
+
return customTokensByChainId[chainId.toString()] ?? [];
|
|
2205
|
+
}
|
|
1912
2206
|
function useCofheTokenLists({ chainId }, queryOptions) {
|
|
1913
2207
|
const widgetConfig = useCofheContext().client.config.react;
|
|
1914
2208
|
const tokensListsUrls = chainId ? widgetConfig.tokenLists?.[chainId] : [];
|
|
@@ -1930,7 +2224,7 @@ function useCofheTokenLists({ chainId }, queryOptions) {
|
|
|
1930
2224
|
select: (data) => {
|
|
1931
2225
|
return {
|
|
1932
2226
|
...data,
|
|
1933
|
-
tokens: data.tokens.filter((token) => token.chainId === chainId)
|
|
2227
|
+
tokens: data.tokens.filter((token) => token.chainId === chainId && isSupportedToken(token))
|
|
1934
2228
|
};
|
|
1935
2229
|
},
|
|
1936
2230
|
...queryOptions
|
|
@@ -1942,6 +2236,8 @@ function useCofheTokenLists({ chainId }, queryOptions) {
|
|
|
1942
2236
|
}
|
|
1943
2237
|
function useCofheTokens(chainId) {
|
|
1944
2238
|
const tokenLists = useCofheTokenLists({ chainId });
|
|
2239
|
+
const customTokensByChainId = useCustomTokensStore((state) => state.customTokensByChainId);
|
|
2240
|
+
const customTokens = getCustomTokensForChain(customTokensByChainId, chainId);
|
|
1945
2241
|
const tokens = (0, import_react5.useMemo)(() => {
|
|
1946
2242
|
const map = /* @__PURE__ */ new Map();
|
|
1947
2243
|
tokenLists.forEach((result) => {
|
|
@@ -1952,8 +2248,13 @@ function useCofheTokens(chainId) {
|
|
|
1952
2248
|
map.set(key, token);
|
|
1953
2249
|
});
|
|
1954
2250
|
});
|
|
2251
|
+
customTokens.forEach((token) => {
|
|
2252
|
+
const key = `${token.chainId}-${token.address.toLowerCase()}`;
|
|
2253
|
+
if (map.has(key)) return;
|
|
2254
|
+
map.set(key, token);
|
|
2255
|
+
});
|
|
1955
2256
|
return Array.from(map.values());
|
|
1956
|
-
}, [tokenLists]);
|
|
2257
|
+
}, [customTokens, tokenLists]);
|
|
1957
2258
|
return tokens;
|
|
1958
2259
|
}
|
|
1959
2260
|
function useCofheToken({ chainId: _chainId, address }, metdataQueryOptions) {
|
|
@@ -1964,22 +2265,23 @@ function useCofheToken({ chainId: _chainId, address }, metdataQueryOptions) {
|
|
|
1964
2265
|
if (!address || !chainId) return;
|
|
1965
2266
|
return tokens.find((t) => t.chainId === chainId && t.address.toLowerCase() === address.toLowerCase());
|
|
1966
2267
|
}, [address, chainId, tokens]);
|
|
1967
|
-
|
|
2268
|
+
const resolvedToken = useResolvedCofheToken(
|
|
2269
|
+
{
|
|
2270
|
+
chainId,
|
|
2271
|
+
address
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
...metdataQueryOptions,
|
|
2275
|
+
enabled: (metdataQueryOptions?.enabled ?? true) && !!address && !!chainId && !tokenFromList
|
|
2276
|
+
}
|
|
2277
|
+
);
|
|
2278
|
+
return tokenFromList ?? resolvedToken.data;
|
|
1968
2279
|
}
|
|
1969
2280
|
|
|
1970
2281
|
// src/hooks/useCofheTokenPublicBalance.ts
|
|
1971
2282
|
var import_react_query4 = require("@tanstack/react-query");
|
|
1972
|
-
var
|
|
1973
|
-
|
|
1974
|
-
// src/constants/erc20ABIs.ts
|
|
1975
|
-
var import_viem5 = require("viem");
|
|
1976
|
-
var ERC20_BALANCE_OF_ABI = (0, import_viem5.parseAbi)(["function balanceOf(address owner) view returns (uint256)"]);
|
|
1977
|
-
var ERC20_DECIMALS_ABI = (0, import_viem5.parseAbi)(["function decimals() view returns (uint8)"]);
|
|
1978
|
-
var ERC20_SYMBOL_ABI = (0, import_viem5.parseAbi)(["function symbol() view returns (string)"]);
|
|
1979
|
-
var ERC20_NAME_ABI = (0, import_viem5.parseAbi)(["function name() view returns (string)"]);
|
|
1980
|
-
|
|
1981
|
-
// src/hooks/useCofheTokenPublicBalance.ts
|
|
1982
|
-
var import_ts_essentials2 = __toESM(require_dist(), 1);
|
|
2283
|
+
var import_viem7 = require("viem");
|
|
2284
|
+
var import_ts_essentials2 = __toESM(require_dist());
|
|
1983
2285
|
|
|
1984
2286
|
// src/utils/format.ts
|
|
1985
2287
|
var import_bignumber = __toESM(require("bignumber.js"));
|
|
@@ -2022,7 +2324,8 @@ function constructPublicTokenBalanceQueryKeyForInvalidation({
|
|
|
2022
2324
|
function getPublicTokenBalanceSource(token) {
|
|
2023
2325
|
const confidentialityType = token?.extensions.fhenix.confidentialityType;
|
|
2024
2326
|
const underlyingErc20 = token?.extensions.fhenix.erc20Pair;
|
|
2025
|
-
const
|
|
2327
|
+
const publicBalanceSourceType = getPublicBalanceSourceType(confidentialityType);
|
|
2328
|
+
const tokenToFetchBalanceFrom = publicBalanceSourceType === "erc20Pair" ? underlyingErc20 : publicBalanceSourceType === "token" ? token : void 0;
|
|
2026
2329
|
if (!tokenToFetchBalanceFrom) return void 0;
|
|
2027
2330
|
return {
|
|
2028
2331
|
address: tokenToFetchBalanceFrom.address,
|
|
@@ -2103,18 +2406,18 @@ function useCofheTokenPublicBalance({ token, accountAddress, displayDecimals = 5
|
|
|
2103
2406
|
|
|
2104
2407
|
// src/hooks/useCofheTokenClaimable.ts
|
|
2105
2408
|
var import_react_query6 = require("@tanstack/react-query");
|
|
2106
|
-
var
|
|
2409
|
+
var import_viem9 = require("viem");
|
|
2107
2410
|
|
|
2108
2411
|
// src/utils/decryptionAwareReadContract.ts
|
|
2109
2412
|
var import_react_query5 = require("@tanstack/react-query");
|
|
2110
|
-
var
|
|
2413
|
+
var import_viem8 = require("viem");
|
|
2111
2414
|
|
|
2112
2415
|
// src/stores/decryptionWatchingStore.ts
|
|
2113
|
-
var
|
|
2114
|
-
var
|
|
2115
|
-
var bigintStorage2 = (0,
|
|
2116
|
-
var useDecryptionWatchersStore = (0,
|
|
2117
|
-
(0,
|
|
2416
|
+
var import_zustand3 = require("zustand");
|
|
2417
|
+
var import_middleware3 = require("zustand/middleware");
|
|
2418
|
+
var bigintStorage2 = (0, import_middleware3.createJSONStorage)(() => localStorage, bigintJSONStorageOptions);
|
|
2419
|
+
var useDecryptionWatchersStore = (0, import_zustand3.create)()(
|
|
2420
|
+
(0, import_middleware3.persist)(
|
|
2118
2421
|
(set, get) => ({
|
|
2119
2422
|
byKey: {},
|
|
2120
2423
|
upsert: (input) => {
|
|
@@ -2280,7 +2583,7 @@ var DEFAULT_UNSHIELD_CLAIM_SUMMARY = {
|
|
|
2280
2583
|
hasPending: false
|
|
2281
2584
|
};
|
|
2282
2585
|
function isTokenConfidentialityTypeClaimable(type) {
|
|
2283
|
-
return type
|
|
2586
|
+
return isTokenOperationSupported(type, "claimable");
|
|
2284
2587
|
}
|
|
2285
2588
|
async function fetchUnshieldClaimsSummary({
|
|
2286
2589
|
publicClient,
|
|
@@ -2290,58 +2593,36 @@ async function fetchUnshieldClaimsSummary({
|
|
|
2290
2593
|
queryKey,
|
|
2291
2594
|
signal
|
|
2292
2595
|
}) {
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
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]
|
|
2596
|
+
const contractConfig = getClaimableContractConfig(confidentialityType);
|
|
2597
|
+
const result = await decryptionAwareReadContract({
|
|
2598
|
+
publicClient,
|
|
2599
|
+
queryKey,
|
|
2600
|
+
signal,
|
|
2601
|
+
readContractParams: {
|
|
2602
|
+
address: token.address,
|
|
2603
|
+
abi: contractConfig.abi,
|
|
2604
|
+
functionName: contractConfig.functionName,
|
|
2605
|
+
args: [accountAddress]
|
|
2606
|
+
}
|
|
2607
|
+
});
|
|
2608
|
+
const claims = result.filter((c) => !c.claimed);
|
|
2609
|
+
const { claimableAmount, pendingAmount } = claims.reduce(
|
|
2610
|
+
(acc, claim) => {
|
|
2611
|
+
if (claim.decrypted) {
|
|
2612
|
+
acc.claimableAmount += claim.decryptedAmount;
|
|
2613
|
+
} else {
|
|
2614
|
+
acc.pendingAmount += claim.requestedAmount;
|
|
2323
2615
|
}
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
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;
|
|
2616
|
+
return acc;
|
|
2617
|
+
},
|
|
2618
|
+
{ claimableAmount: 0n, pendingAmount: 0n }
|
|
2619
|
+
);
|
|
2620
|
+
return {
|
|
2621
|
+
claimableAmount,
|
|
2622
|
+
pendingAmount,
|
|
2623
|
+
hasClaimable: claimableAmount > 0n,
|
|
2624
|
+
hasPending: pendingAmount > 0n
|
|
2625
|
+
};
|
|
2345
2626
|
}
|
|
2346
2627
|
function useCofheTokenClaimable({ accountAddress: account, token }, queryOptions) {
|
|
2347
2628
|
const publicClient = useCofhePublicClient();
|
|
@@ -2385,7 +2666,7 @@ function useCofheTokenClaimable({ accountAddress: account, token }, queryOptions
|
|
|
2385
2666
|
|
|
2386
2667
|
// src/hooks/useTokenAllowance.ts
|
|
2387
2668
|
var import_react_query7 = require("@tanstack/react-query");
|
|
2388
|
-
var
|
|
2669
|
+
var import_viem10 = require("viem");
|
|
2389
2670
|
var import_ts_essentials4 = __toESM(require_dist(), 1);
|
|
2390
2671
|
function constructTokenAllowanceQueryKey({
|
|
2391
2672
|
chainId,
|
|
@@ -2432,12 +2713,15 @@ function createTokenAllowanceQueryOptions(params) {
|
|
|
2432
2713
|
(0, import_ts_essentials4.assert)(tokenAddress, "Token address is required to fetch token allowance");
|
|
2433
2714
|
(0, import_ts_essentials4.assert)(ownerAddress, "Owner address is required to fetch token allowance");
|
|
2434
2715
|
(0, import_ts_essentials4.assert)(spenderAddress, "Spender address is required to fetch token allowance");
|
|
2435
|
-
|
|
2716
|
+
const allowanceContract = getShieldAllowanceContractConfig();
|
|
2717
|
+
const allowance = await publicClient.readContract({
|
|
2436
2718
|
address: tokenAddress,
|
|
2437
|
-
abi:
|
|
2438
|
-
functionName:
|
|
2719
|
+
abi: allowanceContract.abi,
|
|
2720
|
+
functionName: allowanceContract.functionName,
|
|
2439
2721
|
args: [ownerAddress, spenderAddress]
|
|
2440
2722
|
});
|
|
2723
|
+
(0, import_ts_essentials4.assert)(typeof allowance === "bigint", "Token allowance must resolve to bigint");
|
|
2724
|
+
return allowance;
|
|
2441
2725
|
},
|
|
2442
2726
|
enabled,
|
|
2443
2727
|
refetchOnMount: false,
|
|
@@ -2530,8 +2814,8 @@ function usePendingTransactions() {
|
|
|
2530
2814
|
}
|
|
2531
2815
|
|
|
2532
2816
|
// src/stores/portalModalStore.tsx
|
|
2533
|
-
var
|
|
2534
|
-
var usePortalModals = (0,
|
|
2817
|
+
var import_zustand4 = require("zustand");
|
|
2818
|
+
var usePortalModals = (0, import_zustand4.create)()((set, get) => ({
|
|
2535
2819
|
modalStack: [],
|
|
2536
2820
|
openModal: (...args) => {
|
|
2537
2821
|
const [modal, props] = args;
|
|
@@ -2549,11 +2833,11 @@ var usePortalModals = (0, import_zustand3.create)()((set, get) => ({
|
|
|
2549
2833
|
|
|
2550
2834
|
// src/stores/portalUIStore.tsx
|
|
2551
2835
|
var import_react8 = require("react");
|
|
2552
|
-
var
|
|
2836
|
+
var import_zustand6 = require("zustand");
|
|
2553
2837
|
|
|
2554
2838
|
// src/stores/portalStatuses.tsx
|
|
2555
|
-
var
|
|
2556
|
-
var usePortalStatuses = (0,
|
|
2839
|
+
var import_zustand5 = require("zustand");
|
|
2840
|
+
var usePortalStatuses = (0, import_zustand5.create)()((set, get) => ({
|
|
2557
2841
|
statuses: [],
|
|
2558
2842
|
addStatus: (status) => {
|
|
2559
2843
|
if (get().hasStatus(status.id)) return;
|
|
@@ -2571,7 +2855,7 @@ var usePortalStatuses = (0, import_zustand4.create)()((set, get) => ({
|
|
|
2571
2855
|
|
|
2572
2856
|
// src/stores/portalUIStore.tsx
|
|
2573
2857
|
var ANIM_DURATION = 300;
|
|
2574
|
-
var usePortalUI = (0,
|
|
2858
|
+
var usePortalUI = (0, import_zustand6.create)()((set, get) => ({
|
|
2575
2859
|
portalOpen: false,
|
|
2576
2860
|
statusPanelOpen: false,
|
|
2577
2861
|
contentPanelOpen: false,
|
|
@@ -2642,8 +2926,8 @@ var usePortalUIMaxContentHeight = () => {
|
|
|
2642
2926
|
};
|
|
2643
2927
|
|
|
2644
2928
|
// src/stores/portalNavigationStore.tsx
|
|
2645
|
-
var
|
|
2646
|
-
var usePortalNavigation = (0,
|
|
2929
|
+
var import_zustand7 = require("zustand");
|
|
2930
|
+
var usePortalNavigation = (0, import_zustand7.create)()((set, get) => {
|
|
2647
2931
|
function clearNavigationHistory() {
|
|
2648
2932
|
set({ pageHistory: [{ page: "main" /* Main */ }], overridingPage: null });
|
|
2649
2933
|
}
|
|
@@ -2761,7 +3045,7 @@ var CopyButton = ({ text, size = 14, className }) => {
|
|
|
2761
3045
|
setCopied(true);
|
|
2762
3046
|
setTimeout(() => setCopied(false), 800);
|
|
2763
3047
|
} catch (err) {
|
|
2764
|
-
|
|
3048
|
+
cofheLogger.error("Failed to copy address:", err);
|
|
2765
3049
|
}
|
|
2766
3050
|
};
|
|
2767
3051
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -2871,9 +3155,9 @@ var ToastPrimitive = (props) => {
|
|
|
2871
3155
|
};
|
|
2872
3156
|
|
|
2873
3157
|
// src/stores/portalToasts.tsx
|
|
2874
|
-
var
|
|
3158
|
+
var import_zustand8 = require("zustand");
|
|
2875
3159
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2876
|
-
var usePortalToasts = (0,
|
|
3160
|
+
var usePortalToasts = (0, import_zustand8.create)()((set, get) => ({
|
|
2877
3161
|
toasts: [],
|
|
2878
3162
|
addToast: (toast, duration = 5e3) => {
|
|
2879
3163
|
const content = isReactNode(toast) ? toast : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ToastPrimitive, { ...toast });
|
|
@@ -2913,7 +3197,7 @@ var usePortalToasts = (0, import_zustand7.create)()((set, get) => ({
|
|
|
2913
3197
|
}));
|
|
2914
3198
|
|
|
2915
3199
|
// src/hooks/useTransactionGlobalLifecycle.ts
|
|
2916
|
-
var
|
|
3200
|
+
var import_viem11 = require("viem");
|
|
2917
3201
|
var TOAST_DELAY_MS = 1e4;
|
|
2918
3202
|
function useTransactionGlobalToastsLifecycle() {
|
|
2919
3203
|
const { addToast } = usePortalToasts();
|
|
@@ -2936,15 +3220,15 @@ function useTransactionGlobalToastsLifecycle() {
|
|
|
2936
3220
|
},
|
|
2937
3221
|
onTransactionSubmitError: (error, transactionType) => {
|
|
2938
3222
|
let humanReadableError;
|
|
2939
|
-
if (error instanceof
|
|
2940
|
-
if (error.cause instanceof
|
|
3223
|
+
if (error instanceof import_viem11.ContractFunctionExecutionError) {
|
|
3224
|
+
if (error.cause instanceof import_viem11.ContractFunctionRevertedError) {
|
|
2941
3225
|
const reasonOfRevert = error.cause.raw;
|
|
2942
3226
|
if (typeof reasonOfRevert === "string") {
|
|
2943
3227
|
humanReadableError = cofheHumanizeRevertReason(reasonOfRevert);
|
|
2944
3228
|
}
|
|
2945
3229
|
}
|
|
2946
3230
|
}
|
|
2947
|
-
|
|
3231
|
+
cofheLogger.error("____ Transaction submission failed for type:", transactionType, "with error:", error);
|
|
2948
3232
|
addToast(
|
|
2949
3233
|
{
|
|
2950
3234
|
variant: "error",
|
|
@@ -2989,7 +3273,7 @@ function useTransactionGlobalToastsLifecycle() {
|
|
|
2989
3273
|
},
|
|
2990
3274
|
// 2.b. tx receipt fetch failed
|
|
2991
3275
|
onWatchReceiptFailure: (error, transaction) => {
|
|
2992
|
-
|
|
3276
|
+
cofheLogger.error("____ Transaction receipt fetch failed for tx:", transaction, "with error:", error);
|
|
2993
3277
|
addToast(
|
|
2994
3278
|
{
|
|
2995
3279
|
variant: "error",
|
|
@@ -3194,7 +3478,7 @@ function useHandleInvalidations() {
|
|
|
3194
3478
|
);
|
|
3195
3479
|
}
|
|
3196
3480
|
} else {
|
|
3197
|
-
|
|
3481
|
+
cofheLogger.warn("No invalidation logic for transaction action type:", tx.actionType);
|
|
3198
3482
|
}
|
|
3199
3483
|
};
|
|
3200
3484
|
return handleInvalidations;
|
|
@@ -3562,13 +3846,13 @@ var useCofheClient = () => {
|
|
|
3562
3846
|
|
|
3563
3847
|
// src/hooks/useCofheTokenDecryptedBalance.ts
|
|
3564
3848
|
var import_react_query10 = require("@tanstack/react-query");
|
|
3565
|
-
var
|
|
3849
|
+
var import_viem13 = require("viem");
|
|
3566
3850
|
var import_sdk6 = require("@cofhe/sdk");
|
|
3567
3851
|
var import_ts_essentials10 = __toESM(require_dist(), 1);
|
|
3568
3852
|
|
|
3569
3853
|
// src/hooks/useCofheReadContractAndDecrypt.ts
|
|
3570
3854
|
var import_react_query9 = require("@tanstack/react-query");
|
|
3571
|
-
var
|
|
3855
|
+
var import_viem12 = require("viem");
|
|
3572
3856
|
var import_sdk5 = require("@cofhe/sdk");
|
|
3573
3857
|
|
|
3574
3858
|
// src/hooks/useCofheDecrypt.ts
|
|
@@ -3681,7 +3965,7 @@ function useCofheTokenDecryptedBalance({ token, accountAddress, displayDecimals
|
|
|
3681
3965
|
}
|
|
3682
3966
|
|
|
3683
3967
|
// src/hooks/useCofheTokenTransfer.ts
|
|
3684
|
-
var
|
|
3968
|
+
var import_viem14 = require("viem");
|
|
3685
3969
|
var import_sdk9 = require("@cofhe/sdk");
|
|
3686
3970
|
|
|
3687
3971
|
// src/hooks/useCofheEncryptAndWriteContract.ts
|
|
@@ -3940,7 +4224,8 @@ function useCofheTokenTransfer(writeMutationOptions) {
|
|
|
3940
4224
|
encryptAmountAndSendToken: ({ input, encryptionOptions }) => {
|
|
3941
4225
|
const { token, to, amount, userAddress } = input;
|
|
3942
4226
|
const { input: _ignoredInput, ...encryptionOpts } = encryptionOptions ?? {};
|
|
3943
|
-
|
|
4227
|
+
assertTokenOperationSupported(token.extensions.fhenix.confidentialityType, "transfer");
|
|
4228
|
+
const contractConfig = getTransferContractConfig(token.extensions.fhenix.confidentialityType);
|
|
3944
4229
|
return encryptAndWrite({
|
|
3945
4230
|
params: {
|
|
3946
4231
|
address: token.address,
|
|
@@ -3990,7 +4275,7 @@ function useCofheTokenApprove(writeMutationOptions) {
|
|
|
3990
4275
|
|
|
3991
4276
|
// src/hooks/useCofheTokenShield.ts
|
|
3992
4277
|
var import_react_query11 = require("@tanstack/react-query");
|
|
3993
|
-
var
|
|
4278
|
+
var import_viem15 = require("viem");
|
|
3994
4279
|
var import_ts_essentials13 = __toESM(require_dist(), 1);
|
|
3995
4280
|
function getCofheTokenShieldCallArgs(params) {
|
|
3996
4281
|
const { token, amount, account } = params;
|
|
@@ -3999,30 +4284,16 @@ function getCofheTokenShieldCallArgs(params) {
|
|
|
3999
4284
|
if (!confidentialityType) {
|
|
4000
4285
|
throw new Error("confidentialityType is required in token extensions");
|
|
4001
4286
|
}
|
|
4002
|
-
|
|
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
|
-
}
|
|
4287
|
+
assertTokenOperationSupported(confidentialityType, "shield");
|
|
4018
4288
|
const erc20PairAddress = token.extensions.fhenix.erc20Pair?.address;
|
|
4019
4289
|
const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS_LOWERCASE;
|
|
4020
4290
|
if (isEth) {
|
|
4291
|
+
const contractConfig = getShieldEthContractConfig(confidentialityType);
|
|
4021
4292
|
return {
|
|
4022
4293
|
main: {
|
|
4023
4294
|
address: tokenAddress,
|
|
4024
|
-
abi:
|
|
4025
|
-
functionName:
|
|
4295
|
+
abi: contractConfig.abi,
|
|
4296
|
+
functionName: contractConfig.functionName,
|
|
4026
4297
|
args: [account],
|
|
4027
4298
|
value: amount,
|
|
4028
4299
|
account,
|
|
@@ -4036,16 +4307,14 @@ function getCofheTokenShieldCallArgs(params) {
|
|
|
4036
4307
|
return {
|
|
4037
4308
|
approval: {
|
|
4038
4309
|
address: erc20PairAddress,
|
|
4039
|
-
|
|
4040
|
-
functionName: "approve",
|
|
4310
|
+
...getShieldApproveContractConfig(),
|
|
4041
4311
|
args: [tokenAddress, amount],
|
|
4042
4312
|
account,
|
|
4043
4313
|
chain: void 0
|
|
4044
4314
|
},
|
|
4045
4315
|
main: {
|
|
4316
|
+
...getShieldContractConfig(confidentialityType),
|
|
4046
4317
|
address: tokenAddress,
|
|
4047
|
-
abi: WRAPPED_ENCRYPT_ABI,
|
|
4048
|
-
functionName: "encrypt",
|
|
4049
4318
|
args: [account, amount],
|
|
4050
4319
|
account,
|
|
4051
4320
|
chain: void 0
|
|
@@ -4075,47 +4344,35 @@ function useCofheTokenShield(options) {
|
|
|
4075
4344
|
if (!walletClient.account) {
|
|
4076
4345
|
throw new Error("Wallet account is required for token shield");
|
|
4077
4346
|
}
|
|
4078
|
-
|
|
4079
|
-
throw new Error(`Shield not supported for confidentialityType: ${confidentialityType}`);
|
|
4080
|
-
}
|
|
4347
|
+
assertTokenOperationSupported(confidentialityType, "shield");
|
|
4081
4348
|
let hash;
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
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;
|
|
4349
|
+
const erc20PairAddress = input.token.extensions.fhenix.erc20Pair?.address;
|
|
4350
|
+
const isEth = erc20PairAddress?.toLowerCase() === ETH_ADDRESS_LOWERCASE;
|
|
4351
|
+
if (isEth) {
|
|
4352
|
+
const contractConfig = getShieldEthContractConfig(confidentialityType);
|
|
4111
4353
|
const { request } = await publicClient.simulateContract({
|
|
4112
4354
|
address: tokenAddress,
|
|
4113
4355
|
abi: contractConfig.abi,
|
|
4114
4356
|
functionName: contractConfig.functionName,
|
|
4115
|
-
args: [
|
|
4357
|
+
args: [walletClient.account.address],
|
|
4358
|
+
value: input.amount,
|
|
4116
4359
|
account: walletClient.account
|
|
4117
4360
|
});
|
|
4118
4361
|
hash = await walletClient.writeContract({ ...request, chain: void 0 });
|
|
4362
|
+
} else {
|
|
4363
|
+
if (!erc20PairAddress) {
|
|
4364
|
+
throw new Error("erc20Pair address is required for wrapped ERC20 tokens");
|
|
4365
|
+
}
|
|
4366
|
+
input.onStatusChange?.("Please confirm shield in wallet...");
|
|
4367
|
+
const contractConfig = getShieldContractConfig(confidentialityType);
|
|
4368
|
+
const { request: encryptRequest } = await publicClient.simulateContract({
|
|
4369
|
+
address: tokenAddress,
|
|
4370
|
+
abi: contractConfig.abi,
|
|
4371
|
+
functionName: contractConfig.functionName,
|
|
4372
|
+
args: [walletClient.account.address, input.amount],
|
|
4373
|
+
account: walletClient.account
|
|
4374
|
+
});
|
|
4375
|
+
hash = await walletClient.writeContract({ ...encryptRequest, chain: void 0 });
|
|
4119
4376
|
}
|
|
4120
4377
|
return hash;
|
|
4121
4378
|
},
|
|
@@ -4144,7 +4401,7 @@ function useCofheTokenShield(options) {
|
|
|
4144
4401
|
|
|
4145
4402
|
// src/hooks/useCofheTokenUnshield.ts
|
|
4146
4403
|
var import_react_query12 = require("@tanstack/react-query");
|
|
4147
|
-
var
|
|
4404
|
+
var import_viem16 = require("viem");
|
|
4148
4405
|
var import_ts_essentials15 = __toESM(require_dist(), 1);
|
|
4149
4406
|
|
|
4150
4407
|
// src/hooks/useStoredTransaction.ts
|
|
@@ -4245,29 +4502,13 @@ function getCofheTokenUnshieldCallArgs(params) {
|
|
|
4245
4502
|
if (!confidentialityType) {
|
|
4246
4503
|
throw new Error("confidentialityType is required in token extensions");
|
|
4247
4504
|
}
|
|
4248
|
-
|
|
4249
|
-
|
|
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);
|
|
4505
|
+
assertTokenOperationSupported(confidentialityType, "unshield");
|
|
4506
|
+
const contractConfig = getUnshieldContractConfig(confidentialityType);
|
|
4266
4507
|
return {
|
|
4267
4508
|
address: tokenAddress,
|
|
4268
4509
|
abi: contractConfig.abi,
|
|
4269
4510
|
functionName: contractConfig.functionName,
|
|
4270
|
-
args: [
|
|
4511
|
+
args: [account, rawAmount],
|
|
4271
4512
|
account,
|
|
4272
4513
|
chain: void 0
|
|
4273
4514
|
};
|
|
@@ -4295,35 +4536,18 @@ function useCofheTokenUnshieldMutation(options) {
|
|
|
4295
4536
|
if (!walletClient.account) {
|
|
4296
4537
|
throw new Error("Wallet account is required for token unshield");
|
|
4297
4538
|
}
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
}
|
|
4301
|
-
const contractConfig = UNSHIELD_ABIS[confidentialityType];
|
|
4302
|
-
if (!contractConfig) {
|
|
4303
|
-
throw new Error(`Unsupported confidentialityType for unshield: ${confidentialityType}`);
|
|
4304
|
-
}
|
|
4539
|
+
assertTokenOperationSupported(confidentialityType, "unshield");
|
|
4540
|
+
const contractConfig = getUnshieldContractConfig(confidentialityType);
|
|
4305
4541
|
let hash;
|
|
4306
4542
|
input.onStatusChange?.("Please confirm in wallet...");
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
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
|
-
}
|
|
4543
|
+
const { request } = await publicClient.simulateContract({
|
|
4544
|
+
address: tokenAddress,
|
|
4545
|
+
abi: contractConfig.abi,
|
|
4546
|
+
functionName: contractConfig.functionName,
|
|
4547
|
+
args: [walletClient.account.address, input.amount],
|
|
4548
|
+
account: walletClient.account
|
|
4549
|
+
});
|
|
4550
|
+
hash = await walletClient.writeContract({ ...request, chain: void 0 });
|
|
4327
4551
|
return hash;
|
|
4328
4552
|
},
|
|
4329
4553
|
onError: (error, variables, onMutateResult, context) => {
|
|
@@ -4371,7 +4595,7 @@ function useCofheTokenUnshield(input) {
|
|
|
4371
4595
|
|
|
4372
4596
|
// src/hooks/useCofheTokenClaimUnshielded.ts
|
|
4373
4597
|
var import_react_query13 = require("@tanstack/react-query");
|
|
4374
|
-
var
|
|
4598
|
+
var import_viem17 = require("viem");
|
|
4375
4599
|
var import_ts_essentials16 = __toESM(require_dist(), 1);
|
|
4376
4600
|
function getCofheTokenClaimUnshieldedCallArgs(params) {
|
|
4377
4601
|
const { token, account } = params;
|
|
@@ -4380,13 +4604,8 @@ function getCofheTokenClaimUnshieldedCallArgs(params) {
|
|
|
4380
4604
|
if (!confidentialityType) {
|
|
4381
4605
|
throw new Error("confidentialityType is required in token extensions");
|
|
4382
4606
|
}
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
}
|
|
4386
|
-
const contractConfig = CLAIM_ABIS[confidentialityType];
|
|
4387
|
-
if (!contractConfig) {
|
|
4388
|
-
throw new Error(`Unsupported confidentialityType for claim: ${confidentialityType}`);
|
|
4389
|
-
}
|
|
4607
|
+
assertTokenOperationSupported(confidentialityType, "claim");
|
|
4608
|
+
const contractConfig = getClaimContractConfig(confidentialityType);
|
|
4390
4609
|
return {
|
|
4391
4610
|
address: tokenAddress,
|
|
4392
4611
|
abi: contractConfig.abi,
|
|
@@ -4419,13 +4638,8 @@ function useCofheTokenClaimUnshielded(options) {
|
|
|
4419
4638
|
if (!walletClient.account) {
|
|
4420
4639
|
throw new Error("Wallet account is required for claim");
|
|
4421
4640
|
}
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
}
|
|
4425
|
-
const contractConfig = CLAIM_ABIS[confidentialityType];
|
|
4426
|
-
if (!contractConfig) {
|
|
4427
|
-
throw new Error(`Unsupported confidentialityType for claim: ${confidentialityType}`);
|
|
4428
|
-
}
|
|
4641
|
+
assertTokenOperationSupported(confidentialityType, "claim");
|
|
4642
|
+
const contractConfig = getClaimContractConfig(confidentialityType);
|
|
4429
4643
|
const { request } = await publicClient.simulateContract({
|
|
4430
4644
|
address: tokenAddress,
|
|
4431
4645
|
abi: contractConfig.abi,
|
|
@@ -4461,7 +4675,7 @@ function useCofheTokenClaimUnshielded(options) {
|
|
|
4461
4675
|
// src/hooks/useCofheTokensClaimable.ts
|
|
4462
4676
|
var import_react_query14 = require("@tanstack/react-query");
|
|
4463
4677
|
var import_react21 = require("react");
|
|
4464
|
-
var
|
|
4678
|
+
var import_viem19 = require("viem");
|
|
4465
4679
|
var import_ts_essentials18 = __toESM(require_dist(), 1);
|
|
4466
4680
|
|
|
4467
4681
|
// src/hooks/useNormalizedList.ts
|
|
@@ -4492,14 +4706,14 @@ function useNormalizedList(items, options) {
|
|
|
4492
4706
|
|
|
4493
4707
|
// src/hooks/useIsWaitingForDecryptionByAddress.ts
|
|
4494
4708
|
var import_react20 = require("react");
|
|
4495
|
-
var
|
|
4709
|
+
var import_viem18 = require("viem");
|
|
4496
4710
|
var import_ts_essentials17 = __toESM(require_dist(), 1);
|
|
4497
4711
|
function useIsWaitingForDecryptionByAddress(entries) {
|
|
4498
4712
|
const awaitingDecryptionKeySet = useAwaitingDecryptionQueryKeySet();
|
|
4499
4713
|
return (0, import_react20.useMemo)(() => {
|
|
4500
4714
|
const map = {};
|
|
4501
4715
|
for (const entry of entries) {
|
|
4502
|
-
(0, import_ts_essentials17.assert)((0,
|
|
4716
|
+
(0, import_ts_essentials17.assert)((0, import_viem18.isAddress)(entry.address), "address is valid");
|
|
4503
4717
|
map[entry.address] = awaitingDecryptionKeySet.has(JSON.stringify(entry.queryKey));
|
|
4504
4718
|
}
|
|
4505
4719
|
return map;
|
|
@@ -5004,17 +5218,17 @@ function usePermitDuration(options) {
|
|
|
5004
5218
|
var import_react25 = require("react");
|
|
5005
5219
|
|
|
5006
5220
|
// src/stores/portalPersisted.tsx
|
|
5007
|
-
var
|
|
5008
|
-
var
|
|
5009
|
-
var usePortalPersisted = (0,
|
|
5010
|
-
(0,
|
|
5221
|
+
var import_zustand9 = require("zustand");
|
|
5222
|
+
var import_middleware4 = require("zustand/middleware");
|
|
5223
|
+
var usePortalPersisted = (0, import_zustand9.create)()(
|
|
5224
|
+
(0, import_middleware4.persist)(
|
|
5011
5225
|
(set, get) => ({
|
|
5012
5226
|
hasCreatedFirstPermit: false,
|
|
5013
5227
|
setHasCreatedFirstPermit: (hasCreated) => set({ hasCreatedFirstPermit: hasCreated })
|
|
5014
5228
|
}),
|
|
5015
5229
|
{
|
|
5016
5230
|
name: "cofhesdk-react-persisted",
|
|
5017
|
-
storage: (0,
|
|
5231
|
+
storage: (0, import_middleware4.createJSONStorage)(() => localStorage)
|
|
5018
5232
|
}
|
|
5019
5233
|
)
|
|
5020
5234
|
);
|
|
@@ -5255,7 +5469,7 @@ function useReceivePermit({ onSuccess, onError } = {}) {
|
|
|
5255
5469
|
setImportedPermit(permit);
|
|
5256
5470
|
setErrorMsg(null);
|
|
5257
5471
|
} catch (e) {
|
|
5258
|
-
|
|
5472
|
+
cofheLogger.error("Error parsing pasted permit data", e);
|
|
5259
5473
|
setImportedPermit(null);
|
|
5260
5474
|
setErrorMsg(`Invalid permit data. Expected JSON.`);
|
|
5261
5475
|
}
|
|
@@ -5275,7 +5489,7 @@ function useReceivePermit({ onSuccess, onError } = {}) {
|
|
|
5275
5489
|
|
|
5276
5490
|
// src/hooks/permits/usePermitDetailsAndActions.ts
|
|
5277
5491
|
var import_react30 = require("react");
|
|
5278
|
-
var
|
|
5492
|
+
var import_viem20 = require("viem");
|
|
5279
5493
|
var import_permits4 = require("@cofhe/sdk/permits");
|
|
5280
5494
|
|
|
5281
5495
|
// src/hooks/useCopyFeedback.ts
|
|
@@ -5373,7 +5587,7 @@ var usePermitDetailsAndActions = (permitHash) => {
|
|
|
5373
5587
|
const permitLabel = (0, import_react30.useMemo)(() => {
|
|
5374
5588
|
if (!permit) return void 0;
|
|
5375
5589
|
if (permit.name?.trim()) return permit.name;
|
|
5376
|
-
const fallbackAddress = permit.recipient && permit.recipient !==
|
|
5590
|
+
const fallbackAddress = permit.recipient && permit.recipient !== import_viem20.zeroAddress ? permit.recipient : permit.issuer || import_viem20.zeroAddress;
|
|
5377
5591
|
return truncateAddress(fallbackAddress, 4, 4) ?? fallbackAddress;
|
|
5378
5592
|
}, [permit]);
|
|
5379
5593
|
const expirationInfo = (0, import_react30.useMemo)(() => formatExpirationLabel(permit?.expiration), [permit?.expiration]);
|
|
@@ -6208,7 +6422,7 @@ var StatusBarContent = () => {
|
|
|
6208
6422
|
};
|
|
6209
6423
|
|
|
6210
6424
|
// src/components/CofheFloatingButton/ContentSection.tsx
|
|
6211
|
-
var
|
|
6425
|
+
var import_react60 = require("react");
|
|
6212
6426
|
|
|
6213
6427
|
// src/components/CofheFloatingButton/pages/MainPage/WalletHeader.tsx
|
|
6214
6428
|
var import_md4 = require("react-icons/md");
|
|
@@ -6226,7 +6440,7 @@ var AddressButton = ({ address, className, icon, showCopyIcon = true }) => {
|
|
|
6226
6440
|
setCopied(true);
|
|
6227
6441
|
setTimeout(() => setCopied(false), 2e3);
|
|
6228
6442
|
} catch (err) {
|
|
6229
|
-
|
|
6443
|
+
cofheLogger.error("Failed to copy address:", err);
|
|
6230
6444
|
}
|
|
6231
6445
|
};
|
|
6232
6446
|
const truncatedAddress = truncateAddress(address) || "Not connected";
|
|
@@ -6841,7 +7055,7 @@ var PageContainer = ({ isModal, header, content, footer }) => {
|
|
|
6841
7055
|
};
|
|
6842
7056
|
|
|
6843
7057
|
// src/components/CofheFloatingButton/components/TransactionItem.tsx
|
|
6844
|
-
var
|
|
7058
|
+
var import_viem21 = require("viem");
|
|
6845
7059
|
var import_go = require("react-icons/go");
|
|
6846
7060
|
var import_tb2 = require("react-icons/tb");
|
|
6847
7061
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
@@ -6870,7 +7084,7 @@ var TransactionItem = ({ transaction }) => {
|
|
|
6870
7084
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
6871
7085
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-sm font-semibold cofhe-text-primary", children: actionToString(transaction.actionType) }),
|
|
6872
7086
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "text-sm font-semibold cofhe-text-primary", children: [
|
|
6873
|
-
(0,
|
|
7087
|
+
(0, import_viem21.formatUnits)(transaction.tokenAmount, transaction.token.decimals),
|
|
6874
7088
|
" ",
|
|
6875
7089
|
transaction.token.symbol
|
|
6876
7090
|
] })
|
|
@@ -7008,8 +7222,8 @@ var MainPage = () => {
|
|
|
7008
7222
|
};
|
|
7009
7223
|
|
|
7010
7224
|
// src/components/CofheFloatingButton/stores/settingsStore.ts
|
|
7011
|
-
var
|
|
7012
|
-
var
|
|
7225
|
+
var import_zustand10 = require("zustand");
|
|
7226
|
+
var import_middleware5 = require("zustand/middleware");
|
|
7013
7227
|
var ShieldPageVariant = /* @__PURE__ */ ((ShieldPageVariant2) => {
|
|
7014
7228
|
ShieldPageVariant2["Option1"] = "option1";
|
|
7015
7229
|
ShieldPageVariant2["Option2"] = "option2";
|
|
@@ -7019,8 +7233,8 @@ var SHIELD_PAGE_VARIANT_LABELS = {
|
|
|
7019
7233
|
["option1" /* Option1 */]: "Modern UI",
|
|
7020
7234
|
["option2" /* Option2 */]: "Classic UI"
|
|
7021
7235
|
};
|
|
7022
|
-
var useSettingsStore = (0,
|
|
7023
|
-
(0,
|
|
7236
|
+
var useSettingsStore = (0, import_zustand10.create)()(
|
|
7237
|
+
(0, import_middleware5.persist)(
|
|
7024
7238
|
(set) => ({
|
|
7025
7239
|
shieldPageVariant: "option1" /* Option1 */,
|
|
7026
7240
|
setShieldPageVariant: (variant) => set({ shieldPageVariant: variant })
|
|
@@ -7199,7 +7413,7 @@ var InfoModalButton = ({ onClick }) => {
|
|
|
7199
7413
|
|
|
7200
7414
|
// src/components/CofheFloatingButton/components/PermitCard.tsx
|
|
7201
7415
|
var import_fa63 = require("react-icons/fa6");
|
|
7202
|
-
var
|
|
7416
|
+
var import_viem22 = require("viem");
|
|
7203
7417
|
var import_permits7 = require("@cofhe/sdk/permits");
|
|
7204
7418
|
|
|
7205
7419
|
// src/components/StripedBackground.tsx
|
|
@@ -7319,14 +7533,14 @@ var BasePermitCard = ({
|
|
|
7319
7533
|
] })
|
|
7320
7534
|
] }),
|
|
7321
7535
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("br", {}),
|
|
7322
|
-
permit.recipient != null && permit.recipient !==
|
|
7536
|
+
permit.recipient != null && permit.recipient !== import_viem22.zeroAddress && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
7323
7537
|
"Recipient: ",
|
|
7324
7538
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("b", { children: truncateAddress(permit.recipient, 6, 6) }),
|
|
7325
7539
|
" ",
|
|
7326
7540
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CopyButton2, { hash: permit.recipient }),
|
|
7327
7541
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("br", {})
|
|
7328
7542
|
] }),
|
|
7329
|
-
permit.validatorContract != null && permit.validatorContract !==
|
|
7543
|
+
permit.validatorContract != null && permit.validatorContract !== import_viem22.zeroAddress && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
7330
7544
|
"Validator:",
|
|
7331
7545
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("br", {}),
|
|
7332
7546
|
" ",
|
|
@@ -7793,7 +8007,7 @@ var ImportPermitPage = () => {
|
|
|
7793
8007
|
title: "Failed to import permit",
|
|
7794
8008
|
description: error.message
|
|
7795
8009
|
});
|
|
7796
|
-
|
|
8010
|
+
cofheLogger.error("Error importing permit", error);
|
|
7797
8011
|
}
|
|
7798
8012
|
});
|
|
7799
8013
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
@@ -7974,7 +8188,7 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
|
|
|
7974
8188
|
|
|
7975
8189
|
// src/components/CofheFloatingButton/pages/TokenInfoTransactionHistory.tsx
|
|
7976
8190
|
var import_react51 = require("react");
|
|
7977
|
-
var
|
|
8191
|
+
var import_viem23 = require("viem");
|
|
7978
8192
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
7979
8193
|
var TokenInfoTransactionHistoryHeader = ({ token }) => {
|
|
7980
8194
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
@@ -7998,7 +8212,7 @@ var TokenInfoTransactionHistory = ({ token, priceUsd }) => {
|
|
|
7998
8212
|
});
|
|
7999
8213
|
const activity = (0, import_react51.useMemo)(() => {
|
|
8000
8214
|
return tokenTxs.slice().sort((a, b) => b.timestamp - a.timestamp).map((tx) => {
|
|
8001
|
-
const amountToken = parseFloat((0,
|
|
8215
|
+
const amountToken = parseFloat((0, import_viem23.formatUnits)(tx.tokenAmount, tx.token.decimals));
|
|
8002
8216
|
const amountUsd = typeof priceUsd === "number" && Number.isFinite(amountToken) ? amountToken * priceUsd : void 0;
|
|
8003
8217
|
return {
|
|
8004
8218
|
kind: actionToString(tx.actionType),
|
|
@@ -8103,7 +8317,7 @@ var TokenInfoPage = ({ token }) => {
|
|
|
8103
8317
|
|
|
8104
8318
|
// src/components/CofheFloatingButton/pages/SendPage.tsx
|
|
8105
8319
|
var import_react53 = require("react");
|
|
8106
|
-
var
|
|
8320
|
+
var import_viem24 = require("viem");
|
|
8107
8321
|
var import_ts_essentials22 = __toESM(require_dist(), 1);
|
|
8108
8322
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
8109
8323
|
var SendPage = ({ token: _token }) => {
|
|
@@ -8125,7 +8339,7 @@ var SendPage = ({ token: _token }) => {
|
|
|
8125
8339
|
onError: (error2) => {
|
|
8126
8340
|
const errorMessage = cofheHumanizeViemError(error2) ?? (error2 instanceof Error ? error2.message : "Failed to send tokens");
|
|
8127
8341
|
setError(errorMessage);
|
|
8128
|
-
|
|
8342
|
+
cofheLogger.error("Send tx submit error:", error2);
|
|
8129
8343
|
},
|
|
8130
8344
|
onMutate: () => {
|
|
8131
8345
|
setError(null);
|
|
@@ -8156,12 +8370,12 @@ var SendPage = ({ token: _token }) => {
|
|
|
8156
8370
|
const [recipientAddress, setRecipientAddress] = (0, import_react53.useState)("");
|
|
8157
8371
|
const [error, setError] = (0, import_react53.useState)(null);
|
|
8158
8372
|
const [success, setSuccess] = (0, import_react53.useState)(null);
|
|
8159
|
-
const isValidAddress2 = (0,
|
|
8373
|
+
const isValidAddress2 = (0, import_viem24.isAddress)(recipientAddress);
|
|
8160
8374
|
const isValidAmount = (amount.length > 0 && confidentialUnitBalance && confidentialUnitBalance.gte(amount)) ?? false;
|
|
8161
8375
|
const handleSend = async () => {
|
|
8162
|
-
(0, import_ts_essentials22.assert)((0,
|
|
8376
|
+
(0, import_ts_essentials22.assert)((0, import_viem24.isAddress)(recipientAddress), "Recipient address is not valid");
|
|
8163
8377
|
const amountWei = unitToWei(amount, token.decimals);
|
|
8164
|
-
(0, import_ts_essentials22.assert)(amountWei <=
|
|
8378
|
+
(0, import_ts_essentials22.assert)(amountWei <= import_viem24.maxUint128, "Amount exceeds maximum supported value (uint128 max)");
|
|
8165
8379
|
(0, import_ts_essentials22.assert)(account, "Sender account is required");
|
|
8166
8380
|
await encryptAmountAndSendToken({
|
|
8167
8381
|
input: {
|
|
@@ -8303,7 +8517,7 @@ var SendPage = ({ token: _token }) => {
|
|
|
8303
8517
|
var import_tb4 = require("react-icons/tb");
|
|
8304
8518
|
var import_lu2 = require("react-icons/lu");
|
|
8305
8519
|
var import_react55 = require("react");
|
|
8306
|
-
var
|
|
8520
|
+
var import_viem25 = require("viem");
|
|
8307
8521
|
var import_ts_essentials23 = __toESM(require_dist(), 1);
|
|
8308
8522
|
|
|
8309
8523
|
// src/hooks/useIsUnshieldingMining.ts
|
|
@@ -8342,7 +8556,7 @@ function humanizeSimulationError(error, fallbackMessage) {
|
|
|
8342
8556
|
if (!error) return null;
|
|
8343
8557
|
const cofheErrorMessage = cofheHumanizeViemError(error);
|
|
8344
8558
|
if (cofheErrorMessage) return cofheErrorMessage;
|
|
8345
|
-
if (error instanceof
|
|
8559
|
+
if (error instanceof import_viem25.ContractFunctionExecutionError) return error.shortMessage;
|
|
8346
8560
|
return fallbackMessage;
|
|
8347
8561
|
}
|
|
8348
8562
|
function TxHashWithActions({ hash, chainId }) {
|
|
@@ -8396,7 +8610,7 @@ function useClaimUnshieldedWithLifecycle() {
|
|
|
8396
8610
|
const errorMessage = cofheHumanizeViemError(error2) ?? (error2 instanceof Error ? error2.message : "Failed to claim unshielded tokens");
|
|
8397
8611
|
setError(errorMessage);
|
|
8398
8612
|
setStatus(null);
|
|
8399
|
-
|
|
8613
|
+
cofheLogger.error("Claim tx submit error:", error2);
|
|
8400
8614
|
}
|
|
8401
8615
|
});
|
|
8402
8616
|
const { isMining: isClaimingMining } = useOnceTransactionMined({
|
|
@@ -8455,7 +8669,7 @@ function useShieldWithLifecycle(token) {
|
|
|
8455
8669
|
const errorMessage = cofheHumanizeViemError(error2) ?? (error2 instanceof Error ? error2.message : "Failed to shield tokens");
|
|
8456
8670
|
setError(errorMessage);
|
|
8457
8671
|
setStatus(null);
|
|
8458
|
-
|
|
8672
|
+
cofheLogger.error("Shield tx submit error:", error2);
|
|
8459
8673
|
}
|
|
8460
8674
|
});
|
|
8461
8675
|
const { tokenApprove, isApprovingMining } = useApproveWithLifecycle({
|
|
@@ -8553,7 +8767,7 @@ function useShieldWithLifecycle(token) {
|
|
|
8553
8767
|
if (!relevantError) return null;
|
|
8554
8768
|
const cofheErrorMessage = cofheHumanizeViemError(relevantError);
|
|
8555
8769
|
if (cofheErrorMessage) return cofheErrorMessage;
|
|
8556
|
-
if (relevantError instanceof
|
|
8770
|
+
if (relevantError instanceof import_viem25.ContractFunctionExecutionError) return relevantError.shortMessage;
|
|
8557
8771
|
return shouldApprove ? "Failed to simulate approval transaction" : "Failed to simulate shield transaction";
|
|
8558
8772
|
}, [approvalSimulation.error, shieldSimulation.error, shouldApprove]);
|
|
8559
8773
|
const canShield = isValidShieldAmount && !!shieldCallArgs && isAllowanceKnown && hasSufficientAllowance && !shieldSimulation.isFetching && !shieldSimulation.error;
|
|
@@ -8604,7 +8818,7 @@ function useUnshieldWithLifecycle(token) {
|
|
|
8604
8818
|
const errorMessage = cofheHumanizeViemError(error2) ?? (error2 instanceof Error ? error2.message : "Failed to unshield tokens");
|
|
8605
8819
|
setError(errorMessage);
|
|
8606
8820
|
setStatus(null);
|
|
8607
|
-
|
|
8821
|
+
cofheLogger.error("Unshield tx submit error:", error2);
|
|
8608
8822
|
},
|
|
8609
8823
|
onceMined: (transaction) => {
|
|
8610
8824
|
if (transaction.status === "confirmed") {
|
|
@@ -8632,7 +8846,7 @@ function useUnshieldWithLifecycle(token) {
|
|
|
8632
8846
|
}
|
|
8633
8847
|
});
|
|
8634
8848
|
const handleUnshield = async () => {
|
|
8635
|
-
const amountWei = (0,
|
|
8849
|
+
const amountWei = (0, import_viem25.parseUnits)(unshieldAmount, token.decimals);
|
|
8636
8850
|
tokenUnshield.mutateAsync({
|
|
8637
8851
|
token,
|
|
8638
8852
|
amount: amountWei,
|
|
@@ -8646,7 +8860,7 @@ function useUnshieldWithLifecycle(token) {
|
|
|
8646
8860
|
const isValidUnshieldAmount = (unshieldAmount.length > 0 && confidentialBalanceUnit?.gte(unshieldAmount)) ?? false;
|
|
8647
8861
|
const unshieldCallArgs = (0, import_react55.useMemo)(() => {
|
|
8648
8862
|
if (!account || !isValidUnshieldAmount) return void 0;
|
|
8649
|
-
const amountWei = (0,
|
|
8863
|
+
const amountWei = (0, import_viem25.parseUnits)(unshieldAmount, token.decimals);
|
|
8650
8864
|
return getCofheTokenUnshieldCallArgs({ token, amount: amountWei, account });
|
|
8651
8865
|
}, [account, isValidUnshieldAmount, token, unshieldAmount]);
|
|
8652
8866
|
const unshieldSimulation = useCofheSimulateWriteContract(unshieldCallArgs, {
|
|
@@ -8674,7 +8888,6 @@ function useUnshieldWithLifecycle(token) {
|
|
|
8674
8888
|
primaryIcon: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_tb4.TbShieldMinus, { className: "w-3 h-3" })
|
|
8675
8889
|
};
|
|
8676
8890
|
}
|
|
8677
|
-
var shieldableTypes = /* @__PURE__ */ new Set(["dual", "wrapped"]);
|
|
8678
8891
|
var ShieldPageV2 = ({ token: _token, defaultMode }) => {
|
|
8679
8892
|
const [mode, setMode] = (0, import_react55.useState)(defaultMode ?? "shield");
|
|
8680
8893
|
const [overriddenToken, setOverriddenToken] = (0, import_react55.useState)(null);
|
|
@@ -8800,9 +9013,15 @@ var ShieldAndUnshieldPageView = ({
|
|
|
8800
9013
|
}) => {
|
|
8801
9014
|
const { navigateBack } = usePortalNavigation();
|
|
8802
9015
|
const { openModal } = usePortalModals();
|
|
8803
|
-
const isShieldableToken =
|
|
9016
|
+
const isShieldableToken = isTokenOperationSupported(token.extensions.fhenix.confidentialityType, "shield");
|
|
8804
9017
|
const { tokensWithExistingEncryptedBalance } = useCofheTokensWithExistingEncryptedBalances();
|
|
8805
9018
|
const { tokensWithPublicBalances } = useTokensWithPublicBalances();
|
|
9019
|
+
const selectableTokens = (0, import_react55.useMemo)(
|
|
9020
|
+
() => (mode === "unshield" ? tokensWithExistingEncryptedBalance : tokensWithPublicBalances).filter(
|
|
9021
|
+
(candidate) => isTokenOperationSupported(candidate.extensions.fhenix.confidentialityType, mode)
|
|
9022
|
+
),
|
|
9023
|
+
[mode, tokensWithExistingEncryptedBalance, tokensWithPublicBalances]
|
|
9024
|
+
);
|
|
8806
9025
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
8807
9026
|
PageContainer,
|
|
8808
9027
|
{
|
|
@@ -8823,7 +9042,7 @@ var ShieldAndUnshieldPageView = ({
|
|
|
8823
9042
|
{
|
|
8824
9043
|
onClick: () => openModal("tokenList" /* TokenList */, {
|
|
8825
9044
|
balanceType: mode === "shield" ? "public" /* Public */ : "confidential" /* Confidential */,
|
|
8826
|
-
tokens:
|
|
9045
|
+
tokens: selectableTokens,
|
|
8827
9046
|
title: mode === "shield" ? "Select token to shield" : "Select token to unshield",
|
|
8828
9047
|
onSelectToken: (token2) => setToken(token2)
|
|
8829
9048
|
}),
|
|
@@ -8944,7 +9163,7 @@ function useApproveWithLifecycle({
|
|
|
8944
9163
|
const errorMessage = cofheHumanizeViemError(error) ?? (error instanceof Error ? error.message : "Failed to approve tokens");
|
|
8945
9164
|
setError(errorMessage);
|
|
8946
9165
|
setStatus(null);
|
|
8947
|
-
|
|
9166
|
+
cofheLogger.error("Approve tx submit error:", error);
|
|
8948
9167
|
}
|
|
8949
9168
|
});
|
|
8950
9169
|
const { isMining: isApprovingMining } = useOnceTransactionMined({
|
|
@@ -9009,7 +9228,7 @@ var ActivityPage = () => {
|
|
|
9009
9228
|
// src/components/CofheFloatingButton/pages/DebugPage.tsx
|
|
9010
9229
|
var import_react56 = require("react");
|
|
9011
9230
|
var import_accounts = require("viem/accounts");
|
|
9012
|
-
var
|
|
9231
|
+
var import_viem26 = require("viem");
|
|
9013
9232
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
9014
9233
|
var DebugPage = () => {
|
|
9015
9234
|
const { navigateBack } = usePortalNavigation();
|
|
@@ -9370,7 +9589,7 @@ var FirstPermitDebug = () => {
|
|
|
9370
9589
|
};
|
|
9371
9590
|
var CreateSelfExpiringPermitButton = () => {
|
|
9372
9591
|
const cofheClient = useCofheClient();
|
|
9373
|
-
const
|
|
9592
|
+
const create11 = async () => {
|
|
9374
9593
|
const { account } = cofheClient.getSnapshot();
|
|
9375
9594
|
if (!account) throw new Error("No connected account found");
|
|
9376
9595
|
const expiration = Math.floor(Date.now() / 1e3) + 2 * 60;
|
|
@@ -9381,7 +9600,7 @@ var CreateSelfExpiringPermitButton = () => {
|
|
|
9381
9600
|
});
|
|
9382
9601
|
usePortalPersisted.getState().setHasCreatedFirstPermit(true);
|
|
9383
9602
|
};
|
|
9384
|
-
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { onClick:
|
|
9603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { onClick: create11, children: "Create self permit (expires in 2 minutes)" });
|
|
9385
9604
|
};
|
|
9386
9605
|
var CreateAndUseReceivingPermitButton = () => {
|
|
9387
9606
|
const cofheClient = useCofheClient();
|
|
@@ -9390,9 +9609,9 @@ var CreateAndUseReceivingPermitButton = () => {
|
|
|
9390
9609
|
if (!account) throw new Error("No connected account found");
|
|
9391
9610
|
if (!publicClient) throw new Error("No public client found");
|
|
9392
9611
|
const sharingAccount = (0, import_accounts.privateKeyToAccount)("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80");
|
|
9393
|
-
const sharingWalletClient = (0,
|
|
9612
|
+
const sharingWalletClient = (0, import_viem26.createWalletClient)({
|
|
9394
9613
|
chain: publicClient.chain,
|
|
9395
|
-
transport: (0,
|
|
9614
|
+
transport: (0, import_viem26.http)(),
|
|
9396
9615
|
account: sharingAccount
|
|
9397
9616
|
});
|
|
9398
9617
|
const sharedPermit = await cofheClient.permits.createSharing(
|
|
@@ -9490,9 +9709,12 @@ var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
|
|
|
9490
9709
|
);
|
|
9491
9710
|
};
|
|
9492
9711
|
|
|
9493
|
-
// src/components/CofheFloatingButton/modals/
|
|
9712
|
+
// src/components/CofheFloatingButton/modals/AddCustomTokenButton.tsx
|
|
9494
9713
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
9495
|
-
var AddCustomTokenButton = () => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Button, { variant: "outline", size: "sm", label
|
|
9714
|
+
var AddCustomTokenButton = ({ label = "Import token", onClick }) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Button, { variant: "outline", size: "sm", label, onClick });
|
|
9715
|
+
|
|
9716
|
+
// src/components/CofheFloatingButton/modals/TokenListModal.tsx
|
|
9717
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
9496
9718
|
var TokenListModal = ({
|
|
9497
9719
|
tokens,
|
|
9498
9720
|
onClose,
|
|
@@ -9500,17 +9722,31 @@ var TokenListModal = ({
|
|
|
9500
9722
|
onSelectToken,
|
|
9501
9723
|
balanceType
|
|
9502
9724
|
}) => {
|
|
9503
|
-
|
|
9725
|
+
const { openModal } = usePortalModals();
|
|
9726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
9504
9727
|
PageContainer,
|
|
9505
9728
|
{
|
|
9506
|
-
header: /* @__PURE__ */ (0,
|
|
9507
|
-
/* @__PURE__ */ (0,
|
|
9508
|
-
/* @__PURE__ */ (0,
|
|
9509
|
-
/* @__PURE__ */ (0,
|
|
9729
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex justify-between flex-row", children: [
|
|
9730
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("button", { onClick: onClose, className: "flex items-center gap-1 text-sm hover:opacity-80 transition-opacity", children: [
|
|
9731
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ArrowBackIcon, { style: { fontSize: 16 } }),
|
|
9732
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "text-sm font-medium", children: title })
|
|
9510
9733
|
] }),
|
|
9511
|
-
/* @__PURE__ */ (0,
|
|
9734
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
9735
|
+
AddCustomTokenButton,
|
|
9736
|
+
{
|
|
9737
|
+
onClick: () => openModal("importCustomToken" /* ImportCustomToken */, {
|
|
9738
|
+
balanceType,
|
|
9739
|
+
title: "Import token",
|
|
9740
|
+
tokens,
|
|
9741
|
+
onSelectToken: (token) => {
|
|
9742
|
+
onSelectToken(token);
|
|
9743
|
+
onClose();
|
|
9744
|
+
}
|
|
9745
|
+
})
|
|
9746
|
+
}
|
|
9747
|
+
)
|
|
9512
9748
|
] }),
|
|
9513
|
-
content: /* @__PURE__ */ (0,
|
|
9749
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
9514
9750
|
TokenListContent,
|
|
9515
9751
|
{
|
|
9516
9752
|
balanceType,
|
|
@@ -9529,8 +9765,8 @@ var TokenListContent = ({ tokens, onSelectToken, balanceType }) => {
|
|
|
9529
9765
|
const normalizedPinnedAddress = pinnedTokenAddress?.toLowerCase();
|
|
9530
9766
|
const pinnedToken = normalizedPinnedAddress ? tokens.find((t) => t.address.toLowerCase() === normalizedPinnedAddress) : void 0;
|
|
9531
9767
|
const nonPinnedTokens = pinnedToken ? tokens.filter((t) => t.address.toLowerCase() !== normalizedPinnedAddress) : tokens;
|
|
9532
|
-
return /* @__PURE__ */ (0,
|
|
9533
|
-
pinnedToken && /* @__PURE__ */ (0,
|
|
9768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "cofhe-token-list-container", children: tokens.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "text-xs opacity-70 py-4 text-center", children: "No tokens found" }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
9769
|
+
pinnedToken && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
9534
9770
|
TokenRow,
|
|
9535
9771
|
{
|
|
9536
9772
|
balanceType,
|
|
@@ -9542,7 +9778,7 @@ var TokenListContent = ({ tokens, onSelectToken, balanceType }) => {
|
|
|
9542
9778
|
},
|
|
9543
9779
|
`pinned-${pinnedToken.address}`
|
|
9544
9780
|
),
|
|
9545
|
-
nonPinnedTokens.map((token) => /* @__PURE__ */ (0,
|
|
9781
|
+
nonPinnedTokens.map((token) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
9546
9782
|
TokenRow,
|
|
9547
9783
|
{
|
|
9548
9784
|
balanceType,
|
|
@@ -9557,29 +9793,46 @@ var TokenListContent = ({ tokens, onSelectToken, balanceType }) => {
|
|
|
9557
9793
|
};
|
|
9558
9794
|
|
|
9559
9795
|
// src/components/CofheFloatingButton/pages/PortfolioPage.tsx
|
|
9560
|
-
var
|
|
9796
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
9561
9797
|
var PortfolioPage = () => {
|
|
9562
9798
|
const { navigateBack, navigateTo } = usePortalNavigation();
|
|
9799
|
+
const { openModal } = usePortalModals();
|
|
9563
9800
|
const chainId = useCofheChainId();
|
|
9564
9801
|
const allTokens = useCofheTokens(chainId);
|
|
9565
|
-
return /* @__PURE__ */ (0,
|
|
9802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
9566
9803
|
PageContainer,
|
|
9567
9804
|
{
|
|
9568
|
-
header: /* @__PURE__ */ (0,
|
|
9569
|
-
/* @__PURE__ */ (0,
|
|
9805
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex justify-between flex-row", children: [
|
|
9806
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
9570
9807
|
"button",
|
|
9571
9808
|
{
|
|
9572
9809
|
onClick: navigateBack,
|
|
9573
9810
|
className: "flex items-center gap-1 text-sm hover:opacity-80 transition-opacity",
|
|
9574
9811
|
children: [
|
|
9575
|
-
/* @__PURE__ */ (0,
|
|
9576
|
-
/* @__PURE__ */ (0,
|
|
9812
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ArrowBackIcon, { style: { fontSize: 16 } }),
|
|
9813
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("p", { className: "text-sm font-medium", children: "Tokens list" })
|
|
9577
9814
|
]
|
|
9578
9815
|
}
|
|
9579
9816
|
),
|
|
9580
|
-
/* @__PURE__ */ (0,
|
|
9817
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
9818
|
+
AddCustomTokenButton,
|
|
9819
|
+
{
|
|
9820
|
+
onClick: () => openModal("importCustomToken" /* ImportCustomToken */, {
|
|
9821
|
+
balanceType: "confidential" /* Confidential */,
|
|
9822
|
+
title: "Import token",
|
|
9823
|
+
tokens: allTokens,
|
|
9824
|
+
onSelectToken: (token) => {
|
|
9825
|
+
navigateTo("tokeninfo" /* TokenInfo */, {
|
|
9826
|
+
pageProps: {
|
|
9827
|
+
token
|
|
9828
|
+
}
|
|
9829
|
+
});
|
|
9830
|
+
}
|
|
9831
|
+
})
|
|
9832
|
+
}
|
|
9833
|
+
)
|
|
9581
9834
|
] }),
|
|
9582
|
-
content: /* @__PURE__ */ (0,
|
|
9835
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
9583
9836
|
TokenListContent,
|
|
9584
9837
|
{
|
|
9585
9838
|
balanceType: "confidential" /* Confidential */,
|
|
@@ -9600,7 +9853,7 @@ var PortfolioPage = () => {
|
|
|
9600
9853
|
// src/components/CofheFloatingButton/pages/ClaimableTokens.tsx
|
|
9601
9854
|
var import_react57 = require("react");
|
|
9602
9855
|
var import_ts_essentials24 = __toESM(require_dist(), 1);
|
|
9603
|
-
var
|
|
9856
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
9604
9857
|
function ClaimableTokens() {
|
|
9605
9858
|
const chainsClaimableTokens = useCofheClaimableTokens();
|
|
9606
9859
|
const claimableByTokenAddress = chainsClaimableTokens.claimableByTokenAddress;
|
|
@@ -9623,30 +9876,30 @@ function ClaimableTokens() {
|
|
|
9623
9876
|
(0, import_ts_essentials24.assert)(row, "token not found for claim");
|
|
9624
9877
|
await claimMutation.mutateAsync({ token: row.token, amount: row.claimableAmount });
|
|
9625
9878
|
};
|
|
9626
|
-
return /* @__PURE__ */ (0,
|
|
9879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
9627
9880
|
PageContainer,
|
|
9628
9881
|
{
|
|
9629
|
-
header: /* @__PURE__ */ (0,
|
|
9630
|
-
/* @__PURE__ */ (0,
|
|
9882
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
9883
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
9631
9884
|
"button",
|
|
9632
9885
|
{
|
|
9633
9886
|
className: "flex items-center gap-2 text-xl font-semibold text-[#0E2F3F] transition-opacity hover:opacity-80 dark:text-white",
|
|
9634
9887
|
type: "button",
|
|
9635
9888
|
onClick: navigateBack,
|
|
9636
|
-
children: /* @__PURE__ */ (0,
|
|
9889
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ArrowBackIcon, { fontSize: "small" })
|
|
9637
9890
|
}
|
|
9638
9891
|
),
|
|
9639
|
-
/* @__PURE__ */ (0,
|
|
9892
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { children: "Claimable Tokens list" })
|
|
9640
9893
|
] }),
|
|
9641
|
-
content: /* @__PURE__ */ (0,
|
|
9894
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex flex-col gap-4 pr-1", children: [
|
|
9642
9895
|
rows.map(({ token, claimableAmount }) => {
|
|
9643
9896
|
const isDecrypting = waitingByTokenAddress?.[token.address] ?? false;
|
|
9644
9897
|
const isUnshielding = unshieldingInProgressByTokenAddress?.[token.address.toLowerCase()] ?? false;
|
|
9645
9898
|
const formatted = formatTokenAmount(claimableAmount, token.decimals, 5).formatted;
|
|
9646
9899
|
const isClaimingThis = isClaimingByTokenAddress?.[token.address.toLowerCase()] ?? false;
|
|
9647
|
-
return /* @__PURE__ */ (0,
|
|
9648
|
-
/* @__PURE__ */ (0,
|
|
9649
|
-
/* @__PURE__ */ (0,
|
|
9900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "grid grid-cols-[1fr,auto,auto] items-center gap-4", children: [
|
|
9901
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
9902
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
9650
9903
|
TokenIcon,
|
|
9651
9904
|
{
|
|
9652
9905
|
logoURI: token.logoURI,
|
|
@@ -9660,10 +9913,10 @@ function ClaimableTokens() {
|
|
|
9660
9913
|
)
|
|
9661
9914
|
}
|
|
9662
9915
|
),
|
|
9663
|
-
/* @__PURE__ */ (0,
|
|
9916
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "text-xl font-semibold cofhe-text-primary truncate", children: token.name }) })
|
|
9664
9917
|
] }),
|
|
9665
|
-
/* @__PURE__ */ (0,
|
|
9666
|
-
/* @__PURE__ */ (0,
|
|
9918
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "text-2xl font-semibold cofhe-text-primary tabular-nums", children: formatted }),
|
|
9919
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
9667
9920
|
Button,
|
|
9668
9921
|
{
|
|
9669
9922
|
type: "button",
|
|
@@ -9674,7 +9927,7 @@ function ClaimableTokens() {
|
|
|
9674
9927
|
)
|
|
9675
9928
|
] }, token.address);
|
|
9676
9929
|
}),
|
|
9677
|
-
rows.length === 0 && /* @__PURE__ */ (0,
|
|
9930
|
+
rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "text-sm opacity-70 cofhe-text-primary", children: "No claimable tokens." })
|
|
9678
9931
|
] })
|
|
9679
9932
|
}
|
|
9680
9933
|
);
|
|
@@ -9698,24 +9951,24 @@ var pages = {
|
|
|
9698
9951
|
};
|
|
9699
9952
|
|
|
9700
9953
|
// src/components/CofheFloatingButton/ContentSection.tsx
|
|
9701
|
-
var
|
|
9954
|
+
var import_react61 = require("motion/react");
|
|
9702
9955
|
|
|
9703
9956
|
// src/components/CofheFloatingButton/modals/ExampleSelectionPage.tsx
|
|
9704
|
-
var
|
|
9957
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
9705
9958
|
var ExampleSelectionPage = ({
|
|
9706
9959
|
onClose,
|
|
9707
9960
|
onSelect
|
|
9708
9961
|
}) => {
|
|
9709
9962
|
const options = ["1", "2", "3"];
|
|
9710
|
-
return /* @__PURE__ */ (0,
|
|
9963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
9711
9964
|
PageContainer,
|
|
9712
9965
|
{
|
|
9713
9966
|
isModal: true,
|
|
9714
|
-
header: /* @__PURE__ */ (0,
|
|
9715
|
-
/* @__PURE__ */ (0,
|
|
9716
|
-
/* @__PURE__ */ (0,
|
|
9967
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("button", { onClick: onClose, className: "flex items-center gap-1 text-sm hover:opacity-80 transition-opacity", children: [
|
|
9968
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(CloseIcon, { style: { fontSize: 16 } }),
|
|
9969
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "text-sm font-medium", children: "Select an option" })
|
|
9717
9970
|
] }),
|
|
9718
|
-
content: /* @__PURE__ */ (0,
|
|
9971
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex flex-1 flex-col gap-3 items-start justify-start", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
|
|
9719
9972
|
"button",
|
|
9720
9973
|
{
|
|
9721
9974
|
onClick: () => {
|
|
@@ -9729,29 +9982,29 @@ var ExampleSelectionPage = ({
|
|
|
9729
9982
|
},
|
|
9730
9983
|
option
|
|
9731
9984
|
)) }),
|
|
9732
|
-
footer: /* @__PURE__ */ (0,
|
|
9985
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex flex-row flex-1 justify-end items-center mt-auto", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { onClick: onClose, className: "flex items-center gap-1 text-sm hover:opacity-80 transition-opacity", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { children: "Close" }) }) })
|
|
9733
9986
|
}
|
|
9734
9987
|
);
|
|
9735
9988
|
};
|
|
9736
9989
|
|
|
9737
9990
|
// src/components/CofheFloatingButton/modals/ExampleInfoPage.tsx
|
|
9738
|
-
var
|
|
9991
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
9739
9992
|
var ExampleInfoPage = ({ onClose }) => {
|
|
9740
|
-
return /* @__PURE__ */ (0,
|
|
9993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
9741
9994
|
PageContainer,
|
|
9742
9995
|
{
|
|
9743
9996
|
isModal: true,
|
|
9744
|
-
header: /* @__PURE__ */ (0,
|
|
9745
|
-
/* @__PURE__ */ (0,
|
|
9746
|
-
/* @__PURE__ */ (0,
|
|
9997
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("button", { onClick: onClose, className: "flex items-center gap-1 text-sm hover:opacity-80 transition-opacity", children: [
|
|
9998
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(CloseIcon, { style: { fontSize: 16 } }),
|
|
9999
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "text-sm font-medium", children: "More info" })
|
|
9747
10000
|
] }),
|
|
9748
|
-
content: /* @__PURE__ */ (0,
|
|
9749
|
-
/* @__PURE__ */ (0,
|
|
9750
|
-
/* @__PURE__ */ (0,
|
|
9751
|
-
/* @__PURE__ */ (0,
|
|
9752
|
-
/* @__PURE__ */ (0,
|
|
10001
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "flex flex-1 flex-col gap-3 items-start justify-start", children: [
|
|
10002
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: "Cofhesdk is complex, so we have created this modal to help you understand." }),
|
|
10003
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: "You probably clicked on a ? button next to some functionality. And in this modal you'll get your information or explanation." }),
|
|
10004
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: "This is another paragraph of explanation." }),
|
|
10005
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: `Now that you're done reading, you can click "Got It" at the bottom to close this modal.` })
|
|
9753
10006
|
] }),
|
|
9754
|
-
footer: /* @__PURE__ */ (0,
|
|
10007
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "flex flex-row flex-1 justify-end items-center mt-auto", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("button", { onClick: onClose, className: "flex items-center gap-1 text-sm hover:opacity-80 transition-opacity", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { children: "Got It" }) }) })
|
|
9755
10008
|
}
|
|
9756
10009
|
);
|
|
9757
10010
|
};
|
|
@@ -9759,19 +10012,19 @@ var ExampleInfoPage = ({ onClose }) => {
|
|
|
9759
10012
|
// src/components/CofheFloatingButton/modals/PermitDetailsModal.tsx
|
|
9760
10013
|
var import_fa64 = require("react-icons/fa6");
|
|
9761
10014
|
var import_react58 = require("react");
|
|
9762
|
-
var
|
|
10015
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
9763
10016
|
var PermitTypeLabel2 = {
|
|
9764
10017
|
self: "Self",
|
|
9765
10018
|
sharing: "Delegated",
|
|
9766
10019
|
recipient: "Imported"
|
|
9767
10020
|
};
|
|
9768
10021
|
var NoPermitFoundModal = ({ onClose }) => {
|
|
9769
|
-
return /* @__PURE__ */ (0,
|
|
10022
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
9770
10023
|
PageContainer,
|
|
9771
10024
|
{
|
|
9772
|
-
header: /* @__PURE__ */ (0,
|
|
9773
|
-
content: /* @__PURE__ */ (0,
|
|
9774
|
-
footer: /* @__PURE__ */ (0,
|
|
10025
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "flex items-center gap-2 text-base font-semibold tracking-tight text-[#0E2F3F] transition-opacity hover:opacity-80 dark:text-white", children: "No permit found" }),
|
|
10026
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { children: "No permit found" }) }),
|
|
10027
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Button, { label: "CLOSE", onClick: onClose, variant: "ghost" })
|
|
9775
10028
|
}
|
|
9776
10029
|
);
|
|
9777
10030
|
};
|
|
@@ -9804,77 +10057,77 @@ var PermitDetailsModal = ({ hash, onClose }) => {
|
|
|
9804
10057
|
onClose();
|
|
9805
10058
|
}, [confirmDelete, onClose, handleRemovePermit]);
|
|
9806
10059
|
if (permit == null) {
|
|
9807
|
-
return /* @__PURE__ */ (0,
|
|
10060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(NoPermitFoundModal, { onClose });
|
|
9808
10061
|
}
|
|
9809
|
-
return /* @__PURE__ */ (0,
|
|
10062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
9810
10063
|
PageContainer,
|
|
9811
10064
|
{
|
|
9812
10065
|
isModal: true,
|
|
9813
|
-
header: /* @__PURE__ */ (0,
|
|
10066
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
9814
10067
|
PermitCard,
|
|
9815
10068
|
{
|
|
9816
10069
|
hash,
|
|
9817
10070
|
className: "-mt-4 -ml-4 -mr-4",
|
|
9818
|
-
header: /* @__PURE__ */ (0,
|
|
10071
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
9819
10072
|
"button",
|
|
9820
10073
|
{
|
|
9821
10074
|
className: "flex items-center gap-2 text-base font-semibold tracking-tight text-[#0E2F3F] transition-opacity hover:opacity-80 dark:text-white",
|
|
9822
10075
|
onClick: onClose,
|
|
9823
10076
|
type: "button",
|
|
9824
10077
|
children: [
|
|
9825
|
-
/* @__PURE__ */ (0,
|
|
9826
|
-
/* @__PURE__ */ (0,
|
|
10078
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(CloseIcon, { fontSize: "small" }),
|
|
10079
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { children: "Permit" })
|
|
9827
10080
|
]
|
|
9828
10081
|
}
|
|
9829
10082
|
)
|
|
9830
10083
|
}
|
|
9831
10084
|
),
|
|
9832
|
-
content: permit != null && /* @__PURE__ */ (0,
|
|
9833
|
-
/* @__PURE__ */ (0,
|
|
10085
|
+
content: permit != null && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
10086
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("p", { className: "flex flex-row gap-2 text-sm", children: [
|
|
9834
10087
|
"Type: ",
|
|
9835
|
-
/* @__PURE__ */ (0,
|
|
9836
|
-
/* @__PURE__ */ (0,
|
|
10088
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: PermitTypeLabel2[permit.type] }),
|
|
10089
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(InfoModalButton, { onClick: () => openModal("permitTypeInfo" /* PermitTypeInfo */, { type: permit.type }) })
|
|
9837
10090
|
] }),
|
|
9838
|
-
/* @__PURE__ */ (0,
|
|
10091
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("p", { className: "text-sm", children: [
|
|
9839
10092
|
"Expires in: ",
|
|
9840
|
-
/* @__PURE__ */ (0,
|
|
10093
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: expirationInfo.label })
|
|
9841
10094
|
] }),
|
|
9842
|
-
permit.type === "self" && /* @__PURE__ */ (0,
|
|
10095
|
+
permit.type === "self" && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("p", { className: "text-sm", children: [
|
|
9843
10096
|
"To select this permit for usage, click the ",
|
|
9844
|
-
/* @__PURE__ */ (0,
|
|
10097
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: '"SELECT"' }),
|
|
9845
10098
|
" button below. When this permit is active, you will be able to view your own encrypted data."
|
|
9846
10099
|
] }),
|
|
9847
|
-
permit.type === "sharing" && /* @__PURE__ */ (0,
|
|
10100
|
+
permit.type === "sharing" && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("p", { className: "text-sm", children: [
|
|
9848
10101
|
"To share this permit with ",
|
|
9849
|
-
/* @__PURE__ */ (0,
|
|
10102
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: "recipient" }),
|
|
9850
10103
|
", click the ",
|
|
9851
|
-
/* @__PURE__ */ (0,
|
|
10104
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: '"SHARE"' }),
|
|
9852
10105
|
" button below to copy the permit data to your clipboard. Share the copied permit data with ",
|
|
9853
|
-
/* @__PURE__ */ (0,
|
|
10106
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: "recipient" }),
|
|
9854
10107
|
" to grant them access to your encrypted data.",
|
|
9855
|
-
/* @__PURE__ */ (0,
|
|
9856
|
-
/* @__PURE__ */ (0,
|
|
9857
|
-
/* @__PURE__ */ (0,
|
|
9858
|
-
/* @__PURE__ */ (0,
|
|
10108
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("br", {}),
|
|
10109
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("br", {}),
|
|
10110
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("i", { children: [
|
|
10111
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: "Note:" }),
|
|
9859
10112
|
" The copied permit data is not sensitive and can be sent to recipient via any communication channel."
|
|
9860
10113
|
] })
|
|
9861
10114
|
] }),
|
|
9862
|
-
permit.type === "recipient" && /* @__PURE__ */ (0,
|
|
10115
|
+
permit.type === "recipient" && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("p", { className: "text-sm", children: [
|
|
9863
10116
|
"To select this imported permit for usage, click the ",
|
|
9864
|
-
/* @__PURE__ */ (0,
|
|
10117
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: '"SELECT"' }),
|
|
9865
10118
|
" button below. When this permit is active, you will be able to view ",
|
|
9866
|
-
/* @__PURE__ */ (0,
|
|
10119
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("b", { children: "issuer" }),
|
|
9867
10120
|
"'s (",
|
|
9868
10121
|
truncateAddress(permit.issuer, 4, 4),
|
|
9869
10122
|
") encrypted data."
|
|
9870
10123
|
] })
|
|
9871
10124
|
] }),
|
|
9872
|
-
footer: /* @__PURE__ */ (0,
|
|
9873
|
-
isShareablePermit && /* @__PURE__ */ (0,
|
|
9874
|
-
isCopyComplete ? /* @__PURE__ */ (0,
|
|
10125
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex flex-row gap-3 w-full", children: [
|
|
10126
|
+
isShareablePermit && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Button, { variant: "primary", onClick: handlePermitShare, children: [
|
|
10127
|
+
isCopyComplete ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_fa64.FaCheck, {}) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_fa64.FaRegCopy, {}),
|
|
9875
10128
|
isCopyComplete ? "COPIED" : "SHARE"
|
|
9876
10129
|
] }),
|
|
9877
|
-
!isShareablePermit && /* @__PURE__ */ (0,
|
|
10130
|
+
!isShareablePermit && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
9878
10131
|
Button,
|
|
9879
10132
|
{
|
|
9880
10133
|
variant: "primary",
|
|
@@ -9883,53 +10136,53 @@ var PermitDetailsModal = ({ hash, onClose }) => {
|
|
|
9883
10136
|
disabled: isActivePermit
|
|
9884
10137
|
}
|
|
9885
10138
|
),
|
|
9886
|
-
/* @__PURE__ */ (0,
|
|
9887
|
-
/* @__PURE__ */ (0,
|
|
10139
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Button, { label: confirmDelete ? "CONFIRM" : "DELETE", onClick: handlePermitDelete, variant: "error" }),
|
|
10140
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Button, { label: "CLOSE", onClick: onClose, variant: "ghost" })
|
|
9888
10141
|
] })
|
|
9889
10142
|
}
|
|
9890
10143
|
);
|
|
9891
10144
|
};
|
|
9892
10145
|
|
|
9893
10146
|
// src/components/CofheFloatingButton/modals/BaseInfoModal.tsx
|
|
9894
|
-
var
|
|
10147
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
9895
10148
|
var BaseInfoModal = ({ header, content, onClose }) => {
|
|
9896
|
-
return /* @__PURE__ */ (0,
|
|
10149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
9897
10150
|
PageContainer,
|
|
9898
10151
|
{
|
|
9899
10152
|
isModal: true,
|
|
9900
|
-
header: /* @__PURE__ */ (0,
|
|
10153
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
|
|
9901
10154
|
"button",
|
|
9902
10155
|
{
|
|
9903
10156
|
onClick: onClose,
|
|
9904
10157
|
className: "flex items-center gap-1 text-base font-semibold tracking-tight text-[#0E2F3F] transition-opacity hover:opacity-80 dark:text-white",
|
|
9905
10158
|
children: [
|
|
9906
|
-
/* @__PURE__ */ (0,
|
|
9907
|
-
typeof header === "string" ? /* @__PURE__ */ (0,
|
|
10159
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CloseIcon, { style: { fontSize: 16 } }),
|
|
10160
|
+
typeof header === "string" ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { className: "text-base font-semibold tracking-tight text-[#0E2F3F]", children: header }) : header
|
|
9908
10161
|
]
|
|
9909
10162
|
}
|
|
9910
10163
|
),
|
|
9911
|
-
content: /* @__PURE__ */ (0,
|
|
9912
|
-
footer: /* @__PURE__ */ (0,
|
|
10164
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "flex flex-1 flex-col w-full gap-3 items-start justify-start", children: content }),
|
|
10165
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "flex flex-row", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Button, { onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { children: "Close" }) }) })
|
|
9913
10166
|
}
|
|
9914
10167
|
);
|
|
9915
10168
|
};
|
|
9916
10169
|
|
|
9917
10170
|
// src/components/CofheFloatingButton/modals/PermitTypeInfoModal.tsx
|
|
9918
|
-
var
|
|
10171
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
9919
10172
|
var PermitTypeLabel3 = {
|
|
9920
10173
|
self: "Self",
|
|
9921
10174
|
sharing: "Delegated",
|
|
9922
10175
|
recipient: "Imported"
|
|
9923
10176
|
};
|
|
9924
10177
|
var PermitTypeInfoModal = ({ type, onClose }) => {
|
|
9925
|
-
return /* @__PURE__ */ (0,
|
|
10178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
9926
10179
|
BaseInfoModal,
|
|
9927
10180
|
{
|
|
9928
10181
|
header: `${PermitTypeLabel3[type]} Permit`,
|
|
9929
|
-
content: /* @__PURE__ */ (0,
|
|
9930
|
-
type === "self" && /* @__PURE__ */ (0,
|
|
9931
|
-
type === "sharing" && /* @__PURE__ */ (0,
|
|
9932
|
-
type === "recipient" && /* @__PURE__ */ (0,
|
|
10182
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
|
|
10183
|
+
type === "self" && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { children: '"Self" permits are created by a user to access their own encrypted data. The provided signature is verified on-chain by the ACL (Access Control List).' }),
|
|
10184
|
+
type === "sharing" && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { children: `"Delegated" permits are created by a user (Issuer) to share their encrypted data with another user (Recipient). Both Issuer and Rceipient must sign as a handshake. Issuer's signature is verified on-chain by the ACL (Access Control List) and grants access to Recipient, and Recipient's signature applies and verifies the re-encryption key.` }),
|
|
10185
|
+
type === "recipient" && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { children: `"Imported" permits are imported by a user (Recipient) to access encrypted data that has been shared with them by the permit's Issuer. Both Issuer and Rceipient must sign as a handshake. Issuer's signature is verified on-chain by the ACL (Access Control List) and grants access to Recipient, and Recipient's signature applies and verifies the re-encryption key.` })
|
|
9933
10186
|
] }),
|
|
9934
10187
|
onClose
|
|
9935
10188
|
}
|
|
@@ -9937,25 +10190,168 @@ var PermitTypeInfoModal = ({ type, onClose }) => {
|
|
|
9937
10190
|
};
|
|
9938
10191
|
|
|
9939
10192
|
// src/components/CofheFloatingButton/modals/PermitInfoModal.tsx
|
|
9940
|
-
var
|
|
10193
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
9941
10194
|
var PermitInfoModal = ({ onClose }) => {
|
|
9942
|
-
return /* @__PURE__ */ (0,
|
|
10195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
9943
10196
|
BaseInfoModal,
|
|
9944
10197
|
{
|
|
9945
10198
|
header: "Permit",
|
|
9946
|
-
content: /* @__PURE__ */ (0,
|
|
9947
|
-
/* @__PURE__ */ (0,
|
|
9948
|
-
/* @__PURE__ */ (0,
|
|
9949
|
-
/* @__PURE__ */ (0,
|
|
10199
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
|
|
10200
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "flex flex-col w-full justify-center items-center gap-3 text-[#0E2F3F] dark:text-white", children: [
|
|
10201
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(fhenix_permit_icon_default, { className: "h-7 w-7 fill-black dark:fill-white", "aria-label": "CoFHE permit icon" }),
|
|
10202
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "text-lg font-semibold", children: "CoFHE Permits" })
|
|
9950
10203
|
] }),
|
|
9951
|
-
/* @__PURE__ */ (0,
|
|
9952
|
-
/* @__PURE__ */ (0,
|
|
10204
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "text-sm leading-relaxed text-[#355366] dark:text-white/80", children: "CoFHE permits are used to authenticate your identity and grant access to your encrypted data." }),
|
|
10205
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "text-sm leading-relaxed text-[#355366] dark:text-white/80", children: "Generating a permit requires a signature, which will open your connected wallet to sign a message (EIP712). This signed message contains only info used to authenticate and grant access." })
|
|
9953
10206
|
] }),
|
|
9954
10207
|
onClose
|
|
9955
10208
|
}
|
|
9956
10209
|
);
|
|
9957
10210
|
};
|
|
9958
10211
|
|
|
10212
|
+
// src/components/CofheFloatingButton/modals/ImportCustomTokenCard.tsx
|
|
10213
|
+
var import_react59 = require("react");
|
|
10214
|
+
var import_viem27 = require("viem");
|
|
10215
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
10216
|
+
var ImportCustomTokenCard = ({ tokens, onSelectToken, balanceType }) => {
|
|
10217
|
+
const [addressInput, setAddressInput] = (0, import_react59.useState)("");
|
|
10218
|
+
const chainId = useCofheChainId();
|
|
10219
|
+
const addCustomToken = useCustomTokensStore((state) => state.addCustomToken);
|
|
10220
|
+
const removeCustomToken = useCustomTokensStore((state) => state.removeCustomToken);
|
|
10221
|
+
const customTokensByChainId = useCustomTokensStore((state) => state.customTokensByChainId);
|
|
10222
|
+
const trimmedAddress = addressInput.trim();
|
|
10223
|
+
const normalizedAddress = (0, import_viem27.isAddress)(trimmedAddress) ? trimmedAddress : void 0;
|
|
10224
|
+
const importedCustomTokens = (0, import_react59.useMemo)(() => {
|
|
10225
|
+
if (!chainId) return [];
|
|
10226
|
+
return customTokensByChainId[chainId.toString()] ?? [];
|
|
10227
|
+
}, [chainId, customTokensByChainId]);
|
|
10228
|
+
const existingToken = (0, import_react59.useMemo)(() => {
|
|
10229
|
+
if (!normalizedAddress) return void 0;
|
|
10230
|
+
return tokens.find((token) => token.address.toLowerCase() === normalizedAddress.toLowerCase());
|
|
10231
|
+
}, [normalizedAddress, tokens]);
|
|
10232
|
+
const resolvedToken = useResolvedCofheToken(
|
|
10233
|
+
{ address: normalizedAddress },
|
|
10234
|
+
{
|
|
10235
|
+
enabled: !!normalizedAddress && !existingToken,
|
|
10236
|
+
retry: false
|
|
10237
|
+
}
|
|
10238
|
+
);
|
|
10239
|
+
const previewToken = existingToken ?? resolvedToken.data;
|
|
10240
|
+
const canImport = !!previewToken && !resolvedToken.isFetching;
|
|
10241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "fnx-card-bg border fnx-card-border rounded-lg p-3 flex flex-col gap-3", children: [
|
|
10242
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
10243
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("label", { className: "text-xs font-medium opacity-70", children: "Token contract address" }),
|
|
10244
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10245
|
+
"input",
|
|
10246
|
+
{
|
|
10247
|
+
type: "text",
|
|
10248
|
+
value: addressInput,
|
|
10249
|
+
onChange: (event) => setAddressInput(event.target.value),
|
|
10250
|
+
placeholder: "0x...",
|
|
10251
|
+
className: "w-full bg-transparent fnx-text-primary outline-none border-b pb-2 px-2 text-sm"
|
|
10252
|
+
}
|
|
10253
|
+
)
|
|
10254
|
+
] }),
|
|
10255
|
+
!normalizedAddress && trimmedAddress.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "text-xxxs text-[#c2410c]", children: "Enter a valid token address." }),
|
|
10256
|
+
resolvedToken.isFetching && !existingToken && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "text-xxxs opacity-70", children: "Checking token metadata and CoFHE support..." }),
|
|
10257
|
+
resolvedToken.error && !existingToken && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "text-xxxs text-[#c2410c]", children: resolvedToken.error.message }),
|
|
10258
|
+
previewToken && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-col gap-1 text-xs", children: [
|
|
10259
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("p", { className: "font-medium fnx-text-primary", children: [
|
|
10260
|
+
previewToken.symbol,
|
|
10261
|
+
" \xB7 ",
|
|
10262
|
+
previewToken.name
|
|
10263
|
+
] }),
|
|
10264
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "opacity-70", children: getTokenConfidentialityLabel(previewToken.extensions.fhenix.confidentialityType) ?? "Confidential token" }),
|
|
10265
|
+
balanceType === "public" && previewToken.extensions.fhenix.confidentialityType === "wrapped" && !previewToken.extensions.fhenix.erc20Pair && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "text-xxxs opacity-70", children: "Public-balance actions may stay unavailable until the token's paired asset can be discovered." })
|
|
10266
|
+
] }),
|
|
10267
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10268
|
+
Button,
|
|
10269
|
+
{
|
|
10270
|
+
variant: "primary",
|
|
10271
|
+
size: "sm",
|
|
10272
|
+
disabled: !canImport,
|
|
10273
|
+
label: existingToken ? "Select token" : "Import and select",
|
|
10274
|
+
onClick: () => {
|
|
10275
|
+
if (!previewToken) return;
|
|
10276
|
+
if (!existingToken) {
|
|
10277
|
+
addCustomToken(previewToken);
|
|
10278
|
+
}
|
|
10279
|
+
onSelectToken(previewToken);
|
|
10280
|
+
}
|
|
10281
|
+
}
|
|
10282
|
+
),
|
|
10283
|
+
importedCustomTokens.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-col gap-2 border-t pt-3", children: [
|
|
10284
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "text-xs font-medium opacity-70", children: "Imported tokens" }),
|
|
10285
|
+
importedCustomTokens.map((token) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
10286
|
+
"div",
|
|
10287
|
+
{
|
|
10288
|
+
className: "flex items-center justify-between gap-3 px-3 py-2",
|
|
10289
|
+
children: [
|
|
10290
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
10291
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("p", { className: "text-sm font-medium fnx-text-primary truncate", children: [
|
|
10292
|
+
token.symbol,
|
|
10293
|
+
" \xB7 ",
|
|
10294
|
+
token.name
|
|
10295
|
+
] }),
|
|
10296
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "text-xxxs opacity-70 truncate", children: token.address })
|
|
10297
|
+
] }),
|
|
10298
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10299
|
+
Button,
|
|
10300
|
+
{
|
|
10301
|
+
variant: "error",
|
|
10302
|
+
size: "sm",
|
|
10303
|
+
label: "Remove",
|
|
10304
|
+
onClick: () => {
|
|
10305
|
+
removeCustomToken({
|
|
10306
|
+
chainId: token.chainId,
|
|
10307
|
+
address: token.address
|
|
10308
|
+
});
|
|
10309
|
+
if (normalizedAddress?.toLowerCase() === token.address.toLowerCase()) {
|
|
10310
|
+
setAddressInput("");
|
|
10311
|
+
}
|
|
10312
|
+
}
|
|
10313
|
+
}
|
|
10314
|
+
)
|
|
10315
|
+
]
|
|
10316
|
+
},
|
|
10317
|
+
`${token.chainId}-${token.address}`
|
|
10318
|
+
))
|
|
10319
|
+
] })
|
|
10320
|
+
] });
|
|
10321
|
+
};
|
|
10322
|
+
|
|
10323
|
+
// src/components/CofheFloatingButton/modals/ImportCustomTokenModal.tsx
|
|
10324
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
10325
|
+
var ImportCustomTokenModal = ({
|
|
10326
|
+
tokens,
|
|
10327
|
+
onClose,
|
|
10328
|
+
title,
|
|
10329
|
+
onSelectToken,
|
|
10330
|
+
balanceType
|
|
10331
|
+
}) => {
|
|
10332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10333
|
+
PageContainer,
|
|
10334
|
+
{
|
|
10335
|
+
isModal: true,
|
|
10336
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("button", { onClick: onClose, className: "flex items-center gap-1 text-sm hover:opacity-80 transition-opacity", children: [
|
|
10337
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ArrowBackIcon, { style: { fontSize: 16 } }),
|
|
10338
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { className: "text-sm font-medium", children: title })
|
|
10339
|
+
] }),
|
|
10340
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10341
|
+
ImportCustomTokenCard,
|
|
10342
|
+
{
|
|
10343
|
+
balanceType,
|
|
10344
|
+
tokens,
|
|
10345
|
+
onSelectToken: (token) => {
|
|
10346
|
+
onSelectToken(token);
|
|
10347
|
+
onClose();
|
|
10348
|
+
}
|
|
10349
|
+
}
|
|
10350
|
+
)
|
|
10351
|
+
}
|
|
10352
|
+
);
|
|
10353
|
+
};
|
|
10354
|
+
|
|
9959
10355
|
// src/components/CofheFloatingButton/modals/index.ts
|
|
9960
10356
|
var modals = {
|
|
9961
10357
|
["exampleSelection" /* ExampleSelection */]: ExampleSelectionPage,
|
|
@@ -9963,15 +10359,16 @@ var modals = {
|
|
|
9963
10359
|
["permitDetails" /* PermitDetails */]: PermitDetailsModal,
|
|
9964
10360
|
["permitTypeInfo" /* PermitTypeInfo */]: PermitTypeInfoModal,
|
|
9965
10361
|
["permitInfo" /* PermitInfo */]: PermitInfoModal,
|
|
9966
|
-
["tokenList" /* TokenList */]: TokenListModal
|
|
10362
|
+
["tokenList" /* TokenList */]: TokenListModal,
|
|
10363
|
+
["importCustomToken" /* ImportCustomToken */]: ImportCustomTokenModal
|
|
9967
10364
|
};
|
|
9968
10365
|
|
|
9969
10366
|
// src/components/CofheFloatingButton/ContentSection.tsx
|
|
9970
|
-
var
|
|
10367
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
9971
10368
|
var MeasuredContentRenderer = ({ children, id, isModal, onModalOverlayClick }) => {
|
|
9972
10369
|
const { setContentHeight, removeContentHeight } = usePortalUI();
|
|
9973
|
-
const contentRef = (0,
|
|
9974
|
-
(0,
|
|
10370
|
+
const contentRef = (0, import_react60.useRef)(null);
|
|
10371
|
+
(0, import_react60.useEffect)(() => {
|
|
9975
10372
|
if (!contentRef.current) return;
|
|
9976
10373
|
const observer = new ResizeObserver((entries) => {
|
|
9977
10374
|
for (const entry of entries) {
|
|
@@ -9985,8 +10382,8 @@ var MeasuredContentRenderer = ({ children, id, isModal, onModalOverlayClick }) =
|
|
|
9985
10382
|
removeContentHeight(id);
|
|
9986
10383
|
};
|
|
9987
10384
|
}, [id]);
|
|
9988
|
-
return /* @__PURE__ */ (0,
|
|
9989
|
-
isModal && /* @__PURE__ */ (0,
|
|
10385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
|
|
10386
|
+
isModal && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
9990
10387
|
"div",
|
|
9991
10388
|
{
|
|
9992
10389
|
onClick: (e) => {
|
|
@@ -9997,23 +10394,23 @@ var MeasuredContentRenderer = ({ children, id, isModal, onModalOverlayClick }) =
|
|
|
9997
10394
|
className: "absolute flex w-full h-full bg-[#0E2F3F]/30 origin-top translate-y-[-8px] scale-[0.95]"
|
|
9998
10395
|
}
|
|
9999
10396
|
),
|
|
10000
|
-
/* @__PURE__ */ (0,
|
|
10397
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "relative flex w-full h-full overflow-y-hidden pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: cn("cofhe-panel absolute flex left-0 w-full p-4 top-0 pointer-events-auto"), ref: contentRef, children }) })
|
|
10001
10398
|
] });
|
|
10002
10399
|
};
|
|
10003
10400
|
var ContentRenderer = ({ page }) => {
|
|
10004
|
-
const content = (0,
|
|
10401
|
+
const content = (0, import_react60.useMemo)(() => {
|
|
10005
10402
|
const PageComp = pages[page.page];
|
|
10006
10403
|
const props = page.props ?? {};
|
|
10007
|
-
return /* @__PURE__ */ (0,
|
|
10404
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(PageComp, { ...props });
|
|
10008
10405
|
}, [page]);
|
|
10009
|
-
return /* @__PURE__ */ (0,
|
|
10406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(MeasuredContentRenderer, { id: "content", children: content });
|
|
10010
10407
|
};
|
|
10011
10408
|
var ModalRenderer = ({ modal }) => {
|
|
10012
|
-
const content = (0,
|
|
10409
|
+
const content = (0, import_react60.useMemo)(() => {
|
|
10013
10410
|
const ModalComp = modals[modal.modal];
|
|
10014
|
-
return /* @__PURE__ */ (0,
|
|
10411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ModalComp, { ...modal });
|
|
10015
10412
|
}, [modal]);
|
|
10016
|
-
return /* @__PURE__ */ (0,
|
|
10413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(MeasuredContentRenderer, { id: `${modal.modal}-modal`, isModal: true, onModalOverlayClick: modal.onClose, children: content });
|
|
10017
10414
|
};
|
|
10018
10415
|
var ContentSection = ({ overriddingPage }) => {
|
|
10019
10416
|
const { isTopSide } = useCofheFloatingButtonContext();
|
|
@@ -10022,17 +10419,17 @@ var ContentSection = ({ overriddingPage }) => {
|
|
|
10022
10419
|
const maxContentHeight = usePortalUIMaxContentHeight();
|
|
10023
10420
|
const currentPage = usePortalCurrentPage();
|
|
10024
10421
|
const pageOrOverridingPage = overriddingPage ?? currentPage;
|
|
10025
|
-
return /* @__PURE__ */ (0,
|
|
10026
|
-
|
|
10422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_react61.AnimatePresence, { children: contentPanelOpen && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10423
|
+
import_react61.motion.div,
|
|
10027
10424
|
{
|
|
10028
10425
|
className: "relative flex w-full z-50",
|
|
10029
10426
|
initial: { opacity: 0, y: isTopSide ? -10 : 10 },
|
|
10030
10427
|
animate: { opacity: 1, y: 0, height: `${maxContentHeight}px`, maxHeight: `${maxContentHeight}px` },
|
|
10031
10428
|
exit: { opacity: 0, y: isTopSide ? -10 : 10 },
|
|
10032
|
-
children: /* @__PURE__ */ (0,
|
|
10033
|
-
/* @__PURE__ */ (0,
|
|
10429
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(AnimatedZStack, { children: [
|
|
10430
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ContentRenderer, { page: pageOrOverridingPage }),
|
|
10034
10431
|
modalStack.map((modal) => {
|
|
10035
|
-
return /* @__PURE__ */ (0,
|
|
10432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ModalRenderer, { modal }, modal.modal);
|
|
10036
10433
|
})
|
|
10037
10434
|
] })
|
|
10038
10435
|
}
|
|
@@ -10040,13 +10437,13 @@ var ContentSection = ({ overriddingPage }) => {
|
|
|
10040
10437
|
};
|
|
10041
10438
|
|
|
10042
10439
|
// src/components/CofheFloatingButton/ToastsSection.tsx
|
|
10043
|
-
var
|
|
10044
|
-
var
|
|
10045
|
-
var
|
|
10440
|
+
var import_react62 = require("react");
|
|
10441
|
+
var import_react63 = require("motion/react");
|
|
10442
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
10046
10443
|
var ToastClearer = ({ id, paused, remainingMs }) => {
|
|
10047
10444
|
const { removeToast } = usePortalToasts();
|
|
10048
|
-
const timerRef = (0,
|
|
10049
|
-
(0,
|
|
10445
|
+
const timerRef = (0, import_react62.useRef)(null);
|
|
10446
|
+
(0, import_react62.useEffect)(() => {
|
|
10050
10447
|
if (remainingMs <= 0) {
|
|
10051
10448
|
removeToast(id);
|
|
10052
10449
|
return;
|
|
@@ -10082,7 +10479,7 @@ var ToastComponent = ({
|
|
|
10082
10479
|
const handleDismiss = () => {
|
|
10083
10480
|
removeToast(id);
|
|
10084
10481
|
};
|
|
10085
|
-
const injectedContent = (0,
|
|
10482
|
+
const injectedContent = (0, import_react62.isValidElement)(content) ? (0, import_react62.cloneElement)(content, {
|
|
10086
10483
|
id,
|
|
10087
10484
|
paused,
|
|
10088
10485
|
startMs,
|
|
@@ -10092,8 +10489,8 @@ var ToastComponent = ({
|
|
|
10092
10489
|
onDismiss: handleDismiss,
|
|
10093
10490
|
...content.props
|
|
10094
10491
|
}) : content;
|
|
10095
|
-
return /* @__PURE__ */ (0,
|
|
10096
|
-
|
|
10492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
10493
|
+
import_react63.motion.div,
|
|
10097
10494
|
{
|
|
10098
10495
|
initial: { opacity: 0, y: isTopSide ? -4 : 4 },
|
|
10099
10496
|
animate: { opacity: 1, y: 0 },
|
|
@@ -10102,7 +10499,7 @@ var ToastComponent = ({
|
|
|
10102
10499
|
className: cn("min-h-8 bg-white border items-center justify-start w-full max-w-full"),
|
|
10103
10500
|
children: [
|
|
10104
10501
|
injectedContent,
|
|
10105
|
-
duration != "infinite" && /* @__PURE__ */ (0,
|
|
10502
|
+
duration != "infinite" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ToastClearer, { id, paused, remainingMs })
|
|
10106
10503
|
]
|
|
10107
10504
|
},
|
|
10108
10505
|
id
|
|
@@ -10110,11 +10507,11 @@ var ToastComponent = ({
|
|
|
10110
10507
|
};
|
|
10111
10508
|
var ToastsSection = () => {
|
|
10112
10509
|
const { toasts } = usePortalToasts();
|
|
10113
|
-
return /* @__PURE__ */ (0,
|
|
10510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "flex flex-col gap-3 w-full max-w-full", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_react63.AnimatePresence, { children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ToastComponent, { ...toast }, toast.id)) }) });
|
|
10114
10511
|
};
|
|
10115
10512
|
|
|
10116
10513
|
// src/components/CofheFloatingButton/CofheFloatingButtonBase.tsx
|
|
10117
|
-
var
|
|
10514
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
10118
10515
|
var positionStyles = {
|
|
10119
10516
|
"top-left": "top-4 left-4",
|
|
10120
10517
|
"top-right": "top-4 right-4",
|
|
@@ -10133,7 +10530,7 @@ var CofheFloatingButtonBase = ({
|
|
|
10133
10530
|
const { clearAllModals } = usePortalModals();
|
|
10134
10531
|
const { clearNavigationHistory } = usePortalNavigation();
|
|
10135
10532
|
const darkMode = theme === "dark";
|
|
10136
|
-
return /* @__PURE__ */ (0,
|
|
10533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
|
|
10137
10534
|
"div",
|
|
10138
10535
|
{
|
|
10139
10536
|
"data-testid": testId,
|
|
@@ -10149,10 +10546,10 @@ var CofheFloatingButtonBase = ({
|
|
|
10149
10546
|
className
|
|
10150
10547
|
),
|
|
10151
10548
|
children: [
|
|
10152
|
-
/* @__PURE__ */ (0,
|
|
10153
|
-
/* @__PURE__ */ (0,
|
|
10154
|
-
/* @__PURE__ */ (0,
|
|
10155
|
-
/* @__PURE__ */ (0,
|
|
10549
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ToastsSection, {}),
|
|
10550
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ContentSection, { overriddingPage }),
|
|
10551
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: cn("flex w-full gap-3 items-center", isLeftSide ? "flex-row" : "flex-row-reverse"), children: [
|
|
10552
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
10156
10553
|
FloatingButtonComponent,
|
|
10157
10554
|
{
|
|
10158
10555
|
onClick: () => togglePortal({
|
|
@@ -10163,7 +10560,7 @@ var CofheFloatingButtonBase = ({
|
|
|
10163
10560
|
})
|
|
10164
10561
|
}
|
|
10165
10562
|
),
|
|
10166
|
-
/* @__PURE__ */ (0,
|
|
10563
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(StatusBarSection, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(StatusBarContent, {}) })
|
|
10167
10564
|
] })
|
|
10168
10565
|
]
|
|
10169
10566
|
}
|
|
@@ -10171,10 +10568,10 @@ var CofheFloatingButtonBase = ({
|
|
|
10171
10568
|
};
|
|
10172
10569
|
|
|
10173
10570
|
// src/components/CofheFloatingButton/CofheFloatingButton.tsx
|
|
10174
|
-
var
|
|
10571
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
10175
10572
|
var CofheFloatingButtonWithProvider = (props) => {
|
|
10176
|
-
return /* @__PURE__ */ (0,
|
|
10177
|
-
/* @__PURE__ */ (0,
|
|
10573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(CofheFloatingButtonProvider, { children: [
|
|
10574
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CofheFloatingButtonBase, { ...props }),
|
|
10178
10575
|
props.children
|
|
10179
10576
|
] });
|
|
10180
10577
|
};
|
|
@@ -10183,7 +10580,7 @@ var CofheFloatingButtonWithProvider = (props) => {
|
|
|
10183
10580
|
var import_zod = require("zod");
|
|
10184
10581
|
var import_sdk10 = require("@cofhe/sdk");
|
|
10185
10582
|
var import_web2 = require("@cofhe/sdk/web");
|
|
10186
|
-
var
|
|
10583
|
+
var import_viem28 = require("viem");
|
|
10187
10584
|
var noopCofheReactLoggerMethod2 = (..._args) => {
|
|
10188
10585
|
};
|
|
10189
10586
|
var NOOP_COFHE_REACT_LOGGER = {
|
|
@@ -10209,11 +10606,11 @@ function resolveCofheReactLogger(logger) {
|
|
|
10209
10606
|
var CofheReactLoggerSchema = import_zod.z.custom((value) => value === null || typeof value === "object" && value !== null, {
|
|
10210
10607
|
error: "Invalid logger"
|
|
10211
10608
|
}).optional().default(null).transform((value) => resolveCofheReactLogger(value));
|
|
10212
|
-
var addressSchema = import_zod.z.string().refine((val) => (0,
|
|
10609
|
+
var addressSchema = import_zod.z.string().refine((val) => (0, import_viem28.isAddress)(val), {
|
|
10213
10610
|
error: "Invalid address"
|
|
10214
|
-
}).refine((val) => val !==
|
|
10611
|
+
}).refine((val) => val !== import_viem28.zeroAddress, {
|
|
10215
10612
|
error: "Must not be zeroAddress"
|
|
10216
|
-
}).transform((val) => (0,
|
|
10613
|
+
}).transform((val) => (0, import_viem28.getAddress)(val));
|
|
10217
10614
|
var CofheReactConfigSchema = import_zod.z.object({
|
|
10218
10615
|
shareablePermits: import_zod.z.boolean().optional().default(false),
|
|
10219
10616
|
enableShieldUnshield: import_zod.z.boolean().optional().default(true),
|
|
@@ -10259,11 +10656,11 @@ function createCofheConfig(config) {
|
|
|
10259
10656
|
// src/providers/CofheProvider.tsx
|
|
10260
10657
|
var import_chains5 = require("@cofhe/sdk/chains");
|
|
10261
10658
|
var import_ts_essentials25 = __toESM(require_dist(), 1);
|
|
10262
|
-
var
|
|
10263
|
-
var CofheContext = (0,
|
|
10659
|
+
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
10660
|
+
var CofheContext = (0, import_react64.createContext)(void 0);
|
|
10264
10661
|
function CofheProvider(props) {
|
|
10265
10662
|
const { children, queryClient, publicClient, walletClient } = props;
|
|
10266
|
-
const config = (0,
|
|
10663
|
+
const config = (0, import_react64.useMemo)(() => {
|
|
10267
10664
|
if (props.config) return props.config;
|
|
10268
10665
|
if (props.cofheClient) {
|
|
10269
10666
|
(0, import_ts_essentials25.assert)(props.cofheClient.config.environment === "react", "Provided cofheClient must have react config");
|
|
@@ -10271,10 +10668,10 @@ function CofheProvider(props) {
|
|
|
10271
10668
|
}
|
|
10272
10669
|
return createCofheConfig({ supportedChains: Object.values(import_chains5.chains) });
|
|
10273
10670
|
}, [props.config, props.cofheClient]);
|
|
10274
|
-
const cofheClient = (0,
|
|
10275
|
-
const [position, setPosition] = (0,
|
|
10276
|
-
const [theme, setTheme] = (0,
|
|
10277
|
-
return /* @__PURE__ */ (0,
|
|
10671
|
+
const cofheClient = (0, import_react64.useMemo)(() => props.cofheClient ?? (0, import_web3.createCofheClient)(config), [props.cofheClient, config]);
|
|
10672
|
+
const [position, setPosition] = (0, import_react64.useState)(config.react.position);
|
|
10673
|
+
const [theme, setTheme] = (0, import_react64.useState)(config.react.initialTheme);
|
|
10674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
10278
10675
|
CofheContext.Provider,
|
|
10279
10676
|
{
|
|
10280
10677
|
value: {
|
|
@@ -10286,9 +10683,9 @@ function CofheProvider(props) {
|
|
|
10286
10683
|
setTheme
|
|
10287
10684
|
}
|
|
10288
10685
|
},
|
|
10289
|
-
children: /* @__PURE__ */ (0,
|
|
10290
|
-
/* @__PURE__ */ (0,
|
|
10291
|
-
/* @__PURE__ */ (0,
|
|
10686
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(QueryProvider, { queryClient, children: [
|
|
10687
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(AutoConnect, { walletClient, publicClient }),
|
|
10688
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(CofheFloatingButtonWithProvider, { children })
|
|
10292
10689
|
] })
|
|
10293
10690
|
}
|
|
10294
10691
|
);
|
|
@@ -10298,7 +10695,7 @@ function AutoConnect({ walletClient, publicClient }) {
|
|
|
10298
10695
|
return null;
|
|
10299
10696
|
}
|
|
10300
10697
|
function useCofheContext() {
|
|
10301
|
-
const context = (0,
|
|
10698
|
+
const context = (0, import_react64.useContext)(CofheContext);
|
|
10302
10699
|
if (context === void 0) {
|
|
10303
10700
|
throw new Error("useCofheContext must be used within a CofheProvider");
|
|
10304
10701
|
}
|
|
@@ -10306,9 +10703,9 @@ function useCofheContext() {
|
|
|
10306
10703
|
}
|
|
10307
10704
|
|
|
10308
10705
|
// src/components/CofheEncryptInput.tsx
|
|
10309
|
-
var
|
|
10706
|
+
var import_react65 = require("react");
|
|
10310
10707
|
var import_sdk11 = require("@cofhe/sdk");
|
|
10311
|
-
var
|
|
10708
|
+
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
10312
10709
|
var CofheEncryptInput = ({
|
|
10313
10710
|
className,
|
|
10314
10711
|
testId,
|
|
@@ -10328,30 +10725,30 @@ var CofheEncryptInput = ({
|
|
|
10328
10725
|
onEncryptComplete,
|
|
10329
10726
|
onEncryptError
|
|
10330
10727
|
}) => {
|
|
10331
|
-
const [textValue, setTextValue] = (0,
|
|
10332
|
-
const [selectedType, setSelectedType] = (0,
|
|
10333
|
-
const [isDropdownOpen, setIsDropdownOpen] = (0,
|
|
10334
|
-
const [showProgress, setShowProgress] = (0,
|
|
10335
|
-
const [encryptedResult, setEncryptedResult] = (0,
|
|
10336
|
-
const [copySuccess, setCopySuccess] = (0,
|
|
10337
|
-
const dropdownRef = (0,
|
|
10728
|
+
const [textValue, setTextValue] = (0, import_react65.useState)(initialValue);
|
|
10729
|
+
const [selectedType, setSelectedType] = (0, import_react65.useState)(options[0]?.value || "uint32");
|
|
10730
|
+
const [isDropdownOpen, setIsDropdownOpen] = (0, import_react65.useState)(false);
|
|
10731
|
+
const [showProgress, setShowProgress] = (0, import_react65.useState)(false);
|
|
10732
|
+
const [encryptedResult, setEncryptedResult] = (0, import_react65.useState)(null);
|
|
10733
|
+
const [copySuccess, setCopySuccess] = (0, import_react65.useState)(false);
|
|
10734
|
+
const dropdownRef = (0, import_react65.useRef)(null);
|
|
10338
10735
|
const {
|
|
10339
10736
|
encryptInputsAsync: encrypt,
|
|
10340
10737
|
isEncrypting,
|
|
10341
10738
|
stepsState: { lastStep: lastEncryptionStep }
|
|
10342
10739
|
} = useCofheEncrypt();
|
|
10343
|
-
const { progress: encryptionProgress, label: encryptionProgressLabel } = (0,
|
|
10740
|
+
const { progress: encryptionProgress, label: encryptionProgressLabel } = (0, import_react65.useMemo)(() => {
|
|
10344
10741
|
return lastEncryptionStep ? getStepConfig(lastEncryptionStep) : {
|
|
10345
10742
|
progress: void 0,
|
|
10346
10743
|
label: void 0
|
|
10347
10744
|
};
|
|
10348
10745
|
}, [lastEncryptionStep]);
|
|
10349
|
-
const debouncedValidation = (0,
|
|
10746
|
+
const debouncedValidation = (0, import_react65.useRef)(
|
|
10350
10747
|
debounce((value) => {
|
|
10351
10748
|
cofheLogger.log("Debounced validation for:", value);
|
|
10352
10749
|
}, debounceMs)
|
|
10353
10750
|
).current;
|
|
10354
|
-
(0,
|
|
10751
|
+
(0, import_react65.useEffect)(() => {
|
|
10355
10752
|
if (showProgressBar && isEncrypting) {
|
|
10356
10753
|
setShowProgress(true);
|
|
10357
10754
|
} else if (!isEncrypting) {
|
|
@@ -10359,7 +10756,7 @@ var CofheEncryptInput = ({
|
|
|
10359
10756
|
return () => clearTimeout(timer);
|
|
10360
10757
|
}
|
|
10361
10758
|
}, [showProgressBar, isEncrypting]);
|
|
10362
|
-
(0,
|
|
10759
|
+
(0, import_react65.useEffect)(() => {
|
|
10363
10760
|
if (isEncrypting && lastEncryptionStep && encryptionProgress && encryptionProgressLabel) {
|
|
10364
10761
|
onEncryptProgress?.({
|
|
10365
10762
|
step: lastEncryptionStep.step,
|
|
@@ -10368,7 +10765,7 @@ var CofheEncryptInput = ({
|
|
|
10368
10765
|
});
|
|
10369
10766
|
}
|
|
10370
10767
|
}, [encryptionProgress, encryptionProgressLabel, onEncryptProgress, isEncrypting, lastEncryptionStep]);
|
|
10371
|
-
(0,
|
|
10768
|
+
(0, import_react65.useEffect)(() => {
|
|
10372
10769
|
const handleClickOutside = (event) => {
|
|
10373
10770
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
10374
10771
|
setIsDropdownOpen(false);
|
|
@@ -10477,7 +10874,7 @@ var CofheEncryptInput = ({
|
|
|
10477
10874
|
setCopySuccess(false);
|
|
10478
10875
|
}, 2e3);
|
|
10479
10876
|
} catch (error) {
|
|
10480
|
-
|
|
10877
|
+
cofheLogger.error("Failed to copy to clipboard:", error);
|
|
10481
10878
|
}
|
|
10482
10879
|
};
|
|
10483
10880
|
const handleTypeSelect = async (type) => {
|
|
@@ -10496,13 +10893,13 @@ var CofheEncryptInput = ({
|
|
|
10496
10893
|
onEncryptComplete?.(data);
|
|
10497
10894
|
} catch (error) {
|
|
10498
10895
|
const errorMessage2 = error instanceof Error ? error.message : "Encryption failed";
|
|
10499
|
-
|
|
10896
|
+
cofheLogger.error("Encryption failed:", error);
|
|
10500
10897
|
onEncryptError?.(errorMessage2);
|
|
10501
10898
|
}
|
|
10502
10899
|
})();
|
|
10503
10900
|
} catch (error) {
|
|
10504
10901
|
const errorMessage2 = error instanceof Error ? error.message : "Encryption setup failed";
|
|
10505
|
-
|
|
10902
|
+
cofheLogger.error("Encryption setup failed:", error);
|
|
10506
10903
|
onEncryptError?.(errorMessage2);
|
|
10507
10904
|
}
|
|
10508
10905
|
}
|
|
@@ -10512,12 +10909,12 @@ var CofheEncryptInput = ({
|
|
|
10512
10909
|
setIsDropdownOpen(!isDropdownOpen);
|
|
10513
10910
|
}
|
|
10514
10911
|
};
|
|
10515
|
-
const ShieldIcon2 = () => /* @__PURE__ */ (0,
|
|
10516
|
-
const ChevronDownIcon = () => /* @__PURE__ */ (0,
|
|
10517
|
-
return /* @__PURE__ */ (0,
|
|
10518
|
-
/* @__PURE__ */ (0,
|
|
10519
|
-
/* @__PURE__ */ (0,
|
|
10520
|
-
/* @__PURE__ */ (0,
|
|
10912
|
+
const ShieldIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(SecurityIcon, { style: { fontSize: 14 } });
|
|
10913
|
+
const ChevronDownIcon = () => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(KeyboardArrowDownIcon, { style: { fontSize: 14 } });
|
|
10914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "w-full", children: [
|
|
10915
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "flex items-start gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex-1", children: [
|
|
10916
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: inputContainerClasses, "data-testid": testId, children: [
|
|
10917
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
10521
10918
|
"input",
|
|
10522
10919
|
{
|
|
10523
10920
|
type: "text",
|
|
@@ -10529,21 +10926,21 @@ var CofheEncryptInput = ({
|
|
|
10529
10926
|
"data-testid": testId ? `${testId}-input` : "cofhe-encrypt-input"
|
|
10530
10927
|
}
|
|
10531
10928
|
),
|
|
10532
|
-
(isEncrypting || encryptedResult) && /* @__PURE__ */ (0,
|
|
10929
|
+
(isEncrypting || encryptedResult) && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "absolute right-16 top-1/2 transform -translate-y-1/2", children: isEncrypting ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "bg-blue-500 px-2 py-1 text-xs text-white rounded animate-pulse", children: "Encrypting..." }) : encryptedResult ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
10533
10930
|
"button",
|
|
10534
10931
|
{
|
|
10535
10932
|
onClick: handleCopyResult,
|
|
10536
10933
|
disabled: copySuccess,
|
|
10537
10934
|
className: `px-2 py-1 text-xs text-white rounded flex items-center gap-1 transition-all duration-300 ${copySuccess ? "bg-green-600 cursor-default" : "bg-green-500 hover:bg-green-600"}`,
|
|
10538
10935
|
title: copySuccess ? "Copied to clipboard!" : "Copy encrypted result to clipboard",
|
|
10539
|
-
children: /* @__PURE__ */ (0,
|
|
10540
|
-
copySuccess ? /* @__PURE__ */ (0,
|
|
10936
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
10937
|
+
copySuccess ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CheckIcon, { style: { fontSize: 12 } }) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ContentCopyIcon, { style: { fontSize: 12 } }),
|
|
10541
10938
|
"Copy"
|
|
10542
10939
|
] })
|
|
10543
10940
|
}
|
|
10544
10941
|
) : null }),
|
|
10545
|
-
/* @__PURE__ */ (0,
|
|
10546
|
-
/* @__PURE__ */ (0,
|
|
10942
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "cofhe-dropdown-container", ref: dropdownRef, children: [
|
|
10943
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
10547
10944
|
"button",
|
|
10548
10945
|
{
|
|
10549
10946
|
type: "button",
|
|
@@ -10552,29 +10949,29 @@ var CofheEncryptInput = ({
|
|
|
10552
10949
|
disabled: disabled || isEncrypting,
|
|
10553
10950
|
"data-testid": testId ? `${testId}-type-selector` : "cofhe-type-selector",
|
|
10554
10951
|
children: [
|
|
10555
|
-
/* @__PURE__ */ (0,
|
|
10556
|
-
/* @__PURE__ */ (0,
|
|
10952
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ShieldIcon2, {}),
|
|
10953
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ChevronDownIcon, {})
|
|
10557
10954
|
]
|
|
10558
10955
|
}
|
|
10559
10956
|
),
|
|
10560
|
-
isDropdownOpen && /* @__PURE__ */ (0,
|
|
10957
|
+
isDropdownOpen && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "cofhe-dropdown-menu", children: options.map((option) => {
|
|
10561
10958
|
const isCompatible = isTypeCompatible(option.value, textValue);
|
|
10562
10959
|
const isSelected = option.value === selectedType;
|
|
10563
|
-
return /* @__PURE__ */ (0,
|
|
10960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
10564
10961
|
"div",
|
|
10565
10962
|
{
|
|
10566
10963
|
className: dropdownItemClasses(isSelected, isCompatible),
|
|
10567
10964
|
onClick: () => isCompatible && handleTypeSelect(option.value),
|
|
10568
10965
|
"data-testid": `${testId ? `${testId}-` : ""}type-option-${option.value}`,
|
|
10569
10966
|
title: !isCompatible ? `Value "${textValue}" is not compatible with ${option.label}` : void 0,
|
|
10570
|
-
children: /* @__PURE__ */ (0,
|
|
10967
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "font-mono", children: option.label })
|
|
10571
10968
|
},
|
|
10572
10969
|
option.value
|
|
10573
10970
|
);
|
|
10574
10971
|
}) })
|
|
10575
10972
|
] })
|
|
10576
10973
|
] }),
|
|
10577
|
-
showProgress && /* @__PURE__ */ (0,
|
|
10974
|
+
showProgress && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
10578
10975
|
"div",
|
|
10579
10976
|
{
|
|
10580
10977
|
className: "mt-3 overflow-hidden",
|
|
@@ -10583,14 +10980,14 @@ var CofheEncryptInput = ({
|
|
|
10583
10980
|
},
|
|
10584
10981
|
"data-testid": testId ? `${testId}-progress` : "cofhe-encrypt-progress",
|
|
10585
10982
|
children: [
|
|
10586
|
-
/* @__PURE__ */ (0,
|
|
10587
|
-
/* @__PURE__ */ (0,
|
|
10588
|
-
/* @__PURE__ */ (0,
|
|
10983
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex justify-between items-center mb-1", children: [
|
|
10984
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: encryptionProgressLabel || "Processing..." }),
|
|
10985
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
10589
10986
|
encryptionProgress || 0,
|
|
10590
10987
|
"%"
|
|
10591
10988
|
] })
|
|
10592
10989
|
] }),
|
|
10593
|
-
/* @__PURE__ */ (0,
|
|
10990
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: progressContainerClasses, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
10594
10991
|
"div",
|
|
10595
10992
|
{
|
|
10596
10993
|
className: progressBarClasses("primary"),
|
|
@@ -10605,7 +11002,7 @@ var CofheEncryptInput = ({
|
|
|
10605
11002
|
}
|
|
10606
11003
|
)
|
|
10607
11004
|
] }) }),
|
|
10608
|
-
hasError && errorMessage && /* @__PURE__ */ (0,
|
|
11005
|
+
hasError && errorMessage && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
10609
11006
|
"p",
|
|
10610
11007
|
{
|
|
10611
11008
|
className: "mt-2 text-sm text-red-600 dark:text-red-400",
|