@tokenops/sdk 1.0.0 → 1.5.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/README.md +120 -26
- package/dist/{chunk-5SGMJADP.cjs → chunk-2NCLOQ56.cjs} +9 -9
- package/dist/{chunk-QIHZVLIK.js → chunk-2PWNH3UE.js} +35 -6
- package/dist/{chunk-T5LVV3KY.cjs → chunk-4WPGQSNT.cjs} +3 -3
- package/dist/{chunk-SUOG3BQS.cjs → chunk-5X5WL5CU.cjs} +266 -103
- package/dist/{chunk-56UI7LUR.cjs → chunk-67OV5CX2.cjs} +19 -0
- package/dist/{chunk-WRCUDSUJ.js → chunk-6BMP4ICG.js} +2 -2
- package/dist/{chunk-XXXDQSHE.js → chunk-6R4KNAPK.js} +5 -3
- package/dist/{chunk-XSNLAS5M.js → chunk-AOP6HMPW.js} +1 -1
- package/dist/{chunk-62DF53UQ.cjs → chunk-C7BRZXJA.cjs} +19 -21
- package/dist/{chunk-UOG4PJL5.js → chunk-DUZIIRPF.js} +181 -14
- package/dist/{chunk-Q7ARQSUH.cjs → chunk-FAXIIH5R.cjs} +3 -3
- package/dist/chunk-FT4LNBOS.js +11 -0
- package/dist/chunk-IJFQ5L4I.js +2171 -0
- package/dist/{chunk-52TC6BF7.js → chunk-IXLO7GO5.js} +210 -47
- package/dist/{chunk-CQIPRNS7.cjs → chunk-JK4XMMKM.cjs} +3 -3
- package/dist/{chunk-ITQ7WKVC.cjs → chunk-JYOTGRSO.cjs} +8 -8
- package/dist/{chunk-VDXVNZCO.cjs → chunk-KLKI352M.cjs} +85 -29
- package/dist/{chunk-5SA2HF2W.cjs → chunk-MCRBVJGZ.cjs} +24 -22
- package/dist/{chunk-ECT3NL2L.js → chunk-NTZY6IB7.js} +4 -4
- package/dist/{chunk-ZHFLRKFY.js → chunk-ODLTEGHB.js} +1 -1
- package/dist/{chunk-HGXNRR25.js → chunk-ORFTDNFZ.js} +4 -4
- package/dist/{chunk-72YGZEQE.js → chunk-OXTLPTO3.js} +9 -11
- package/dist/{chunk-HTOMTEA3.cjs → chunk-PFXURMBZ.cjs} +77 -48
- package/dist/{chunk-OLDGMKW2.cjs → chunk-PUPKNW3R.cjs} +35 -2
- package/dist/{chunk-IVE3QEGD.js → chunk-QBJ7O2B4.js} +18 -1
- package/dist/{chunk-JFLEEXKP.js → chunk-SG65XWH7.js} +58 -2
- package/dist/{chunk-K6MFFDBJ.cjs → chunk-T46YXSBP.cjs} +11 -11
- package/dist/{chunk-NS44KBV5.cjs → chunk-TEBM66WA.cjs} +12 -12
- package/dist/{chunk-6ECAHP5O.cjs → chunk-TIUKIY5V.cjs} +200 -33
- package/dist/{chunk-QCA7O2Q5.cjs → chunk-V2PXZVBF.cjs} +4 -4
- package/dist/{chunk-JFR5J4FL.cjs → chunk-W7IGCOVL.cjs} +11 -11
- package/dist/chunk-WENHUPZC.cjs +2180 -0
- package/dist/{chunk-ZXCOJY2Z.js → chunk-WMACINXO.js} +1 -1
- package/dist/{chunk-COPFW5Z4.js → chunk-XGGTQQFH.js} +31 -2
- package/dist/{chunk-CMRETRZO.js → chunk-YQIBBEFJ.js} +1 -1
- package/dist/{chunk-BE2AIZ3K.js → chunk-ZA673I3O.js} +1 -1
- package/dist/chunk-ZQUE2B3Q.cjs +33 -0
- package/dist/{chunk-FYQ2UW4T.js → chunk-ZWXJTBZO.js} +1 -1
- package/dist/core/addresses.d.ts +22 -0
- package/dist/core/errors.d.ts +41 -1
- package/dist/core/revert-mapper.d.ts +77 -0
- package/dist/core/telemetry.d.ts +0 -3
- package/dist/core/wagmi-compat.d.ts +40 -0
- package/dist/fhe/index.cjs +112 -66
- package/dist/fhe/index.d.cts +1 -1
- package/dist/fhe/index.d.ts +1 -1
- package/dist/fhe/index.js +50 -8
- package/dist/fhe/operators.d.ts +1 -1
- package/dist/fhe/react/index.cjs +7 -7
- package/dist/fhe/react/index.js +2 -2
- package/dist/fhe/sepolia-encryptor-web.d.ts +27 -1
- package/dist/fhe/sepolia-encryptor.d.ts +38 -0
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +3 -3
- package/dist/fhe-airdrop/advanced/index.cjs +9 -8
- package/dist/fhe-airdrop/advanced/index.d.cts +2 -2
- package/dist/fhe-airdrop/advanced/index.d.ts +2 -2
- package/dist/fhe-airdrop/advanced/index.js +7 -6
- package/dist/fhe-airdrop/advanced/react/index.cjs +14 -13
- package/dist/fhe-airdrop/advanced/react/index.d.cts +1 -1
- package/dist/fhe-airdrop/advanced/react/index.d.ts +1 -1
- package/dist/fhe-airdrop/advanced/react/index.js +10 -9
- package/dist/fhe-airdrop/airdrop.d.ts +2 -0
- package/dist/fhe-airdrop/encryption.d.ts +8 -0
- package/dist/fhe-airdrop/factory.d.ts +94 -11
- package/dist/fhe-airdrop/index.cjs +61 -57
- package/dist/fhe-airdrop/index.d.cts +3 -3
- package/dist/fhe-airdrop/index.d.ts +3 -3
- package/dist/fhe-airdrop/index.js +7 -7
- package/dist/fhe-airdrop/react/index.cjs +163 -133
- package/dist/fhe-airdrop/react/index.d.cts +4 -3
- package/dist/fhe-airdrop/react/index.d.ts +4 -3
- package/dist/fhe-airdrop/react/index.js +38 -13
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +2 -0
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +3 -2
- package/dist/fhe-airdrop/react/useClaim.d.ts +2 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +8 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +8 -0
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +8 -0
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +51 -0
- package/dist/fhe-airdrop/types.d.ts +45 -0
- package/dist/fhe-disperse/encryption.d.ts +8 -0
- package/dist/fhe-disperse/index.cjs +69 -65
- package/dist/fhe-disperse/index.d.cts +1 -1
- package/dist/fhe-disperse/index.d.ts +1 -1
- package/dist/fhe-disperse/index.js +8 -8
- package/dist/fhe-disperse/react/index.cjs +90 -86
- package/dist/fhe-disperse/react/index.d.cts +1 -1
- package/dist/fhe-disperse/react/index.d.ts +1 -1
- package/dist/fhe-disperse/react/index.js +10 -10
- package/dist/fhe-disperse/react/useCalculateFee.d.ts +7 -0
- package/dist/fhe-disperse/react/useDisperse.d.ts +9 -0
- package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +7 -0
- package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +7 -0
- package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +8 -2
- package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-disperse/singleton.d.ts +29 -0
- package/dist/fhe-disperse/subtotals.d.ts +6 -0
- package/dist/fhe-vesting/advanced/factory-advanced.d.ts +2 -2
- package/dist/fhe-vesting/advanced/index.cjs +8 -8
- package/dist/fhe-vesting/advanced/index.d.cts +2 -2
- package/dist/fhe-vesting/advanced/index.d.ts +2 -2
- package/dist/fhe-vesting/advanced/index.js +6 -6
- package/dist/fhe-vesting/advanced/react/index.cjs +15 -14
- package/dist/fhe-vesting/advanced/react/index.d.cts +1 -1
- package/dist/fhe-vesting/advanced/react/index.d.ts +1 -1
- package/dist/fhe-vesting/advanced/react/index.js +12 -11
- package/dist/fhe-vesting/encryption.d.ts +8 -0
- package/dist/fhe-vesting/factory.d.ts +6 -8
- package/dist/fhe-vesting/index.cjs +79 -75
- package/dist/fhe-vesting/index.d.cts +2 -2
- package/dist/fhe-vesting/index.d.ts +2 -2
- package/dist/fhe-vesting/index.js +9 -9
- package/dist/fhe-vesting/manager.d.ts +101 -3
- package/dist/fhe-vesting/react/index.cjs +241 -219
- 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 +29 -12
- package/dist/fhe-vesting/react/useAdminClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useCreateVesting.d.ts +8 -0
- package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +7 -1
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/usePreflightCreateVesting.d.ts +37 -0
- package/dist/fhe-vesting/react/useVestingClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +6 -0
- package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-vesting/types.d.ts +34 -2
- package/dist/index.cjs +73 -49
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/testnet-faucet/abis/confidential-test-token.d.ts +1039 -0
- package/dist/testnet-faucet/abis/index.d.ts +2 -0
- package/dist/testnet-faucet/abis/test-token.d.ts +253 -0
- package/dist/testnet-faucet/errors.d.ts +21 -0
- package/dist/testnet-faucet/faucet.d.ts +173 -0
- package/dist/testnet-faucet/index.cjs +212 -0
- package/dist/testnet-faucet/index.d.cts +8 -0
- package/dist/testnet-faucet/index.d.ts +8 -0
- package/dist/testnet-faucet/index.js +7 -0
- package/dist/testnet-faucet/react/_shared.d.ts +61 -0
- package/dist/testnet-faucet/react/index.cjs +384 -0
- package/dist/testnet-faucet/react/index.d.cts +39 -0
- package/dist/testnet-faucet/react/index.d.ts +39 -0
- package/dist/testnet-faucet/react/index.js +220 -0
- package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +25 -0
- package/dist/testnet-faucet/react/useFaucetDecimals.d.ts +9 -0
- package/dist/testnet-faucet/react/useFaucetMetadata.d.ts +14 -0
- package/dist/testnet-faucet/react/useFaucetRate.d.ts +11 -0
- package/dist/testnet-faucet/react/useInferredTotalSupply.d.ts +11 -0
- package/dist/testnet-faucet/react/useMaxTotalSupply.d.ts +10 -0
- package/dist/testnet-faucet/react/useMintConfidential.d.ts +35 -0
- package/dist/testnet-faucet/react/useMintUnderlying.d.ts +31 -0
- package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +19 -0
- package/dist/testnet-faucet/react/useUnderlyingDecimals.d.ts +9 -0
- package/dist/testnet-faucet/react/useUnderlyingTokenAddress.d.ts +12 -0
- package/dist/testnet-faucet/types.d.ts +92 -0
- package/dist/testnet-faucet/validate.d.ts +44 -0
- package/package.json +79 -30
|
@@ -208,6 +208,23 @@ var AccessDeniedError = class extends TokenOpsSdkError {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
|
+
var OPERATOR_NOT_APPROVED_REMEDIATION = "The token has not approved this contract as an operator. Call `setOperator()` (see `/fhe` operators) before this transaction.";
|
|
212
|
+
var OperatorNotApprovedError = class extends TokenOpsSdkError {
|
|
213
|
+
name = "OperatorNotApprovedError";
|
|
214
|
+
constructor(args) {
|
|
215
|
+
super(OPERATOR_NOT_APPROVED_REMEDIATION, {
|
|
216
|
+
code: "TOKENOPS_OPERATOR_NOT_APPROVED",
|
|
217
|
+
cause: args.cause,
|
|
218
|
+
context: {
|
|
219
|
+
method: args.method,
|
|
220
|
+
contractAddress: args.contractAddress,
|
|
221
|
+
tokenAddress: args.tokenAddress,
|
|
222
|
+
holder: args.holder,
|
|
223
|
+
spender: args.spender
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
};
|
|
211
228
|
var InsufficientFeeError = class extends TokenOpsSdkError {
|
|
212
229
|
name = "InsufficientFeeError";
|
|
213
230
|
constructor(args) {
|
|
@@ -497,6 +514,8 @@ exports.MissingEncryptorError = MissingEncryptorError;
|
|
|
497
514
|
exports.MissingPublicClientError = MissingPublicClientError;
|
|
498
515
|
exports.MissingWalletClientError = MissingWalletClientError;
|
|
499
516
|
exports.NetworkError = NetworkError;
|
|
517
|
+
exports.OPERATOR_NOT_APPROVED_REMEDIATION = OPERATOR_NOT_APPROVED_REMEDIATION;
|
|
518
|
+
exports.OperatorNotApprovedError = OperatorNotApprovedError;
|
|
500
519
|
exports.PausedError = PausedError;
|
|
501
520
|
exports.ReceiptEventAmbiguousError = ReceiptEventAmbiguousError;
|
|
502
521
|
exports.ReceiptEventNotFoundError = ReceiptEventNotFoundError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { normaliseAddress } from './chunk-
|
|
1
|
+
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
2
2
|
import { withTelemetry } from './chunk-Q2GP5UDC.js';
|
|
3
|
-
import { TokenOpsContractError } from './chunk-
|
|
3
|
+
import { TokenOpsContractError } from './chunk-QBJ7O2B4.js';
|
|
4
4
|
|
|
5
5
|
// src/fhe/operators.ts
|
|
6
6
|
var ERC7984_SET_OPERATOR_ABI = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-
|
|
2
|
-
import { SDK_VERSION, mapContractRevert, isContractRevert } from './chunk-
|
|
1
|
+
import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-ZWXJTBZO.js';
|
|
2
|
+
import { SDK_VERSION, mapContractRevert, isContractRevert } from './chunk-SG65XWH7.js';
|
|
3
3
|
import { withTelemetry } from './chunk-Q2GP5UDC.js';
|
|
4
|
-
import { TokenOpsSdkError, PausedError, InsufficientFeeError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, InvalidArgumentError, MissingWalletClientError, MissingAccountError, InsufficientBalanceError, InvalidSignatureError } from './chunk-
|
|
4
|
+
import { TokenOpsSdkError, PausedError, InsufficientFeeError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, InvalidArgumentError, MissingWalletClientError, MissingAccountError, InsufficientBalanceError, InvalidSignatureError } from './chunk-QBJ7O2B4.js';
|
|
5
5
|
import { parseEventLogs, isAddress } from 'viem';
|
|
6
6
|
|
|
7
7
|
// src/fhe-airdrop/abis/cloneable.ts
|
|
@@ -1358,6 +1358,8 @@ var ConfidentialAirdropClient = class {
|
|
|
1358
1358
|
* {@link signClaimAuthorization}. The signature commits to that handle, so the SDK
|
|
1359
1359
|
* does NOT re-encrypt — submit the admin-issued payload as-is.
|
|
1360
1360
|
*
|
|
1361
|
+
* **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
|
|
1362
|
+
*
|
|
1361
1363
|
* @returns Transaction hash.
|
|
1362
1364
|
* @example
|
|
1363
1365
|
* const fee = await airdrop.gasFee();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkKLKI352M_cjs = require('./chunk-KLKI352M.cjs');
|
|
4
|
+
var chunkPUPKNW3R_cjs = require('./chunk-PUPKNW3R.cjs');
|
|
5
|
+
var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
|
|
6
6
|
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
7
7
|
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
9
9
|
var viem = require('viem');
|
|
10
10
|
|
|
11
11
|
// src/fhe-vesting/abis/factory.ts
|
|
@@ -444,10 +444,10 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
444
444
|
this.publicClient = config.publicClient;
|
|
445
445
|
this.walletClient = config.walletClient;
|
|
446
446
|
const chainId = config.chainId ?? config.publicClient.chain?.id;
|
|
447
|
-
const addressOverride = config.address ?
|
|
448
|
-
const resolved = addressOverride ?? (chainId === void 0 ? void 0 :
|
|
447
|
+
const addressOverride = config.address ? chunkJK4XMMKM_cjs.normaliseAddress(config.address) : void 0;
|
|
448
|
+
const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkPUPKNW3R_cjs.getFheVestingFactoryAddress(chainId));
|
|
449
449
|
if (!resolved) {
|
|
450
|
-
throw new
|
|
450
|
+
throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
451
451
|
reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
|
|
452
452
|
product: "fheVesting",
|
|
453
453
|
contract: "confidentialVestingFactory",
|
|
@@ -463,7 +463,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
463
463
|
hasWallet: !!this.walletClient,
|
|
464
464
|
aclResolved: true,
|
|
465
465
|
// factory has no ACL dependency; constant for funnel-shape parity with manager.
|
|
466
|
-
sdkVersion:
|
|
466
|
+
sdkVersion: chunkKLKI352M_cjs.SDK_VERSION
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
469
|
// ----------------------- writes -----------------------
|
|
@@ -471,11 +471,10 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
471
471
|
* Deploy a new `ConfidentialVestingManager` clone via the factory and return
|
|
472
472
|
* its address, parsed from the `ManagerCreated` event in the tx receipt.
|
|
473
473
|
*
|
|
474
|
-
* **This is the headline factory entry point.**
|
|
475
|
-
*
|
|
476
|
-
* the address is only knowable after the tx mines (the factory packs
|
|
474
|
+
* **This is the headline factory entry point.** It returns one rich-return
|
|
475
|
+
* shape: the address is only knowable after the tx mines (the factory packs
|
|
477
476
|
* `block.number` into the clone's immutable args), so a hash-only variant
|
|
478
|
-
*
|
|
477
|
+
* would force consumers to re-derive what the SDK already had to compute.
|
|
479
478
|
*
|
|
480
479
|
* Calls `createManagerWithOptions` when `splitEnabled` or `pausableEnabled`
|
|
481
480
|
* is provided; otherwise calls the simpler `createManager` entry point.
|
|
@@ -596,9 +595,8 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
596
595
|
* Alias for {@link ConfidentialVestingFactoryClient.implementation} that matches
|
|
597
596
|
* the contract's storage field name (`_managerImplementation`).
|
|
598
597
|
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
* server devs reading the Solidity reach for `factory.managerImplementation()`
|
|
598
|
+
* Named for clarity: server devs reading the Solidity reach for
|
|
599
|
+
* `factory.managerImplementation()`
|
|
602
600
|
* via autocomplete (the contract storage slot name) and hit a TS2551. The
|
|
603
601
|
* canonical `implementation()` method is retained for backwards-compat and
|
|
604
602
|
* cross-factory uniformity (fhe-airdrop exposes the same shape).
|
|
@@ -655,12 +653,12 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
655
653
|
});
|
|
656
654
|
const ours = events.filter((ev) => ev.address.toLowerCase() === this.address.toLowerCase());
|
|
657
655
|
if (ours.length === 0) {
|
|
658
|
-
throw new
|
|
656
|
+
throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
|
|
659
657
|
`${method}: no ManagerCreated event from factory ${this.address} in tx ${hash}`
|
|
660
658
|
);
|
|
661
659
|
}
|
|
662
660
|
if (ours.length > 1) {
|
|
663
|
-
throw new
|
|
661
|
+
throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
|
|
664
662
|
`${method}: ${ours.length} ManagerCreated events from factory ${this.address} in tx ${hash}; ambiguous result`
|
|
665
663
|
);
|
|
666
664
|
}
|
|
@@ -668,7 +666,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
668
666
|
}
|
|
669
667
|
#requireWallet(method) {
|
|
670
668
|
if (!this.walletClient) {
|
|
671
|
-
throw new
|
|
669
|
+
throw new chunk67OV5CX2_cjs.MissingWalletClientError(method);
|
|
672
670
|
}
|
|
673
671
|
return this.walletClient;
|
|
674
672
|
}
|
|
@@ -676,7 +674,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
676
674
|
const wallet = this.#requireWallet(functionName);
|
|
677
675
|
const acct = account ?? wallet.account;
|
|
678
676
|
if (!acct) {
|
|
679
|
-
throw new
|
|
677
|
+
throw new chunk67OV5CX2_cjs.MissingAccountError(String(functionName));
|
|
680
678
|
}
|
|
681
679
|
await this.#preflightWrite(String(functionName), functionName, args, acct);
|
|
682
680
|
try {
|
|
@@ -693,7 +691,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
693
691
|
}
|
|
694
692
|
}
|
|
695
693
|
#mapRevert(method, err, account) {
|
|
696
|
-
return
|
|
694
|
+
return chunkKLKI352M_cjs.mapContractRevert(err, {
|
|
697
695
|
method,
|
|
698
696
|
contractAddress: this.address,
|
|
699
697
|
abi: confidentialVestingFactoryAbi,
|
|
@@ -718,7 +716,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
718
716
|
...value !== void 0 ? { value } : {}
|
|
719
717
|
});
|
|
720
718
|
} catch (err) {
|
|
721
|
-
if (
|
|
719
|
+
if (chunkKLKI352M_cjs.isContractRevert(err)) {
|
|
722
720
|
throw this.#mapRevert(method, err, accountAddress(account));
|
|
723
721
|
}
|
|
724
722
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { erc7984OperatorAbi } from './chunk-7VELUOMI.js';
|
|
2
|
+
import { SDK_VERSION, mapContractRevert, isContractRevert } from './chunk-SG65XWH7.js';
|
|
3
|
+
import { getFheAirdropFactoryAddress } from './chunk-XGGTQQFH.js';
|
|
4
|
+
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
4
5
|
import { withTelemetry } from './chunk-Q2GP5UDC.js';
|
|
5
6
|
import { asExternalInputProof, asEncryptedHandle, asSignature, asTxHash } from './chunk-KWFFIJYX.js';
|
|
6
|
-
import { InvalidArgumentError, TokenOpsSdkError, MissingAccountError, DeploymentAddressUnavailableError, MissingWalletClientError, MissingEncryptorError } from './chunk-
|
|
7
|
-
import { bytesToHex, parseEventLogs } from 'viem';
|
|
7
|
+
import { InvalidArgumentError, TokenOpsSdkError, MissingAccountError, DeploymentAddressUnavailableError, OperatorNotApprovedError, AlreadyInitializedError, MissingWalletClientError, MissingEncryptorError } from './chunk-QBJ7O2B4.js';
|
|
8
|
+
import { bytesToHex, isAddress, parseEventLogs } from 'viem';
|
|
8
9
|
|
|
9
10
|
// src/fhe-airdrop/abis/factory.ts
|
|
10
11
|
var confidentialAirdropFactoryAbi = [
|
|
@@ -1077,11 +1078,10 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1077
1078
|
* Deploy a new airdrop clone via the factory and return its address, parsed
|
|
1078
1079
|
* from the `ConfidentialAirdropCreated` event in the tx receipt.
|
|
1079
1080
|
*
|
|
1080
|
-
* **This is the headline factory entry point.**
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
1084
|
-
* themselves.
|
|
1081
|
+
* **This is the headline factory entry point.** It returns one rich-return
|
|
1082
|
+
* shape: most consumers want the deployed address back, and the SDK already
|
|
1083
|
+
* waits for and parses the event, so there's no reason to make consumers do
|
|
1084
|
+
* it themselves.
|
|
1085
1085
|
*
|
|
1086
1086
|
* Internally: `writeContract` → {@link PublicClient.waitForTransactionReceipt} →
|
|
1087
1087
|
* `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
|
|
@@ -1117,9 +1117,17 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1117
1117
|
* Prerequisites: caller must have set this factory as an operator on the
|
|
1118
1118
|
* token: `token.setOperator(factoryAddress, deadline)`.
|
|
1119
1119
|
*
|
|
1120
|
+
* **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
|
|
1121
|
+
*
|
|
1122
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1123
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1124
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1125
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1126
|
+
* transparent TTT test token uses 18 decimals.
|
|
1127
|
+
*
|
|
1120
1128
|
* Symmetric with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdrop}
|
|
1121
1129
|
* — both return `{ hash, airdrop }` parsed from the
|
|
1122
|
-
* `ConfidentialAirdropCreated` event
|
|
1130
|
+
* `ConfidentialAirdropCreated` event.
|
|
1123
1131
|
*
|
|
1124
1132
|
* @example
|
|
1125
1133
|
* const { hash, airdrop } = await factory.createAndFundConfidentialAirdrop({
|
|
@@ -1179,6 +1187,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1179
1187
|
* Prerequisites: caller must have set this factory as an operator on the token:
|
|
1180
1188
|
* `token.setOperator(factoryAddress, deadline)`
|
|
1181
1189
|
*
|
|
1190
|
+
* **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
|
|
1191
|
+
*
|
|
1192
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1193
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1194
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1195
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1196
|
+
* transparent TTT test token uses 18 decimals.
|
|
1197
|
+
*
|
|
1182
1198
|
* @returns Transaction hash.
|
|
1183
1199
|
*/
|
|
1184
1200
|
async fundConfidentialAirdrop(args) {
|
|
@@ -1248,6 +1264,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1248
1264
|
* Symmetry with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdropAndGetAddress}
|
|
1249
1265
|
* — use this when you also need to seed the pool in the same transaction.
|
|
1250
1266
|
*
|
|
1267
|
+
* **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
|
|
1268
|
+
*
|
|
1269
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1270
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1271
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1272
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1273
|
+
* transparent TTT test token uses 18 decimals.
|
|
1274
|
+
*
|
|
1251
1275
|
* Internally: {@link ConfidentialAirdropFactoryClient.createAndFundConfidentialAirdrop} →
|
|
1252
1276
|
* {@link PublicClient.waitForTransactionReceipt} →
|
|
1253
1277
|
* `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
|
|
@@ -1294,9 +1318,8 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1294
1318
|
* Alias for {@link ConfidentialAirdropFactoryClient.implementation} that matches
|
|
1295
1319
|
* the contract's storage field name (`_airdropImplementation`).
|
|
1296
1320
|
*
|
|
1297
|
-
*
|
|
1298
|
-
*
|
|
1299
|
-
* backend-integrator-r14 minor). The airdrop factory has the same
|
|
1321
|
+
* Provided for parity with `fhe-vesting`'s `managerImplementation()` alias.
|
|
1322
|
+
* The airdrop factory has the same
|
|
1300
1323
|
* LibClone shape mirroring `_airdropImplementation` storage, so server
|
|
1301
1324
|
* devs reading the Solidity first reach for `factory.airdropImplementation()`
|
|
1302
1325
|
* via autocomplete and would otherwise hit a TS2551 on the SDK's
|
|
@@ -1331,6 +1354,149 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1331
1354
|
async getInitCodeHash(args) {
|
|
1332
1355
|
return this.#read("getInitCodeHash", [toAbiParams(args.params), args.gasFee]);
|
|
1333
1356
|
}
|
|
1357
|
+
// ----------------------- preflight -----------------------
|
|
1358
|
+
/**
|
|
1359
|
+
* Read-only preflight for {@link createConfidentialAirdrop} /
|
|
1360
|
+
* {@link createAndFundConfidentialAirdrop}. Runs the
|
|
1361
|
+
* deterministic-from-off-chain checks and reports blockers both as
|
|
1362
|
+
* human-readable strings (`blockers`) and as typed {@link TokenOpsSdkError}s
|
|
1363
|
+
* (`blockerErrors`), index-aligned.
|
|
1364
|
+
*
|
|
1365
|
+
* Preflight is **opt-in**. Consumers who have already validated state can
|
|
1366
|
+
* skip this call and invoke the write directly — they'll receive the same
|
|
1367
|
+
* typed errors at write time via the revert mapper.
|
|
1368
|
+
*
|
|
1369
|
+
* Report fields: `isFactoryOperator`, `gasFee`, `predictedAirdrop`,
|
|
1370
|
+
* `alreadyDeployed`, `ready`, `blockers`, `blockerErrors` — see
|
|
1371
|
+
* {@link CreateAirdropPreflightReport} for the meaning of each.
|
|
1372
|
+
*
|
|
1373
|
+
* Checks performed (all read-only, no gas):
|
|
1374
|
+
* - Structural `params` validation mirroring the factory + clone
|
|
1375
|
+
* `initialize` requirements (`InvalidArgumentError` blockers): `token` and
|
|
1376
|
+
* `admin` are checksummed non-zero addresses,
|
|
1377
|
+
* `startTimestamp < endTimestamp`, and `endTimestamp` is in the future
|
|
1378
|
+
* (the clone's `initialize` reverts with `EndTimeInPast`).
|
|
1379
|
+
* - Operator: creator has approved this factory as an ERC-7984 operator on
|
|
1380
|
+
* `params.token` — a blocker only when `funding: true`
|
|
1381
|
+
* ({@link OperatorNotApprovedError}); otherwise informational via
|
|
1382
|
+
* `isFactoryOperator`.
|
|
1383
|
+
* - Collision (only when `userSalt` is supplied): bytecode already at the
|
|
1384
|
+
* predicted CREATE2 address means a repeat create with the same
|
|
1385
|
+
* `(params, userSalt, gasFee)` would revert
|
|
1386
|
+
* ({@link AlreadyInitializedError} blocker).
|
|
1387
|
+
*
|
|
1388
|
+
* **Not preflight-detectable — read before trusting `ready: true`:** the
|
|
1389
|
+
* creator's confidential token balance is an encrypted `euint64` the SDK
|
|
1390
|
+
* cannot read in plaintext, and an underfunded `createAndFund` does **not**
|
|
1391
|
+
* revert — the ERC-7984 transfer silently moves an encrypted zero. Confirm
|
|
1392
|
+
* the creator's balance covers the pool before submitting.
|
|
1393
|
+
*
|
|
1394
|
+
* @param args See {@link PreflightCreateAirdropArgs}.
|
|
1395
|
+
* @returns A {@link CreateAirdropPreflightReport}.
|
|
1396
|
+
*/
|
|
1397
|
+
async preflightCreateAirdrop(args) {
|
|
1398
|
+
const { params, creator, userSalt, funding } = args;
|
|
1399
|
+
const blockers = [];
|
|
1400
|
+
const blockerErrors = [];
|
|
1401
|
+
const pushBlocker = (err) => {
|
|
1402
|
+
blockerErrors.push(err);
|
|
1403
|
+
blockers.push(err.message);
|
|
1404
|
+
};
|
|
1405
|
+
const tokenOk = isAddress(params.token, { strict: true }) && params.token !== ZERO_ADDRESS;
|
|
1406
|
+
if (!tokenOk) {
|
|
1407
|
+
pushBlocker(
|
|
1408
|
+
new InvalidArgumentError({
|
|
1409
|
+
method: "createConfidentialAirdrop",
|
|
1410
|
+
argument: "params.token",
|
|
1411
|
+
reason: "must be a valid, non-zero EIP-55 checksummed address",
|
|
1412
|
+
value: params.token
|
|
1413
|
+
})
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
const adminOk = isAddress(params.admin, { strict: true }) && params.admin !== ZERO_ADDRESS;
|
|
1417
|
+
if (!adminOk) {
|
|
1418
|
+
pushBlocker(
|
|
1419
|
+
new InvalidArgumentError({
|
|
1420
|
+
method: "createConfidentialAirdrop",
|
|
1421
|
+
argument: "params.admin",
|
|
1422
|
+
reason: "must be a valid, non-zero EIP-55 checksummed address",
|
|
1423
|
+
value: params.admin
|
|
1424
|
+
})
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1427
|
+
if (params.startTimestamp >= params.endTimestamp) {
|
|
1428
|
+
pushBlocker(
|
|
1429
|
+
new InvalidArgumentError({
|
|
1430
|
+
method: "createConfidentialAirdrop",
|
|
1431
|
+
argument: "params.startTimestamp/params.endTimestamp",
|
|
1432
|
+
reason: "startTimestamp must be strictly less than endTimestamp",
|
|
1433
|
+
value: { startTimestamp: params.startTimestamp, endTimestamp: params.endTimestamp }
|
|
1434
|
+
})
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1437
|
+
const [block, customFee, defaultFee, isFactoryOperator] = await Promise.all([
|
|
1438
|
+
this.publicClient.getBlock(),
|
|
1439
|
+
this.getCustomFee(creator),
|
|
1440
|
+
this.defaultGasFee(),
|
|
1441
|
+
tokenOk ? this.publicClient.readContract({
|
|
1442
|
+
address: params.token,
|
|
1443
|
+
abi: erc7984OperatorAbi,
|
|
1444
|
+
functionName: "isOperator",
|
|
1445
|
+
args: [creator, this.address]
|
|
1446
|
+
}) : Promise.resolve(false)
|
|
1447
|
+
]);
|
|
1448
|
+
const gasFee = customFee.enabled ? customFee.gasFee : defaultFee;
|
|
1449
|
+
if (params.endTimestamp <= Number(block.timestamp)) {
|
|
1450
|
+
pushBlocker(
|
|
1451
|
+
new InvalidArgumentError({
|
|
1452
|
+
method: "createConfidentialAirdrop",
|
|
1453
|
+
argument: "params.endTimestamp",
|
|
1454
|
+
reason: "must be in the future (the clone's initialize reverts with EndTimeInPast)",
|
|
1455
|
+
value: params.endTimestamp
|
|
1456
|
+
})
|
|
1457
|
+
);
|
|
1458
|
+
}
|
|
1459
|
+
if (funding === true && !isFactoryOperator) {
|
|
1460
|
+
pushBlocker(
|
|
1461
|
+
new OperatorNotApprovedError({
|
|
1462
|
+
method: "createAndFundConfidentialAirdrop",
|
|
1463
|
+
contractAddress: this.address,
|
|
1464
|
+
tokenAddress: params.token,
|
|
1465
|
+
holder: creator,
|
|
1466
|
+
spender: this.address
|
|
1467
|
+
})
|
|
1468
|
+
);
|
|
1469
|
+
}
|
|
1470
|
+
let predictedAirdrop;
|
|
1471
|
+
let alreadyDeployed;
|
|
1472
|
+
if (userSalt !== void 0 && tokenOk && adminOk) {
|
|
1473
|
+
predictedAirdrop = await this.#read("predictAirdropAddress", [
|
|
1474
|
+
toAbiParams(params),
|
|
1475
|
+
userSalt,
|
|
1476
|
+
creator,
|
|
1477
|
+
gasFee
|
|
1478
|
+
]);
|
|
1479
|
+
const bytecode = await this.publicClient.getCode({ address: predictedAirdrop });
|
|
1480
|
+
alreadyDeployed = bytecode !== void 0 && bytecode !== "0x";
|
|
1481
|
+
if (alreadyDeployed) {
|
|
1482
|
+
pushBlocker(
|
|
1483
|
+
new AlreadyInitializedError({
|
|
1484
|
+
method: "createConfidentialAirdrop",
|
|
1485
|
+
contractAddress: predictedAirdrop
|
|
1486
|
+
})
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
return {
|
|
1491
|
+
isFactoryOperator,
|
|
1492
|
+
gasFee,
|
|
1493
|
+
predictedAirdrop,
|
|
1494
|
+
alreadyDeployed,
|
|
1495
|
+
ready: blockers.length === 0,
|
|
1496
|
+
blockers,
|
|
1497
|
+
blockerErrors
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1334
1500
|
// ----------------------- internals -----------------------
|
|
1335
1501
|
/**
|
|
1336
1502
|
* Wait for the receipt of a clone-deploy tx and parse the
|
|
@@ -1472,6 +1638,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1472
1638
|
function createConfidentialAirdropFactoryClient(config) {
|
|
1473
1639
|
return new ConfidentialAirdropFactoryClient(config);
|
|
1474
1640
|
}
|
|
1641
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
1475
1642
|
function accountAddress(account) {
|
|
1476
1643
|
return typeof account === "string" ? account : account.address;
|
|
1477
1644
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
4
4
|
var viem = require('viem');
|
|
5
5
|
|
|
6
6
|
var FHEVM_ACL_ADDRESS_BY_CHAIN = {
|
|
@@ -16,7 +16,7 @@ function getFhevmAclAddress(chainId) {
|
|
|
16
16
|
}
|
|
17
17
|
function requireFhevmAclAddress(chainId, clientLabel) {
|
|
18
18
|
if (chainId === void 0) {
|
|
19
|
-
throw new
|
|
19
|
+
throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
20
20
|
reason: "chain-id-missing",
|
|
21
21
|
product: "fhevm",
|
|
22
22
|
contract: "acl",
|
|
@@ -26,7 +26,7 @@ function requireFhevmAclAddress(chainId, clientLabel) {
|
|
|
26
26
|
}
|
|
27
27
|
const addr = FHEVM_ACL_ADDRESS_BY_CHAIN[chainId];
|
|
28
28
|
if (addr) return addr;
|
|
29
|
-
throw new
|
|
29
|
+
throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
30
30
|
reason: "registry-unknown-chain",
|
|
31
31
|
product: "fhevm",
|
|
32
32
|
contract: "acl",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as wagmi from 'wagmi';
|
|
2
|
+
|
|
3
|
+
// src/core/wagmi-compat.ts
|
|
4
|
+
var wagmiModule = wagmi;
|
|
5
|
+
var useWagmiAccount = wagmiModule.useConnection ?? wagmiModule.useAccount ?? (() => {
|
|
6
|
+
throw new Error(
|
|
7
|
+
"@tokenops/sdk: the installed `wagmi` package exposes neither `useConnection` (v3) nor `useAccount` (v2). Install wagmi ^2.0.0 or ^3.0.0 \u2014 the SDK's /react subpaths support both majors."
|
|
8
|
+
);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export { useWagmiAccount };
|