@tokenops/sdk 1.5.1 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +198 -2
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SECURITY.md +7 -1
- package/SUPPORT.md +47 -0
- package/dist/{chunk-YQIBBEFJ.js → chunk-335Z2W67.js} +1 -1
- package/dist/{chunk-2NCLOQ56.cjs → chunk-3QHNYEQD.cjs} +77 -0
- package/dist/chunk-456VDDA3.js +370 -0
- package/dist/{chunk-SG65XWH7.js → chunk-4RAAATVY.js} +1 -3
- package/dist/{chunk-6BMP4ICG.js → chunk-4TSDNZQ3.js} +60 -2
- package/dist/{chunk-PUPKNW3R.cjs → chunk-5576FRT3.cjs} +30 -6
- package/dist/{chunk-AOP6HMPW.js → chunk-6GNR22OV.js} +75 -1
- package/dist/{chunk-NTZY6IB7.js → chunk-6NAVMWZQ.js} +4 -3
- package/dist/{chunk-C7BRZXJA.cjs → chunk-6PXXGACR.cjs} +8 -7
- package/dist/{chunk-IJFQ5L4I.js → chunk-74QFZ5MK.js} +4 -3
- package/dist/chunk-7AFPOE7N.cjs +59 -0
- package/dist/chunk-AXIPOR3C.js +56 -0
- package/dist/chunk-CTED3MTR.cjs +380 -0
- package/dist/{chunk-XGGTQQFH.js → chunk-DZHYSUGY.js} +28 -7
- package/dist/{chunk-OXTLPTO3.js → chunk-EAJ7SYHE.js} +4 -3
- package/dist/{chunk-V2PXZVBF.cjs → chunk-FGEB7RMY.cjs} +4 -4
- package/dist/chunk-GKKDAW44.js +8823 -0
- package/dist/{chunk-2PWNH3UE.js → chunk-H5POPGOZ.js} +63 -5
- package/dist/{chunk-W7IGCOVL.cjs → chunk-JQYC66TO.cjs} +9 -8
- package/dist/{chunk-PFXURMBZ.cjs → chunk-JZLGCTGK.cjs} +68 -8
- package/dist/{chunk-JYOTGRSO.cjs → chunk-KFRDLKMA.cjs} +61 -1
- package/dist/chunk-M4IT6DNJ.cjs +608 -0
- package/dist/{chunk-KLKI352M.cjs → chunk-MVDQMV25.cjs} +0 -3
- package/dist/chunk-NCVX3K2N.cjs +161 -0
- package/dist/chunk-NWFMBLSQ.js +4 -0
- package/dist/chunk-O5676ZWY.js +585 -0
- package/dist/chunk-PUX5VXDB.cjs +8845 -0
- package/dist/{chunk-IXLO7GO5.js → chunk-TWT3STIX.js} +46 -80
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/chunk-VP2B4WM2.js +154 -0
- package/dist/{chunk-5X5WL5CU.cjs → chunk-WJLECC22.cjs} +51 -88
- package/dist/{chunk-WENHUPZC.cjs → chunk-XAYGD4E4.cjs} +9 -8
- package/dist/core/addresses.d.ts +15 -3
- package/dist/core/brands.d.ts +8 -2
- package/dist/core/errors.d.ts +71 -10
- package/dist/core/preflight.d.ts +1 -0
- package/dist/fhe/erc7984-abi.d.ts +1 -0
- package/dist/fhe/index.cjs +34 -13
- package/dist/fhe/index.d.cts +1 -0
- package/dist/fhe/index.d.ts +1 -0
- package/dist/fhe/index.js +19 -6
- package/dist/fhe/mock-erc7984.d.ts +4 -4
- package/dist/fhe/operators.d.ts +160 -3
- package/dist/fhe/react/index.cjs +14 -0
- package/dist/fhe/react/index.d.cts +2 -0
- package/dist/fhe/react/index.d.ts +2 -0
- package/dist/fhe/react/index.js +6 -0
- package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
- package/dist/fhe/react/useIsOperator.d.ts +54 -0
- package/dist/fhe/sepolia-encryptor-web.d.ts +18 -3
- package/dist/fhe/types.d.ts +6 -0
- package/dist/fhe-airdrop/abis/{cloneable.d.ts → airdrop-base.d.ts} +254 -396
- package/dist/fhe-airdrop/abis/compliance.d.ts +422 -0
- package/dist/fhe-airdrop/abis/ecdsa.d.ts +1316 -0
- package/dist/fhe-airdrop/abis/factory.d.ts +1319 -190
- package/dist/fhe-airdrop/abis/index.d.ts +5 -2
- package/dist/fhe-airdrop/abis/merkle.d.ts +1238 -0
- package/dist/fhe-airdrop/advanced/index.cjs +10 -12
- package/dist/fhe-airdrop/advanced/index.d.cts +34 -11
- package/dist/fhe-airdrop/advanced/index.d.ts +34 -11
- package/dist/fhe-airdrop/advanced/index.js +2 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +34 -48
- package/dist/fhe-airdrop/advanced/react/index.d.cts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.d.ts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.js +33 -48
- package/dist/fhe-airdrop/advanced/react/usePredictEcdsaAirdropAddress.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/usePredictMerkleAirdropAddress.d.ts +27 -0
- package/dist/fhe-airdrop/airdrop-base.d.ts +600 -0
- package/dist/fhe-airdrop/campaign.d.ts +297 -0
- package/dist/fhe-airdrop/compliance.d.ts +302 -0
- package/dist/fhe-airdrop/constants.d.ts +33 -0
- package/dist/fhe-airdrop/ecdsa.d.ts +263 -0
- package/dist/fhe-airdrop/encryption.d.ts +92 -14
- package/dist/fhe-airdrop/errors.d.ts +245 -15
- package/dist/fhe-airdrop/factory.d.ts +533 -274
- package/dist/fhe-airdrop/guards.d.ts +273 -0
- package/dist/fhe-airdrop/index.cjs +1089 -33
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +929 -7
- package/dist/fhe-airdrop/merkle-tree.d.ts +103 -0
- package/dist/fhe-airdrop/merkle.d.ts +180 -0
- package/dist/fhe-airdrop/react/_shared.d.ts +144 -71
- package/dist/fhe-airdrop/react/index.cjs +364 -413
- package/dist/fhe-airdrop/react/index.d.cts +53 -72
- package/dist/fhe-airdrop/react/index.d.ts +53 -72
- package/dist/fhe-airdrop/react/index.js +258 -369
- package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +10 -5
- package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +15 -6
- package/dist/fhe-airdrop/react/useAirdropPause.d.ts +30 -0
- package/dist/fhe-airdrop/react/useAirdropPaused.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -4
- package/dist/fhe-airdrop/react/useAirdropWindow.d.ts +37 -0
- package/dist/fhe-airdrop/react/useClaimedAmount.d.ts +29 -0
- package/dist/fhe-airdrop/react/useComplianceManager.d.ts +16 -0
- package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +28 -0
- package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +25 -0
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +23 -0
- package/dist/fhe-airdrop/react/useEffectiveUpgradeable.d.ts +20 -0
- package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +17 -12
- package/dist/fhe-airdrop/react/useFactoryFees.d.ts +28 -0
- package/dist/fhe-airdrop/react/useFactoryRegistry.d.ts +35 -0
- package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +35 -0
- package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +35 -0
- package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +34 -0
- package/dist/fhe-airdrop/react/useMerkleRoot.d.ts +15 -0
- package/dist/fhe-airdrop/react/useSetMerkleRoot.d.ts +22 -0
- package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +23 -0
- package/dist/fhe-airdrop/roles.d.ts +147 -0
- package/dist/fhe-airdrop/types.d.ts +68 -55
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +34 -25
- package/dist/fhe-disperse/index.d.cts +1 -1
- package/dist/fhe-disperse/index.d.ts +1 -1
- package/dist/fhe-disperse/index.js +6 -5
- package/dist/fhe-disperse/react/index.cjs +42 -23
- package/dist/fhe-disperse/react/index.d.cts +3 -1
- package/dist/fhe-disperse/react/index.d.ts +3 -1
- package/dist/fhe-disperse/react/index.js +9 -6
- package/dist/fhe-vesting/advanced/index.cjs +8 -7
- package/dist/fhe-vesting/advanced/index.js +6 -5
- package/dist/fhe-vesting/advanced/react/index.cjs +12 -11
- package/dist/fhe-vesting/advanced/react/index.js +9 -8
- package/dist/fhe-vesting/index.cjs +35 -34
- package/dist/fhe-vesting/index.js +7 -6
- package/dist/fhe-vesting/manager.d.ts +19 -0
- package/dist/fhe-vesting/react/index.cjs +160 -140
- package/dist/fhe-vesting/react/index.d.cts +6 -4
- package/dist/fhe-vesting/react/index.d.ts +6 -4
- package/dist/fhe-vesting/react/index.js +24 -16
- package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
- package/dist/fhe-vesting/types.d.ts +12 -1
- package/dist/index.cjs +27 -15
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/index.cjs +17 -16
- package/dist/testnet-faucet/index.js +5 -4
- package/dist/testnet-faucet/react/index.cjs +11 -10
- package/dist/testnet-faucet/react/index.js +6 -5
- package/package.json +18 -9
- package/dist/chunk-4WPGQSNT.cjs +0 -44
- package/dist/chunk-6R4KNAPK.js +0 -1630
- package/dist/chunk-DUZIIRPF.js +0 -1655
- package/dist/chunk-MCRBVJGZ.cjs +0 -1637
- package/dist/chunk-ODLTEGHB.js +0 -41
- package/dist/chunk-ORFTDNFZ.js +0 -105
- package/dist/chunk-T46YXSBP.cjs +0 -109
- package/dist/chunk-TIUKIY5V.cjs +0 -1663
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +0 -53
- package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +0 -49
- package/dist/fhe-airdrop/airdrop.d.ts +0 -310
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -31
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
- package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +0 -6
- package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +0 -9
- package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +0 -22
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +0 -51
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useClaim.d.ts +0 -31
- package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +0 -11
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +0 -41
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +0 -48
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +0 -29
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +0 -31
- package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +0 -14
- package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +0 -33
- package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +0 -51
- package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +0 -14
- package/dist/fhe-airdrop/react/useSetPaused.d.ts +0 -14
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +0 -31
- package/dist/fhe-airdrop/react/useWithdraw.d.ts +0 -12
- package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +0 -13
- package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
- package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
|
@@ -1,10 +1,932 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { ConfidentialAirdropFactoryClient,
|
|
1
|
+
export { buildMerkleCampaign, buildMerkleTree, encryptCampaignAmounts, grantInstanceRoles, leafOf, planInstanceRoleSplit, planMerkleCampaign, rotateMerkleRoot, validateCampaignRecipients } from '../chunk-456VDDA3.js';
|
|
2
|
+
export { AirdropBaseClient, CLAIM_TYPEHASH, CLAIM_TYPES, ConfidentialAirdropFactoryClient, EIP712_DOMAIN_NAME, EIP712_DOMAIN_VERSION, EcdsaAirdropClient, FACTORY_ROLE_CONCENTRATION_NOTE, MerkleAirdropClient, airdropFactoryAbi, confidentialAirdropBaseAbi, createAirdropBaseClient, createConfidentialAirdropFactoryClient, createEcdsaAirdropClient, createMerkleAirdropClient, ecdsaConfidentialAirdropAbi, encryptUint64, encryptUint64Batch, merkleConfidentialAirdropAbi, resolveEncryptor, signClaimAuthorization } from '../chunk-GKKDAW44.js';
|
|
3
|
+
import { assertSupportedChain, airdropProductMapper } from '../chunk-O5676ZWY.js';
|
|
4
|
+
export { AIRDROP_CONTRACTS_COMMIT, AlreadyClaimedError, ClaimNotStartedError, ClaimWindowClosedError, DEDUP_MODE, DEPLOYMENT_MODE, DedupIdConsumedError, FeeCollectorSelfAdministeredError, MerkleUupsUnsupportedError, NonStockWrapperError, PredictionDriftError, SaltCollisionError, SignatureExpiredError, UpgradeabilityNotAllowedError, preflightClaim, preflightCreate } from '../chunk-O5676ZWY.js';
|
|
5
|
+
export { ERC7984_OPERATOR_MAX_DEADLINE, revokeOperator, setOperator } from '../chunk-4TSDNZQ3.js';
|
|
3
6
|
import '../chunk-ZWXJTBZO.js';
|
|
4
7
|
export { erc7984OperatorAbi } from '../chunk-7VELUOMI.js';
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
9
|
-
|
|
8
|
+
import { SDK_VERSION } from '../chunk-NWFMBLSQ.js';
|
|
9
|
+
import { isContractRevert, mapContractRevert } from '../chunk-4RAAATVY.js';
|
|
10
|
+
import '../chunk-DZHYSUGY.js';
|
|
11
|
+
import { normaliseAddress } from '../chunk-ZA673I3O.js';
|
|
12
|
+
import '../chunk-KWFFIJYX.js';
|
|
13
|
+
import { DeploymentAddressUnavailableError, MissingWalletClientError, MissingAccountError } from '../chunk-QBJ7O2B4.js';
|
|
10
14
|
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';
|
|
15
|
+
import { withTelemetry } from '../chunk-Q2GP5UDC.js';
|
|
16
|
+
|
|
17
|
+
// src/fhe-airdrop/abis/compliance.ts
|
|
18
|
+
var complianceRoleManagerAbi = [
|
|
19
|
+
{
|
|
20
|
+
inputs: [],
|
|
21
|
+
stateMutability: "nonpayable",
|
|
22
|
+
type: "constructor"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
inputs: [],
|
|
26
|
+
name: "AccessControlBadConfirmation",
|
|
27
|
+
type: "error"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
inputs: [
|
|
31
|
+
{
|
|
32
|
+
internalType: "address",
|
|
33
|
+
name: "account",
|
|
34
|
+
type: "address"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
internalType: "bytes32",
|
|
38
|
+
name: "neededRole",
|
|
39
|
+
type: "bytes32"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
name: "AccessControlUnauthorizedAccount",
|
|
43
|
+
type: "error"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
inputs: [
|
|
47
|
+
{
|
|
48
|
+
internalType: "address",
|
|
49
|
+
name: "airdrop",
|
|
50
|
+
type: "address"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
name: "AirdropAndManagerAreSameAddress",
|
|
54
|
+
type: "error"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
inputs: [],
|
|
58
|
+
name: "CannotManageComplianceDelegate",
|
|
59
|
+
type: "error"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
inputs: [],
|
|
63
|
+
name: "DelegateAlreadyAdded",
|
|
64
|
+
type: "error"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
inputs: [
|
|
68
|
+
{
|
|
69
|
+
internalType: "address",
|
|
70
|
+
name: "delegate",
|
|
71
|
+
type: "address"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
name: "DelegateAndAirdropAreSameAddress",
|
|
75
|
+
type: "error"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
inputs: [
|
|
79
|
+
{
|
|
80
|
+
internalType: "address",
|
|
81
|
+
name: "delegate",
|
|
82
|
+
type: "address"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
name: "DelegateAndManagerAreSameAddress",
|
|
86
|
+
type: "error"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
inputs: [],
|
|
90
|
+
name: "DelegateNotFound",
|
|
91
|
+
type: "error"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
inputs: [],
|
|
95
|
+
name: "InvalidInitialization",
|
|
96
|
+
type: "error"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
inputs: [],
|
|
100
|
+
name: "NotInitializing",
|
|
101
|
+
type: "error"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
inputs: [],
|
|
105
|
+
name: "ZamaProtocolUnsupported",
|
|
106
|
+
type: "error"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
inputs: [],
|
|
110
|
+
name: "ZeroAirdrop",
|
|
111
|
+
type: "error"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
inputs: [],
|
|
115
|
+
name: "ZeroClientAdmin",
|
|
116
|
+
type: "error"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
inputs: [],
|
|
120
|
+
name: "ZeroDelegate",
|
|
121
|
+
type: "error"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
anonymous: false,
|
|
125
|
+
inputs: [
|
|
126
|
+
{
|
|
127
|
+
indexed: true,
|
|
128
|
+
internalType: "address",
|
|
129
|
+
name: "delegate",
|
|
130
|
+
type: "address"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
name: "ClientDelegateAdded",
|
|
134
|
+
type: "event"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
anonymous: false,
|
|
138
|
+
inputs: [
|
|
139
|
+
{
|
|
140
|
+
indexed: true,
|
|
141
|
+
internalType: "address",
|
|
142
|
+
name: "delegate",
|
|
143
|
+
type: "address"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
name: "ClientDelegateRevoked",
|
|
147
|
+
type: "event"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
anonymous: false,
|
|
151
|
+
inputs: [
|
|
152
|
+
{
|
|
153
|
+
indexed: true,
|
|
154
|
+
internalType: "address",
|
|
155
|
+
name: "delegate",
|
|
156
|
+
type: "address"
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
name: "ComplianceDelegateSet",
|
|
160
|
+
type: "event"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
anonymous: false,
|
|
164
|
+
inputs: [
|
|
165
|
+
{
|
|
166
|
+
indexed: false,
|
|
167
|
+
internalType: "uint64",
|
|
168
|
+
name: "version",
|
|
169
|
+
type: "uint64"
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
name: "Initialized",
|
|
173
|
+
type: "event"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
anonymous: false,
|
|
177
|
+
inputs: [
|
|
178
|
+
{
|
|
179
|
+
indexed: true,
|
|
180
|
+
internalType: "bytes32",
|
|
181
|
+
name: "role",
|
|
182
|
+
type: "bytes32"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
indexed: true,
|
|
186
|
+
internalType: "bytes32",
|
|
187
|
+
name: "previousAdminRole",
|
|
188
|
+
type: "bytes32"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
indexed: true,
|
|
192
|
+
internalType: "bytes32",
|
|
193
|
+
name: "newAdminRole",
|
|
194
|
+
type: "bytes32"
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
name: "RoleAdminChanged",
|
|
198
|
+
type: "event"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
anonymous: false,
|
|
202
|
+
inputs: [
|
|
203
|
+
{
|
|
204
|
+
indexed: true,
|
|
205
|
+
internalType: "bytes32",
|
|
206
|
+
name: "role",
|
|
207
|
+
type: "bytes32"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
indexed: true,
|
|
211
|
+
internalType: "address",
|
|
212
|
+
name: "account",
|
|
213
|
+
type: "address"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
indexed: true,
|
|
217
|
+
internalType: "address",
|
|
218
|
+
name: "sender",
|
|
219
|
+
type: "address"
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
name: "RoleGranted",
|
|
223
|
+
type: "event"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
anonymous: false,
|
|
227
|
+
inputs: [
|
|
228
|
+
{
|
|
229
|
+
indexed: true,
|
|
230
|
+
internalType: "bytes32",
|
|
231
|
+
name: "role",
|
|
232
|
+
type: "bytes32"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
indexed: true,
|
|
236
|
+
internalType: "address",
|
|
237
|
+
name: "account",
|
|
238
|
+
type: "address"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
indexed: true,
|
|
242
|
+
internalType: "address",
|
|
243
|
+
name: "sender",
|
|
244
|
+
type: "address"
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
name: "RoleRevoked",
|
|
248
|
+
type: "event"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
inputs: [],
|
|
252
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
253
|
+
outputs: [
|
|
254
|
+
{
|
|
255
|
+
internalType: "bytes32",
|
|
256
|
+
name: "",
|
|
257
|
+
type: "bytes32"
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
stateMutability: "view",
|
|
261
|
+
type: "function"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
inputs: [],
|
|
265
|
+
name: "DELEGATION_ADMIN_ROLE",
|
|
266
|
+
outputs: [
|
|
267
|
+
{
|
|
268
|
+
internalType: "bytes32",
|
|
269
|
+
name: "",
|
|
270
|
+
type: "bytes32"
|
|
271
|
+
}
|
|
272
|
+
],
|
|
273
|
+
stateMutability: "view",
|
|
274
|
+
type: "function"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
inputs: [
|
|
278
|
+
{
|
|
279
|
+
internalType: "address",
|
|
280
|
+
name: "delegate",
|
|
281
|
+
type: "address"
|
|
282
|
+
}
|
|
283
|
+
],
|
|
284
|
+
name: "addDelegate",
|
|
285
|
+
outputs: [],
|
|
286
|
+
stateMutability: "nonpayable",
|
|
287
|
+
type: "function"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
inputs: [],
|
|
291
|
+
name: "airdrop",
|
|
292
|
+
outputs: [
|
|
293
|
+
{
|
|
294
|
+
internalType: "address",
|
|
295
|
+
name: "",
|
|
296
|
+
type: "address"
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
stateMutability: "view",
|
|
300
|
+
type: "function"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
inputs: [],
|
|
304
|
+
name: "clientDelegates",
|
|
305
|
+
outputs: [
|
|
306
|
+
{
|
|
307
|
+
internalType: "address[]",
|
|
308
|
+
name: "",
|
|
309
|
+
type: "address[]"
|
|
310
|
+
}
|
|
311
|
+
],
|
|
312
|
+
stateMutability: "view",
|
|
313
|
+
type: "function"
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
inputs: [],
|
|
317
|
+
name: "complianceDelegate",
|
|
318
|
+
outputs: [
|
|
319
|
+
{
|
|
320
|
+
internalType: "address",
|
|
321
|
+
name: "",
|
|
322
|
+
type: "address"
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
stateMutability: "view",
|
|
326
|
+
type: "function"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
inputs: [
|
|
330
|
+
{
|
|
331
|
+
internalType: "bytes32",
|
|
332
|
+
name: "role",
|
|
333
|
+
type: "bytes32"
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
name: "getRoleAdmin",
|
|
337
|
+
outputs: [
|
|
338
|
+
{
|
|
339
|
+
internalType: "bytes32",
|
|
340
|
+
name: "",
|
|
341
|
+
type: "bytes32"
|
|
342
|
+
}
|
|
343
|
+
],
|
|
344
|
+
stateMutability: "view",
|
|
345
|
+
type: "function"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
inputs: [
|
|
349
|
+
{
|
|
350
|
+
internalType: "bytes32",
|
|
351
|
+
name: "role",
|
|
352
|
+
type: "bytes32"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
internalType: "uint256",
|
|
356
|
+
name: "index",
|
|
357
|
+
type: "uint256"
|
|
358
|
+
}
|
|
359
|
+
],
|
|
360
|
+
name: "getRoleMember",
|
|
361
|
+
outputs: [
|
|
362
|
+
{
|
|
363
|
+
internalType: "address",
|
|
364
|
+
name: "",
|
|
365
|
+
type: "address"
|
|
366
|
+
}
|
|
367
|
+
],
|
|
368
|
+
stateMutability: "view",
|
|
369
|
+
type: "function"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
inputs: [
|
|
373
|
+
{
|
|
374
|
+
internalType: "bytes32",
|
|
375
|
+
name: "role",
|
|
376
|
+
type: "bytes32"
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
name: "getRoleMemberCount",
|
|
380
|
+
outputs: [
|
|
381
|
+
{
|
|
382
|
+
internalType: "uint256",
|
|
383
|
+
name: "",
|
|
384
|
+
type: "uint256"
|
|
385
|
+
}
|
|
386
|
+
],
|
|
387
|
+
stateMutability: "view",
|
|
388
|
+
type: "function"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
inputs: [
|
|
392
|
+
{
|
|
393
|
+
internalType: "bytes32",
|
|
394
|
+
name: "role",
|
|
395
|
+
type: "bytes32"
|
|
396
|
+
}
|
|
397
|
+
],
|
|
398
|
+
name: "getRoleMembers",
|
|
399
|
+
outputs: [
|
|
400
|
+
{
|
|
401
|
+
internalType: "address[]",
|
|
402
|
+
name: "",
|
|
403
|
+
type: "address[]"
|
|
404
|
+
}
|
|
405
|
+
],
|
|
406
|
+
stateMutability: "view",
|
|
407
|
+
type: "function"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
inputs: [
|
|
411
|
+
{
|
|
412
|
+
internalType: "bytes32",
|
|
413
|
+
name: "role",
|
|
414
|
+
type: "bytes32"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
internalType: "address",
|
|
418
|
+
name: "account",
|
|
419
|
+
type: "address"
|
|
420
|
+
}
|
|
421
|
+
],
|
|
422
|
+
name: "grantRole",
|
|
423
|
+
outputs: [],
|
|
424
|
+
stateMutability: "nonpayable",
|
|
425
|
+
type: "function"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
inputs: [
|
|
429
|
+
{
|
|
430
|
+
internalType: "bytes32",
|
|
431
|
+
name: "role",
|
|
432
|
+
type: "bytes32"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
internalType: "address",
|
|
436
|
+
name: "account",
|
|
437
|
+
type: "address"
|
|
438
|
+
}
|
|
439
|
+
],
|
|
440
|
+
name: "hasRole",
|
|
441
|
+
outputs: [
|
|
442
|
+
{
|
|
443
|
+
internalType: "bool",
|
|
444
|
+
name: "",
|
|
445
|
+
type: "bool"
|
|
446
|
+
}
|
|
447
|
+
],
|
|
448
|
+
stateMutability: "view",
|
|
449
|
+
type: "function"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
inputs: [
|
|
453
|
+
{
|
|
454
|
+
internalType: "address",
|
|
455
|
+
name: "airdrop_",
|
|
456
|
+
type: "address"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
internalType: "address",
|
|
460
|
+
name: "clientAdmin",
|
|
461
|
+
type: "address"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
internalType: "address",
|
|
465
|
+
name: "clientDelegate",
|
|
466
|
+
type: "address"
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
internalType: "address",
|
|
470
|
+
name: "complianceDelegate_",
|
|
471
|
+
type: "address"
|
|
472
|
+
}
|
|
473
|
+
],
|
|
474
|
+
name: "initialize",
|
|
475
|
+
outputs: [],
|
|
476
|
+
stateMutability: "nonpayable",
|
|
477
|
+
type: "function"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
inputs: [
|
|
481
|
+
{
|
|
482
|
+
internalType: "address",
|
|
483
|
+
name: "delegate",
|
|
484
|
+
type: "address"
|
|
485
|
+
}
|
|
486
|
+
],
|
|
487
|
+
name: "isActiveDelegate",
|
|
488
|
+
outputs: [
|
|
489
|
+
{
|
|
490
|
+
internalType: "bool",
|
|
491
|
+
name: "",
|
|
492
|
+
type: "bool"
|
|
493
|
+
}
|
|
494
|
+
],
|
|
495
|
+
stateMutability: "view",
|
|
496
|
+
type: "function"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
inputs: [
|
|
500
|
+
{
|
|
501
|
+
internalType: "bytes32",
|
|
502
|
+
name: "role",
|
|
503
|
+
type: "bytes32"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
internalType: "address",
|
|
507
|
+
name: "callerConfirmation",
|
|
508
|
+
type: "address"
|
|
509
|
+
}
|
|
510
|
+
],
|
|
511
|
+
name: "renounceRole",
|
|
512
|
+
outputs: [],
|
|
513
|
+
stateMutability: "nonpayable",
|
|
514
|
+
type: "function"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
inputs: [
|
|
518
|
+
{
|
|
519
|
+
internalType: "address",
|
|
520
|
+
name: "delegate",
|
|
521
|
+
type: "address"
|
|
522
|
+
}
|
|
523
|
+
],
|
|
524
|
+
name: "revokeDelegate",
|
|
525
|
+
outputs: [],
|
|
526
|
+
stateMutability: "nonpayable",
|
|
527
|
+
type: "function"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
inputs: [
|
|
531
|
+
{
|
|
532
|
+
internalType: "bytes32",
|
|
533
|
+
name: "role",
|
|
534
|
+
type: "bytes32"
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
internalType: "address",
|
|
538
|
+
name: "account",
|
|
539
|
+
type: "address"
|
|
540
|
+
}
|
|
541
|
+
],
|
|
542
|
+
name: "revokeRole",
|
|
543
|
+
outputs: [],
|
|
544
|
+
stateMutability: "nonpayable",
|
|
545
|
+
type: "function"
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
inputs: [
|
|
549
|
+
{
|
|
550
|
+
internalType: "bytes4",
|
|
551
|
+
name: "interfaceId",
|
|
552
|
+
type: "bytes4"
|
|
553
|
+
}
|
|
554
|
+
],
|
|
555
|
+
name: "supportsInterface",
|
|
556
|
+
outputs: [
|
|
557
|
+
{
|
|
558
|
+
internalType: "bool",
|
|
559
|
+
name: "",
|
|
560
|
+
type: "bool"
|
|
561
|
+
}
|
|
562
|
+
],
|
|
563
|
+
stateMutability: "view",
|
|
564
|
+
type: "function"
|
|
565
|
+
}
|
|
566
|
+
];
|
|
567
|
+
|
|
568
|
+
// src/fhe-airdrop/compliance.ts
|
|
569
|
+
var ACL_PROPAGATION_CODE = "DELEGATION_NOT_PROPAGATED";
|
|
570
|
+
var ACL_PROPAGATION_ERROR_NAME = "DelegationNotPropagatedError";
|
|
571
|
+
var ACL_PROPAGATION_STATUSES = /* @__PURE__ */ new Set([400, 500]);
|
|
572
|
+
function matchesPropagationMessage(message) {
|
|
573
|
+
const lower = message.toLowerCase();
|
|
574
|
+
if (lower.includes("acl check not propagated")) return true;
|
|
575
|
+
return lower.includes("propagat") && lower.includes("gateway");
|
|
576
|
+
}
|
|
577
|
+
function readRecord(value) {
|
|
578
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
579
|
+
}
|
|
580
|
+
function readNumber(obj, key) {
|
|
581
|
+
const value = obj?.[key];
|
|
582
|
+
return typeof value === "number" ? value : void 0;
|
|
583
|
+
}
|
|
584
|
+
function readString(obj, key) {
|
|
585
|
+
const value = obj?.[key];
|
|
586
|
+
return typeof value === "string" ? value : void 0;
|
|
587
|
+
}
|
|
588
|
+
function isAclPropagationError(error) {
|
|
589
|
+
const err = readRecord(error);
|
|
590
|
+
if (!err) return false;
|
|
591
|
+
const cause = readRecord(err["cause"]);
|
|
592
|
+
if (err["code"] === ACL_PROPAGATION_CODE || err["name"] === ACL_PROPAGATION_ERROR_NAME || cause?.["code"] === ACL_PROPAGATION_CODE || cause?.["name"] === ACL_PROPAGATION_ERROR_NAME) {
|
|
593
|
+
return true;
|
|
594
|
+
}
|
|
595
|
+
const status = readNumber(err, "status") ?? readNumber(err, "statusCode") ?? readNumber(cause, "status") ?? readNumber(cause, "statusCode");
|
|
596
|
+
if (status === void 0 || !ACL_PROPAGATION_STATUSES.has(status)) return false;
|
|
597
|
+
const errMessage = readString(err, "message");
|
|
598
|
+
const causeMessage = readString(cause, "message");
|
|
599
|
+
return errMessage !== void 0 && matchesPropagationMessage(errMessage) || causeMessage !== void 0 && matchesPropagationMessage(causeMessage);
|
|
600
|
+
}
|
|
601
|
+
var ComplianceManagerClient = class {
|
|
602
|
+
publicClient;
|
|
603
|
+
walletClient;
|
|
604
|
+
address;
|
|
605
|
+
chainId;
|
|
606
|
+
#telemetry;
|
|
607
|
+
constructor(config) {
|
|
608
|
+
this.publicClient = config.publicClient;
|
|
609
|
+
this.walletClient = config.walletClient;
|
|
610
|
+
const chainId = config.chainId ?? config.publicClient.chain?.id;
|
|
611
|
+
if (chainId === void 0) {
|
|
612
|
+
throw new DeploymentAddressUnavailableError({
|
|
613
|
+
reason: "chain-id-missing",
|
|
614
|
+
product: "fheAirdrop",
|
|
615
|
+
contract: "complianceManager",
|
|
616
|
+
clientLabel: "ComplianceManagerClient"
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
assertSupportedChain(chainId);
|
|
620
|
+
this.chainId = chainId;
|
|
621
|
+
this.address = normaliseAddress(config.address);
|
|
622
|
+
this.#telemetry = config.telemetry;
|
|
623
|
+
this.#telemetry?.event("fhe-airdrop.client.init", {
|
|
624
|
+
surface: "compliance",
|
|
625
|
+
chainId,
|
|
626
|
+
hasWallet: !!this.walletClient,
|
|
627
|
+
sdkVersion: SDK_VERSION
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
// ============================================================
|
|
631
|
+
// CLIENT DELEGATION MGMT
|
|
632
|
+
// ============================================================
|
|
633
|
+
/**
|
|
634
|
+
* Add a client delegate: grants `delegate` permanent (never-expiring)
|
|
635
|
+
* user-decryption delegation over this clone's airdrop. Requires
|
|
636
|
+
* {@link DELEGATION_ADMIN_ROLE}.
|
|
637
|
+
*
|
|
638
|
+
* Effective on-chain immediately; see the class TSDoc for the gateway
|
|
639
|
+
* propagation lag before `delegatedUserDecrypt` catches up.
|
|
640
|
+
*
|
|
641
|
+
* @throws {@link InvalidArgumentError} (`argument: "delegate"`) when `delegate` is the zero address
|
|
642
|
+
* (`ZeroDelegate`), already an active client delegate (`DelegateAlreadyAdded`), or targets the
|
|
643
|
+
* irrevocable platform compliance delegate (`CannotManageComplianceDelegate`).
|
|
644
|
+
* @returns The transaction hash.
|
|
645
|
+
*/
|
|
646
|
+
async addDelegate(args) {
|
|
647
|
+
return withTelemetry(
|
|
648
|
+
this.#telemetry,
|
|
649
|
+
"fhe-airdrop.compliance.addDelegate",
|
|
650
|
+
() => this.#write("addDelegate", [args.delegate], args.account, "addDelegate")
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Revoke a client delegate. Requires {@link DELEGATION_ADMIN_ROLE}.
|
|
655
|
+
*
|
|
656
|
+
* Effective on-chain immediately — but off-chain, gateway-served
|
|
657
|
+
* `delegatedUserDecrypt` calls stop succeeding only once the gateway
|
|
658
|
+
* observes the revocation, which is not instantaneous either. Cannot target
|
|
659
|
+
* the platform compliance delegate, which is irrevocable by construction.
|
|
660
|
+
*
|
|
661
|
+
* **Not in the same block as {@link addDelegate} for the same delegate.**
|
|
662
|
+
* The FHEVM ACL rejects an add and a revoke of one delegate within a single
|
|
663
|
+
* block (`AlreadyDelegatedOrRevokedInSameBlock`), and because that revert
|
|
664
|
+
* comes from the ACL rather than from this contract, it surfaces as an
|
|
665
|
+
* opaque {@link ContractRevertError} with no decodable selector — nothing
|
|
666
|
+
* names the delegate or the cause. Batching an add and a revoke into one
|
|
667
|
+
* multicall, or sending both inside one block, is the way to hit it; wait a
|
|
668
|
+
* block between them. This is the sequencing counterpart to the propagation
|
|
669
|
+
* gotcha on the class TSDoc: that one is the gateway lagging the chain, this
|
|
670
|
+
* one is the chain refusing two conflicting writes at the same height.
|
|
671
|
+
*
|
|
672
|
+
* @throws {@link InvalidArgumentError} (`argument: "delegate"`) when `delegate` is the zero address
|
|
673
|
+
* (`ZeroDelegate`), not currently an active client delegate (`DelegateNotFound`), or targets the
|
|
674
|
+
* irrevocable platform compliance delegate (`CannotManageComplianceDelegate`).
|
|
675
|
+
* @returns The transaction hash.
|
|
676
|
+
*/
|
|
677
|
+
async revokeDelegate(args) {
|
|
678
|
+
return withTelemetry(
|
|
679
|
+
this.#telemetry,
|
|
680
|
+
"fhe-airdrop.compliance.revokeDelegate",
|
|
681
|
+
() => this.#write("revokeDelegate", [args.delegate], args.account, "revokeDelegate")
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
// ============================================================
|
|
685
|
+
// READS
|
|
686
|
+
// ============================================================
|
|
687
|
+
/** The one airdrop instance this clone serves — set once, at `initialize`. */
|
|
688
|
+
async airdrop() {
|
|
689
|
+
return this.#read("airdrop");
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* The platform compliance delegate.
|
|
693
|
+
*
|
|
694
|
+
* @returns The delegate address, or the zero address when this clone was
|
|
695
|
+
* created with the platform compliance policy OFF. Because `initialize`
|
|
696
|
+
* always runs atomically before this client can reach the clone (see the
|
|
697
|
+
* class TSDoc), a zero return never means "not wired yet" — there is no
|
|
698
|
+
* such observable state on this contract. It unambiguously means "no
|
|
699
|
+
* platform delegate for this airdrop."
|
|
700
|
+
*/
|
|
701
|
+
async complianceDelegate() {
|
|
702
|
+
return this.#read("complianceDelegate");
|
|
703
|
+
}
|
|
704
|
+
/** The current set of active client delegates (excludes the platform compliance delegate, if any). */
|
|
705
|
+
async clientDelegates() {
|
|
706
|
+
return this.#read("clientDelegates");
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Authoritative active-delegate check for `delegate` — reads the ACL
|
|
710
|
+
* expiration date directly rather than the contract's `EnumerableSet`
|
|
711
|
+
* mirror, so it reflects the platform compliance delegate too (which never
|
|
712
|
+
* appears in {@link clientDelegates}).
|
|
713
|
+
*
|
|
714
|
+
* On-chain truth only: a `true` result means the delegation is live in the
|
|
715
|
+
* ACL, not that the gateway has caught up with it yet — see the class
|
|
716
|
+
* TSDoc's propagation note.
|
|
717
|
+
*/
|
|
718
|
+
async isActiveDelegate(delegate) {
|
|
719
|
+
return this.#read("isActiveDelegate", [delegate]);
|
|
720
|
+
}
|
|
721
|
+
// Role-constant getters are named for the contract function they read, the
|
|
722
|
+
// same convention every other client in this module follows: one spelling
|
|
723
|
+
// per role, whichever client you happen to be holding.
|
|
724
|
+
/** Gates {@link addDelegate} / {@link revokeDelegate}. */
|
|
725
|
+
async DELEGATION_ADMIN_ROLE() {
|
|
726
|
+
return this.#read("DELEGATION_ADMIN_ROLE");
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* OpenZeppelin's root role (`bytes32(0)`), read from the clone rather than
|
|
730
|
+
* hard-coded. It administers {@link DELEGATION_ADMIN_ROLE}.
|
|
731
|
+
*/
|
|
732
|
+
async DEFAULT_ADMIN_ROLE() {
|
|
733
|
+
return this.#read("DEFAULT_ADMIN_ROLE");
|
|
734
|
+
}
|
|
735
|
+
// ============================================================
|
|
736
|
+
// ROLE ADMINISTRATION
|
|
737
|
+
// ============================================================
|
|
738
|
+
//
|
|
739
|
+
// The clone is `AccessControlEnumerableUpgradeable`, so membership is
|
|
740
|
+
// enumerable as well as checkable. This surface is what makes the delegation
|
|
741
|
+
// verbs above administrable: without it, whoever the factory named at
|
|
742
|
+
// `initialize` is the only account that can ever add a delegate, and there
|
|
743
|
+
// is no way to find out who that is.
|
|
744
|
+
//
|
|
745
|
+
// Unlike an airdrop instance, this contract adds no "never empty" floor of
|
|
746
|
+
// its own - emptying `DEFAULT_ADMIN_ROLE` here permanently freezes the
|
|
747
|
+
// clone's delegate set at whatever it currently holds.
|
|
748
|
+
/**
|
|
749
|
+
* Whether `holder` holds `role`.
|
|
750
|
+
*
|
|
751
|
+
* The role subject is called `holder`, not `account`: on the writes below
|
|
752
|
+
* `account` already means "who sends this transaction", and one key cannot
|
|
753
|
+
* be both.
|
|
754
|
+
*
|
|
755
|
+
* @param args.role A `bytes32` from {@link DELEGATION_ADMIN_ROLE} or {@link DEFAULT_ADMIN_ROLE}.
|
|
756
|
+
*/
|
|
757
|
+
async hasRole(args) {
|
|
758
|
+
return this.#read("hasRole", [args.role, args.holder]);
|
|
759
|
+
}
|
|
760
|
+
/** The role whose holders may {@link grantRole} and {@link revokeRole} `role`. */
|
|
761
|
+
async getRoleAdmin(role) {
|
|
762
|
+
return this.#read("getRoleAdmin", [role]);
|
|
763
|
+
}
|
|
764
|
+
/** How many accounts hold `role`. */
|
|
765
|
+
async getRoleMemberCount(role) {
|
|
766
|
+
return this.#read("getRoleMemberCount", [role]);
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* The `index`-th holder of `role`, in `EnumerableSet` order - which is not
|
|
770
|
+
* stable across grants and revokes. Prefer {@link getRoleMembers}.
|
|
771
|
+
*/
|
|
772
|
+
async getRoleMember(args) {
|
|
773
|
+
return this.#read("getRoleMember", [args.role, args.index]);
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Every account currently holding `role`.
|
|
777
|
+
*
|
|
778
|
+
* With {@link DELEGATION_ADMIN_ROLE} this answers "who may add or revoke a
|
|
779
|
+
* delegate on this clone?" - the administrative counterpart to
|
|
780
|
+
* {@link clientDelegates}, which answers "who may currently decrypt?".
|
|
781
|
+
*/
|
|
782
|
+
async getRoleMembers(role) {
|
|
783
|
+
return this.#read("getRoleMembers", [role]);
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Grant `role` to `holder`. Requires the role's admin role
|
|
787
|
+
* ({@link getRoleAdmin}).
|
|
788
|
+
*
|
|
789
|
+
* This is how a second operator is added to {@link DELEGATION_ADMIN_ROLE} -
|
|
790
|
+
* the delegation verbs themselves are unaffected, the grant only widens who
|
|
791
|
+
* may call them.
|
|
792
|
+
*
|
|
793
|
+
* @returns The transaction hash.
|
|
794
|
+
*/
|
|
795
|
+
async grantRole(args) {
|
|
796
|
+
return withTelemetry(
|
|
797
|
+
this.#telemetry,
|
|
798
|
+
"fhe-airdrop.compliance.grantRole",
|
|
799
|
+
() => this.#write("grantRole", [args.role, args.holder], args.account, "grantRole")
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Revoke `role` from `holder`. Requires the role's admin role.
|
|
804
|
+
*
|
|
805
|
+
* Revoking a delegation admin does **not** revoke the delegations they
|
|
806
|
+
* created: an existing delegate keeps decrypting until
|
|
807
|
+
* {@link revokeDelegate} is called for it explicitly.
|
|
808
|
+
*
|
|
809
|
+
* @returns The transaction hash.
|
|
810
|
+
*/
|
|
811
|
+
async revokeRole(args) {
|
|
812
|
+
return withTelemetry(
|
|
813
|
+
this.#telemetry,
|
|
814
|
+
"fhe-airdrop.compliance.revokeRole",
|
|
815
|
+
() => this.#write("revokeRole", [args.role, args.holder], args.account, "revokeRole")
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Give up `role` yourself.
|
|
820
|
+
*
|
|
821
|
+
* The contract's signature is `renounceRole(role, callerConfirmation)` and
|
|
822
|
+
* it reverts `AccessControlBadConfirmation` unless `callerConfirmation` is
|
|
823
|
+
* the sender, so this method takes no holder and fills the confirmation from
|
|
824
|
+
* the resolved sending account. Renouncing for somebody else is not a call
|
|
825
|
+
* that can succeed; use {@link revokeRole} to remove another account's role.
|
|
826
|
+
*
|
|
827
|
+
* @returns The transaction hash.
|
|
828
|
+
*/
|
|
829
|
+
async renounceRole(args) {
|
|
830
|
+
const method = "renounceRole";
|
|
831
|
+
const wallet = this.#requireWallet(method);
|
|
832
|
+
const account = this.#resolveAccount(wallet, args.account, method);
|
|
833
|
+
return withTelemetry(
|
|
834
|
+
this.#telemetry,
|
|
835
|
+
"fhe-airdrop.compliance.renounceRole",
|
|
836
|
+
() => this.#write(method, [args.role, accountAddress(account)], account, method)
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
// ============================================================
|
|
840
|
+
// INTERNALS (private)
|
|
841
|
+
// ============================================================
|
|
842
|
+
async #write(functionName, args, account, method) {
|
|
843
|
+
const wallet = this.#requireWallet(method);
|
|
844
|
+
const acct = this.#resolveAccount(wallet, account, method);
|
|
845
|
+
await this.#preflightWrite(method, functionName, args, acct);
|
|
846
|
+
try {
|
|
847
|
+
return await wallet.writeContract({
|
|
848
|
+
address: this.address,
|
|
849
|
+
abi: complianceRoleManagerAbi,
|
|
850
|
+
functionName,
|
|
851
|
+
args,
|
|
852
|
+
account: acct,
|
|
853
|
+
chain: wallet.chain
|
|
854
|
+
});
|
|
855
|
+
} catch (err) {
|
|
856
|
+
throw this.#mapRevert(method, err, acct);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
async #read(functionName, args = []) {
|
|
860
|
+
const result = await this.publicClient.readContract({
|
|
861
|
+
address: this.address,
|
|
862
|
+
abi: complianceRoleManagerAbi,
|
|
863
|
+
functionName,
|
|
864
|
+
args
|
|
865
|
+
});
|
|
866
|
+
return result;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Simulate a write purely to surface typed reverts.
|
|
870
|
+
*
|
|
871
|
+
* The simulate's return value is discarded on principle: this contract
|
|
872
|
+
* returns nothing from `addDelegate` / `revokeDelegate` anyway, but the
|
|
873
|
+
* pattern is kept identical to every other airdrop v2 client so a revert is
|
|
874
|
+
* always decoded before the user pays for it.
|
|
875
|
+
*/
|
|
876
|
+
async #preflightWrite(method, functionName, args, account) {
|
|
877
|
+
try {
|
|
878
|
+
await this.publicClient.simulateContract({
|
|
879
|
+
address: this.address,
|
|
880
|
+
abi: complianceRoleManagerAbi,
|
|
881
|
+
functionName,
|
|
882
|
+
args,
|
|
883
|
+
account
|
|
884
|
+
});
|
|
885
|
+
} catch (err) {
|
|
886
|
+
if (isContractRevert(err)) {
|
|
887
|
+
throw this.#mapRevert(method, err, account);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Map a viem error to the SDK's typed palette.
|
|
893
|
+
*
|
|
894
|
+
* `productContext` deliberately carries only public identifiers — the
|
|
895
|
+
* caller, the chain. Never an amount: this contract never handles amounts
|
|
896
|
+
* at all, but the convention is shared across every airdrop v2 client.
|
|
897
|
+
*/
|
|
898
|
+
#mapRevert(method, err, account) {
|
|
899
|
+
return mapContractRevert(err, {
|
|
900
|
+
method,
|
|
901
|
+
contractAddress: this.address,
|
|
902
|
+
abi: complianceRoleManagerAbi,
|
|
903
|
+
productMapper: airdropProductMapper,
|
|
904
|
+
account: accountAddress(account),
|
|
905
|
+
productContext: {
|
|
906
|
+
creator: accountAddress(account),
|
|
907
|
+
chainId: this.chainId
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
#requireWallet(method) {
|
|
912
|
+
if (!this.walletClient) {
|
|
913
|
+
throw new MissingWalletClientError(method);
|
|
914
|
+
}
|
|
915
|
+
return this.walletClient;
|
|
916
|
+
}
|
|
917
|
+
#resolveAccount(wallet, override, method) {
|
|
918
|
+
const acct = override ?? wallet.account;
|
|
919
|
+
if (!acct) {
|
|
920
|
+
throw new MissingAccountError(method);
|
|
921
|
+
}
|
|
922
|
+
return acct;
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
function createComplianceManagerClient(config) {
|
|
926
|
+
return new ComplianceManagerClient(config);
|
|
927
|
+
}
|
|
928
|
+
function accountAddress(account) {
|
|
929
|
+
return typeof account === "string" ? account : account.address;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
export { ComplianceManagerClient, complianceRoleManagerAbi, createComplianceManagerClient, isAclPropagationError };
|