@tokenops/sdk 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +158 -2
- package/SECURITY.md +7 -1
- package/dist/{chunk-67OV5CX2.cjs → chunk-2RNW4MIJ.cjs} +18 -0
- package/dist/{chunk-KLKI352M.cjs → chunk-43RFBQ73.cjs} +29 -29
- package/dist/{chunk-ZA673I3O.js → chunk-46T67CE2.js} +1 -1
- package/dist/{chunk-6BMP4ICG.js → chunk-4KJ66YRH.js} +61 -3
- package/dist/{chunk-JYOTGRSO.cjs → chunk-4ZCXK4VI.cjs} +68 -8
- package/dist/{chunk-SG65XWH7.js → chunk-6WSNS3UV.js} +1 -1
- package/dist/{chunk-V2PXZVBF.cjs → chunk-7G7UOQV4.cjs} +4 -4
- package/dist/{chunk-WENHUPZC.cjs → chunk-AYGRYDBX.cjs} +35 -36
- package/dist/{chunk-2NCLOQ56.cjs → chunk-BD4LZBVF.cjs} +85 -9
- package/dist/{chunk-5X5WL5CU.cjs → chunk-BK7YIVLK.cjs} +110 -149
- package/dist/{chunk-W7IGCOVL.cjs → chunk-CBRL2PJA.cjs} +12 -11
- package/dist/{chunk-ORFTDNFZ.js → chunk-CNP4L3GF.js} +4 -4
- package/dist/{chunk-QBJ7O2B4.js → chunk-DRSPMIZ7.js} +11 -1
- package/dist/{chunk-C7BRZXJA.cjs → chunk-EUKPOXWR.cjs} +15 -16
- package/dist/{chunk-YQIBBEFJ.js → chunk-HETNKZEE.js} +1 -1
- package/dist/{chunk-ODLTEGHB.js → chunk-KSDSXJ34.js} +1 -1
- package/dist/{chunk-TIUKIY5V.cjs → chunk-LBWRFZR3.cjs} +58 -40
- package/dist/{chunk-WMACINXO.js → chunk-NFW7AUEX.js} +1 -1
- package/dist/{chunk-4WPGQSNT.cjs → chunk-OL6SHN3D.cjs} +3 -3
- package/dist/{chunk-AOP6HMPW.js → chunk-PD7ME2BT.js} +75 -2
- package/dist/{chunk-2PWNH3UE.js → chunk-QET3Q4JP.js} +65 -9
- package/dist/{chunk-XGGTQQFH.js → chunk-QKKBBH7I.js} +2 -2
- package/dist/{chunk-6R4KNAPK.js → chunk-S2XD75JM.js} +10 -3
- package/dist/{chunk-MCRBVJGZ.cjs → chunk-SPGSO5SO.cjs} +29 -22
- package/dist/{chunk-FAXIIH5R.cjs → chunk-SYHNZSZZ.cjs} +3 -3
- package/dist/{chunk-IXLO7GO5.js → chunk-TN65XNTI.js} +47 -83
- package/dist/chunk-U57COLUE.js +56 -0
- package/dist/{chunk-DUZIIRPF.js → chunk-UE5XK2SY.js} +27 -9
- package/dist/{chunk-TEBM66WA.cjs → chunk-UJS4N2XM.cjs} +12 -12
- package/dist/{chunk-OXTLPTO3.js → chunk-V5D7BHW3.js} +4 -5
- package/dist/{chunk-NTZY6IB7.js → chunk-VHSNYUYV.js} +5 -4
- package/dist/{chunk-JK4XMMKM.cjs → chunk-VR3FREBX.cjs} +3 -3
- package/dist/{chunk-T46YXSBP.cjs → chunk-WO72UBQD.cjs} +11 -11
- package/dist/chunk-WOEETTH7.cjs +59 -0
- package/dist/{chunk-IJFQ5L4I.js → chunk-WTK6JDSI.js} +4 -5
- package/dist/{chunk-PUPKNW3R.cjs → chunk-WUXUWTFW.cjs} +3 -3
- package/dist/{chunk-PFXURMBZ.cjs → chunk-YFIWCYHC.cjs} +112 -54
- package/dist/{chunk-ZWXJTBZO.js → chunk-YPYCWLYP.js} +1 -1
- package/dist/core/addresses.d.ts +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/fhe/index.cjs +84 -64
- package/dist/fhe/index.d.cts +1 -0
- package/dist/fhe/index.d.ts +1 -0
- package/dist/fhe/index.js +21 -9
- package/dist/fhe/mock-erc7984.d.ts +4 -4
- package/dist/fhe/operators.d.ts +142 -2
- package/dist/fhe/react/index.cjs +21 -8
- package/dist/fhe/react/index.d.cts +2 -0
- package/dist/fhe/react/index.d.ts +2 -0
- package/dist/fhe/react/index.js +8 -3
- package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
- package/dist/fhe/react/useIsOperator.d.ts +54 -0
- package/dist/fhe/sepolia-encryptor-web.d.ts +18 -3
- package/dist/fhe-airdrop/advanced/index.cjs +8 -9
- package/dist/fhe-airdrop/advanced/index.js +6 -7
- package/dist/fhe-airdrop/advanced/react/index.cjs +13 -14
- package/dist/fhe-airdrop/advanced/react/index.js +9 -10
- package/dist/fhe-airdrop/airdrop.d.ts +7 -0
- package/dist/fhe-airdrop/index.cjs +66 -67
- package/dist/fhe-airdrop/index.js +7 -8
- package/dist/fhe-airdrop/react/index.cjs +148 -137
- package/dist/fhe-airdrop/react/index.d.cts +3 -1
- package/dist/fhe-airdrop/react/index.d.ts +3 -1
- package/dist/fhe-airdrop/react/index.js +16 -14
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +17 -11
- package/dist/fhe-airdrop/react/useClaim.d.ts +8 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +1 -1
- package/dist/fhe-airdrop/types.d.ts +14 -3
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +74 -67
- 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 -9
- package/dist/fhe-disperse/react/index.cjs +105 -88
- package/dist/fhe-disperse/react/index.d.cts +3 -1
- package/dist/fhe-disperse/react/index.d.ts +3 -1
- package/dist/fhe-disperse/react/index.js +12 -11
- package/dist/fhe-vesting/advanced/index.cjs +8 -9
- package/dist/fhe-vesting/advanced/index.js +6 -7
- package/dist/fhe-vesting/advanced/react/index.cjs +14 -15
- package/dist/fhe-vesting/advanced/react/index.js +11 -12
- package/dist/fhe-vesting/index.cjs +75 -76
- package/dist/fhe-vesting/index.js +9 -10
- package/dist/fhe-vesting/manager.d.ts +19 -0
- package/dist/fhe-vesting/react/index.cjs +245 -227
- package/dist/fhe-vesting/react/index.d.cts +6 -4
- package/dist/fhe-vesting/react/index.d.ts +6 -4
- package/dist/fhe-vesting/react/index.js +27 -21
- package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
- package/dist/fhe-vesting/types.d.ts +12 -1
- package/dist/index.cjs +87 -88
- package/dist/index.js +2 -3
- package/dist/testnet-faucet/index.cjs +55 -56
- package/dist/testnet-faucet/index.js +5 -6
- package/dist/testnet-faucet/react/index.cjs +53 -54
- package/dist/testnet-faucet/react/index.js +7 -8
- package/package.json +13 -8
- package/dist/chunk-66IHPTOK.cjs +0 -20
- package/dist/chunk-KWFFIJYX.js +0 -11
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
- package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
- package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
- package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TokenOpsSdkError, ContractRevertError, InvalidArgumentError, OperatorNotApprovedError, InvalidSignatureError, FheHandleNotAllowedError, TransferFailedError, FeatureDisabledError, BatchTooLargeError, InsufficientBalanceError, InsufficientFeeError, ReentrancyError, AlreadyInitializedError, AccessDeniedError, PausedError, UnknownWriteFailureError, WalletRejectedError, WalletChainMismatchError, InsufficientGasFundsError, NetworkError } from './chunk-
|
|
1
|
+
import { TokenOpsSdkError, ContractRevertError, InvalidArgumentError, OperatorNotApprovedError, InvalidSignatureError, FheHandleNotAllowedError, TransferFailedError, FeatureDisabledError, BatchTooLargeError, InsufficientBalanceError, InsufficientFeeError, ReentrancyError, AlreadyInitializedError, AccessDeniedError, PausedError, UnknownWriteFailureError, WalletRejectedError, WalletChainMismatchError, InsufficientGasFundsError, NetworkError } from './chunk-DRSPMIZ7.js';
|
|
2
2
|
import { decodeErrorResult, BaseError, ContractFunctionRevertedError, UserRejectedRequestError, TransactionRejectedRpcError, ChainMismatchError, InsufficientFundsError, HttpRequestError, TimeoutError } from 'viem';
|
|
3
3
|
|
|
4
4
|
// src/core/version.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkEUKPOXWR_cjs = require('./chunk-EUKPOXWR.cjs');
|
|
4
4
|
|
|
5
5
|
// src/fhe-vesting/advanced/factory-advanced.ts
|
|
6
|
-
var ConfidentialVestingFactoryAdvancedClient = class extends
|
|
6
|
+
var ConfidentialVestingFactoryAdvancedClient = class extends chunkEUKPOXWR_cjs.ConfidentialVestingFactoryClient {
|
|
7
7
|
/**
|
|
8
8
|
* Compute the deterministic CREATE2 clone address as the factory would have
|
|
9
9
|
* computed it at `args.blockNumber`.
|
|
@@ -20,7 +20,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunkC7BRZXJA_cjs.C
|
|
|
20
20
|
if (hasOptions) {
|
|
21
21
|
return this.publicClient.readContract({
|
|
22
22
|
address: this.address,
|
|
23
|
-
abi:
|
|
23
|
+
abi: chunkEUKPOXWR_cjs.confidentialVestingFactoryAbi,
|
|
24
24
|
functionName: "predictManagerAddressWithOptions",
|
|
25
25
|
args: [
|
|
26
26
|
args.token,
|
|
@@ -34,7 +34,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunkC7BRZXJA_cjs.C
|
|
|
34
34
|
}
|
|
35
35
|
return this.publicClient.readContract({
|
|
36
36
|
address: this.address,
|
|
37
|
-
abi:
|
|
37
|
+
abi: chunkEUKPOXWR_cjs.confidentialVestingFactoryAbi,
|
|
38
38
|
functionName: "predictManagerAddress",
|
|
39
39
|
args: [args.token, args.userSalt, args.deployer],
|
|
40
40
|
blockNumber: args.blockNumber
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk43RFBQ73_cjs = require('./chunk-43RFBQ73.cjs');
|
|
4
|
+
var chunkWUXUWTFW_cjs = require('./chunk-WUXUWTFW.cjs');
|
|
5
|
+
var chunkVR3FREBX_cjs = require('./chunk-VR3FREBX.cjs');
|
|
6
|
+
var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
|
|
6
7
|
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
7
|
-
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
8
|
-
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
9
8
|
var chains = require('viem/chains');
|
|
10
9
|
var viem = require('viem');
|
|
11
10
|
|
|
@@ -1701,7 +1700,7 @@ var tokenopsTestTokenAbi = [
|
|
|
1701
1700
|
];
|
|
1702
1701
|
|
|
1703
1702
|
// src/testnet-faucet/errors.ts
|
|
1704
|
-
var FaucetSupplyExhaustedError = class extends
|
|
1703
|
+
var FaucetSupplyExhaustedError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
|
|
1705
1704
|
name = "FaucetSupplyExhaustedError";
|
|
1706
1705
|
constructor(args) {
|
|
1707
1706
|
super(
|
|
@@ -1721,14 +1720,14 @@ function isTestnetFaucetChainId(chainId) {
|
|
|
1721
1720
|
function assertTestnetFaucetChain(chainId) {
|
|
1722
1721
|
if (chainId === void 0) return;
|
|
1723
1722
|
if (!isTestnetFaucetChainId(chainId)) {
|
|
1724
|
-
throw new
|
|
1723
|
+
throw new chunk2RNW4MIJ_cjs.UnsupportedChainError(chainId);
|
|
1725
1724
|
}
|
|
1726
1725
|
}
|
|
1727
1726
|
var UINT64_MAX = (1n << 64n) - 1n;
|
|
1728
1727
|
var UINT256_MAX = (1n << 256n) - 1n;
|
|
1729
1728
|
function assertUint64Amount(value, argument, method) {
|
|
1730
1729
|
if (typeof value !== "bigint") {
|
|
1731
|
-
throw new
|
|
1730
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1732
1731
|
method,
|
|
1733
1732
|
argument,
|
|
1734
1733
|
reason: "amount must be a bigint",
|
|
@@ -1736,7 +1735,7 @@ function assertUint64Amount(value, argument, method) {
|
|
|
1736
1735
|
});
|
|
1737
1736
|
}
|
|
1738
1737
|
if (value <= 0n) {
|
|
1739
|
-
throw new
|
|
1738
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1740
1739
|
method,
|
|
1741
1740
|
argument,
|
|
1742
1741
|
reason: "amount must be greater than zero",
|
|
@@ -1744,7 +1743,7 @@ function assertUint64Amount(value, argument, method) {
|
|
|
1744
1743
|
});
|
|
1745
1744
|
}
|
|
1746
1745
|
if (value > UINT64_MAX) {
|
|
1747
|
-
throw new
|
|
1746
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1748
1747
|
method,
|
|
1749
1748
|
argument,
|
|
1750
1749
|
reason: `amount exceeds uint64 max (${UINT64_MAX.toString()})`,
|
|
@@ -1754,7 +1753,7 @@ function assertUint64Amount(value, argument, method) {
|
|
|
1754
1753
|
}
|
|
1755
1754
|
function assertUint256Amount(value, argument, method) {
|
|
1756
1755
|
if (typeof value !== "bigint") {
|
|
1757
|
-
throw new
|
|
1756
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1758
1757
|
method,
|
|
1759
1758
|
argument,
|
|
1760
1759
|
reason: "amount must be a bigint",
|
|
@@ -1762,7 +1761,7 @@ function assertUint256Amount(value, argument, method) {
|
|
|
1762
1761
|
});
|
|
1763
1762
|
}
|
|
1764
1763
|
if (value <= 0n) {
|
|
1765
|
-
throw new
|
|
1764
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1766
1765
|
method,
|
|
1767
1766
|
argument,
|
|
1768
1767
|
reason: "amount must be greater than zero",
|
|
@@ -1770,7 +1769,7 @@ function assertUint256Amount(value, argument, method) {
|
|
|
1770
1769
|
});
|
|
1771
1770
|
}
|
|
1772
1771
|
if (value > UINT256_MAX) {
|
|
1773
|
-
throw new
|
|
1772
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1774
1773
|
method,
|
|
1775
1774
|
argument,
|
|
1776
1775
|
reason: "amount exceeds uint256 max",
|
|
@@ -1779,9 +1778,9 @@ function assertUint256Amount(value, argument, method) {
|
|
|
1779
1778
|
}
|
|
1780
1779
|
}
|
|
1781
1780
|
function assertNonZeroRecipient(input, argument, method) {
|
|
1782
|
-
const normalised =
|
|
1781
|
+
const normalised = chunkVR3FREBX_cjs.normaliseAddress(input);
|
|
1783
1782
|
if (/^0x0{40}$/i.test(normalised)) {
|
|
1784
|
-
throw new
|
|
1783
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1785
1784
|
method,
|
|
1786
1785
|
argument,
|
|
1787
1786
|
reason: "recipient must not be the zero address",
|
|
@@ -1799,7 +1798,7 @@ var faucetProductMapper = (name, _args, ctx) => {
|
|
|
1799
1798
|
});
|
|
1800
1799
|
case "ERC7984InvalidReceiver":
|
|
1801
1800
|
case "ERC20InvalidReceiver":
|
|
1802
|
-
return new
|
|
1801
|
+
return new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1803
1802
|
method: ctx.method,
|
|
1804
1803
|
argument: "to",
|
|
1805
1804
|
reason: "recipient must not be the zero address"
|
|
@@ -1824,10 +1823,10 @@ var TestnetFaucetClient = class {
|
|
|
1824
1823
|
const chainId = config.chainId ?? config.publicClient.chain?.id;
|
|
1825
1824
|
this.#chainId = chainId;
|
|
1826
1825
|
assertTestnetFaucetChain(chainId);
|
|
1827
|
-
const addressOverride = config.address ?
|
|
1828
|
-
const resolved = addressOverride ?? (chainId === void 0 ? void 0 :
|
|
1826
|
+
const addressOverride = config.address ? chunkVR3FREBX_cjs.normaliseAddress(config.address) : void 0;
|
|
1827
|
+
const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkWUXUWTFW_cjs.getConfidentialTestTokenAddress(chainId));
|
|
1829
1828
|
if (!resolved) {
|
|
1830
|
-
throw new
|
|
1829
|
+
throw new chunk2RNW4MIJ_cjs.DeploymentAddressUnavailableError({
|
|
1831
1830
|
reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
|
|
1832
1831
|
product: "testnetFaucet",
|
|
1833
1832
|
contract: "confidentialTestToken",
|
|
@@ -1840,7 +1839,7 @@ var TestnetFaucetClient = class {
|
|
|
1840
1839
|
this.#telemetry?.event("testnet-faucet.client.init", {
|
|
1841
1840
|
chainId: chainId ?? null,
|
|
1842
1841
|
hasWallet: !!this.walletClient,
|
|
1843
|
-
sdkVersion:
|
|
1842
|
+
sdkVersion: chunk43RFBQ73_cjs.SDK_VERSION
|
|
1844
1843
|
});
|
|
1845
1844
|
}
|
|
1846
1845
|
// ============================================================
|
|
@@ -1863,9 +1862,9 @@ var TestnetFaucetClient = class {
|
|
|
1863
1862
|
*/
|
|
1864
1863
|
async underlyingToken() {
|
|
1865
1864
|
if (this.#cachedUnderlying) return this.#cachedUnderlying;
|
|
1866
|
-
const fromRegistry = this.#cttAddressIsOverride || this.#chainId === void 0 ? void 0 :
|
|
1865
|
+
const fromRegistry = this.#cttAddressIsOverride || this.#chainId === void 0 ? void 0 : chunkWUXUWTFW_cjs.getTestTokenAddress(this.#chainId);
|
|
1867
1866
|
const resolved = fromRegistry ?? await this.#readCtt("underlying");
|
|
1868
|
-
this.#cachedUnderlying =
|
|
1867
|
+
this.#cachedUnderlying = chunkVR3FREBX_cjs.normaliseAddress(resolved);
|
|
1869
1868
|
return this.#cachedUnderlying;
|
|
1870
1869
|
}
|
|
1871
1870
|
/**
|
|
@@ -1884,7 +1883,7 @@ var TestnetFaucetClient = class {
|
|
|
1884
1883
|
async confidentialBalanceOf(account) {
|
|
1885
1884
|
const who = this.#resolveReadAddress(account, "confidentialBalanceOf");
|
|
1886
1885
|
const handle = await this.#readCtt("confidentialBalanceOf", [who]);
|
|
1887
|
-
return
|
|
1886
|
+
return chunk2RNW4MIJ_cjs.asEncryptedHandle(handle);
|
|
1888
1887
|
}
|
|
1889
1888
|
/**
|
|
1890
1889
|
* Read the plaintext underlying `TokenopsTestToken` (TTT) balance for
|
|
@@ -1997,7 +1996,7 @@ var TestnetFaucetClient = class {
|
|
|
1997
1996
|
}
|
|
1998
1997
|
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
1999
1998
|
if (receipt.status !== "success") {
|
|
2000
|
-
throw new
|
|
1999
|
+
throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(`mintConfidential: transaction ${hash} reverted`, {
|
|
2001
2000
|
contract: "ConfidentialTokenopsTestToken",
|
|
2002
2001
|
call: "mint",
|
|
2003
2002
|
tx: hash
|
|
@@ -2010,7 +2009,7 @@ var TestnetFaucetClient = class {
|
|
|
2010
2009
|
});
|
|
2011
2010
|
const ours = events.filter((ev2) => ev2.address.toLowerCase() === this.address.toLowerCase());
|
|
2012
2011
|
if (ours.length === 0) {
|
|
2013
|
-
throw new
|
|
2012
|
+
throw new chunk2RNW4MIJ_cjs.ReceiptEventNotFoundError({
|
|
2014
2013
|
method: "mintConfidential",
|
|
2015
2014
|
eventName: "ConfidentialMint",
|
|
2016
2015
|
contractAddress: this.address,
|
|
@@ -2018,7 +2017,7 @@ var TestnetFaucetClient = class {
|
|
|
2018
2017
|
});
|
|
2019
2018
|
}
|
|
2020
2019
|
if (ours.length > 1) {
|
|
2021
|
-
throw new
|
|
2020
|
+
throw new chunk2RNW4MIJ_cjs.ReceiptEventAmbiguousError({
|
|
2022
2021
|
method: "mintConfidential",
|
|
2023
2022
|
eventName: "ConfidentialMint",
|
|
2024
2023
|
contractAddress: this.address,
|
|
@@ -2028,11 +2027,11 @@ var TestnetFaucetClient = class {
|
|
|
2028
2027
|
}
|
|
2029
2028
|
const ev = ours[0];
|
|
2030
2029
|
return {
|
|
2031
|
-
hash:
|
|
2030
|
+
hash: chunk2RNW4MIJ_cjs.asTxHash(hash),
|
|
2032
2031
|
to: ev.args.to,
|
|
2033
2032
|
amount: args.amount,
|
|
2034
2033
|
underlyingMinted: ev.args.underlyingMinted,
|
|
2035
|
-
handle:
|
|
2034
|
+
handle: chunk2RNW4MIJ_cjs.asEncryptedHandle(ev.args.encryptedAmount)
|
|
2036
2035
|
};
|
|
2037
2036
|
});
|
|
2038
2037
|
}
|
|
@@ -2071,13 +2070,13 @@ var TestnetFaucetClient = class {
|
|
|
2071
2070
|
}
|
|
2072
2071
|
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
2073
2072
|
if (receipt.status !== "success") {
|
|
2074
|
-
throw new
|
|
2073
|
+
throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(`mintUnderlying: transaction ${hash} reverted`, {
|
|
2075
2074
|
contract: "TokenopsTestToken",
|
|
2076
2075
|
call: "mint",
|
|
2077
2076
|
tx: hash
|
|
2078
2077
|
});
|
|
2079
2078
|
}
|
|
2080
|
-
return { hash:
|
|
2079
|
+
return { hash: chunk2RNW4MIJ_cjs.asTxHash(hash), to, amount: args.amount };
|
|
2081
2080
|
});
|
|
2082
2081
|
}
|
|
2083
2082
|
// ============================================================
|
|
@@ -2088,14 +2087,14 @@ var TestnetFaucetClient = class {
|
|
|
2088
2087
|
}
|
|
2089
2088
|
#requireWallet(method) {
|
|
2090
2089
|
if (!this.walletClient) {
|
|
2091
|
-
throw new
|
|
2090
|
+
throw new chunk2RNW4MIJ_cjs.MissingWalletClientError(method);
|
|
2092
2091
|
}
|
|
2093
2092
|
return this.walletClient;
|
|
2094
2093
|
}
|
|
2095
2094
|
#resolveAccount(wallet, override, method) {
|
|
2096
2095
|
const acct = override ?? wallet.account;
|
|
2097
2096
|
if (!acct) {
|
|
2098
|
-
throw new
|
|
2097
|
+
throw new chunk2RNW4MIJ_cjs.MissingAccountError(method);
|
|
2099
2098
|
}
|
|
2100
2099
|
return acct;
|
|
2101
2100
|
}
|
|
@@ -2105,10 +2104,10 @@ var TestnetFaucetClient = class {
|
|
|
2105
2104
|
* neither is available (a read-only client must be told whose balance to read).
|
|
2106
2105
|
*/
|
|
2107
2106
|
#resolveReadAddress(override, method) {
|
|
2108
|
-
if (override) return
|
|
2107
|
+
if (override) return chunkVR3FREBX_cjs.normaliseAddress(override);
|
|
2109
2108
|
const acct = this.walletClient?.account?.address;
|
|
2110
2109
|
if (!acct) {
|
|
2111
|
-
throw new
|
|
2110
|
+
throw new chunk2RNW4MIJ_cjs.MissingAccountError(method);
|
|
2112
2111
|
}
|
|
2113
2112
|
return acct;
|
|
2114
2113
|
}
|
|
@@ -2147,13 +2146,13 @@ var TestnetFaucetClient = class {
|
|
|
2147
2146
|
account
|
|
2148
2147
|
});
|
|
2149
2148
|
} catch (err) {
|
|
2150
|
-
if (
|
|
2149
|
+
if (chunk43RFBQ73_cjs.isContractRevert(err)) {
|
|
2151
2150
|
throw this.#mapRevert(target, method, err, void 0, accountAddress(account));
|
|
2152
2151
|
}
|
|
2153
2152
|
}
|
|
2154
2153
|
}
|
|
2155
2154
|
#mapRevert(target, method, err, productContext, account) {
|
|
2156
|
-
return
|
|
2155
|
+
return chunk43RFBQ73_cjs.mapContractRevert(err, {
|
|
2157
2156
|
method,
|
|
2158
2157
|
contractAddress: target.address,
|
|
2159
2158
|
abi: target.abi,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
|
|
4
|
+
var viem = require('viem');
|
|
4
5
|
|
|
5
6
|
// src/fhe/scale-ratio.ts
|
|
6
7
|
var FHE_SPLIT_DENOMINATOR = 90090000n;
|
|
@@ -15,7 +16,7 @@ function scaleRatio({
|
|
|
15
16
|
width = "uint128"
|
|
16
17
|
}) {
|
|
17
18
|
if (denominator <= 0n) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
19
20
|
method: "scaleRatio",
|
|
20
21
|
argument: "denominator",
|
|
21
22
|
reason: `must be > 0, got ${denominator}`,
|
|
@@ -23,7 +24,7 @@ function scaleRatio({
|
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
if (numerator < 0n) {
|
|
26
|
-
throw new
|
|
27
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
27
28
|
method: "scaleRatio",
|
|
28
29
|
argument: "numerator",
|
|
29
30
|
reason: `must be >= 0, got ${numerator}`,
|
|
@@ -31,7 +32,7 @@ function scaleRatio({
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
if (minDenominator <= 0n) {
|
|
34
|
-
throw new
|
|
35
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
35
36
|
method: "scaleRatio",
|
|
36
37
|
argument: "minDenominator",
|
|
37
38
|
reason: `must be > 0, got ${minDenominator}`,
|
|
@@ -51,7 +52,7 @@ function scaleRatio({
|
|
|
51
52
|
function assertWithinWidth(value, width, label) {
|
|
52
53
|
const max = width === "uint64" ? MAX_UINT64 : MAX_UINT128;
|
|
53
54
|
if (value > max) {
|
|
54
|
-
throw new
|
|
55
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
55
56
|
method: "scaleRatio",
|
|
56
57
|
argument: label,
|
|
57
58
|
reason: `exceeds ${width} range`,
|
|
@@ -78,7 +79,7 @@ var share = {
|
|
|
78
79
|
const n = toIntegerBigInt(numerator, "share.fraction", "numerator");
|
|
79
80
|
const m = toIntegerBigInt(denominator, "share.fraction", "denominator");
|
|
80
81
|
if (m <= 0n || m > MAX_FRACTION_DENOMINATOR) {
|
|
81
|
-
throw new
|
|
82
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
82
83
|
method: "share.fraction",
|
|
83
84
|
argument: "denominator",
|
|
84
85
|
reason: `must be in 1..${MAX_FRACTION_DENOMINATOR}, got ${m}`,
|
|
@@ -86,7 +87,7 @@ var share = {
|
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
if (n < 0n || n > m) {
|
|
89
|
-
throw new
|
|
90
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
90
91
|
method: "share.fraction",
|
|
91
92
|
argument: "numerator",
|
|
92
93
|
reason: `must be in 0..${m} (denominator), got ${n}`,
|
|
@@ -111,7 +112,7 @@ var share = {
|
|
|
111
112
|
basisPoints(bps) {
|
|
112
113
|
const value = toIntegerBigInt(bps, "share.basisPoints", "bps");
|
|
113
114
|
if (value < 0n || value > BASIS_POINT_SCALE) {
|
|
114
|
-
throw new
|
|
115
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
115
116
|
method: "share.basisPoints",
|
|
116
117
|
argument: "bps",
|
|
117
118
|
reason: `must be in 0..${BASIS_POINT_SCALE}, got ${value}`,
|
|
@@ -124,7 +125,7 @@ var share = {
|
|
|
124
125
|
function toIntegerBigInt(value, method, argument) {
|
|
125
126
|
if (typeof value === "bigint") return value;
|
|
126
127
|
if (!Number.isInteger(value)) {
|
|
127
|
-
throw new
|
|
128
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
128
129
|
method,
|
|
129
130
|
argument,
|
|
130
131
|
reason: `must be an integer, got ${value}`,
|
|
@@ -133,7 +134,82 @@ function toIntegerBigInt(value, method, argument) {
|
|
|
133
134
|
}
|
|
134
135
|
return BigInt(value);
|
|
135
136
|
}
|
|
137
|
+
function resolveEncryptor(source) {
|
|
138
|
+
if (source === void 0) return void 0;
|
|
139
|
+
return typeof source === "function" ? source() : source;
|
|
140
|
+
}
|
|
141
|
+
var MAX_UINT642 = (1n << 64n) - 1n;
|
|
142
|
+
function assertUint64(value, label) {
|
|
143
|
+
if (value < 0n || value > MAX_UINT642) {
|
|
144
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
145
|
+
method: "encryptUint64",
|
|
146
|
+
argument: label,
|
|
147
|
+
reason: `does not fit in uint64 (0..2^64-1)`,
|
|
148
|
+
value
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function encryptUint64({
|
|
153
|
+
encryptor,
|
|
154
|
+
contractAddress,
|
|
155
|
+
userAddress,
|
|
156
|
+
value
|
|
157
|
+
}) {
|
|
158
|
+
assertUint64(value, "value");
|
|
159
|
+
const { handles, inputProof } = await encryptor.encrypt({
|
|
160
|
+
values: [{ value, type: "euint64" }],
|
|
161
|
+
contractAddress,
|
|
162
|
+
userAddress
|
|
163
|
+
});
|
|
164
|
+
if (handles.length !== 1) {
|
|
165
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
166
|
+
method: "encryptUint64",
|
|
167
|
+
argument: "handles",
|
|
168
|
+
reason: `expected 1 handle, got ${handles.length}`,
|
|
169
|
+
value: handles.length
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
handle: chunk2RNW4MIJ_cjs.asEncryptedHandle(viem.bytesToHex(handles[0])),
|
|
174
|
+
inputProof: chunk2RNW4MIJ_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
async function encryptUint64Batch({
|
|
178
|
+
encryptor,
|
|
179
|
+
contractAddress,
|
|
180
|
+
userAddress,
|
|
181
|
+
values
|
|
182
|
+
}) {
|
|
183
|
+
if (values.length === 0) {
|
|
184
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
185
|
+
method: "encryptUint64Batch",
|
|
186
|
+
argument: "values",
|
|
187
|
+
reason: "must be non-empty"
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
values.forEach((v, i) => assertUint64(v, `values[${i}]`));
|
|
191
|
+
const { handles, inputProof } = await encryptor.encrypt({
|
|
192
|
+
values: values.map((value) => ({ value, type: "euint64" })),
|
|
193
|
+
contractAddress,
|
|
194
|
+
userAddress
|
|
195
|
+
});
|
|
196
|
+
if (handles.length !== values.length) {
|
|
197
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
198
|
+
method: "encryptUint64Batch",
|
|
199
|
+
argument: "handles",
|
|
200
|
+
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
201
|
+
value: handles.length
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
handles: handles.map((h) => chunk2RNW4MIJ_cjs.asEncryptedHandle(viem.bytesToHex(h))),
|
|
206
|
+
inputProof: chunk2RNW4MIJ_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
207
|
+
};
|
|
208
|
+
}
|
|
136
209
|
|
|
137
210
|
exports.FHE_SPLIT_DENOMINATOR = FHE_SPLIT_DENOMINATOR;
|
|
211
|
+
exports.encryptUint64 = encryptUint64;
|
|
212
|
+
exports.encryptUint64Batch = encryptUint64Batch;
|
|
213
|
+
exports.resolveEncryptor = resolveEncryptor;
|
|
138
214
|
exports.scaleRatio = scaleRatio;
|
|
139
215
|
exports.share = share;
|