@tokenops/sdk 2.0.0-alpha.1 → 2.0.0-alpha.2

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 (145) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +5 -5
  3. package/dist/{chunk-JZLGCTGK.cjs → chunk-3YHBO2DL.cjs} +2 -2
  4. package/dist/{chunk-H5POPGOZ.js → chunk-44YJPMQC.js} +1 -1
  5. package/dist/{chunk-DZHYSUGY.js → chunk-A4DCEE33.js} +11 -5
  6. package/dist/{chunk-M4IT6DNJ.cjs → chunk-AREQJHKA.cjs} +108 -3
  7. package/dist/chunk-EBLBPUPI.cjs +255 -0
  8. package/dist/chunk-EYDA6Q6C.js +245 -0
  9. package/dist/{chunk-XAYGD4E4.cjs → chunk-FEDX7B6T.cjs} +3 -3
  10. package/dist/{chunk-JQYC66TO.cjs → chunk-FHWSBGWE.cjs} +5 -5
  11. package/dist/{chunk-5576FRT3.cjs → chunk-FT5H2Q7Y.cjs} +11 -5
  12. package/dist/{chunk-456VDDA3.js → chunk-GADGBQJO.js} +78 -25
  13. package/dist/{chunk-6NAVMWZQ.js → chunk-IGO5XSPS.js} +2 -2
  14. package/dist/{chunk-CTED3MTR.cjs → chunk-IUKKNJ2R.cjs} +82 -29
  15. package/dist/{chunk-FGEB7RMY.cjs → chunk-MM5BV5CS.cjs} +4 -4
  16. package/dist/{chunk-335Z2W67.js → chunk-PYYSB5ZN.js} +1 -1
  17. package/dist/{chunk-PUX5VXDB.cjs → chunk-PZZK3O3S.cjs} +1040 -42
  18. package/dist/{chunk-74QFZ5MK.js → chunk-SPLNGUFF.js} +1 -1
  19. package/dist/{chunk-6PXXGACR.cjs → chunk-UHHMVBLU.cjs} +2 -2
  20. package/dist/{chunk-O5676ZWY.js → chunk-VW356KR3.js} +108 -5
  21. package/dist/{chunk-EAJ7SYHE.js → chunk-WJMEBBU7.js} +1 -1
  22. package/dist/{chunk-GKKDAW44.js → chunk-X7WBPCEU.js} +1026 -32
  23. package/dist/core/addresses.d.ts +4 -4
  24. package/dist/core/errors.d.ts +1 -1
  25. package/dist/fhe/types.d.ts +2 -2
  26. package/dist/fhe-airdrop/abis/merkle.d.ts +24 -12
  27. package/dist/fhe-airdrop/advanced/index.cjs +4 -4
  28. package/dist/fhe-airdrop/advanced/index.js +1 -1
  29. package/dist/fhe-airdrop/advanced/react/index.cjs +590 -9
  30. package/dist/fhe-airdrop/advanced/react/index.d.cts +34 -0
  31. package/dist/fhe-airdrop/advanced/react/index.d.ts +34 -0
  32. package/dist/fhe-airdrop/advanced/react/index.js +561 -7
  33. package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +28 -0
  34. package/dist/fhe-airdrop/advanced/react/useClearUpgradeabilityPolicy.d.ts +26 -0
  35. package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +25 -0
  36. package/dist/fhe-airdrop/advanced/react/useEcdsaInitCodeHash.d.ts +30 -0
  37. package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +25 -0
  38. package/dist/fhe-airdrop/advanced/react/useFactoryCompliancePolicy.d.ts +38 -0
  39. package/dist/fhe-airdrop/advanced/react/useFactoryCustomFee.d.ts +24 -0
  40. package/dist/fhe-airdrop/advanced/react/useFactoryGrantRole.d.ts +32 -0
  41. package/dist/fhe-airdrop/advanced/react/useFactoryHasRole.d.ts +27 -0
  42. package/dist/fhe-airdrop/advanced/react/useFactoryImplementations.d.ts +33 -0
  43. package/dist/fhe-airdrop/advanced/react/useFactoryRenounceRole.d.ts +36 -0
  44. package/dist/fhe-airdrop/advanced/react/useFactoryRevokeRole.d.ts +35 -0
  45. package/dist/fhe-airdrop/advanced/react/useFactoryRoleConstants.d.ts +46 -0
  46. package/dist/fhe-airdrop/advanced/react/useFactoryRoleMembers.d.ts +47 -0
  47. package/dist/fhe-airdrop/advanced/react/useFactoryUpgradeabilityPolicy.d.ts +39 -0
  48. package/dist/fhe-airdrop/advanced/react/useMerkleInitCodeHash.d.ts +24 -0
  49. package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +33 -0
  50. package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +27 -0
  51. package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +28 -0
  52. package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +28 -0
  53. package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +31 -0
  54. package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +28 -0
  55. package/dist/fhe-airdrop/advanced/react/useSetDefaultUpgradeable.d.ts +27 -0
  56. package/dist/fhe-airdrop/advanced/react/useSetEcdsaImplementation.d.ts +34 -0
  57. package/dist/fhe-airdrop/advanced/react/useSetFeeCollector.d.ts +27 -0
  58. package/dist/fhe-airdrop/advanced/react/useSetMerkleImplementation.d.ts +30 -0
  59. package/dist/fhe-airdrop/advanced/react/useSetUpgradeabilityPolicy.d.ts +31 -0
  60. package/dist/fhe-airdrop/airdrop-base.d.ts +8 -0
  61. package/dist/fhe-airdrop/campaign.d.ts +61 -20
  62. package/dist/fhe-airdrop/constants.d.ts +1 -1
  63. package/dist/fhe-airdrop/errors.d.ts +28 -0
  64. package/dist/fhe-airdrop/guards.d.ts +46 -2
  65. package/dist/fhe-airdrop/index.cjs +74 -971
  66. package/dist/fhe-airdrop/index.d.cts +2 -2
  67. package/dist/fhe-airdrop/index.d.ts +2 -2
  68. package/dist/fhe-airdrop/index.js +8 -927
  69. package/dist/fhe-airdrop/merkle-tree.d.ts +32 -38
  70. package/dist/fhe-airdrop/merkle.d.ts +52 -31
  71. package/dist/fhe-airdrop/react/_shared.d.ts +13 -0
  72. package/dist/fhe-airdrop/react/index.cjs +934 -84
  73. package/dist/fhe-airdrop/react/index.d.cts +49 -3
  74. package/dist/fhe-airdrop/react/index.d.ts +49 -3
  75. package/dist/fhe-airdrop/react/index.js +825 -22
  76. package/dist/fhe-airdrop/react/keys.d.ts +90 -0
  77. package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +26 -0
  78. package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +27 -0
  79. package/dist/fhe-airdrop/react/useAddComplianceDelegate.d.ts +37 -0
  80. package/dist/fhe-airdrop/react/useAdminBatchDiscloseBalanceToParties.d.ts +36 -0
  81. package/dist/fhe-airdrop/react/useAdminDiscloseBalanceToParty.d.ts +31 -0
  82. package/dist/fhe-airdrop/react/useAdminGetCurrentBalance.d.ts +27 -0
  83. package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +49 -0
  84. package/dist/fhe-airdrop/react/useAirdropDeploymentMode.d.ts +28 -0
  85. package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +35 -0
  86. package/dist/fhe-airdrop/react/useAirdropRenounceRole.d.ts +36 -0
  87. package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +33 -0
  88. package/dist/fhe-airdrop/react/useAirdropRoleAdmin.d.ts +28 -0
  89. package/dist/fhe-airdrop/react/useAirdropRoleConstants.d.ts +67 -0
  90. package/dist/fhe-airdrop/react/useAirdropRoleMembers.d.ts +49 -0
  91. package/dist/fhe-airdrop/react/useAirdropUpgradeToAndCall.d.ts +45 -0
  92. package/dist/fhe-airdrop/react/useBatchDiscloseHandlesToParty.d.ts +32 -0
  93. package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +68 -0
  94. package/dist/fhe-airdrop/react/useComplianceGrantRole.d.ts +32 -0
  95. package/dist/fhe-airdrop/react/useComplianceHasRole.d.ts +37 -0
  96. package/dist/fhe-airdrop/react/useComplianceInfo.d.ts +50 -0
  97. package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +32 -0
  98. package/dist/fhe-airdrop/react/useComplianceRenounceRole.d.ts +38 -0
  99. package/dist/fhe-airdrop/react/useComplianceRevokeRole.d.ts +36 -0
  100. package/dist/fhe-airdrop/react/useComplianceRoleConstants.d.ts +41 -0
  101. package/dist/fhe-airdrop/react/useComplianceRoleMembers.d.ts +45 -0
  102. package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +55 -0
  103. package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +52 -0
  104. package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +35 -0
  105. package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +4 -3
  106. package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +27 -0
  107. package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +41 -0
  108. package/dist/fhe-airdrop/react/useEffectiveDelegateToCompliance.d.ts +26 -0
  109. package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +59 -0
  110. package/dist/fhe-airdrop/react/useIsActiveDelegate.d.ts +29 -0
  111. package/dist/fhe-airdrop/react/useIsMerkleRootMutable.d.ts +21 -0
  112. package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +46 -0
  113. package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +7 -19
  114. package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +29 -0
  115. package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +53 -0
  116. package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +46 -0
  117. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +67 -0
  118. package/dist/fhe-airdrop/react/useRescueERC20.d.ts +30 -0
  119. package/dist/fhe-airdrop/react/useRescueOtherConfidentialToken.d.ts +34 -0
  120. package/dist/fhe-airdrop/react/useRevokeComplianceDelegate.d.ts +37 -0
  121. package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +52 -0
  122. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +42 -0
  123. package/dist/fhe-airdrop/react/useWithdrawGasFee.d.ts +37 -0
  124. package/dist/fhe-airdrop/types.d.ts +14 -1
  125. package/dist/fhe-disperse/index.cjs +21 -21
  126. package/dist/fhe-disperse/index.js +2 -2
  127. package/dist/fhe-disperse/react/index.cjs +22 -22
  128. package/dist/fhe-disperse/react/index.js +3 -3
  129. package/dist/fhe-vesting/advanced/index.cjs +5 -5
  130. package/dist/fhe-vesting/advanced/index.js +3 -3
  131. package/dist/fhe-vesting/advanced/react/index.cjs +7 -7
  132. package/dist/fhe-vesting/advanced/react/index.js +4 -4
  133. package/dist/fhe-vesting/index.cjs +8 -8
  134. package/dist/fhe-vesting/index.js +2 -2
  135. package/dist/fhe-vesting/react/index.cjs +114 -114
  136. package/dist/fhe-vesting/react/index.js +3 -3
  137. package/dist/index.cjs +18 -18
  138. package/dist/index.js +1 -1
  139. package/dist/testnet-faucet/index.cjs +14 -14
  140. package/dist/testnet-faucet/index.js +2 -2
  141. package/dist/testnet-faucet/react/index.cjs +8 -8
  142. package/dist/testnet-faucet/react/index.js +3 -3
  143. package/package.json +1 -1
  144. package/dist/chunk-NCVX3K2N.cjs +0 -161
  145. package/dist/chunk-VP2B4WM2.js +0 -154
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkM4IT6DNJ_cjs = require('./chunk-M4IT6DNJ.cjs');
3
+ var chunkAREQJHKA_cjs = require('./chunk-AREQJHKA.cjs');
4
4
  var chunkFAXIIH5R_cjs = require('./chunk-FAXIIH5R.cjs');
5
5
  var chunkUG5RKLU2_cjs = require('./chunk-UG5RKLU2.cjs');
6
6
  var chunkMVDQMV25_cjs = require('./chunk-MVDQMV25.cjs');
7
- var chunk5576FRT3_cjs = require('./chunk-5576FRT3.cjs');
7
+ var chunkFT5H2Q7Y_cjs = require('./chunk-FT5H2Q7Y.cjs');
8
8
  var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
9
9
  var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
10
10
  var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
@@ -5101,7 +5101,7 @@ var AirdropBaseClient = class {
5101
5101
  clientLabel: "AirdropBaseClient"
5102
5102
  });
5103
5103
  }
5104
- chunkM4IT6DNJ_cjs.assertSupportedChain(chainId);
5104
+ chunkAREQJHKA_cjs.assertSupportedChain(chainId);
5105
5105
  this.chainId = chainId;
5106
5106
  this.address = chunkJK4XMMKM_cjs.normaliseAddress(config.address);
5107
5107
  this.aclAddress = config.aclAddress ? chunkJK4XMMKM_cjs.normaliseAddress(config.aclAddress) : chunkFAXIIH5R_cjs.requireFhevmAclAddress(chainId, "AirdropBaseClient");
@@ -5788,7 +5788,7 @@ var AirdropBaseClient = class {
5788
5788
  method,
5789
5789
  contractAddress: this.address,
5790
5790
  abi: this.abi,
5791
- productMapper: chunkM4IT6DNJ_cjs.airdropProductMapper,
5791
+ productMapper: chunkAREQJHKA_cjs.airdropProductMapper,
5792
5792
  account: accountAddress(account),
5793
5793
  productContext: {
5794
5794
  creator: accountAddress(account),
@@ -5809,6 +5809,17 @@ var AirdropBaseClient = class {
5809
5809
  }
5810
5810
  return acct;
5811
5811
  }
5812
+ /**
5813
+ * The address that will actually send the transaction, as a plain `Address`.
5814
+ *
5815
+ * Needed by any method whose arguments must be validated against the sender before
5816
+ * the write — on the Merkle variant the claim identity, the payout destination and
5817
+ * the submitter are three separate addresses with rules between them.
5818
+ */
5819
+ resolveSender(override, method) {
5820
+ const wallet = this.requireWallet(method);
5821
+ return accountAddress(this.resolveAccount(wallet, override, method));
5822
+ }
5812
5823
  };
5813
5824
  function createAirdropBaseClient(config) {
5814
5825
  return new AirdropBaseClient(config);
@@ -6108,7 +6119,7 @@ async function signClaimAuthorization(args) {
6108
6119
  return chunk66IHPTOK_cjs.asSignature(sig);
6109
6120
  }
6110
6121
  function toDeploymentModeOrdinal(mode) {
6111
- return chunkM4IT6DNJ_cjs.DEPLOYMENT_MODE[mode];
6122
+ return chunkAREQJHKA_cjs.DEPLOYMENT_MODE[mode];
6112
6123
  }
6113
6124
  function toContractCommonParams(common) {
6114
6125
  return {
@@ -6124,7 +6135,7 @@ function toContractEcdsaParams(params) {
6124
6135
  return {
6125
6136
  common: toContractCommonParams(params.common),
6126
6137
  signer: params.signer,
6127
- dedupMode: chunkM4IT6DNJ_cjs.DEDUP_MODE[params.dedupMode]
6138
+ dedupMode: chunkAREQJHKA_cjs.DEDUP_MODE[params.dedupMode]
6128
6139
  };
6129
6140
  }
6130
6141
  function toContractMerkleParams(params) {
@@ -6155,9 +6166,9 @@ var ConfidentialAirdropFactoryClient = class {
6155
6166
  clientLabel: "ConfidentialAirdropFactoryClient"
6156
6167
  });
6157
6168
  }
6158
- chunkM4IT6DNJ_cjs.assertSupportedChain(chainId);
6169
+ chunkAREQJHKA_cjs.assertSupportedChain(chainId);
6159
6170
  this.chainId = chainId;
6160
- this.address = config.address ? chunkJK4XMMKM_cjs.normaliseAddress(config.address) : chunk5576FRT3_cjs.requireFheAirdropFactoryAddress(chainId);
6171
+ this.address = config.address ? chunkJK4XMMKM_cjs.normaliseAddress(config.address) : chunkFT5H2Q7Y_cjs.requireFheAirdropFactoryAddress(chainId);
6161
6172
  this.#telemetry = config.telemetry;
6162
6173
  this.#telemetry?.event("fhe-airdrop.client.init", {
6163
6174
  surface: "factory",
@@ -6228,7 +6239,7 @@ var ConfidentialAirdropFactoryClient = class {
6228
6239
  * @throws {@link InvalidArgumentError} when the root is zero and `isMerkleRootMutable` is false, or the salt was already used.
6229
6240
  */
6230
6241
  async createMerkleAirdrop(args) {
6231
- chunkM4IT6DNJ_cjs.assertMerkleModeSupported(args.mode);
6242
+ chunkAREQJHKA_cjs.assertMerkleModeSupported(args.mode);
6232
6243
  return chunkVJKZWYYJ_cjs.withTelemetry(this.#telemetry, "fhe-airdrop.factory.createMerkleAirdrop", async () => {
6233
6244
  const method = "createMerkleAirdrop";
6234
6245
  const account = this.#senderFor(args.account, method);
@@ -6320,7 +6331,7 @@ var ConfidentialAirdropFactoryClient = class {
6320
6331
  * @throws {@link MissingEncryptorError} when `amount` is given and no encryptor is resolvable.
6321
6332
  */
6322
6333
  async createAndFundMerkleAirdrop(args) {
6323
- chunkM4IT6DNJ_cjs.assertMerkleModeSupported(args.mode);
6334
+ chunkAREQJHKA_cjs.assertMerkleModeSupported(args.mode);
6324
6335
  return chunkVJKZWYYJ_cjs.withTelemetry(
6325
6336
  this.#telemetry,
6326
6337
  "fhe-airdrop.factory.createAndFundMerkleAirdrop",
@@ -6893,7 +6904,7 @@ var ConfidentialAirdropFactoryClient = class {
6893
6904
  */
6894
6905
  async #guardCreate(input) {
6895
6906
  const { variant, args, deployer, method } = input;
6896
- await chunkM4IT6DNJ_cjs.assertStockWrapper({
6907
+ await chunkAREQJHKA_cjs.assertStockWrapper({
6897
6908
  publicClient: this.publicClient,
6898
6909
  token: args.params.common.token,
6899
6910
  unwrappable: args.params.common.unwrappable
@@ -6906,7 +6917,7 @@ var ConfidentialAirdropFactoryClient = class {
6906
6917
  params: args.params,
6907
6918
  ...predictArgs
6908
6919
  });
6909
- await chunkM4IT6DNJ_cjs.assertSaltAvailable({
6920
+ await chunkAREQJHKA_cjs.assertSaltAvailable({
6910
6921
  publicClient: this.publicClient,
6911
6922
  predictedAddress,
6912
6923
  variant,
@@ -7009,7 +7020,7 @@ var ConfidentialAirdropFactoryClient = class {
7009
7020
  method,
7010
7021
  contractAddress: this.address,
7011
7022
  abi: airdropFactoryAbi,
7012
- productMapper: chunkM4IT6DNJ_cjs.airdropProductMapper,
7023
+ productMapper: chunkAREQJHKA_cjs.airdropProductMapper,
7013
7024
  account: accountAddress2(account),
7014
7025
  // `UpgradeabilityNotAllowed` and `ZamaProtocolUnsupported` carry no args
7015
7026
  // on-chain; the mapper can only name the creator and chain if we forward
@@ -7332,22 +7343,6 @@ var merkleConfidentialAirdropAbi = [
7332
7343
  name: "SafeERC20FailedOperation",
7333
7344
  type: "error"
7334
7345
  },
7335
- {
7336
- inputs: [
7337
- {
7338
- internalType: "bytes32",
7339
- name: "handle",
7340
- type: "bytes32"
7341
- },
7342
- {
7343
- internalType: "address",
7344
- name: "sender",
7345
- type: "address"
7346
- }
7347
- ],
7348
- name: "SenderNotAllowedToUseHandle",
7349
- type: "error"
7350
- },
7351
7346
  {
7352
7347
  inputs: [],
7353
7348
  name: "TokenNotAWrapper",
@@ -7374,11 +7369,32 @@ var merkleConfidentialAirdropAbi = [
7374
7369
  name: "UUPSUnsupportedProxiableUUID",
7375
7370
  type: "error"
7376
7371
  },
7372
+ {
7373
+ inputs: [
7374
+ {
7375
+ internalType: "address",
7376
+ name: "account",
7377
+ type: "address"
7378
+ },
7379
+ {
7380
+ internalType: "address",
7381
+ name: "to",
7382
+ type: "address"
7383
+ }
7384
+ ],
7385
+ name: "UnauthorizedRedirect",
7386
+ type: "error"
7387
+ },
7377
7388
  {
7378
7389
  inputs: [],
7379
7390
  name: "ZamaProtocolUnsupported",
7380
7391
  type: "error"
7381
7392
  },
7393
+ {
7394
+ inputs: [],
7395
+ name: "ZeroAccount",
7396
+ type: "error"
7397
+ },
7382
7398
  {
7383
7399
  inputs: [],
7384
7400
  name: "ZeroAdminGrant",
@@ -7998,6 +8014,11 @@ var merkleConfidentialAirdropAbi = [
7998
8014
  },
7999
8015
  {
8000
8016
  inputs: [
8017
+ {
8018
+ internalType: "address",
8019
+ name: "account",
8020
+ type: "address"
8021
+ },
8001
8022
  {
8002
8023
  internalType: "address",
8003
8024
  name: "to",
@@ -8124,6 +8145,11 @@ var merkleConfidentialAirdropAbi = [
8124
8145
  },
8125
8146
  {
8126
8147
  inputs: [
8148
+ {
8149
+ internalType: "address",
8150
+ name: "account",
8151
+ type: "address"
8152
+ },
8127
8153
  {
8128
8154
  internalType: "externalEuint64",
8129
8155
  name: "inputAmount",
@@ -8676,8 +8702,8 @@ var MerkleAirdropClient = class extends AirdropBaseClient {
8676
8702
  // CLAIM
8677
8703
  // ============================================================
8678
8704
  /**
8679
- * Claim the outstanding amount for a proof-bearing entry, delivering the
8680
- * tokens to `to` (defaults to the sending account).
8705
+ * Claim the outstanding amount for a proof-bearing entry, delivering the tokens to
8706
+ * `to` — which defaults to `entry.account`, the CLAIM IDENTITY, not the sender.
8681
8707
  *
8682
8708
  * Requires `msg.value == gasFee()` exactly — handled for you; see the
8683
8709
  * class TSDoc.
@@ -8694,16 +8720,31 @@ var MerkleAirdropClient = class extends AirdropBaseClient {
8694
8720
  *
8695
8721
  * @throws {@link ClaimNotStartedError} before `startTime`.
8696
8722
  * @throws {@link ClaimWindowClosedError} after `endTime`.
8697
- * @throws {@link InvalidArgumentError} (`argument: "merkleProof"`) when the proof does not verify against
8698
- * the current root — including when `entry.recipient` does not match the sending account.
8723
+ * @throws {@link InvalidArgumentError} (`argument: "entry.boundTo"`) when the entry's proof is bound to
8724
+ * another address, or (`argument: "merkleProof"`) when the proof does not verify against the current root.
8725
+ * @throws {@link UnauthorizedRedirectError} when a third-party submitter passes a `to` other than `entry.account`.
8699
8726
  * @returns The transaction hash.
8700
8727
  */
8701
8728
  async claim(args) {
8702
8729
  return chunkVJKZWYYJ_cjs.withTelemetry(this.telemetry, `${this.spanPrefix}.claim`, async () => {
8730
+ const submitter = this.resolveSender(args.account, "claim");
8731
+ chunkAREQJHKA_cjs.assertMerkleClaimIdentity({
8732
+ method: "claim",
8733
+ account: args.entry.account,
8734
+ boundTo: args.entry.boundTo,
8735
+ submitter,
8736
+ to: args.to
8737
+ });
8703
8738
  const fee = await this.gasFee();
8704
8739
  return this.write(
8705
8740
  "claim",
8706
- [args.to ?? viem.zeroAddress, args.entry.handle, args.entry.inputProof, args.entry.merkleProof],
8741
+ [
8742
+ args.entry.account,
8743
+ args.to ?? viem.zeroAddress,
8744
+ args.entry.handle,
8745
+ args.entry.inputProof,
8746
+ args.entry.merkleProof
8747
+ ],
8707
8748
  args.account,
8708
8749
  "claim",
8709
8750
  fee
@@ -8719,12 +8760,29 @@ var MerkleAirdropClient = class extends AirdropBaseClient {
8719
8760
  * Same replay/accounting semantics and `msg.value == gasFee()` requirement
8720
8761
  * as {@link claim} — see its `@remarks`.
8721
8762
  *
8763
+ * @remarks
8764
+ * **Self-only by design.** This entrypoint takes no claim identity: releasing an
8765
+ * allocation as a public ERC-20 transfer publishes the amount irreversibly, which is
8766
+ * the recipient's own choice to make. A relayed unwrap is therefore unrepresentable
8767
+ * rather than merely rejected, and an entry whose `account` is not the sender is
8768
+ * refused before the write. A third party can still submit a confidential
8769
+ * {@link claim}.
8770
+ *
8722
8771
  * @returns The transaction hash. The underlying ERC-20 is released later by
8723
8772
  * a separate, permissionless `finalizeUnwrap` — this hash is only the
8724
8773
  * unwrap request.
8725
8774
  */
8726
8775
  async claimAndUnwrap(args) {
8727
8776
  return chunkVJKZWYYJ_cjs.withTelemetry(this.telemetry, `${this.spanPrefix}.claimAndUnwrap`, async () => {
8777
+ const submitter = this.resolveSender(args.account, "claimAndUnwrap");
8778
+ chunkAREQJHKA_cjs.assertMerkleClaimIdentity({
8779
+ method: "claimAndUnwrap",
8780
+ account: args.entry.account,
8781
+ boundTo: args.entry.boundTo,
8782
+ submitter,
8783
+ to: args.to,
8784
+ entrypoint: "claimAndUnwrap"
8785
+ });
8728
8786
  const fee = await this.gasFee();
8729
8787
  return this.write(
8730
8788
  "claimAndUnwrap",
@@ -8740,16 +8798,32 @@ var MerkleAirdropClient = class extends AirdropBaseClient {
8740
8798
  * caller can decrypt. Consumes no accounting and no per-leaf state — the
8741
8799
  * same entry still pays the same amount after a preview. No fee.
8742
8800
  *
8743
- * An encrypted view: the contract calls `FHE.allow(outstanding, msg.sender)`,
8744
- * so the result is recovered from the receipt's ACL `Allowed` event, never
8745
- * from a simulation. See {@link AirdropBaseClient}'s class TSDoc.
8801
+ * **Submits a transaction.** The contract calls `FHE.allow(outstanding, account)`, so
8802
+ * the result is recovered from the receipt's ACL `Allowed` event, never from a
8803
+ * simulation. See {@link AirdropBaseClient}'s class TSDoc.
8746
8804
  *
8747
- * @returns `{ handle, hash }` — pass `handle` to the Zama relayer's `userDecrypt`.
8805
+ * **`entry.account` is the decryptable party, not the caller.** A relayer previewing on
8806
+ * someone's behalf gets a valid handle it cannot read — that is the contract's intent,
8807
+ * and it is what makes a blind relayed submission possible.
8808
+ *
8809
+ * @returns `{ handle, hash }` — pass `handle` to the Zama relayer's `userDecrypt`, as `entry.account`.
8748
8810
  */
8749
8811
  async getClaimAmount(args) {
8812
+ const submitter = this.resolveSender(args.account, "getClaimAmount");
8813
+ chunkAREQJHKA_cjs.assertMerkleClaimIdentity({
8814
+ method: "getClaimAmount",
8815
+ account: args.entry.account,
8816
+ boundTo: args.entry.boundTo,
8817
+ submitter
8818
+ });
8750
8819
  return this.encryptedView({
8751
8820
  functionName: "getClaimAmount",
8752
- args: [args.entry.handle, args.entry.inputProof, args.entry.merkleProof],
8821
+ args: [args.entry.account, args.entry.handle, args.entry.inputProof, args.entry.merkleProof],
8822
+ // The contract grants the outstanding handle to `account`, never to the caller
8823
+ // (`_outstandingOf(account, account, …)`), so the receipt's ACL `Allowed` event
8824
+ // names the account. Defaulting to the sender would fail extraction on any
8825
+ // relayed preview — after the transaction had already been mined.
8826
+ grantee: args.entry.account,
8753
8827
  account: args.account
8754
8828
  });
8755
8829
  }
@@ -8772,10 +8846,15 @@ var MerkleAirdropClient = class extends AirdropBaseClient {
8772
8846
  * leaves for the same recipient, claiming both pays the higher of the
8773
8847
  * two totals net of this running value — `max`, not `sum`.
8774
8848
  *
8775
- * The zero handle (uninitialized ciphertext) before an account's first
8776
- * settled claim decrypts as zero.
8849
+ * **An account that has never claimed returns the ZERO handle, which cannot be
8850
+ * decrypted.** It is an uninitialized ciphertext, so nobody holds an ACL on it and
8851
+ * the relayer rejects it with "not authorized to user decrypt handle 0x0…0" rather
8852
+ * than answering zero. Treat `handle === zeroHash` as "nothing delivered yet" and
8853
+ * skip the decrypt; only call `userDecrypt` on a non-zero handle. (A mock FHEVM
8854
+ * instance does answer zero here, so this only bites against a live relayer.)
8777
8855
  *
8778
- * @returns The account's cumulative delivered total, as an encrypted handle.
8856
+ * @returns The account's cumulative delivered total as an encrypted handle, or the
8857
+ * zero handle if it has never claimed.
8779
8858
  */
8780
8859
  async getClaimedAmount(account) {
8781
8860
  const handle = await this.read("getClaimedAmount", [account]);
@@ -8822,9 +8901,925 @@ function createMerkleAirdropClient(config) {
8822
8901
  return new MerkleAirdropClient(config);
8823
8902
  }
8824
8903
 
8904
+ // src/fhe-airdrop/abis/compliance.ts
8905
+ var complianceRoleManagerAbi = [
8906
+ {
8907
+ inputs: [],
8908
+ stateMutability: "nonpayable",
8909
+ type: "constructor"
8910
+ },
8911
+ {
8912
+ inputs: [],
8913
+ name: "AccessControlBadConfirmation",
8914
+ type: "error"
8915
+ },
8916
+ {
8917
+ inputs: [
8918
+ {
8919
+ internalType: "address",
8920
+ name: "account",
8921
+ type: "address"
8922
+ },
8923
+ {
8924
+ internalType: "bytes32",
8925
+ name: "neededRole",
8926
+ type: "bytes32"
8927
+ }
8928
+ ],
8929
+ name: "AccessControlUnauthorizedAccount",
8930
+ type: "error"
8931
+ },
8932
+ {
8933
+ inputs: [
8934
+ {
8935
+ internalType: "address",
8936
+ name: "airdrop",
8937
+ type: "address"
8938
+ }
8939
+ ],
8940
+ name: "AirdropAndManagerAreSameAddress",
8941
+ type: "error"
8942
+ },
8943
+ {
8944
+ inputs: [],
8945
+ name: "CannotManageComplianceDelegate",
8946
+ type: "error"
8947
+ },
8948
+ {
8949
+ inputs: [],
8950
+ name: "DelegateAlreadyAdded",
8951
+ type: "error"
8952
+ },
8953
+ {
8954
+ inputs: [
8955
+ {
8956
+ internalType: "address",
8957
+ name: "delegate",
8958
+ type: "address"
8959
+ }
8960
+ ],
8961
+ name: "DelegateAndAirdropAreSameAddress",
8962
+ type: "error"
8963
+ },
8964
+ {
8965
+ inputs: [
8966
+ {
8967
+ internalType: "address",
8968
+ name: "delegate",
8969
+ type: "address"
8970
+ }
8971
+ ],
8972
+ name: "DelegateAndManagerAreSameAddress",
8973
+ type: "error"
8974
+ },
8975
+ {
8976
+ inputs: [],
8977
+ name: "DelegateNotFound",
8978
+ type: "error"
8979
+ },
8980
+ {
8981
+ inputs: [],
8982
+ name: "InvalidInitialization",
8983
+ type: "error"
8984
+ },
8985
+ {
8986
+ inputs: [],
8987
+ name: "NotInitializing",
8988
+ type: "error"
8989
+ },
8990
+ {
8991
+ inputs: [],
8992
+ name: "ZamaProtocolUnsupported",
8993
+ type: "error"
8994
+ },
8995
+ {
8996
+ inputs: [],
8997
+ name: "ZeroAirdrop",
8998
+ type: "error"
8999
+ },
9000
+ {
9001
+ inputs: [],
9002
+ name: "ZeroClientAdmin",
9003
+ type: "error"
9004
+ },
9005
+ {
9006
+ inputs: [],
9007
+ name: "ZeroDelegate",
9008
+ type: "error"
9009
+ },
9010
+ {
9011
+ anonymous: false,
9012
+ inputs: [
9013
+ {
9014
+ indexed: true,
9015
+ internalType: "address",
9016
+ name: "delegate",
9017
+ type: "address"
9018
+ }
9019
+ ],
9020
+ name: "ClientDelegateAdded",
9021
+ type: "event"
9022
+ },
9023
+ {
9024
+ anonymous: false,
9025
+ inputs: [
9026
+ {
9027
+ indexed: true,
9028
+ internalType: "address",
9029
+ name: "delegate",
9030
+ type: "address"
9031
+ }
9032
+ ],
9033
+ name: "ClientDelegateRevoked",
9034
+ type: "event"
9035
+ },
9036
+ {
9037
+ anonymous: false,
9038
+ inputs: [
9039
+ {
9040
+ indexed: true,
9041
+ internalType: "address",
9042
+ name: "delegate",
9043
+ type: "address"
9044
+ }
9045
+ ],
9046
+ name: "ComplianceDelegateSet",
9047
+ type: "event"
9048
+ },
9049
+ {
9050
+ anonymous: false,
9051
+ inputs: [
9052
+ {
9053
+ indexed: false,
9054
+ internalType: "uint64",
9055
+ name: "version",
9056
+ type: "uint64"
9057
+ }
9058
+ ],
9059
+ name: "Initialized",
9060
+ type: "event"
9061
+ },
9062
+ {
9063
+ anonymous: false,
9064
+ inputs: [
9065
+ {
9066
+ indexed: true,
9067
+ internalType: "bytes32",
9068
+ name: "role",
9069
+ type: "bytes32"
9070
+ },
9071
+ {
9072
+ indexed: true,
9073
+ internalType: "bytes32",
9074
+ name: "previousAdminRole",
9075
+ type: "bytes32"
9076
+ },
9077
+ {
9078
+ indexed: true,
9079
+ internalType: "bytes32",
9080
+ name: "newAdminRole",
9081
+ type: "bytes32"
9082
+ }
9083
+ ],
9084
+ name: "RoleAdminChanged",
9085
+ type: "event"
9086
+ },
9087
+ {
9088
+ anonymous: false,
9089
+ inputs: [
9090
+ {
9091
+ indexed: true,
9092
+ internalType: "bytes32",
9093
+ name: "role",
9094
+ type: "bytes32"
9095
+ },
9096
+ {
9097
+ indexed: true,
9098
+ internalType: "address",
9099
+ name: "account",
9100
+ type: "address"
9101
+ },
9102
+ {
9103
+ indexed: true,
9104
+ internalType: "address",
9105
+ name: "sender",
9106
+ type: "address"
9107
+ }
9108
+ ],
9109
+ name: "RoleGranted",
9110
+ type: "event"
9111
+ },
9112
+ {
9113
+ anonymous: false,
9114
+ inputs: [
9115
+ {
9116
+ indexed: true,
9117
+ internalType: "bytes32",
9118
+ name: "role",
9119
+ type: "bytes32"
9120
+ },
9121
+ {
9122
+ indexed: true,
9123
+ internalType: "address",
9124
+ name: "account",
9125
+ type: "address"
9126
+ },
9127
+ {
9128
+ indexed: true,
9129
+ internalType: "address",
9130
+ name: "sender",
9131
+ type: "address"
9132
+ }
9133
+ ],
9134
+ name: "RoleRevoked",
9135
+ type: "event"
9136
+ },
9137
+ {
9138
+ inputs: [],
9139
+ name: "DEFAULT_ADMIN_ROLE",
9140
+ outputs: [
9141
+ {
9142
+ internalType: "bytes32",
9143
+ name: "",
9144
+ type: "bytes32"
9145
+ }
9146
+ ],
9147
+ stateMutability: "view",
9148
+ type: "function"
9149
+ },
9150
+ {
9151
+ inputs: [],
9152
+ name: "DELEGATION_ADMIN_ROLE",
9153
+ outputs: [
9154
+ {
9155
+ internalType: "bytes32",
9156
+ name: "",
9157
+ type: "bytes32"
9158
+ }
9159
+ ],
9160
+ stateMutability: "view",
9161
+ type: "function"
9162
+ },
9163
+ {
9164
+ inputs: [
9165
+ {
9166
+ internalType: "address",
9167
+ name: "delegate",
9168
+ type: "address"
9169
+ }
9170
+ ],
9171
+ name: "addDelegate",
9172
+ outputs: [],
9173
+ stateMutability: "nonpayable",
9174
+ type: "function"
9175
+ },
9176
+ {
9177
+ inputs: [],
9178
+ name: "airdrop",
9179
+ outputs: [
9180
+ {
9181
+ internalType: "address",
9182
+ name: "",
9183
+ type: "address"
9184
+ }
9185
+ ],
9186
+ stateMutability: "view",
9187
+ type: "function"
9188
+ },
9189
+ {
9190
+ inputs: [],
9191
+ name: "clientDelegates",
9192
+ outputs: [
9193
+ {
9194
+ internalType: "address[]",
9195
+ name: "",
9196
+ type: "address[]"
9197
+ }
9198
+ ],
9199
+ stateMutability: "view",
9200
+ type: "function"
9201
+ },
9202
+ {
9203
+ inputs: [],
9204
+ name: "complianceDelegate",
9205
+ outputs: [
9206
+ {
9207
+ internalType: "address",
9208
+ name: "",
9209
+ type: "address"
9210
+ }
9211
+ ],
9212
+ stateMutability: "view",
9213
+ type: "function"
9214
+ },
9215
+ {
9216
+ inputs: [
9217
+ {
9218
+ internalType: "bytes32",
9219
+ name: "role",
9220
+ type: "bytes32"
9221
+ }
9222
+ ],
9223
+ name: "getRoleAdmin",
9224
+ outputs: [
9225
+ {
9226
+ internalType: "bytes32",
9227
+ name: "",
9228
+ type: "bytes32"
9229
+ }
9230
+ ],
9231
+ stateMutability: "view",
9232
+ type: "function"
9233
+ },
9234
+ {
9235
+ inputs: [
9236
+ {
9237
+ internalType: "bytes32",
9238
+ name: "role",
9239
+ type: "bytes32"
9240
+ },
9241
+ {
9242
+ internalType: "uint256",
9243
+ name: "index",
9244
+ type: "uint256"
9245
+ }
9246
+ ],
9247
+ name: "getRoleMember",
9248
+ outputs: [
9249
+ {
9250
+ internalType: "address",
9251
+ name: "",
9252
+ type: "address"
9253
+ }
9254
+ ],
9255
+ stateMutability: "view",
9256
+ type: "function"
9257
+ },
9258
+ {
9259
+ inputs: [
9260
+ {
9261
+ internalType: "bytes32",
9262
+ name: "role",
9263
+ type: "bytes32"
9264
+ }
9265
+ ],
9266
+ name: "getRoleMemberCount",
9267
+ outputs: [
9268
+ {
9269
+ internalType: "uint256",
9270
+ name: "",
9271
+ type: "uint256"
9272
+ }
9273
+ ],
9274
+ stateMutability: "view",
9275
+ type: "function"
9276
+ },
9277
+ {
9278
+ inputs: [
9279
+ {
9280
+ internalType: "bytes32",
9281
+ name: "role",
9282
+ type: "bytes32"
9283
+ }
9284
+ ],
9285
+ name: "getRoleMembers",
9286
+ outputs: [
9287
+ {
9288
+ internalType: "address[]",
9289
+ name: "",
9290
+ type: "address[]"
9291
+ }
9292
+ ],
9293
+ stateMutability: "view",
9294
+ type: "function"
9295
+ },
9296
+ {
9297
+ inputs: [
9298
+ {
9299
+ internalType: "bytes32",
9300
+ name: "role",
9301
+ type: "bytes32"
9302
+ },
9303
+ {
9304
+ internalType: "address",
9305
+ name: "account",
9306
+ type: "address"
9307
+ }
9308
+ ],
9309
+ name: "grantRole",
9310
+ outputs: [],
9311
+ stateMutability: "nonpayable",
9312
+ type: "function"
9313
+ },
9314
+ {
9315
+ inputs: [
9316
+ {
9317
+ internalType: "bytes32",
9318
+ name: "role",
9319
+ type: "bytes32"
9320
+ },
9321
+ {
9322
+ internalType: "address",
9323
+ name: "account",
9324
+ type: "address"
9325
+ }
9326
+ ],
9327
+ name: "hasRole",
9328
+ outputs: [
9329
+ {
9330
+ internalType: "bool",
9331
+ name: "",
9332
+ type: "bool"
9333
+ }
9334
+ ],
9335
+ stateMutability: "view",
9336
+ type: "function"
9337
+ },
9338
+ {
9339
+ inputs: [
9340
+ {
9341
+ internalType: "address",
9342
+ name: "airdrop_",
9343
+ type: "address"
9344
+ },
9345
+ {
9346
+ internalType: "address",
9347
+ name: "clientAdmin",
9348
+ type: "address"
9349
+ },
9350
+ {
9351
+ internalType: "address",
9352
+ name: "clientDelegate",
9353
+ type: "address"
9354
+ },
9355
+ {
9356
+ internalType: "address",
9357
+ name: "complianceDelegate_",
9358
+ type: "address"
9359
+ }
9360
+ ],
9361
+ name: "initialize",
9362
+ outputs: [],
9363
+ stateMutability: "nonpayable",
9364
+ type: "function"
9365
+ },
9366
+ {
9367
+ inputs: [
9368
+ {
9369
+ internalType: "address",
9370
+ name: "delegate",
9371
+ type: "address"
9372
+ }
9373
+ ],
9374
+ name: "isActiveDelegate",
9375
+ outputs: [
9376
+ {
9377
+ internalType: "bool",
9378
+ name: "",
9379
+ type: "bool"
9380
+ }
9381
+ ],
9382
+ stateMutability: "view",
9383
+ type: "function"
9384
+ },
9385
+ {
9386
+ inputs: [
9387
+ {
9388
+ internalType: "bytes32",
9389
+ name: "role",
9390
+ type: "bytes32"
9391
+ },
9392
+ {
9393
+ internalType: "address",
9394
+ name: "callerConfirmation",
9395
+ type: "address"
9396
+ }
9397
+ ],
9398
+ name: "renounceRole",
9399
+ outputs: [],
9400
+ stateMutability: "nonpayable",
9401
+ type: "function"
9402
+ },
9403
+ {
9404
+ inputs: [
9405
+ {
9406
+ internalType: "address",
9407
+ name: "delegate",
9408
+ type: "address"
9409
+ }
9410
+ ],
9411
+ name: "revokeDelegate",
9412
+ outputs: [],
9413
+ stateMutability: "nonpayable",
9414
+ type: "function"
9415
+ },
9416
+ {
9417
+ inputs: [
9418
+ {
9419
+ internalType: "bytes32",
9420
+ name: "role",
9421
+ type: "bytes32"
9422
+ },
9423
+ {
9424
+ internalType: "address",
9425
+ name: "account",
9426
+ type: "address"
9427
+ }
9428
+ ],
9429
+ name: "revokeRole",
9430
+ outputs: [],
9431
+ stateMutability: "nonpayable",
9432
+ type: "function"
9433
+ },
9434
+ {
9435
+ inputs: [
9436
+ {
9437
+ internalType: "bytes4",
9438
+ name: "interfaceId",
9439
+ type: "bytes4"
9440
+ }
9441
+ ],
9442
+ name: "supportsInterface",
9443
+ outputs: [
9444
+ {
9445
+ internalType: "bool",
9446
+ name: "",
9447
+ type: "bool"
9448
+ }
9449
+ ],
9450
+ stateMutability: "view",
9451
+ type: "function"
9452
+ }
9453
+ ];
9454
+
9455
+ // src/fhe-airdrop/compliance.ts
9456
+ var ACL_PROPAGATION_CODE = "DELEGATION_NOT_PROPAGATED";
9457
+ var ACL_PROPAGATION_ERROR_NAME = "DelegationNotPropagatedError";
9458
+ var ACL_PROPAGATION_STATUSES = /* @__PURE__ */ new Set([400, 500]);
9459
+ function matchesPropagationMessage(message) {
9460
+ const lower = message.toLowerCase();
9461
+ if (lower.includes("acl check not propagated")) return true;
9462
+ return lower.includes("propagat") && lower.includes("gateway");
9463
+ }
9464
+ function readRecord(value) {
9465
+ return typeof value === "object" && value !== null ? value : void 0;
9466
+ }
9467
+ function readNumber(obj, key) {
9468
+ const value = obj?.[key];
9469
+ return typeof value === "number" ? value : void 0;
9470
+ }
9471
+ function readString(obj, key) {
9472
+ const value = obj?.[key];
9473
+ return typeof value === "string" ? value : void 0;
9474
+ }
9475
+ function isAclPropagationError(error) {
9476
+ const err = readRecord(error);
9477
+ if (!err) return false;
9478
+ const cause = readRecord(err["cause"]);
9479
+ if (err["code"] === ACL_PROPAGATION_CODE || err["name"] === ACL_PROPAGATION_ERROR_NAME || cause?.["code"] === ACL_PROPAGATION_CODE || cause?.["name"] === ACL_PROPAGATION_ERROR_NAME) {
9480
+ return true;
9481
+ }
9482
+ const status = readNumber(err, "status") ?? readNumber(err, "statusCode") ?? readNumber(cause, "status") ?? readNumber(cause, "statusCode");
9483
+ if (status === void 0 || !ACL_PROPAGATION_STATUSES.has(status)) return false;
9484
+ const errMessage = readString(err, "message");
9485
+ const causeMessage = readString(cause, "message");
9486
+ return errMessage !== void 0 && matchesPropagationMessage(errMessage) || causeMessage !== void 0 && matchesPropagationMessage(causeMessage);
9487
+ }
9488
+ var ComplianceManagerClient = class {
9489
+ publicClient;
9490
+ walletClient;
9491
+ address;
9492
+ chainId;
9493
+ #telemetry;
9494
+ constructor(config) {
9495
+ this.publicClient = config.publicClient;
9496
+ this.walletClient = config.walletClient;
9497
+ const chainId = config.chainId ?? config.publicClient.chain?.id;
9498
+ if (chainId === void 0) {
9499
+ throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
9500
+ reason: "chain-id-missing",
9501
+ product: "fheAirdrop",
9502
+ contract: "complianceManager",
9503
+ clientLabel: "ComplianceManagerClient"
9504
+ });
9505
+ }
9506
+ chunkAREQJHKA_cjs.assertSupportedChain(chainId);
9507
+ this.chainId = chainId;
9508
+ this.address = chunkJK4XMMKM_cjs.normaliseAddress(config.address);
9509
+ this.#telemetry = config.telemetry;
9510
+ this.#telemetry?.event("fhe-airdrop.client.init", {
9511
+ surface: "compliance",
9512
+ chainId,
9513
+ hasWallet: !!this.walletClient,
9514
+ sdkVersion: chunkUG5RKLU2_cjs.SDK_VERSION
9515
+ });
9516
+ }
9517
+ // ============================================================
9518
+ // CLIENT DELEGATION MGMT
9519
+ // ============================================================
9520
+ /**
9521
+ * Add a client delegate: grants `delegate` permanent (never-expiring)
9522
+ * user-decryption delegation over this clone's airdrop. Requires
9523
+ * {@link DELEGATION_ADMIN_ROLE}.
9524
+ *
9525
+ * Effective on-chain immediately; see the class TSDoc for the gateway
9526
+ * propagation lag before `delegatedUserDecrypt` catches up.
9527
+ *
9528
+ * @throws {@link InvalidArgumentError} (`argument: "delegate"`) when `delegate` is the zero address
9529
+ * (`ZeroDelegate`), already an active client delegate (`DelegateAlreadyAdded`), or targets the
9530
+ * irrevocable platform compliance delegate (`CannotManageComplianceDelegate`).
9531
+ * @returns The transaction hash.
9532
+ */
9533
+ async addDelegate(args) {
9534
+ return chunkVJKZWYYJ_cjs.withTelemetry(
9535
+ this.#telemetry,
9536
+ "fhe-airdrop.compliance.addDelegate",
9537
+ () => this.#write("addDelegate", [args.delegate], args.account, "addDelegate")
9538
+ );
9539
+ }
9540
+ /**
9541
+ * Revoke a client delegate. Requires {@link DELEGATION_ADMIN_ROLE}.
9542
+ *
9543
+ * Effective on-chain immediately — but off-chain, gateway-served
9544
+ * `delegatedUserDecrypt` calls stop succeeding only once the gateway
9545
+ * observes the revocation, which is not instantaneous either. Cannot target
9546
+ * the platform compliance delegate, which is irrevocable by construction.
9547
+ *
9548
+ * **Not in the same block as {@link addDelegate} for the same delegate.**
9549
+ * The FHEVM ACL rejects an add and a revoke of one delegate within a single
9550
+ * block (`AlreadyDelegatedOrRevokedInSameBlock`), and because that revert
9551
+ * comes from the ACL rather than from this contract, it surfaces as an
9552
+ * opaque {@link ContractRevertError} with no decodable selector — nothing
9553
+ * names the delegate or the cause. Batching an add and a revoke into one
9554
+ * multicall, or sending both inside one block, is the way to hit it; wait a
9555
+ * block between them. This is the sequencing counterpart to the propagation
9556
+ * gotcha on the class TSDoc: that one is the gateway lagging the chain, this
9557
+ * one is the chain refusing two conflicting writes at the same height.
9558
+ *
9559
+ * @throws {@link InvalidArgumentError} (`argument: "delegate"`) when `delegate` is the zero address
9560
+ * (`ZeroDelegate`), not currently an active client delegate (`DelegateNotFound`), or targets the
9561
+ * irrevocable platform compliance delegate (`CannotManageComplianceDelegate`).
9562
+ * @returns The transaction hash.
9563
+ */
9564
+ async revokeDelegate(args) {
9565
+ return chunkVJKZWYYJ_cjs.withTelemetry(
9566
+ this.#telemetry,
9567
+ "fhe-airdrop.compliance.revokeDelegate",
9568
+ () => this.#write("revokeDelegate", [args.delegate], args.account, "revokeDelegate")
9569
+ );
9570
+ }
9571
+ // ============================================================
9572
+ // READS
9573
+ // ============================================================
9574
+ /** The one airdrop instance this clone serves — set once, at `initialize`. */
9575
+ async airdrop() {
9576
+ return this.#read("airdrop");
9577
+ }
9578
+ /**
9579
+ * The platform compliance delegate.
9580
+ *
9581
+ * @returns The delegate address, or the zero address when this clone was
9582
+ * created with the platform compliance policy OFF. Because `initialize`
9583
+ * always runs atomically before this client can reach the clone (see the
9584
+ * class TSDoc), a zero return never means "not wired yet" — there is no
9585
+ * such observable state on this contract. It unambiguously means "no
9586
+ * platform delegate for this airdrop."
9587
+ */
9588
+ async complianceDelegate() {
9589
+ return this.#read("complianceDelegate");
9590
+ }
9591
+ /** The current set of active client delegates (excludes the platform compliance delegate, if any). */
9592
+ async clientDelegates() {
9593
+ return this.#read("clientDelegates");
9594
+ }
9595
+ /**
9596
+ * Authoritative active-delegate check for `delegate` — reads the ACL
9597
+ * expiration date directly rather than the contract's `EnumerableSet`
9598
+ * mirror, so it reflects the platform compliance delegate too (which never
9599
+ * appears in {@link clientDelegates}).
9600
+ *
9601
+ * On-chain truth only: a `true` result means the delegation is live in the
9602
+ * ACL, not that the gateway has caught up with it yet — see the class
9603
+ * TSDoc's propagation note.
9604
+ */
9605
+ async isActiveDelegate(delegate) {
9606
+ return this.#read("isActiveDelegate", [delegate]);
9607
+ }
9608
+ // Role-constant getters are named for the contract function they read, the
9609
+ // same convention every other client in this module follows: one spelling
9610
+ // per role, whichever client you happen to be holding.
9611
+ /** Gates {@link addDelegate} / {@link revokeDelegate}. */
9612
+ async DELEGATION_ADMIN_ROLE() {
9613
+ return this.#read("DELEGATION_ADMIN_ROLE");
9614
+ }
9615
+ /**
9616
+ * OpenZeppelin's root role (`bytes32(0)`), read from the clone rather than
9617
+ * hard-coded. It administers {@link DELEGATION_ADMIN_ROLE}.
9618
+ */
9619
+ async DEFAULT_ADMIN_ROLE() {
9620
+ return this.#read("DEFAULT_ADMIN_ROLE");
9621
+ }
9622
+ // ============================================================
9623
+ // ROLE ADMINISTRATION
9624
+ // ============================================================
9625
+ //
9626
+ // The clone is `AccessControlEnumerableUpgradeable`, so membership is
9627
+ // enumerable as well as checkable. This surface is what makes the delegation
9628
+ // verbs above administrable: without it, whoever the factory named at
9629
+ // `initialize` is the only account that can ever add a delegate, and there
9630
+ // is no way to find out who that is.
9631
+ //
9632
+ // Unlike an airdrop instance, this contract adds no "never empty" floor of
9633
+ // its own - emptying `DEFAULT_ADMIN_ROLE` here permanently freezes the
9634
+ // clone's delegate set at whatever it currently holds.
9635
+ /**
9636
+ * Whether `holder` holds `role`.
9637
+ *
9638
+ * The role subject is called `holder`, not `account`: on the writes below
9639
+ * `account` already means "who sends this transaction", and one key cannot
9640
+ * be both.
9641
+ *
9642
+ * @param args.role A `bytes32` from {@link DELEGATION_ADMIN_ROLE} or {@link DEFAULT_ADMIN_ROLE}.
9643
+ */
9644
+ async hasRole(args) {
9645
+ return this.#read("hasRole", [args.role, args.holder]);
9646
+ }
9647
+ /** The role whose holders may {@link grantRole} and {@link revokeRole} `role`. */
9648
+ async getRoleAdmin(role) {
9649
+ return this.#read("getRoleAdmin", [role]);
9650
+ }
9651
+ /** How many accounts hold `role`. */
9652
+ async getRoleMemberCount(role) {
9653
+ return this.#read("getRoleMemberCount", [role]);
9654
+ }
9655
+ /**
9656
+ * The `index`-th holder of `role`, in `EnumerableSet` order - which is not
9657
+ * stable across grants and revokes. Prefer {@link getRoleMembers}.
9658
+ */
9659
+ async getRoleMember(args) {
9660
+ return this.#read("getRoleMember", [args.role, args.index]);
9661
+ }
9662
+ /**
9663
+ * Every account currently holding `role`.
9664
+ *
9665
+ * With {@link DELEGATION_ADMIN_ROLE} this answers "who may add or revoke a
9666
+ * delegate on this clone?" - the administrative counterpart to
9667
+ * {@link clientDelegates}, which answers "who may currently decrypt?".
9668
+ */
9669
+ async getRoleMembers(role) {
9670
+ return this.#read("getRoleMembers", [role]);
9671
+ }
9672
+ /**
9673
+ * Grant `role` to `holder`. Requires the role's admin role
9674
+ * ({@link getRoleAdmin}).
9675
+ *
9676
+ * This is how a second operator is added to {@link DELEGATION_ADMIN_ROLE} -
9677
+ * the delegation verbs themselves are unaffected, the grant only widens who
9678
+ * may call them.
9679
+ *
9680
+ * @returns The transaction hash.
9681
+ */
9682
+ async grantRole(args) {
9683
+ return chunkVJKZWYYJ_cjs.withTelemetry(
9684
+ this.#telemetry,
9685
+ "fhe-airdrop.compliance.grantRole",
9686
+ () => this.#write("grantRole", [args.role, args.holder], args.account, "grantRole")
9687
+ );
9688
+ }
9689
+ /**
9690
+ * Revoke `role` from `holder`. Requires the role's admin role.
9691
+ *
9692
+ * Revoking a delegation admin does **not** revoke the delegations they
9693
+ * created: an existing delegate keeps decrypting until
9694
+ * {@link revokeDelegate} is called for it explicitly.
9695
+ *
9696
+ * @returns The transaction hash.
9697
+ */
9698
+ async revokeRole(args) {
9699
+ return chunkVJKZWYYJ_cjs.withTelemetry(
9700
+ this.#telemetry,
9701
+ "fhe-airdrop.compliance.revokeRole",
9702
+ () => this.#write("revokeRole", [args.role, args.holder], args.account, "revokeRole")
9703
+ );
9704
+ }
9705
+ /**
9706
+ * Give up `role` yourself.
9707
+ *
9708
+ * The contract's signature is `renounceRole(role, callerConfirmation)` and
9709
+ * it reverts `AccessControlBadConfirmation` unless `callerConfirmation` is
9710
+ * the sender, so this method takes no holder and fills the confirmation from
9711
+ * the resolved sending account. Renouncing for somebody else is not a call
9712
+ * that can succeed; use {@link revokeRole} to remove another account's role.
9713
+ *
9714
+ * @returns The transaction hash.
9715
+ */
9716
+ async renounceRole(args) {
9717
+ const method = "renounceRole";
9718
+ const wallet = this.#requireWallet(method);
9719
+ const account = this.#resolveAccount(wallet, args.account, method);
9720
+ return chunkVJKZWYYJ_cjs.withTelemetry(
9721
+ this.#telemetry,
9722
+ "fhe-airdrop.compliance.renounceRole",
9723
+ () => this.#write(method, [args.role, accountAddress3(account)], account, method)
9724
+ );
9725
+ }
9726
+ // ============================================================
9727
+ // INTERNALS (private)
9728
+ // ============================================================
9729
+ async #write(functionName, args, account, method) {
9730
+ const wallet = this.#requireWallet(method);
9731
+ const acct = this.#resolveAccount(wallet, account, method);
9732
+ await this.#preflightWrite(method, functionName, args, acct);
9733
+ try {
9734
+ return await wallet.writeContract({
9735
+ address: this.address,
9736
+ abi: complianceRoleManagerAbi,
9737
+ functionName,
9738
+ args,
9739
+ account: acct,
9740
+ chain: wallet.chain
9741
+ });
9742
+ } catch (err) {
9743
+ throw this.#mapRevert(method, err, acct);
9744
+ }
9745
+ }
9746
+ async #read(functionName, args = []) {
9747
+ const result = await this.publicClient.readContract({
9748
+ address: this.address,
9749
+ abi: complianceRoleManagerAbi,
9750
+ functionName,
9751
+ args
9752
+ });
9753
+ return result;
9754
+ }
9755
+ /**
9756
+ * Simulate a write purely to surface typed reverts.
9757
+ *
9758
+ * The simulate's return value is discarded on principle: this contract
9759
+ * returns nothing from `addDelegate` / `revokeDelegate` anyway, but the
9760
+ * pattern is kept identical to every other airdrop v2 client so a revert is
9761
+ * always decoded before the user pays for it.
9762
+ */
9763
+ async #preflightWrite(method, functionName, args, account) {
9764
+ try {
9765
+ await this.publicClient.simulateContract({
9766
+ address: this.address,
9767
+ abi: complianceRoleManagerAbi,
9768
+ functionName,
9769
+ args,
9770
+ account
9771
+ });
9772
+ } catch (err) {
9773
+ if (chunkMVDQMV25_cjs.isContractRevert(err)) {
9774
+ throw this.#mapRevert(method, err, account);
9775
+ }
9776
+ }
9777
+ }
9778
+ /**
9779
+ * Map a viem error to the SDK's typed palette.
9780
+ *
9781
+ * `productContext` deliberately carries only public identifiers — the
9782
+ * caller, the chain. Never an amount: this contract never handles amounts
9783
+ * at all, but the convention is shared across every airdrop v2 client.
9784
+ */
9785
+ #mapRevert(method, err, account) {
9786
+ return chunkMVDQMV25_cjs.mapContractRevert(err, {
9787
+ method,
9788
+ contractAddress: this.address,
9789
+ abi: complianceRoleManagerAbi,
9790
+ productMapper: chunkAREQJHKA_cjs.airdropProductMapper,
9791
+ account: accountAddress3(account),
9792
+ productContext: {
9793
+ creator: accountAddress3(account),
9794
+ chainId: this.chainId
9795
+ }
9796
+ });
9797
+ }
9798
+ #requireWallet(method) {
9799
+ if (!this.walletClient) {
9800
+ throw new chunk67OV5CX2_cjs.MissingWalletClientError(method);
9801
+ }
9802
+ return this.walletClient;
9803
+ }
9804
+ #resolveAccount(wallet, override, method) {
9805
+ const acct = override ?? wallet.account;
9806
+ if (!acct) {
9807
+ throw new chunk67OV5CX2_cjs.MissingAccountError(method);
9808
+ }
9809
+ return acct;
9810
+ }
9811
+ };
9812
+ function createComplianceManagerClient(config) {
9813
+ return new ComplianceManagerClient(config);
9814
+ }
9815
+ function accountAddress3(account) {
9816
+ return typeof account === "string" ? account : account.address;
9817
+ }
9818
+
8825
9819
  exports.AirdropBaseClient = AirdropBaseClient;
8826
9820
  exports.CLAIM_TYPEHASH = CLAIM_TYPEHASH;
8827
9821
  exports.CLAIM_TYPES = CLAIM_TYPES;
9822
+ exports.ComplianceManagerClient = ComplianceManagerClient;
8828
9823
  exports.ConfidentialAirdropFactoryClient = ConfidentialAirdropFactoryClient;
8829
9824
  exports.EIP712_DOMAIN_NAME = EIP712_DOMAIN_NAME;
8830
9825
  exports.EIP712_DOMAIN_VERSION = EIP712_DOMAIN_VERSION;
@@ -8832,14 +9827,17 @@ exports.EcdsaAirdropClient = EcdsaAirdropClient;
8832
9827
  exports.FACTORY_ROLE_CONCENTRATION_NOTE = FACTORY_ROLE_CONCENTRATION_NOTE;
8833
9828
  exports.MerkleAirdropClient = MerkleAirdropClient;
8834
9829
  exports.airdropFactoryAbi = airdropFactoryAbi;
9830
+ exports.complianceRoleManagerAbi = complianceRoleManagerAbi;
8835
9831
  exports.confidentialAirdropBaseAbi = confidentialAirdropBaseAbi;
8836
9832
  exports.createAirdropBaseClient = createAirdropBaseClient;
9833
+ exports.createComplianceManagerClient = createComplianceManagerClient;
8837
9834
  exports.createConfidentialAirdropFactoryClient = createConfidentialAirdropFactoryClient;
8838
9835
  exports.createEcdsaAirdropClient = createEcdsaAirdropClient;
8839
9836
  exports.createMerkleAirdropClient = createMerkleAirdropClient;
8840
9837
  exports.ecdsaConfidentialAirdropAbi = ecdsaConfidentialAirdropAbi;
8841
9838
  exports.encryptUint64 = encryptUint64;
8842
9839
  exports.encryptUint64Batch = encryptUint64Batch;
9840
+ exports.isAclPropagationError = isAclPropagationError;
8843
9841
  exports.merkleConfidentialAirdropAbi = merkleConfidentialAirdropAbi;
8844
9842
  exports.resolveEncryptor = resolveEncryptor;
8845
9843
  exports.signClaimAuthorization = signClaimAuthorization;