@tokenops/sdk 1.1.1 → 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 +18 -8
- package/dist/{chunk-5SGMJADP.cjs → chunk-2NCLOQ56.cjs} +9 -9
- package/dist/{chunk-FXCW7LVB.js → chunk-2PWNH3UE.js} +35 -6
- package/dist/{chunk-FPQBFIUW.cjs → chunk-4WPGQSNT.cjs} +3 -3
- package/dist/{chunk-OYLZEEHF.cjs → chunk-5X5WL5CU.cjs} +265 -101
- 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-SAGJIEQK.cjs → chunk-C7BRZXJA.cjs} +14 -14
- package/dist/{chunk-OQZAZIAS.js → chunk-DUZIIRPF.js} +174 -5
- package/dist/{chunk-Q7ARQSUH.cjs → chunk-FAXIIH5R.cjs} +3 -3
- package/dist/chunk-FT4LNBOS.js +11 -0
- package/dist/{chunk-QE7ZONJ2.js → chunk-IJFQ5L4I.js} +4 -4
- package/dist/{chunk-X56UVEXS.js → chunk-IXLO7GO5.js} +209 -45
- 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-3PQ2RFPC.js → chunk-NTZY6IB7.js} +4 -4
- package/dist/{chunk-JJ4R5QXF.js → chunk-ODLTEGHB.js} +1 -1
- package/dist/{chunk-XWDVPV42.js → chunk-ORFTDNFZ.js} +4 -4
- package/dist/{chunk-IR5AK5U5.js → chunk-OXTLPTO3.js} +4 -4
- package/dist/{chunk-23F7JIK5.cjs → chunk-PFXURMBZ.cjs} +77 -48
- package/dist/{chunk-3ZRHDTEX.cjs → chunk-PUPKNW3R.cjs} +2 -2
- package/dist/{chunk-IVE3QEGD.js → chunk-QBJ7O2B4.js} +18 -1
- package/dist/{chunk-JFLEEXKP.js → chunk-SG65XWH7.js} +58 -2
- package/dist/{chunk-G7G75C46.cjs → chunk-T46YXSBP.cjs} +11 -11
- package/dist/{chunk-NS44KBV5.cjs → chunk-TEBM66WA.cjs} +12 -12
- package/dist/{chunk-SYHXDHWX.cjs → chunk-TIUKIY5V.cjs} +193 -24
- package/dist/{chunk-W7JHOK7G.cjs → chunk-V2PXZVBF.cjs} +4 -4
- package/dist/{chunk-SEKC7H5Y.cjs → chunk-W7IGCOVL.cjs} +11 -11
- package/dist/{chunk-5KHIQG7Y.cjs → chunk-WENHUPZC.cjs} +31 -31
- package/dist/{chunk-ZXCOJY2Z.js → chunk-WMACINXO.js} +1 -1
- package/dist/{chunk-M7V2EDPB.js → chunk-XGGTQQFH.js} +1 -1
- package/dist/{chunk-ITQBDRWX.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/errors.d.ts +41 -1
- package/dist/core/revert-mapper.d.ts +77 -0
- 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/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/index.cjs +9 -8
- 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.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 +86 -1
- 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 +6 -0
- 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/index.cjs +8 -8
- 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.js +12 -11
- package/dist/fhe-vesting/encryption.d.ts +8 -0
- 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 +100 -1
- 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 +6 -0
- 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 -0
- package/dist/index.cjs +61 -53
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/testnet-faucet/index.cjs +58 -54
- package/dist/testnet-faucet/index.d.cts +1 -1
- package/dist/testnet-faucet/index.d.ts +1 -1
- package/dist/testnet-faucet/index.js +5 -5
- package/dist/testnet-faucet/react/index.cjs +60 -55
- package/dist/testnet-faucet/react/index.d.cts +3 -2
- package/dist/testnet-faucet/react/index.d.ts +3 -2
- package/dist/testnet-faucet/react/index.js +11 -10
- package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +3 -2
- package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +2 -2
- package/package.json +3 -2
|
@@ -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 -----------------------
|
|
@@ -653,12 +653,12 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
653
653
|
});
|
|
654
654
|
const ours = events.filter((ev) => ev.address.toLowerCase() === this.address.toLowerCase());
|
|
655
655
|
if (ours.length === 0) {
|
|
656
|
-
throw new
|
|
656
|
+
throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
|
|
657
657
|
`${method}: no ManagerCreated event from factory ${this.address} in tx ${hash}`
|
|
658
658
|
);
|
|
659
659
|
}
|
|
660
660
|
if (ours.length > 1) {
|
|
661
|
-
throw new
|
|
661
|
+
throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
|
|
662
662
|
`${method}: ${ours.length} ManagerCreated events from factory ${this.address} in tx ${hash}; ambiguous result`
|
|
663
663
|
);
|
|
664
664
|
}
|
|
@@ -666,7 +666,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
666
666
|
}
|
|
667
667
|
#requireWallet(method) {
|
|
668
668
|
if (!this.walletClient) {
|
|
669
|
-
throw new
|
|
669
|
+
throw new chunk67OV5CX2_cjs.MissingWalletClientError(method);
|
|
670
670
|
}
|
|
671
671
|
return this.walletClient;
|
|
672
672
|
}
|
|
@@ -674,7 +674,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
674
674
|
const wallet = this.#requireWallet(functionName);
|
|
675
675
|
const acct = account ?? wallet.account;
|
|
676
676
|
if (!acct) {
|
|
677
|
-
throw new
|
|
677
|
+
throw new chunk67OV5CX2_cjs.MissingAccountError(String(functionName));
|
|
678
678
|
}
|
|
679
679
|
await this.#preflightWrite(String(functionName), functionName, args, acct);
|
|
680
680
|
try {
|
|
@@ -691,7 +691,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
#mapRevert(method, err, account) {
|
|
694
|
-
return
|
|
694
|
+
return chunkKLKI352M_cjs.mapContractRevert(err, {
|
|
695
695
|
method,
|
|
696
696
|
contractAddress: this.address,
|
|
697
697
|
abi: confidentialVestingFactoryAbi,
|
|
@@ -716,7 +716,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
716
716
|
...value !== void 0 ? { value } : {}
|
|
717
717
|
});
|
|
718
718
|
} catch (err) {
|
|
719
|
-
if (
|
|
719
|
+
if (chunkKLKI352M_cjs.isContractRevert(err)) {
|
|
720
720
|
throw this.#mapRevert(method, err, accountAddress(account));
|
|
721
721
|
}
|
|
722
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 = [
|
|
@@ -1116,6 +1117,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1116
1117
|
* Prerequisites: caller must have set this factory as an operator on the
|
|
1117
1118
|
* token: `token.setOperator(factoryAddress, deadline)`.
|
|
1118
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
|
+
*
|
|
1119
1128
|
* Symmetric with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdrop}
|
|
1120
1129
|
* — both return `{ hash, airdrop }` parsed from the
|
|
1121
1130
|
* `ConfidentialAirdropCreated` event.
|
|
@@ -1178,6 +1187,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1178
1187
|
* Prerequisites: caller must have set this factory as an operator on the token:
|
|
1179
1188
|
* `token.setOperator(factoryAddress, deadline)`
|
|
1180
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
|
+
*
|
|
1181
1198
|
* @returns Transaction hash.
|
|
1182
1199
|
*/
|
|
1183
1200
|
async fundConfidentialAirdrop(args) {
|
|
@@ -1247,6 +1264,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1247
1264
|
* Symmetry with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdropAndGetAddress}
|
|
1248
1265
|
* — use this when you also need to seed the pool in the same transaction.
|
|
1249
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
|
+
*
|
|
1250
1275
|
* Internally: {@link ConfidentialAirdropFactoryClient.createAndFundConfidentialAirdrop} →
|
|
1251
1276
|
* {@link PublicClient.waitForTransactionReceipt} →
|
|
1252
1277
|
* `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
|
|
@@ -1329,6 +1354,149 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1329
1354
|
async getInitCodeHash(args) {
|
|
1330
1355
|
return this.#read("getInitCodeHash", [toAbiParams(args.params), args.gasFee]);
|
|
1331
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
|
+
}
|
|
1332
1500
|
// ----------------------- internals -----------------------
|
|
1333
1501
|
/**
|
|
1334
1502
|
* Wait for the receipt of a clone-deploy tx and parse the
|
|
@@ -1470,6 +1638,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1470
1638
|
function createConfidentialAirdropFactoryClient(config) {
|
|
1471
1639
|
return new ConfidentialAirdropFactoryClient(config);
|
|
1472
1640
|
}
|
|
1641
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
1473
1642
|
function accountAddress(account) {
|
|
1474
1643
|
return typeof account === "string" ? account : account.address;
|
|
1475
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 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SDK_VERSION, isContractRevert, mapContractRevert } from './chunk-
|
|
2
|
-
import { getConfidentialTestTokenAddress, getTestTokenAddress } from './chunk-
|
|
3
|
-
import { normaliseAddress } from './chunk-
|
|
1
|
+
import { SDK_VERSION, isContractRevert, mapContractRevert } from './chunk-SG65XWH7.js';
|
|
2
|
+
import { getConfidentialTestTokenAddress, getTestTokenAddress } from './chunk-XGGTQQFH.js';
|
|
3
|
+
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
4
4
|
import { withTelemetry } from './chunk-Q2GP5UDC.js';
|
|
5
5
|
import { asEncryptedHandle, asTxHash } from './chunk-KWFFIJYX.js';
|
|
6
|
-
import { TokenOpsSdkError, UnsupportedChainError, DeploymentAddressUnavailableError, TokenOpsContractError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, MissingWalletClientError, MissingAccountError, InvalidArgumentError } from './chunk-
|
|
6
|
+
import { TokenOpsSdkError, UnsupportedChainError, DeploymentAddressUnavailableError, TokenOpsContractError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, MissingWalletClientError, MissingAccountError, InvalidArgumentError } from './chunk-QBJ7O2B4.js';
|
|
7
7
|
import { sepolia } from 'viem/chains';
|
|
8
8
|
import { parseEventLogs } from 'viem';
|
|
9
9
|
|