@tokenops/sdk 1.5.1 → 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 +198 -2
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SECURITY.md +7 -1
- package/SUPPORT.md +47 -0
- package/dist/{chunk-YQIBBEFJ.js → chunk-335Z2W67.js} +1 -1
- package/dist/{chunk-2NCLOQ56.cjs → chunk-3QHNYEQD.cjs} +77 -0
- package/dist/chunk-456VDDA3.js +370 -0
- package/dist/{chunk-SG65XWH7.js → chunk-4RAAATVY.js} +1 -3
- package/dist/{chunk-6BMP4ICG.js → chunk-4TSDNZQ3.js} +60 -2
- package/dist/{chunk-PUPKNW3R.cjs → chunk-5576FRT3.cjs} +30 -6
- package/dist/{chunk-AOP6HMPW.js → chunk-6GNR22OV.js} +75 -1
- package/dist/{chunk-NTZY6IB7.js → chunk-6NAVMWZQ.js} +4 -3
- package/dist/{chunk-C7BRZXJA.cjs → chunk-6PXXGACR.cjs} +8 -7
- package/dist/{chunk-IJFQ5L4I.js → chunk-74QFZ5MK.js} +4 -3
- package/dist/chunk-7AFPOE7N.cjs +59 -0
- package/dist/chunk-AXIPOR3C.js +56 -0
- package/dist/chunk-CTED3MTR.cjs +380 -0
- package/dist/{chunk-XGGTQQFH.js → chunk-DZHYSUGY.js} +28 -7
- package/dist/{chunk-OXTLPTO3.js → chunk-EAJ7SYHE.js} +4 -3
- package/dist/{chunk-V2PXZVBF.cjs → chunk-FGEB7RMY.cjs} +4 -4
- package/dist/chunk-GKKDAW44.js +8823 -0
- package/dist/{chunk-2PWNH3UE.js → chunk-H5POPGOZ.js} +63 -5
- package/dist/{chunk-W7IGCOVL.cjs → chunk-JQYC66TO.cjs} +9 -8
- package/dist/{chunk-PFXURMBZ.cjs → chunk-JZLGCTGK.cjs} +68 -8
- package/dist/{chunk-JYOTGRSO.cjs → chunk-KFRDLKMA.cjs} +61 -1
- package/dist/chunk-M4IT6DNJ.cjs +608 -0
- package/dist/{chunk-KLKI352M.cjs → chunk-MVDQMV25.cjs} +0 -3
- 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-IXLO7GO5.js → chunk-TWT3STIX.js} +46 -80
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/chunk-VP2B4WM2.js +154 -0
- package/dist/{chunk-5X5WL5CU.cjs → chunk-WJLECC22.cjs} +51 -88
- package/dist/{chunk-WENHUPZC.cjs → chunk-XAYGD4E4.cjs} +9 -8
- package/dist/core/addresses.d.ts +15 -3
- 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 +34 -13
- package/dist/fhe/index.d.cts +1 -0
- package/dist/fhe/index.d.ts +1 -0
- package/dist/fhe/index.js +19 -6
- package/dist/fhe/mock-erc7984.d.ts +4 -4
- package/dist/fhe/operators.d.ts +160 -3
- package/dist/fhe/react/index.cjs +14 -0
- package/dist/fhe/react/index.d.cts +2 -0
- package/dist/fhe/react/index.d.ts +2 -0
- package/dist/fhe/react/index.js +6 -0
- 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/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 +10 -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 +2 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +34 -48
- 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 +33 -48
- 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 +1089 -33
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +929 -7
- 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 +364 -413
- package/dist/fhe-airdrop/react/index.d.cts +53 -72
- package/dist/fhe-airdrop/react/index.d.ts +53 -72
- package/dist/fhe-airdrop/react/index.js +258 -369
- 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 +68 -55
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +34 -25
- package/dist/fhe-disperse/index.d.cts +1 -1
- package/dist/fhe-disperse/index.d.ts +1 -1
- package/dist/fhe-disperse/index.js +6 -5
- package/dist/fhe-disperse/react/index.cjs +42 -23
- 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 +9 -6
- package/dist/fhe-vesting/advanced/index.cjs +8 -7
- package/dist/fhe-vesting/advanced/index.js +6 -5
- package/dist/fhe-vesting/advanced/react/index.cjs +12 -11
- package/dist/fhe-vesting/advanced/react/index.js +9 -8
- package/dist/fhe-vesting/index.cjs +35 -34
- package/dist/fhe-vesting/index.js +7 -6
- package/dist/fhe-vesting/manager.d.ts +19 -0
- package/dist/fhe-vesting/react/index.cjs +160 -140
- 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 +24 -16
- 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 +27 -15
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/index.cjs +17 -16
- package/dist/testnet-faucet/index.js +5 -4
- package/dist/testnet-faucet/react/index.cjs +11 -10
- package/dist/testnet-faucet/react/index.js +6 -5
- package/package.json +18 -9
- package/dist/chunk-4WPGQSNT.cjs +0 -44
- package/dist/chunk-6R4KNAPK.js +0 -1630
- package/dist/chunk-DUZIIRPF.js +0 -1655
- package/dist/chunk-MCRBVJGZ.cjs +0 -1637
- package/dist/chunk-ODLTEGHB.js +0 -41
- package/dist/chunk-ORFTDNFZ.js +0 -105
- package/dist/chunk-T46YXSBP.cjs +0 -109
- package/dist/chunk-TIUKIY5V.cjs +0 -1663
- 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 -310
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -31
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
- 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 -31
- 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/useGetClaimAmount.d.ts +0 -30
- 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
- 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
package/README.md
CHANGED
|
@@ -21,27 +21,43 @@ Node `>= 22` is required (constraint from `@zama-fhe/sdk`).
|
|
|
21
21
|
|
|
22
22
|
All subpaths are independently tree-shakeable. The `/react` paths keep React deps out of the server bundle.
|
|
23
23
|
|
|
24
|
-
| Subpath | Status
|
|
25
|
-
| ------------------------------------------ |
|
|
26
|
-
| `@tokenops/sdk` | stable
|
|
27
|
-
| `@tokenops/sdk/telemetry` | stable
|
|
28
|
-
| `@tokenops/sdk/fhe` | stable
|
|
29
|
-
| `@tokenops/sdk/fhe/react` | stable
|
|
30
|
-
| `@tokenops/sdk/fhe-vesting` | factory live on Sepolia
|
|
31
|
-
| `@tokenops/sdk/fhe-vesting/react` | stable
|
|
32
|
-
| `@tokenops/sdk/fhe-vesting/advanced` | stable
|
|
33
|
-
| `@tokenops/sdk/fhe-vesting/advanced/react` | stable
|
|
34
|
-
| `@tokenops/sdk/fhe-airdrop` | factory live on Sepolia
|
|
35
|
-
| `@tokenops/sdk/fhe-airdrop/react` |
|
|
36
|
-
| `@tokenops/sdk/fhe-airdrop/advanced` |
|
|
37
|
-
| `@tokenops/sdk/fhe-airdrop/advanced/react` |
|
|
38
|
-
| `@tokenops/sdk/fhe-disperse` | singleton live on mainnet + Sepolia
|
|
39
|
-
| `@tokenops/sdk/fhe-disperse/react` | stable
|
|
40
|
-
| `@tokenops/sdk/testnet-faucet` | token pair live on Sepolia
|
|
41
|
-
| `@tokenops/sdk/testnet-faucet/react` | stable
|
|
24
|
+
| Subpath | Status | Description |
|
|
25
|
+
| ------------------------------------------ | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| `@tokenops/sdk` | stable | Root re-exports (version, core error types) |
|
|
27
|
+
| `@tokenops/sdk/telemetry` | stable | Telemetry sink adapters (`NoopTelemetry`, `ConsoleTelemetry`, `TokenOpsTelemetry`) |
|
|
28
|
+
| `@tokenops/sdk/fhe` | stable | FHE utility helpers (ratio scaling, encrypted-input types, operator helpers) |
|
|
29
|
+
| `@tokenops/sdk/fhe/react` | stable | React hooks for shared FHE utilities |
|
|
30
|
+
| `@tokenops/sdk/fhe-vesting` | factory live on Sepolia | Confidential vesting (LibClone + packed immutable args) |
|
|
31
|
+
| `@tokenops/sdk/fhe-vesting/react` | stable | React/wagmi hooks for confidential vesting |
|
|
32
|
+
| `@tokenops/sdk/fhe-vesting/advanced` | stable | Pre-mine address prediction (`predictManagerAddress`) |
|
|
33
|
+
| `@tokenops/sdk/fhe-vesting/advanced/react` | stable | React hooks for advanced vesting flows |
|
|
34
|
+
| `@tokenops/sdk/fhe-airdrop` | **v2, unaudited** — `alpha` dist-tag, factory live on Sepolia | ECDSA + Merkle confidential airdrop campaigns — see [Compatibility](#compatibility) |
|
|
35
|
+
| `@tokenops/sdk/fhe-airdrop/react` | **v2, unaudited** | React/wagmi hooks for confidential airdrops |
|
|
36
|
+
| `@tokenops/sdk/fhe-airdrop/advanced` | **v2, unaudited** | Prediction-freshness / salt-availability guards for CREATE2 address prediction (prediction itself is on the headline `ConfidentialAirdropFactoryClient`) |
|
|
37
|
+
| `@tokenops/sdk/fhe-airdrop/advanced/react` | **v2, unaudited** | `usePredictEcdsaAirdropAddress` / `usePredictMerkleAirdropAddress` |
|
|
38
|
+
| `@tokenops/sdk/fhe-disperse` | singleton live on mainnet + Sepolia | DisperseConfidential (singleton + per-user wallet-pair clones) |
|
|
39
|
+
| `@tokenops/sdk/fhe-disperse/react` | stable | React/wagmi hooks for confidential disperse |
|
|
40
|
+
| `@tokenops/sdk/testnet-faucet` | token pair live on Sepolia | Testnet faucet for the TokenOps test-token pair — TTT (plain ERC-20) + CTTT (ERC-7984 wrapper); open mint |
|
|
41
|
+
| `@tokenops/sdk/testnet-faucet/react` | stable | React/wagmi hooks for the testnet faucet |
|
|
42
42
|
|
|
43
43
|
The canonical exports map is in [`package.json`](https://github.com/VestingLabs/tokenops-sdk/blob/main/package.json) under `"exports"`.
|
|
44
44
|
|
|
45
|
+
## Compatibility
|
|
46
|
+
|
|
47
|
+
Which contract generation a given SDK version talks to, and where that generation is deployed:
|
|
48
|
+
|
|
49
|
+
| SDK | Airdrop contracts | Contract commit | Chains |
|
|
50
|
+
| --------------- | ------------------ | --------------- | ------- |
|
|
51
|
+
| `2.0.0-alpha.x` | v2 (**unaudited**) | `8e5b144` | Sepolia |
|
|
52
|
+
| `1.x` | v1 | n/a | Sepolia |
|
|
53
|
+
|
|
54
|
+
`2.x`'s `/fhe-airdrop` is a full replacement of v1, not an extension — see
|
|
55
|
+
[`docs/migration/airdrop-v1-to-v2.md`](docs/migration/airdrop-v1-to-v2.md) for the symbol-by-symbol
|
|
56
|
+
delta and [`SUPPORT.md`](SUPPORT.md) for how long `1.x` keeps receiving fixes. The v1 Sepolia
|
|
57
|
+
factory (`0xbE6A3B78B36684fFee48De77d47Bc3393F5Acd4c`) stays live on-chain; `2.x` simply stops
|
|
58
|
+
addressing it. `/fhe-vesting` and `/fhe-disperse` are unaffected by this table — both are on their
|
|
59
|
+
usual SemVer track regardless of which `/fhe-airdrop` line you install.
|
|
60
|
+
|
|
45
61
|
## Quickstart — confidential vesting
|
|
46
62
|
|
|
47
63
|
```ts
|
|
@@ -268,17 +284,22 @@ See [Confidential Vesting — React hooks on docs.tokenops.xyz](https://docs.tok
|
|
|
268
284
|
|
|
269
285
|
## Quickstart — confidential airdrop
|
|
270
286
|
|
|
287
|
+
> **v2, unaudited.** `/fhe-airdrop` targets `tokenops-fhe-airdrop-v2` (`8e5b144`, Sepolia only, `alpha` dist-tag) — see [Compatibility](#compatibility). Migrating from `1.x`? See [`docs/migration/airdrop-v1-to-v2.md`](docs/migration/airdrop-v1-to-v2.md).
|
|
288
|
+
|
|
289
|
+
Two claim-authorisation variants share one factory: **ECDSA** (an off-chain signature from a `SIGNER_ROLE` holder) and **Merkle** (inclusion in a published tree). The example below is ECDSA — see [`docs/fhe-airdrop/README.md`](docs/fhe-airdrop/README.md#quickstart--merkle-campaign) for the Merkle flow.
|
|
290
|
+
|
|
271
291
|
```ts
|
|
272
|
-
import { createPublicClient, createWalletClient, http } from "viem";
|
|
292
|
+
import { createPublicClient, createWalletClient, http, zeroAddress } from "viem";
|
|
273
293
|
import { sepolia } from "viem/chains";
|
|
274
294
|
import { privateKeyToAccount } from "viem/accounts";
|
|
275
295
|
import { RelayerNode, SepoliaConfig } from "@zama-fhe/sdk/node";
|
|
276
296
|
import {
|
|
277
297
|
createConfidentialAirdropFactoryClient,
|
|
278
|
-
|
|
298
|
+
createEcdsaAirdropClient,
|
|
279
299
|
encryptUint64,
|
|
280
300
|
signClaimAuthorization,
|
|
281
301
|
} from "@tokenops/sdk/fhe-airdrop";
|
|
302
|
+
import { setOperator } from "@tokenops/sdk/fhe";
|
|
282
303
|
|
|
283
304
|
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
|
284
305
|
const rpcUrl = process.env.RPC_URL!;
|
|
@@ -291,80 +312,98 @@ const encryptor = new RelayerNode({
|
|
|
291
312
|
});
|
|
292
313
|
|
|
293
314
|
// Factory address resolves automatically from DEPLOYED_ADDRESSES on Sepolia.
|
|
294
|
-
const factory = createConfidentialAirdropFactoryClient({
|
|
295
|
-
publicClient,
|
|
296
|
-
walletClient,
|
|
297
|
-
encryptor,
|
|
298
|
-
});
|
|
315
|
+
const factory = createConfidentialAirdropFactoryClient({ publicClient, walletClient, encryptor });
|
|
299
316
|
|
|
300
317
|
const now = Math.floor(Date.now() / 1000);
|
|
301
318
|
const userSalt = "0x0000000000000000000000000000000000000000000000000000000000000001" as const;
|
|
302
319
|
const token = process.env.TOKEN as `0x${string}`;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
320
|
+
|
|
321
|
+
// Create. There is no `admin` field — the factory injects `admin = msg.sender`.
|
|
322
|
+
// `dedupMode` is required and cannot be read back from the chain later; record
|
|
323
|
+
// it yourself alongside the deployed address.
|
|
324
|
+
const { airdrop: airdropAddress } = await factory.createEcdsaAirdrop({
|
|
325
|
+
params: {
|
|
326
|
+
common: {
|
|
327
|
+
token,
|
|
328
|
+
startTime: now + 60,
|
|
329
|
+
endTime: now + 30 * 86400,
|
|
330
|
+
canExtendClaimWindow: false,
|
|
331
|
+
unwrappable: false,
|
|
332
|
+
complianceAdmin: zeroAddress, // zero => msg.sender
|
|
333
|
+
},
|
|
334
|
+
signer: account.address, // SIGNER_ROLE holder authorising claims
|
|
335
|
+
dedupMode: "perAddress",
|
|
336
|
+
},
|
|
337
|
+
mode: "clone",
|
|
316
338
|
userSalt,
|
|
317
339
|
});
|
|
318
340
|
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
//
|
|
341
|
+
// Fund. Requires the factory to hold ERC-7984 operator approval first — the
|
|
342
|
+
// FACTORY calls FHE.fromExternal on the pool amount, so the operator grant
|
|
343
|
+
// and the encryption both bind to the factory, not to the airdrop instance.
|
|
344
|
+
await setOperator({ publicClient, walletClient, token, spender: factory.address });
|
|
345
|
+
await factory.fundAirdrop({ airdrop: airdropAddress, amount: 1_000_000n });
|
|
346
|
+
|
|
347
|
+
// Admin: sign a claim authorization for a recipient. Bind the input proof to
|
|
348
|
+
// the RECIPIENT and to the AIRDROP INSTANCE — Zama proofs commit to
|
|
349
|
+
// (contractAddress, userAddress) at encrypt time, and a claim binds to
|
|
350
|
+
// (instance, claimant), not (factory, funder). Get the pair wrong and
|
|
351
|
+
// `FHE.fromExternal` reverts; it does not silently decrypt to zero.
|
|
322
352
|
// amount is raw token units; ERC-7984 uses 6 decimals, so 1_000_000n = 1 token.
|
|
323
353
|
const recipient = "0xRecipientAddress" as `0x${string}`;
|
|
324
|
-
const
|
|
354
|
+
const encryptedInput = await encryptUint64({
|
|
325
355
|
encryptor,
|
|
326
356
|
contractAddress: airdropAddress,
|
|
327
357
|
userAddress: recipient,
|
|
328
358
|
value: 1_000_000n,
|
|
329
359
|
});
|
|
360
|
+
const dedupId = "0x0000000000000000000000000000000000000000000000000000000000000001" as const;
|
|
361
|
+
const deadline = BigInt(now + 3600); // signature expires in 1 hour
|
|
330
362
|
const signature = await signClaimAuthorization({
|
|
331
363
|
walletClient,
|
|
332
|
-
airdropAddress,
|
|
364
|
+
airdrop: airdropAddress,
|
|
365
|
+
chainId: sepolia.id,
|
|
333
366
|
recipient,
|
|
334
|
-
encryptedAmountHandle:
|
|
367
|
+
encryptedAmountHandle: encryptedInput.handle,
|
|
368
|
+
dedupId,
|
|
369
|
+
deadline,
|
|
335
370
|
});
|
|
336
|
-
// Deliver { encryptedInput:
|
|
371
|
+
// Deliver { encryptedInput, dedupId, deadline, signer: account.address, signature }
|
|
372
|
+
// to the recipient via API / email / etc.
|
|
337
373
|
|
|
338
374
|
// User: claim tokens. The SDK submits the admin-issued pair verbatim — no
|
|
339
|
-
// re-encryption.
|
|
340
|
-
|
|
375
|
+
// re-encryption. The exact-equality gas fee (0 on the live Sepolia deployment
|
|
376
|
+
// today) is fetched fresh and attached as msg.value automatically.
|
|
377
|
+
const airdrop = createEcdsaAirdropClient({
|
|
341
378
|
publicClient,
|
|
342
379
|
walletClient,
|
|
343
380
|
address: airdropAddress,
|
|
381
|
+
dedupMode: "perAddress", // must match what was passed at create — no getter exists
|
|
344
382
|
});
|
|
345
|
-
await airdrop.claim({
|
|
383
|
+
await airdrop.claim({ encryptedInput, dedupId, deadline, signer: account.address, signature });
|
|
346
384
|
```
|
|
347
385
|
|
|
348
|
-
See [
|
|
386
|
+
See [`docs/fhe-airdrop/README.md`](docs/fhe-airdrop/README.md) for the full API reference, the Merkle campaign flow, guardrails, and the unaudited-contracts warning.
|
|
349
387
|
|
|
350
388
|
### Quickstart — confidential airdrop (React hooks)
|
|
351
389
|
|
|
352
|
-
Uses `@tokenops/sdk/fhe-airdrop/react`. Requires `wagmi`, `@tanstack/react-query`, and `@zama-fhe/react-sdk` as additional peer deps.
|
|
390
|
+
Uses `@tokenops/sdk/fhe-airdrop/react`. Requires `wagmi`, `@tanstack/react-query`, and `@zama-fhe/react-sdk` as additional peer deps. `signClaimAuthorization` is re-exported as a plain function (not a mutation hook) — signing is a synchronous `walletClient.signTypedData` call with no chain state to invalidate.
|
|
353
391
|
|
|
354
392
|
```tsx
|
|
355
|
-
import {
|
|
393
|
+
import { useWalletClient } from "wagmi";
|
|
356
394
|
import { useZamaSDK } from "@zama-fhe/react-sdk";
|
|
357
395
|
import {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
396
|
+
useCreateEcdsaAirdrop,
|
|
397
|
+
useFundAirdrop,
|
|
398
|
+
useEcdsaClaim,
|
|
361
399
|
encryptUint64,
|
|
400
|
+
signClaimAuthorization,
|
|
362
401
|
} from "@tokenops/sdk/fhe-airdrop/react";
|
|
363
402
|
|
|
364
403
|
// Wrap your app in wagmi's <WagmiProvider> + <QueryClientProvider> +
|
|
365
404
|
// @zama-fhe/react-sdk's <ZamaProvider> before rendering these components.
|
|
366
405
|
|
|
367
|
-
// --- Admin: deploy a campaign and issue a claim authorization ---
|
|
406
|
+
// --- Admin: deploy a campaign, fund it, and issue a claim authorization ---
|
|
368
407
|
|
|
369
408
|
function AdminPanel({
|
|
370
409
|
token,
|
|
@@ -379,58 +418,79 @@ function AdminPanel({
|
|
|
379
418
|
airdrop: `0x${string}`,
|
|
380
419
|
payload: {
|
|
381
420
|
encryptedInput: { handle: `0x${string}`; inputProof: `0x${string}` };
|
|
421
|
+
dedupId: `0x${string}`;
|
|
422
|
+
deadline: bigint;
|
|
423
|
+
signer: `0x${string}`;
|
|
382
424
|
signature: `0x${string}`;
|
|
383
425
|
},
|
|
384
426
|
) => void;
|
|
385
427
|
}) {
|
|
386
|
-
const queryClient = useQueryClient();
|
|
387
428
|
const zamaSDK = useZamaSDK();
|
|
429
|
+
const { data: walletClient } = useWalletClient();
|
|
388
430
|
|
|
389
431
|
// Factory address resolves automatically from DEPLOYED_ADDRESSES on Sepolia.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const sign = useSignClaimAuthorization();
|
|
432
|
+
// `useCreateEcdsaAirdrop` invalidates the factory registry reads for you.
|
|
433
|
+
const create = useCreateEcdsaAirdrop({ encryptor: () => zamaSDK.relayer });
|
|
434
|
+
const fund = useFundAirdrop({ encryptor: () => zamaSDK.relayer });
|
|
394
435
|
|
|
395
436
|
const now = Math.floor(Date.now() / 1000);
|
|
396
437
|
|
|
397
438
|
async function handleLaunch() {
|
|
398
439
|
const { airdrop } = await create.mutateAsync({
|
|
399
440
|
params: {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
441
|
+
common: {
|
|
442
|
+
token,
|
|
443
|
+
startTime: now + 60,
|
|
444
|
+
endTime: now + 30 * 86400,
|
|
445
|
+
canExtendClaimWindow: false,
|
|
446
|
+
unwrappable: false,
|
|
447
|
+
complianceAdmin: "0x0000000000000000000000000000000000000000",
|
|
448
|
+
},
|
|
449
|
+
signer: "0xYourSignerAddress" as `0x${string}`,
|
|
450
|
+
dedupMode: "perAddress", // record this — no on-chain getter exists later
|
|
405
451
|
},
|
|
452
|
+
mode: "clone",
|
|
406
453
|
userSalt:
|
|
407
454
|
"0x0000000000000000000000000000000000000000000000000000000000000001" as `0x${string}`,
|
|
408
455
|
});
|
|
409
456
|
|
|
410
|
-
|
|
457
|
+
await fund.mutateAsync({ airdrop, amount });
|
|
411
458
|
|
|
412
|
-
// Encrypt
|
|
413
|
-
const
|
|
459
|
+
// Encrypt bound to (airdrop instance, recipient) — not the factory.
|
|
460
|
+
const encryptedInput = await encryptUint64({
|
|
414
461
|
encryptor: zamaSDK.relayer,
|
|
415
462
|
contractAddress: airdrop,
|
|
416
463
|
userAddress: recipient,
|
|
417
464
|
value: amount,
|
|
418
465
|
});
|
|
419
466
|
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
|
|
467
|
+
const dedupId = "0x0000000000000000000000000000000000000000000000000000000000000001" as const;
|
|
468
|
+
const deadline = BigInt(now + 3600);
|
|
469
|
+
|
|
470
|
+
// Sign is a plain async function here — walletClient comes from wagmi.
|
|
471
|
+
const signature = await signClaimAuthorization({
|
|
472
|
+
walletClient: walletClient!,
|
|
473
|
+
airdrop,
|
|
474
|
+
chainId: walletClient!.chain.id,
|
|
423
475
|
recipient,
|
|
424
|
-
encryptedAmountHandle:
|
|
476
|
+
encryptedAmountHandle: encryptedInput.handle,
|
|
477
|
+
dedupId,
|
|
478
|
+
deadline,
|
|
425
479
|
});
|
|
426
480
|
|
|
427
|
-
// Deliver
|
|
428
|
-
onCampaignReady(airdrop, {
|
|
481
|
+
// Deliver this payload to the recipient via your API / email.
|
|
482
|
+
onCampaignReady(airdrop, {
|
|
483
|
+
encryptedInput,
|
|
484
|
+
dedupId,
|
|
485
|
+
deadline,
|
|
486
|
+
signer: "0xYourSignerAddress" as `0x${string}`,
|
|
487
|
+
signature,
|
|
488
|
+
});
|
|
429
489
|
}
|
|
430
490
|
|
|
431
491
|
return (
|
|
432
|
-
<button onClick={handleLaunch} disabled={create.isPending ||
|
|
433
|
-
{create.isPending ? "Deploying…" :
|
|
492
|
+
<button onClick={handleLaunch} disabled={create.isPending || fund.isPending}>
|
|
493
|
+
{create.isPending ? "Deploying…" : fund.isPending ? "Funding…" : "Launch airdrop"}
|
|
434
494
|
</button>
|
|
435
495
|
);
|
|
436
496
|
}
|
|
@@ -442,33 +502,29 @@ function RecipientClaim({
|
|
|
442
502
|
claimPayload,
|
|
443
503
|
}: {
|
|
444
504
|
airdropAddress: `0x${string}`;
|
|
445
|
-
// The admin-issued payload — encryption bound to this recipient
|
|
446
|
-
// committed to by the signature.
|
|
505
|
+
// The admin-issued payload — encryption bound to this recipient and this
|
|
506
|
+
// instance, handle committed to by the signature. Submitted verbatim.
|
|
447
507
|
claimPayload: {
|
|
448
508
|
encryptedInput: { handle: `0x${string}`; inputProof: `0x${string}` };
|
|
509
|
+
dedupId: `0x${string}`;
|
|
510
|
+
deadline: bigint;
|
|
511
|
+
signer: `0x${string}`;
|
|
449
512
|
signature: `0x${string}`;
|
|
450
513
|
};
|
|
451
514
|
}) {
|
|
452
|
-
|
|
453
|
-
|
|
515
|
+
// `dedupMode` must match what the campaign was created with — the contract
|
|
516
|
+
// has no on-chain getter, so a consumer must already know it.
|
|
517
|
+
const claim = useEcdsaClaim({ address: airdropAddress, dedupMode: "perAddress" });
|
|
454
518
|
|
|
455
519
|
return (
|
|
456
|
-
<button
|
|
457
|
-
onClick={() =>
|
|
458
|
-
claim.mutate(claimPayload, {
|
|
459
|
-
onSuccess: () =>
|
|
460
|
-
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-airdrop"] }),
|
|
461
|
-
})
|
|
462
|
-
}
|
|
463
|
-
disabled={claim.isPending}
|
|
464
|
-
>
|
|
520
|
+
<button onClick={() => claim.mutate(claimPayload)} disabled={claim.isPending}>
|
|
465
521
|
{claim.isPending ? "Claiming…" : "Claim tokens"}
|
|
466
522
|
</button>
|
|
467
523
|
);
|
|
468
524
|
}
|
|
469
525
|
```
|
|
470
526
|
|
|
471
|
-
See [
|
|
527
|
+
See [`docs/fhe-airdrop/README.md`](docs/fhe-airdrop/README.md) for the full hook catalogue (including the Merkle-side `useCreateMerkleAirdrop` / `useMerkleClaim` / `useSetMerkleRoot`), encryptor wiring, address overrides, and query-key reference.
|
|
472
528
|
|
|
473
529
|
## Quickstart — confidential disperse
|
|
474
530
|
|
package/SECURITY.md
CHANGED
|
@@ -46,7 +46,7 @@ The following are **not in scope** for this SDK's security policy:
|
|
|
46
46
|
|
|
47
47
|
**Encryptor binding is address-scoped.** Input proofs from `encryptUint64` are bound to `(contractAddress, userAddress)` — they cannot be replayed against a different contract or submitted by a different sender. Do not reuse proofs across different contract deployments.
|
|
48
48
|
|
|
49
|
-
**Operator approvals (`setOperator`) have a deadline.**
|
|
49
|
+
**Operator approvals (`setOperator`) have a deadline — scope it in production.** The SDK exports `ERC7984_OPERATOR_MAX_DEADLINE` (the `uint48` max, effectively forever) as the default when a consumer doesn't care about expiry — appropriate for local-chain dev loops and test fixtures, not for production. For production flows, scope the deadline to the expected operation window (e.g. `Date.now()/1000 + 3600`) and call `revokeOperator` when the authorization is no longer needed. The SDK validates that the deadline is within the `uint48` range but does **not** warn when a supplied deadline is already in the past — a past-but-otherwise-valid deadline is accepted silently.
|
|
50
50
|
|
|
51
51
|
## Supported Versions
|
|
52
52
|
|
|
@@ -54,6 +54,12 @@ The following are **not in scope** for this SDK's security policy:
|
|
|
54
54
|
| ------- | ------------------ |
|
|
55
55
|
| 1.x | :white_check_mark: |
|
|
56
56
|
|
|
57
|
+
## Known Advisories
|
|
58
|
+
|
|
59
|
+
Open Dependabot alerts against this repo are all **transitive** — the SDK's only runtime dependency is `abitype`. The remaining alerts (e.g. `axios`, reached via `wagmi` → `@wagmi/connectors` → `@base-org/account` → `@coinbase/cdp-sdk`; and `hono`, reached via `porto`) come in through the `wagmi` **peer** dependency tree, not through anything this SDK ships at runtime.
|
|
60
|
+
|
|
61
|
+
This repo's `pnpm.overrides` pin those transitive versions for our own lockfile, which fixes CI and our security dashboard — but that pin has no effect for consumers, who resolve their own `wagmi`/peer dependency tree at install time. Consumers running `npm audit` (or similar) against their own install may still see these advisories; that reflects their resolved tree, not a vulnerability this SDK ships. Real remediation is upstream, in `wagmi`'s own dependency graph.
|
|
62
|
+
|
|
57
63
|
## Acknowledgments
|
|
58
64
|
|
|
59
65
|
We will acknowledge reporters in the relevant release notes unless they request anonymity.
|
package/SUPPORT.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Support policy
|
|
2
|
+
|
|
3
|
+
This document states what level of support each `@tokenops/sdk` release line receives. It exists
|
|
4
|
+
because `2.0.0` is a major version driven by a full replacement of the `/fhe-airdrop` module
|
|
5
|
+
(v1 deleted, v2 takes the subpath) — see
|
|
6
|
+
[`docs/migration/airdrop-v1-to-v2.md`](docs/migration/airdrop-v1-to-v2.md) for the technical
|
|
7
|
+
delta.
|
|
8
|
+
|
|
9
|
+
## `1.x`
|
|
10
|
+
|
|
11
|
+
- **Critical security and correctness fixes only, for 90 days after `2.0.0` reaches `latest`
|
|
12
|
+
(GA).** After that window, `1.x` receives no further fixes of any kind.
|
|
13
|
+
- **No feature work on `1.x` from the day `release/v2` was opened (2026-09-05).** Every new
|
|
14
|
+
capability lands on the `2.x` line only, starting from that date.
|
|
15
|
+
- `1.x` is what you stay on if you depend on the v1 `/fhe-airdrop` shape and are not ready to
|
|
16
|
+
migrate — nothing about `1.x` breaks or is withdrawn by `2.0.0` shipping. Consumers that do not
|
|
17
|
+
import `/fhe-airdrop` are unaffected by the replacement and can move on their own schedule.
|
|
18
|
+
- The v1 contracts stay live on-chain throughout and beyond this window. This policy governs the
|
|
19
|
+
SDK's code, not contract uptime.
|
|
20
|
+
|
|
21
|
+
## `2.x`
|
|
22
|
+
|
|
23
|
+
- `2.0.0-alpha.x` and `2.0.0-beta.x` are pre-release channels for the airdrop v2 rewrite. No
|
|
24
|
+
stability promise between alpha builds; breaking changes may land between any two alpha
|
|
25
|
+
versions without a major bump, per SemVer's prerelease semantics. See the compatibility matrix
|
|
26
|
+
in [`README.md`](README.md#compatibility) for which contract commit each build speaks to.
|
|
27
|
+
- `2.0.0` (GA, `latest` dist-tag) ships once `tokenops-fhe-airdrop-v2` is audited and its
|
|
28
|
+
addresses are final. From GA onward, `2.x` follows the SDK's normal SemVer + Conventional
|
|
29
|
+
Commits support model — the same one `1.x` operated under before this document existed.
|
|
30
|
+
|
|
31
|
+
## Why `npm deprecate` is not used on the `1.x` range
|
|
32
|
+
|
|
33
|
+
`npm deprecate` operates on the package as a whole, scoped by version range — it has no concept
|
|
34
|
+
of "deprecate this subpath only." Running it against the `1.x` range would print a deprecation
|
|
35
|
+
warning on every install of `@tokenops/sdk@1.x`, including installs that use only `/fhe-vesting`
|
|
36
|
+
or `/fhe-disperse` — modules that are not being replaced and are not affected by this migration.
|
|
37
|
+
A package-wide deprecation notice would misrepresent the status of code that isn't changing. The
|
|
38
|
+
`1.x` line is fully supported per the window above; only the `/fhe-airdrop` _shape_ is superseded,
|
|
39
|
+
and that message belongs in the migration guide and the module README, not in an npm-wide flag
|
|
40
|
+
that cannot be scoped to one subpath.
|
|
41
|
+
|
|
42
|
+
## Getting help
|
|
43
|
+
|
|
44
|
+
- Migrating off v1 `/fhe-airdrop`: [`docs/migration/airdrop-v1-to-v2.md`](docs/migration/airdrop-v1-to-v2.md).
|
|
45
|
+
- Module docs (v2, unaudited): [`docs/fhe-airdrop/README.md`](docs/fhe-airdrop/README.md).
|
|
46
|
+
- Security issues: see [`SECURITY.md`](SECURITY.md).
|
|
47
|
+
- Everything else: open an issue against `VestingLabs/tokenops-sdk`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfidentialVestingFactoryClient, confidentialVestingFactoryAbi } from './chunk-
|
|
1
|
+
import { ConfidentialVestingFactoryClient, confidentialVestingFactoryAbi } from './chunk-EAJ7SYHE.js';
|
|
2
2
|
|
|
3
3
|
// src/fhe-vesting/advanced/factory-advanced.ts
|
|
4
4
|
var ConfidentialVestingFactoryAdvancedClient = class extends ConfidentialVestingFactoryClient {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
3
4
|
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
5
|
+
var viem = require('viem');
|
|
4
6
|
|
|
5
7
|
// src/fhe/scale-ratio.ts
|
|
6
8
|
var FHE_SPLIT_DENOMINATOR = 90090000n;
|
|
@@ -133,7 +135,82 @@ function toIntegerBigInt(value, method, argument) {
|
|
|
133
135
|
}
|
|
134
136
|
return BigInt(value);
|
|
135
137
|
}
|
|
138
|
+
function resolveEncryptor(source) {
|
|
139
|
+
if (source === void 0) return void 0;
|
|
140
|
+
return typeof source === "function" ? source() : source;
|
|
141
|
+
}
|
|
142
|
+
var MAX_UINT642 = (1n << 64n) - 1n;
|
|
143
|
+
function assertUint64(value, label) {
|
|
144
|
+
if (value < 0n || value > MAX_UINT642) {
|
|
145
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
146
|
+
method: "encryptUint64",
|
|
147
|
+
argument: label,
|
|
148
|
+
reason: `does not fit in uint64 (0..2^64-1)`,
|
|
149
|
+
value
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function encryptUint64({
|
|
154
|
+
encryptor,
|
|
155
|
+
contractAddress,
|
|
156
|
+
userAddress,
|
|
157
|
+
value
|
|
158
|
+
}) {
|
|
159
|
+
assertUint64(value, "value");
|
|
160
|
+
const { handles, inputProof } = await encryptor.encrypt({
|
|
161
|
+
values: [{ value, type: "euint64" }],
|
|
162
|
+
contractAddress,
|
|
163
|
+
userAddress
|
|
164
|
+
});
|
|
165
|
+
if (handles.length !== 1) {
|
|
166
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
167
|
+
method: "encryptUint64",
|
|
168
|
+
argument: "handles",
|
|
169
|
+
reason: `expected 1 handle, got ${handles.length}`,
|
|
170
|
+
value: handles.length
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
handle: chunk66IHPTOK_cjs.asEncryptedHandle(viem.bytesToHex(handles[0])),
|
|
175
|
+
inputProof: chunk66IHPTOK_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
async function encryptUint64Batch({
|
|
179
|
+
encryptor,
|
|
180
|
+
contractAddress,
|
|
181
|
+
userAddress,
|
|
182
|
+
values
|
|
183
|
+
}) {
|
|
184
|
+
if (values.length === 0) {
|
|
185
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
186
|
+
method: "encryptUint64Batch",
|
|
187
|
+
argument: "values",
|
|
188
|
+
reason: "must be non-empty"
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
values.forEach((v, i) => assertUint64(v, `values[${i}]`));
|
|
192
|
+
const { handles, inputProof } = await encryptor.encrypt({
|
|
193
|
+
values: values.map((value) => ({ value, type: "euint64" })),
|
|
194
|
+
contractAddress,
|
|
195
|
+
userAddress
|
|
196
|
+
});
|
|
197
|
+
if (handles.length !== values.length) {
|
|
198
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
199
|
+
method: "encryptUint64Batch",
|
|
200
|
+
argument: "handles",
|
|
201
|
+
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
202
|
+
value: handles.length
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
handles: handles.map((h) => chunk66IHPTOK_cjs.asEncryptedHandle(viem.bytesToHex(h))),
|
|
207
|
+
inputProof: chunk66IHPTOK_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
208
|
+
};
|
|
209
|
+
}
|
|
136
210
|
|
|
137
211
|
exports.FHE_SPLIT_DENOMINATOR = FHE_SPLIT_DENOMINATOR;
|
|
212
|
+
exports.encryptUint64 = encryptUint64;
|
|
213
|
+
exports.encryptUint64Batch = encryptUint64Batch;
|
|
214
|
+
exports.resolveEncryptor = resolveEncryptor;
|
|
138
215
|
exports.scaleRatio = scaleRatio;
|
|
139
216
|
exports.share = share;
|