@tokenops/sdk 2.0.0-alpha.1 → 2.0.0-alpha.3
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 +67 -2
- package/README.md +14 -8
- package/dist/{chunk-PUX5VXDB.cjs → chunk-4AWQJQXY.cjs} +1415 -69
- package/dist/{chunk-74QFZ5MK.js → chunk-4IB4IY5Y.js} +1 -1
- package/dist/{chunk-DZHYSUGY.js → chunk-6HCT4QIX.js} +12 -5
- package/dist/{chunk-FGEB7RMY.cjs → chunk-6XOAYDC6.cjs} +4 -4
- package/dist/{chunk-XAYGD4E4.cjs → chunk-AHU2HMNE.cjs} +3 -3
- package/dist/{chunk-6NAVMWZQ.js → chunk-BPIVVCSQ.js} +2 -2
- package/dist/{chunk-GKKDAW44.js → chunk-BXX5TETM.js} +1401 -59
- package/dist/{chunk-456VDDA3.js → chunk-GCJFAY4X.js} +78 -25
- package/dist/{chunk-CTED3MTR.cjs → chunk-GKYZQJGP.cjs} +82 -29
- package/dist/{chunk-JZLGCTGK.cjs → chunk-IEKTGJ4J.cjs} +2 -2
- package/dist/{chunk-6PXXGACR.cjs → chunk-JVNJSDQ4.cjs} +2 -2
- package/dist/{chunk-O5676ZWY.js → chunk-LEYYG4RF.js} +232 -6
- package/dist/{chunk-335Z2W67.js → chunk-NGU4JYIR.js} +1 -1
- package/dist/{chunk-5576FRT3.cjs → chunk-PG3WXT3K.cjs} +12 -5
- package/dist/{chunk-H5POPGOZ.js → chunk-PK6Q6J5F.js} +1 -1
- package/dist/chunk-TND5NDV7.cjs +263 -0
- package/dist/chunk-U3TBQRT7.js +253 -0
- package/dist/{chunk-EAJ7SYHE.js → chunk-WRWRA4TN.js} +1 -1
- package/dist/{chunk-JQYC66TO.cjs → chunk-YABHXJNH.cjs} +5 -5
- package/dist/{chunk-M4IT6DNJ.cjs → chunk-YTIYTV4K.cjs} +236 -4
- package/dist/core/addresses.d.ts +4 -4
- package/dist/core/errors.d.ts +1 -1
- package/dist/fhe/types.d.ts +2 -2
- package/dist/fhe-airdrop/abis/airdrop-base.d.ts +19 -0
- package/dist/fhe-airdrop/abis/ecdsa.d.ts +19 -0
- package/dist/fhe-airdrop/abis/factory.d.ts +113 -0
- package/dist/fhe-airdrop/abis/merkle.d.ts +43 -12
- package/dist/fhe-airdrop/advanced/index.cjs +4 -4
- package/dist/fhe-airdrop/advanced/index.js +1 -1
- package/dist/fhe-airdrop/advanced/react/index.cjs +620 -9
- package/dist/fhe-airdrop/advanced/react/index.d.cts +35 -0
- package/dist/fhe-airdrop/advanced/react/index.d.ts +35 -0
- package/dist/fhe-airdrop/advanced/react/index.js +590 -7
- package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +28 -0
- package/dist/fhe-airdrop/advanced/react/useClearUpgradeabilityPolicy.d.ts +26 -0
- package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +26 -0
- package/dist/fhe-airdrop/advanced/react/useEcdsaInitCodeHash.d.ts +30 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +25 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryCompliancePolicy.d.ts +38 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryCustomFee.d.ts +24 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryGrantRole.d.ts +32 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryHasRole.d.ts +27 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryImplementations.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryRenounceRole.d.ts +37 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryRevokeRole.d.ts +37 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryRoleConstants.d.ts +46 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryRoleMembers.d.ts +48 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryUpgradeabilityPolicy.d.ts +39 -0
- package/dist/fhe-airdrop/advanced/react/useMerkleInitCodeHash.d.ts +24 -0
- package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +27 -0
- package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +28 -0
- package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +29 -0
- package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +31 -0
- package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +30 -0
- package/dist/fhe-airdrop/advanced/react/useSetDefaultUpgradeable.d.ts +27 -0
- package/dist/fhe-airdrop/advanced/react/useSetEcdsaImplementation.d.ts +34 -0
- package/dist/fhe-airdrop/advanced/react/useSetFeeCollector.d.ts +27 -0
- package/dist/fhe-airdrop/advanced/react/useSetMaxGasFee.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/useSetMerkleImplementation.d.ts +30 -0
- package/dist/fhe-airdrop/advanced/react/useSetUpgradeabilityPolicy.d.ts +31 -0
- package/dist/fhe-airdrop/airdrop-base.d.ts +55 -8
- package/dist/fhe-airdrop/campaign.d.ts +61 -20
- package/dist/fhe-airdrop/constants.d.ts +9 -1
- package/dist/fhe-airdrop/ecdsa.d.ts +13 -0
- package/dist/fhe-airdrop/errors.d.ts +87 -0
- package/dist/fhe-airdrop/factory.d.ts +62 -22
- package/dist/fhe-airdrop/guards.d.ts +133 -4
- package/dist/fhe-airdrop/index.cjs +86 -971
- package/dist/fhe-airdrop/index.d.cts +4 -4
- package/dist/fhe-airdrop/index.d.ts +4 -4
- package/dist/fhe-airdrop/index.js +8 -927
- package/dist/fhe-airdrop/merkle-tree.d.ts +32 -38
- package/dist/fhe-airdrop/merkle.d.ts +52 -31
- package/dist/fhe-airdrop/react/_shared.d.ts +13 -0
- package/dist/fhe-airdrop/react/index.cjs +997 -87
- package/dist/fhe-airdrop/react/index.d.cts +53 -4
- package/dist/fhe-airdrop/react/index.d.ts +53 -4
- package/dist/fhe-airdrop/react/index.js +887 -27
- package/dist/fhe-airdrop/react/keys.d.ts +98 -0
- package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +26 -0
- package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +27 -0
- package/dist/fhe-airdrop/react/useAddComplianceDelegate.d.ts +37 -0
- package/dist/fhe-airdrop/react/useAdminBatchDiscloseBalanceToParties.d.ts +36 -0
- package/dist/fhe-airdrop/react/useAdminDiscloseBalanceToParty.d.ts +31 -0
- package/dist/fhe-airdrop/react/useAdminGetCurrentBalance.d.ts +27 -0
- package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +49 -0
- package/dist/fhe-airdrop/react/useAirdropDeploymentMode.d.ts +28 -0
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +35 -0
- package/dist/fhe-airdrop/react/useAirdropRenounceRole.d.ts +36 -0
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +33 -0
- package/dist/fhe-airdrop/react/useAirdropRoleAdmin.d.ts +28 -0
- package/dist/fhe-airdrop/react/useAirdropRoleConstants.d.ts +67 -0
- package/dist/fhe-airdrop/react/useAirdropRoleMembers.d.ts +49 -0
- package/dist/fhe-airdrop/react/useAirdropUpgradeToAndCall.d.ts +45 -0
- package/dist/fhe-airdrop/react/useBatchDiscloseHandlesToParty.d.ts +32 -0
- package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +68 -0
- package/dist/fhe-airdrop/react/useComplianceGrantRole.d.ts +32 -0
- package/dist/fhe-airdrop/react/useComplianceHasRole.d.ts +37 -0
- package/dist/fhe-airdrop/react/useComplianceInfo.d.ts +50 -0
- package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +32 -0
- package/dist/fhe-airdrop/react/useComplianceRenounceRole.d.ts +38 -0
- package/dist/fhe-airdrop/react/useComplianceRevokeRole.d.ts +36 -0
- package/dist/fhe-airdrop/react/useComplianceRoleConstants.d.ts +41 -0
- package/dist/fhe-airdrop/react/useComplianceRoleMembers.d.ts +45 -0
- package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +55 -0
- package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +52 -0
- package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +35 -0
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +4 -3
- package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +27 -0
- package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +41 -0
- package/dist/fhe-airdrop/react/useEffectiveDelegateToCompliance.d.ts +26 -0
- package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +59 -0
- package/dist/fhe-airdrop/react/useFactoryFees.d.ts +11 -4
- package/dist/fhe-airdrop/react/useIsActiveDelegate.d.ts +29 -0
- package/dist/fhe-airdrop/react/useIsAirdrop.d.ts +44 -0
- package/dist/fhe-airdrop/react/useIsMerkleRootMutable.d.ts +21 -0
- package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +46 -0
- package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +7 -19
- package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +29 -0
- package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +53 -0
- package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +46 -0
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +67 -0
- package/dist/fhe-airdrop/react/useRefreshComplianceBalance.d.ts +36 -0
- package/dist/fhe-airdrop/react/useRescueERC20.d.ts +30 -0
- package/dist/fhe-airdrop/react/useRescueOtherConfidentialToken.d.ts +34 -0
- package/dist/fhe-airdrop/react/useResolveGasFee.d.ts +30 -0
- package/dist/fhe-airdrop/react/useRevokeComplianceDelegate.d.ts +37 -0
- package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +52 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +42 -0
- package/dist/fhe-airdrop/react/useWithdrawGasFee.d.ts +37 -0
- package/dist/fhe-airdrop/types.d.ts +27 -1
- package/dist/fhe-disperse/index.cjs +21 -21
- package/dist/fhe-disperse/index.js +2 -2
- package/dist/fhe-disperse/react/index.cjs +22 -22
- package/dist/fhe-disperse/react/index.js +3 -3
- package/dist/fhe-vesting/advanced/index.cjs +5 -5
- package/dist/fhe-vesting/advanced/index.js +3 -3
- package/dist/fhe-vesting/advanced/react/index.cjs +7 -7
- package/dist/fhe-vesting/advanced/react/index.js +4 -4
- package/dist/fhe-vesting/index.cjs +8 -8
- package/dist/fhe-vesting/index.js +2 -2
- package/dist/fhe-vesting/react/index.cjs +114 -114
- package/dist/fhe-vesting/react/index.js +3 -3
- package/dist/index.cjs +18 -18
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/index.cjs +14 -14
- package/dist/testnet-faucet/index.js +2 -2
- package/dist/testnet-faucet/react/index.cjs +8 -8
- package/dist/testnet-faucet/react/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-NCVX3K2N.cjs +0 -161
- package/dist/chunk-VP2B4WM2.js +0 -154
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { isContractRevert } from './chunk-4RAAATVY.js';
|
|
2
2
|
import { TokenOpsSdkError, InvalidArgumentError, FeatureDisabledError, UnsupportedChainError, FheHandleNotAllowedError, TransferFailedError, InsufficientBalanceError, InsufficientFeeError, PausedError, InvalidSignatureError, isTokenOpsSdkError } from './chunk-QBJ7O2B4.js';
|
|
3
|
-
import { isAddressEqual, zeroAddress, BaseError, ContractFunctionZeroDataError } from 'viem';
|
|
3
|
+
import { isAddressEqual, zeroAddress, isAddress, BaseError, ContractFunctionZeroDataError } from 'viem';
|
|
4
4
|
|
|
5
5
|
// src/fhe-airdrop/constants.ts
|
|
6
|
-
var AIRDROP_CONTRACTS_COMMIT = "
|
|
6
|
+
var AIRDROP_CONTRACTS_COMMIT = "c5c12c2087f61bcd5bd1daa802563ed3cd68f002";
|
|
7
7
|
var DEPLOYMENT_MODE = { clone: 0, uups: 1 };
|
|
8
8
|
var DEDUP_MODE = { perAddress: 0, perDedupId: 1, both: 2, none: 3 };
|
|
9
|
+
var UINT96_MAX = (1n << 96n) - 1n;
|
|
9
10
|
|
|
10
11
|
// src/fhe-airdrop/errors.ts
|
|
11
12
|
var MerkleUupsUnsupportedError = class extends TokenOpsSdkError {
|
|
@@ -35,6 +36,25 @@ var NonStockWrapperError = class extends TokenOpsSdkError {
|
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
};
|
|
39
|
+
var UnauthorizedRedirectError = class extends TokenOpsSdkError {
|
|
40
|
+
name = "UnauthorizedRedirectError";
|
|
41
|
+
constructor(args) {
|
|
42
|
+
const who = args?.submitter ? ` (submitter: ${args.submitter})` : "";
|
|
43
|
+
super(
|
|
44
|
+
`Only the claim identity may redirect its own payout${who}: \`to\` (${args?.to ?? "unknown"}) differs from \`account\` (${args?.account ?? "unknown"}) and the submitter is not that account. Leave \`to\` unset (or equal to \`account\`) when submitting on someone else's behalf.`,
|
|
45
|
+
{
|
|
46
|
+
code: "TOKENOPS_UNAUTHORIZED_REDIRECT",
|
|
47
|
+
cause: args?.cause,
|
|
48
|
+
context: {
|
|
49
|
+
constraint: "merkle-third-party-redirect",
|
|
50
|
+
account: args?.account,
|
|
51
|
+
to: args?.to,
|
|
52
|
+
submitter: args?.submitter
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
38
58
|
var SaltCollisionError = class extends TokenOpsSdkError {
|
|
39
59
|
name = "SaltCollisionError";
|
|
40
60
|
constructor(args) {
|
|
@@ -184,6 +204,42 @@ var ClaimWindowClosedError = class extends TokenOpsSdkError {
|
|
|
184
204
|
});
|
|
185
205
|
}
|
|
186
206
|
};
|
|
207
|
+
var GasFeeNotAcceptedError = class extends TokenOpsSdkError {
|
|
208
|
+
name = "GasFeeNotAcceptedError";
|
|
209
|
+
constructor(args) {
|
|
210
|
+
const detail = args.resolvedFee !== void 0 && args.maxAcceptedGasFee !== void 0 ? ` The factory resolved ${args.resolvedFee} wei; \`maxAcceptedGasFee\` is ${args.maxAcceptedGasFee} wei.` : "";
|
|
211
|
+
super(
|
|
212
|
+
`${args.method}: the resolved per-claim gas fee exceeds \`common.maxAcceptedGasFee\`.${detail} The fee is frozen into the instance at create and cannot be changed after. Every claimant pays it on every claim, so raise the bound only if that is a fee you accept charging them.`,
|
|
213
|
+
{
|
|
214
|
+
code: "TOKENOPS_GAS_FEE_NOT_ACCEPTED",
|
|
215
|
+
cause: args.cause,
|
|
216
|
+
context: {
|
|
217
|
+
method: args.method,
|
|
218
|
+
contractAddress: args.contractAddress,
|
|
219
|
+
resolvedFee: args.resolvedFee,
|
|
220
|
+
maxAcceptedGasFee: args.maxAcceptedGasFee
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
var UnrecognisedAirdropError = class extends TokenOpsSdkError {
|
|
227
|
+
name = "UnrecognisedAirdropError";
|
|
228
|
+
constructor(args) {
|
|
229
|
+
super(
|
|
230
|
+
`${args.method}: ${args.contractAddress} was not created by the factory at ${args.factory}, so it is not a TokenOps airdrop. Treat its ABI, its events and its pool as unverified.`,
|
|
231
|
+
{
|
|
232
|
+
code: "TOKENOPS_UNRECOGNISED_AIRDROP",
|
|
233
|
+
cause: args.cause,
|
|
234
|
+
context: {
|
|
235
|
+
method: args.method,
|
|
236
|
+
contractAddress: args.contractAddress,
|
|
237
|
+
factory: args.factory
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
187
243
|
var airdropProductMapper = (name, errArgs, ctx) => {
|
|
188
244
|
switch (name) {
|
|
189
245
|
// ---- guarded conditions, caught on-chain instead of pre-flight -------
|
|
@@ -239,6 +295,22 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
239
295
|
});
|
|
240
296
|
case "RootImmutable":
|
|
241
297
|
return new FeatureDisabledError({ ...ctx, feature: "merkleRootRotation" });
|
|
298
|
+
case "ZeroAccount":
|
|
299
|
+
return invalidArg(
|
|
300
|
+
ctx,
|
|
301
|
+
"account",
|
|
302
|
+
name,
|
|
303
|
+
"the claim identity is mandatory and is never defaulted from the caller"
|
|
304
|
+
);
|
|
305
|
+
case "UnauthorizedRedirect": {
|
|
306
|
+
const account = errArgs?.[0];
|
|
307
|
+
const to = errArgs?.[1];
|
|
308
|
+
return new UnauthorizedRedirectError({
|
|
309
|
+
account,
|
|
310
|
+
to,
|
|
311
|
+
submitter: ctx.productContext?.["creator"]
|
|
312
|
+
});
|
|
313
|
+
}
|
|
242
314
|
// ---- FHEVM chain config ---------------------------------------------
|
|
243
315
|
case "ZamaProtocolUnsupported": {
|
|
244
316
|
const chainId = ctx.productContext?.["chainId"] ?? 0;
|
|
@@ -252,6 +324,28 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
252
324
|
}
|
|
253
325
|
// ---- argument-validation bucket: reverts not already covered by the
|
|
254
326
|
// cross-product default mapper's `Zero*`/`Invalid*` list ---------------
|
|
327
|
+
case "GasFeeNotAccepted": {
|
|
328
|
+
const resolvedFee = errArgs?.[0];
|
|
329
|
+
const maxAcceptedGasFee = errArgs?.[1];
|
|
330
|
+
return new GasFeeNotAcceptedError({ ...ctx, resolvedFee, maxAcceptedGasFee });
|
|
331
|
+
}
|
|
332
|
+
case "GasFeeExceedsMaximum": {
|
|
333
|
+
const gasFee = errArgs?.[0];
|
|
334
|
+
const maxGasFee = errArgs?.[1];
|
|
335
|
+
return new InvalidArgumentError({
|
|
336
|
+
method: ctx.method,
|
|
337
|
+
argument: "gasFee",
|
|
338
|
+
reason: `exceeds the factory's own maximum${gasFee !== void 0 && maxGasFee !== void 0 ? ` (${gasFee} wei > ${maxGasFee} wei)` : ""}; \`setMaxGasFee\` is DEFAULT_ADMIN_ROLE-gated and bounds what FEE_MANAGER_ROLE may configure`,
|
|
339
|
+
value: gasFee
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
case "ZeroUnwrapRequestId":
|
|
343
|
+
return invalidArg(
|
|
344
|
+
ctx,
|
|
345
|
+
"token",
|
|
346
|
+
name,
|
|
347
|
+
"the wrapper returned the zero request id, which names no handle to read the delivered amount from; the campaign token is not a conforming ERC7984ERC20Wrapper"
|
|
348
|
+
);
|
|
255
349
|
case "ZeroToken":
|
|
256
350
|
return invalidArg(ctx, "token", name);
|
|
257
351
|
case "ZeroFeeCollector":
|
|
@@ -284,7 +378,7 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
284
378
|
ctx,
|
|
285
379
|
"admin",
|
|
286
380
|
name,
|
|
287
|
-
"revoking or renouncing the sole DEFAULT_ADMIN_ROLE member would leave the
|
|
381
|
+
"revoking or renouncing the sole DEFAULT_ADMIN_ROLE member would leave the contract permanently ungovernable. Declared once and enforced by BOTH the instances and the factory, each on its own admin set (audit-14) - grant a second admin first, then renounce"
|
|
288
382
|
);
|
|
289
383
|
case "LastFeeCollector":
|
|
290
384
|
return invalidArg(
|
|
@@ -443,6 +537,27 @@ async function assertSaltAvailable(args) {
|
|
|
443
537
|
predictedAddress: args.predictedAddress
|
|
444
538
|
});
|
|
445
539
|
}
|
|
540
|
+
function assertMaxAcceptedGasFeeRange(value, method) {
|
|
541
|
+
if (value < 0n || value > UINT96_MAX) {
|
|
542
|
+
throw new InvalidArgumentError({
|
|
543
|
+
method,
|
|
544
|
+
argument: "common.maxAcceptedGasFee",
|
|
545
|
+
reason: `is outside uint96 (0 to ${UINT96_MAX}); the params tuple cannot be ABI-encoded at all`,
|
|
546
|
+
value
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
async function assertGasFeeAccepted(args) {
|
|
551
|
+
assertMaxAcceptedGasFeeRange(args.maxAcceptedGasFee, args.method);
|
|
552
|
+
const resolvedFee = await args.factory.resolveGasFee(args.creator);
|
|
553
|
+
if (resolvedFee <= args.maxAcceptedGasFee) return;
|
|
554
|
+
throw new GasFeeNotAcceptedError({
|
|
555
|
+
method: args.method,
|
|
556
|
+
contractAddress: args.factory.address,
|
|
557
|
+
resolvedFee,
|
|
558
|
+
maxAcceptedGasFee: args.maxAcceptedGasFee
|
|
559
|
+
});
|
|
560
|
+
}
|
|
446
561
|
function assertPredictionFresh(args) {
|
|
447
562
|
if (args.initCodeHashBefore.toLowerCase() === args.initCodeHashAfter.toLowerCase()) return;
|
|
448
563
|
throw new PredictionDriftError({
|
|
@@ -460,6 +575,20 @@ async function preflightCreate(args) {
|
|
|
460
575
|
if (args.variant === "merkle") {
|
|
461
576
|
collect(blockers, () => assertMerkleModeSupported(args.mode));
|
|
462
577
|
}
|
|
578
|
+
const encodable = collect(
|
|
579
|
+
blockers,
|
|
580
|
+
() => assertMaxAcceptedGasFeeRange(args.params.common.maxAcceptedGasFee, method)
|
|
581
|
+
);
|
|
582
|
+
if (!encodable) return { ready: false, blockers };
|
|
583
|
+
await collectAsync(
|
|
584
|
+
blockers,
|
|
585
|
+
() => assertGasFeeAccepted({
|
|
586
|
+
factory: args.factory,
|
|
587
|
+
creator: args.creator,
|
|
588
|
+
maxAcceptedGasFee: args.params.common.maxAcceptedGasFee,
|
|
589
|
+
method
|
|
590
|
+
})
|
|
591
|
+
);
|
|
463
592
|
const predictArgs = {
|
|
464
593
|
mode: args.mode,
|
|
465
594
|
deployer: args.creator,
|
|
@@ -513,18 +642,113 @@ async function preflightCreate(args) {
|
|
|
513
642
|
}
|
|
514
643
|
return { ready: blockers.length === 0, blockers };
|
|
515
644
|
}
|
|
645
|
+
async function assertKnownAirdrop(args) {
|
|
646
|
+
if (args.factory.chainId !== args.chainId) {
|
|
647
|
+
throw new InvalidArgumentError({
|
|
648
|
+
method: args.method,
|
|
649
|
+
argument: "factory",
|
|
650
|
+
reason: `is bound to chain ${args.factory.chainId} but the airdrop is on chain ${args.chainId}; a registry answer from another chain proves nothing about this instance`,
|
|
651
|
+
value: args.factory.address
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
if (await args.factory.isAirdrop(args.airdrop)) return;
|
|
655
|
+
throw new UnrecognisedAirdropError({
|
|
656
|
+
method: args.method,
|
|
657
|
+
contractAddress: args.airdrop,
|
|
658
|
+
factory: args.factory.address
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
function assertMerkleClaimIdentity(args) {
|
|
662
|
+
const { method, account, submitter, boundTo, to, entrypoint = "claim" } = args;
|
|
663
|
+
for (const [argument, value] of [
|
|
664
|
+
["account", account],
|
|
665
|
+
["entry.boundTo", boundTo],
|
|
666
|
+
["to", to],
|
|
667
|
+
["submitter", submitter]
|
|
668
|
+
]) {
|
|
669
|
+
if (value !== void 0 && !isAddress(value, { strict: false })) {
|
|
670
|
+
throw new InvalidArgumentError({
|
|
671
|
+
method,
|
|
672
|
+
argument,
|
|
673
|
+
reason: "is not a 20-byte hex address",
|
|
674
|
+
value
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (isAddressEqual(account, zeroAddress)) {
|
|
679
|
+
throw new InvalidArgumentError({
|
|
680
|
+
method,
|
|
681
|
+
argument: "account",
|
|
682
|
+
reason: "is the zero address; the claim identity is mandatory and is never defaulted from the caller"
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
if (boundTo !== void 0 && !isAddressEqual(boundTo, submitter)) {
|
|
686
|
+
throw new InvalidArgumentError({
|
|
687
|
+
method,
|
|
688
|
+
argument: "entry.boundTo",
|
|
689
|
+
reason: `is ${boundTo}, but this transaction is sent from ${submitter}; the FHE input proof is bound to the sender, so only ${boundTo} can submit this entry`
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
if (entrypoint === "claimAndUnwrap") {
|
|
693
|
+
if (!isAddressEqual(account, submitter)) {
|
|
694
|
+
throw new InvalidArgumentError({
|
|
695
|
+
method,
|
|
696
|
+
argument: "entry.account",
|
|
697
|
+
reason: `is ${account}, but \`claimAndUnwrap\` is always submitted for the caller (${submitter}); use \`claim\` to settle on someone else's behalf`
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
const beneficiary = to === void 0 || isAddressEqual(to, zeroAddress) ? account : to;
|
|
703
|
+
if (!isAddressEqual(beneficiary, account) && !isAddressEqual(submitter, account)) {
|
|
704
|
+
throw new UnauthorizedRedirectError({ account, to: beneficiary, submitter });
|
|
705
|
+
}
|
|
706
|
+
}
|
|
516
707
|
async function preflightClaim(args) {
|
|
517
708
|
const { airdrop, claimant } = args;
|
|
518
709
|
const method = "preflightClaim";
|
|
519
710
|
const blockers = [];
|
|
520
711
|
collect(blockers, () => assertSupportedChain(airdrop.chainId));
|
|
521
|
-
|
|
712
|
+
if (args.factory) {
|
|
713
|
+
await collectAsync(
|
|
714
|
+
blockers,
|
|
715
|
+
() => assertKnownAirdrop({
|
|
716
|
+
factory: args.factory,
|
|
717
|
+
airdrop: airdrop.address,
|
|
718
|
+
chainId: airdrop.chainId,
|
|
719
|
+
method
|
|
720
|
+
})
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
if (args.account !== void 0 || args.entrypoint !== void 0) {
|
|
724
|
+
collect(
|
|
725
|
+
blockers,
|
|
726
|
+
() => assertMerkleClaimIdentity({
|
|
727
|
+
method,
|
|
728
|
+
account: args.account ?? claimant,
|
|
729
|
+
submitter: claimant,
|
|
730
|
+
to: args.to,
|
|
731
|
+
entrypoint: args.entrypoint
|
|
732
|
+
})
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
const [started, ended, paused, fee, balance, unwrappable] = await Promise.all([
|
|
522
736
|
airdrop.hasClaimStarted(),
|
|
523
737
|
airdrop.hasClaimEnded(),
|
|
524
738
|
airdrop.paused(),
|
|
525
739
|
airdrop.gasFee(),
|
|
526
|
-
airdrop.publicClient.getBalance({ address: claimant })
|
|
740
|
+
airdrop.publicClient.getBalance({ address: claimant }),
|
|
741
|
+
args.entrypoint === "claimAndUnwrap" && airdrop.unwrappable ? airdrop.unwrappable() : Promise.resolve(true)
|
|
527
742
|
]);
|
|
743
|
+
if (!unwrappable) {
|
|
744
|
+
blockers.push(
|
|
745
|
+
new FeatureDisabledError({
|
|
746
|
+
method,
|
|
747
|
+
contractAddress: airdrop.address,
|
|
748
|
+
feature: "claimAndUnwrap"
|
|
749
|
+
})
|
|
750
|
+
);
|
|
751
|
+
}
|
|
528
752
|
if (paused) {
|
|
529
753
|
blockers.push(new PausedError({ method, contractAddress: airdrop.address }));
|
|
530
754
|
}
|
|
@@ -568,9 +792,11 @@ async function preflightClaim(args) {
|
|
|
568
792
|
function collect(blockers, run) {
|
|
569
793
|
try {
|
|
570
794
|
run();
|
|
795
|
+
return true;
|
|
571
796
|
} catch (err) {
|
|
572
797
|
if (!isTokenOpsSdkError(err)) throw err;
|
|
573
798
|
blockers.push(err);
|
|
799
|
+
return false;
|
|
574
800
|
}
|
|
575
801
|
}
|
|
576
802
|
async function collectAsync(blockers, run) {
|
|
@@ -582,4 +808,4 @@ async function collectAsync(blockers, run) {
|
|
|
582
808
|
}
|
|
583
809
|
}
|
|
584
810
|
|
|
585
|
-
export { AIRDROP_CONTRACTS_COMMIT, AlreadyClaimedError, ClaimNotStartedError, ClaimWindowClosedError, DEDUP_MODE, DEPLOYMENT_MODE, DedupIdConsumedError, FeeCollectorSelfAdministeredError, MerkleUupsUnsupportedError, NonStockWrapperError, PredictionDriftError, SaltCollisionError, SignatureExpiredError, UpgradeabilityNotAllowedError, airdropProductMapper, assertMerkleModeSupported, assertPredictionFresh, assertSaltAvailable, assertStockWrapper, assertSupportedChain, preflightClaim, preflightCreate };
|
|
811
|
+
export { AIRDROP_CONTRACTS_COMMIT, AlreadyClaimedError, ClaimNotStartedError, ClaimWindowClosedError, DEDUP_MODE, DEPLOYMENT_MODE, DedupIdConsumedError, FeeCollectorSelfAdministeredError, GasFeeNotAcceptedError, MerkleUupsUnsupportedError, NonStockWrapperError, PredictionDriftError, SaltCollisionError, SignatureExpiredError, UINT96_MAX, UnauthorizedRedirectError, UnrecognisedAirdropError, UpgradeabilityNotAllowedError, airdropProductMapper, assertGasFeeAccepted, assertMerkleClaimIdentity, assertMerkleModeSupported, assertPredictionFresh, assertSaltAvailable, assertStockWrapper, assertSupportedChain, preflightClaim, preflightCreate };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfidentialVestingFactoryClient, confidentialVestingFactoryAbi } from './chunk-
|
|
1
|
+
import { ConfidentialVestingFactoryClient, confidentialVestingFactoryAbi } from './chunk-WRWRA4TN.js';
|
|
2
2
|
|
|
3
3
|
// src/fhe-vesting/advanced/factory-advanced.ts
|
|
4
4
|
var ConfidentialVestingFactoryAdvancedClient = class extends ConfidentialVestingFactoryClient {
|
|
@@ -10,22 +10,29 @@ var DEPLOYED_ADDRESSES = {
|
|
|
10
10
|
// mainnet omitted — not deployed.
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
|
-
// Airdrop v2 (tokenops-fhe-airdrop-v2 @
|
|
13
|
+
// Airdrop v2 (tokenops-fhe-airdrop-v2 @ c5c12c2). The four contracts deploy
|
|
14
14
|
// together in one scripted run, so a chain either has all of them or none —
|
|
15
15
|
// which is what `chainsWithDeployment` assumes.
|
|
16
|
+
//
|
|
17
|
+
// Every address moved again at c5c12c2. The internal-audit round changed the
|
|
18
|
+
// factory and all three implementations, and CREATE3 returns a consumed salt's
|
|
19
|
+
// EXISTING address without comparing codehashes - so the run bumps the canonical
|
|
20
|
+
// salt version (2.0.0 → 2.0.2) rather than redeploying over itself. A campaign
|
|
21
|
+
// planned against the previous factory therefore predicts an address the new
|
|
22
|
+
// factory will never produce; `PredictionDriftError` is what catches that.
|
|
16
23
|
fheAirdrop: {
|
|
17
24
|
airdropFactory: {
|
|
18
|
-
[chains.sepolia.id]: "
|
|
25
|
+
[chains.sepolia.id]: "0xA10ff713cfeE5348313Cda0B2CA1b190A1194cab"
|
|
19
26
|
// mainnet omitted — ZamaConfig-gated, not deployed.
|
|
20
27
|
},
|
|
21
28
|
ecdsaImplementation: {
|
|
22
|
-
[chains.sepolia.id]: "
|
|
29
|
+
[chains.sepolia.id]: "0x8d4E8F379f73D5488a76B6C3CC8a2fD489936BDe"
|
|
23
30
|
},
|
|
24
31
|
merkleImplementation: {
|
|
25
|
-
[chains.sepolia.id]: "
|
|
32
|
+
[chains.sepolia.id]: "0x4B4F43Ed9aB3F9D10468b59C03d14f55A9d4E82F"
|
|
26
33
|
},
|
|
27
34
|
complianceManagerImplementation: {
|
|
28
|
-
[chains.sepolia.id]: "
|
|
35
|
+
[chains.sepolia.id]: "0x14bdE71e6b32b50dF1a5Dca1bccD150a319168e2"
|
|
29
36
|
}
|
|
30
37
|
},
|
|
31
38
|
fheDisperse: {
|
|
@@ -2,7 +2,7 @@ import { mapZamaError } from './chunk-WMACINXO.js';
|
|
|
2
2
|
import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-ZWXJTBZO.js';
|
|
3
3
|
import { SDK_VERSION } from './chunk-NWFMBLSQ.js';
|
|
4
4
|
import { isContractRevert, mapContractRevert } from './chunk-4RAAATVY.js';
|
|
5
|
-
import { getFheDisperseSingletonAddress } from './chunk-
|
|
5
|
+
import { getFheDisperseSingletonAddress } from './chunk-6HCT4QIX.js';
|
|
6
6
|
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
7
7
|
import { asExternalInputProof, asEncryptedHandle } from './chunk-KWFFIJYX.js';
|
|
8
8
|
import { InvalidArgumentError, TokenOpsSdkError, DeploymentAddressUnavailableError, PausedError, InsufficientFeeError, MissingEncryptorError, ReceiptEventAmbiguousError, MissingWalletClientError, MissingAccountError, BatchTooLargeError } from './chunk-QBJ7O2B4.js';
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk4AWQJQXY_cjs = require('./chunk-4AWQJQXY.cjs');
|
|
4
|
+
var chunkPG3WXT3K_cjs = require('./chunk-PG3WXT3K.cjs');
|
|
5
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var wagmi = require('wagmi');
|
|
8
|
+
|
|
9
|
+
var FHE_AIRDROP_KEY = "tokenops-sdk";
|
|
10
|
+
var FHE_AIRDROP_NAMESPACE = "fhe-airdrop";
|
|
11
|
+
function airdropQueryKey(params) {
|
|
12
|
+
return [
|
|
13
|
+
FHE_AIRDROP_KEY,
|
|
14
|
+
FHE_AIRDROP_NAMESPACE,
|
|
15
|
+
params.chainId ?? null,
|
|
16
|
+
params.address ? normalizeKeyArg(params.address) : null,
|
|
17
|
+
params.fn,
|
|
18
|
+
params.args.map(normalizeKeyArg)
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
function airdropQueryKeyPrefix(params) {
|
|
22
|
+
const prefix = [
|
|
23
|
+
FHE_AIRDROP_KEY,
|
|
24
|
+
FHE_AIRDROP_NAMESPACE,
|
|
25
|
+
params.chainId ?? null,
|
|
26
|
+
params.address ? normalizeKeyArg(params.address) : null
|
|
27
|
+
];
|
|
28
|
+
if (params.fn !== void 0) prefix.push(params.fn);
|
|
29
|
+
return prefix;
|
|
30
|
+
}
|
|
31
|
+
function normalizeKeyArg(value) {
|
|
32
|
+
if (typeof value === "bigint") return value.toString();
|
|
33
|
+
if (Array.isArray(value)) return value.map(normalizeKeyArg);
|
|
34
|
+
if (value && typeof value === "object") {
|
|
35
|
+
return Object.fromEntries(
|
|
36
|
+
Object.entries(value).map(([k, v]) => [k, normalizeKeyArg(v)])
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (typeof value === "string" && value.startsWith("0x")) return value.toLowerCase();
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
function tryResolveAirdropFactoryAddress(override, chainId) {
|
|
43
|
+
if (override) return override;
|
|
44
|
+
if (chainId === void 0) return void 0;
|
|
45
|
+
return chunkPG3WXT3K_cjs.getFheAirdropFactoryAddress(chainId);
|
|
46
|
+
}
|
|
47
|
+
function computeAirdropFactoryResolutionError(override, chainId) {
|
|
48
|
+
if (override) return void 0;
|
|
49
|
+
if (chainId === void 0) {
|
|
50
|
+
return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
51
|
+
reason: "chain-id-missing",
|
|
52
|
+
product: "fheAirdrop",
|
|
53
|
+
contract: "airdropFactory",
|
|
54
|
+
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const resolved = chunkPG3WXT3K_cjs.getFheAirdropFactoryAddress(chainId);
|
|
58
|
+
if (!resolved) {
|
|
59
|
+
return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
60
|
+
reason: "registry-not-deployed",
|
|
61
|
+
product: "fheAirdrop",
|
|
62
|
+
contract: "airdropFactory",
|
|
63
|
+
chainId,
|
|
64
|
+
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
function useMemoAirdropFactoryClient(opts = {}) {
|
|
70
|
+
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
71
|
+
const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
|
|
72
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
73
|
+
const resolvedAddress = tryResolveAirdropFactoryAddress(opts.address, chainId);
|
|
74
|
+
const resolutionError = computeAirdropFactoryResolutionError(opts.address, chainId);
|
|
75
|
+
const encryptorSourceRef = react.useRef(opts.encryptor);
|
|
76
|
+
encryptorSourceRef.current = opts.encryptor;
|
|
77
|
+
const telemetry = opts.telemetry;
|
|
78
|
+
const client = react.useMemo(() => {
|
|
79
|
+
if (!publicClient) return void 0;
|
|
80
|
+
if (!resolvedAddress) return void 0;
|
|
81
|
+
return chunk4AWQJQXY_cjs.createConfidentialAirdropFactoryClient({
|
|
82
|
+
publicClient,
|
|
83
|
+
...walletClient ? { walletClient } : {},
|
|
84
|
+
address: resolvedAddress,
|
|
85
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
86
|
+
// Lazy — invoked per-encryption inside the headless client.
|
|
87
|
+
encryptor: () => chunk4AWQJQXY_cjs.resolveEncryptor(encryptorSourceRef.current),
|
|
88
|
+
...telemetry ? { telemetry } : {}
|
|
89
|
+
});
|
|
90
|
+
}, [publicClient, walletClient, resolvedAddress, chainId, telemetry]);
|
|
91
|
+
return {
|
|
92
|
+
client,
|
|
93
|
+
resolutionError,
|
|
94
|
+
publicClient,
|
|
95
|
+
walletClient: walletClient ?? void 0,
|
|
96
|
+
chainId,
|
|
97
|
+
resolvedAddress
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function useMemoAirdropBaseClient(opts) {
|
|
101
|
+
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
102
|
+
const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
|
|
103
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
104
|
+
const telemetry = opts.telemetry;
|
|
105
|
+
const client = react.useMemo(() => {
|
|
106
|
+
if (!publicClient) return void 0;
|
|
107
|
+
if (!opts.address) return void 0;
|
|
108
|
+
return chunk4AWQJQXY_cjs.createAirdropBaseClient({
|
|
109
|
+
publicClient,
|
|
110
|
+
...walletClient ? { walletClient } : {},
|
|
111
|
+
address: opts.address,
|
|
112
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
113
|
+
...telemetry ? { telemetry } : {}
|
|
114
|
+
});
|
|
115
|
+
}, [publicClient, walletClient, opts.address, chainId, telemetry]);
|
|
116
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
117
|
+
}
|
|
118
|
+
function useMemoMerkleAirdropClient(opts) {
|
|
119
|
+
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
120
|
+
const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
|
|
121
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
122
|
+
const telemetry = opts.telemetry;
|
|
123
|
+
const client = react.useMemo(() => {
|
|
124
|
+
if (!publicClient) return void 0;
|
|
125
|
+
if (!opts.address) return void 0;
|
|
126
|
+
return chunk4AWQJQXY_cjs.createMerkleAirdropClient({
|
|
127
|
+
publicClient,
|
|
128
|
+
...walletClient ? { walletClient } : {},
|
|
129
|
+
address: opts.address,
|
|
130
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
131
|
+
...telemetry ? { telemetry } : {}
|
|
132
|
+
});
|
|
133
|
+
}, [publicClient, walletClient, opts.address, chainId, telemetry]);
|
|
134
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
135
|
+
}
|
|
136
|
+
function useMemoComplianceManagerClient(opts) {
|
|
137
|
+
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
138
|
+
const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
|
|
139
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
140
|
+
const telemetry = opts.telemetry;
|
|
141
|
+
const client = react.useMemo(() => {
|
|
142
|
+
if (!publicClient) return void 0;
|
|
143
|
+
if (!opts.address) return void 0;
|
|
144
|
+
return chunk4AWQJQXY_cjs.createComplianceManagerClient({
|
|
145
|
+
publicClient,
|
|
146
|
+
...walletClient ? { walletClient } : {},
|
|
147
|
+
address: opts.address,
|
|
148
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
149
|
+
...telemetry ? { telemetry } : {}
|
|
150
|
+
});
|
|
151
|
+
}, [publicClient, walletClient, opts.address, chainId, telemetry]);
|
|
152
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
153
|
+
}
|
|
154
|
+
function useMemoEcdsaAirdropClient(opts) {
|
|
155
|
+
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
156
|
+
const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
|
|
157
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
158
|
+
const telemetry = opts.telemetry;
|
|
159
|
+
const client = react.useMemo(() => {
|
|
160
|
+
if (!publicClient) return void 0;
|
|
161
|
+
if (!opts.address) return void 0;
|
|
162
|
+
return chunk4AWQJQXY_cjs.createEcdsaAirdropClient({
|
|
163
|
+
publicClient,
|
|
164
|
+
...walletClient ? { walletClient } : {},
|
|
165
|
+
address: opts.address,
|
|
166
|
+
dedupMode: opts.dedupMode,
|
|
167
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
168
|
+
...telemetry ? { telemetry } : {}
|
|
169
|
+
});
|
|
170
|
+
}, [publicClient, walletClient, opts.address, opts.dedupMode, chainId, telemetry]);
|
|
171
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/fhe-airdrop/react/keys.ts
|
|
175
|
+
var AIRDROP_FN = {
|
|
176
|
+
// instance reads
|
|
177
|
+
claimedAmount: "getClaimedAmount",
|
|
178
|
+
paused: "paused",
|
|
179
|
+
window: "window",
|
|
180
|
+
config: "config",
|
|
181
|
+
merkleRoot: "merkleRoot",
|
|
182
|
+
merkleRootMutable: "isMerkleRootMutable",
|
|
183
|
+
hasRole: "hasRole",
|
|
184
|
+
roleMembers: "roleMembers",
|
|
185
|
+
gasFee: "gasFee",
|
|
186
|
+
preflightCreate: "preflightCreate",
|
|
187
|
+
isSignatureValid: "isSignatureValid",
|
|
188
|
+
// factory reads
|
|
189
|
+
fees: "fees",
|
|
190
|
+
registry: "registry",
|
|
191
|
+
isAirdrop: "isAirdrop",
|
|
192
|
+
resolvedGasFee: "resolvedGasFee",
|
|
193
|
+
customFee: "customFee",
|
|
194
|
+
implementations: "implementations",
|
|
195
|
+
compliancePolicy: "compliancePolicy",
|
|
196
|
+
upgradeabilityPolicy: "upgradeabilityPolicy",
|
|
197
|
+
factoryHasRole: "factoryHasRole",
|
|
198
|
+
factoryRoleMembers: "factoryRoleMembers",
|
|
199
|
+
// compliance-manager reads
|
|
200
|
+
complianceInfo: "complianceInfo",
|
|
201
|
+
activeDelegate: "isActiveDelegate",
|
|
202
|
+
clientDelegates: "clientDelegates",
|
|
203
|
+
complianceHasRole: "complianceHasRole",
|
|
204
|
+
complianceRoleMembers: "complianceRoleMembers"
|
|
205
|
+
};
|
|
206
|
+
var airdropKeys = {
|
|
207
|
+
/** One account's cumulative delivered total. Keyed on the CLAIM IDENTITY, never the sender. */
|
|
208
|
+
claimedAmount: (s, account) => airdropQueryKey({ ...s, fn: AIRDROP_FN.claimedAmount, args: [account] }),
|
|
209
|
+
paused: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.paused, args: [] }),
|
|
210
|
+
window: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.window, args: [] }),
|
|
211
|
+
config: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.config, args: [] }),
|
|
212
|
+
gasFee: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.gasFee, args: [] }),
|
|
213
|
+
merkleRoot: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.merkleRoot, args: [] }),
|
|
214
|
+
merkleRootMutable: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.merkleRootMutable, args: [] }),
|
|
215
|
+
hasRole: (s, role, holder) => airdropQueryKey({ ...s, fn: AIRDROP_FN.hasRole, args: [role, holder] }),
|
|
216
|
+
/** Every cached `hasRole` for this instance, whatever role/holder pair was queried. */
|
|
217
|
+
hasRoleAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.hasRole }),
|
|
218
|
+
roleMembers: (s, role) => airdropQueryKey({ ...s, fn: AIRDROP_FN.roleMembers, args: [role] }),
|
|
219
|
+
roleMembersAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.roleMembers }),
|
|
220
|
+
/** Every cached create-preflight, whatever params/mode/salt combination was queried. */
|
|
221
|
+
preflightCreateAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.preflightCreate }),
|
|
222
|
+
/** Every cached signature check on this instance; a claim consumes a digest and flips it. */
|
|
223
|
+
isSignatureValidAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.isSignatureValid }),
|
|
224
|
+
fees: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.fees, args: [] }),
|
|
225
|
+
customFee: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.customFee, args: [creator] }),
|
|
226
|
+
customFeeAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.customFee }),
|
|
227
|
+
resolvedGasFee: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.resolvedGasFee, args: [creator] }),
|
|
228
|
+
/** Every creator's resolved fee; the default and any override both move it. */
|
|
229
|
+
resolvedGasFeeAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.resolvedGasFee }),
|
|
230
|
+
/** Every registry page, whatever offset/limit was queried. */
|
|
231
|
+
registryAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.registry }),
|
|
232
|
+
isAirdrop: (s, candidate) => airdropQueryKey({ ...s, fn: AIRDROP_FN.isAirdrop, args: [candidate] }),
|
|
233
|
+
/** Every genuineness answer from this factory; a create adds one address. */
|
|
234
|
+
isAirdropAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.isAirdrop }),
|
|
235
|
+
implementations: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.implementations, args: [] }),
|
|
236
|
+
compliancePolicy: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.compliancePolicy, args: [creator] }),
|
|
237
|
+
compliancePolicyAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.compliancePolicy }),
|
|
238
|
+
upgradeabilityPolicy: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.upgradeabilityPolicy, args: [creator] }),
|
|
239
|
+
upgradeabilityPolicyAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.upgradeabilityPolicy }),
|
|
240
|
+
factoryHasRole: (s, role, holder) => airdropQueryKey({ ...s, fn: AIRDROP_FN.factoryHasRole, args: [role, holder] }),
|
|
241
|
+
factoryHasRoleAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.factoryHasRole }),
|
|
242
|
+
factoryRoleMembers: (s, role) => airdropQueryKey({ ...s, fn: AIRDROP_FN.factoryRoleMembers, args: [role] }),
|
|
243
|
+
factoryRoleMembersAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.factoryRoleMembers }),
|
|
244
|
+
complianceInfo: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceInfo, args: [] }),
|
|
245
|
+
activeDelegate: (s, delegate) => airdropQueryKey({ ...s, fn: AIRDROP_FN.activeDelegate, args: [delegate] }),
|
|
246
|
+
activeDelegateAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.activeDelegate }),
|
|
247
|
+
clientDelegates: (s, index) => airdropQueryKey({ ...s, fn: AIRDROP_FN.clientDelegates, args: [index] }),
|
|
248
|
+
clientDelegatesAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.clientDelegates }),
|
|
249
|
+
complianceHasRole: (s, role, holder) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceHasRole, args: [role, holder] }),
|
|
250
|
+
complianceHasRoleAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.complianceHasRole }),
|
|
251
|
+
complianceRoleMembers: (s, role) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceRoleMembers, args: [role] }),
|
|
252
|
+
complianceRoleMembersAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.complianceRoleMembers })
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
exports.AIRDROP_FN = AIRDROP_FN;
|
|
256
|
+
exports.airdropKeys = airdropKeys;
|
|
257
|
+
exports.airdropQueryKey = airdropQueryKey;
|
|
258
|
+
exports.airdropQueryKeyPrefix = airdropQueryKeyPrefix;
|
|
259
|
+
exports.useMemoAirdropBaseClient = useMemoAirdropBaseClient;
|
|
260
|
+
exports.useMemoAirdropFactoryClient = useMemoAirdropFactoryClient;
|
|
261
|
+
exports.useMemoComplianceManagerClient = useMemoComplianceManagerClient;
|
|
262
|
+
exports.useMemoEcdsaAirdropClient = useMemoEcdsaAirdropClient;
|
|
263
|
+
exports.useMemoMerkleAirdropClient = useMemoMerkleAirdropClient;
|