@tokenops/sdk 1.6.0 → 2.0.0-alpha.1
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 +48 -8
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SUPPORT.md +47 -0
- package/dist/{chunk-HETNKZEE.js → chunk-335Z2W67.js} +1 -1
- package/dist/{chunk-BD4LZBVF.cjs → chunk-3QHNYEQD.cjs} +18 -17
- package/dist/chunk-456VDDA3.js +370 -0
- package/dist/{chunk-6WSNS3UV.js → chunk-4RAAATVY.js} +2 -4
- package/dist/{chunk-4KJ66YRH.js → chunk-4TSDNZQ3.js} +2 -2
- package/dist/{chunk-WUXUWTFW.cjs → chunk-5576FRT3.cjs} +31 -7
- package/dist/chunk-66IHPTOK.cjs +20 -0
- package/dist/{chunk-2RNW4MIJ.cjs → chunk-67OV5CX2.cjs} +0 -18
- package/dist/{chunk-PD7ME2BT.js → chunk-6GNR22OV.js} +2 -1
- package/dist/{chunk-VHSNYUYV.js → chunk-6NAVMWZQ.js} +5 -5
- package/dist/{chunk-EUKPOXWR.cjs → chunk-6PXXGACR.cjs} +17 -15
- package/dist/{chunk-WTK6JDSI.js → chunk-74QFZ5MK.js} +6 -4
- package/dist/{chunk-WOEETTH7.cjs → chunk-7AFPOE7N.cjs} +6 -6
- package/dist/{chunk-U57COLUE.js → chunk-AXIPOR3C.js} +2 -2
- package/dist/chunk-CTED3MTR.cjs +380 -0
- package/dist/{chunk-QKKBBH7I.js → chunk-DZHYSUGY.js} +28 -7
- package/dist/{chunk-V5D7BHW3.js → chunk-EAJ7SYHE.js} +6 -4
- package/dist/{chunk-SYHNZSZZ.cjs → chunk-FAXIIH5R.cjs} +3 -3
- package/dist/{chunk-7G7UOQV4.cjs → chunk-FGEB7RMY.cjs} +4 -4
- package/dist/chunk-GKKDAW44.js +8823 -0
- package/dist/{chunk-QET3Q4JP.js → chunk-H5POPGOZ.js} +8 -6
- package/dist/{chunk-VR3FREBX.cjs → chunk-JK4XMMKM.cjs} +3 -3
- package/dist/{chunk-CBRL2PJA.cjs → chunk-JQYC66TO.cjs} +12 -12
- package/dist/{chunk-YFIWCYHC.cjs → chunk-JZLGCTGK.cjs} +56 -54
- package/dist/{chunk-4ZCXK4VI.cjs → chunk-KFRDLKMA.cjs} +14 -14
- package/dist/chunk-KWFFIJYX.js +11 -0
- package/dist/chunk-M4IT6DNJ.cjs +608 -0
- package/dist/{chunk-43RFBQ73.cjs → chunk-MVDQMV25.cjs} +29 -32
- package/dist/chunk-NCVX3K2N.cjs +161 -0
- package/dist/chunk-NWFMBLSQ.js +4 -0
- package/dist/chunk-O5676ZWY.js +585 -0
- package/dist/chunk-PUX5VXDB.cjs +8845 -0
- package/dist/{chunk-DRSPMIZ7.js → chunk-QBJ7O2B4.js} +1 -11
- package/dist/{chunk-UJS4N2XM.cjs → chunk-TEBM66WA.cjs} +12 -12
- package/dist/{chunk-TN65XNTI.js → chunk-TWT3STIX.js} +8 -6
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/chunk-VP2B4WM2.js +154 -0
- package/dist/{chunk-BK7YIVLK.cjs → chunk-WJLECC22.cjs} +75 -73
- package/dist/{chunk-NFW7AUEX.js → chunk-WMACINXO.js} +1 -1
- package/dist/{chunk-AYGRYDBX.cjs → chunk-XAYGD4E4.cjs} +37 -35
- package/dist/{chunk-46T67CE2.js → chunk-ZA673I3O.js} +1 -1
- package/dist/{chunk-YPYCWLYP.js → chunk-ZWXJTBZO.js} +1 -1
- package/dist/core/addresses.d.ts +14 -2
- package/dist/core/brands.d.ts +8 -2
- package/dist/core/errors.d.ts +71 -10
- package/dist/core/preflight.d.ts +1 -0
- package/dist/fhe/erc7984-abi.d.ts +1 -0
- package/dist/fhe/index.cjs +64 -63
- package/dist/fhe/index.js +7 -6
- package/dist/fhe/operators.d.ts +22 -5
- package/dist/fhe/react/index.cjs +13 -12
- package/dist/fhe/react/index.js +6 -5
- package/dist/fhe/types.d.ts +6 -0
- package/dist/fhe-airdrop/abis/{cloneable.d.ts → airdrop-base.d.ts} +254 -396
- package/dist/fhe-airdrop/abis/compliance.d.ts +422 -0
- package/dist/fhe-airdrop/abis/ecdsa.d.ts +1316 -0
- package/dist/fhe-airdrop/abis/factory.d.ts +1319 -190
- package/dist/fhe-airdrop/abis/index.d.ts +5 -2
- package/dist/fhe-airdrop/abis/merkle.d.ts +1238 -0
- package/dist/fhe-airdrop/advanced/index.cjs +11 -12
- package/dist/fhe-airdrop/advanced/index.d.cts +34 -11
- package/dist/fhe-airdrop/advanced/index.d.ts +34 -11
- package/dist/fhe-airdrop/advanced/index.js +3 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +37 -50
- package/dist/fhe-airdrop/advanced/react/index.d.cts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.d.ts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.js +36 -50
- package/dist/fhe-airdrop/advanced/react/usePredictEcdsaAirdropAddress.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/usePredictMerkleAirdropAddress.d.ts +27 -0
- package/dist/fhe-airdrop/airdrop-base.d.ts +600 -0
- package/dist/fhe-airdrop/campaign.d.ts +297 -0
- package/dist/fhe-airdrop/compliance.d.ts +302 -0
- package/dist/fhe-airdrop/constants.d.ts +33 -0
- package/dist/fhe-airdrop/ecdsa.d.ts +263 -0
- package/dist/fhe-airdrop/encryption.d.ts +92 -14
- package/dist/fhe-airdrop/errors.d.ts +245 -15
- package/dist/fhe-airdrop/factory.d.ts +533 -274
- package/dist/fhe-airdrop/guards.d.ts +273 -0
- package/dist/fhe-airdrop/index.cjs +1131 -74
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +931 -8
- package/dist/fhe-airdrop/merkle-tree.d.ts +103 -0
- package/dist/fhe-airdrop/merkle.d.ts +180 -0
- package/dist/fhe-airdrop/react/_shared.d.ts +144 -71
- package/dist/fhe-airdrop/react/index.cjs +399 -459
- package/dist/fhe-airdrop/react/index.d.cts +53 -74
- package/dist/fhe-airdrop/react/index.d.ts +53 -74
- package/dist/fhe-airdrop/react/index.js +261 -374
- package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +10 -5
- package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +15 -6
- package/dist/fhe-airdrop/react/useAirdropPause.d.ts +30 -0
- package/dist/fhe-airdrop/react/useAirdropPaused.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -4
- package/dist/fhe-airdrop/react/useAirdropWindow.d.ts +37 -0
- package/dist/fhe-airdrop/react/useClaimedAmount.d.ts +29 -0
- package/dist/fhe-airdrop/react/useComplianceManager.d.ts +16 -0
- package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +28 -0
- package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +25 -0
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +23 -0
- package/dist/fhe-airdrop/react/useEffectiveUpgradeable.d.ts +20 -0
- package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +17 -12
- package/dist/fhe-airdrop/react/useFactoryFees.d.ts +28 -0
- package/dist/fhe-airdrop/react/useFactoryRegistry.d.ts +35 -0
- package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +35 -0
- package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +35 -0
- package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +34 -0
- package/dist/fhe-airdrop/react/useMerkleRoot.d.ts +15 -0
- package/dist/fhe-airdrop/react/useSetMerkleRoot.d.ts +22 -0
- package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +23 -0
- package/dist/fhe-airdrop/roles.d.ts +147 -0
- package/dist/fhe-airdrop/types.d.ts +67 -65
- package/dist/fhe-disperse/index.cjs +70 -68
- package/dist/fhe-disperse/index.js +10 -8
- package/dist/fhe-disperse/react/index.cjs +94 -92
- package/dist/fhe-disperse/react/index.js +13 -11
- package/dist/fhe-vesting/advanced/index.cjs +10 -8
- package/dist/fhe-vesting/advanced/index.js +8 -6
- package/dist/fhe-vesting/advanced/react/index.cjs +16 -14
- package/dist/fhe-vesting/advanced/react/index.js +13 -11
- package/dist/fhe-vesting/index.cjs +74 -72
- package/dist/fhe-vesting/index.js +11 -9
- package/dist/fhe-vesting/react/index.cjs +228 -226
- package/dist/fhe-vesting/react/index.js +15 -13
- package/dist/index.cjs +100 -87
- package/dist/index.js +3 -2
- package/dist/testnet-faucet/index.cjs +57 -55
- package/dist/testnet-faucet/index.js +7 -5
- package/dist/testnet-faucet/react/index.cjs +55 -53
- package/dist/testnet-faucet/react/index.js +9 -7
- package/package.json +6 -2
- package/dist/chunk-CNP4L3GF.js +0 -105
- package/dist/chunk-KSDSXJ34.js +0 -41
- package/dist/chunk-LBWRFZR3.cjs +0 -1681
- package/dist/chunk-OL6SHN3D.cjs +0 -44
- package/dist/chunk-S2XD75JM.js +0 -1637
- package/dist/chunk-SPGSO5SO.cjs +0 -1644
- package/dist/chunk-UE5XK2SY.js +0 -1673
- package/dist/chunk-WO72UBQD.cjs +0 -109
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +0 -53
- package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +0 -49
- package/dist/fhe-airdrop/airdrop.d.ts +0 -317
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -37
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +0 -6
- package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +0 -9
- package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +0 -22
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +0 -51
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useClaim.d.ts +0 -39
- package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +0 -11
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +0 -41
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +0 -48
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +0 -29
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +0 -31
- package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +0 -14
- package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +0 -33
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +0 -51
- package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +0 -14
- package/dist/fhe-airdrop/react/useSetPaused.d.ts +0 -14
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +0 -31
- package/dist/fhe-airdrop/react/useWithdraw.d.ts +0 -12
- package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +0 -13
- package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +0 -13
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
4
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
4
5
|
var viem = require('viem');
|
|
5
6
|
|
|
6
7
|
// src/fhe/scale-ratio.ts
|
|
@@ -16,7 +17,7 @@ function scaleRatio({
|
|
|
16
17
|
width = "uint128"
|
|
17
18
|
}) {
|
|
18
19
|
if (denominator <= 0n) {
|
|
19
|
-
throw new
|
|
20
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
20
21
|
method: "scaleRatio",
|
|
21
22
|
argument: "denominator",
|
|
22
23
|
reason: `must be > 0, got ${denominator}`,
|
|
@@ -24,7 +25,7 @@ function scaleRatio({
|
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
if (numerator < 0n) {
|
|
27
|
-
throw new
|
|
28
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
28
29
|
method: "scaleRatio",
|
|
29
30
|
argument: "numerator",
|
|
30
31
|
reason: `must be >= 0, got ${numerator}`,
|
|
@@ -32,7 +33,7 @@ function scaleRatio({
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
if (minDenominator <= 0n) {
|
|
35
|
-
throw new
|
|
36
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
36
37
|
method: "scaleRatio",
|
|
37
38
|
argument: "minDenominator",
|
|
38
39
|
reason: `must be > 0, got ${minDenominator}`,
|
|
@@ -52,7 +53,7 @@ function scaleRatio({
|
|
|
52
53
|
function assertWithinWidth(value, width, label) {
|
|
53
54
|
const max = width === "uint64" ? MAX_UINT64 : MAX_UINT128;
|
|
54
55
|
if (value > max) {
|
|
55
|
-
throw new
|
|
56
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
56
57
|
method: "scaleRatio",
|
|
57
58
|
argument: label,
|
|
58
59
|
reason: `exceeds ${width} range`,
|
|
@@ -79,7 +80,7 @@ var share = {
|
|
|
79
80
|
const n = toIntegerBigInt(numerator, "share.fraction", "numerator");
|
|
80
81
|
const m = toIntegerBigInt(denominator, "share.fraction", "denominator");
|
|
81
82
|
if (m <= 0n || m > MAX_FRACTION_DENOMINATOR) {
|
|
82
|
-
throw new
|
|
83
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
83
84
|
method: "share.fraction",
|
|
84
85
|
argument: "denominator",
|
|
85
86
|
reason: `must be in 1..${MAX_FRACTION_DENOMINATOR}, got ${m}`,
|
|
@@ -87,7 +88,7 @@ var share = {
|
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
if (n < 0n || n > m) {
|
|
90
|
-
throw new
|
|
91
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
91
92
|
method: "share.fraction",
|
|
92
93
|
argument: "numerator",
|
|
93
94
|
reason: `must be in 0..${m} (denominator), got ${n}`,
|
|
@@ -112,7 +113,7 @@ var share = {
|
|
|
112
113
|
basisPoints(bps) {
|
|
113
114
|
const value = toIntegerBigInt(bps, "share.basisPoints", "bps");
|
|
114
115
|
if (value < 0n || value > BASIS_POINT_SCALE) {
|
|
115
|
-
throw new
|
|
116
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
116
117
|
method: "share.basisPoints",
|
|
117
118
|
argument: "bps",
|
|
118
119
|
reason: `must be in 0..${BASIS_POINT_SCALE}, got ${value}`,
|
|
@@ -125,7 +126,7 @@ var share = {
|
|
|
125
126
|
function toIntegerBigInt(value, method, argument) {
|
|
126
127
|
if (typeof value === "bigint") return value;
|
|
127
128
|
if (!Number.isInteger(value)) {
|
|
128
|
-
throw new
|
|
129
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
129
130
|
method,
|
|
130
131
|
argument,
|
|
131
132
|
reason: `must be an integer, got ${value}`,
|
|
@@ -141,7 +142,7 @@ function resolveEncryptor(source) {
|
|
|
141
142
|
var MAX_UINT642 = (1n << 64n) - 1n;
|
|
142
143
|
function assertUint64(value, label) {
|
|
143
144
|
if (value < 0n || value > MAX_UINT642) {
|
|
144
|
-
throw new
|
|
145
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
145
146
|
method: "encryptUint64",
|
|
146
147
|
argument: label,
|
|
147
148
|
reason: `does not fit in uint64 (0..2^64-1)`,
|
|
@@ -162,7 +163,7 @@ async function encryptUint64({
|
|
|
162
163
|
userAddress
|
|
163
164
|
});
|
|
164
165
|
if (handles.length !== 1) {
|
|
165
|
-
throw new
|
|
166
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
166
167
|
method: "encryptUint64",
|
|
167
168
|
argument: "handles",
|
|
168
169
|
reason: `expected 1 handle, got ${handles.length}`,
|
|
@@ -170,8 +171,8 @@ async function encryptUint64({
|
|
|
170
171
|
});
|
|
171
172
|
}
|
|
172
173
|
return {
|
|
173
|
-
handle:
|
|
174
|
-
inputProof:
|
|
174
|
+
handle: chunk66IHPTOK_cjs.asEncryptedHandle(viem.bytesToHex(handles[0])),
|
|
175
|
+
inputProof: chunk66IHPTOK_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
175
176
|
};
|
|
176
177
|
}
|
|
177
178
|
async function encryptUint64Batch({
|
|
@@ -181,7 +182,7 @@ async function encryptUint64Batch({
|
|
|
181
182
|
values
|
|
182
183
|
}) {
|
|
183
184
|
if (values.length === 0) {
|
|
184
|
-
throw new
|
|
185
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
185
186
|
method: "encryptUint64Batch",
|
|
186
187
|
argument: "values",
|
|
187
188
|
reason: "must be non-empty"
|
|
@@ -194,7 +195,7 @@ async function encryptUint64Batch({
|
|
|
194
195
|
userAddress
|
|
195
196
|
});
|
|
196
197
|
if (handles.length !== values.length) {
|
|
197
|
-
throw new
|
|
198
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
198
199
|
method: "encryptUint64Batch",
|
|
199
200
|
argument: "handles",
|
|
200
201
|
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
@@ -202,8 +203,8 @@ async function encryptUint64Batch({
|
|
|
202
203
|
});
|
|
203
204
|
}
|
|
204
205
|
return {
|
|
205
|
-
handles: handles.map((h) =>
|
|
206
|
-
inputProof:
|
|
206
|
+
handles: handles.map((h) => chunk66IHPTOK_cjs.asEncryptedHandle(viem.bytesToHex(h))),
|
|
207
|
+
inputProof: chunk66IHPTOK_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
207
208
|
};
|
|
208
209
|
}
|
|
209
210
|
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { resolveEncryptor, encryptUint64 } from './chunk-GKKDAW44.js';
|
|
2
|
+
import { assertPredictionFresh, FeeCollectorSelfAdministeredError } from './chunk-O5676ZWY.js';
|
|
3
|
+
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
4
|
+
import { InvalidArgumentError, MissingWalletClientError, MissingAccountError, ContractRevertError, MissingEncryptorError, isTokenOpsSdkError, UnknownWriteFailureError } from './chunk-QBJ7O2B4.js';
|
|
5
|
+
import { StandardMerkleTree } from '@openzeppelin/merkle-tree';
|
|
6
|
+
import { keccak256, encodeAbiParameters, isAddress, isAddressEqual, zeroAddress } from 'viem';
|
|
7
|
+
|
|
8
|
+
function leafOf(args) {
|
|
9
|
+
const inner = keccak256(
|
|
10
|
+
encodeAbiParameters(
|
|
11
|
+
[{ type: "address" }, { type: "address" }, { type: "bytes32" }],
|
|
12
|
+
[args.instance, args.recipient, args.handle]
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
return keccak256(inner);
|
|
16
|
+
}
|
|
17
|
+
var HANDLE_PATTERN = /^0x[0-9a-fA-F]{64}$/;
|
|
18
|
+
function assertLeaves(instance, leaves, method) {
|
|
19
|
+
if (!isAddress(instance, { strict: false })) {
|
|
20
|
+
throw new InvalidArgumentError({
|
|
21
|
+
method,
|
|
22
|
+
argument: "instance",
|
|
23
|
+
reason: "is not a 20-byte hex address",
|
|
24
|
+
value: instance
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (isAddressEqual(instance, zeroAddress)) {
|
|
28
|
+
throw new InvalidArgumentError({
|
|
29
|
+
method,
|
|
30
|
+
argument: "instance",
|
|
31
|
+
reason: "is the zero address; leaves must be scoped to the airdrop instance"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (leaves.length === 0) {
|
|
35
|
+
throw new InvalidArgumentError({
|
|
36
|
+
method,
|
|
37
|
+
argument: "leaves",
|
|
38
|
+
reason: "a tree needs at least one leaf"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const seen = /* @__PURE__ */ new Map();
|
|
42
|
+
leaves.forEach((leaf, index) => {
|
|
43
|
+
if (!isAddress(leaf.recipient, { strict: false })) {
|
|
44
|
+
throw new InvalidArgumentError({
|
|
45
|
+
method,
|
|
46
|
+
argument: `leaves[${index}].recipient`,
|
|
47
|
+
reason: "is not a 20-byte hex address",
|
|
48
|
+
value: leaf.recipient
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (isAddressEqual(leaf.recipient, zeroAddress)) {
|
|
52
|
+
throw new InvalidArgumentError({
|
|
53
|
+
method,
|
|
54
|
+
argument: `leaves[${index}].recipient`,
|
|
55
|
+
reason: "is the zero address, whose leaf can never be claimed"
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (!HANDLE_PATTERN.test(leaf.handle)) {
|
|
59
|
+
throw new InvalidArgumentError({
|
|
60
|
+
method,
|
|
61
|
+
argument: `leaves[${index}].handle`,
|
|
62
|
+
reason: "is not a 32-byte hex handle; the tree would commit to a value no claim can reproduce",
|
|
63
|
+
value: leaf.handle
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const key = leaf.recipient.toLowerCase();
|
|
67
|
+
const first = seen.get(key);
|
|
68
|
+
if (first !== void 0) {
|
|
69
|
+
throw new InvalidArgumentError({
|
|
70
|
+
method,
|
|
71
|
+
argument: `leaves[${index}].recipient`,
|
|
72
|
+
reason: `appears twice (also at index ${first}); one root pays max, not sum, of a recipient's leaves \u2014 merge them into a single cumulative total`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
seen.set(key, index);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function buildMerkleTree(args) {
|
|
79
|
+
return buildMerkleTreeInternal(args, "buildMerkleTree");
|
|
80
|
+
}
|
|
81
|
+
function buildMerkleTreeInternal({ instance, leaves }, method) {
|
|
82
|
+
assertLeaves(instance, leaves, method);
|
|
83
|
+
const airdrop = normaliseAddress(instance);
|
|
84
|
+
const accounts = leaves.map((leaf) => normaliseAddress(leaf.recipient));
|
|
85
|
+
const rows = accounts.map((account, i) => [airdrop, account, leaves[i].handle]);
|
|
86
|
+
const tree = StandardMerkleTree.of(rows, ["address", "address", "bytes32"]);
|
|
87
|
+
return {
|
|
88
|
+
root: tree.root,
|
|
89
|
+
// `getProof(i)` indexes the INPUT array, not the tree: `StandardMerkleTree`
|
|
90
|
+
// sorts leaves internally but keeps `values` in insertion order, so entry
|
|
91
|
+
// `i` always belongs to `leaves[i]`.
|
|
92
|
+
entries: leaves.map((leaf, i) => ({
|
|
93
|
+
...leaf,
|
|
94
|
+
recipient: accounts[i],
|
|
95
|
+
merkleProof: tree.getProof(i)
|
|
96
|
+
}))
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
100
|
+
function validateCampaignRecipients(recipients) {
|
|
101
|
+
validateCampaignRecipientsInternal(recipients, "validateCampaignRecipients");
|
|
102
|
+
}
|
|
103
|
+
function validateCampaignRecipientsInternal(recipients, method) {
|
|
104
|
+
if (recipients.length === 0) {
|
|
105
|
+
throw new InvalidArgumentError({
|
|
106
|
+
method,
|
|
107
|
+
argument: "recipients",
|
|
108
|
+
reason: "a campaign needs at least one recipient"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const seen = /* @__PURE__ */ new Map();
|
|
112
|
+
recipients.forEach((entry, index) => {
|
|
113
|
+
if (!isAddress(entry.recipient, { strict: false })) {
|
|
114
|
+
throw new InvalidArgumentError({
|
|
115
|
+
method,
|
|
116
|
+
argument: `recipients[${index}].recipient`,
|
|
117
|
+
reason: "is not a 20-byte hex address",
|
|
118
|
+
value: entry.recipient
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (isAddressEqual(entry.recipient, zeroAddress)) {
|
|
122
|
+
throw new InvalidArgumentError({
|
|
123
|
+
method,
|
|
124
|
+
argument: `recipients[${index}].recipient`,
|
|
125
|
+
reason: "is the zero address, whose leaf can never be claimed"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (entry.cumulativeTotal < 0n || entry.cumulativeTotal > MAX_UINT64) {
|
|
129
|
+
throw new InvalidArgumentError({
|
|
130
|
+
method,
|
|
131
|
+
argument: `recipients[${index}].cumulativeTotal`,
|
|
132
|
+
// Deliberately no `value`: the total is confidential.
|
|
133
|
+
reason: "is outside uint64 range (0..2^64-1)"
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const key = entry.recipient.toLowerCase();
|
|
137
|
+
const first = seen.get(key);
|
|
138
|
+
if (first !== void 0) {
|
|
139
|
+
throw new InvalidArgumentError({
|
|
140
|
+
method,
|
|
141
|
+
argument: `recipients[${index}].recipient`,
|
|
142
|
+
reason: `appears twice (also at index ${first}); one root pays max, not sum, of a recipient's leaves \u2014 merge them into a single cumulative total`
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
seen.set(key, index);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async function encryptRoster({ instance, recipients, encryptor }, method) {
|
|
149
|
+
validateCampaignRecipientsInternal(recipients, method);
|
|
150
|
+
if (!isAddress(instance, { strict: false })) {
|
|
151
|
+
throw new InvalidArgumentError({
|
|
152
|
+
method,
|
|
153
|
+
argument: "instance",
|
|
154
|
+
reason: "is not a 20-byte hex address",
|
|
155
|
+
value: instance
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (isAddressEqual(instance, zeroAddress)) {
|
|
159
|
+
throw new InvalidArgumentError({
|
|
160
|
+
method,
|
|
161
|
+
argument: "instance",
|
|
162
|
+
reason: "is the zero address; inputs must be bound to the airdrop instance"
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const enc = resolveEncryptor(encryptor);
|
|
166
|
+
if (!enc) {
|
|
167
|
+
throw new MissingEncryptorError(method, {
|
|
168
|
+
hint: "Pass an encryptor instance, or a lazy factory that returns one."
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const airdrop = normaliseAddress(instance);
|
|
172
|
+
const accounts = recipients.map((r) => normaliseAddress(r.recipient));
|
|
173
|
+
const encrypted = await Promise.all(
|
|
174
|
+
recipients.map(
|
|
175
|
+
(r, i) => encryptUint64({
|
|
176
|
+
encryptor: enc,
|
|
177
|
+
contractAddress: airdrop,
|
|
178
|
+
userAddress: accounts[i],
|
|
179
|
+
value: r.cumulativeTotal
|
|
180
|
+
})
|
|
181
|
+
)
|
|
182
|
+
);
|
|
183
|
+
return accounts.map((recipient, i) => ({
|
|
184
|
+
recipient,
|
|
185
|
+
handle: encrypted[i].handle,
|
|
186
|
+
inputProof: encrypted[i].inputProof
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
async function encryptCampaignAmounts(args) {
|
|
190
|
+
return encryptRoster(args, "encryptCampaignAmounts");
|
|
191
|
+
}
|
|
192
|
+
async function buildMerkleCampaign({
|
|
193
|
+
instance,
|
|
194
|
+
recipients,
|
|
195
|
+
encryptor
|
|
196
|
+
}) {
|
|
197
|
+
const leaves = await encryptRoster({ instance, recipients, encryptor }, "buildMerkleCampaign");
|
|
198
|
+
return buildMerkleTreeInternal({ instance, leaves }, "buildMerkleCampaign");
|
|
199
|
+
}
|
|
200
|
+
async function planMerkleCampaign({
|
|
201
|
+
factory,
|
|
202
|
+
params,
|
|
203
|
+
mode,
|
|
204
|
+
creator,
|
|
205
|
+
userSalt,
|
|
206
|
+
recipients,
|
|
207
|
+
encryptor
|
|
208
|
+
}) {
|
|
209
|
+
validateCampaignRecipientsInternal(recipients, "planMerkleCampaign");
|
|
210
|
+
const initCodeHashBefore = await factory.getMerkleInitCodeHash({ params, mode });
|
|
211
|
+
const predictedAddress = await factory.predictMerkleAirdropAddress({
|
|
212
|
+
params,
|
|
213
|
+
mode,
|
|
214
|
+
deployer: creator,
|
|
215
|
+
userSalt
|
|
216
|
+
});
|
|
217
|
+
const campaign = await buildMerkleCampaign({
|
|
218
|
+
instance: predictedAddress,
|
|
219
|
+
recipients,
|
|
220
|
+
encryptor
|
|
221
|
+
});
|
|
222
|
+
const initCodeHashAfter = await factory.getMerkleInitCodeHash({ params, mode });
|
|
223
|
+
assertPredictionFresh({
|
|
224
|
+
variant: "merkle",
|
|
225
|
+
initCodeHashBefore,
|
|
226
|
+
initCodeHashAfter,
|
|
227
|
+
predictedAddress,
|
|
228
|
+
method: "planMerkleCampaign"
|
|
229
|
+
});
|
|
230
|
+
return { ...campaign, predictedAddress, initCodeHashBefore, initCodeHashAfter };
|
|
231
|
+
}
|
|
232
|
+
async function rotateMerkleRoot({
|
|
233
|
+
airdrop,
|
|
234
|
+
recipients,
|
|
235
|
+
encryptor,
|
|
236
|
+
account
|
|
237
|
+
}) {
|
|
238
|
+
const campaign = await buildMerkleCampaign({
|
|
239
|
+
instance: airdrop.address,
|
|
240
|
+
recipients,
|
|
241
|
+
encryptor
|
|
242
|
+
});
|
|
243
|
+
const hash = await airdrop.setMerkleRoot({ newRoot: campaign.root, account });
|
|
244
|
+
return { ...campaign, hash };
|
|
245
|
+
}
|
|
246
|
+
var ASSIGNABLE_ROLES = [
|
|
247
|
+
{ key: "pauser", role: "PAUSER_ROLE" },
|
|
248
|
+
{ key: "windowAdmin", role: "WINDOW_ADMIN_ROLE" },
|
|
249
|
+
{ key: "treasury", role: "TREASURY_ROLE" },
|
|
250
|
+
{ key: "rescuer", role: "RESCUER_ROLE" },
|
|
251
|
+
{ key: "disclosureAdmin", role: "DISCLOSURE_ADMIN_ROLE" },
|
|
252
|
+
{ key: "upgrader", role: "UPGRADER_ROLE" },
|
|
253
|
+
{ key: "merkleAdmin", role: "MERKLE_ADMIN_ROLE", variant: "merkle" },
|
|
254
|
+
{ key: "signer", role: "SIGNER_ROLE", variant: "ecdsa" }
|
|
255
|
+
];
|
|
256
|
+
function planInstanceRoleSplit(args) {
|
|
257
|
+
const { assignment, caller, airdropType } = args;
|
|
258
|
+
if (assignment.feeCollector !== void 0) {
|
|
259
|
+
throw new FeeCollectorSelfAdministeredError({ requestedGrantee: assignment.feeCollector });
|
|
260
|
+
}
|
|
261
|
+
const steps = [];
|
|
262
|
+
for (const { key, role, variant } of ASSIGNABLE_ROLES) {
|
|
263
|
+
const account = assignment[key];
|
|
264
|
+
if (account === void 0) continue;
|
|
265
|
+
if (variant !== void 0 && variant !== airdropType) {
|
|
266
|
+
throw new InvalidArgumentError({
|
|
267
|
+
method: "planInstanceRoleSplit",
|
|
268
|
+
argument: `assignment.${key}`,
|
|
269
|
+
reason: `${role} only exists on ${variant} campaigns; this is a(n) ${airdropType} campaign`
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
steps.push({ kind: "grant", role, account });
|
|
273
|
+
}
|
|
274
|
+
if (assignment.admin !== void 0) {
|
|
275
|
+
if (isAddressEqual(assignment.admin, zeroAddress)) {
|
|
276
|
+
throw new InvalidArgumentError({
|
|
277
|
+
method: "planInstanceRoleSplit",
|
|
278
|
+
argument: "assignment.admin",
|
|
279
|
+
reason: "granting DEFAULT_ADMIN_ROLE to the zero address is never valid"
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
steps.push({ kind: "grant", role: "DEFAULT_ADMIN_ROLE", account: assignment.admin });
|
|
283
|
+
steps.push({ kind: "revoke", role: "DEFAULT_ADMIN_ROLE", account: caller });
|
|
284
|
+
}
|
|
285
|
+
return steps;
|
|
286
|
+
}
|
|
287
|
+
function roleGetterAbiEntry(name) {
|
|
288
|
+
return {
|
|
289
|
+
inputs: [],
|
|
290
|
+
name,
|
|
291
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
292
|
+
stateMutability: "view",
|
|
293
|
+
type: "function"
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
var ROLE_GETTER_ABI = [
|
|
297
|
+
roleGetterAbiEntry("PAUSER_ROLE"),
|
|
298
|
+
roleGetterAbiEntry("WINDOW_ADMIN_ROLE"),
|
|
299
|
+
roleGetterAbiEntry("TREASURY_ROLE"),
|
|
300
|
+
roleGetterAbiEntry("RESCUER_ROLE"),
|
|
301
|
+
roleGetterAbiEntry("DISCLOSURE_ADMIN_ROLE"),
|
|
302
|
+
roleGetterAbiEntry("UPGRADER_ROLE"),
|
|
303
|
+
roleGetterAbiEntry("MERKLE_ADMIN_ROLE"),
|
|
304
|
+
roleGetterAbiEntry("SIGNER_ROLE")
|
|
305
|
+
];
|
|
306
|
+
var DEFAULT_ADMIN_ROLE_CONSTANT = `0x${"0".repeat(64)}`;
|
|
307
|
+
async function resolveRoleConstant(airdrop, role) {
|
|
308
|
+
if (role === "DEFAULT_ADMIN_ROLE") return DEFAULT_ADMIN_ROLE_CONSTANT;
|
|
309
|
+
const result = await airdrop.publicClient.readContract({
|
|
310
|
+
address: airdrop.address,
|
|
311
|
+
abi: ROLE_GETTER_ABI,
|
|
312
|
+
functionName: role
|
|
313
|
+
});
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
function toOutcomeError(step, airdrop, error) {
|
|
317
|
+
if (isTokenOpsSdkError(error)) return error;
|
|
318
|
+
return new UnknownWriteFailureError({
|
|
319
|
+
method: `grantInstanceRoles.${step.kind}.${step.role}`,
|
|
320
|
+
contractAddress: airdrop.address,
|
|
321
|
+
cause: error
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
async function grantInstanceRoles(args) {
|
|
325
|
+
const { airdrop, assignment, revokeFromCreator = true } = args;
|
|
326
|
+
const wallet = airdrop.walletClient;
|
|
327
|
+
if (!wallet) {
|
|
328
|
+
throw new MissingWalletClientError("grantInstanceRoles");
|
|
329
|
+
}
|
|
330
|
+
const callerAccount = wallet.account;
|
|
331
|
+
if (!callerAccount) {
|
|
332
|
+
throw new MissingAccountError("grantInstanceRoles");
|
|
333
|
+
}
|
|
334
|
+
const caller = typeof callerAccount === "string" ? callerAccount : callerAccount.address;
|
|
335
|
+
const airdropType = await airdrop.airdropType() === 1 ? "merkle" : "ecdsa";
|
|
336
|
+
let steps = planInstanceRoleSplit({ assignment, caller, airdropType });
|
|
337
|
+
if (!revokeFromCreator) {
|
|
338
|
+
steps = steps.filter((step) => !(step.kind === "revoke" && step.role === "DEFAULT_ADMIN_ROLE"));
|
|
339
|
+
}
|
|
340
|
+
const outcomes = [];
|
|
341
|
+
for (const step of steps) {
|
|
342
|
+
try {
|
|
343
|
+
const role = await resolveRoleConstant(airdrop, step.role);
|
|
344
|
+
const hash = step.kind === "grant" ? await airdrop.grantRole({ role, holder: step.account, account: caller }) : await airdrop.revokeRole({ role, holder: step.account, account: caller });
|
|
345
|
+
const receipt = await airdrop.publicClient.waitForTransactionReceipt({ hash });
|
|
346
|
+
if (receipt.status !== "success") {
|
|
347
|
+
outcomes.push({
|
|
348
|
+
role: step.role,
|
|
349
|
+
account: step.account,
|
|
350
|
+
error: new ContractRevertError({
|
|
351
|
+
method: `grantInstanceRoles.${step.kind}.${step.role}`,
|
|
352
|
+
contractAddress: airdrop.address,
|
|
353
|
+
message: `grantInstanceRoles.${step.kind}.${step.role}: transaction ${hash} was mined with a reverted status; the role change did not apply.`
|
|
354
|
+
})
|
|
355
|
+
});
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
outcomes.push({ role: step.role, account: step.account, hash });
|
|
359
|
+
} catch (error) {
|
|
360
|
+
outcomes.push({
|
|
361
|
+
role: step.role,
|
|
362
|
+
account: step.account,
|
|
363
|
+
error: toOutcomeError(step, airdrop, error)
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return outcomes;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export { buildMerkleCampaign, buildMerkleTree, encryptCampaignAmounts, grantInstanceRoles, leafOf, planInstanceRoleSplit, planMerkleCampaign, rotateMerkleRoot, validateCampaignRecipients };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { TokenOpsSdkError, ContractRevertError, InvalidArgumentError, OperatorNotApprovedError, InvalidSignatureError, FheHandleNotAllowedError, TransferFailedError, FeatureDisabledError, BatchTooLargeError, InsufficientBalanceError, InsufficientFeeError, ReentrancyError, AlreadyInitializedError, AccessDeniedError, PausedError, UnknownWriteFailureError, WalletRejectedError, WalletChainMismatchError, InsufficientGasFundsError, NetworkError } from './chunk-
|
|
1
|
+
import { TokenOpsSdkError, ContractRevertError, InvalidArgumentError, OperatorNotApprovedError, InvalidSignatureError, FheHandleNotAllowedError, TransferFailedError, FeatureDisabledError, BatchTooLargeError, InsufficientBalanceError, InsufficientFeeError, ReentrancyError, AlreadyInitializedError, AccessDeniedError, PausedError, UnknownWriteFailureError, WalletRejectedError, WalletChainMismatchError, InsufficientGasFundsError, NetworkError } from './chunk-QBJ7O2B4.js';
|
|
2
2
|
import { decodeErrorResult, BaseError, ContractFunctionRevertedError, UserRejectedRequestError, TransactionRejectedRpcError, ChainMismatchError, InsufficientFundsError, HttpRequestError, TimeoutError } from 'viem';
|
|
3
3
|
|
|
4
|
-
// src/core/version.ts
|
|
5
|
-
var SDK_VERSION = "1.0.0";
|
|
6
4
|
var ERC7984_ERRORS_ABI = [
|
|
7
5
|
{
|
|
8
6
|
type: "error",
|
|
@@ -378,4 +376,4 @@ function coerceRevertHex(value) {
|
|
|
378
376
|
return void 0;
|
|
379
377
|
}
|
|
380
378
|
|
|
381
|
-
export {
|
|
379
|
+
export { isContractRevert, mapContractRevert };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { erc7984OperatorAbi } from './chunk-7VELUOMI.js';
|
|
2
|
-
import { normaliseAddress } from './chunk-
|
|
3
|
-
import { TokenOpsContractError } from './chunk-
|
|
2
|
+
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
3
|
+
import { TokenOpsContractError } from './chunk-QBJ7O2B4.js';
|
|
4
4
|
import { withTelemetry } from './chunk-Q2GP5UDC.js';
|
|
5
5
|
|
|
6
6
|
// src/fhe/operators.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
4
4
|
var chains = require('viem/chains');
|
|
5
5
|
|
|
6
6
|
var DEPLOYED_ADDRESSES = {
|
|
@@ -10,10 +10,22 @@ var DEPLOYED_ADDRESSES = {
|
|
|
10
10
|
// mainnet omitted — not deployed.
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
|
+
// Airdrop v2 (tokenops-fhe-airdrop-v2 @ 8e5b144). The four contracts deploy
|
|
14
|
+
// together in one scripted run, so a chain either has all of them or none —
|
|
15
|
+
// which is what `chainsWithDeployment` assumes.
|
|
13
16
|
fheAirdrop: {
|
|
14
|
-
|
|
15
|
-
[chains.sepolia.id]: "
|
|
16
|
-
// mainnet omitted — not deployed.
|
|
17
|
+
airdropFactory: {
|
|
18
|
+
[chains.sepolia.id]: "0x383083B6f13a0ee513596A6750B511c5E482d2d1"
|
|
19
|
+
// mainnet omitted — ZamaConfig-gated, not deployed.
|
|
20
|
+
},
|
|
21
|
+
ecdsaImplementation: {
|
|
22
|
+
[chains.sepolia.id]: "0xefE40570C1837210f8E4Ae938635e11bd1ae788E"
|
|
23
|
+
},
|
|
24
|
+
merkleImplementation: {
|
|
25
|
+
[chains.sepolia.id]: "0x9f3156546744F3ceE98Dc44bed817d98A8b8ae74"
|
|
26
|
+
},
|
|
27
|
+
complianceManagerImplementation: {
|
|
28
|
+
[chains.sepolia.id]: "0x6adA841250C048364d1d3027958C662Dd4E62136"
|
|
17
29
|
}
|
|
18
30
|
},
|
|
19
31
|
fheDisperse: {
|
|
@@ -50,7 +62,7 @@ function requireDeployedAddress(product, contract, chainId) {
|
|
|
50
62
|
const contractEntry = productEntry[contract];
|
|
51
63
|
const entry = contractEntry?.[chainId];
|
|
52
64
|
if (entry) return entry;
|
|
53
|
-
throw new
|
|
65
|
+
throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
54
66
|
reason: entry === null ? "registry-not-deployed" : "registry-unknown-chain",
|
|
55
67
|
product: String(product),
|
|
56
68
|
contract: String(contract),
|
|
@@ -64,10 +76,19 @@ function requireFheVestingFactoryAddress(chainId) {
|
|
|
64
76
|
return requireDeployedAddress("fheVesting", "confidentialVestingFactory", chainId);
|
|
65
77
|
}
|
|
66
78
|
function getFheAirdropFactoryAddress(chainId) {
|
|
67
|
-
return getDeployedAddress("fheAirdrop", "
|
|
79
|
+
return getDeployedAddress("fheAirdrop", "airdropFactory", chainId);
|
|
68
80
|
}
|
|
69
81
|
function requireFheAirdropFactoryAddress(chainId) {
|
|
70
|
-
return requireDeployedAddress("fheAirdrop", "
|
|
82
|
+
return requireDeployedAddress("fheAirdrop", "airdropFactory", chainId);
|
|
83
|
+
}
|
|
84
|
+
function getFheAirdropEcdsaImplementationAddress(chainId) {
|
|
85
|
+
return getDeployedAddress("fheAirdrop", "ecdsaImplementation", chainId);
|
|
86
|
+
}
|
|
87
|
+
function getFheAirdropMerkleImplementationAddress(chainId) {
|
|
88
|
+
return getDeployedAddress("fheAirdrop", "merkleImplementation", chainId);
|
|
89
|
+
}
|
|
90
|
+
function getFheAirdropComplianceImplementationAddress(chainId) {
|
|
91
|
+
return getDeployedAddress("fheAirdrop", "complianceManagerImplementation", chainId);
|
|
71
92
|
}
|
|
72
93
|
function getFheDisperseSingletonAddress(chainId) {
|
|
73
94
|
return getDeployedAddress("fheDisperse", "disperseConfidentialSingleton", chainId);
|
|
@@ -115,7 +136,10 @@ exports.chainsWithDeployment = chainsWithDeployment;
|
|
|
115
136
|
exports.chainsWithKnownRegistryEntry = chainsWithKnownRegistryEntry;
|
|
116
137
|
exports.getConfidentialTestTokenAddress = getConfidentialTestTokenAddress;
|
|
117
138
|
exports.getDeployedAddress = getDeployedAddress;
|
|
139
|
+
exports.getFheAirdropComplianceImplementationAddress = getFheAirdropComplianceImplementationAddress;
|
|
140
|
+
exports.getFheAirdropEcdsaImplementationAddress = getFheAirdropEcdsaImplementationAddress;
|
|
118
141
|
exports.getFheAirdropFactoryAddress = getFheAirdropFactoryAddress;
|
|
142
|
+
exports.getFheAirdropMerkleImplementationAddress = getFheAirdropMerkleImplementationAddress;
|
|
119
143
|
exports.getFheDisperseSingletonAddress = getFheDisperseSingletonAddress;
|
|
120
144
|
exports.getFheVestingFactoryAddress = getFheVestingFactoryAddress;
|
|
121
145
|
exports.getTestTokenAddress = getTestTokenAddress;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/core/brands.ts
|
|
4
|
+
var asEncryptedHandle = (h) => h;
|
|
5
|
+
var asExternalInputProof = (h) => h;
|
|
6
|
+
var asTxHash = (h) => h;
|
|
7
|
+
var asVestingId = (h) => h;
|
|
8
|
+
var asAirdropId = (h) => h;
|
|
9
|
+
var asDisperseId = (h) => h;
|
|
10
|
+
var asRole = (h) => h;
|
|
11
|
+
var asSignature = (h) => h;
|
|
12
|
+
|
|
13
|
+
exports.asAirdropId = asAirdropId;
|
|
14
|
+
exports.asDisperseId = asDisperseId;
|
|
15
|
+
exports.asEncryptedHandle = asEncryptedHandle;
|
|
16
|
+
exports.asExternalInputProof = asExternalInputProof;
|
|
17
|
+
exports.asRole = asRole;
|
|
18
|
+
exports.asSignature = asSignature;
|
|
19
|
+
exports.asTxHash = asTxHash;
|
|
20
|
+
exports.asVestingId = asVestingId;
|
|
@@ -494,16 +494,6 @@ var TokenOpsContractError = class extends TokenOpsSdkError {
|
|
|
494
494
|
}
|
|
495
495
|
};
|
|
496
496
|
|
|
497
|
-
// src/core/brands.ts
|
|
498
|
-
var asEncryptedHandle = (h) => h;
|
|
499
|
-
var asExternalInputProof = (h) => h;
|
|
500
|
-
var asTxHash = (h) => h;
|
|
501
|
-
var asVestingId = (h) => h;
|
|
502
|
-
var asAirdropId = (h) => h;
|
|
503
|
-
var asDisperseId = (h) => h;
|
|
504
|
-
var asRole = (h) => h;
|
|
505
|
-
var asSignature = (h) => h;
|
|
506
|
-
|
|
507
497
|
exports.AccessDeniedError = AccessDeniedError;
|
|
508
498
|
exports.AlreadyInitializedError = AlreadyInitializedError;
|
|
509
499
|
exports.BatchTooLargeError = BatchTooLargeError;
|
|
@@ -542,12 +532,4 @@ exports.UserDecryptNotAllowedError = UserDecryptNotAllowedError;
|
|
|
542
532
|
exports.UserRejectedSignatureError = UserRejectedSignatureError;
|
|
543
533
|
exports.WalletChainMismatchError = WalletChainMismatchError;
|
|
544
534
|
exports.WalletRejectedError = WalletRejectedError;
|
|
545
|
-
exports.asAirdropId = asAirdropId;
|
|
546
|
-
exports.asDisperseId = asDisperseId;
|
|
547
|
-
exports.asEncryptedHandle = asEncryptedHandle;
|
|
548
|
-
exports.asExternalInputProof = asExternalInputProof;
|
|
549
|
-
exports.asRole = asRole;
|
|
550
|
-
exports.asSignature = asSignature;
|
|
551
|
-
exports.asTxHash = asTxHash;
|
|
552
|
-
exports.asVestingId = asVestingId;
|
|
553
535
|
exports.isTokenOpsSdkError = isTokenOpsSdkError;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { asExternalInputProof, asEncryptedHandle } from './chunk-KWFFIJYX.js';
|
|
2
|
+
import { InvalidArgumentError } from './chunk-QBJ7O2B4.js';
|
|
2
3
|
import { bytesToHex } from 'viem';
|
|
3
4
|
|
|
4
5
|
// src/fhe/scale-ratio.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createConfidentialVestingManagerClient } from './chunk-
|
|
2
|
-
import { resolveEncryptor } from './chunk-
|
|
3
|
-
import { createConfidentialVestingFactoryClient } from './chunk-
|
|
4
|
-
import { getFheVestingFactoryAddress } from './chunk-
|
|
5
|
-
import { DeploymentAddressUnavailableError } from './chunk-
|
|
1
|
+
import { createConfidentialVestingManagerClient } from './chunk-TWT3STIX.js';
|
|
2
|
+
import { resolveEncryptor } from './chunk-6GNR22OV.js';
|
|
3
|
+
import { createConfidentialVestingFactoryClient } from './chunk-EAJ7SYHE.js';
|
|
4
|
+
import { getFheVestingFactoryAddress } from './chunk-DZHYSUGY.js';
|
|
5
|
+
import { DeploymentAddressUnavailableError } from './chunk-QBJ7O2B4.js';
|
|
6
6
|
import { useMemo, useRef, useEffect } from 'react';
|
|
7
7
|
import { usePublicClient, useWalletClient } from 'wagmi';
|
|
8
8
|
|