@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.
Files changed (163) hide show
  1. package/CHANGELOG.md +158 -2
  2. package/README.md +18 -8
  3. package/SECURITY.md +7 -1
  4. package/dist/{chunk-56UI7LUR.cjs → chunk-2RNW4MIJ.cjs} +37 -0
  5. package/dist/{chunk-VDXVNZCO.cjs → chunk-43RFBQ73.cjs} +85 -29
  6. package/dist/{chunk-BE2AIZ3K.js → chunk-46T67CE2.js} +1 -1
  7. package/dist/{chunk-WRCUDSUJ.js → chunk-4KJ66YRH.js} +61 -3
  8. package/dist/{chunk-ITQ7WKVC.cjs → chunk-4ZCXK4VI.cjs} +68 -8
  9. package/dist/{chunk-JFLEEXKP.js → chunk-6WSNS3UV.js} +58 -2
  10. package/dist/{chunk-W7JHOK7G.cjs → chunk-7G7UOQV4.cjs} +4 -4
  11. package/dist/{chunk-5KHIQG7Y.cjs → chunk-AYGRYDBX.cjs} +35 -36
  12. package/dist/{chunk-5SGMJADP.cjs → chunk-BD4LZBVF.cjs} +85 -9
  13. package/dist/{chunk-OYLZEEHF.cjs → chunk-BK7YIVLK.cjs} +304 -179
  14. package/dist/{chunk-SEKC7H5Y.cjs → chunk-CBRL2PJA.cjs} +12 -11
  15. package/dist/{chunk-XWDVPV42.js → chunk-CNP4L3GF.js} +4 -4
  16. package/dist/{chunk-IVE3QEGD.js → chunk-DRSPMIZ7.js} +28 -1
  17. package/dist/{chunk-SAGJIEQK.cjs → chunk-EUKPOXWR.cjs} +15 -16
  18. package/dist/chunk-FT4LNBOS.js +11 -0
  19. package/dist/{chunk-ITQBDRWX.js → chunk-HETNKZEE.js} +1 -1
  20. package/dist/{chunk-JJ4R5QXF.js → chunk-KSDSXJ34.js} +1 -1
  21. package/dist/{chunk-SYHXDHWX.cjs → chunk-LBWRFZR3.cjs} +218 -31
  22. package/dist/{chunk-ZXCOJY2Z.js → chunk-NFW7AUEX.js} +1 -1
  23. package/dist/{chunk-FPQBFIUW.cjs → chunk-OL6SHN3D.cjs} +3 -3
  24. package/dist/{chunk-XSNLAS5M.js → chunk-PD7ME2BT.js} +75 -2
  25. package/dist/{chunk-FXCW7LVB.js → chunk-QET3Q4JP.js} +94 -9
  26. package/dist/{chunk-M7V2EDPB.js → chunk-QKKBBH7I.js} +2 -2
  27. package/dist/{chunk-XXXDQSHE.js → chunk-S2XD75JM.js} +12 -3
  28. package/dist/{chunk-5SA2HF2W.cjs → chunk-SPGSO5SO.cjs} +31 -22
  29. package/dist/{chunk-Q7ARQSUH.cjs → chunk-SYHNZSZZ.cjs} +3 -3
  30. package/dist/{chunk-X56UVEXS.js → chunk-TN65XNTI.js} +248 -120
  31. package/dist/chunk-U57COLUE.js +56 -0
  32. package/dist/{chunk-OQZAZIAS.js → chunk-UE5XK2SY.js} +193 -6
  33. package/dist/{chunk-NS44KBV5.cjs → chunk-UJS4N2XM.cjs} +12 -12
  34. package/dist/{chunk-IR5AK5U5.js → chunk-V5D7BHW3.js} +4 -5
  35. package/dist/{chunk-3PQ2RFPC.js → chunk-VHSNYUYV.js} +5 -4
  36. package/dist/{chunk-CQIPRNS7.cjs → chunk-VR3FREBX.cjs} +3 -3
  37. package/dist/{chunk-G7G75C46.cjs → chunk-WO72UBQD.cjs} +11 -11
  38. package/dist/chunk-WOEETTH7.cjs +59 -0
  39. package/dist/{chunk-QE7ZONJ2.js → chunk-WTK6JDSI.js} +4 -5
  40. package/dist/{chunk-3ZRHDTEX.cjs → chunk-WUXUWTFW.cjs} +3 -3
  41. package/dist/{chunk-23F7JIK5.cjs → chunk-YFIWCYHC.cjs} +141 -54
  42. package/dist/{chunk-FYQ2UW4T.js → chunk-YPYCWLYP.js} +1 -1
  43. package/dist/chunk-ZQUE2B3Q.cjs +33 -0
  44. package/dist/core/addresses.d.ts +1 -1
  45. package/dist/core/errors.d.ts +41 -1
  46. package/dist/core/revert-mapper.d.ts +77 -0
  47. package/dist/core/wagmi-compat.d.ts +40 -0
  48. package/dist/fhe/index.cjs +134 -68
  49. package/dist/fhe/index.d.cts +2 -1
  50. package/dist/fhe/index.d.ts +2 -1
  51. package/dist/fhe/index.js +64 -10
  52. package/dist/fhe/mock-erc7984.d.ts +4 -4
  53. package/dist/fhe/operators.d.ts +142 -2
  54. package/dist/fhe/react/index.cjs +21 -8
  55. package/dist/fhe/react/index.d.cts +2 -0
  56. package/dist/fhe/react/index.d.ts +2 -0
  57. package/dist/fhe/react/index.js +8 -3
  58. package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
  59. package/dist/fhe/react/useIsOperator.d.ts +54 -0
  60. package/dist/fhe/sepolia-encryptor-web.d.ts +45 -4
  61. package/dist/fhe/sepolia-encryptor.d.ts +38 -0
  62. package/dist/fhe-airdrop/advanced/index.cjs +9 -9
  63. package/dist/fhe-airdrop/advanced/index.js +7 -7
  64. package/dist/fhe-airdrop/advanced/react/index.cjs +14 -14
  65. package/dist/fhe-airdrop/advanced/react/index.js +10 -10
  66. package/dist/fhe-airdrop/airdrop.d.ts +9 -0
  67. package/dist/fhe-airdrop/encryption.d.ts +8 -0
  68. package/dist/fhe-airdrop/factory.d.ts +86 -1
  69. package/dist/fhe-airdrop/index.cjs +69 -66
  70. package/dist/fhe-airdrop/index.d.cts +3 -3
  71. package/dist/fhe-airdrop/index.d.ts +3 -3
  72. package/dist/fhe-airdrop/index.js +7 -8
  73. package/dist/fhe-airdrop/react/index.cjs +176 -135
  74. package/dist/fhe-airdrop/react/index.d.cts +7 -4
  75. package/dist/fhe-airdrop/react/index.d.ts +7 -4
  76. package/dist/fhe-airdrop/react/index.js +43 -16
  77. package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +17 -11
  78. package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +3 -2
  79. package/dist/fhe-airdrop/react/useClaim.d.ts +10 -0
  80. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +8 -0
  81. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +8 -0
  82. package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +8 -0
  83. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +51 -0
  84. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +1 -1
  85. package/dist/fhe-airdrop/types.d.ts +56 -0
  86. package/dist/fhe-disperse/encryption.d.ts +8 -0
  87. package/dist/fhe-disperse/errors.d.ts +55 -0
  88. package/dist/fhe-disperse/index.cjs +77 -66
  89. package/dist/fhe-disperse/index.d.cts +2 -2
  90. package/dist/fhe-disperse/index.d.ts +2 -2
  91. package/dist/fhe-disperse/index.js +8 -9
  92. package/dist/fhe-disperse/react/index.cjs +108 -87
  93. package/dist/fhe-disperse/react/index.d.cts +4 -2
  94. package/dist/fhe-disperse/react/index.d.ts +4 -2
  95. package/dist/fhe-disperse/react/index.js +12 -11
  96. package/dist/fhe-disperse/react/useCalculateFee.d.ts +7 -0
  97. package/dist/fhe-disperse/react/useDisperse.d.ts +9 -0
  98. package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +7 -0
  99. package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +7 -0
  100. package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +6 -0
  101. package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +6 -0
  102. package/dist/fhe-disperse/singleton.d.ts +29 -0
  103. package/dist/fhe-disperse/subtotals.d.ts +6 -0
  104. package/dist/fhe-vesting/advanced/index.cjs +8 -9
  105. package/dist/fhe-vesting/advanced/index.js +6 -7
  106. package/dist/fhe-vesting/advanced/react/index.cjs +15 -15
  107. package/dist/fhe-vesting/advanced/react/index.js +12 -12
  108. package/dist/fhe-vesting/encryption.d.ts +8 -0
  109. package/dist/fhe-vesting/index.cjs +82 -79
  110. package/dist/fhe-vesting/index.d.cts +2 -2
  111. package/dist/fhe-vesting/index.d.ts +2 -2
  112. package/dist/fhe-vesting/index.js +9 -10
  113. package/dist/fhe-vesting/manager.d.ts +119 -1
  114. package/dist/fhe-vesting/react/index.cjs +264 -224
  115. package/dist/fhe-vesting/react/index.d.cts +9 -6
  116. package/dist/fhe-vesting/react/index.d.ts +9 -6
  117. package/dist/fhe-vesting/react/index.js +44 -21
  118. package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
  119. package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
  120. package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
  121. package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
  122. package/dist/fhe-vesting/react/useAdminClaim.d.ts +2 -0
  123. package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
  124. package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
  125. package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
  126. package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
  127. package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +10 -0
  128. package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +8 -0
  129. package/dist/fhe-vesting/react/useClaim.d.ts +3 -1
  130. package/dist/fhe-vesting/react/useCreateVesting.d.ts +8 -0
  131. package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
  132. package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
  133. package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +6 -0
  134. package/dist/fhe-vesting/react/usePartialClaim.d.ts +9 -1
  135. package/dist/fhe-vesting/react/usePreflightCreateVesting.d.ts +37 -0
  136. package/dist/fhe-vesting/react/useVestingClaim.d.ts +2 -0
  137. package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
  138. package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +6 -0
  139. package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +6 -0
  140. package/dist/fhe-vesting/types.d.ts +45 -0
  141. package/dist/index.cjs +93 -86
  142. package/dist/index.d.cts +1 -1
  143. package/dist/index.d.ts +1 -1
  144. package/dist/index.js +2 -3
  145. package/dist/testnet-faucet/index.cjs +58 -55
  146. package/dist/testnet-faucet/index.d.cts +1 -1
  147. package/dist/testnet-faucet/index.d.ts +1 -1
  148. package/dist/testnet-faucet/index.js +5 -6
  149. package/dist/testnet-faucet/react/index.cjs +60 -56
  150. package/dist/testnet-faucet/react/index.d.cts +3 -2
  151. package/dist/testnet-faucet/react/index.d.ts +3 -2
  152. package/dist/testnet-faucet/react/index.js +11 -11
  153. package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +3 -2
  154. package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +2 -2
  155. package/package.json +14 -8
  156. package/dist/chunk-66IHPTOK.cjs +0 -20
  157. package/dist/chunk-KWFFIJYX.js +0 -11
  158. package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -25
  159. package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
  160. package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
  161. package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
  162. package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
  163. package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk56UI7LUR_cjs = require('./chunk-56UI7LUR.cjs');
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 chunk56UI7LUR_cjs.InvalidArgumentError({
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 chunk56UI7LUR_cjs.InvalidArgumentError({
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 chunk56UI7LUR_cjs.InvalidArgumentError({
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 chunk56UI7LUR_cjs.InvalidArgumentError({
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 chunk56UI7LUR_cjs.InvalidArgumentError({
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 chunk56UI7LUR_cjs.InvalidArgumentError({
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 chunk56UI7LUR_cjs.InvalidArgumentError({
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 chunk56UI7LUR_cjs.InvalidArgumentError({
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;