@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
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { mapZamaError } from './chunk-
|
|
2
|
-
import { scaleRatio } from './chunk-
|
|
3
|
-
import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { mapZamaError } from './chunk-WMACINXO.js';
|
|
2
|
+
import { scaleRatio } from './chunk-AOP6HMPW.js';
|
|
3
|
+
import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-ZWXJTBZO.js';
|
|
4
|
+
import { erc7984OperatorAbi } from './chunk-7VELUOMI.js';
|
|
5
|
+
import { SDK_VERSION, mapContractRevert, isContractRevert } from './chunk-SG65XWH7.js';
|
|
6
|
+
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
6
7
|
import { withTelemetry } from './chunk-Q2GP5UDC.js';
|
|
7
8
|
import { asExternalInputProof, asEncryptedHandle, asTxHash } from './chunk-KWFFIJYX.js';
|
|
8
|
-
import { InvalidArgumentError, TokenOpsSdkError, PausedError, InsufficientFeeError, MissingEncryptorError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, MissingWalletClientError, MissingAccountError } from './chunk-
|
|
9
|
+
import { InvalidArgumentError, TokenOpsSdkError, PausedError, InsufficientFeeError, AccessDeniedError, OperatorNotApprovedError, MissingEncryptorError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, MissingWalletClientError, MissingAccountError } from './chunk-QBJ7O2B4.js';
|
|
9
10
|
import { bytesToHex, parseEventLogs, isAddress } from 'viem';
|
|
10
11
|
|
|
11
12
|
// src/fhe-vesting/abis/manager.ts
|
|
@@ -1398,8 +1399,7 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1398
1399
|
* Accepts `bigint | number` for `start` / `end` for ergonomics on read paths
|
|
1399
1400
|
* — CI scripts typically derive these from `Number(process.env.X)` and
|
|
1400
1401
|
* forcing bigint coercion at the call site is a pure paper cut. The
|
|
1401
|
-
* underlying contract reads through unchanged (viem coerces).
|
|
1402
|
-
* devops-integrator MINOR-4; R25 close.
|
|
1402
|
+
* underlying contract reads through unchanged (viem coerces).
|
|
1403
1403
|
*/
|
|
1404
1404
|
async getAllRecipientsSliced(start, end) {
|
|
1405
1405
|
return this.#read("getAllRecipientsSliced", [BigInt(start), BigInt(end)]);
|
|
@@ -1530,6 +1530,100 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1530
1530
|
}
|
|
1531
1531
|
return { ready: blockers.length === 0, blockers };
|
|
1532
1532
|
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Read-only preflight for {@link createVesting} / {@link batchCreateVesting}.
|
|
1535
|
+
* Runs the deterministic-from-off-chain checks and reports blockers both as
|
|
1536
|
+
* human-readable strings (`blockers`) and as typed {@link TokenOpsSdkError}s
|
|
1537
|
+
* (`blockerErrors`), index-aligned.
|
|
1538
|
+
*
|
|
1539
|
+
* Preflight is **opt-in**. Consumers who have already validated state can
|
|
1540
|
+
* skip this call and invoke the write directly — they'll receive the same
|
|
1541
|
+
* typed errors at write time via the revert mapper.
|
|
1542
|
+
*
|
|
1543
|
+
* Report fields: `token`, `hasCreatorRole`, `isOperatorSet`, `ready`,
|
|
1544
|
+
* `blockers`, `blockerErrors` — see {@link CreateVestingPreflightReport} for
|
|
1545
|
+
* the meaning of each.
|
|
1546
|
+
*
|
|
1547
|
+
* Checks performed (all read-only, no gas):
|
|
1548
|
+
* - Structural `params` validation mirroring the contract's
|
|
1549
|
+
* `_validateVestingParams` (`InvalidArgumentError` blockers): recipient is
|
|
1550
|
+
* a checksummed non-zero address, `startTimestamp < endTimestamp`, cliff
|
|
1551
|
+
* within the window, `initialUnlockBps + cliffAmountBps ≤ 10000`.
|
|
1552
|
+
* - Role: creator holds `VESTING_CREATOR_ROLE`
|
|
1553
|
+
* ({@link AccessDeniedError} blocker).
|
|
1554
|
+
* - Operator: creator has approved this manager as an ERC-7984 operator on
|
|
1555
|
+
* the distribution token, required for the manager's
|
|
1556
|
+
* `confidentialTransferFrom` pull ({@link OperatorNotApprovedError} blocker).
|
|
1557
|
+
*
|
|
1558
|
+
* **Not preflight-detectable — read before trusting `ready: true`:**
|
|
1559
|
+
* - The creator's confidential token balance is an encrypted `euint64` the
|
|
1560
|
+
* SDK cannot read in plaintext. An underfunded create does **not** revert:
|
|
1561
|
+
* the contract's all-or-nothing `FHE.select` pattern silently zeroes the
|
|
1562
|
+
* vesting amounts instead. Confirm the creator's balance covers the total
|
|
1563
|
+
* before submitting.
|
|
1564
|
+
* - `batchCreateVesting` additionally enforces `items.length ≤ maxBatchSize()`
|
|
1565
|
+
* on-chain; check {@link maxBatchSize} for batches.
|
|
1566
|
+
*
|
|
1567
|
+
* Pausing the manager does NOT block vesting creation (only claims), so
|
|
1568
|
+
* paused state is intentionally not a blocker here.
|
|
1569
|
+
*
|
|
1570
|
+
* @param args.params The vesting schedule parameters to validate.
|
|
1571
|
+
* @param args.creator The address that will send the create transaction.
|
|
1572
|
+
* @returns A {@link CreateVestingPreflightReport}.
|
|
1573
|
+
*/
|
|
1574
|
+
async preflightCreateVesting(args) {
|
|
1575
|
+
const blockers = [];
|
|
1576
|
+
const blockerErrors = [];
|
|
1577
|
+
const pushBlocker = (err) => {
|
|
1578
|
+
blockerErrors.push(err);
|
|
1579
|
+
blockers.push(err.message);
|
|
1580
|
+
};
|
|
1581
|
+
for (const err of collectVestingParamsErrors(args.params, "createVesting")) {
|
|
1582
|
+
pushBlocker(err);
|
|
1583
|
+
}
|
|
1584
|
+
const [token, creatorRole] = await Promise.all([
|
|
1585
|
+
this.token(),
|
|
1586
|
+
this.#read("VESTING_CREATOR_ROLE")
|
|
1587
|
+
]);
|
|
1588
|
+
const [hasCreatorRole, isOperatorSet] = await Promise.all([
|
|
1589
|
+
this.hasRole(creatorRole, args.creator),
|
|
1590
|
+
this.publicClient.readContract({
|
|
1591
|
+
address: token,
|
|
1592
|
+
abi: erc7984OperatorAbi,
|
|
1593
|
+
functionName: "isOperator",
|
|
1594
|
+
args: [args.creator, this.address]
|
|
1595
|
+
})
|
|
1596
|
+
]);
|
|
1597
|
+
if (!hasCreatorRole) {
|
|
1598
|
+
pushBlocker(
|
|
1599
|
+
new AccessDeniedError({
|
|
1600
|
+
method: "createVesting",
|
|
1601
|
+
contractAddress: this.address,
|
|
1602
|
+
account: args.creator,
|
|
1603
|
+
role: creatorRole
|
|
1604
|
+
})
|
|
1605
|
+
);
|
|
1606
|
+
}
|
|
1607
|
+
if (!isOperatorSet) {
|
|
1608
|
+
pushBlocker(
|
|
1609
|
+
new OperatorNotApprovedError({
|
|
1610
|
+
method: "createVesting",
|
|
1611
|
+
contractAddress: this.address,
|
|
1612
|
+
tokenAddress: token,
|
|
1613
|
+
holder: args.creator,
|
|
1614
|
+
spender: this.address
|
|
1615
|
+
})
|
|
1616
|
+
);
|
|
1617
|
+
}
|
|
1618
|
+
return {
|
|
1619
|
+
token,
|
|
1620
|
+
hasCreatorRole,
|
|
1621
|
+
isOperatorSet,
|
|
1622
|
+
ready: blockers.length === 0,
|
|
1623
|
+
blockers,
|
|
1624
|
+
blockerErrors
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1533
1627
|
// ============================================================
|
|
1534
1628
|
// ENCRYPTED VIEWS (TX)
|
|
1535
1629
|
// ============================================================
|
|
@@ -1595,6 +1689,14 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1595
1689
|
*
|
|
1596
1690
|
* Pass `encryptedInput` to bypass the encryptor when you manage encryption yourself.
|
|
1597
1691
|
*
|
|
1692
|
+
* **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.
|
|
1693
|
+
*
|
|
1694
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1695
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1696
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1697
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1698
|
+
* transparent TTT test token uses 18 decimals.
|
|
1699
|
+
*
|
|
1598
1700
|
* @returns Transaction hash. Parse the `VestingCreated` event to extract the `vestingId`.
|
|
1599
1701
|
* @example
|
|
1600
1702
|
* const hash = await manager.createVesting({
|
|
@@ -1636,6 +1738,14 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1636
1738
|
*
|
|
1637
1739
|
* Respects `maxBatchSize` — check before calling on large lists.
|
|
1638
1740
|
*
|
|
1741
|
+
* **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.
|
|
1742
|
+
*
|
|
1743
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1744
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1745
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1746
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1747
|
+
* transparent TTT test token uses 18 decimals.
|
|
1748
|
+
*
|
|
1639
1749
|
* @returns Transaction hash.
|
|
1640
1750
|
*/
|
|
1641
1751
|
async batchCreateVesting(args) {
|
|
@@ -1686,6 +1796,9 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1686
1796
|
/**
|
|
1687
1797
|
* Claim all currently vested tokens for `vestingId`.
|
|
1688
1798
|
* For `FeeType.Gas` managers, pass `value` (gas fee in wei from `getFeeInfo()`).
|
|
1799
|
+
*
|
|
1800
|
+
* **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.
|
|
1801
|
+
*
|
|
1689
1802
|
* @param args Discriminated by `feeType`: pass `{ feeType, vestingId, value }` for Gas, `{ feeType, vestingId }` for DistributionToken.
|
|
1690
1803
|
* @returns Transaction hash.
|
|
1691
1804
|
* @example
|
|
@@ -1714,6 +1827,9 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1714
1827
|
/**
|
|
1715
1828
|
* Admin variant of `claim` — callable by the manager admin on behalf of any recipient.
|
|
1716
1829
|
* Useful for gas-sponsored claim flows. Same fee rules as `claim`.
|
|
1830
|
+
*
|
|
1831
|
+
* **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.
|
|
1832
|
+
*
|
|
1717
1833
|
* @param args Same discriminated union as `claim`.
|
|
1718
1834
|
* @returns Transaction hash.
|
|
1719
1835
|
*/
|
|
@@ -1742,6 +1858,15 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1742
1858
|
/**
|
|
1743
1859
|
* Claim a specific encrypted amount from a vesting schedule rather than the full claimable balance.
|
|
1744
1860
|
* The SDK encrypts `amount` — pass plaintext. Alternatively pass `encryptedInput` to bypass encryption.
|
|
1861
|
+
*
|
|
1862
|
+
* **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.
|
|
1863
|
+
*
|
|
1864
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1865
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1866
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1867
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1868
|
+
* transparent TTT test token uses 18 decimals.
|
|
1869
|
+
*
|
|
1745
1870
|
* @param args Includes `vestingId`, `amount` or `encryptedInput`, and optional `value` for Gas-fee managers.
|
|
1746
1871
|
* @returns Transaction hash.
|
|
1747
1872
|
*/
|
|
@@ -1776,6 +1901,15 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1776
1901
|
}
|
|
1777
1902
|
/**
|
|
1778
1903
|
* Admin variant of `partialClaim` — callable by the manager admin on behalf of any recipient.
|
|
1904
|
+
*
|
|
1905
|
+
* **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.
|
|
1906
|
+
*
|
|
1907
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1908
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1909
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1910
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1911
|
+
* transparent TTT test token uses 18 decimals.
|
|
1912
|
+
*
|
|
1779
1913
|
* @param args Same as `partialClaim`.
|
|
1780
1914
|
* @returns Transaction hash.
|
|
1781
1915
|
*/
|
|
@@ -2165,6 +2299,13 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2165
2299
|
/**
|
|
2166
2300
|
* Withdraw a confidential token amount from the manager's balance back to the admin.
|
|
2167
2301
|
* The SDK encrypts `amount` — pass plaintext. Alternatively pass `encryptedInput`.
|
|
2302
|
+
*
|
|
2303
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
2304
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
2305
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
2306
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
2307
|
+
* transparent TTT test token uses 18 decimals.
|
|
2308
|
+
*
|
|
2168
2309
|
* @param args `{ amount }` (plaintext, SDK encrypts) or `{ encryptedInput }` (pre-encrypted).
|
|
2169
2310
|
* @returns Transaction hash.
|
|
2170
2311
|
*/
|
|
@@ -2221,6 +2362,13 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2221
2362
|
/**
|
|
2222
2363
|
* Withdraw accumulated token fees from a `FeeType.DistributionToken` manager. Admin only.
|
|
2223
2364
|
* The SDK encrypts `amount` — pass plaintext. Alternatively pass `encryptedInput`.
|
|
2365
|
+
*
|
|
2366
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
2367
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
2368
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
2369
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
2370
|
+
* transparent TTT test token uses 18 decimals.
|
|
2371
|
+
*
|
|
2224
2372
|
* @param args `{ to, amount }` (plaintext, SDK encrypts) or `{ to, encryptedInput }` (pre-encrypted).
|
|
2225
2373
|
* @returns Transaction hash.
|
|
2226
2374
|
*/
|
|
@@ -2634,45 +2782,8 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2634
2782
|
* than wait for the on-chain revert.
|
|
2635
2783
|
*/
|
|
2636
2784
|
#validateVestingParams(params, where) {
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
method: where,
|
|
2640
|
-
argument: "recipient",
|
|
2641
|
-
reason: "must be a valid EIP-55 checksummed address",
|
|
2642
|
-
value: params.recipient
|
|
2643
|
-
});
|
|
2644
|
-
}
|
|
2645
|
-
if (params.recipient === ZERO_ADDRESS) {
|
|
2646
|
-
throw new InvalidArgumentError({
|
|
2647
|
-
method: where,
|
|
2648
|
-
argument: "recipient",
|
|
2649
|
-
reason: "must not be the zero address"
|
|
2650
|
-
});
|
|
2651
|
-
}
|
|
2652
|
-
if (params.startTimestamp >= params.endTimestamp) {
|
|
2653
|
-
throw new InvalidArgumentError({
|
|
2654
|
-
method: where,
|
|
2655
|
-
argument: "startTimestamp/endTimestamp",
|
|
2656
|
-
reason: "startTimestamp must be strictly less than endTimestamp",
|
|
2657
|
-
value: { startTimestamp: params.startTimestamp, endTimestamp: params.endTimestamp }
|
|
2658
|
-
});
|
|
2659
|
-
}
|
|
2660
|
-
if (params.startTimestamp + params.cliffSeconds > params.endTimestamp) {
|
|
2661
|
-
throw new InvalidArgumentError({
|
|
2662
|
-
method: where,
|
|
2663
|
-
argument: "cliffSeconds",
|
|
2664
|
-
reason: "cliff cannot extend past endTimestamp",
|
|
2665
|
-
value: params.cliffSeconds
|
|
2666
|
-
});
|
|
2667
|
-
}
|
|
2668
|
-
if (params.initialUnlockBps + params.cliffAmountBps > 1e4) {
|
|
2669
|
-
throw new InvalidArgumentError({
|
|
2670
|
-
method: where,
|
|
2671
|
-
argument: "initialUnlockBps + cliffAmountBps",
|
|
2672
|
-
reason: "must be \u2264 10000 (100%)",
|
|
2673
|
-
value: { initialUnlockBps: params.initialUnlockBps, cliffAmountBps: params.cliffAmountBps }
|
|
2674
|
-
});
|
|
2675
|
-
}
|
|
2785
|
+
const [first] = collectVestingParamsErrors(params, where);
|
|
2786
|
+
if (first) throw first;
|
|
2676
2787
|
}
|
|
2677
2788
|
async #read(functionName, args = []) {
|
|
2678
2789
|
const result = await this.publicClient.readContract({
|
|
@@ -2751,5 +2862,57 @@ function accountAddress(account) {
|
|
|
2751
2862
|
return typeof account === "string" ? account : account.address;
|
|
2752
2863
|
}
|
|
2753
2864
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
2865
|
+
function collectVestingParamsErrors(params, where) {
|
|
2866
|
+
const errors = [];
|
|
2867
|
+
if (!isAddress(params.recipient, { strict: true })) {
|
|
2868
|
+
errors.push(
|
|
2869
|
+
new InvalidArgumentError({
|
|
2870
|
+
method: where,
|
|
2871
|
+
argument: "recipient",
|
|
2872
|
+
reason: "must be a valid EIP-55 checksummed address",
|
|
2873
|
+
value: params.recipient
|
|
2874
|
+
})
|
|
2875
|
+
);
|
|
2876
|
+
} else if (params.recipient === ZERO_ADDRESS) {
|
|
2877
|
+
errors.push(
|
|
2878
|
+
new InvalidArgumentError({
|
|
2879
|
+
method: where,
|
|
2880
|
+
argument: "recipient",
|
|
2881
|
+
reason: "must not be the zero address"
|
|
2882
|
+
})
|
|
2883
|
+
);
|
|
2884
|
+
}
|
|
2885
|
+
if (params.startTimestamp >= params.endTimestamp) {
|
|
2886
|
+
errors.push(
|
|
2887
|
+
new InvalidArgumentError({
|
|
2888
|
+
method: where,
|
|
2889
|
+
argument: "startTimestamp/endTimestamp",
|
|
2890
|
+
reason: "startTimestamp must be strictly less than endTimestamp",
|
|
2891
|
+
value: { startTimestamp: params.startTimestamp, endTimestamp: params.endTimestamp }
|
|
2892
|
+
})
|
|
2893
|
+
);
|
|
2894
|
+
}
|
|
2895
|
+
if (params.startTimestamp < params.endTimestamp && params.startTimestamp + params.cliffSeconds > params.endTimestamp) {
|
|
2896
|
+
errors.push(
|
|
2897
|
+
new InvalidArgumentError({
|
|
2898
|
+
method: where,
|
|
2899
|
+
argument: "cliffSeconds",
|
|
2900
|
+
reason: "cliff cannot extend past endTimestamp",
|
|
2901
|
+
value: params.cliffSeconds
|
|
2902
|
+
})
|
|
2903
|
+
);
|
|
2904
|
+
}
|
|
2905
|
+
if (params.initialUnlockBps + params.cliffAmountBps > 1e4) {
|
|
2906
|
+
errors.push(
|
|
2907
|
+
new InvalidArgumentError({
|
|
2908
|
+
method: where,
|
|
2909
|
+
argument: "initialUnlockBps + cliffAmountBps",
|
|
2910
|
+
reason: "must be \u2264 10000 (100%)",
|
|
2911
|
+
value: { initialUnlockBps: params.initialUnlockBps, cliffAmountBps: params.cliffAmountBps }
|
|
2912
|
+
})
|
|
2913
|
+
);
|
|
2914
|
+
}
|
|
2915
|
+
return errors;
|
|
2916
|
+
}
|
|
2754
2917
|
|
|
2755
2918
|
export { ClaimLockedError, ConfidentialVestingManagerClient, NoPendingTransferError, NotPendingRecipientError, NotVestingRecipientError, TransferAlreadyPendingError, TransferExpiredError, VestingExpiredError, VestingNotFoundError, VestingNotRevocableError, VestingRevokedError, confidentialVestingManagerAbi, createConfidentialVestingManagerClient, encryptUint64, encryptUint64Batch, resolveEncryptor };
|
|
@@ -1,17 +1,17 @@
|
|
|
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
|
function normaliseAddress(input) {
|
|
7
7
|
if (typeof input !== "string") {
|
|
8
|
-
throw new
|
|
8
|
+
throw new chunk67OV5CX2_cjs.TokenOpsValidationError("normaliseAddress: input is not a string", {
|
|
9
9
|
method: "normaliseAddress",
|
|
10
10
|
args: { input: typeof input }
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
if (!viem.isAddress(input, { strict: false })) {
|
|
14
|
-
throw new
|
|
14
|
+
throw new chunk67OV5CX2_cjs.TokenOpsValidationError(
|
|
15
15
|
`normaliseAddress: '${input}' is not a valid 0x-prefixed 20-byte hex address`,
|
|
16
16
|
{
|
|
17
17
|
method: "normaliseAddress",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
|
|
4
4
|
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
6
6
|
|
|
7
7
|
// src/fhe/operators.ts
|
|
8
8
|
var ERC7984_SET_OPERATOR_ABI = [
|
|
@@ -20,19 +20,19 @@ var ERC7984_SET_OPERATOR_ABI = [
|
|
|
20
20
|
var ERC7984_OPERATOR_MAX_DEADLINE = (1n << 48n) - 1n;
|
|
21
21
|
async function setOperator(args) {
|
|
22
22
|
const { publicClient, walletClient, account, waitForReceipt = true, telemetry } = args;
|
|
23
|
-
const token =
|
|
24
|
-
const spender =
|
|
23
|
+
const token = chunkJK4XMMKM_cjs.normaliseAddress(args.token);
|
|
24
|
+
const spender = chunkJK4XMMKM_cjs.normaliseAddress(args.spender);
|
|
25
25
|
const deadline = args.deadline ?? ERC7984_OPERATOR_MAX_DEADLINE;
|
|
26
26
|
return chunkVJKZWYYJ_cjs.withTelemetry(telemetry, "fhe.setOperator", async () => {
|
|
27
27
|
const fromAccount = account ?? walletClient.account;
|
|
28
28
|
if (!fromAccount) {
|
|
29
|
-
throw new
|
|
29
|
+
throw new chunk67OV5CX2_cjs.TokenOpsContractError(
|
|
30
30
|
"setOperator: no account available \u2014 pass `account` explicitly or attach an account to the walletClient",
|
|
31
31
|
{ contract: "ERC7984", call: "setOperator" }
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
if (deadline < 0n || deadline > ERC7984_OPERATOR_MAX_DEADLINE) {
|
|
35
|
-
throw new
|
|
35
|
+
throw new chunk67OV5CX2_cjs.TokenOpsContractError(
|
|
36
36
|
`setOperator: deadline ${deadline} out of uint48 range [0, ${ERC7984_OPERATOR_MAX_DEADLINE}]`,
|
|
37
37
|
{ contract: "ERC7984", call: "setOperator", deadline: deadline.toString() }
|
|
38
38
|
);
|
|
@@ -53,7 +53,7 @@ async function setOperator(args) {
|
|
|
53
53
|
chain: walletClient.chain
|
|
54
54
|
});
|
|
55
55
|
} catch (err) {
|
|
56
|
-
throw new
|
|
56
|
+
throw new chunk67OV5CX2_cjs.TokenOpsContractError(
|
|
57
57
|
`setOperator: writeContract failed (token=${token}, spender=${spender})`,
|
|
58
58
|
{
|
|
59
59
|
contract: "ERC7984",
|
|
@@ -68,7 +68,7 @@ async function setOperator(args) {
|
|
|
68
68
|
try {
|
|
69
69
|
await publicClient.waitForTransactionReceipt({ hash });
|
|
70
70
|
} catch (err) {
|
|
71
|
-
throw new
|
|
71
|
+
throw new chunk67OV5CX2_cjs.TokenOpsContractError(`setOperator: receipt wait failed (tx=${hash})`, {
|
|
72
72
|
contract: "ERC7984",
|
|
73
73
|
call: "setOperator",
|
|
74
74
|
tx: hash,
|
|
@@ -1,12 +1,55 @@
|
|
|
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
|
// src/core/version.ts
|
|
7
7
|
var SDK_VERSION = "1.0.0";
|
|
8
|
+
var ERC7984_ERRORS_ABI = [
|
|
9
|
+
{
|
|
10
|
+
type: "error",
|
|
11
|
+
name: "ERC7984UnauthorizedSpender",
|
|
12
|
+
inputs: [
|
|
13
|
+
{ name: "holder", type: "address" },
|
|
14
|
+
{ name: "spender", type: "address" }
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: "error",
|
|
19
|
+
name: "ERC7984UnauthorizedCaller",
|
|
20
|
+
inputs: [{ name: "caller", type: "address" }]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "error",
|
|
24
|
+
name: "ERC7984UnauthorizedUseOfEncryptedAmount",
|
|
25
|
+
inputs: [
|
|
26
|
+
{ name: "amount", type: "bytes32" },
|
|
27
|
+
{ name: "user", type: "address" }
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "error",
|
|
32
|
+
name: "ERC7984InvalidReceiver",
|
|
33
|
+
inputs: [{ name: "receiver", type: "address" }]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "error",
|
|
37
|
+
name: "ERC7984InvalidSender",
|
|
38
|
+
inputs: [{ name: "sender", type: "address" }]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "error",
|
|
42
|
+
name: "ERC7984ZeroBalance",
|
|
43
|
+
inputs: [{ name: "holder", type: "address" }]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "error",
|
|
47
|
+
name: "ERC7984InvalidGatewayRequest",
|
|
48
|
+
inputs: [{ name: "requestId", type: "uint256" }]
|
|
49
|
+
}
|
|
50
|
+
];
|
|
8
51
|
function mapContractRevert(error, args) {
|
|
9
|
-
if (error instanceof
|
|
52
|
+
if (error instanceof chunk67OV5CX2_cjs.TokenOpsSdkError) return error;
|
|
10
53
|
const ctx = {
|
|
11
54
|
method: args.method,
|
|
12
55
|
contractAddress: args.contractAddress,
|
|
@@ -24,7 +67,10 @@ function mapContractRevert(error, args) {
|
|
|
24
67
|
if (revertName === void 0 && rawRevertData !== void 0 && rawRevertData.length >= 10) {
|
|
25
68
|
revertSelector = rawRevertData.slice(0, 10);
|
|
26
69
|
try {
|
|
27
|
-
const decoded = viem.decodeErrorResult({
|
|
70
|
+
const decoded = viem.decodeErrorResult({
|
|
71
|
+
abi: [...args.abi, ...ERC7984_ERRORS_ABI],
|
|
72
|
+
data: rawRevertData
|
|
73
|
+
});
|
|
28
74
|
revertName = decoded.errorName;
|
|
29
75
|
revertArgs = decoded.args;
|
|
30
76
|
} catch {
|
|
@@ -38,7 +84,7 @@ function mapContractRevert(error, args) {
|
|
|
38
84
|
const fromDefault = defaultRevertNameMapper(revertName, revertArgs, ctx, args.account);
|
|
39
85
|
if (fromDefault) return attachCause(fromDefault, error);
|
|
40
86
|
}
|
|
41
|
-
return new
|
|
87
|
+
return new chunk67OV5CX2_cjs.ContractRevertError({
|
|
42
88
|
method: args.method,
|
|
43
89
|
contractAddress: args.contractAddress,
|
|
44
90
|
revertName,
|
|
@@ -66,62 +112,72 @@ function defaultRevertNameMapper(name, errArgs, ctx, account) {
|
|
|
66
112
|
case "EnforcedPause":
|
|
67
113
|
case "PausableUpgradeable__Paused":
|
|
68
114
|
case "ClaimsPaused":
|
|
69
|
-
return new
|
|
115
|
+
return new chunk67OV5CX2_cjs.PausedError(ctx);
|
|
70
116
|
case "AccessControlUnauthorizedAccount": {
|
|
71
117
|
const acct = errArgs?.[0] ?? account;
|
|
72
118
|
const role = errArgs?.[1];
|
|
73
|
-
return new
|
|
119
|
+
return new chunk67OV5CX2_cjs.AccessDeniedError({ ...ctx, account: acct, role });
|
|
74
120
|
}
|
|
75
121
|
case "AccessControlBadConfirmation":
|
|
76
|
-
return new
|
|
122
|
+
return new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
77
123
|
method: ctx.method,
|
|
78
124
|
argument: "callerConfirmation",
|
|
79
125
|
reason: "must equal msg.sender for renounceRole"
|
|
80
126
|
});
|
|
81
127
|
case "InvalidInitialization":
|
|
82
128
|
case "Initializable_InvalidInitialization":
|
|
83
|
-
return new
|
|
129
|
+
return new chunk67OV5CX2_cjs.AlreadyInitializedError(ctx);
|
|
84
130
|
case "ReentrancyGuardReentrantCall":
|
|
85
131
|
case "ReentrancyGuardTransient":
|
|
86
|
-
return new
|
|
132
|
+
return new chunk67OV5CX2_cjs.ReentrancyError(ctx);
|
|
87
133
|
// Cross-product custom errors with stable, unambiguous meaning.
|
|
88
134
|
case "InsufficientFee":
|
|
89
135
|
case "InsufficientGasFee":
|
|
90
|
-
return new
|
|
136
|
+
return new chunk67OV5CX2_cjs.InsufficientFeeError({ ...ctx, feeKind: "gas" });
|
|
91
137
|
case "InsufficientAmount": {
|
|
92
138
|
const provided = errArgs?.[0];
|
|
93
139
|
const required = errArgs?.[1];
|
|
94
|
-
return new
|
|
140
|
+
return new chunk67OV5CX2_cjs.InsufficientFeeError({ ...ctx, feeKind: "gas", required, provided });
|
|
95
141
|
}
|
|
96
142
|
case "ZeroBalance":
|
|
97
143
|
case "InsufficientBalance":
|
|
98
|
-
return new
|
|
144
|
+
return new chunk67OV5CX2_cjs.InsufficientBalanceError({ ...ctx, balanceKind: "eth" });
|
|
99
145
|
case "BatchTooLarge": {
|
|
100
146
|
const requested = Number(errArgs?.[0] ?? 0);
|
|
101
147
|
const max = errArgs?.[1] ?? 0n;
|
|
102
|
-
return new
|
|
148
|
+
return new chunk67OV5CX2_cjs.BatchTooLargeError({ ...ctx, requested, max });
|
|
103
149
|
}
|
|
104
150
|
case "SplitDisabled":
|
|
105
|
-
return new
|
|
151
|
+
return new chunk67OV5CX2_cjs.FeatureDisabledError({ ...ctx, feature: "split" });
|
|
106
152
|
case "PausableDisabled":
|
|
107
|
-
return new
|
|
153
|
+
return new chunk67OV5CX2_cjs.FeatureDisabledError({ ...ctx, feature: "pause" });
|
|
108
154
|
case "ExtensionNotAllowed":
|
|
109
|
-
return new
|
|
155
|
+
return new chunk67OV5CX2_cjs.FeatureDisabledError({ ...ctx, feature: "extendClaimWindow" });
|
|
110
156
|
case "TransferFailed":
|
|
111
|
-
return new
|
|
157
|
+
return new chunk67OV5CX2_cjs.TransferFailedError({ ...ctx, asset: "eth" });
|
|
112
158
|
case "HandleNotAllowed":
|
|
113
|
-
return new
|
|
159
|
+
return new chunk67OV5CX2_cjs.FheHandleNotAllowedError({ ...ctx, account });
|
|
114
160
|
case "SenderNotAllowedToUseHandle": {
|
|
115
161
|
const handle = errArgs?.[0];
|
|
116
162
|
const sender = errArgs?.[1] ?? account;
|
|
117
|
-
return new
|
|
163
|
+
return new chunk67OV5CX2_cjs.FheHandleNotAllowedError({ ...ctx, handle, account: sender });
|
|
118
164
|
}
|
|
119
165
|
case "SenderNotAllowed": {
|
|
120
166
|
const sender = errArgs?.[0] ?? account;
|
|
121
|
-
return new
|
|
167
|
+
return new chunk67OV5CX2_cjs.FheHandleNotAllowedError({ ...ctx, account: sender });
|
|
122
168
|
}
|
|
123
169
|
case "InvalidSignature":
|
|
124
|
-
return new
|
|
170
|
+
return new chunk67OV5CX2_cjs.InvalidSignatureError(ctx);
|
|
171
|
+
case "ERC7984UnauthorizedSpender": {
|
|
172
|
+
const holder = errArgs?.[0];
|
|
173
|
+
const spender = errArgs?.[1];
|
|
174
|
+
return new chunk67OV5CX2_cjs.OperatorNotApprovedError({
|
|
175
|
+
method: ctx.method,
|
|
176
|
+
contractAddress: ctx.contractAddress,
|
|
177
|
+
holder,
|
|
178
|
+
spender
|
|
179
|
+
});
|
|
180
|
+
}
|
|
125
181
|
// Range / arg-validation reverts the SDK should already have caught in
|
|
126
182
|
// preflight or input validation. If they slip through, surface them as
|
|
127
183
|
// structural `InvalidArgumentError` so consumers see `TOKENOPS_INVALID_ARGUMENT`
|
|
@@ -155,7 +211,7 @@ function defaultRevertNameMapper(name, errArgs, ctx, account) {
|
|
|
155
211
|
case "ArrayLengthMismatch":
|
|
156
212
|
case "VestingIdsNotStrictlyAsc":
|
|
157
213
|
case "CustomFeeNotSet":
|
|
158
|
-
return new
|
|
214
|
+
return new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
159
215
|
method: ctx.method,
|
|
160
216
|
argument: invalidArgumentLabelFor(name),
|
|
161
217
|
reason: `the contract reverted with \`${name}\`. If you did not pass an invalid value, this may be an SDK bug \u2014 please file an issue.`
|
|
@@ -228,7 +284,7 @@ function isContractRevert(error) {
|
|
|
228
284
|
}
|
|
229
285
|
function classifyNonRevert(error, args) {
|
|
230
286
|
if (!(error instanceof viem.BaseError)) {
|
|
231
|
-
return new
|
|
287
|
+
return new chunk67OV5CX2_cjs.UnknownWriteFailureError({
|
|
232
288
|
method: args.method,
|
|
233
289
|
contractAddress: args.contractAddress,
|
|
234
290
|
cause: error
|
|
@@ -239,21 +295,21 @@ function classifyNonRevert(error, args) {
|
|
|
239
295
|
return predicate(frame) ? frame : void 0;
|
|
240
296
|
};
|
|
241
297
|
if (walk((e) => e instanceof viem.UserRejectedRequestError) || walk((e) => e instanceof viem.TransactionRejectedRpcError)) {
|
|
242
|
-
return new
|
|
298
|
+
return new chunk67OV5CX2_cjs.WalletRejectedError({
|
|
243
299
|
method: args.method,
|
|
244
300
|
contractAddress: args.contractAddress,
|
|
245
301
|
cause: error
|
|
246
302
|
});
|
|
247
303
|
}
|
|
248
304
|
if (walk((e) => e instanceof viem.ChainMismatchError)) {
|
|
249
|
-
return new
|
|
305
|
+
return new chunk67OV5CX2_cjs.WalletChainMismatchError({
|
|
250
306
|
method: args.method,
|
|
251
307
|
contractAddress: args.contractAddress,
|
|
252
308
|
cause: error
|
|
253
309
|
});
|
|
254
310
|
}
|
|
255
311
|
if (walk((e) => e instanceof viem.InsufficientFundsError)) {
|
|
256
|
-
return new
|
|
312
|
+
return new chunk67OV5CX2_cjs.InsufficientGasFundsError({
|
|
257
313
|
method: args.method,
|
|
258
314
|
contractAddress: args.contractAddress,
|
|
259
315
|
cause: error
|
|
@@ -261,7 +317,7 @@ function classifyNonRevert(error, args) {
|
|
|
261
317
|
}
|
|
262
318
|
const httpFrame = walk((e) => e instanceof viem.HttpRequestError);
|
|
263
319
|
if (httpFrame) {
|
|
264
|
-
return new
|
|
320
|
+
return new chunk67OV5CX2_cjs.NetworkError({
|
|
265
321
|
method: args.method,
|
|
266
322
|
contractAddress: args.contractAddress,
|
|
267
323
|
statusCode: httpFrame.status,
|
|
@@ -269,13 +325,13 @@ function classifyNonRevert(error, args) {
|
|
|
269
325
|
});
|
|
270
326
|
}
|
|
271
327
|
if (walk((e) => e instanceof viem.TimeoutError)) {
|
|
272
|
-
return new
|
|
328
|
+
return new chunk67OV5CX2_cjs.NetworkError({
|
|
273
329
|
method: args.method,
|
|
274
330
|
contractAddress: args.contractAddress,
|
|
275
331
|
cause: error
|
|
276
332
|
});
|
|
277
333
|
}
|
|
278
|
-
return new
|
|
334
|
+
return new chunk67OV5CX2_cjs.UnknownWriteFailureError({
|
|
279
335
|
method: args.method,
|
|
280
336
|
contractAddress: args.contractAddress,
|
|
281
337
|
cause: error
|