@tokenops/sdk 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +158 -2
  2. package/SECURITY.md +7 -1
  3. package/dist/{chunk-67OV5CX2.cjs → chunk-2RNW4MIJ.cjs} +18 -0
  4. package/dist/{chunk-KLKI352M.cjs → chunk-43RFBQ73.cjs} +29 -29
  5. package/dist/{chunk-ZA673I3O.js → chunk-46T67CE2.js} +1 -1
  6. package/dist/{chunk-6BMP4ICG.js → chunk-4KJ66YRH.js} +61 -3
  7. package/dist/{chunk-JYOTGRSO.cjs → chunk-4ZCXK4VI.cjs} +68 -8
  8. package/dist/{chunk-SG65XWH7.js → chunk-6WSNS3UV.js} +1 -1
  9. package/dist/{chunk-V2PXZVBF.cjs → chunk-7G7UOQV4.cjs} +4 -4
  10. package/dist/{chunk-WENHUPZC.cjs → chunk-AYGRYDBX.cjs} +35 -36
  11. package/dist/{chunk-2NCLOQ56.cjs → chunk-BD4LZBVF.cjs} +85 -9
  12. package/dist/{chunk-5X5WL5CU.cjs → chunk-BK7YIVLK.cjs} +110 -149
  13. package/dist/{chunk-W7IGCOVL.cjs → chunk-CBRL2PJA.cjs} +12 -11
  14. package/dist/{chunk-ORFTDNFZ.js → chunk-CNP4L3GF.js} +4 -4
  15. package/dist/{chunk-QBJ7O2B4.js → chunk-DRSPMIZ7.js} +11 -1
  16. package/dist/{chunk-C7BRZXJA.cjs → chunk-EUKPOXWR.cjs} +15 -16
  17. package/dist/{chunk-YQIBBEFJ.js → chunk-HETNKZEE.js} +1 -1
  18. package/dist/{chunk-ODLTEGHB.js → chunk-KSDSXJ34.js} +1 -1
  19. package/dist/{chunk-TIUKIY5V.cjs → chunk-LBWRFZR3.cjs} +58 -40
  20. package/dist/{chunk-WMACINXO.js → chunk-NFW7AUEX.js} +1 -1
  21. package/dist/{chunk-4WPGQSNT.cjs → chunk-OL6SHN3D.cjs} +3 -3
  22. package/dist/{chunk-AOP6HMPW.js → chunk-PD7ME2BT.js} +75 -2
  23. package/dist/{chunk-2PWNH3UE.js → chunk-QET3Q4JP.js} +65 -9
  24. package/dist/{chunk-XGGTQQFH.js → chunk-QKKBBH7I.js} +2 -2
  25. package/dist/{chunk-6R4KNAPK.js → chunk-S2XD75JM.js} +10 -3
  26. package/dist/{chunk-MCRBVJGZ.cjs → chunk-SPGSO5SO.cjs} +29 -22
  27. package/dist/{chunk-FAXIIH5R.cjs → chunk-SYHNZSZZ.cjs} +3 -3
  28. package/dist/{chunk-IXLO7GO5.js → chunk-TN65XNTI.js} +47 -83
  29. package/dist/chunk-U57COLUE.js +56 -0
  30. package/dist/{chunk-DUZIIRPF.js → chunk-UE5XK2SY.js} +27 -9
  31. package/dist/{chunk-TEBM66WA.cjs → chunk-UJS4N2XM.cjs} +12 -12
  32. package/dist/{chunk-OXTLPTO3.js → chunk-V5D7BHW3.js} +4 -5
  33. package/dist/{chunk-NTZY6IB7.js → chunk-VHSNYUYV.js} +5 -4
  34. package/dist/{chunk-JK4XMMKM.cjs → chunk-VR3FREBX.cjs} +3 -3
  35. package/dist/{chunk-T46YXSBP.cjs → chunk-WO72UBQD.cjs} +11 -11
  36. package/dist/chunk-WOEETTH7.cjs +59 -0
  37. package/dist/{chunk-IJFQ5L4I.js → chunk-WTK6JDSI.js} +4 -5
  38. package/dist/{chunk-PUPKNW3R.cjs → chunk-WUXUWTFW.cjs} +3 -3
  39. package/dist/{chunk-PFXURMBZ.cjs → chunk-YFIWCYHC.cjs} +112 -54
  40. package/dist/{chunk-ZWXJTBZO.js → chunk-YPYCWLYP.js} +1 -1
  41. package/dist/core/addresses.d.ts +1 -1
  42. package/dist/core/errors.d.ts +1 -1
  43. package/dist/fhe/index.cjs +84 -64
  44. package/dist/fhe/index.d.cts +1 -0
  45. package/dist/fhe/index.d.ts +1 -0
  46. package/dist/fhe/index.js +21 -9
  47. package/dist/fhe/mock-erc7984.d.ts +4 -4
  48. package/dist/fhe/operators.d.ts +142 -2
  49. package/dist/fhe/react/index.cjs +21 -8
  50. package/dist/fhe/react/index.d.cts +2 -0
  51. package/dist/fhe/react/index.d.ts +2 -0
  52. package/dist/fhe/react/index.js +8 -3
  53. package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
  54. package/dist/fhe/react/useIsOperator.d.ts +54 -0
  55. package/dist/fhe/sepolia-encryptor-web.d.ts +18 -3
  56. package/dist/fhe-airdrop/advanced/index.cjs +8 -9
  57. package/dist/fhe-airdrop/advanced/index.js +6 -7
  58. package/dist/fhe-airdrop/advanced/react/index.cjs +13 -14
  59. package/dist/fhe-airdrop/advanced/react/index.js +9 -10
  60. package/dist/fhe-airdrop/airdrop.d.ts +7 -0
  61. package/dist/fhe-airdrop/index.cjs +66 -67
  62. package/dist/fhe-airdrop/index.js +7 -8
  63. package/dist/fhe-airdrop/react/index.cjs +148 -137
  64. package/dist/fhe-airdrop/react/index.d.cts +3 -1
  65. package/dist/fhe-airdrop/react/index.d.ts +3 -1
  66. package/dist/fhe-airdrop/react/index.js +16 -14
  67. package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +17 -11
  68. package/dist/fhe-airdrop/react/useClaim.d.ts +8 -0
  69. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +1 -1
  70. package/dist/fhe-airdrop/types.d.ts +14 -3
  71. package/dist/fhe-disperse/errors.d.ts +55 -0
  72. package/dist/fhe-disperse/index.cjs +74 -67
  73. package/dist/fhe-disperse/index.d.cts +1 -1
  74. package/dist/fhe-disperse/index.d.ts +1 -1
  75. package/dist/fhe-disperse/index.js +8 -9
  76. package/dist/fhe-disperse/react/index.cjs +105 -88
  77. package/dist/fhe-disperse/react/index.d.cts +3 -1
  78. package/dist/fhe-disperse/react/index.d.ts +3 -1
  79. package/dist/fhe-disperse/react/index.js +12 -11
  80. package/dist/fhe-vesting/advanced/index.cjs +8 -9
  81. package/dist/fhe-vesting/advanced/index.js +6 -7
  82. package/dist/fhe-vesting/advanced/react/index.cjs +14 -15
  83. package/dist/fhe-vesting/advanced/react/index.js +11 -12
  84. package/dist/fhe-vesting/index.cjs +75 -76
  85. package/dist/fhe-vesting/index.js +9 -10
  86. package/dist/fhe-vesting/manager.d.ts +19 -0
  87. package/dist/fhe-vesting/react/index.cjs +245 -227
  88. package/dist/fhe-vesting/react/index.d.cts +6 -4
  89. package/dist/fhe-vesting/react/index.d.ts +6 -4
  90. package/dist/fhe-vesting/react/index.js +27 -21
  91. package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
  92. package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
  93. package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
  94. package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
  95. package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
  96. package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
  97. package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
  98. package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
  99. package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
  100. package/dist/fhe-vesting/react/useClaim.d.ts +1 -1
  101. package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
  102. package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
  103. package/dist/fhe-vesting/react/usePartialClaim.d.ts +1 -1
  104. package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
  105. package/dist/fhe-vesting/types.d.ts +12 -1
  106. package/dist/index.cjs +87 -88
  107. package/dist/index.js +2 -3
  108. package/dist/testnet-faucet/index.cjs +55 -56
  109. package/dist/testnet-faucet/index.js +5 -6
  110. package/dist/testnet-faucet/react/index.cjs +53 -54
  111. package/dist/testnet-faucet/react/index.js +7 -8
  112. package/package.json +13 -8
  113. package/dist/chunk-66IHPTOK.cjs +0 -20
  114. package/dist/chunk-KWFFIJYX.js +0 -11
  115. package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
  116. package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
  117. package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
  118. package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
  119. package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
  120. package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkJYOTGRSO_cjs = require('../chunk-JYOTGRSO.cjs');
4
- var chunk2NCLOQ56_cjs = require('../chunk-2NCLOQ56.cjs');
5
- var chunkFAXIIH5R_cjs = require('../chunk-FAXIIH5R.cjs');
3
+ var chunk4ZCXK4VI_cjs = require('../chunk-4ZCXK4VI.cjs');
4
+ var chunkBD4LZBVF_cjs = require('../chunk-BD4LZBVF.cjs');
5
+ var chunkSYHNZSZZ_cjs = require('../chunk-SYHNZSZZ.cjs');
6
6
  var chunkFWHYQZ5E_cjs = require('../chunk-FWHYQZ5E.cjs');
7
- var chunkJK4XMMKM_cjs = require('../chunk-JK4XMMKM.cjs');
7
+ var chunkVR3FREBX_cjs = require('../chunk-VR3FREBX.cjs');
8
+ var chunk2RNW4MIJ_cjs = require('../chunk-2RNW4MIJ.cjs');
8
9
  var chunkVJKZWYYJ_cjs = require('../chunk-VJKZWYYJ.cjs');
9
- var chunk67OV5CX2_cjs = require('../chunk-67OV5CX2.cjs');
10
10
  var sdk = require('@zama-fhe/sdk');
11
11
 
12
12
  // src/fhe/mock-encryptor.ts
@@ -23,7 +23,8 @@ async function requirePeerDep(spec, hint) {
23
23
  throw new Error(
24
24
  `@tokenops/sdk: peer dependency "${spec}" is required for createMockEncryptor.
25
25
  install it with: ${hint}
26
- underlying error: ${String(err)}`
26
+ underlying error: ${String(err)}`,
27
+ { cause: err }
27
28
  );
28
29
  }
29
30
  }
@@ -216,18 +217,18 @@ var MOCK_ERC7984_MINT_ABI = [
216
217
  var UINT64_MAX = (1n << 64n) - 1n;
217
218
  async function mintMockERC7984(args) {
218
219
  const { publicClient, walletClient, account, waitForReceipt = true, telemetry } = args;
219
- const token = chunkJK4XMMKM_cjs.normaliseAddress(args.token);
220
- const to = chunkJK4XMMKM_cjs.normaliseAddress(args.to);
220
+ const token = chunkVR3FREBX_cjs.normaliseAddress(args.token);
221
+ const to = chunkVR3FREBX_cjs.normaliseAddress(args.to);
221
222
  return chunkVJKZWYYJ_cjs.withTelemetry(telemetry, "fhe.mintMockERC7984", async () => {
222
223
  const fromAccount = account ?? walletClient.account;
223
224
  if (!fromAccount) {
224
- throw new chunk67OV5CX2_cjs.TokenOpsContractError(
225
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
225
226
  "mintMockERC7984: no account available \u2014 pass `account` explicitly or attach an account to the walletClient",
226
227
  { contract: "ERC7984", call: "mint" }
227
228
  );
228
229
  }
229
230
  if (args.amount < 0n || args.amount > UINT64_MAX) {
230
- throw new chunk67OV5CX2_cjs.TokenOpsContractError(
231
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
231
232
  `mintMockERC7984: amount ${args.amount} out of uint64 range [0, ${UINT64_MAX}]`,
232
233
  { contract: "ERC7984", call: "mint", amount: args.amount.toString() }
233
234
  );
@@ -245,7 +246,7 @@ async function mintMockERC7984(args) {
245
246
  chain: walletClient.chain
246
247
  });
247
248
  } catch (err) {
248
- throw new chunk67OV5CX2_cjs.TokenOpsContractError(
249
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
249
250
  `mintMockERC7984: writeContract failed (token=${token}, to=${to})`,
250
251
  {
251
252
  contract: "ERC7984",
@@ -262,7 +263,7 @@ async function mintMockERC7984(args) {
262
263
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
263
264
  blockNumber = receipt.blockNumber;
264
265
  } catch (err) {
265
- throw new chunk67OV5CX2_cjs.TokenOpsContractError(`mintMockERC7984: receipt wait failed (tx=${hash})`, {
266
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(`mintMockERC7984: receipt wait failed (tx=${hash})`, {
266
267
  contract: "ERC7984",
267
268
  call: "mint",
268
269
  tx: hash,
@@ -274,7 +275,7 @@ async function mintMockERC7984(args) {
274
275
  });
275
276
  }
276
277
  function createMockErc7984Client(args) {
277
- const address = chunkJK4XMMKM_cjs.normaliseAddress(args.address);
278
+ const address = chunkVR3FREBX_cjs.normaliseAddress(args.address);
278
279
  const { publicClient, walletClient, telemetry } = args;
279
280
  return {
280
281
  address,
@@ -303,7 +304,8 @@ async function requirePeerDep2(spec, hint) {
303
304
  throw new Error(
304
305
  `@tokenops/sdk: peer dependency "${spec}" is required for createSepoliaEncryptor.
305
306
  install it with: ${hint}
306
- underlying error: ${String(err)}`
307
+ underlying error: ${String(err)}`,
308
+ { cause: err }
307
309
  );
308
310
  }
309
311
  }
@@ -416,11 +418,21 @@ function createSepoliaEncryptorWeb(opts) {
416
418
  firePhase("ready");
417
419
  }
418
420
  } : void 0;
421
+ if (opts.threads !== void 0 && opts.threads > 1) {
422
+ const isolated = globalThis.crossOriginIsolated === true;
423
+ if (!isolated) {
424
+ const warn = safeLogger?.warn ?? console.warn;
425
+ warn(
426
+ `@tokenops/sdk: createSepoliaEncryptorWeb({ threads: ${opts.threads} }) \u2014 this page is NOT cross-origin isolated, so SharedArrayBuffer is unavailable and encryption will run single-threaded. Serve \`Cross-Origin-Opener-Policy: same-origin\` + \`Cross-Origin-Embedder-Policy: require-corp\` to enable the worker pool, or omit \`threads\`.`
427
+ );
428
+ }
429
+ }
419
430
  const instance = new sdk.RelayerWeb({
420
431
  transports: { [chainId]: transportConfig },
421
432
  getChainId: () => Promise.resolve(chainId),
422
433
  logger: safeLogger,
423
- onStatusChange
434
+ onStatusChange,
435
+ ...opts.threads !== void 0 ? { threads: opts.threads } : {}
424
436
  });
425
437
  return Promise.resolve({
426
438
  instance,
@@ -436,47 +448,55 @@ function createSepoliaEncryptorWeb(opts) {
436
448
 
437
449
  Object.defineProperty(exports, "ERC7984_OPERATOR_MAX_DEADLINE", {
438
450
  enumerable: true,
439
- get: function () { return chunkJYOTGRSO_cjs.ERC7984_OPERATOR_MAX_DEADLINE; }
451
+ get: function () { return chunk4ZCXK4VI_cjs.ERC7984_OPERATOR_MAX_DEADLINE; }
440
452
  });
441
453
  Object.defineProperty(exports, "ERC7984_SET_OPERATOR_ABI", {
442
454
  enumerable: true,
443
- get: function () { return chunkJYOTGRSO_cjs.ERC7984_SET_OPERATOR_ABI; }
455
+ get: function () { return chunk4ZCXK4VI_cjs.ERC7984_SET_OPERATOR_ABI; }
456
+ });
457
+ Object.defineProperty(exports, "ensureOperator", {
458
+ enumerable: true,
459
+ get: function () { return chunk4ZCXK4VI_cjs.ensureOperator; }
460
+ });
461
+ Object.defineProperty(exports, "isOperator", {
462
+ enumerable: true,
463
+ get: function () { return chunk4ZCXK4VI_cjs.isOperator; }
444
464
  });
445
465
  Object.defineProperty(exports, "revokeOperator", {
446
466
  enumerable: true,
447
- get: function () { return chunkJYOTGRSO_cjs.revokeOperator; }
467
+ get: function () { return chunk4ZCXK4VI_cjs.revokeOperator; }
448
468
  });
449
469
  Object.defineProperty(exports, "setOperator", {
450
470
  enumerable: true,
451
- get: function () { return chunkJYOTGRSO_cjs.setOperator; }
471
+ get: function () { return chunk4ZCXK4VI_cjs.setOperator; }
452
472
  });
453
473
  Object.defineProperty(exports, "FHE_SPLIT_DENOMINATOR", {
454
474
  enumerable: true,
455
- get: function () { return chunk2NCLOQ56_cjs.FHE_SPLIT_DENOMINATOR; }
475
+ get: function () { return chunkBD4LZBVF_cjs.FHE_SPLIT_DENOMINATOR; }
456
476
  });
457
477
  Object.defineProperty(exports, "scaleRatio", {
458
478
  enumerable: true,
459
- get: function () { return chunk2NCLOQ56_cjs.scaleRatio; }
479
+ get: function () { return chunkBD4LZBVF_cjs.scaleRatio; }
460
480
  });
461
481
  Object.defineProperty(exports, "share", {
462
482
  enumerable: true,
463
- get: function () { return chunk2NCLOQ56_cjs.share; }
483
+ get: function () { return chunkBD4LZBVF_cjs.share; }
464
484
  });
465
485
  Object.defineProperty(exports, "ACL_ALLOWED_EVENT", {
466
486
  enumerable: true,
467
- get: function () { return chunkFAXIIH5R_cjs.ACL_ALLOWED_EVENT; }
487
+ get: function () { return chunkSYHNZSZZ_cjs.ACL_ALLOWED_EVENT; }
468
488
  });
469
489
  Object.defineProperty(exports, "FHEVM_ACL_ADDRESS_BY_CHAIN", {
470
490
  enumerable: true,
471
- get: function () { return chunkFAXIIH5R_cjs.FHEVM_ACL_ADDRESS_BY_CHAIN; }
491
+ get: function () { return chunkSYHNZSZZ_cjs.FHEVM_ACL_ADDRESS_BY_CHAIN; }
472
492
  });
473
493
  Object.defineProperty(exports, "getFhevmAclAddress", {
474
494
  enumerable: true,
475
- get: function () { return chunkFAXIIH5R_cjs.getFhevmAclAddress; }
495
+ get: function () { return chunkSYHNZSZZ_cjs.getFhevmAclAddress; }
476
496
  });
477
497
  Object.defineProperty(exports, "requireFhevmAclAddress", {
478
498
  enumerable: true,
479
- get: function () { return chunkFAXIIH5R_cjs.requireFhevmAclAddress; }
499
+ get: function () { return chunkSYHNZSZZ_cjs.requireFhevmAclAddress; }
480
500
  });
481
501
  Object.defineProperty(exports, "erc7984OperatorAbi", {
482
502
  enumerable: true,
@@ -484,155 +504,155 @@ Object.defineProperty(exports, "erc7984OperatorAbi", {
484
504
  });
485
505
  Object.defineProperty(exports, "AccessDeniedError", {
486
506
  enumerable: true,
487
- get: function () { return chunk67OV5CX2_cjs.AccessDeniedError; }
507
+ get: function () { return chunk2RNW4MIJ_cjs.AccessDeniedError; }
488
508
  });
489
509
  Object.defineProperty(exports, "AlreadyInitializedError", {
490
510
  enumerable: true,
491
- get: function () { return chunk67OV5CX2_cjs.AlreadyInitializedError; }
511
+ get: function () { return chunk2RNW4MIJ_cjs.AlreadyInitializedError; }
492
512
  });
493
513
  Object.defineProperty(exports, "BatchTooLargeError", {
494
514
  enumerable: true,
495
- get: function () { return chunk67OV5CX2_cjs.BatchTooLargeError; }
515
+ get: function () { return chunk2RNW4MIJ_cjs.BatchTooLargeError; }
496
516
  });
497
517
  Object.defineProperty(exports, "ContractRevertError", {
498
518
  enumerable: true,
499
- get: function () { return chunk67OV5CX2_cjs.ContractRevertError; }
519
+ get: function () { return chunk2RNW4MIJ_cjs.ContractRevertError; }
500
520
  });
501
521
  Object.defineProperty(exports, "DecryptionFailedError", {
502
522
  enumerable: true,
503
- get: function () { return chunk67OV5CX2_cjs.DecryptionFailedError; }
523
+ get: function () { return chunk2RNW4MIJ_cjs.DecryptionFailedError; }
504
524
  });
505
525
  Object.defineProperty(exports, "DeploymentAddressUnavailableError", {
506
526
  enumerable: true,
507
- get: function () { return chunk67OV5CX2_cjs.DeploymentAddressUnavailableError; }
527
+ get: function () { return chunk2RNW4MIJ_cjs.DeploymentAddressUnavailableError; }
508
528
  });
509
529
  Object.defineProperty(exports, "EncryptionFailedError", {
510
530
  enumerable: true,
511
- get: function () { return chunk67OV5CX2_cjs.EncryptionFailedError; }
531
+ get: function () { return chunk2RNW4MIJ_cjs.EncryptionFailedError; }
512
532
  });
513
533
  Object.defineProperty(exports, "FeatureDisabledError", {
514
534
  enumerable: true,
515
- get: function () { return chunk67OV5CX2_cjs.FeatureDisabledError; }
535
+ get: function () { return chunk2RNW4MIJ_cjs.FeatureDisabledError; }
516
536
  });
517
537
  Object.defineProperty(exports, "FheHandleNotAllowedError", {
518
538
  enumerable: true,
519
- get: function () { return chunk67OV5CX2_cjs.FheHandleNotAllowedError; }
539
+ get: function () { return chunk2RNW4MIJ_cjs.FheHandleNotAllowedError; }
520
540
  });
521
541
  Object.defineProperty(exports, "InsufficientBalanceError", {
522
542
  enumerable: true,
523
- get: function () { return chunk67OV5CX2_cjs.InsufficientBalanceError; }
543
+ get: function () { return chunk2RNW4MIJ_cjs.InsufficientBalanceError; }
524
544
  });
525
545
  Object.defineProperty(exports, "InsufficientFeeError", {
526
546
  enumerable: true,
527
- get: function () { return chunk67OV5CX2_cjs.InsufficientFeeError; }
547
+ get: function () { return chunk2RNW4MIJ_cjs.InsufficientFeeError; }
528
548
  });
529
549
  Object.defineProperty(exports, "InsufficientGasFundsError", {
530
550
  enumerable: true,
531
- get: function () { return chunk67OV5CX2_cjs.InsufficientGasFundsError; }
551
+ get: function () { return chunk2RNW4MIJ_cjs.InsufficientGasFundsError; }
532
552
  });
533
553
  Object.defineProperty(exports, "InvalidArgumentError", {
534
554
  enumerable: true,
535
- get: function () { return chunk67OV5CX2_cjs.InvalidArgumentError; }
555
+ get: function () { return chunk2RNW4MIJ_cjs.InvalidArgumentError; }
536
556
  });
537
557
  Object.defineProperty(exports, "InvalidSignatureError", {
538
558
  enumerable: true,
539
- get: function () { return chunk67OV5CX2_cjs.InvalidSignatureError; }
559
+ get: function () { return chunk2RNW4MIJ_cjs.InvalidSignatureError; }
540
560
  });
541
561
  Object.defineProperty(exports, "MissingAccountError", {
542
562
  enumerable: true,
543
- get: function () { return chunk67OV5CX2_cjs.MissingAccountError; }
563
+ get: function () { return chunk2RNW4MIJ_cjs.MissingAccountError; }
544
564
  });
545
565
  Object.defineProperty(exports, "MissingClientError", {
546
566
  enumerable: true,
547
- get: function () { return chunk67OV5CX2_cjs.MissingClientError; }
567
+ get: function () { return chunk2RNW4MIJ_cjs.MissingClientError; }
548
568
  });
549
569
  Object.defineProperty(exports, "MissingEncryptorError", {
550
570
  enumerable: true,
551
- get: function () { return chunk67OV5CX2_cjs.MissingEncryptorError; }
571
+ get: function () { return chunk2RNW4MIJ_cjs.MissingEncryptorError; }
552
572
  });
553
573
  Object.defineProperty(exports, "MissingPublicClientError", {
554
574
  enumerable: true,
555
- get: function () { return chunk67OV5CX2_cjs.MissingPublicClientError; }
575
+ get: function () { return chunk2RNW4MIJ_cjs.MissingPublicClientError; }
556
576
  });
557
577
  Object.defineProperty(exports, "MissingWalletClientError", {
558
578
  enumerable: true,
559
- get: function () { return chunk67OV5CX2_cjs.MissingWalletClientError; }
579
+ get: function () { return chunk2RNW4MIJ_cjs.MissingWalletClientError; }
560
580
  });
561
581
  Object.defineProperty(exports, "NetworkError", {
562
582
  enumerable: true,
563
- get: function () { return chunk67OV5CX2_cjs.NetworkError; }
583
+ get: function () { return chunk2RNW4MIJ_cjs.NetworkError; }
564
584
  });
565
585
  Object.defineProperty(exports, "OperatorNotApprovedError", {
566
586
  enumerable: true,
567
- get: function () { return chunk67OV5CX2_cjs.OperatorNotApprovedError; }
587
+ get: function () { return chunk2RNW4MIJ_cjs.OperatorNotApprovedError; }
568
588
  });
569
589
  Object.defineProperty(exports, "PausedError", {
570
590
  enumerable: true,
571
- get: function () { return chunk67OV5CX2_cjs.PausedError; }
591
+ get: function () { return chunk2RNW4MIJ_cjs.PausedError; }
572
592
  });
573
593
  Object.defineProperty(exports, "ReceiptEventAmbiguousError", {
574
594
  enumerable: true,
575
- get: function () { return chunk67OV5CX2_cjs.ReceiptEventAmbiguousError; }
595
+ get: function () { return chunk2RNW4MIJ_cjs.ReceiptEventAmbiguousError; }
576
596
  });
577
597
  Object.defineProperty(exports, "ReceiptEventNotFoundError", {
578
598
  enumerable: true,
579
- get: function () { return chunk67OV5CX2_cjs.ReceiptEventNotFoundError; }
599
+ get: function () { return chunk2RNW4MIJ_cjs.ReceiptEventNotFoundError; }
580
600
  });
581
601
  Object.defineProperty(exports, "ReentrancyError", {
582
602
  enumerable: true,
583
- get: function () { return chunk67OV5CX2_cjs.ReentrancyError; }
603
+ get: function () { return chunk2RNW4MIJ_cjs.ReentrancyError; }
584
604
  });
585
605
  Object.defineProperty(exports, "RelayerUnreachableError", {
586
606
  enumerable: true,
587
- get: function () { return chunk67OV5CX2_cjs.RelayerUnreachableError; }
607
+ get: function () { return chunk2RNW4MIJ_cjs.RelayerUnreachableError; }
588
608
  });
589
609
  Object.defineProperty(exports, "SigningFailedError", {
590
610
  enumerable: true,
591
- get: function () { return chunk67OV5CX2_cjs.SigningFailedError; }
611
+ get: function () { return chunk2RNW4MIJ_cjs.SigningFailedError; }
592
612
  });
593
613
  Object.defineProperty(exports, "TokenOpsContractError", {
594
614
  enumerable: true,
595
- get: function () { return chunk67OV5CX2_cjs.TokenOpsContractError; }
615
+ get: function () { return chunk2RNW4MIJ_cjs.TokenOpsContractError; }
596
616
  });
597
617
  Object.defineProperty(exports, "TokenOpsSdkError", {
598
618
  enumerable: true,
599
- get: function () { return chunk67OV5CX2_cjs.TokenOpsSdkError; }
619
+ get: function () { return chunk2RNW4MIJ_cjs.TokenOpsSdkError; }
600
620
  });
601
621
  Object.defineProperty(exports, "TokenOpsValidationError", {
602
622
  enumerable: true,
603
- get: function () { return chunk67OV5CX2_cjs.TokenOpsValidationError; }
623
+ get: function () { return chunk2RNW4MIJ_cjs.TokenOpsValidationError; }
604
624
  });
605
625
  Object.defineProperty(exports, "TransferFailedError", {
606
626
  enumerable: true,
607
- get: function () { return chunk67OV5CX2_cjs.TransferFailedError; }
627
+ get: function () { return chunk2RNW4MIJ_cjs.TransferFailedError; }
608
628
  });
609
629
  Object.defineProperty(exports, "UnknownWriteFailureError", {
610
630
  enumerable: true,
611
- get: function () { return chunk67OV5CX2_cjs.UnknownWriteFailureError; }
631
+ get: function () { return chunk2RNW4MIJ_cjs.UnknownWriteFailureError; }
612
632
  });
613
633
  Object.defineProperty(exports, "UnsupportedChainError", {
614
634
  enumerable: true,
615
- get: function () { return chunk67OV5CX2_cjs.UnsupportedChainError; }
635
+ get: function () { return chunk2RNW4MIJ_cjs.UnsupportedChainError; }
616
636
  });
617
637
  Object.defineProperty(exports, "UserDecryptNotAllowedError", {
618
638
  enumerable: true,
619
- get: function () { return chunk67OV5CX2_cjs.UserDecryptNotAllowedError; }
639
+ get: function () { return chunk2RNW4MIJ_cjs.UserDecryptNotAllowedError; }
620
640
  });
621
641
  Object.defineProperty(exports, "UserRejectedSignatureError", {
622
642
  enumerable: true,
623
- get: function () { return chunk67OV5CX2_cjs.UserRejectedSignatureError; }
643
+ get: function () { return chunk2RNW4MIJ_cjs.UserRejectedSignatureError; }
624
644
  });
625
645
  Object.defineProperty(exports, "WalletChainMismatchError", {
626
646
  enumerable: true,
627
- get: function () { return chunk67OV5CX2_cjs.WalletChainMismatchError; }
647
+ get: function () { return chunk2RNW4MIJ_cjs.WalletChainMismatchError; }
628
648
  });
629
649
  Object.defineProperty(exports, "WalletRejectedError", {
630
650
  enumerable: true,
631
- get: function () { return chunk67OV5CX2_cjs.WalletRejectedError; }
651
+ get: function () { return chunk2RNW4MIJ_cjs.WalletRejectedError; }
632
652
  });
633
653
  Object.defineProperty(exports, "isTokenOpsSdkError", {
634
654
  enumerable: true,
635
- get: function () { return chunk67OV5CX2_cjs.isTokenOpsSdkError; }
655
+ get: function () { return chunk2RNW4MIJ_cjs.isTokenOpsSdkError; }
636
656
  });
637
657
  exports.MAINNET_CHAIN_ID = MAINNET_CHAIN_ID;
638
658
  exports.MOCK_ERC7984_MINT_ABI = MOCK_ERC7984_MINT_ABI;
@@ -7,5 +7,6 @@ export * from "./sepolia-encryptor.js";
7
7
  export * from "./sepolia-encryptor-web.js";
8
8
  export * from "./types.js";
9
9
  export { erc7984OperatorAbi } from "./erc7984-abi.js";
10
+ export { type Encryptor, type EncryptorSource, type FheValueInput, } from "../fhe-vesting/encryption.js";
10
11
  export { TokenOpsSdkError, isTokenOpsSdkError, DeploymentAddressUnavailableError, UnsupportedChainError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, InvalidArgumentError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, TokenOpsValidationError, ContractRevertError, TokenOpsContractError, PausedError, AccessDeniedError, OperatorNotApprovedError, InsufficientFeeError, InsufficientBalanceError, BatchTooLargeError, FeatureDisabledError, TransferFailedError, FheHandleNotAllowedError, AlreadyInitializedError, ReentrancyError, InvalidSignatureError, WalletRejectedError, WalletChainMismatchError, NetworkError, InsufficientGasFundsError, UnknownWriteFailureError, UserRejectedSignatureError, SigningFailedError, RelayerUnreachableError, EncryptionFailedError, DecryptionFailedError, UserDecryptNotAllowedError, type DeploymentAddressUnavailableReason, type TokenOpsSdkErrorCode, } from "../core/errors.js";
11
12
  export { type PreflightResult } from "../core/preflight.js";
@@ -7,5 +7,6 @@ export * from "./sepolia-encryptor.js";
7
7
  export * from "./sepolia-encryptor-web.js";
8
8
  export * from "./types.js";
9
9
  export { erc7984OperatorAbi } from "./erc7984-abi.js";
10
+ export { type Encryptor, type EncryptorSource, type FheValueInput, } from "../fhe-vesting/encryption.js";
10
11
  export { TokenOpsSdkError, isTokenOpsSdkError, DeploymentAddressUnavailableError, UnsupportedChainError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, InvalidArgumentError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, TokenOpsValidationError, ContractRevertError, TokenOpsContractError, PausedError, AccessDeniedError, OperatorNotApprovedError, InsufficientFeeError, InsufficientBalanceError, BatchTooLargeError, FeatureDisabledError, TransferFailedError, FheHandleNotAllowedError, AlreadyInitializedError, ReentrancyError, InvalidSignatureError, WalletRejectedError, WalletChainMismatchError, NetworkError, InsufficientGasFundsError, UnknownWriteFailureError, UserRejectedSignatureError, SigningFailedError, RelayerUnreachableError, EncryptionFailedError, DecryptionFailedError, UserDecryptNotAllowedError, type DeploymentAddressUnavailableReason, type TokenOpsSdkErrorCode, } from "../core/errors.js";
11
12
  export { type PreflightResult } from "../core/preflight.js";
package/dist/fhe/index.js CHANGED
@@ -1,11 +1,11 @@
1
- export { ERC7984_OPERATOR_MAX_DEADLINE, ERC7984_SET_OPERATOR_ABI, revokeOperator, setOperator } from '../chunk-6BMP4ICG.js';
2
- export { FHE_SPLIT_DENOMINATOR, scaleRatio, share } from '../chunk-AOP6HMPW.js';
3
- export { ACL_ALLOWED_EVENT, FHEVM_ACL_ADDRESS_BY_CHAIN, getFhevmAclAddress, requireFhevmAclAddress } from '../chunk-ZWXJTBZO.js';
1
+ export { ERC7984_OPERATOR_MAX_DEADLINE, ERC7984_SET_OPERATOR_ABI, ensureOperator, isOperator, revokeOperator, setOperator } from '../chunk-4KJ66YRH.js';
2
+ export { FHE_SPLIT_DENOMINATOR, scaleRatio, share } from '../chunk-PD7ME2BT.js';
3
+ export { ACL_ALLOWED_EVENT, FHEVM_ACL_ADDRESS_BY_CHAIN, getFhevmAclAddress, requireFhevmAclAddress } from '../chunk-YPYCWLYP.js';
4
4
  export { erc7984OperatorAbi } from '../chunk-7VELUOMI.js';
5
- import { normaliseAddress } from '../chunk-ZA673I3O.js';
5
+ import { normaliseAddress } from '../chunk-46T67CE2.js';
6
+ import { TokenOpsContractError } from '../chunk-DRSPMIZ7.js';
7
+ export { AccessDeniedError, AlreadyInitializedError, BatchTooLargeError, ContractRevertError, DecryptionFailedError, DeploymentAddressUnavailableError, EncryptionFailedError, FeatureDisabledError, FheHandleNotAllowedError, InsufficientBalanceError, InsufficientFeeError, InsufficientGasFundsError, InvalidArgumentError, InvalidSignatureError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, NetworkError, OperatorNotApprovedError, PausedError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ReentrancyError, RelayerUnreachableError, SigningFailedError, TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, TransferFailedError, UnknownWriteFailureError, UnsupportedChainError, UserDecryptNotAllowedError, UserRejectedSignatureError, WalletChainMismatchError, WalletRejectedError, isTokenOpsSdkError } from '../chunk-DRSPMIZ7.js';
6
8
  import { withTelemetry } from '../chunk-Q2GP5UDC.js';
7
- import { TokenOpsContractError } from '../chunk-QBJ7O2B4.js';
8
- export { AccessDeniedError, AlreadyInitializedError, BatchTooLargeError, ContractRevertError, DecryptionFailedError, DeploymentAddressUnavailableError, EncryptionFailedError, FeatureDisabledError, FheHandleNotAllowedError, InsufficientBalanceError, InsufficientFeeError, InsufficientGasFundsError, InvalidArgumentError, InvalidSignatureError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, NetworkError, OperatorNotApprovedError, PausedError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ReentrancyError, RelayerUnreachableError, SigningFailedError, TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, TransferFailedError, UnknownWriteFailureError, UnsupportedChainError, UserDecryptNotAllowedError, UserRejectedSignatureError, WalletChainMismatchError, WalletRejectedError, isTokenOpsSdkError } from '../chunk-QBJ7O2B4.js';
9
9
  import { RelayerWeb, MainnetConfig, SepoliaConfig } from '@zama-fhe/sdk';
10
10
 
11
11
  // src/fhe/mock-encryptor.ts
@@ -22,7 +22,8 @@ async function requirePeerDep(spec, hint) {
22
22
  throw new Error(
23
23
  `@tokenops/sdk: peer dependency "${spec}" is required for createMockEncryptor.
24
24
  install it with: ${hint}
25
- underlying error: ${String(err)}`
25
+ underlying error: ${String(err)}`,
26
+ { cause: err }
26
27
  );
27
28
  }
28
29
  }
@@ -302,7 +303,8 @@ async function requirePeerDep2(spec, hint) {
302
303
  throw new Error(
303
304
  `@tokenops/sdk: peer dependency "${spec}" is required for createSepoliaEncryptor.
304
305
  install it with: ${hint}
305
- underlying error: ${String(err)}`
306
+ underlying error: ${String(err)}`,
307
+ { cause: err }
306
308
  );
307
309
  }
308
310
  }
@@ -415,11 +417,21 @@ function createSepoliaEncryptorWeb(opts) {
415
417
  firePhase("ready");
416
418
  }
417
419
  } : void 0;
420
+ if (opts.threads !== void 0 && opts.threads > 1) {
421
+ const isolated = globalThis.crossOriginIsolated === true;
422
+ if (!isolated) {
423
+ const warn = safeLogger?.warn ?? console.warn;
424
+ warn(
425
+ `@tokenops/sdk: createSepoliaEncryptorWeb({ threads: ${opts.threads} }) \u2014 this page is NOT cross-origin isolated, so SharedArrayBuffer is unavailable and encryption will run single-threaded. Serve \`Cross-Origin-Opener-Policy: same-origin\` + \`Cross-Origin-Embedder-Policy: require-corp\` to enable the worker pool, or omit \`threads\`.`
426
+ );
427
+ }
428
+ }
418
429
  const instance = new RelayerWeb({
419
430
  transports: { [chainId]: transportConfig },
420
431
  getChainId: () => Promise.resolve(chainId),
421
432
  logger: safeLogger,
422
- onStatusChange
433
+ onStatusChange,
434
+ ...opts.threads !== void 0 ? { threads: opts.threads } : {}
423
435
  });
424
436
  return Promise.resolve({
425
437
  instance,
@@ -76,12 +76,12 @@ export interface MintMockERC7984Result {
76
76
  *
77
77
  * @example
78
78
  * ```ts
79
- * import { mintMockERC7984, DEPLOYED_ADDRESSES } from "@tokenops/sdk";
79
+ * import { mintMockERC7984 } from "@tokenops/sdk/fhe";
80
80
  *
81
81
  * const { hash, blockNumber } = await mintMockERC7984({
82
82
  * publicClient,
83
83
  * walletClient,
84
- * token: DEPLOYED_ADDRESSES.tokens.testConfidential[11155111]!,
84
+ * token: "0xYourMockToken", // MockERC7984Token address
85
85
  * to: walletClient.account!.address,
86
86
  * amount: 1_000_000n,
87
87
  * });
@@ -119,12 +119,12 @@ export interface MockErc7984Client {
119
119
  *
120
120
  * @example
121
121
  * ```ts
122
- * import { createMockErc7984Client, DEPLOYED_ADDRESSES } from "@tokenops/sdk/fhe";
122
+ * import { createMockErc7984Client } from "@tokenops/sdk/fhe";
123
123
  *
124
124
  * const token = createMockErc7984Client({
125
125
  * publicClient,
126
126
  * walletClient,
127
- * address: DEPLOYED_ADDRESSES.tokens.testConfidential[11155111]!,
127
+ * address: "0xYourMockToken", // MockERC7984Token address
128
128
  * });
129
129
  *
130
130
  * await token.mint({ to: alice, amount: 1_000_000n });
@@ -108,7 +108,7 @@ export interface SetOperatorArgs {
108
108
  * await setOperator({
109
109
  * publicClient,
110
110
  * walletClient,
111
- * token: DEPLOYED_ADDRESSES.tokens.testConfidential[31337]!,
111
+ * token: "0xYourToken", // ERC-7984 token address
112
112
  * spender: manager,
113
113
  * // deadline defaults to ERC7984_OPERATOR_MAX_DEADLINE (forever).
114
114
  * });
@@ -177,7 +177,7 @@ export interface RevokeOperatorArgs {
177
177
  * await revokeOperator({
178
178
  * publicClient,
179
179
  * walletClient,
180
- * token: DEPLOYED_ADDRESSES.tokens.testConfidential[31337]!,
180
+ * token: "0xYourToken", // ERC-7984 token address
181
181
  * spender: staleManager, // old manager clone after deploying a new one
182
182
  * });
183
183
  * // `staleManager` can no longer call `confidentialTransferFrom` against
@@ -188,3 +188,143 @@ export interface RevokeOperatorArgs {
188
188
  * step throws. The original viem error is attached as the cause.
189
189
  */
190
190
  export declare function revokeOperator(args: RevokeOperatorArgs): Promise<Hex>;
191
+ /** Arguments for {@link isOperator}. Read-only — no wallet required. */
192
+ export interface IsOperatorArgs {
193
+ /** Read-only viem client the `isOperator` view call goes through. */
194
+ publicClient: PublicClient;
195
+ /** ERC-7984 token contract address. */
196
+ token: Address;
197
+ /** Account that owns the tokens (the operator-authorization granter). */
198
+ holder: Address;
199
+ /**
200
+ * Address whose operator status is being checked — typically a manager
201
+ * clone (`/fhe-vesting`), an airdrop clone/factory (`/fhe-airdrop`), or
202
+ * the disperse singleton (`/fhe-disperse`).
203
+ */
204
+ spender: Address;
205
+ /** Optional telemetry sink — span emits as `fhe.isOperator`. */
206
+ telemetry?: SdkTelemetry;
207
+ }
208
+ /**
209
+ * Check whether `spender` is currently an authorized ERC-7984 operator for
210
+ * `holder` on `token`. Read-only sibling of {@link setOperator} — the
211
+ * contract-side check is `until >= block.timestamp`, so an expired grant
212
+ * reads `false` here without any revoke transaction having happened.
213
+ *
214
+ * Use this to gate UX ("Approve operator" button vs "Create vesting" button)
215
+ * or as a cheap pre-check before flows that would otherwise fail with
216
+ * {@link OperatorNotApprovedError} — the SDK's mapping of the on-chain
217
+ * `ERC7984UnauthorizedSpender` revert, whose message is the canonical
218
+ * {@link OPERATOR_NOT_APPROVED_REMEDIATION} copy. For a check-then-set in
219
+ * one call, see {@link ensureOperator}.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * import { isOperator } from "@tokenops/sdk/fhe";
224
+ *
225
+ * const authorized = await isOperator({
226
+ * publicClient,
227
+ * token,
228
+ * holder: account.address,
229
+ * spender: manager,
230
+ * });
231
+ * if (!authorized) {
232
+ * // prompt the user to run setOperator / ensureOperator first
233
+ * }
234
+ * ```
235
+ *
236
+ * @throws {@link TokenOpsContractError} if the read call itself fails (RPC
237
+ * error, non-ERC-7984 token). The original viem error is attached as the
238
+ * cause.
239
+ */
240
+ export declare function isOperator(args: IsOperatorArgs): Promise<boolean>;
241
+ /**
242
+ * Arguments for {@link ensureOperator}. Same shape as {@link SetOperatorArgs}
243
+ * except `deadline` is **required**: `ensureOperator` only sends a
244
+ * transaction when the authorization is missing, so the expiry it would
245
+ * grant must be an explicit caller decision — the SDK refuses to default a
246
+ * security-sensitive approval window (a silent
247
+ * {@link ERC7984_OPERATOR_MAX_DEADLINE} would grant "forever").
248
+ */
249
+ export interface EnsureOperatorArgs {
250
+ /** Read-only viem client for the `isOperator` pre-check + receipt waiting. */
251
+ publicClient: PublicClient;
252
+ /** Wallet client used to send the `setOperator` call (only when needed). */
253
+ walletClient: WalletClient;
254
+ /**
255
+ * Account that owns the tokens. Same `Account | Address` semantics and
256
+ * fallback hierarchy as {@link SetOperatorArgs} — also used to derive the
257
+ * `holder` for the read-side `isOperator` pre-check.
258
+ */
259
+ account?: Account | Address;
260
+ /** ERC-7984 token contract address. */
261
+ token: Address;
262
+ /** Address being authorized to pull tokens. */
263
+ spender: Address;
264
+ /**
265
+ * `uint48` unix timestamp after which the operator authorization expires.
266
+ * Required — scope it to the expected operation window (e.g.
267
+ * `BigInt(Math.floor(Date.now() / 1000) + 3600)` for one hour). Pass
268
+ * {@link ERC7984_OPERATOR_MAX_DEADLINE} only when you explicitly want a
269
+ * never-expiring grant (local dev loops, test fixtures).
270
+ */
271
+ deadline: bigint;
272
+ /**
273
+ * If `true` (default), waits for the transaction to be mined before
274
+ * returning. Only relevant when a transaction is actually sent.
275
+ */
276
+ waitForReceipt?: boolean;
277
+ /** Optional telemetry sink — span emits as `fhe.ensureOperator`. */
278
+ telemetry?: SdkTelemetry;
279
+ }
280
+ /** Result of {@link ensureOperator}. */
281
+ export interface EnsureOperatorResult {
282
+ /**
283
+ * `true` when the authorization was already in place and no transaction
284
+ * was sent; `false` when this call performed the `setOperator` write.
285
+ */
286
+ alreadyOperator: boolean;
287
+ /**
288
+ * Transaction hash of the `setOperator` call, or `null` when no
289
+ * transaction was needed (`alreadyOperator === true`).
290
+ */
291
+ hash: Hex | null;
292
+ }
293
+ /**
294
+ * Idempotent operator authorization: check {@link isOperator} first and call
295
+ * {@link setOperator} only when the grant is missing. The no-op path sends
296
+ * no transaction and costs one `eth_call`.
297
+ *
298
+ * This is the recommended pre-step before any flow that pulls tokens from
299
+ * the caller's balance (`createVesting` / `batchCreateVesting`,
300
+ * `fundConfidentialAirdrop` / `createAndFundConfidentialAirdrop`, disperse
301
+ * registration) — skipping it fails with {@link OperatorNotApprovedError},
302
+ * the SDK's mapping of the on-chain `ERC7984UnauthorizedSpender` revert,
303
+ * whose message is the canonical {@link OPERATOR_NOT_APPROVED_REMEDIATION}
304
+ * copy.
305
+ *
306
+ * **Note on expiry:** the pre-check only tells you the grant is currently
307
+ * active, not until when. If an existing grant expires mid-flow,
308
+ * `ensureOperator` will not have refreshed it — pass a fresh
309
+ * {@link setOperator} call instead when you need to extend a window.
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * import { ensureOperator } from "@tokenops/sdk/fhe";
314
+ *
315
+ * const oneHour = BigInt(Math.floor(Date.now() / 1000) + 3600);
316
+ * const { alreadyOperator, hash } = await ensureOperator({
317
+ * publicClient,
318
+ * walletClient,
319
+ * token,
320
+ * spender: manager,
321
+ * deadline: oneHour,
322
+ * });
323
+ * // Now safe to call manager.createVesting / factory.fundConfidentialAirdrop / etc.
324
+ * ```
325
+ *
326
+ * @throws {@link TokenOpsContractError} if no holder account can be
327
+ * resolved, if `deadline` is outside `(0, 2**48 - 1]`, or if the
328
+ * read/write/receipt step fails.
329
+ */
330
+ export declare function ensureOperator(args: EnsureOperatorArgs): Promise<EnsureOperatorResult>;