@tokenops/sdk 1.6.0 → 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 +48 -8
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SUPPORT.md +47 -0
- package/dist/{chunk-HETNKZEE.js → chunk-335Z2W67.js} +1 -1
- package/dist/{chunk-BD4LZBVF.cjs → chunk-3QHNYEQD.cjs} +18 -17
- package/dist/chunk-456VDDA3.js +370 -0
- package/dist/{chunk-6WSNS3UV.js → chunk-4RAAATVY.js} +2 -4
- package/dist/{chunk-4KJ66YRH.js → chunk-4TSDNZQ3.js} +2 -2
- package/dist/{chunk-WUXUWTFW.cjs → chunk-5576FRT3.cjs} +31 -7
- package/dist/chunk-66IHPTOK.cjs +20 -0
- package/dist/{chunk-2RNW4MIJ.cjs → chunk-67OV5CX2.cjs} +0 -18
- package/dist/{chunk-PD7ME2BT.js → chunk-6GNR22OV.js} +2 -1
- package/dist/{chunk-VHSNYUYV.js → chunk-6NAVMWZQ.js} +5 -5
- package/dist/{chunk-EUKPOXWR.cjs → chunk-6PXXGACR.cjs} +17 -15
- package/dist/{chunk-WTK6JDSI.js → chunk-74QFZ5MK.js} +6 -4
- package/dist/{chunk-WOEETTH7.cjs → chunk-7AFPOE7N.cjs} +6 -6
- package/dist/{chunk-U57COLUE.js → chunk-AXIPOR3C.js} +2 -2
- package/dist/chunk-CTED3MTR.cjs +380 -0
- package/dist/{chunk-QKKBBH7I.js → chunk-DZHYSUGY.js} +28 -7
- package/dist/{chunk-V5D7BHW3.js → chunk-EAJ7SYHE.js} +6 -4
- package/dist/{chunk-SYHNZSZZ.cjs → chunk-FAXIIH5R.cjs} +3 -3
- package/dist/{chunk-7G7UOQV4.cjs → chunk-FGEB7RMY.cjs} +4 -4
- package/dist/chunk-GKKDAW44.js +8823 -0
- package/dist/{chunk-QET3Q4JP.js → chunk-H5POPGOZ.js} +8 -6
- package/dist/{chunk-VR3FREBX.cjs → chunk-JK4XMMKM.cjs} +3 -3
- package/dist/{chunk-CBRL2PJA.cjs → chunk-JQYC66TO.cjs} +12 -12
- package/dist/{chunk-YFIWCYHC.cjs → chunk-JZLGCTGK.cjs} +56 -54
- package/dist/{chunk-4ZCXK4VI.cjs → chunk-KFRDLKMA.cjs} +14 -14
- package/dist/chunk-KWFFIJYX.js +11 -0
- package/dist/chunk-M4IT6DNJ.cjs +608 -0
- package/dist/{chunk-43RFBQ73.cjs → chunk-MVDQMV25.cjs} +29 -32
- 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-DRSPMIZ7.js → chunk-QBJ7O2B4.js} +1 -11
- package/dist/{chunk-UJS4N2XM.cjs → chunk-TEBM66WA.cjs} +12 -12
- package/dist/{chunk-TN65XNTI.js → chunk-TWT3STIX.js} +8 -6
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/chunk-VP2B4WM2.js +154 -0
- package/dist/{chunk-BK7YIVLK.cjs → chunk-WJLECC22.cjs} +75 -73
- package/dist/{chunk-NFW7AUEX.js → chunk-WMACINXO.js} +1 -1
- package/dist/{chunk-AYGRYDBX.cjs → chunk-XAYGD4E4.cjs} +37 -35
- package/dist/{chunk-46T67CE2.js → chunk-ZA673I3O.js} +1 -1
- package/dist/{chunk-YPYCWLYP.js → chunk-ZWXJTBZO.js} +1 -1
- package/dist/core/addresses.d.ts +14 -2
- 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 +64 -63
- package/dist/fhe/index.js +7 -6
- package/dist/fhe/operators.d.ts +22 -5
- package/dist/fhe/react/index.cjs +13 -12
- package/dist/fhe/react/index.js +6 -5
- 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 +11 -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 +3 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +37 -50
- 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 +36 -50
- 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 +1131 -74
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +931 -8
- 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 +399 -459
- package/dist/fhe-airdrop/react/index.d.cts +53 -74
- package/dist/fhe-airdrop/react/index.d.ts +53 -74
- package/dist/fhe-airdrop/react/index.js +261 -374
- 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 +67 -65
- package/dist/fhe-disperse/index.cjs +70 -68
- package/dist/fhe-disperse/index.js +10 -8
- package/dist/fhe-disperse/react/index.cjs +94 -92
- package/dist/fhe-disperse/react/index.js +13 -11
- package/dist/fhe-vesting/advanced/index.cjs +10 -8
- package/dist/fhe-vesting/advanced/index.js +8 -6
- package/dist/fhe-vesting/advanced/react/index.cjs +16 -14
- package/dist/fhe-vesting/advanced/react/index.js +13 -11
- package/dist/fhe-vesting/index.cjs +74 -72
- package/dist/fhe-vesting/index.js +11 -9
- package/dist/fhe-vesting/react/index.cjs +228 -226
- package/dist/fhe-vesting/react/index.js +15 -13
- package/dist/index.cjs +100 -87
- package/dist/index.js +3 -2
- package/dist/testnet-faucet/index.cjs +57 -55
- package/dist/testnet-faucet/index.js +7 -5
- package/dist/testnet-faucet/react/index.cjs +55 -53
- package/dist/testnet-faucet/react/index.js +9 -7
- package/package.json +6 -2
- package/dist/chunk-CNP4L3GF.js +0 -105
- package/dist/chunk-KSDSXJ34.js +0 -41
- package/dist/chunk-LBWRFZR3.cjs +0 -1681
- package/dist/chunk-OL6SHN3D.cjs +0 -44
- package/dist/chunk-S2XD75JM.js +0 -1637
- package/dist/chunk-SPGSO5SO.cjs +0 -1644
- package/dist/chunk-UE5XK2SY.js +0 -1673
- package/dist/chunk-WO72UBQD.cjs +0 -109
- 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 -317
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -37
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- 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 -39
- 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/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
|
@@ -492,14 +492,4 @@ var TokenOpsContractError = class extends TokenOpsSdkError {
|
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
494
|
|
|
495
|
-
|
|
496
|
-
var asEncryptedHandle = (h) => h;
|
|
497
|
-
var asExternalInputProof = (h) => h;
|
|
498
|
-
var asTxHash = (h) => h;
|
|
499
|
-
var asVestingId = (h) => h;
|
|
500
|
-
var asAirdropId = (h) => h;
|
|
501
|
-
var asDisperseId = (h) => h;
|
|
502
|
-
var asRole = (h) => h;
|
|
503
|
-
var asSignature = (h) => h;
|
|
504
|
-
|
|
505
|
-
export { AccessDeniedError, AlreadyInitializedError, BatchTooLargeError, ContractRevertError, DecryptionFailedError, DeploymentAddressUnavailableError, EncryptionFailedError, FeatureDisabledError, FheHandleNotAllowedError, InsufficientBalanceError, InsufficientFeeError, InsufficientGasFundsError, InvalidArgumentError, InvalidSignatureError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, NetworkError, OPERATOR_NOT_APPROVED_REMEDIATION, OperatorNotApprovedError, PausedError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ReentrancyError, RelayerUnreachableError, SigningFailedError, TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, TransferFailedError, UnknownWriteFailureError, UnsupportedChainError, UserDecryptNotAllowedError, UserRejectedSignatureError, WalletChainMismatchError, WalletRejectedError, asAirdropId, asDisperseId, asEncryptedHandle, asExternalInputProof, asRole, asSignature, asTxHash, asVestingId, isTokenOpsSdkError };
|
|
495
|
+
export { AccessDeniedError, AlreadyInitializedError, BatchTooLargeError, ContractRevertError, DecryptionFailedError, DeploymentAddressUnavailableError, EncryptionFailedError, FeatureDisabledError, FheHandleNotAllowedError, InsufficientBalanceError, InsufficientFeeError, InsufficientGasFundsError, InvalidArgumentError, InvalidSignatureError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, NetworkError, OPERATOR_NOT_APPROVED_REMEDIATION, OperatorNotApprovedError, PausedError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ReentrancyError, RelayerUnreachableError, SigningFailedError, TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, TransferFailedError, UnknownWriteFailureError, UnsupportedChainError, UserDecryptNotAllowedError, UserRejectedSignatureError, WalletChainMismatchError, WalletRejectedError, isTokenOpsSdkError };
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
4
4
|
|
|
5
5
|
// src/core/zama-error-mapper.ts
|
|
6
6
|
function mapZamaError(error, args) {
|
|
7
|
-
if (error instanceof
|
|
7
|
+
if (error instanceof chunk67OV5CX2_cjs.TokenOpsSdkError) return error;
|
|
8
8
|
const zama = readZamaError(error);
|
|
9
9
|
if (zama?.code) {
|
|
10
10
|
switch (zama.code) {
|
|
11
11
|
case "SIGNING_REJECTED":
|
|
12
|
-
return new
|
|
12
|
+
return new chunk67OV5CX2_cjs.UserRejectedSignatureError({ ...args, cause: error });
|
|
13
13
|
case "SIGNING_FAILED":
|
|
14
|
-
return new
|
|
14
|
+
return new chunk67OV5CX2_cjs.SigningFailedError({ ...args, cause: error });
|
|
15
15
|
case "RELAYER_REQUEST_FAILED":
|
|
16
|
-
return new
|
|
16
|
+
return new chunk67OV5CX2_cjs.RelayerUnreachableError({
|
|
17
17
|
...args,
|
|
18
18
|
statusCode: zama.statusCode,
|
|
19
19
|
cause: error
|
|
20
20
|
});
|
|
21
21
|
case "ENCRYPTION_FAILED":
|
|
22
|
-
return new
|
|
22
|
+
return new chunk67OV5CX2_cjs.EncryptionFailedError({ ...args, cause: error });
|
|
23
23
|
case "DECRYPTION_FAILED":
|
|
24
|
-
return new
|
|
24
|
+
return new chunk67OV5CX2_cjs.DecryptionFailedError({ ...args, cause: error });
|
|
25
25
|
case "CONFIGURATION":
|
|
26
|
-
return new
|
|
26
|
+
return new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
27
27
|
method: args.method,
|
|
28
28
|
argument: "config",
|
|
29
29
|
reason: "Zama SDK configuration is invalid (chain id, type, or signer state).",
|
|
@@ -34,13 +34,13 @@ function mapZamaError(error, args) {
|
|
|
34
34
|
const message = readMessage(error);
|
|
35
35
|
if (message) {
|
|
36
36
|
if (USER_REJECTION_PATTERNS.some((pat) => pat.test(message))) {
|
|
37
|
-
return new
|
|
37
|
+
return new chunk67OV5CX2_cjs.UserRejectedSignatureError({ ...args, cause: error });
|
|
38
38
|
}
|
|
39
39
|
if (USER_DECRYPT_NOT_ALLOWED_PATTERNS.some((pat) => pat.test(message))) {
|
|
40
|
-
return new
|
|
40
|
+
return new chunk67OV5CX2_cjs.UserDecryptNotAllowedError({ method: args.method, cause: error });
|
|
41
41
|
}
|
|
42
42
|
if (INVALID_INPUT_PATTERNS.some((pat) => pat.test(message))) {
|
|
43
|
-
return new
|
|
43
|
+
return new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
44
44
|
method: args.method,
|
|
45
45
|
argument: "input",
|
|
46
46
|
reason: "encrypted input value rejected by FHE SDK \u2014 see `error.cause` for details",
|
|
@@ -48,7 +48,7 @@ function mapZamaError(error, args) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
return args.operation === "encrypt" ? new
|
|
51
|
+
return args.operation === "encrypt" ? new chunk67OV5CX2_cjs.EncryptionFailedError({ ...args, cause: error }) : new chunk67OV5CX2_cjs.DecryptionFailedError({ ...args, cause: error });
|
|
52
52
|
}
|
|
53
53
|
function readZamaError(err) {
|
|
54
54
|
if (typeof err !== "object" || err === null) return void 0;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { mapZamaError } from './chunk-
|
|
2
|
-
import { resolveEncryptor, encryptUint64Batch, scaleRatio, encryptUint64 } from './chunk-
|
|
3
|
-
import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-
|
|
1
|
+
import { mapZamaError } from './chunk-WMACINXO.js';
|
|
2
|
+
import { resolveEncryptor, encryptUint64Batch, scaleRatio, encryptUint64 } from './chunk-6GNR22OV.js';
|
|
3
|
+
import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-ZWXJTBZO.js';
|
|
4
4
|
import { erc7984OperatorAbi } from './chunk-7VELUOMI.js';
|
|
5
|
-
import { SDK_VERSION
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { SDK_VERSION } from './chunk-NWFMBLSQ.js';
|
|
6
|
+
import { mapContractRevert, isContractRevert } from './chunk-4RAAATVY.js';
|
|
7
|
+
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
8
|
+
import { asEncryptedHandle, asTxHash } from './chunk-KWFFIJYX.js';
|
|
9
|
+
import { TokenOpsSdkError, PausedError, InsufficientFeeError, AccessDeniedError, InvalidArgumentError, OperatorNotApprovedError, MissingEncryptorError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, MissingWalletClientError, MissingAccountError } from './chunk-QBJ7O2B4.js';
|
|
8
10
|
import { withTelemetry } from './chunk-Q2GP5UDC.js';
|
|
9
11
|
import { parseEventLogs, isAddress, BaseError, ContractFunctionZeroDataError } from 'viem';
|
|
10
12
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createConfidentialAirdropFactoryClient, resolveEncryptor, createAirdropBaseClient, createMerkleAirdropClient, createEcdsaAirdropClient } from './chunk-GKKDAW44.js';
|
|
2
|
+
import { getFheAirdropFactoryAddress } from './chunk-DZHYSUGY.js';
|
|
3
|
+
import { DeploymentAddressUnavailableError } from './chunk-QBJ7O2B4.js';
|
|
4
|
+
import { useRef, useMemo } from 'react';
|
|
5
|
+
import { usePublicClient, useWalletClient } from 'wagmi';
|
|
6
|
+
|
|
7
|
+
var FHE_AIRDROP_KEY = "tokenops-sdk";
|
|
8
|
+
var FHE_AIRDROP_NAMESPACE = "fhe-airdrop";
|
|
9
|
+
function airdropQueryKey(params) {
|
|
10
|
+
return [
|
|
11
|
+
FHE_AIRDROP_KEY,
|
|
12
|
+
FHE_AIRDROP_NAMESPACE,
|
|
13
|
+
params.chainId ?? null,
|
|
14
|
+
params.address ? normalizeKeyArg(params.address) : null,
|
|
15
|
+
params.fn,
|
|
16
|
+
params.args.map(normalizeKeyArg)
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
function airdropQueryKeyPrefix(params) {
|
|
20
|
+
const prefix = [
|
|
21
|
+
FHE_AIRDROP_KEY,
|
|
22
|
+
FHE_AIRDROP_NAMESPACE,
|
|
23
|
+
params.chainId ?? null,
|
|
24
|
+
params.address ? normalizeKeyArg(params.address) : null
|
|
25
|
+
];
|
|
26
|
+
if (params.fn !== void 0) prefix.push(params.fn);
|
|
27
|
+
return prefix;
|
|
28
|
+
}
|
|
29
|
+
function normalizeKeyArg(value) {
|
|
30
|
+
if (typeof value === "bigint") return value.toString();
|
|
31
|
+
if (Array.isArray(value)) return value.map(normalizeKeyArg);
|
|
32
|
+
if (value && typeof value === "object") {
|
|
33
|
+
return Object.fromEntries(
|
|
34
|
+
Object.entries(value).map(([k, v]) => [k, normalizeKeyArg(v)])
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === "string" && value.startsWith("0x")) return value.toLowerCase();
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function tryResolveAirdropFactoryAddress(override, chainId) {
|
|
41
|
+
if (override) return override;
|
|
42
|
+
if (chainId === void 0) return void 0;
|
|
43
|
+
return getFheAirdropFactoryAddress(chainId);
|
|
44
|
+
}
|
|
45
|
+
function computeAirdropFactoryResolutionError(override, chainId) {
|
|
46
|
+
if (override) return void 0;
|
|
47
|
+
if (chainId === void 0) {
|
|
48
|
+
return new DeploymentAddressUnavailableError({
|
|
49
|
+
reason: "chain-id-missing",
|
|
50
|
+
product: "fheAirdrop",
|
|
51
|
+
contract: "airdropFactory",
|
|
52
|
+
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const resolved = getFheAirdropFactoryAddress(chainId);
|
|
56
|
+
if (!resolved) {
|
|
57
|
+
return new DeploymentAddressUnavailableError({
|
|
58
|
+
reason: "registry-not-deployed",
|
|
59
|
+
product: "fheAirdrop",
|
|
60
|
+
contract: "airdropFactory",
|
|
61
|
+
chainId,
|
|
62
|
+
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
function useMemoAirdropFactoryClient(opts = {}) {
|
|
68
|
+
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
69
|
+
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
70
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
71
|
+
const resolvedAddress = tryResolveAirdropFactoryAddress(opts.address, chainId);
|
|
72
|
+
const resolutionError = computeAirdropFactoryResolutionError(opts.address, chainId);
|
|
73
|
+
const encryptorSourceRef = useRef(opts.encryptor);
|
|
74
|
+
encryptorSourceRef.current = opts.encryptor;
|
|
75
|
+
const telemetry = opts.telemetry;
|
|
76
|
+
const client = useMemo(() => {
|
|
77
|
+
if (!publicClient) return void 0;
|
|
78
|
+
if (!resolvedAddress) return void 0;
|
|
79
|
+
return createConfidentialAirdropFactoryClient({
|
|
80
|
+
publicClient,
|
|
81
|
+
...walletClient ? { walletClient } : {},
|
|
82
|
+
address: resolvedAddress,
|
|
83
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
84
|
+
// Lazy — invoked per-encryption inside the headless client.
|
|
85
|
+
encryptor: () => resolveEncryptor(encryptorSourceRef.current),
|
|
86
|
+
...telemetry ? { telemetry } : {}
|
|
87
|
+
});
|
|
88
|
+
}, [publicClient, walletClient, resolvedAddress, chainId, telemetry]);
|
|
89
|
+
return {
|
|
90
|
+
client,
|
|
91
|
+
resolutionError,
|
|
92
|
+
publicClient,
|
|
93
|
+
walletClient: walletClient ?? void 0,
|
|
94
|
+
chainId,
|
|
95
|
+
resolvedAddress
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function useMemoAirdropBaseClient(opts) {
|
|
99
|
+
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
100
|
+
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
101
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
102
|
+
const telemetry = opts.telemetry;
|
|
103
|
+
const client = useMemo(() => {
|
|
104
|
+
if (!publicClient) return void 0;
|
|
105
|
+
if (!opts.address) return void 0;
|
|
106
|
+
return createAirdropBaseClient({
|
|
107
|
+
publicClient,
|
|
108
|
+
...walletClient ? { walletClient } : {},
|
|
109
|
+
address: opts.address,
|
|
110
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
111
|
+
...telemetry ? { telemetry } : {}
|
|
112
|
+
});
|
|
113
|
+
}, [publicClient, walletClient, opts.address, chainId, telemetry]);
|
|
114
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
115
|
+
}
|
|
116
|
+
function useMemoMerkleAirdropClient(opts) {
|
|
117
|
+
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
118
|
+
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
119
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
120
|
+
const telemetry = opts.telemetry;
|
|
121
|
+
const client = useMemo(() => {
|
|
122
|
+
if (!publicClient) return void 0;
|
|
123
|
+
if (!opts.address) return void 0;
|
|
124
|
+
return createMerkleAirdropClient({
|
|
125
|
+
publicClient,
|
|
126
|
+
...walletClient ? { walletClient } : {},
|
|
127
|
+
address: opts.address,
|
|
128
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
129
|
+
...telemetry ? { telemetry } : {}
|
|
130
|
+
});
|
|
131
|
+
}, [publicClient, walletClient, opts.address, chainId, telemetry]);
|
|
132
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
133
|
+
}
|
|
134
|
+
function useMemoEcdsaAirdropClient(opts) {
|
|
135
|
+
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
136
|
+
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
137
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
138
|
+
const telemetry = opts.telemetry;
|
|
139
|
+
const client = useMemo(() => {
|
|
140
|
+
if (!publicClient) return void 0;
|
|
141
|
+
if (!opts.address) return void 0;
|
|
142
|
+
return createEcdsaAirdropClient({
|
|
143
|
+
publicClient,
|
|
144
|
+
...walletClient ? { walletClient } : {},
|
|
145
|
+
address: opts.address,
|
|
146
|
+
dedupMode: opts.dedupMode,
|
|
147
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
148
|
+
...telemetry ? { telemetry } : {}
|
|
149
|
+
});
|
|
150
|
+
}, [publicClient, walletClient, opts.address, opts.dedupMode, chainId, telemetry]);
|
|
151
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { airdropQueryKey, airdropQueryKeyPrefix, useMemoAirdropBaseClient, useMemoAirdropFactoryClient, useMemoEcdsaAirdropClient, useMemoMerkleAirdropClient };
|