@tokenops/sdk 1.1.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/README.md +18 -8
- package/SECURITY.md +7 -1
- package/dist/{chunk-56UI7LUR.cjs → chunk-2RNW4MIJ.cjs} +37 -0
- package/dist/{chunk-VDXVNZCO.cjs → chunk-43RFBQ73.cjs} +85 -29
- package/dist/{chunk-BE2AIZ3K.js → chunk-46T67CE2.js} +1 -1
- package/dist/{chunk-WRCUDSUJ.js → chunk-4KJ66YRH.js} +61 -3
- package/dist/{chunk-ITQ7WKVC.cjs → chunk-4ZCXK4VI.cjs} +68 -8
- package/dist/{chunk-JFLEEXKP.js → chunk-6WSNS3UV.js} +58 -2
- package/dist/{chunk-W7JHOK7G.cjs → chunk-7G7UOQV4.cjs} +4 -4
- package/dist/{chunk-5KHIQG7Y.cjs → chunk-AYGRYDBX.cjs} +35 -36
- package/dist/{chunk-5SGMJADP.cjs → chunk-BD4LZBVF.cjs} +85 -9
- package/dist/{chunk-OYLZEEHF.cjs → chunk-BK7YIVLK.cjs} +304 -179
- package/dist/{chunk-SEKC7H5Y.cjs → chunk-CBRL2PJA.cjs} +12 -11
- package/dist/{chunk-XWDVPV42.js → chunk-CNP4L3GF.js} +4 -4
- package/dist/{chunk-IVE3QEGD.js → chunk-DRSPMIZ7.js} +28 -1
- package/dist/{chunk-SAGJIEQK.cjs → chunk-EUKPOXWR.cjs} +15 -16
- package/dist/chunk-FT4LNBOS.js +11 -0
- package/dist/{chunk-ITQBDRWX.js → chunk-HETNKZEE.js} +1 -1
- package/dist/{chunk-JJ4R5QXF.js → chunk-KSDSXJ34.js} +1 -1
- package/dist/{chunk-SYHXDHWX.cjs → chunk-LBWRFZR3.cjs} +218 -31
- package/dist/{chunk-ZXCOJY2Z.js → chunk-NFW7AUEX.js} +1 -1
- package/dist/{chunk-FPQBFIUW.cjs → chunk-OL6SHN3D.cjs} +3 -3
- package/dist/{chunk-XSNLAS5M.js → chunk-PD7ME2BT.js} +75 -2
- package/dist/{chunk-FXCW7LVB.js → chunk-QET3Q4JP.js} +94 -9
- package/dist/{chunk-M7V2EDPB.js → chunk-QKKBBH7I.js} +2 -2
- package/dist/{chunk-XXXDQSHE.js → chunk-S2XD75JM.js} +12 -3
- package/dist/{chunk-5SA2HF2W.cjs → chunk-SPGSO5SO.cjs} +31 -22
- package/dist/{chunk-Q7ARQSUH.cjs → chunk-SYHNZSZZ.cjs} +3 -3
- package/dist/{chunk-X56UVEXS.js → chunk-TN65XNTI.js} +248 -120
- package/dist/chunk-U57COLUE.js +56 -0
- package/dist/{chunk-OQZAZIAS.js → chunk-UE5XK2SY.js} +193 -6
- package/dist/{chunk-NS44KBV5.cjs → chunk-UJS4N2XM.cjs} +12 -12
- package/dist/{chunk-IR5AK5U5.js → chunk-V5D7BHW3.js} +4 -5
- package/dist/{chunk-3PQ2RFPC.js → chunk-VHSNYUYV.js} +5 -4
- package/dist/{chunk-CQIPRNS7.cjs → chunk-VR3FREBX.cjs} +3 -3
- package/dist/{chunk-G7G75C46.cjs → chunk-WO72UBQD.cjs} +11 -11
- package/dist/chunk-WOEETTH7.cjs +59 -0
- package/dist/{chunk-QE7ZONJ2.js → chunk-WTK6JDSI.js} +4 -5
- package/dist/{chunk-3ZRHDTEX.cjs → chunk-WUXUWTFW.cjs} +3 -3
- package/dist/{chunk-23F7JIK5.cjs → chunk-YFIWCYHC.cjs} +141 -54
- package/dist/{chunk-FYQ2UW4T.js → chunk-YPYCWLYP.js} +1 -1
- package/dist/chunk-ZQUE2B3Q.cjs +33 -0
- package/dist/core/addresses.d.ts +1 -1
- package/dist/core/errors.d.ts +41 -1
- package/dist/core/revert-mapper.d.ts +77 -0
- package/dist/core/wagmi-compat.d.ts +40 -0
- package/dist/fhe/index.cjs +134 -68
- package/dist/fhe/index.d.cts +2 -1
- package/dist/fhe/index.d.ts +2 -1
- package/dist/fhe/index.js +64 -10
- 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 +45 -4
- package/dist/fhe/sepolia-encryptor.d.ts +38 -0
- package/dist/fhe-airdrop/advanced/index.cjs +9 -9
- package/dist/fhe-airdrop/advanced/index.js +7 -7
- package/dist/fhe-airdrop/advanced/react/index.cjs +14 -14
- package/dist/fhe-airdrop/advanced/react/index.js +10 -10
- package/dist/fhe-airdrop/airdrop.d.ts +9 -0
- package/dist/fhe-airdrop/encryption.d.ts +8 -0
- package/dist/fhe-airdrop/factory.d.ts +86 -1
- package/dist/fhe-airdrop/index.cjs +69 -66
- package/dist/fhe-airdrop/index.d.cts +3 -3
- package/dist/fhe-airdrop/index.d.ts +3 -3
- package/dist/fhe-airdrop/index.js +7 -8
- package/dist/fhe-airdrop/react/index.cjs +176 -135
- package/dist/fhe-airdrop/react/index.d.cts +7 -4
- package/dist/fhe-airdrop/react/index.d.ts +7 -4
- package/dist/fhe-airdrop/react/index.js +43 -16
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +17 -11
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +3 -2
- package/dist/fhe-airdrop/react/useClaim.d.ts +10 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +8 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +8 -0
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +8 -0
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +51 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +1 -1
- package/dist/fhe-airdrop/types.d.ts +56 -0
- package/dist/fhe-disperse/encryption.d.ts +8 -0
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +77 -66
- package/dist/fhe-disperse/index.d.cts +2 -2
- package/dist/fhe-disperse/index.d.ts +2 -2
- package/dist/fhe-disperse/index.js +8 -9
- package/dist/fhe-disperse/react/index.cjs +108 -87
- package/dist/fhe-disperse/react/index.d.cts +4 -2
- package/dist/fhe-disperse/react/index.d.ts +4 -2
- package/dist/fhe-disperse/react/index.js +12 -11
- package/dist/fhe-disperse/react/useCalculateFee.d.ts +7 -0
- package/dist/fhe-disperse/react/useDisperse.d.ts +9 -0
- package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +7 -0
- package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +7 -0
- package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-disperse/singleton.d.ts +29 -0
- package/dist/fhe-disperse/subtotals.d.ts +6 -0
- 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 +15 -15
- package/dist/fhe-vesting/advanced/react/index.js +12 -12
- package/dist/fhe-vesting/encryption.d.ts +8 -0
- package/dist/fhe-vesting/index.cjs +82 -79
- package/dist/fhe-vesting/index.d.cts +2 -2
- package/dist/fhe-vesting/index.d.ts +2 -2
- package/dist/fhe-vesting/index.js +9 -10
- package/dist/fhe-vesting/manager.d.ts +119 -1
- package/dist/fhe-vesting/react/index.cjs +264 -224
- package/dist/fhe-vesting/react/index.d.cts +9 -6
- package/dist/fhe-vesting/react/index.d.ts +9 -6
- package/dist/fhe-vesting/react/index.js +44 -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/useAdminClaim.d.ts +2 -0
- 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 +10 -0
- package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +3 -1
- package/dist/fhe-vesting/react/useCreateVesting.d.ts +8 -0
- 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/useManagerWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +9 -1
- package/dist/fhe-vesting/react/usePreflightCreateVesting.d.ts +37 -0
- package/dist/fhe-vesting/react/useVestingClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
- package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +6 -0
- package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-vesting/types.d.ts +45 -0
- package/dist/index.cjs +93 -86
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -3
- package/dist/testnet-faucet/index.cjs +58 -55
- package/dist/testnet-faucet/index.d.cts +1 -1
- package/dist/testnet-faucet/index.d.ts +1 -1
- package/dist/testnet-faucet/index.js +5 -6
- package/dist/testnet-faucet/react/index.cjs +60 -56
- package/dist/testnet-faucet/react/index.d.cts +3 -2
- package/dist/testnet-faucet/react/index.d.ts +3 -2
- package/dist/testnet-faucet/react/index.js +11 -11
- package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +3 -2
- package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +2 -2
- package/package.json +14 -8
- package/dist/chunk-66IHPTOK.cjs +0 -20
- package/dist/chunk-KWFFIJYX.js +0 -11
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -25
- 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,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
|
|
4
|
+
var viem = require('viem');
|
|
4
5
|
|
|
5
6
|
// src/fhe/scale-ratio.ts
|
|
6
7
|
var FHE_SPLIT_DENOMINATOR = 90090000n;
|
|
@@ -15,7 +16,7 @@ function scaleRatio({
|
|
|
15
16
|
width = "uint128"
|
|
16
17
|
}) {
|
|
17
18
|
if (denominator <= 0n) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
19
20
|
method: "scaleRatio",
|
|
20
21
|
argument: "denominator",
|
|
21
22
|
reason: `must be > 0, got ${denominator}`,
|
|
@@ -23,7 +24,7 @@ function scaleRatio({
|
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
if (numerator < 0n) {
|
|
26
|
-
throw new
|
|
27
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
27
28
|
method: "scaleRatio",
|
|
28
29
|
argument: "numerator",
|
|
29
30
|
reason: `must be >= 0, got ${numerator}`,
|
|
@@ -31,7 +32,7 @@ function scaleRatio({
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
if (minDenominator <= 0n) {
|
|
34
|
-
throw new
|
|
35
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
35
36
|
method: "scaleRatio",
|
|
36
37
|
argument: "minDenominator",
|
|
37
38
|
reason: `must be > 0, got ${minDenominator}`,
|
|
@@ -51,7 +52,7 @@ function scaleRatio({
|
|
|
51
52
|
function assertWithinWidth(value, width, label) {
|
|
52
53
|
const max = width === "uint64" ? MAX_UINT64 : MAX_UINT128;
|
|
53
54
|
if (value > max) {
|
|
54
|
-
throw new
|
|
55
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
55
56
|
method: "scaleRatio",
|
|
56
57
|
argument: label,
|
|
57
58
|
reason: `exceeds ${width} range`,
|
|
@@ -78,7 +79,7 @@ var share = {
|
|
|
78
79
|
const n = toIntegerBigInt(numerator, "share.fraction", "numerator");
|
|
79
80
|
const m = toIntegerBigInt(denominator, "share.fraction", "denominator");
|
|
80
81
|
if (m <= 0n || m > MAX_FRACTION_DENOMINATOR) {
|
|
81
|
-
throw new
|
|
82
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
82
83
|
method: "share.fraction",
|
|
83
84
|
argument: "denominator",
|
|
84
85
|
reason: `must be in 1..${MAX_FRACTION_DENOMINATOR}, got ${m}`,
|
|
@@ -86,7 +87,7 @@ var share = {
|
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
if (n < 0n || n > m) {
|
|
89
|
-
throw new
|
|
90
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
90
91
|
method: "share.fraction",
|
|
91
92
|
argument: "numerator",
|
|
92
93
|
reason: `must be in 0..${m} (denominator), got ${n}`,
|
|
@@ -111,7 +112,7 @@ var share = {
|
|
|
111
112
|
basisPoints(bps) {
|
|
112
113
|
const value = toIntegerBigInt(bps, "share.basisPoints", "bps");
|
|
113
114
|
if (value < 0n || value > BASIS_POINT_SCALE) {
|
|
114
|
-
throw new
|
|
115
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
115
116
|
method: "share.basisPoints",
|
|
116
117
|
argument: "bps",
|
|
117
118
|
reason: `must be in 0..${BASIS_POINT_SCALE}, got ${value}`,
|
|
@@ -124,7 +125,7 @@ var share = {
|
|
|
124
125
|
function toIntegerBigInt(value, method, argument) {
|
|
125
126
|
if (typeof value === "bigint") return value;
|
|
126
127
|
if (!Number.isInteger(value)) {
|
|
127
|
-
throw new
|
|
128
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
128
129
|
method,
|
|
129
130
|
argument,
|
|
130
131
|
reason: `must be an integer, got ${value}`,
|
|
@@ -133,7 +134,82 @@ function toIntegerBigInt(value, method, argument) {
|
|
|
133
134
|
}
|
|
134
135
|
return BigInt(value);
|
|
135
136
|
}
|
|
137
|
+
function resolveEncryptor(source) {
|
|
138
|
+
if (source === void 0) return void 0;
|
|
139
|
+
return typeof source === "function" ? source() : source;
|
|
140
|
+
}
|
|
141
|
+
var MAX_UINT642 = (1n << 64n) - 1n;
|
|
142
|
+
function assertUint64(value, label) {
|
|
143
|
+
if (value < 0n || value > MAX_UINT642) {
|
|
144
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
145
|
+
method: "encryptUint64",
|
|
146
|
+
argument: label,
|
|
147
|
+
reason: `does not fit in uint64 (0..2^64-1)`,
|
|
148
|
+
value
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function encryptUint64({
|
|
153
|
+
encryptor,
|
|
154
|
+
contractAddress,
|
|
155
|
+
userAddress,
|
|
156
|
+
value
|
|
157
|
+
}) {
|
|
158
|
+
assertUint64(value, "value");
|
|
159
|
+
const { handles, inputProof } = await encryptor.encrypt({
|
|
160
|
+
values: [{ value, type: "euint64" }],
|
|
161
|
+
contractAddress,
|
|
162
|
+
userAddress
|
|
163
|
+
});
|
|
164
|
+
if (handles.length !== 1) {
|
|
165
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
166
|
+
method: "encryptUint64",
|
|
167
|
+
argument: "handles",
|
|
168
|
+
reason: `expected 1 handle, got ${handles.length}`,
|
|
169
|
+
value: handles.length
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
handle: chunk2RNW4MIJ_cjs.asEncryptedHandle(viem.bytesToHex(handles[0])),
|
|
174
|
+
inputProof: chunk2RNW4MIJ_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
async function encryptUint64Batch({
|
|
178
|
+
encryptor,
|
|
179
|
+
contractAddress,
|
|
180
|
+
userAddress,
|
|
181
|
+
values
|
|
182
|
+
}) {
|
|
183
|
+
if (values.length === 0) {
|
|
184
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
185
|
+
method: "encryptUint64Batch",
|
|
186
|
+
argument: "values",
|
|
187
|
+
reason: "must be non-empty"
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
values.forEach((v, i) => assertUint64(v, `values[${i}]`));
|
|
191
|
+
const { handles, inputProof } = await encryptor.encrypt({
|
|
192
|
+
values: values.map((value) => ({ value, type: "euint64" })),
|
|
193
|
+
contractAddress,
|
|
194
|
+
userAddress
|
|
195
|
+
});
|
|
196
|
+
if (handles.length !== values.length) {
|
|
197
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
198
|
+
method: "encryptUint64Batch",
|
|
199
|
+
argument: "handles",
|
|
200
|
+
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
201
|
+
value: handles.length
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
handles: handles.map((h) => chunk2RNW4MIJ_cjs.asEncryptedHandle(viem.bytesToHex(h))),
|
|
206
|
+
inputProof: chunk2RNW4MIJ_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
207
|
+
};
|
|
208
|
+
}
|
|
136
209
|
|
|
137
210
|
exports.FHE_SPLIT_DENOMINATOR = FHE_SPLIT_DENOMINATOR;
|
|
211
|
+
exports.encryptUint64 = encryptUint64;
|
|
212
|
+
exports.encryptUint64Batch = encryptUint64Batch;
|
|
213
|
+
exports.resolveEncryptor = resolveEncryptor;
|
|
138
214
|
exports.scaleRatio = scaleRatio;
|
|
139
215
|
exports.share = share;
|