@tokenops/sdk 2.0.0-alpha.3 → 2.0.0-alpha.4
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 +53 -0
- package/README.md +71 -35
- package/SUPPORT.md +1 -1
- package/dist/{chunk-NGU4JYIR.js → chunk-2ND7US2I.js} +1 -1
- package/dist/{chunk-U3TBQRT7.js → chunk-3ZSPRHR3.js} +55 -12
- package/dist/{chunk-BXX5TETM.js → chunk-67Q6KSVV.js} +4114 -3267
- package/dist/{chunk-JVNJSDQ4.cjs → chunk-6AYJRUGP.cjs} +7 -50
- package/dist/{chunk-AHU2HMNE.cjs → chunk-6FUHF73F.cjs} +5 -5
- package/dist/{chunk-NWFMBLSQ.js → chunk-7KY4K4PH.js} +1 -1
- package/dist/{chunk-YABHXJNH.cjs → chunk-ARZ5C3FS.cjs} +7 -7
- package/dist/{chunk-4IB4IY5Y.js → chunk-AX6MQAWU.js} +2 -2
- package/dist/{chunk-BPIVVCSQ.js → chunk-BSXEX2SH.js} +3 -3
- package/dist/{chunk-PK6Q6J5F.js → chunk-CHGY6B7L.js} +34 -81
- package/dist/{chunk-GKYZQJGP.cjs → chunk-DFK5GCJP.cjs} +55 -72
- package/dist/{chunk-4AWQJQXY.cjs → chunk-E4IV4M4E.cjs} +4126 -3279
- package/dist/{chunk-6HCT4QIX.js → chunk-GHGF65LN.js} +16 -13
- package/dist/{chunk-TWT3STIX.js → chunk-K3R27WX4.js} +8 -46
- package/dist/{chunk-GCJFAY4X.js → chunk-KJUNBOJQ.js} +52 -71
- package/dist/{chunk-6XOAYDC6.cjs → chunk-PO3A2AQX.cjs} +4 -4
- package/dist/{chunk-TND5NDV7.cjs → chunk-QHDMPT7I.cjs} +64 -19
- package/dist/{chunk-IEKTGJ4J.cjs → chunk-S47IBDTA.cjs} +36 -83
- package/dist/{chunk-UG5RKLU2.cjs → chunk-SUYBAF27.cjs} +1 -1
- package/dist/{chunk-WRWRA4TN.js → chunk-TWU7L5H7.js} +5 -48
- package/dist/{chunk-WJLECC22.cjs → chunk-UUSSWOPR.cjs} +9 -47
- package/dist/{chunk-YTIYTV4K.cjs → chunk-VHKMWWBA.cjs} +319 -40
- package/dist/{chunk-PG3WXT3K.cjs → chunk-YAL6JSAZ.cjs} +16 -13
- package/dist/{chunk-LEYYG4RF.js → chunk-YMWMIWBP.js} +315 -42
- package/dist/core/addresses.d.ts +4 -4
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/pending.d.ts +57 -0
- package/dist/core/version.d.ts +1 -1
- package/dist/fhe/operators.d.ts +6 -5
- package/dist/fhe/types.d.ts +1 -1
- package/dist/fhe-airdrop/abis/airdrop-base.d.ts +81 -4
- package/dist/fhe-airdrop/abis/ecdsa.d.ts +101 -4
- package/dist/fhe-airdrop/abis/factory.d.ts +222 -4
- package/dist/fhe-airdrop/abis/merkle.d.ts +100 -4
- package/dist/fhe-airdrop/advanced/index.cjs +8 -4
- package/dist/fhe-airdrop/advanced/index.d.cts +1 -0
- package/dist/fhe-airdrop/advanced/index.d.ts +1 -0
- package/dist/fhe-airdrop/advanced/index.js +1 -1
- package/dist/fhe-airdrop/advanced/react/index.cjs +121 -143
- package/dist/fhe-airdrop/advanced/react/index.js +55 -77
- package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +2 -4
- package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +7 -7
- package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +2 -1
- package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +5 -4
- package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useSetMaxGasFee.d.ts +7 -3
- package/dist/fhe-airdrop/airdrop-base.d.ts +95 -10
- package/dist/fhe-airdrop/campaign.d.ts +37 -73
- package/dist/fhe-airdrop/compliance-clone.d.ts +21 -0
- package/dist/fhe-airdrop/constants.d.ts +3 -1
- package/dist/fhe-airdrop/ecdsa.d.ts +67 -27
- package/dist/fhe-airdrop/encryption.d.ts +19 -6
- package/dist/fhe-airdrop/errors.d.ts +77 -2
- package/dist/fhe-airdrop/factory-params.d.ts +2361 -0
- package/dist/fhe-airdrop/factory.d.ts +142 -68
- package/dist/fhe-airdrop/guards.d.ts +110 -31
- package/dist/fhe-airdrop/index.cjs +79 -59
- package/dist/fhe-airdrop/index.d.cts +11 -9
- package/dist/fhe-airdrop/index.d.ts +11 -9
- package/dist/fhe-airdrop/index.js +5 -5
- package/dist/fhe-airdrop/merkle-tree.d.ts +9 -9
- package/dist/fhe-airdrop/merkle.d.ts +32 -11
- package/dist/fhe-airdrop/react/_shared.d.ts +12 -6
- package/dist/fhe-airdrop/react/index.cjs +294 -258
- package/dist/fhe-airdrop/react/index.d.cts +16 -9
- package/dist/fhe-airdrop/react/index.d.ts +16 -9
- package/dist/fhe-airdrop/react/index.js +114 -110
- package/dist/fhe-airdrop/react/keys.d.ts +46 -7
- package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +6 -3
- package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +2 -2
- package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +8 -3
- package/dist/fhe-airdrop/react/useAirdropPause.d.ts +5 -0
- package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +4 -6
- package/dist/fhe-airdrop/react/useComplianceManager.d.ts +2 -2
- package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +1 -2
- package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +16 -11
- package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +23 -7
- package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +13 -8
- package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +27 -7
- package/dist/fhe-airdrop/react/useDedupMode.d.ts +16 -0
- package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +4 -3
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +6 -4
- package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +15 -8
- package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +1 -1
- package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +5 -7
- package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +4 -1
- package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +3 -4
- package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +2 -1
- package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +5 -4
- package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +4 -1
- package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +14 -3
- package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +18 -3
- package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +1 -1
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +34 -13
- package/dist/fhe-airdrop/react/useRescueERC20.d.ts +3 -3
- package/dist/fhe-airdrop/react/useRescueNativeToken.d.ts +23 -0
- package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +5 -2
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +4 -0
- package/dist/fhe-airdrop/react/useTokenOf.d.ts +29 -0
- package/dist/fhe-airdrop/react/useUnwrapRequest.d.ts +25 -0
- package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +4 -0
- package/dist/fhe-airdrop/roles.d.ts +82 -7
- package/dist/fhe-airdrop/types.d.ts +109 -14
- package/dist/fhe-disperse/errors.d.ts +3 -3
- package/dist/fhe-disperse/index.cjs +22 -22
- package/dist/fhe-disperse/index.d.cts +2 -1
- package/dist/fhe-disperse/index.d.ts +2 -1
- package/dist/fhe-disperse/index.js +3 -3
- package/dist/fhe-disperse/react/index.cjs +27 -25
- package/dist/fhe-disperse/react/index.d.cts +2 -1
- package/dist/fhe-disperse/react/index.d.ts +2 -1
- package/dist/fhe-disperse/react/index.js +8 -6
- package/dist/fhe-disperse/react/useDisperse.d.ts +6 -2
- package/dist/fhe-disperse/react/useRegister.d.ts +9 -3
- package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +7 -2
- package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +7 -2
- package/dist/fhe-disperse/singleton.d.ts +33 -19
- package/dist/fhe-disperse/types.d.ts +48 -8
- package/dist/fhe-vesting/advanced/index.cjs +6 -6
- package/dist/fhe-vesting/advanced/index.js +4 -4
- package/dist/fhe-vesting/advanced/react/index.cjs +9 -9
- package/dist/fhe-vesting/advanced/react/index.js +6 -6
- package/dist/fhe-vesting/factory.d.ts +31 -8
- package/dist/fhe-vesting/index.cjs +23 -23
- package/dist/fhe-vesting/index.d.cts +3 -2
- package/dist/fhe-vesting/index.d.ts +3 -2
- package/dist/fhe-vesting/index.js +4 -4
- package/dist/fhe-vesting/manager.d.ts +27 -2
- package/dist/fhe-vesting/react/index.cjs +126 -126
- package/dist/fhe-vesting/react/index.d.cts +3 -2
- package/dist/fhe-vesting/react/index.d.ts +3 -2
- package/dist/fhe-vesting/react/index.js +5 -5
- package/dist/fhe-vesting/react/useCreateManager.d.ts +16 -9
- package/dist/fhe-vesting/react/useCreateManagerAndGetAddress.d.ts +9 -5
- package/dist/fhe-vesting/react/useSplitVesting.d.ts +9 -3
- package/dist/index.cjs +18 -18
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/faucet.d.ts +3 -0
- package/dist/testnet-faucet/index.cjs +15 -15
- package/dist/testnet-faucet/index.js +3 -3
- package/dist/testnet-faucet/react/index.cjs +9 -9
- package/dist/testnet-faucet/react/index.js +4 -4
- package/package.json +1 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { isContractRevert } from './chunk-4RAAATVY.js';
|
|
2
|
-
import { TokenOpsSdkError, InvalidArgumentError, FeatureDisabledError, UnsupportedChainError, FheHandleNotAllowedError, TransferFailedError, InsufficientBalanceError, InsufficientFeeError, PausedError, InvalidSignatureError
|
|
3
|
-
import { isAddressEqual, zeroAddress, isAddress, BaseError, ContractFunctionZeroDataError } from 'viem';
|
|
2
|
+
import { TokenOpsSdkError, InvalidArgumentError, FeatureDisabledError, UnsupportedChainError, FheHandleNotAllowedError, TransferFailedError, InsufficientBalanceError, InsufficientFeeError, isTokenOpsSdkError, PausedError, InvalidSignatureError } from './chunk-QBJ7O2B4.js';
|
|
3
|
+
import { isAddressEqual, zeroAddress, isAddress, keccak256, encodeAbiParameters, getAddress, getCreate2Address, BaseError, ContractFunctionZeroDataError } from 'viem';
|
|
4
4
|
|
|
5
5
|
// src/fhe-airdrop/constants.ts
|
|
6
|
-
var AIRDROP_CONTRACTS_COMMIT = "
|
|
6
|
+
var AIRDROP_CONTRACTS_COMMIT = "005980df194e0dc66053bd517e9759bd4d580047";
|
|
7
7
|
var DEPLOYMENT_MODE = { clone: 0, uups: 1 };
|
|
8
8
|
var DEDUP_MODE = { perAddress: 0, perDedupId: 1, both: 2, none: 3 };
|
|
9
|
+
var DEDUP_MODE_BY_ORDINAL = new Map(
|
|
10
|
+
Object.keys(DEDUP_MODE).map((mode) => [DEDUP_MODE[mode], mode])
|
|
11
|
+
);
|
|
9
12
|
var UINT96_MAX = (1n << 96n) - 1n;
|
|
10
13
|
|
|
11
14
|
// src/fhe-airdrop/errors.ts
|
|
@@ -95,6 +98,43 @@ var PredictionDriftError = class extends TokenOpsSdkError {
|
|
|
95
98
|
);
|
|
96
99
|
}
|
|
97
100
|
};
|
|
101
|
+
var CreateCommitmentMismatchError = class extends TokenOpsSdkError {
|
|
102
|
+
name = "CreateCommitmentMismatchError";
|
|
103
|
+
constructor(args) {
|
|
104
|
+
const rebuild = args.field === "airdrop" ? " Anything bound to the old prediction (Merkle leaves, vouchers, encrypted inputs) must be rebuilt." : "";
|
|
105
|
+
const { cause, ...context } = args;
|
|
106
|
+
super(
|
|
107
|
+
`${args.method}: the factory would deploy with ${args.field} = ${args.actual ?? "?"}, but the create committed to ${args.expected ?? "?"}. Nothing was deployed and the salt is unused; re-quote and retry.${rebuild}`,
|
|
108
|
+
{ code: "TOKENOPS_CREATE_COMMITMENT_MISMATCH", cause, context }
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var ClawbackRequiresPauseError = class extends TokenOpsSdkError {
|
|
113
|
+
name = "ClawbackRequiresPauseError";
|
|
114
|
+
constructor(args) {
|
|
115
|
+
super(
|
|
116
|
+
`${args.method}: withdrawConfidential is refused while the campaign is unpaused inside its claim window. Pause first (PAUSER_ROLE), or run it outside the window (before startTime or after endTime).`,
|
|
117
|
+
{
|
|
118
|
+
code: "TOKENOPS_CLAWBACK_REQUIRES_PAUSE",
|
|
119
|
+
cause: args.cause,
|
|
120
|
+
context: { method: args.method, contractAddress: args.contractAddress }
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var NativeRescueRequiresZeroFeeError = class extends TokenOpsSdkError {
|
|
126
|
+
name = "NativeRescueRequiresZeroFeeError";
|
|
127
|
+
constructor(args) {
|
|
128
|
+
super(
|
|
129
|
+
`${args.method}: rescueNativeToken is only available on a zero-fee campaign; this instance charges a gas fee, so its ETH is fee revenue - use withdrawGasFee.`,
|
|
130
|
+
{
|
|
131
|
+
code: "TOKENOPS_NATIVE_RESCUE_REQUIRES_ZERO_FEE",
|
|
132
|
+
cause: args.cause,
|
|
133
|
+
context: { method: args.method, contractAddress: args.contractAddress }
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
98
138
|
var UpgradeabilityNotAllowedError = class extends TokenOpsSdkError {
|
|
99
139
|
name = "UpgradeabilityNotAllowedError";
|
|
100
140
|
constructor(args) {
|
|
@@ -287,12 +327,16 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
287
327
|
return new FheHandleNotAllowedError({ ...ctx, handle });
|
|
288
328
|
}
|
|
289
329
|
// ---- Merkle-specific ----------------------------------------------
|
|
290
|
-
case "InvalidMerkleProof":
|
|
330
|
+
case "InvalidMerkleProof": {
|
|
331
|
+
const leaf = errArgs?.[0];
|
|
332
|
+
const merkleRoot = errArgs?.[1];
|
|
291
333
|
return new InvalidArgumentError({
|
|
292
334
|
method: ctx.method,
|
|
293
335
|
argument: "merkleProof",
|
|
294
|
-
reason: "the contract reverted with `InvalidMerkleProof` \u2014 the proof does not verify against the current on-chain root. If the root was recently rotated, rebuild the proof against the new root."
|
|
336
|
+
reason: "the contract reverted with `InvalidMerkleProof` \u2014 the proof does not verify against the current on-chain root. If the root was recently rotated, rebuild the proof against the new root.",
|
|
337
|
+
...leaf !== void 0 || merkleRoot !== void 0 ? { value: { leaf, merkleRoot } } : {}
|
|
295
338
|
});
|
|
339
|
+
}
|
|
296
340
|
case "RootImmutable":
|
|
297
341
|
return new FeatureDisabledError({ ...ctx, feature: "merkleRootRotation" });
|
|
298
342
|
case "ZeroAccount":
|
|
@@ -330,13 +374,10 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
330
374
|
return new GasFeeNotAcceptedError({ ...ctx, resolvedFee, maxAcceptedGasFee });
|
|
331
375
|
}
|
|
332
376
|
case "GasFeeExceedsMaximum": {
|
|
333
|
-
|
|
334
|
-
const maxGasFee = errArgs?.[1];
|
|
335
|
-
return new InvalidArgumentError({
|
|
377
|
+
return gasFeeExceedsMaximumError({
|
|
336
378
|
method: ctx.method,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
value: gasFee
|
|
379
|
+
gasFee: errArgs?.[0],
|
|
380
|
+
maxGasFee: errArgs?.[1]
|
|
340
381
|
});
|
|
341
382
|
}
|
|
342
383
|
case "ZeroUnwrapRequestId":
|
|
@@ -402,7 +443,7 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
402
443
|
ctx,
|
|
403
444
|
"complianceDelegate",
|
|
404
445
|
name,
|
|
405
|
-
"
|
|
446
|
+
"the factory requires a non-zero delegate (constructor, setter and create)"
|
|
406
447
|
);
|
|
407
448
|
case "IndexOutOfBounds": {
|
|
408
449
|
const index = errArgs?.[0];
|
|
@@ -425,6 +466,48 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
425
466
|
value: existingAirdrop
|
|
426
467
|
});
|
|
427
468
|
}
|
|
469
|
+
case "PredictionMismatch":
|
|
470
|
+
case "ManagerImplementationMismatch":
|
|
471
|
+
case "ComplianceDelegateMismatch": {
|
|
472
|
+
const field = name === "PredictionMismatch" ? "airdrop" : name === "ManagerImplementationMismatch" ? "complianceManagerImpl" : "complianceDelegate";
|
|
473
|
+
return new CreateCommitmentMismatchError({
|
|
474
|
+
method: ctx.method,
|
|
475
|
+
contractAddress: ctx.contractAddress,
|
|
476
|
+
field,
|
|
477
|
+
expected: errArgs?.[0],
|
|
478
|
+
actual: errArgs?.[1]
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
case "InvalidImplementation":
|
|
482
|
+
return invalidArg(ctx, "implementation", name, void 0, errArgs?.[0]);
|
|
483
|
+
case "EndTimeInPast": {
|
|
484
|
+
const endTime = numberArg(errArgs?.[0]);
|
|
485
|
+
const currentTime = numberArg(errArgs?.[1]);
|
|
486
|
+
return invalidArg(
|
|
487
|
+
ctx,
|
|
488
|
+
"endTime",
|
|
489
|
+
name,
|
|
490
|
+
endTime !== void 0 && currentTime !== void 0 ? `endTime ${endTime} is not after the chain time ${currentTime}` : void 0,
|
|
491
|
+
endTime !== void 0 || currentTime !== void 0 ? { endTime, currentTime } : void 0
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
case "InvalidDuration": {
|
|
495
|
+
const fromTime = numberArg(errArgs?.[0]);
|
|
496
|
+
const toTime = numberArg(errArgs?.[1]);
|
|
497
|
+
return invalidArg(
|
|
498
|
+
ctx,
|
|
499
|
+
"duration",
|
|
500
|
+
name,
|
|
501
|
+
fromTime !== void 0 && toTime !== void 0 ? `${toTime} does not come after ${fromTime}` : void 0,
|
|
502
|
+
fromTime !== void 0 || toTime !== void 0 ? { fromTime, toTime } : void 0
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
case "UninitializedHandle":
|
|
506
|
+
return invalidArg(ctx, "handle", name);
|
|
507
|
+
case "ClawbackRequiresPause":
|
|
508
|
+
return new ClawbackRequiresPauseError(ctx);
|
|
509
|
+
case "NativeRescueRequiresZeroFee":
|
|
510
|
+
return new NativeRescueRequiresZeroFeeError(ctx);
|
|
428
511
|
case "ZeroSigner":
|
|
429
512
|
return invalidArg(ctx, "signer", name);
|
|
430
513
|
case "ZeroMerkleRoot":
|
|
@@ -432,7 +515,7 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
432
515
|
ctx,
|
|
433
516
|
"merkleRoot",
|
|
434
517
|
name,
|
|
435
|
-
"a zero root is only
|
|
518
|
+
"a zero root is permitted only at create on a mutable-root campaign, and never as a rotation target"
|
|
436
519
|
);
|
|
437
520
|
// ---- compliance manager clone (`ComplianceRoleManager`) --------------
|
|
438
521
|
case "ZeroAirdrop":
|
|
@@ -472,15 +555,26 @@ var airdropProductMapper = (name, errArgs, ctx) => {
|
|
|
472
555
|
return void 0;
|
|
473
556
|
}
|
|
474
557
|
};
|
|
475
|
-
function
|
|
558
|
+
function gasFeeExceedsMaximumError(args) {
|
|
559
|
+
const { gasFee, maxGasFee } = args;
|
|
560
|
+
return new InvalidArgumentError({
|
|
561
|
+
method: args.method,
|
|
562
|
+
argument: "gasFee",
|
|
563
|
+
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`,
|
|
564
|
+
value: gasFee
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function invalidArg(ctx, argument, revertName, detail, value) {
|
|
476
568
|
const suffix = detail ? ` ${detail}.` : "";
|
|
477
569
|
return new InvalidArgumentError({
|
|
478
570
|
method: ctx.method,
|
|
479
571
|
argument,
|
|
480
|
-
reason: `the contract reverted with \`${revertName}\`.${suffix}
|
|
572
|
+
reason: `the contract reverted with \`${revertName}\`.${suffix}`,
|
|
573
|
+
...value !== void 0 ? { value } : {}
|
|
481
574
|
});
|
|
482
575
|
}
|
|
483
576
|
function numberArg(value) {
|
|
577
|
+
if (typeof value === "number") return value;
|
|
484
578
|
return typeof value === "bigint" ? Number(value) : void 0;
|
|
485
579
|
}
|
|
486
580
|
var SUPPORTED_CHAIN_IDS = [1, 11155111, 31337];
|
|
@@ -547,9 +641,12 @@ function assertMaxAcceptedGasFeeRange(value, method) {
|
|
|
547
641
|
});
|
|
548
642
|
}
|
|
549
643
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
644
|
+
function assertWithinCeiling(method, resolvedFee, maxGasFee) {
|
|
645
|
+
if (resolvedFee > maxGasFee) {
|
|
646
|
+
throw gasFeeExceedsMaximumError({ method, gasFee: resolvedFee, maxGasFee });
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
function assertResolvedFeeAccepted(args, resolvedFee) {
|
|
553
650
|
if (resolvedFee <= args.maxAcceptedGasFee) return;
|
|
554
651
|
throw new GasFeeNotAcceptedError({
|
|
555
652
|
method: args.method,
|
|
@@ -558,6 +655,15 @@ async function assertGasFeeAccepted(args) {
|
|
|
558
655
|
maxAcceptedGasFee: args.maxAcceptedGasFee
|
|
559
656
|
});
|
|
560
657
|
}
|
|
658
|
+
async function assertCreateGasFee(args) {
|
|
659
|
+
assertMaxAcceptedGasFeeRange(args.maxAcceptedGasFee, args.method);
|
|
660
|
+
const [resolvedFee, maxGasFee] = await Promise.all([
|
|
661
|
+
args.factory.resolveGasFee(args.creator),
|
|
662
|
+
args.factory.maxGasFee()
|
|
663
|
+
]);
|
|
664
|
+
assertWithinCeiling(args.method, resolvedFee, maxGasFee);
|
|
665
|
+
assertResolvedFeeAccepted(args, resolvedFee);
|
|
666
|
+
}
|
|
561
667
|
function assertPredictionFresh(args) {
|
|
562
668
|
if (args.initCodeHashBefore.toLowerCase() === args.initCodeHashAfter.toLowerCase()) return;
|
|
563
669
|
throw new PredictionDriftError({
|
|
@@ -568,6 +674,112 @@ function assertPredictionFresh(args) {
|
|
|
568
674
|
predictedAddress: args.predictedAddress
|
|
569
675
|
});
|
|
570
676
|
}
|
|
677
|
+
var END_TIME_MARGIN_SECONDS = 60;
|
|
678
|
+
function invalidCreateParam(method, argument, revertName, reason, value) {
|
|
679
|
+
return new InvalidArgumentError({
|
|
680
|
+
method,
|
|
681
|
+
argument,
|
|
682
|
+
reason: `${reason}; the instance initializer reverts \`${revertName}\``,
|
|
683
|
+
value
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
function assertCreateParamsWellFormed(args, method) {
|
|
687
|
+
const { common } = args.params;
|
|
688
|
+
if (isAddressEqual(common.token, zeroAddress)) {
|
|
689
|
+
throw invalidCreateParam(
|
|
690
|
+
method,
|
|
691
|
+
"common.token",
|
|
692
|
+
"ZeroToken",
|
|
693
|
+
"is the zero address",
|
|
694
|
+
common.token
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
698
|
+
if (common.endTime <= now + END_TIME_MARGIN_SECONDS) {
|
|
699
|
+
throw invalidCreateParam(
|
|
700
|
+
method,
|
|
701
|
+
"common.endTime",
|
|
702
|
+
"EndTimeInPast",
|
|
703
|
+
`is not at least ${END_TIME_MARGIN_SECONDS}s in the future`,
|
|
704
|
+
common.endTime
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
if (common.startTime > common.endTime) {
|
|
708
|
+
throw invalidCreateParam(
|
|
709
|
+
method,
|
|
710
|
+
"common.startTime",
|
|
711
|
+
"InvalidStartTime",
|
|
712
|
+
"is after `endTime`",
|
|
713
|
+
common.startTime
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
if (common.startTime === common.endTime) {
|
|
717
|
+
throw invalidCreateParam(
|
|
718
|
+
method,
|
|
719
|
+
"common.startTime",
|
|
720
|
+
"InvalidDuration",
|
|
721
|
+
"equals `endTime`, leaving a zero-length claim window",
|
|
722
|
+
common.startTime
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
if (args.variant === "merkle") {
|
|
726
|
+
const { merkleRoot, isMerkleRootMutable } = args.params;
|
|
727
|
+
if (!isMerkleRootMutable && BigInt(merkleRoot) === 0n) {
|
|
728
|
+
throw invalidCreateParam(
|
|
729
|
+
method,
|
|
730
|
+
"merkleRoot",
|
|
731
|
+
"ZeroMerkleRoot",
|
|
732
|
+
"is zero on an immutable-root campaign, so no claim could ever verify",
|
|
733
|
+
merkleRoot
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
} else if (isAddressEqual(args.params.signer, zeroAddress)) {
|
|
737
|
+
throw invalidCreateParam(
|
|
738
|
+
method,
|
|
739
|
+
"signer",
|
|
740
|
+
"ZeroSigner",
|
|
741
|
+
"is the zero address",
|
|
742
|
+
args.params.signer
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
function resolvePlannedCreate(args) {
|
|
747
|
+
const { method, params, expected, expectedInitCodeHash, plan } = args;
|
|
748
|
+
if (!plan) return { expected, expectedInitCodeHash };
|
|
749
|
+
if (params.merkleRoot.toLowerCase() !== plan.root.toLowerCase()) {
|
|
750
|
+
throw new InvalidArgumentError({
|
|
751
|
+
method,
|
|
752
|
+
argument: "params.merkleRoot",
|
|
753
|
+
reason: "differs from plan.root; the plan's entries verify only against the root they were built into",
|
|
754
|
+
value: params.merkleRoot
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
if (expected?.airdrop !== void 0 && !isAddressEqual(expected.airdrop, plan.predictedAddress)) {
|
|
758
|
+
throw new InvalidArgumentError({
|
|
759
|
+
method,
|
|
760
|
+
argument: "expected.airdrop",
|
|
761
|
+
reason: "differs from plan.predictedAddress; a plan's leaves are bound to its predicted address, so the two cannot name different instances",
|
|
762
|
+
value: expected.airdrop
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
if (expectedInitCodeHash !== void 0 && expectedInitCodeHash.toLowerCase() !== plan.initCodeHashAfter.toLowerCase()) {
|
|
766
|
+
throw new InvalidArgumentError({
|
|
767
|
+
method,
|
|
768
|
+
argument: "expectedInitCodeHash",
|
|
769
|
+
reason: "differs from plan.initCodeHashAfter; pass one or the other",
|
|
770
|
+
value: expectedInitCodeHash
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
return {
|
|
774
|
+
expected: { ...definedFields(expected), airdrop: plan.predictedAddress },
|
|
775
|
+
expectedInitCodeHash: plan.initCodeHashAfter
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
var COMMITMENT_FIELDS = ["airdrop", "complianceManagerImpl", "complianceDelegate"];
|
|
779
|
+
function definedFields(pinned) {
|
|
780
|
+
if (!pinned) return {};
|
|
781
|
+
return Object.fromEntries(Object.entries(pinned).filter(([, value]) => value !== void 0));
|
|
782
|
+
}
|
|
571
783
|
async function preflightCreate(args) {
|
|
572
784
|
const method = args.variant === "merkle" ? "createMerkleAirdrop" : "createEcdsaAirdrop";
|
|
573
785
|
const blockers = [];
|
|
@@ -580,15 +792,34 @@ async function preflightCreate(args) {
|
|
|
580
792
|
() => assertMaxAcceptedGasFeeRange(args.params.common.maxAcceptedGasFee, method)
|
|
581
793
|
);
|
|
582
794
|
if (!encodable) return { ready: false, blockers };
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
795
|
+
collect(blockers, () => assertCreateParamsWellFormed(args, method));
|
|
796
|
+
let pins = { expected: args.expected, expectedInitCodeHash: args.expectedInitCodeHash };
|
|
797
|
+
if (args.variant === "merkle") {
|
|
798
|
+
const { params, plan } = args;
|
|
799
|
+
collect(blockers, () => {
|
|
800
|
+
pins = resolvePlannedCreate({ method, params, ...pins, plan });
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
const { expected, expectedInitCodeHash } = pins;
|
|
804
|
+
await collectAsync(blockers, async () => {
|
|
805
|
+
const [resolvedFee, maxGasFee] = await Promise.all([
|
|
806
|
+
args.factory.resolveGasFee(args.creator),
|
|
807
|
+
args.factory.maxGasFee()
|
|
808
|
+
]);
|
|
809
|
+
collect(blockers, () => assertWithinCeiling(method, resolvedFee, maxGasFee));
|
|
810
|
+
collect(
|
|
811
|
+
blockers,
|
|
812
|
+
() => assertResolvedFeeAccepted(
|
|
813
|
+
{
|
|
814
|
+
factory: args.factory,
|
|
815
|
+
creator: args.creator,
|
|
816
|
+
maxAcceptedGasFee: args.params.common.maxAcceptedGasFee,
|
|
817
|
+
method
|
|
818
|
+
},
|
|
819
|
+
resolvedFee
|
|
820
|
+
)
|
|
821
|
+
);
|
|
822
|
+
});
|
|
592
823
|
const predictArgs = {
|
|
593
824
|
mode: args.mode,
|
|
594
825
|
deployer: args.creator,
|
|
@@ -620,7 +851,7 @@ async function preflightCreate(args) {
|
|
|
620
851
|
blockers,
|
|
621
852
|
() => assertSaltAvailable({
|
|
622
853
|
publicClient: args.factory.publicClient,
|
|
623
|
-
predictedAddress,
|
|
854
|
+
predictedAddress: expected?.airdrop ?? predictedAddress,
|
|
624
855
|
variant: args.variant,
|
|
625
856
|
mode: args.mode,
|
|
626
857
|
deployer: args.creator,
|
|
@@ -628,19 +859,53 @@ async function preflightCreate(args) {
|
|
|
628
859
|
method
|
|
629
860
|
})
|
|
630
861
|
);
|
|
631
|
-
if (
|
|
862
|
+
if (expectedInitCodeHash !== void 0) {
|
|
863
|
+
const initCodeHashBefore = expectedInitCodeHash;
|
|
632
864
|
collect(
|
|
633
865
|
blockers,
|
|
634
866
|
() => assertPredictionFresh({
|
|
635
867
|
variant: args.variant,
|
|
636
|
-
initCodeHashBefore
|
|
868
|
+
initCodeHashBefore,
|
|
637
869
|
initCodeHashAfter: liveInitCodeHash,
|
|
638
|
-
predictedAddress,
|
|
870
|
+
predictedAddress: expected?.airdrop ?? predictedAddress,
|
|
639
871
|
method
|
|
640
872
|
})
|
|
641
873
|
);
|
|
642
874
|
}
|
|
643
|
-
|
|
875
|
+
const pinned = Object.keys(definedFields(expected)).length > 0;
|
|
876
|
+
let fresh;
|
|
877
|
+
try {
|
|
878
|
+
fresh = await args.factory.quoteCreateCommitments({
|
|
879
|
+
...args.variant === "merkle" ? { variant: "merkle", params: args.params } : { variant: "ecdsa", params: args.params },
|
|
880
|
+
mode: args.mode,
|
|
881
|
+
deployer: args.creator,
|
|
882
|
+
userSalt: args.userSalt,
|
|
883
|
+
expected: { airdrop: predictedAddress }
|
|
884
|
+
});
|
|
885
|
+
} catch (err) {
|
|
886
|
+
if (pinned) {
|
|
887
|
+
if (!isTokenOpsSdkError(err)) throw err;
|
|
888
|
+
blockers.push(err);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
let commitments;
|
|
892
|
+
if (fresh) {
|
|
893
|
+
commitments = { ...fresh, ...definedFields(expected) };
|
|
894
|
+
for (const field of COMMITMENT_FIELDS) {
|
|
895
|
+
const pinned2 = expected?.[field];
|
|
896
|
+
if (pinned2 === void 0 || isAddressEqual(pinned2, fresh[field])) continue;
|
|
897
|
+
blockers.push(
|
|
898
|
+
new CreateCommitmentMismatchError({
|
|
899
|
+
method,
|
|
900
|
+
contractAddress: args.factory.address,
|
|
901
|
+
field,
|
|
902
|
+
expected: pinned2,
|
|
903
|
+
actual: fresh[field]
|
|
904
|
+
})
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return { ready: blockers.length === 0, blockers, ...commitments ? { commitments } : {} };
|
|
644
909
|
}
|
|
645
910
|
async function assertKnownAirdrop(args) {
|
|
646
911
|
if (args.factory.chainId !== args.chainId) {
|
|
@@ -659,10 +924,9 @@ async function assertKnownAirdrop(args) {
|
|
|
659
924
|
});
|
|
660
925
|
}
|
|
661
926
|
function assertMerkleClaimIdentity(args) {
|
|
662
|
-
const { method, account, submitter,
|
|
927
|
+
const { method, account, submitter, to, entrypoint = "claim" } = args;
|
|
663
928
|
for (const [argument, value] of [
|
|
664
929
|
["account", account],
|
|
665
|
-
["entry.boundTo", boundTo],
|
|
666
930
|
["to", to],
|
|
667
931
|
["submitter", submitter]
|
|
668
932
|
]) {
|
|
@@ -682,13 +946,6 @@ function assertMerkleClaimIdentity(args) {
|
|
|
682
946
|
reason: "is the zero address; the claim identity is mandatory and is never defaulted from the caller"
|
|
683
947
|
});
|
|
684
948
|
}
|
|
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
949
|
if (entrypoint === "claimAndUnwrap") {
|
|
693
950
|
if (!isAddressEqual(account, submitter)) {
|
|
694
951
|
throw new InvalidArgumentError({
|
|
@@ -807,5 +1064,21 @@ async function collectAsync(blockers, run) {
|
|
|
807
1064
|
blockers.push(err);
|
|
808
1065
|
}
|
|
809
1066
|
}
|
|
1067
|
+
var CLONE_INIT_CODE_PREFIX = "0x3d602d80600a3d3981f3363d3d373d3d3d363d73";
|
|
1068
|
+
var CLONE_INIT_CODE_SUFFIX = "5af43d82803e903d91602b57fd5bf3";
|
|
1069
|
+
function predictComplianceManagerClone(args) {
|
|
1070
|
+
const salt = keccak256(
|
|
1071
|
+
encodeAbiParameters(
|
|
1072
|
+
[{ type: "address" }, { type: "string" }],
|
|
1073
|
+
[getAddress(args.airdrop), "compliance"]
|
|
1074
|
+
)
|
|
1075
|
+
);
|
|
1076
|
+
const initCode = `${CLONE_INIT_CODE_PREFIX}${getAddress(args.managerImplementation).slice(2).toLowerCase()}${CLONE_INIT_CODE_SUFFIX}`;
|
|
1077
|
+
return getCreate2Address({
|
|
1078
|
+
from: getAddress(args.factory),
|
|
1079
|
+
salt,
|
|
1080
|
+
bytecodeHash: keccak256(initCode)
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
810
1083
|
|
|
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,
|
|
1084
|
+
export { AIRDROP_CONTRACTS_COMMIT, AlreadyClaimedError, ClaimNotStartedError, ClaimWindowClosedError, ClawbackRequiresPauseError, CreateCommitmentMismatchError, DEDUP_MODE, DEDUP_MODE_BY_ORDINAL, DEPLOYMENT_MODE, DedupIdConsumedError, FeeCollectorSelfAdministeredError, GasFeeNotAcceptedError, MerkleUupsUnsupportedError, NativeRescueRequiresZeroFeeError, NonStockWrapperError, PredictionDriftError, SaltCollisionError, SignatureExpiredError, UINT96_MAX, UnauthorizedRedirectError, UnrecognisedAirdropError, UpgradeabilityNotAllowedError, airdropProductMapper, assertCreateGasFee, assertMerkleClaimIdentity, assertMerkleModeSupported, assertPredictionFresh, assertSaltAvailable, assertStockWrapper, assertSupportedChain, predictComplianceManagerClone, preflightClaim, preflightCreate, resolvePlannedCreate };
|
package/dist/core/addresses.d.ts
CHANGED
|
@@ -15,16 +15,16 @@ export declare const DEPLOYED_ADDRESSES: {
|
|
|
15
15
|
};
|
|
16
16
|
readonly fheAirdrop: {
|
|
17
17
|
readonly airdropFactory: {
|
|
18
|
-
readonly 11155111: "
|
|
18
|
+
readonly 11155111: "0xD5906f366Ff50909F403c8EDfDe680015563046a";
|
|
19
19
|
};
|
|
20
20
|
readonly ecdsaImplementation: {
|
|
21
|
-
readonly 11155111: "
|
|
21
|
+
readonly 11155111: "0xE27A2aF9dCBda2B06535d5502e6dbB90364b43bA";
|
|
22
22
|
};
|
|
23
23
|
readonly merkleImplementation: {
|
|
24
|
-
readonly 11155111: "
|
|
24
|
+
readonly 11155111: "0xccea0A916dBe5aB939915a402942EE6AFDcD505E";
|
|
25
25
|
};
|
|
26
26
|
readonly complianceManagerImplementation: {
|
|
27
|
-
readonly 11155111: "
|
|
27
|
+
readonly 11155111: "0x076719596c21F0Eb358AC45649C3db387D98FADf";
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
readonly fheDisperse: {
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare const TOKENOPS_SDK_ERROR_BRAND: unique symbol;
|
|
|
13
13
|
* human-readable and may evolve between versions.
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
export type TokenOpsSdkErrorCode = "TOKENOPS_UNSUPPORTED_CHAIN" | "TOKENOPS_DEPLOYMENT_ADDRESS_UNAVAILABLE" | "TOKENOPS_MISSING_PUBLIC_CLIENT" | "TOKENOPS_MISSING_WALLET_CLIENT" | "TOKENOPS_MISSING_ACCOUNT" | "TOKENOPS_MISSING_ENCRYPTOR" | "TOKENOPS_MISSING_CLIENT" | "TOKENOPS_INVALID_ARGUMENT" | "TOKENOPS_RECEIPT_EVENT_NOT_FOUND" | "TOKENOPS_RECEIPT_EVENT_AMBIGUOUS" | "TOKENOPS_CONTRACT_REVERT" | "TOKENOPS_PAUSED" | "TOKENOPS_ACCESS_DENIED" | "TOKENOPS_OPERATOR_NOT_APPROVED" | "TOKENOPS_INSUFFICIENT_FEE" | "TOKENOPS_INSUFFICIENT_BALANCE" | "TOKENOPS_BATCH_TOO_LARGE" | "TOKENOPS_FEATURE_DISABLED" | "TOKENOPS_TRANSFER_FAILED" | "TOKENOPS_FHE_HANDLE_NOT_ALLOWED" | "TOKENOPS_ALREADY_INITIALIZED" | "TOKENOPS_REENTRANCY" | "TOKENOPS_INVALID_SIGNATURE" | "TOKENOPS_WALLET_REJECTED" | "TOKENOPS_WALLET_CHAIN_MISMATCH" | "TOKENOPS_NETWORK_ERROR" | "TOKENOPS_INSUFFICIENT_GAS_FUNDS" | "TOKENOPS_UNKNOWN_WRITE_FAILURE" | "TOKENOPS_USER_REJECTED" | "TOKENOPS_SIGNING_FAILED" | "TOKENOPS_RELAYER_UNREACHABLE" | "TOKENOPS_ENCRYPTION_FAILED" | "TOKENOPS_DECRYPTION_FAILED" | "TOKENOPS_USER_DECRYPT_NOT_ALLOWED" | "TOKENOPS_VESTING_NOT_FOUND" | "TOKENOPS_NOT_RECIPIENT" | "TOKENOPS_CLAIM_LOCKED" | "TOKENOPS_VESTING_REVOKED" | "TOKENOPS_NOT_REVOCABLE" | "TOKENOPS_VESTING_EXPIRED" | "TOKENOPS_TRANSFER_ALREADY_PENDING" | "TOKENOPS_NO_PENDING_TRANSFER" | "TOKENOPS_NOT_PENDING_RECIPIENT" | "TOKENOPS_TRANSFER_EXPIRED" | "TOKENOPS_ALREADY_CLAIMED" | "TOKENOPS_CLAIM_NOT_STARTED" | "TOKENOPS_CLAIM_WINDOW_CLOSED" | "TOKENOPS_NOT_REGISTERED" | "TOKENOPS_ALREADY_REGISTERED" | "TOKENOPS_SUBWALLETS_NOT_APPROVED" | "TOKENOPS_SINGLETON_NOT_APPROVED" | "TOKENOPS_FAUCET_SUPPLY_EXHAUSTED" | "TOKENOPS_MERKLE_UUPS_UNSUPPORTED" | "TOKENOPS_NON_STOCK_WRAPPER" | "TOKENOPS_UPGRADEABILITY_NOT_ALLOWED" | "TOKENOPS_FEE_COLLECTOR_SELF_ADMINISTERED" | "TOKENOPS_DEDUP_ID_CONSUMED" | "TOKENOPS_SIGNATURE_EXPIRED" | "TOKENOPS_SALT_COLLISION" | "TOKENOPS_PREDICTION_DRIFT" | "TOKENOPS_UNAUTHORIZED_REDIRECT" | "TOKENOPS_GAS_FEE_NOT_ACCEPTED" | "TOKENOPS_UNRECOGNISED_AIRDROP";
|
|
16
|
+
export type TokenOpsSdkErrorCode = "TOKENOPS_UNSUPPORTED_CHAIN" | "TOKENOPS_DEPLOYMENT_ADDRESS_UNAVAILABLE" | "TOKENOPS_MISSING_PUBLIC_CLIENT" | "TOKENOPS_MISSING_WALLET_CLIENT" | "TOKENOPS_MISSING_ACCOUNT" | "TOKENOPS_MISSING_ENCRYPTOR" | "TOKENOPS_MISSING_CLIENT" | "TOKENOPS_INVALID_ARGUMENT" | "TOKENOPS_RECEIPT_EVENT_NOT_FOUND" | "TOKENOPS_RECEIPT_EVENT_AMBIGUOUS" | "TOKENOPS_CONTRACT_REVERT" | "TOKENOPS_PAUSED" | "TOKENOPS_ACCESS_DENIED" | "TOKENOPS_OPERATOR_NOT_APPROVED" | "TOKENOPS_INSUFFICIENT_FEE" | "TOKENOPS_INSUFFICIENT_BALANCE" | "TOKENOPS_BATCH_TOO_LARGE" | "TOKENOPS_FEATURE_DISABLED" | "TOKENOPS_TRANSFER_FAILED" | "TOKENOPS_FHE_HANDLE_NOT_ALLOWED" | "TOKENOPS_ALREADY_INITIALIZED" | "TOKENOPS_REENTRANCY" | "TOKENOPS_INVALID_SIGNATURE" | "TOKENOPS_WALLET_REJECTED" | "TOKENOPS_WALLET_CHAIN_MISMATCH" | "TOKENOPS_NETWORK_ERROR" | "TOKENOPS_INSUFFICIENT_GAS_FUNDS" | "TOKENOPS_UNKNOWN_WRITE_FAILURE" | "TOKENOPS_UNEXPECTED_CONTRACT_RESPONSE" | "TOKENOPS_USER_REJECTED" | "TOKENOPS_SIGNING_FAILED" | "TOKENOPS_RELAYER_UNREACHABLE" | "TOKENOPS_ENCRYPTION_FAILED" | "TOKENOPS_DECRYPTION_FAILED" | "TOKENOPS_USER_DECRYPT_NOT_ALLOWED" | "TOKENOPS_VESTING_NOT_FOUND" | "TOKENOPS_NOT_RECIPIENT" | "TOKENOPS_CLAIM_LOCKED" | "TOKENOPS_VESTING_REVOKED" | "TOKENOPS_NOT_REVOCABLE" | "TOKENOPS_VESTING_EXPIRED" | "TOKENOPS_TRANSFER_ALREADY_PENDING" | "TOKENOPS_NO_PENDING_TRANSFER" | "TOKENOPS_NOT_PENDING_RECIPIENT" | "TOKENOPS_TRANSFER_EXPIRED" | "TOKENOPS_ALREADY_CLAIMED" | "TOKENOPS_CLAIM_NOT_STARTED" | "TOKENOPS_CLAIM_WINDOW_CLOSED" | "TOKENOPS_NOT_REGISTERED" | "TOKENOPS_ALREADY_REGISTERED" | "TOKENOPS_SUBWALLETS_NOT_APPROVED" | "TOKENOPS_SINGLETON_NOT_APPROVED" | "TOKENOPS_FAUCET_SUPPLY_EXHAUSTED" | "TOKENOPS_MERKLE_UUPS_UNSUPPORTED" | "TOKENOPS_NON_STOCK_WRAPPER" | "TOKENOPS_UPGRADEABILITY_NOT_ALLOWED" | "TOKENOPS_FEE_COLLECTOR_SELF_ADMINISTERED" | "TOKENOPS_DEDUP_ID_CONSUMED" | "TOKENOPS_SIGNATURE_EXPIRED" | "TOKENOPS_SALT_COLLISION" | "TOKENOPS_CREATE_COMMITMENT_MISMATCH" | "TOKENOPS_CLAWBACK_REQUIRES_PAUSE" | "TOKENOPS_NATIVE_RESCUE_REQUIRES_ZERO_FEE" | "TOKENOPS_PREDICTION_DRIFT" | "TOKENOPS_UNAUTHORIZED_REDIRECT" | "TOKENOPS_GAS_FEE_NOT_ACCEPTED" | "TOKENOPS_UNRECOGNISED_AIRDROP";
|
|
17
17
|
/** @public */
|
|
18
18
|
export interface TokenOpsSdkErrorInit {
|
|
19
19
|
code: TokenOpsSdkErrorCode;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./addresses.js";
|
|
|
2
2
|
export * from "./brands.js";
|
|
3
3
|
export * from "./chains.js";
|
|
4
4
|
export * from "./errors.js";
|
|
5
|
+
export * from "./pending.js";
|
|
5
6
|
export * from "./preflight.js";
|
|
6
7
|
export * from "./types.js";
|
|
7
8
|
export { type SdkTelemetry, type SdkTelemetryTags } from "./telemetry.js";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks a write result returned before its transaction was observed executing, because the
|
|
3
|
+
* write was sent with `waitForReceipt: false` (a Safe / multisig signer whose submission is a
|
|
4
|
+
* `safeTxHash` that never mines until threshold owners co-sign).
|
|
5
|
+
*
|
|
6
|
+
* Every receipt-free result in the SDK extends this, and every mined counterpart extends
|
|
7
|
+
* {@link MinedWrite}, so one check narrows a result from any product:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const result = await factory.createManager({ token, userSalt, waitForReceipt });
|
|
11
|
+
* if (result.pending) return trackSafeTx(result.hash);
|
|
12
|
+
* openManager(result.manager); // `Address`
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface PendingWrite {
|
|
17
|
+
/** The transaction has not been observed executing. */
|
|
18
|
+
pending: true;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The mined counterpart of {@link PendingWrite}: the receipt was read and every receipt-derived
|
|
22
|
+
* field is set. `pending` is never present; it is declared so `if (result.pending)` compiles on
|
|
23
|
+
* the union.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export interface MinedWrite {
|
|
28
|
+
/** Never set on a mined result. */
|
|
29
|
+
pending?: never;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The `waitForReceipt` option of every receipt-free write. It is kept off the base `*Args`
|
|
33
|
+
* types, so a value typed as one of them still resolves to the mined overload; the methods
|
|
34
|
+
* take `Args & ReceiptMode<...>` instead.
|
|
35
|
+
*
|
|
36
|
+
* - `ReceiptMode<true>`: omitted or `true`. The SDK waits for the receipt and returns the
|
|
37
|
+
* mined result ({@link MinedWrite}) with every receipt-derived field set.
|
|
38
|
+
* - `ReceiptMode<false>`: `false`, for a Safe / multisig signer whose submission returns a
|
|
39
|
+
* `safeTxHash` that never mines until threshold owners co-sign. The call returns on
|
|
40
|
+
* submission with a {@link PendingWrite} result; read the executed transaction's logs for
|
|
41
|
+
* anything the receipt would have supplied.
|
|
42
|
+
* - `ReceiptMode` (`boolean`): a runtime value, as hooks and dynamic callers pass. The result
|
|
43
|
+
* is the union of the two, narrowed by `pending`.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* async function deploy(args: CreateManagerArgs & ReceiptMode) {
|
|
47
|
+
* const result = await factory.createManager(args);
|
|
48
|
+
* return result.pending ? undefined : result.manager;
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export type ReceiptMode<W extends boolean = boolean> = [W] extends [false] ? {
|
|
54
|
+
waitForReceipt: false;
|
|
55
|
+
} : {
|
|
56
|
+
waitForReceipt?: W | undefined;
|
|
57
|
+
};
|
package/dist/core/version.d.ts
CHANGED
package/dist/fhe/operators.d.ts
CHANGED
|
@@ -73,9 +73,10 @@ export interface SetOperatorArgs {
|
|
|
73
73
|
/** ERC-7984 token contract address. */
|
|
74
74
|
token: Address;
|
|
75
75
|
/**
|
|
76
|
-
* Address being authorized to pull tokens
|
|
77
|
-
* (`/fhe-vesting`),
|
|
78
|
-
*
|
|
76
|
+
* Address being authorized to pull tokens - typically a manager clone
|
|
77
|
+
* (`/fhe-vesting`), the airdrop FACTORY (`/fhe-airdrop`, which pulls the pool on
|
|
78
|
+
* every create-and-fund and `fundAirdrop`), or the disperse singleton
|
|
79
|
+
* (`/fhe-disperse`).
|
|
79
80
|
*/
|
|
80
81
|
spender: Address;
|
|
81
82
|
/**
|
|
@@ -147,7 +148,7 @@ export interface RevokeOperatorArgs {
|
|
|
147
148
|
token: Address;
|
|
148
149
|
/**
|
|
149
150
|
* Address whose operator authorization should be revoked — typically a
|
|
150
|
-
* stale manager clone (`/fhe-vesting`), a
|
|
151
|
+
* stale manager clone (`/fhe-vesting`), a factory you no longer fund through
|
|
151
152
|
* (`/fhe-airdrop`), or a singleton no longer in use (`/fhe-disperse`).
|
|
152
153
|
*/
|
|
153
154
|
spender: Address;
|
|
@@ -208,7 +209,7 @@ export interface IsOperatorArgs {
|
|
|
208
209
|
holder: Address;
|
|
209
210
|
/**
|
|
210
211
|
* Address whose operator status is being checked — typically a manager
|
|
211
|
-
* clone (`/fhe-vesting`),
|
|
212
|
+
* clone (`/fhe-vesting`), the airdrop factory (`/fhe-airdrop`), or
|
|
212
213
|
* the disperse singleton (`/fhe-disperse`).
|
|
213
214
|
*/
|
|
214
215
|
spender: Address;
|
package/dist/fhe/types.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface EncryptedInputs {
|
|
|
36
36
|
* the contract emits `FHE.allow(handle, grantee)` (usually `msg.sender`) and the SDK extracts
|
|
37
37
|
* `handle` from the receipt's ACL `Allowed` event.
|
|
38
38
|
*
|
|
39
|
-
* Pass `handle` to the Zama relayer's `userDecrypt` to obtain the plaintext
|
|
39
|
+
* Pass `handle` to the Zama relayer's `userDecrypt` to obtain the plaintext - AS THE GRANTEE. Most entrypoints grant the caller, but not all: `MerkleAirdropClient.getClaimAmount` grants the entry's `account`, so a third-party sender (any address may submit a Merkle entry) receives a valid handle it is not authorised to read.
|
|
40
40
|
* `hash` is the tx that committed the persistent ACL grant — surface it if
|
|
41
41
|
* your UI needs to show the receipt.
|
|
42
42
|
* @public
|