@tokenops/sdk 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +158 -2
- package/SECURITY.md +7 -1
- package/dist/{chunk-67OV5CX2.cjs → chunk-2RNW4MIJ.cjs} +18 -0
- package/dist/{chunk-KLKI352M.cjs → chunk-43RFBQ73.cjs} +29 -29
- package/dist/{chunk-ZA673I3O.js → chunk-46T67CE2.js} +1 -1
- package/dist/{chunk-6BMP4ICG.js → chunk-4KJ66YRH.js} +61 -3
- package/dist/{chunk-JYOTGRSO.cjs → chunk-4ZCXK4VI.cjs} +68 -8
- package/dist/{chunk-SG65XWH7.js → chunk-6WSNS3UV.js} +1 -1
- package/dist/{chunk-V2PXZVBF.cjs → chunk-7G7UOQV4.cjs} +4 -4
- package/dist/{chunk-WENHUPZC.cjs → chunk-AYGRYDBX.cjs} +35 -36
- package/dist/{chunk-2NCLOQ56.cjs → chunk-BD4LZBVF.cjs} +85 -9
- package/dist/{chunk-5X5WL5CU.cjs → chunk-BK7YIVLK.cjs} +110 -149
- package/dist/{chunk-W7IGCOVL.cjs → chunk-CBRL2PJA.cjs} +12 -11
- package/dist/{chunk-ORFTDNFZ.js → chunk-CNP4L3GF.js} +4 -4
- package/dist/{chunk-QBJ7O2B4.js → chunk-DRSPMIZ7.js} +11 -1
- package/dist/{chunk-C7BRZXJA.cjs → chunk-EUKPOXWR.cjs} +15 -16
- package/dist/{chunk-YQIBBEFJ.js → chunk-HETNKZEE.js} +1 -1
- package/dist/{chunk-ODLTEGHB.js → chunk-KSDSXJ34.js} +1 -1
- package/dist/{chunk-TIUKIY5V.cjs → chunk-LBWRFZR3.cjs} +58 -40
- package/dist/{chunk-WMACINXO.js → chunk-NFW7AUEX.js} +1 -1
- package/dist/{chunk-4WPGQSNT.cjs → chunk-OL6SHN3D.cjs} +3 -3
- package/dist/{chunk-AOP6HMPW.js → chunk-PD7ME2BT.js} +75 -2
- package/dist/{chunk-2PWNH3UE.js → chunk-QET3Q4JP.js} +65 -9
- package/dist/{chunk-XGGTQQFH.js → chunk-QKKBBH7I.js} +2 -2
- package/dist/{chunk-6R4KNAPK.js → chunk-S2XD75JM.js} +10 -3
- package/dist/{chunk-MCRBVJGZ.cjs → chunk-SPGSO5SO.cjs} +29 -22
- package/dist/{chunk-FAXIIH5R.cjs → chunk-SYHNZSZZ.cjs} +3 -3
- package/dist/{chunk-IXLO7GO5.js → chunk-TN65XNTI.js} +47 -83
- package/dist/chunk-U57COLUE.js +56 -0
- package/dist/{chunk-DUZIIRPF.js → chunk-UE5XK2SY.js} +27 -9
- package/dist/{chunk-TEBM66WA.cjs → chunk-UJS4N2XM.cjs} +12 -12
- package/dist/{chunk-OXTLPTO3.js → chunk-V5D7BHW3.js} +4 -5
- package/dist/{chunk-NTZY6IB7.js → chunk-VHSNYUYV.js} +5 -4
- package/dist/{chunk-JK4XMMKM.cjs → chunk-VR3FREBX.cjs} +3 -3
- package/dist/{chunk-T46YXSBP.cjs → chunk-WO72UBQD.cjs} +11 -11
- package/dist/chunk-WOEETTH7.cjs +59 -0
- package/dist/{chunk-IJFQ5L4I.js → chunk-WTK6JDSI.js} +4 -5
- package/dist/{chunk-PUPKNW3R.cjs → chunk-WUXUWTFW.cjs} +3 -3
- package/dist/{chunk-PFXURMBZ.cjs → chunk-YFIWCYHC.cjs} +112 -54
- package/dist/{chunk-ZWXJTBZO.js → chunk-YPYCWLYP.js} +1 -1
- package/dist/core/addresses.d.ts +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/fhe/index.cjs +84 -64
- package/dist/fhe/index.d.cts +1 -0
- package/dist/fhe/index.d.ts +1 -0
- package/dist/fhe/index.js +21 -9
- package/dist/fhe/mock-erc7984.d.ts +4 -4
- package/dist/fhe/operators.d.ts +142 -2
- package/dist/fhe/react/index.cjs +21 -8
- package/dist/fhe/react/index.d.cts +2 -0
- package/dist/fhe/react/index.d.ts +2 -0
- package/dist/fhe/react/index.js +8 -3
- package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
- package/dist/fhe/react/useIsOperator.d.ts +54 -0
- package/dist/fhe/sepolia-encryptor-web.d.ts +18 -3
- package/dist/fhe-airdrop/advanced/index.cjs +8 -9
- package/dist/fhe-airdrop/advanced/index.js +6 -7
- package/dist/fhe-airdrop/advanced/react/index.cjs +13 -14
- package/dist/fhe-airdrop/advanced/react/index.js +9 -10
- package/dist/fhe-airdrop/airdrop.d.ts +7 -0
- package/dist/fhe-airdrop/index.cjs +66 -67
- package/dist/fhe-airdrop/index.js +7 -8
- package/dist/fhe-airdrop/react/index.cjs +148 -137
- package/dist/fhe-airdrop/react/index.d.cts +3 -1
- package/dist/fhe-airdrop/react/index.d.ts +3 -1
- package/dist/fhe-airdrop/react/index.js +16 -14
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +17 -11
- package/dist/fhe-airdrop/react/useClaim.d.ts +8 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +1 -1
- package/dist/fhe-airdrop/types.d.ts +14 -3
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +74 -67
- package/dist/fhe-disperse/index.d.cts +1 -1
- package/dist/fhe-disperse/index.d.ts +1 -1
- package/dist/fhe-disperse/index.js +8 -9
- package/dist/fhe-disperse/react/index.cjs +105 -88
- package/dist/fhe-disperse/react/index.d.cts +3 -1
- package/dist/fhe-disperse/react/index.d.ts +3 -1
- package/dist/fhe-disperse/react/index.js +12 -11
- package/dist/fhe-vesting/advanced/index.cjs +8 -9
- package/dist/fhe-vesting/advanced/index.js +6 -7
- package/dist/fhe-vesting/advanced/react/index.cjs +14 -15
- package/dist/fhe-vesting/advanced/react/index.js +11 -12
- package/dist/fhe-vesting/index.cjs +75 -76
- package/dist/fhe-vesting/index.js +9 -10
- package/dist/fhe-vesting/manager.d.ts +19 -0
- package/dist/fhe-vesting/react/index.cjs +245 -227
- package/dist/fhe-vesting/react/index.d.cts +6 -4
- package/dist/fhe-vesting/react/index.d.ts +6 -4
- package/dist/fhe-vesting/react/index.js +27 -21
- package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
- package/dist/fhe-vesting/types.d.ts +12 -1
- package/dist/index.cjs +87 -88
- package/dist/index.js +2 -3
- package/dist/testnet-faucet/index.cjs +55 -56
- package/dist/testnet-faucet/index.js +5 -6
- package/dist/testnet-faucet/react/index.cjs +53 -54
- package/dist/testnet-faucet/react/index.js +7 -8
- package/package.json +13 -8
- package/dist/chunk-66IHPTOK.cjs +0 -20
- package/dist/chunk-KWFFIJYX.js +0 -11
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
- package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
- package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
- package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
3
|
+
var chunkUJS4N2XM_cjs = require('./chunk-UJS4N2XM.cjs');
|
|
4
|
+
var chunkSYHNZSZZ_cjs = require('./chunk-SYHNZSZZ.cjs');
|
|
5
|
+
var chunk43RFBQ73_cjs = require('./chunk-43RFBQ73.cjs');
|
|
6
|
+
var chunkWUXUWTFW_cjs = require('./chunk-WUXUWTFW.cjs');
|
|
7
|
+
var chunkVR3FREBX_cjs = require('./chunk-VR3FREBX.cjs');
|
|
8
|
+
var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
|
|
8
9
|
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
9
|
-
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
10
|
-
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
11
10
|
var viem = require('viem');
|
|
12
11
|
|
|
13
12
|
// src/fhe-disperse/abis/singleton.ts
|
|
@@ -1689,7 +1688,7 @@ function resolveEncryptor(source) {
|
|
|
1689
1688
|
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
1690
1689
|
function assertUint64(value, label) {
|
|
1691
1690
|
if (value < 0n || value > MAX_UINT64) {
|
|
1692
|
-
throw new
|
|
1691
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1693
1692
|
method: "encryptUint64",
|
|
1694
1693
|
argument: label,
|
|
1695
1694
|
reason: "exceeds uint64 range (0..2^64-1)",
|
|
@@ -1710,7 +1709,7 @@ async function encryptUint64({
|
|
|
1710
1709
|
userAddress
|
|
1711
1710
|
});
|
|
1712
1711
|
if (handles.length !== 1) {
|
|
1713
|
-
throw new
|
|
1712
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1714
1713
|
method: "encryptUint64",
|
|
1715
1714
|
argument: "handles",
|
|
1716
1715
|
reason: `expected 1 handle, got ${handles.length}`,
|
|
@@ -1718,8 +1717,8 @@ async function encryptUint64({
|
|
|
1718
1717
|
});
|
|
1719
1718
|
}
|
|
1720
1719
|
return {
|
|
1721
|
-
handle:
|
|
1722
|
-
inputProof:
|
|
1720
|
+
handle: chunk2RNW4MIJ_cjs.asEncryptedHandle(viem.bytesToHex(handles[0])),
|
|
1721
|
+
inputProof: chunk2RNW4MIJ_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
1723
1722
|
};
|
|
1724
1723
|
}
|
|
1725
1724
|
async function encryptUint64Batch({
|
|
@@ -1729,7 +1728,7 @@ async function encryptUint64Batch({
|
|
|
1729
1728
|
values
|
|
1730
1729
|
}) {
|
|
1731
1730
|
if (values.length === 0) {
|
|
1732
|
-
throw new
|
|
1731
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1733
1732
|
method: "encryptUint64Batch",
|
|
1734
1733
|
argument: "values",
|
|
1735
1734
|
reason: "must be non-empty"
|
|
@@ -1742,7 +1741,7 @@ async function encryptUint64Batch({
|
|
|
1742
1741
|
userAddress
|
|
1743
1742
|
});
|
|
1744
1743
|
if (handles.length !== values.length) {
|
|
1745
|
-
throw new
|
|
1744
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1746
1745
|
method: "encryptUint64Batch",
|
|
1747
1746
|
argument: "handles",
|
|
1748
1747
|
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
@@ -1750,13 +1749,13 @@ async function encryptUint64Batch({
|
|
|
1750
1749
|
});
|
|
1751
1750
|
}
|
|
1752
1751
|
return {
|
|
1753
|
-
handles: handles.map((h) =>
|
|
1754
|
-
inputProof:
|
|
1752
|
+
handles: handles.map((h) => chunk2RNW4MIJ_cjs.asEncryptedHandle(viem.bytesToHex(h))),
|
|
1753
|
+
inputProof: chunk2RNW4MIJ_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
1755
1754
|
};
|
|
1756
1755
|
}
|
|
1757
1756
|
|
|
1758
1757
|
// src/fhe-disperse/errors.ts
|
|
1759
|
-
var NotRegisteredError = class extends
|
|
1758
|
+
var NotRegisteredError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
|
|
1760
1759
|
name = "NotRegisteredError";
|
|
1761
1760
|
constructor(args) {
|
|
1762
1761
|
super(
|
|
@@ -1773,7 +1772,45 @@ var NotRegisteredError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
|
|
|
1773
1772
|
);
|
|
1774
1773
|
}
|
|
1775
1774
|
};
|
|
1776
|
-
var
|
|
1775
|
+
var SubwalletsNotApprovedError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
|
|
1776
|
+
name = "SubwalletsNotApprovedError";
|
|
1777
|
+
constructor(args) {
|
|
1778
|
+
super(
|
|
1779
|
+
`${args.method}: sub-wallets are not fully approved for token ${args.token} \u2014 wallet0: ${args.wallet0Approved}, wallet1: ${args.wallet1Approved}. Call \`approveUserWalletsForToken\` first.`,
|
|
1780
|
+
{
|
|
1781
|
+
code: "TOKENOPS_SUBWALLETS_NOT_APPROVED",
|
|
1782
|
+
cause: args.cause,
|
|
1783
|
+
context: {
|
|
1784
|
+
method: args.method,
|
|
1785
|
+
contractAddress: args.contractAddress,
|
|
1786
|
+
user: args.user,
|
|
1787
|
+
token: args.token,
|
|
1788
|
+
wallet0Approved: args.wallet0Approved,
|
|
1789
|
+
wallet1Approved: args.wallet1Approved
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
);
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1795
|
+
var SingletonNotApprovedError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
|
|
1796
|
+
name = "SingletonNotApprovedError";
|
|
1797
|
+
constructor(args) {
|
|
1798
|
+
super(
|
|
1799
|
+
`${args.method}: ${args.user} has not approved the singleton ${args.contractAddress} as an operator on token ${args.token}. Call setOperator() (see @tokenops/sdk/fhe) before this transaction.`,
|
|
1800
|
+
{
|
|
1801
|
+
code: "TOKENOPS_SINGLETON_NOT_APPROVED",
|
|
1802
|
+
cause: args.cause,
|
|
1803
|
+
context: {
|
|
1804
|
+
method: args.method,
|
|
1805
|
+
contractAddress: args.contractAddress,
|
|
1806
|
+
user: args.user,
|
|
1807
|
+
token: args.token
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
var AlreadyRegisteredError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
|
|
1777
1814
|
name = "AlreadyRegisteredError";
|
|
1778
1815
|
constructor(args) {
|
|
1779
1816
|
super(
|
|
@@ -1810,7 +1847,7 @@ function validateDisperseInputs(args) {
|
|
|
1810
1847
|
const errors = [];
|
|
1811
1848
|
if (recipients.length === 0) {
|
|
1812
1849
|
errors.push(
|
|
1813
|
-
new
|
|
1850
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1814
1851
|
method,
|
|
1815
1852
|
argument: "recipients",
|
|
1816
1853
|
reason: "must be non-empty"
|
|
@@ -1819,7 +1856,7 @@ function validateDisperseInputs(args) {
|
|
|
1819
1856
|
}
|
|
1820
1857
|
if (amounts.length !== recipients.length) {
|
|
1821
1858
|
errors.push(
|
|
1822
|
-
new
|
|
1859
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1823
1860
|
method,
|
|
1824
1861
|
argument: "amounts",
|
|
1825
1862
|
reason: `length mismatch: recipients.length (${recipients.length}) !== amounts.length (${amounts.length})`
|
|
@@ -1829,7 +1866,7 @@ function validateDisperseInputs(args) {
|
|
|
1829
1866
|
recipients.forEach((r, i) => {
|
|
1830
1867
|
if (!viem.isAddress(r, { strict: true })) {
|
|
1831
1868
|
errors.push(
|
|
1832
|
-
new
|
|
1869
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1833
1870
|
method,
|
|
1834
1871
|
argument: `recipients[${i}]`,
|
|
1835
1872
|
reason: "must be a valid EIP-55 checksummed address",
|
|
@@ -1840,7 +1877,7 @@ function validateDisperseInputs(args) {
|
|
|
1840
1877
|
}
|
|
1841
1878
|
if (r === ZERO_ADDRESS) {
|
|
1842
1879
|
errors.push(
|
|
1843
|
-
new
|
|
1880
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1844
1881
|
method,
|
|
1845
1882
|
argument: `recipients[${i}]`,
|
|
1846
1883
|
reason: "zero address",
|
|
@@ -1852,7 +1889,7 @@ function validateDisperseInputs(args) {
|
|
|
1852
1889
|
amounts.forEach((v, i) => {
|
|
1853
1890
|
if (v < 0n || v > MAX_UINT642) {
|
|
1854
1891
|
errors.push(
|
|
1855
|
-
new
|
|
1892
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1856
1893
|
method,
|
|
1857
1894
|
argument: `amounts[${i}]`,
|
|
1858
1895
|
reason: "exceeds uint64 range (0..2^64-1)"
|
|
@@ -1866,7 +1903,7 @@ function validateDisperseInputs(args) {
|
|
|
1866
1903
|
const { group0, group1 } = computeSubtotals([...amounts]);
|
|
1867
1904
|
if (group0 > MAX_UINT642) {
|
|
1868
1905
|
errors.push(
|
|
1869
|
-
new
|
|
1906
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1870
1907
|
method,
|
|
1871
1908
|
argument: "amounts",
|
|
1872
1909
|
reason: "wallet-mode subtotal exceeds uint64 range"
|
|
@@ -1875,7 +1912,7 @@ function validateDisperseInputs(args) {
|
|
|
1875
1912
|
}
|
|
1876
1913
|
if (group1 > MAX_UINT642) {
|
|
1877
1914
|
errors.push(
|
|
1878
|
-
new
|
|
1915
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1879
1916
|
method,
|
|
1880
1917
|
argument: "amounts",
|
|
1881
1918
|
reason: "wallet-mode subtotal exceeds uint64 range"
|
|
@@ -1884,7 +1921,7 @@ function validateDisperseInputs(args) {
|
|
|
1884
1921
|
}
|
|
1885
1922
|
if (group0 <= MAX_UINT642 && group1 <= MAX_UINT642 && group0 + group1 > MAX_UINT642) {
|
|
1886
1923
|
errors.push(
|
|
1887
|
-
new
|
|
1924
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1888
1925
|
method,
|
|
1889
1926
|
argument: "amounts",
|
|
1890
1927
|
reason: "wallet-mode subtotals sum exceeds uint64 range (would silently zero on-chain)"
|
|
@@ -1894,7 +1931,7 @@ function validateDisperseInputs(args) {
|
|
|
1894
1931
|
}
|
|
1895
1932
|
if (batchLimit > 0n && BigInt(recipients.length) > batchLimit) {
|
|
1896
1933
|
errors.push(
|
|
1897
|
-
new
|
|
1934
|
+
new chunk2RNW4MIJ_cjs.BatchTooLargeError({
|
|
1898
1935
|
method,
|
|
1899
1936
|
contractAddress,
|
|
1900
1937
|
requested: recipients.length,
|
|
@@ -1907,7 +1944,7 @@ function validateDisperseInputs(args) {
|
|
|
1907
1944
|
function assertChecksumAddress(value, argument, method) {
|
|
1908
1945
|
if (value === void 0) return;
|
|
1909
1946
|
if (!viem.isAddress(value, { strict: true })) {
|
|
1910
|
-
throw new
|
|
1947
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1911
1948
|
method,
|
|
1912
1949
|
argument,
|
|
1913
1950
|
reason: "must be a valid EIP-55 checksummed address \u2014 use viem's getAddress(addr) to fix the checksum",
|
|
@@ -1919,7 +1956,7 @@ function assertNonZeroChecksumAddress(value, argument, method) {
|
|
|
1919
1956
|
if (value === void 0) return;
|
|
1920
1957
|
assertChecksumAddress(value, argument, method);
|
|
1921
1958
|
if (value === ZERO_ADDRESS) {
|
|
1922
|
-
throw new
|
|
1959
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1923
1960
|
method,
|
|
1924
1961
|
argument,
|
|
1925
1962
|
reason: "must not be the zero address",
|
|
@@ -1934,7 +1971,7 @@ function batchLimitForMode(mode, limits) {
|
|
|
1934
1971
|
}
|
|
1935
1972
|
|
|
1936
1973
|
// src/fhe-disperse/types.ts
|
|
1937
|
-
var DisperseSubwalletNotFoundError = class extends
|
|
1974
|
+
var DisperseSubwalletNotFoundError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
|
|
1938
1975
|
name = "DisperseSubwalletNotFoundError";
|
|
1939
1976
|
constructor(txHash, singletonAddress) {
|
|
1940
1977
|
super(
|
|
@@ -1946,7 +1983,7 @@ var DisperseSubwalletNotFoundError = class extends chunk67OV5CX2_cjs.TokenOpsSdk
|
|
|
1946
1983
|
);
|
|
1947
1984
|
}
|
|
1948
1985
|
};
|
|
1949
|
-
var DisperseEncryptedReserveNotGrantedError = class extends
|
|
1986
|
+
var DisperseEncryptedReserveNotGrantedError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
|
|
1950
1987
|
name = "DisperseEncryptedReserveNotGrantedError";
|
|
1951
1988
|
constructor(txHash, callerAddress) {
|
|
1952
1989
|
super(
|
|
@@ -1968,7 +2005,7 @@ var disperseProductMapper = (name, _args, ctx) => {
|
|
|
1968
2005
|
case "UserNotRegistered":
|
|
1969
2006
|
return new NotRegisteredError({ ...ctx, user });
|
|
1970
2007
|
case "ContractNotAllowed":
|
|
1971
|
-
return new
|
|
2008
|
+
return new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1972
2009
|
method: ctx.method,
|
|
1973
2010
|
argument: "handle",
|
|
1974
2011
|
reason: "the handle's origin contract did not grant this singleton persistent ACL on the handle. ERC-7984 `transferred` handles are scoped to the token contract \u2014 disclose them through the token, not through `DisperseConfidential`."
|
|
@@ -2012,10 +2049,10 @@ var ConfidentialDisperseClient = class {
|
|
|
2012
2049
|
this.encryptor = config.encryptor;
|
|
2013
2050
|
this.#telemetry = config.telemetry;
|
|
2014
2051
|
const chainId = config.chainId ?? config.publicClient.chain?.id;
|
|
2015
|
-
const addressOverride = config.address ?
|
|
2016
|
-
const resolved = addressOverride ?? (chainId === void 0 ? void 0 :
|
|
2052
|
+
const addressOverride = config.address ? chunkVR3FREBX_cjs.normaliseAddress(config.address) : void 0;
|
|
2053
|
+
const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkWUXUWTFW_cjs.getFheDisperseSingletonAddress(chainId));
|
|
2017
2054
|
if (!resolved) {
|
|
2018
|
-
throw new
|
|
2055
|
+
throw new chunk2RNW4MIJ_cjs.DeploymentAddressUnavailableError({
|
|
2019
2056
|
reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
|
|
2020
2057
|
product: "fheDisperse",
|
|
2021
2058
|
contract: "disperseConfidentialSingleton",
|
|
@@ -2029,8 +2066,8 @@ var ConfidentialDisperseClient = class {
|
|
|
2029
2066
|
surface: "singleton",
|
|
2030
2067
|
chainId: chainId ?? null,
|
|
2031
2068
|
hasWallet: !!this.walletClient,
|
|
2032
|
-
aclResolved: !!config.aclAddress || chainId !== void 0 && !!
|
|
2033
|
-
sdkVersion:
|
|
2069
|
+
aclResolved: !!config.aclAddress || chainId !== void 0 && !!chunkSYHNZSZZ_cjs.getFhevmAclAddress(chainId),
|
|
2070
|
+
sdkVersion: chunk43RFBQ73_cjs.SDK_VERSION
|
|
2034
2071
|
});
|
|
2035
2072
|
}
|
|
2036
2073
|
/**
|
|
@@ -2041,7 +2078,7 @@ var ConfidentialDisperseClient = class {
|
|
|
2041
2078
|
*/
|
|
2042
2079
|
get aclAddress() {
|
|
2043
2080
|
if (this.#cachedAclAddress) return this.#cachedAclAddress;
|
|
2044
|
-
this.#cachedAclAddress = this.#aclAddressOverride ??
|
|
2081
|
+
this.#cachedAclAddress = this.#aclAddressOverride ?? chunkSYHNZSZZ_cjs.requireFhevmAclAddress(this.publicClient.chain?.id, "ConfidentialDisperseClient");
|
|
2045
2082
|
return this.#cachedAclAddress;
|
|
2046
2083
|
}
|
|
2047
2084
|
// ============================================================
|
|
@@ -2181,7 +2218,7 @@ var ConfidentialDisperseClient = class {
|
|
|
2181
2218
|
const fees = await this.getFees(args.user);
|
|
2182
2219
|
if (args.mode === "wallet-token-fee") {
|
|
2183
2220
|
if (args.totalTokens === void 0) {
|
|
2184
|
-
throw new
|
|
2221
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
2185
2222
|
method: "calculateFee",
|
|
2186
2223
|
argument: "totalTokens",
|
|
2187
2224
|
reason: "is required for wallet-token-fee mode"
|
|
@@ -2337,23 +2374,42 @@ var ConfidentialDisperseClient = class {
|
|
|
2337
2374
|
})
|
|
2338
2375
|
);
|
|
2339
2376
|
} else if (mode === "wallet" || mode === "wallet-token-fee") {
|
|
2340
|
-
if (!hasApprovedSubwallets.both)
|
|
2377
|
+
if (!hasApprovedSubwallets.both) {
|
|
2341
2378
|
blockers.push(
|
|
2342
2379
|
`Wallets not fully approved for token \u2014 wallet0: ${hasApprovedSubwallets.wallet0}, wallet1: ${hasApprovedSubwallets.wallet1}`
|
|
2343
2380
|
);
|
|
2381
|
+
blockerErrors.push(
|
|
2382
|
+
new SubwalletsNotApprovedError({
|
|
2383
|
+
method: "preflightDisperse",
|
|
2384
|
+
contractAddress: this.address,
|
|
2385
|
+
user: args.user,
|
|
2386
|
+
token: args.token,
|
|
2387
|
+
wallet0Approved: hasApprovedSubwallets.wallet0,
|
|
2388
|
+
wallet1Approved: hasApprovedSubwallets.wallet1
|
|
2389
|
+
})
|
|
2390
|
+
);
|
|
2391
|
+
}
|
|
2344
2392
|
}
|
|
2345
2393
|
if (mode === "direct" && hasApprovedSingleton === false) {
|
|
2346
2394
|
blockers.push("Sender has not approved the singleton as operator on the token");
|
|
2395
|
+
blockerErrors.push(
|
|
2396
|
+
new SingletonNotApprovedError({
|
|
2397
|
+
method: "preflightDisperse",
|
|
2398
|
+
contractAddress: this.address,
|
|
2399
|
+
user: args.user,
|
|
2400
|
+
token: args.token
|
|
2401
|
+
})
|
|
2402
|
+
);
|
|
2347
2403
|
}
|
|
2348
2404
|
if (isPaused) {
|
|
2349
2405
|
blockers.push("Singleton is paused");
|
|
2350
2406
|
blockerErrors.push(
|
|
2351
|
-
new
|
|
2407
|
+
new chunk2RNW4MIJ_cjs.PausedError({ method: "preflightDisperse", contractAddress: this.address })
|
|
2352
2408
|
);
|
|
2353
2409
|
}
|
|
2354
2410
|
if (callerBalance < fee.ethValue) {
|
|
2355
2411
|
blockerErrors.push(
|
|
2356
|
-
new
|
|
2412
|
+
new chunk2RNW4MIJ_cjs.InsufficientFeeError({
|
|
2357
2413
|
method: "preflightDisperse",
|
|
2358
2414
|
contractAddress: this.address,
|
|
2359
2415
|
feeKind: "gas",
|
|
@@ -2510,7 +2566,7 @@ var ConfidentialDisperseClient = class {
|
|
|
2510
2566
|
const account = this.#resolveAccount(wallet, args.account, "disperse");
|
|
2511
2567
|
const enc = resolveEncryptor(this.encryptor);
|
|
2512
2568
|
if (!enc) {
|
|
2513
|
-
throw new
|
|
2569
|
+
throw new chunk2RNW4MIJ_cjs.MissingEncryptorError("disperse", {
|
|
2514
2570
|
hint: "Pass `encryptor` to the call or the client config."
|
|
2515
2571
|
});
|
|
2516
2572
|
}
|
|
@@ -2605,7 +2661,7 @@ var ConfidentialDisperseClient = class {
|
|
|
2605
2661
|
const aclLogs = receipt.logs.filter(
|
|
2606
2662
|
(log) => log.address.toLowerCase() === this.aclAddress.toLowerCase()
|
|
2607
2663
|
);
|
|
2608
|
-
const events = viem.parseEventLogs({ abi: [
|
|
2664
|
+
const events = viem.parseEventLogs({ abi: [chunkSYHNZSZZ_cjs.ACL_ALLOWED_EVENT], logs: aclLogs });
|
|
2609
2665
|
const granted = events.filter(
|
|
2610
2666
|
(ev) => ev.args.account.toLowerCase() === callerAddress && ev.args.caller.toLowerCase() === this.address.toLowerCase()
|
|
2611
2667
|
);
|
|
@@ -2613,7 +2669,7 @@ var ConfidentialDisperseClient = class {
|
|
|
2613
2669
|
throw new DisperseEncryptedReserveNotGrantedError(hash, accountAddress(account));
|
|
2614
2670
|
}
|
|
2615
2671
|
if (granted.length > 1) {
|
|
2616
|
-
throw new
|
|
2672
|
+
throw new chunk2RNW4MIJ_cjs.ReceiptEventAmbiguousError({
|
|
2617
2673
|
method: "getEncryptedFeeReserve",
|
|
2618
2674
|
eventName: "Allowed",
|
|
2619
2675
|
contractAddress: this.aclAddress,
|
|
@@ -2965,7 +3021,7 @@ var ConfidentialDisperseClient = class {
|
|
|
2965
3021
|
values: amounts
|
|
2966
3022
|
});
|
|
2967
3023
|
} catch (err) {
|
|
2968
|
-
throw
|
|
3024
|
+
throw chunkUJS4N2XM_cjs.mapZamaError(err, { method: "disperse[direct]", operation: "encrypt" });
|
|
2969
3025
|
}
|
|
2970
3026
|
let ethValue = gasFeeOverride;
|
|
2971
3027
|
if (ethValue === void 0) {
|
|
@@ -3011,7 +3067,7 @@ var ConfidentialDisperseClient = class {
|
|
|
3011
3067
|
values: allValues
|
|
3012
3068
|
});
|
|
3013
3069
|
} catch (err) {
|
|
3014
|
-
throw
|
|
3070
|
+
throw chunkUJS4N2XM_cjs.mapZamaError(err, { method: `disperse[${mode}]`, operation: "encrypt" });
|
|
3015
3071
|
}
|
|
3016
3072
|
const amountHandles = encrypted.handles.slice(0, count);
|
|
3017
3073
|
const subtotal0Handle = encrypted.handles[count];
|
|
@@ -3138,14 +3194,14 @@ var ConfidentialDisperseClient = class {
|
|
|
3138
3194
|
const hasAmount = amount !== void 0;
|
|
3139
3195
|
const hasInput = preEncrypted !== void 0;
|
|
3140
3196
|
if (hasAmount && hasInput) {
|
|
3141
|
-
throw new
|
|
3197
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
3142
3198
|
method,
|
|
3143
3199
|
argument: "amount/encryptedInput",
|
|
3144
3200
|
reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got both"
|
|
3145
3201
|
});
|
|
3146
3202
|
}
|
|
3147
3203
|
if (!hasAmount && !hasInput) {
|
|
3148
|
-
throw new
|
|
3204
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
3149
3205
|
method,
|
|
3150
3206
|
argument: "amount/encryptedInput",
|
|
3151
3207
|
reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got neither"
|
|
@@ -3154,7 +3210,7 @@ var ConfidentialDisperseClient = class {
|
|
|
3154
3210
|
if (hasInput) return preEncrypted;
|
|
3155
3211
|
const enc = encryptor ?? resolveEncryptor(this.encryptor);
|
|
3156
3212
|
if (!enc) {
|
|
3157
|
-
throw new
|
|
3213
|
+
throw new chunk2RNW4MIJ_cjs.MissingEncryptorError("encryptSingle", {
|
|
3158
3214
|
hint: "Pass `encryptor` to the call or the client config (eager or lazy factory)."
|
|
3159
3215
|
});
|
|
3160
3216
|
}
|
|
@@ -3166,19 +3222,19 @@ var ConfidentialDisperseClient = class {
|
|
|
3166
3222
|
value: amount
|
|
3167
3223
|
});
|
|
3168
3224
|
} catch (err) {
|
|
3169
|
-
throw
|
|
3225
|
+
throw chunkUJS4N2XM_cjs.mapZamaError(err, { method: "encryptSingle", operation: "encrypt" });
|
|
3170
3226
|
}
|
|
3171
3227
|
}
|
|
3172
3228
|
#requireWallet(method) {
|
|
3173
3229
|
if (!this.walletClient) {
|
|
3174
|
-
throw new
|
|
3230
|
+
throw new chunk2RNW4MIJ_cjs.MissingWalletClientError(method);
|
|
3175
3231
|
}
|
|
3176
3232
|
return this.walletClient;
|
|
3177
3233
|
}
|
|
3178
3234
|
#resolveAccount(wallet, override, method) {
|
|
3179
3235
|
const acct = override ?? wallet.account;
|
|
3180
3236
|
if (!acct) {
|
|
3181
|
-
throw new
|
|
3237
|
+
throw new chunk2RNW4MIJ_cjs.MissingAccountError(method);
|
|
3182
3238
|
}
|
|
3183
3239
|
return acct;
|
|
3184
3240
|
}
|
|
@@ -3231,13 +3287,13 @@ var ConfidentialDisperseClient = class {
|
|
|
3231
3287
|
...value !== void 0 ? { value } : {}
|
|
3232
3288
|
});
|
|
3233
3289
|
} catch (err) {
|
|
3234
|
-
if (
|
|
3290
|
+
if (chunk43RFBQ73_cjs.isContractRevert(err)) {
|
|
3235
3291
|
throw this.#mapRevert(method, err, productContext, accountAddress(account));
|
|
3236
3292
|
}
|
|
3237
3293
|
}
|
|
3238
3294
|
}
|
|
3239
3295
|
#mapRevert(method, err, productContext, account) {
|
|
3240
|
-
return
|
|
3296
|
+
return chunk43RFBQ73_cjs.mapContractRevert(err, {
|
|
3241
3297
|
method,
|
|
3242
3298
|
contractAddress: this.address,
|
|
3243
3299
|
abi: disperseConfidentialAbi,
|
|
@@ -3425,6 +3481,8 @@ exports.FEE_COLLECTOR_ROLE = FEE_COLLECTOR_ROLE;
|
|
|
3425
3481
|
exports.FEE_MANAGER_ROLE = FEE_MANAGER_ROLE;
|
|
3426
3482
|
exports.NotRegisteredError = NotRegisteredError;
|
|
3427
3483
|
exports.PAUSER_ROLE = PAUSER_ROLE;
|
|
3484
|
+
exports.SingletonNotApprovedError = SingletonNotApprovedError;
|
|
3485
|
+
exports.SubwalletsNotApprovedError = SubwalletsNotApprovedError;
|
|
3428
3486
|
exports.WITHDRAWER_ROLE = WITHDRAWER_ROLE;
|
|
3429
3487
|
exports.computeSubtotals = computeSubtotals;
|
|
3430
3488
|
exports.createConfidentialDisperseClient = createConfidentialDisperseClient;
|
package/dist/core/addresses.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { Address } from "viem";
|
|
|
10
10
|
export declare const DEPLOYED_ADDRESSES: {
|
|
11
11
|
readonly fheVesting: {
|
|
12
12
|
readonly confidentialVestingFactory: {
|
|
13
|
-
readonly 11155111: "
|
|
13
|
+
readonly 11155111: "0x059d6Bb8ff9a13E794fe416d4757d7310CdC69ab";
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
readonly fheAirdrop: {
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare const TOKENOPS_SDK_ERROR_BRAND: unique symbol;
|
|
|
12
12
|
* on `error.code` in `onError` handlers and UI surfaces. Messages stay
|
|
13
13
|
* human-readable and may evolve between versions.
|
|
14
14
|
*/
|
|
15
|
-
export type TokenOpsSdkErrorCode = "TOKENOPS_UNSUPPORTED_CHAIN" | "TOKENOPS_DEPLOYMENT_ADDRESS_UNAVAILABLE" | "TOKENOPS_MISSING_PUBLIC_CLIENT" | "TOKENOPS_MISSING_WALLET_CLIENT" | "TOKENOPS_MISSING_ACCOUNT" | "TOKENOPS_MISSING_ENCRYPTOR" | "TOKENOPS_MISSING_CLIENT" | "TOKENOPS_INVALID_ARGUMENT" | "TOKENOPS_RECEIPT_EVENT_NOT_FOUND" | "TOKENOPS_RECEIPT_EVENT_AMBIGUOUS" | "TOKENOPS_CONTRACT_REVERT" | "TOKENOPS_PAUSED" | "TOKENOPS_ACCESS_DENIED" | "TOKENOPS_OPERATOR_NOT_APPROVED" | "TOKENOPS_INSUFFICIENT_FEE" | "TOKENOPS_INSUFFICIENT_BALANCE" | "TOKENOPS_BATCH_TOO_LARGE" | "TOKENOPS_FEATURE_DISABLED" | "TOKENOPS_TRANSFER_FAILED" | "TOKENOPS_FHE_HANDLE_NOT_ALLOWED" | "TOKENOPS_ALREADY_INITIALIZED" | "TOKENOPS_REENTRANCY" | "TOKENOPS_INVALID_SIGNATURE" | "TOKENOPS_WALLET_REJECTED" | "TOKENOPS_WALLET_CHAIN_MISMATCH" | "TOKENOPS_NETWORK_ERROR" | "TOKENOPS_INSUFFICIENT_GAS_FUNDS" | "TOKENOPS_UNKNOWN_WRITE_FAILURE" | "TOKENOPS_USER_REJECTED" | "TOKENOPS_SIGNING_FAILED" | "TOKENOPS_RELAYER_UNREACHABLE" | "TOKENOPS_ENCRYPTION_FAILED" | "TOKENOPS_DECRYPTION_FAILED" | "TOKENOPS_USER_DECRYPT_NOT_ALLOWED" | "TOKENOPS_VESTING_NOT_FOUND" | "TOKENOPS_NOT_RECIPIENT" | "TOKENOPS_CLAIM_LOCKED" | "TOKENOPS_VESTING_REVOKED" | "TOKENOPS_NOT_REVOCABLE" | "TOKENOPS_VESTING_EXPIRED" | "TOKENOPS_TRANSFER_ALREADY_PENDING" | "TOKENOPS_NO_PENDING_TRANSFER" | "TOKENOPS_NOT_PENDING_RECIPIENT" | "TOKENOPS_TRANSFER_EXPIRED" | "TOKENOPS_ALREADY_CLAIMED" | "TOKENOPS_CLAIM_NOT_STARTED" | "TOKENOPS_CLAIM_WINDOW_CLOSED" | "TOKENOPS_NOT_REGISTERED" | "TOKENOPS_ALREADY_REGISTERED" | "TOKENOPS_FAUCET_SUPPLY_EXHAUSTED";
|
|
15
|
+
export type TokenOpsSdkErrorCode = "TOKENOPS_UNSUPPORTED_CHAIN" | "TOKENOPS_DEPLOYMENT_ADDRESS_UNAVAILABLE" | "TOKENOPS_MISSING_PUBLIC_CLIENT" | "TOKENOPS_MISSING_WALLET_CLIENT" | "TOKENOPS_MISSING_ACCOUNT" | "TOKENOPS_MISSING_ENCRYPTOR" | "TOKENOPS_MISSING_CLIENT" | "TOKENOPS_INVALID_ARGUMENT" | "TOKENOPS_RECEIPT_EVENT_NOT_FOUND" | "TOKENOPS_RECEIPT_EVENT_AMBIGUOUS" | "TOKENOPS_CONTRACT_REVERT" | "TOKENOPS_PAUSED" | "TOKENOPS_ACCESS_DENIED" | "TOKENOPS_OPERATOR_NOT_APPROVED" | "TOKENOPS_INSUFFICIENT_FEE" | "TOKENOPS_INSUFFICIENT_BALANCE" | "TOKENOPS_BATCH_TOO_LARGE" | "TOKENOPS_FEATURE_DISABLED" | "TOKENOPS_TRANSFER_FAILED" | "TOKENOPS_FHE_HANDLE_NOT_ALLOWED" | "TOKENOPS_ALREADY_INITIALIZED" | "TOKENOPS_REENTRANCY" | "TOKENOPS_INVALID_SIGNATURE" | "TOKENOPS_WALLET_REJECTED" | "TOKENOPS_WALLET_CHAIN_MISMATCH" | "TOKENOPS_NETWORK_ERROR" | "TOKENOPS_INSUFFICIENT_GAS_FUNDS" | "TOKENOPS_UNKNOWN_WRITE_FAILURE" | "TOKENOPS_USER_REJECTED" | "TOKENOPS_SIGNING_FAILED" | "TOKENOPS_RELAYER_UNREACHABLE" | "TOKENOPS_ENCRYPTION_FAILED" | "TOKENOPS_DECRYPTION_FAILED" | "TOKENOPS_USER_DECRYPT_NOT_ALLOWED" | "TOKENOPS_VESTING_NOT_FOUND" | "TOKENOPS_NOT_RECIPIENT" | "TOKENOPS_CLAIM_LOCKED" | "TOKENOPS_VESTING_REVOKED" | "TOKENOPS_NOT_REVOCABLE" | "TOKENOPS_VESTING_EXPIRED" | "TOKENOPS_TRANSFER_ALREADY_PENDING" | "TOKENOPS_NO_PENDING_TRANSFER" | "TOKENOPS_NOT_PENDING_RECIPIENT" | "TOKENOPS_TRANSFER_EXPIRED" | "TOKENOPS_ALREADY_CLAIMED" | "TOKENOPS_CLAIM_NOT_STARTED" | "TOKENOPS_CLAIM_WINDOW_CLOSED" | "TOKENOPS_NOT_REGISTERED" | "TOKENOPS_ALREADY_REGISTERED" | "TOKENOPS_SUBWALLETS_NOT_APPROVED" | "TOKENOPS_SINGLETON_NOT_APPROVED" | "TOKENOPS_FAUCET_SUPPLY_EXHAUSTED";
|
|
16
16
|
export interface TokenOpsSdkErrorInit {
|
|
17
17
|
code: TokenOpsSdkErrorCode;
|
|
18
18
|
cause?: unknown;
|