@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.
Files changed (162) hide show
  1. package/README.md +120 -26
  2. package/dist/{chunk-5SGMJADP.cjs → chunk-2NCLOQ56.cjs} +9 -9
  3. package/dist/{chunk-QIHZVLIK.js → chunk-2PWNH3UE.js} +35 -6
  4. package/dist/{chunk-T5LVV3KY.cjs → chunk-4WPGQSNT.cjs} +3 -3
  5. package/dist/{chunk-SUOG3BQS.cjs → chunk-5X5WL5CU.cjs} +266 -103
  6. package/dist/{chunk-56UI7LUR.cjs → chunk-67OV5CX2.cjs} +19 -0
  7. package/dist/{chunk-WRCUDSUJ.js → chunk-6BMP4ICG.js} +2 -2
  8. package/dist/{chunk-XXXDQSHE.js → chunk-6R4KNAPK.js} +5 -3
  9. package/dist/{chunk-XSNLAS5M.js → chunk-AOP6HMPW.js} +1 -1
  10. package/dist/{chunk-62DF53UQ.cjs → chunk-C7BRZXJA.cjs} +19 -21
  11. package/dist/{chunk-UOG4PJL5.js → chunk-DUZIIRPF.js} +181 -14
  12. package/dist/{chunk-Q7ARQSUH.cjs → chunk-FAXIIH5R.cjs} +3 -3
  13. package/dist/chunk-FT4LNBOS.js +11 -0
  14. package/dist/chunk-IJFQ5L4I.js +2171 -0
  15. package/dist/{chunk-52TC6BF7.js → chunk-IXLO7GO5.js} +210 -47
  16. package/dist/{chunk-CQIPRNS7.cjs → chunk-JK4XMMKM.cjs} +3 -3
  17. package/dist/{chunk-ITQ7WKVC.cjs → chunk-JYOTGRSO.cjs} +8 -8
  18. package/dist/{chunk-VDXVNZCO.cjs → chunk-KLKI352M.cjs} +85 -29
  19. package/dist/{chunk-5SA2HF2W.cjs → chunk-MCRBVJGZ.cjs} +24 -22
  20. package/dist/{chunk-ECT3NL2L.js → chunk-NTZY6IB7.js} +4 -4
  21. package/dist/{chunk-ZHFLRKFY.js → chunk-ODLTEGHB.js} +1 -1
  22. package/dist/{chunk-HGXNRR25.js → chunk-ORFTDNFZ.js} +4 -4
  23. package/dist/{chunk-72YGZEQE.js → chunk-OXTLPTO3.js} +9 -11
  24. package/dist/{chunk-HTOMTEA3.cjs → chunk-PFXURMBZ.cjs} +77 -48
  25. package/dist/{chunk-OLDGMKW2.cjs → chunk-PUPKNW3R.cjs} +35 -2
  26. package/dist/{chunk-IVE3QEGD.js → chunk-QBJ7O2B4.js} +18 -1
  27. package/dist/{chunk-JFLEEXKP.js → chunk-SG65XWH7.js} +58 -2
  28. package/dist/{chunk-K6MFFDBJ.cjs → chunk-T46YXSBP.cjs} +11 -11
  29. package/dist/{chunk-NS44KBV5.cjs → chunk-TEBM66WA.cjs} +12 -12
  30. package/dist/{chunk-6ECAHP5O.cjs → chunk-TIUKIY5V.cjs} +200 -33
  31. package/dist/{chunk-QCA7O2Q5.cjs → chunk-V2PXZVBF.cjs} +4 -4
  32. package/dist/{chunk-JFR5J4FL.cjs → chunk-W7IGCOVL.cjs} +11 -11
  33. package/dist/chunk-WENHUPZC.cjs +2180 -0
  34. package/dist/{chunk-ZXCOJY2Z.js → chunk-WMACINXO.js} +1 -1
  35. package/dist/{chunk-COPFW5Z4.js → chunk-XGGTQQFH.js} +31 -2
  36. package/dist/{chunk-CMRETRZO.js → chunk-YQIBBEFJ.js} +1 -1
  37. package/dist/{chunk-BE2AIZ3K.js → chunk-ZA673I3O.js} +1 -1
  38. package/dist/chunk-ZQUE2B3Q.cjs +33 -0
  39. package/dist/{chunk-FYQ2UW4T.js → chunk-ZWXJTBZO.js} +1 -1
  40. package/dist/core/addresses.d.ts +22 -0
  41. package/dist/core/errors.d.ts +41 -1
  42. package/dist/core/revert-mapper.d.ts +77 -0
  43. package/dist/core/telemetry.d.ts +0 -3
  44. package/dist/core/wagmi-compat.d.ts +40 -0
  45. package/dist/fhe/index.cjs +112 -66
  46. package/dist/fhe/index.d.cts +1 -1
  47. package/dist/fhe/index.d.ts +1 -1
  48. package/dist/fhe/index.js +50 -8
  49. package/dist/fhe/operators.d.ts +1 -1
  50. package/dist/fhe/react/index.cjs +7 -7
  51. package/dist/fhe/react/index.js +2 -2
  52. package/dist/fhe/sepolia-encryptor-web.d.ts +27 -1
  53. package/dist/fhe/sepolia-encryptor.d.ts +38 -0
  54. package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +3 -3
  55. package/dist/fhe-airdrop/advanced/index.cjs +9 -8
  56. package/dist/fhe-airdrop/advanced/index.d.cts +2 -2
  57. package/dist/fhe-airdrop/advanced/index.d.ts +2 -2
  58. package/dist/fhe-airdrop/advanced/index.js +7 -6
  59. package/dist/fhe-airdrop/advanced/react/index.cjs +14 -13
  60. package/dist/fhe-airdrop/advanced/react/index.d.cts +1 -1
  61. package/dist/fhe-airdrop/advanced/react/index.d.ts +1 -1
  62. package/dist/fhe-airdrop/advanced/react/index.js +10 -9
  63. package/dist/fhe-airdrop/airdrop.d.ts +2 -0
  64. package/dist/fhe-airdrop/encryption.d.ts +8 -0
  65. package/dist/fhe-airdrop/factory.d.ts +94 -11
  66. package/dist/fhe-airdrop/index.cjs +61 -57
  67. package/dist/fhe-airdrop/index.d.cts +3 -3
  68. package/dist/fhe-airdrop/index.d.ts +3 -3
  69. package/dist/fhe-airdrop/index.js +7 -7
  70. package/dist/fhe-airdrop/react/index.cjs +163 -133
  71. package/dist/fhe-airdrop/react/index.d.cts +4 -3
  72. package/dist/fhe-airdrop/react/index.d.ts +4 -3
  73. package/dist/fhe-airdrop/react/index.js +38 -13
  74. package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +2 -0
  75. package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +3 -2
  76. package/dist/fhe-airdrop/react/useClaim.d.ts +2 -0
  77. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +8 -0
  78. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +8 -0
  79. package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +8 -0
  80. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +51 -0
  81. package/dist/fhe-airdrop/types.d.ts +45 -0
  82. package/dist/fhe-disperse/encryption.d.ts +8 -0
  83. package/dist/fhe-disperse/index.cjs +69 -65
  84. package/dist/fhe-disperse/index.d.cts +1 -1
  85. package/dist/fhe-disperse/index.d.ts +1 -1
  86. package/dist/fhe-disperse/index.js +8 -8
  87. package/dist/fhe-disperse/react/index.cjs +90 -86
  88. package/dist/fhe-disperse/react/index.d.cts +1 -1
  89. package/dist/fhe-disperse/react/index.d.ts +1 -1
  90. package/dist/fhe-disperse/react/index.js +10 -10
  91. package/dist/fhe-disperse/react/useCalculateFee.d.ts +7 -0
  92. package/dist/fhe-disperse/react/useDisperse.d.ts +9 -0
  93. package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +7 -0
  94. package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +7 -0
  95. package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +8 -2
  96. package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +6 -0
  97. package/dist/fhe-disperse/singleton.d.ts +29 -0
  98. package/dist/fhe-disperse/subtotals.d.ts +6 -0
  99. package/dist/fhe-vesting/advanced/factory-advanced.d.ts +2 -2
  100. package/dist/fhe-vesting/advanced/index.cjs +8 -8
  101. package/dist/fhe-vesting/advanced/index.d.cts +2 -2
  102. package/dist/fhe-vesting/advanced/index.d.ts +2 -2
  103. package/dist/fhe-vesting/advanced/index.js +6 -6
  104. package/dist/fhe-vesting/advanced/react/index.cjs +15 -14
  105. package/dist/fhe-vesting/advanced/react/index.d.cts +1 -1
  106. package/dist/fhe-vesting/advanced/react/index.d.ts +1 -1
  107. package/dist/fhe-vesting/advanced/react/index.js +12 -11
  108. package/dist/fhe-vesting/encryption.d.ts +8 -0
  109. package/dist/fhe-vesting/factory.d.ts +6 -8
  110. package/dist/fhe-vesting/index.cjs +79 -75
  111. package/dist/fhe-vesting/index.d.cts +2 -2
  112. package/dist/fhe-vesting/index.d.ts +2 -2
  113. package/dist/fhe-vesting/index.js +9 -9
  114. package/dist/fhe-vesting/manager.d.ts +101 -3
  115. package/dist/fhe-vesting/react/index.cjs +241 -219
  116. package/dist/fhe-vesting/react/index.d.cts +3 -2
  117. package/dist/fhe-vesting/react/index.d.ts +3 -2
  118. package/dist/fhe-vesting/react/index.js +29 -12
  119. package/dist/fhe-vesting/react/useAdminClaim.d.ts +2 -0
  120. package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +2 -0
  121. package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +8 -0
  122. package/dist/fhe-vesting/react/useClaim.d.ts +2 -0
  123. package/dist/fhe-vesting/react/useCreateVesting.d.ts +8 -0
  124. package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +7 -1
  125. package/dist/fhe-vesting/react/usePartialClaim.d.ts +8 -0
  126. package/dist/fhe-vesting/react/usePreflightCreateVesting.d.ts +37 -0
  127. package/dist/fhe-vesting/react/useVestingClaim.d.ts +2 -0
  128. package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +6 -0
  129. package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +6 -0
  130. package/dist/fhe-vesting/types.d.ts +34 -2
  131. package/dist/index.cjs +73 -49
  132. package/dist/index.d.cts +1 -1
  133. package/dist/index.d.ts +1 -1
  134. package/dist/index.js +2 -2
  135. package/dist/testnet-faucet/abis/confidential-test-token.d.ts +1039 -0
  136. package/dist/testnet-faucet/abis/index.d.ts +2 -0
  137. package/dist/testnet-faucet/abis/test-token.d.ts +253 -0
  138. package/dist/testnet-faucet/errors.d.ts +21 -0
  139. package/dist/testnet-faucet/faucet.d.ts +173 -0
  140. package/dist/testnet-faucet/index.cjs +212 -0
  141. package/dist/testnet-faucet/index.d.cts +8 -0
  142. package/dist/testnet-faucet/index.d.ts +8 -0
  143. package/dist/testnet-faucet/index.js +7 -0
  144. package/dist/testnet-faucet/react/_shared.d.ts +61 -0
  145. package/dist/testnet-faucet/react/index.cjs +384 -0
  146. package/dist/testnet-faucet/react/index.d.cts +39 -0
  147. package/dist/testnet-faucet/react/index.d.ts +39 -0
  148. package/dist/testnet-faucet/react/index.js +220 -0
  149. package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +25 -0
  150. package/dist/testnet-faucet/react/useFaucetDecimals.d.ts +9 -0
  151. package/dist/testnet-faucet/react/useFaucetMetadata.d.ts +14 -0
  152. package/dist/testnet-faucet/react/useFaucetRate.d.ts +11 -0
  153. package/dist/testnet-faucet/react/useInferredTotalSupply.d.ts +11 -0
  154. package/dist/testnet-faucet/react/useMaxTotalSupply.d.ts +10 -0
  155. package/dist/testnet-faucet/react/useMintConfidential.d.ts +35 -0
  156. package/dist/testnet-faucet/react/useMintUnderlying.d.ts +31 -0
  157. package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +19 -0
  158. package/dist/testnet-faucet/react/useUnderlyingDecimals.d.ts +9 -0
  159. package/dist/testnet-faucet/react/useUnderlyingTokenAddress.d.ts +12 -0
  160. package/dist/testnet-faucet/types.d.ts +92 -0
  161. package/dist/testnet-faucet/validate.d.ts +44 -0
  162. package/package.json +79 -30
@@ -0,0 +1,7 @@
1
+ export { FaucetSupplyExhaustedError, TESTNET_FAUCET_SUPPORTED_CHAIN_IDS, TestnetFaucetClient, assertTestnetFaucetChain, confidentialTokenopsTestTokenAbi, createTestnetFaucetClient, isTestnetFaucetChainId, tokenopsTestTokenAbi } from '../chunk-IJFQ5L4I.js';
2
+ import '../chunk-SG65XWH7.js';
3
+ export { getConfidentialTestTokenAddress, getTestTokenAddress, requireConfidentialTestTokenAddress, requireTestTokenAddress } from '../chunk-XGGTQQFH.js';
4
+ import '../chunk-ZA673I3O.js';
5
+ import '../chunk-Q2GP5UDC.js';
6
+ import '../chunk-KWFFIJYX.js';
7
+ export { AccessDeniedError, AlreadyInitializedError, BatchTooLargeError, ContractRevertError, DecryptionFailedError, DeploymentAddressUnavailableError, EncryptionFailedError, FeatureDisabledError, FheHandleNotAllowedError, InsufficientBalanceError, InsufficientFeeError, InsufficientGasFundsError, InvalidArgumentError, InvalidSignatureError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, NetworkError, OperatorNotApprovedError, PausedError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ReentrancyError, RelayerUnreachableError, SigningFailedError, TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, TransferFailedError, UnknownWriteFailureError, UnsupportedChainError, UserDecryptNotAllowedError, UserRejectedSignatureError, WalletChainMismatchError, WalletRejectedError, isTokenOpsSdkError } from '../chunk-QBJ7O2B4.js';
@@ -0,0 +1,61 @@
1
+ import type { Address, PublicClient, WalletClient } from "viem";
2
+ import { type TokenOpsSdkError } from "../../core/errors.js";
3
+ import { type TestnetFaucetClient } from "../faucet.js";
4
+ /** Common per-hook overrides — every public hook accepts these alongside its own args. */
5
+ export interface BaseHookOptions {
6
+ /**
7
+ * Override the on-chain CTTT proxy address. Defaults to
8
+ * {@link getConfidentialTestTokenAddress} keyed by chain id. Mirrors the
9
+ * headless client's single `address` knob — the backing TTT is always derived
10
+ * from this wrapper's `underlying()`, never supplied separately.
11
+ */
12
+ address?: Address;
13
+ /** Override the chain id used for default address resolution. Defaults to `usePublicClient().chain?.id`. */
14
+ chainId?: number;
15
+ }
16
+ /** Stable query-key prefix for every hook in this subpath. */
17
+ export declare const TESTNET_FAUCET_KEY: "tokenops-sdk";
18
+ export declare const TESTNET_FAUCET_NAMESPACE: "testnet-faucet";
19
+ /**
20
+ * Resolve the CTTT proxy address for `chainId` (override → registry entry),
21
+ * returning `undefined` instead of throwing when it can't be resolved. Used by
22
+ * query-key builders and `enabled` gates.
23
+ *
24
+ * Returns `undefined` on a known non-testnet chain (before honoring any
25
+ * `override`) so {@link useMemoFaucetClient}'s `useMemo` never constructs a
26
+ * client — and thus never lets the headless constructor throw
27
+ * `UnsupportedChainError` during render. The unsupported-chain case is surfaced
28
+ * off the render path via {@link computeSingletonResolutionError} instead.
29
+ */
30
+ export declare function tryResolveSingletonAddress(override: Address | undefined, chainId: number | undefined): Address | undefined;
31
+ /**
32
+ * Memoize a {@link TestnetFaucetClient} keyed on
33
+ * `(publicClient, walletClient, address)`.
34
+ *
35
+ * @returns `{ client, resolutionError, publicClient, walletClient, chainId, resolvedAddress }`.
36
+ * `client` is `undefined` when no `publicClient` is available (wagmi may
37
+ * briefly return `undefined` during reconnects) or when the CTTT address
38
+ * could not be resolved — gate queries with `enabled: !!client`.
39
+ * `resolutionError` carries the typed deployment-address error the headless
40
+ * `TestnetFaucetClient` constructor would have thrown (e.g.
41
+ * `DeploymentAddressUnavailableError`); mutation hooks throw it before
42
+ * falling back to a generic `MissingClientError` so consumers see the real
43
+ * "unsupported chain" / "not deployed on this chain" reason.
44
+ */
45
+ export declare function useMemoFaucetClient(opts?: BaseHookOptions): {
46
+ client: TestnetFaucetClient | undefined;
47
+ resolutionError: TokenOpsSdkError | undefined;
48
+ publicClient: PublicClient | undefined;
49
+ walletClient: WalletClient | undefined;
50
+ chainId: number | undefined;
51
+ resolvedAddress: Address | undefined;
52
+ };
53
+ /**
54
+ * Build a stable TanStack Query key for a testnet-faucet hook.
55
+ *
56
+ * Conventions:
57
+ * - Lowercase the contract address (TanStack uses structural equality; viem
58
+ * sometimes returns checksummed addresses).
59
+ * - Convert bigints to base-10 strings (TanStack's serializer doesn't handle bigints).
60
+ */
61
+ export declare function buildQueryKey(method: string, chainId: number | undefined, address: Address | undefined, ...args: ReadonlyArray<unknown>): ReadonlyArray<unknown>;
@@ -0,0 +1,384 @@
1
+ 'use strict';
2
+
3
+ var chunkZQUE2B3Q_cjs = require('../../chunk-ZQUE2B3Q.cjs');
4
+ var chunkWENHUPZC_cjs = require('../../chunk-WENHUPZC.cjs');
5
+ require('../../chunk-KLKI352M.cjs');
6
+ var chunkPUPKNW3R_cjs = require('../../chunk-PUPKNW3R.cjs');
7
+ require('../../chunk-JK4XMMKM.cjs');
8
+ require('../../chunk-VJKZWYYJ.cjs');
9
+ require('../../chunk-66IHPTOK.cjs');
10
+ var chunk67OV5CX2_cjs = require('../../chunk-67OV5CX2.cjs');
11
+ var reactQuery = require('@tanstack/react-query');
12
+ var react = require('react');
13
+ var wagmi = require('wagmi');
14
+
15
+ var TESTNET_FAUCET_KEY = "tokenops-sdk";
16
+ var TESTNET_FAUCET_NAMESPACE = "testnet-faucet";
17
+ function tryResolveSingletonAddress(override, chainId) {
18
+ if (chainId !== void 0 && !chunkWENHUPZC_cjs.isTestnetFaucetChainId(chainId)) return void 0;
19
+ if (override) return override;
20
+ if (chainId === void 0) return void 0;
21
+ return chunkPUPKNW3R_cjs.getConfidentialTestTokenAddress(chainId);
22
+ }
23
+ function useMemoFaucetClient(opts = {}) {
24
+ const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
25
+ const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
26
+ const chainId = opts.chainId ?? publicClient?.chain?.id;
27
+ const resolvedAddress = tryResolveSingletonAddress(opts.address, chainId);
28
+ const resolutionError = computeSingletonResolutionError(opts.address, chainId);
29
+ const client = react.useMemo(() => {
30
+ if (!publicClient) return void 0;
31
+ if (!resolvedAddress) return void 0;
32
+ return chunkWENHUPZC_cjs.createTestnetFaucetClient({
33
+ publicClient,
34
+ ...walletClient ? { walletClient } : {},
35
+ ...opts.address ? { address: resolvedAddress } : {},
36
+ ...chainId !== void 0 ? { chainId } : {}
37
+ });
38
+ }, [publicClient, walletClient, resolvedAddress, chainId]);
39
+ return {
40
+ client,
41
+ resolutionError,
42
+ publicClient,
43
+ walletClient: walletClient ?? void 0,
44
+ chainId,
45
+ resolvedAddress
46
+ };
47
+ }
48
+ function computeSingletonResolutionError(override, chainId) {
49
+ if (chainId !== void 0 && !chunkWENHUPZC_cjs.isTestnetFaucetChainId(chainId)) {
50
+ return new chunk67OV5CX2_cjs.UnsupportedChainError(chainId);
51
+ }
52
+ if (override) return void 0;
53
+ if (chainId === void 0) {
54
+ return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
55
+ reason: "chain-id-missing",
56
+ product: "testnetFaucet",
57
+ contract: "confidentialTestToken",
58
+ clientLabel: "TestnetFaucetClient"
59
+ });
60
+ }
61
+ const resolved = chunkPUPKNW3R_cjs.getConfidentialTestTokenAddress(chainId);
62
+ if (!resolved) {
63
+ return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
64
+ reason: "registry-not-deployed",
65
+ product: "testnetFaucet",
66
+ contract: "confidentialTestToken",
67
+ chainId,
68
+ clientLabel: "TestnetFaucetClient"
69
+ });
70
+ }
71
+ return void 0;
72
+ }
73
+ function buildQueryKey(method, chainId, address, ...args) {
74
+ return [
75
+ TESTNET_FAUCET_KEY,
76
+ TESTNET_FAUCET_NAMESPACE,
77
+ method,
78
+ chainId ?? null,
79
+ address ? address.toLowerCase() : null,
80
+ ...args.map(normalizeKeyArg)
81
+ ];
82
+ }
83
+ function normalizeKeyArg(value) {
84
+ if (typeof value === "bigint") return value.toString();
85
+ if (Array.isArray(value)) return value.map(normalizeKeyArg);
86
+ if (value && typeof value === "object") {
87
+ return Object.fromEntries(
88
+ Object.entries(value).map(([k, v]) => [k, normalizeKeyArg(v)])
89
+ );
90
+ }
91
+ if (typeof value === "string" && value.startsWith("0x")) return value.toLowerCase();
92
+ return value;
93
+ }
94
+
95
+ // src/testnet-faucet/react/useConfidentialBalance.ts
96
+ function useConfidentialBalance(args = {}) {
97
+ const { account, ...base } = args;
98
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(base);
99
+ const { address: connected } = chunkZQUE2B3Q_cjs.useWagmiAccount();
100
+ const resolvedAccount = account ?? connected;
101
+ return reactQuery.useQuery({
102
+ queryKey: buildQueryKey("confidentialBalanceOf", chainId, resolvedAddress, resolvedAccount),
103
+ queryFn: () => client.confidentialBalanceOf(resolvedAccount),
104
+ enabled: !!client && !!resolvedAccount,
105
+ staleTime: 0
106
+ });
107
+ }
108
+ function useUnderlyingBalance(args = {}) {
109
+ const { account, ...base } = args;
110
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(base);
111
+ const { address: connected } = chunkZQUE2B3Q_cjs.useWagmiAccount();
112
+ const resolvedAccount = account ?? connected;
113
+ return reactQuery.useQuery({
114
+ // The TTT is derived from the CTTT, which is already keyed via
115
+ // `resolvedAddress` — no separate underlying segment needed.
116
+ queryKey: buildQueryKey("underlyingBalanceOf", chainId, resolvedAddress, resolvedAccount),
117
+ queryFn: () => client.underlyingBalanceOf(resolvedAccount),
118
+ enabled: !!client && !!resolvedAccount,
119
+ staleTime: 0
120
+ });
121
+ }
122
+ function useFaucetRate(options = {}) {
123
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
124
+ return reactQuery.useQuery({
125
+ queryKey: buildQueryKey("rate", chainId, resolvedAddress),
126
+ queryFn: () => client.rate(),
127
+ enabled: !!client,
128
+ // The conversion rate is fixed per deployment — never goes stale.
129
+ staleTime: Infinity
130
+ });
131
+ }
132
+ function useFaucetDecimals(options = {}) {
133
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
134
+ return reactQuery.useQuery({
135
+ queryKey: buildQueryKey("decimals", chainId, resolvedAddress),
136
+ queryFn: () => client.decimals(),
137
+ enabled: !!client,
138
+ // CTTT decimals are fixed per deployment — never goes stale.
139
+ staleTime: Infinity
140
+ });
141
+ }
142
+ function useUnderlyingDecimals(options = {}) {
143
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
144
+ return reactQuery.useQuery({
145
+ // The TTT is derived from the CTTT, which is already keyed via
146
+ // `resolvedAddress` — no separate underlying segment needed.
147
+ queryKey: buildQueryKey("underlyingDecimals", chainId, resolvedAddress),
148
+ queryFn: () => client.underlyingDecimals(),
149
+ enabled: !!client,
150
+ // TTT decimals are fixed per deployment — never goes stale.
151
+ staleTime: Infinity
152
+ });
153
+ }
154
+ function useUnderlyingTokenAddress(options = {}) {
155
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
156
+ return reactQuery.useQuery({
157
+ // The TTT is derived from the CTTT, which is already keyed via
158
+ // `resolvedAddress` — no separate underlying segment needed.
159
+ queryKey: buildQueryKey("underlyingToken", chainId, resolvedAddress),
160
+ queryFn: () => client.underlyingToken(),
161
+ enabled: !!client,
162
+ // The backing token address is fixed per deployment — never goes stale.
163
+ staleTime: Infinity
164
+ });
165
+ }
166
+ function useInferredTotalSupply(options = {}) {
167
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
168
+ return reactQuery.useQuery({
169
+ queryKey: buildQueryKey("inferredTotalSupply", chainId, resolvedAddress),
170
+ queryFn: () => client.inferredTotalSupply(),
171
+ enabled: !!client,
172
+ staleTime: 0
173
+ });
174
+ }
175
+ function useMaxTotalSupply(options = {}) {
176
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
177
+ return reactQuery.useQuery({
178
+ queryKey: buildQueryKey("maxTotalSupply", chainId, resolvedAddress),
179
+ queryFn: () => client.maxTotalSupply(),
180
+ enabled: !!client,
181
+ // `type(uint64).max` is fixed per deployment — never goes stale.
182
+ staleTime: Infinity
183
+ });
184
+ }
185
+ function useFaucetMetadata(options = {}) {
186
+ const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
187
+ return reactQuery.useQuery({
188
+ // The `underlying` half of the metadata is derived from the CTTT, which is
189
+ // already keyed via `resolvedAddress` — no separate underlying segment needed.
190
+ queryKey: buildQueryKey("getMetadata", chainId, resolvedAddress),
191
+ queryFn: () => client.getMetadata(),
192
+ enabled: !!client,
193
+ // name/symbol/decimals/rate/maxTotalSupply are all fixed per deployment.
194
+ staleTime: Infinity
195
+ });
196
+ }
197
+ function useMintConfidential(options = {}) {
198
+ const { client, resolutionError } = useMemoFaucetClient(options);
199
+ return reactQuery.useMutation({
200
+ mutationFn: async (args) => {
201
+ if (!client) {
202
+ throw resolutionError ?? new chunk67OV5CX2_cjs.MissingClientError("useMintConfidential", "testnet-faucet");
203
+ }
204
+ return client.mintConfidential(args);
205
+ }
206
+ });
207
+ }
208
+ function useMintUnderlying(options = {}) {
209
+ const { client, resolutionError } = useMemoFaucetClient(options);
210
+ return reactQuery.useMutation({
211
+ mutationFn: async (args) => {
212
+ if (!client) {
213
+ throw resolutionError ?? new chunk67OV5CX2_cjs.MissingClientError("useMintUnderlying", "testnet-faucet");
214
+ }
215
+ return client.mintUnderlying(args);
216
+ }
217
+ });
218
+ }
219
+
220
+ Object.defineProperty(exports, "FaucetSupplyExhaustedError", {
221
+ enumerable: true,
222
+ get: function () { return chunkWENHUPZC_cjs.FaucetSupplyExhaustedError; }
223
+ });
224
+ Object.defineProperty(exports, "AccessDeniedError", {
225
+ enumerable: true,
226
+ get: function () { return chunk67OV5CX2_cjs.AccessDeniedError; }
227
+ });
228
+ Object.defineProperty(exports, "AlreadyInitializedError", {
229
+ enumerable: true,
230
+ get: function () { return chunk67OV5CX2_cjs.AlreadyInitializedError; }
231
+ });
232
+ Object.defineProperty(exports, "BatchTooLargeError", {
233
+ enumerable: true,
234
+ get: function () { return chunk67OV5CX2_cjs.BatchTooLargeError; }
235
+ });
236
+ Object.defineProperty(exports, "ContractRevertError", {
237
+ enumerable: true,
238
+ get: function () { return chunk67OV5CX2_cjs.ContractRevertError; }
239
+ });
240
+ Object.defineProperty(exports, "DecryptionFailedError", {
241
+ enumerable: true,
242
+ get: function () { return chunk67OV5CX2_cjs.DecryptionFailedError; }
243
+ });
244
+ Object.defineProperty(exports, "DeploymentAddressUnavailableError", {
245
+ enumerable: true,
246
+ get: function () { return chunk67OV5CX2_cjs.DeploymentAddressUnavailableError; }
247
+ });
248
+ Object.defineProperty(exports, "EncryptionFailedError", {
249
+ enumerable: true,
250
+ get: function () { return chunk67OV5CX2_cjs.EncryptionFailedError; }
251
+ });
252
+ Object.defineProperty(exports, "FeatureDisabledError", {
253
+ enumerable: true,
254
+ get: function () { return chunk67OV5CX2_cjs.FeatureDisabledError; }
255
+ });
256
+ Object.defineProperty(exports, "FheHandleNotAllowedError", {
257
+ enumerable: true,
258
+ get: function () { return chunk67OV5CX2_cjs.FheHandleNotAllowedError; }
259
+ });
260
+ Object.defineProperty(exports, "InsufficientBalanceError", {
261
+ enumerable: true,
262
+ get: function () { return chunk67OV5CX2_cjs.InsufficientBalanceError; }
263
+ });
264
+ Object.defineProperty(exports, "InsufficientFeeError", {
265
+ enumerable: true,
266
+ get: function () { return chunk67OV5CX2_cjs.InsufficientFeeError; }
267
+ });
268
+ Object.defineProperty(exports, "InsufficientGasFundsError", {
269
+ enumerable: true,
270
+ get: function () { return chunk67OV5CX2_cjs.InsufficientGasFundsError; }
271
+ });
272
+ Object.defineProperty(exports, "InvalidArgumentError", {
273
+ enumerable: true,
274
+ get: function () { return chunk67OV5CX2_cjs.InvalidArgumentError; }
275
+ });
276
+ Object.defineProperty(exports, "InvalidSignatureError", {
277
+ enumerable: true,
278
+ get: function () { return chunk67OV5CX2_cjs.InvalidSignatureError; }
279
+ });
280
+ Object.defineProperty(exports, "MissingAccountError", {
281
+ enumerable: true,
282
+ get: function () { return chunk67OV5CX2_cjs.MissingAccountError; }
283
+ });
284
+ Object.defineProperty(exports, "MissingClientError", {
285
+ enumerable: true,
286
+ get: function () { return chunk67OV5CX2_cjs.MissingClientError; }
287
+ });
288
+ Object.defineProperty(exports, "MissingEncryptorError", {
289
+ enumerable: true,
290
+ get: function () { return chunk67OV5CX2_cjs.MissingEncryptorError; }
291
+ });
292
+ Object.defineProperty(exports, "MissingPublicClientError", {
293
+ enumerable: true,
294
+ get: function () { return chunk67OV5CX2_cjs.MissingPublicClientError; }
295
+ });
296
+ Object.defineProperty(exports, "MissingWalletClientError", {
297
+ enumerable: true,
298
+ get: function () { return chunk67OV5CX2_cjs.MissingWalletClientError; }
299
+ });
300
+ Object.defineProperty(exports, "NetworkError", {
301
+ enumerable: true,
302
+ get: function () { return chunk67OV5CX2_cjs.NetworkError; }
303
+ });
304
+ Object.defineProperty(exports, "OperatorNotApprovedError", {
305
+ enumerable: true,
306
+ get: function () { return chunk67OV5CX2_cjs.OperatorNotApprovedError; }
307
+ });
308
+ Object.defineProperty(exports, "PausedError", {
309
+ enumerable: true,
310
+ get: function () { return chunk67OV5CX2_cjs.PausedError; }
311
+ });
312
+ Object.defineProperty(exports, "ReceiptEventAmbiguousError", {
313
+ enumerable: true,
314
+ get: function () { return chunk67OV5CX2_cjs.ReceiptEventAmbiguousError; }
315
+ });
316
+ Object.defineProperty(exports, "ReceiptEventNotFoundError", {
317
+ enumerable: true,
318
+ get: function () { return chunk67OV5CX2_cjs.ReceiptEventNotFoundError; }
319
+ });
320
+ Object.defineProperty(exports, "ReentrancyError", {
321
+ enumerable: true,
322
+ get: function () { return chunk67OV5CX2_cjs.ReentrancyError; }
323
+ });
324
+ Object.defineProperty(exports, "RelayerUnreachableError", {
325
+ enumerable: true,
326
+ get: function () { return chunk67OV5CX2_cjs.RelayerUnreachableError; }
327
+ });
328
+ Object.defineProperty(exports, "SigningFailedError", {
329
+ enumerable: true,
330
+ get: function () { return chunk67OV5CX2_cjs.SigningFailedError; }
331
+ });
332
+ Object.defineProperty(exports, "TokenOpsContractError", {
333
+ enumerable: true,
334
+ get: function () { return chunk67OV5CX2_cjs.TokenOpsContractError; }
335
+ });
336
+ Object.defineProperty(exports, "TokenOpsSdkError", {
337
+ enumerable: true,
338
+ get: function () { return chunk67OV5CX2_cjs.TokenOpsSdkError; }
339
+ });
340
+ Object.defineProperty(exports, "TransferFailedError", {
341
+ enumerable: true,
342
+ get: function () { return chunk67OV5CX2_cjs.TransferFailedError; }
343
+ });
344
+ Object.defineProperty(exports, "UnknownWriteFailureError", {
345
+ enumerable: true,
346
+ get: function () { return chunk67OV5CX2_cjs.UnknownWriteFailureError; }
347
+ });
348
+ Object.defineProperty(exports, "UnsupportedChainError", {
349
+ enumerable: true,
350
+ get: function () { return chunk67OV5CX2_cjs.UnsupportedChainError; }
351
+ });
352
+ Object.defineProperty(exports, "UserDecryptNotAllowedError", {
353
+ enumerable: true,
354
+ get: function () { return chunk67OV5CX2_cjs.UserDecryptNotAllowedError; }
355
+ });
356
+ Object.defineProperty(exports, "UserRejectedSignatureError", {
357
+ enumerable: true,
358
+ get: function () { return chunk67OV5CX2_cjs.UserRejectedSignatureError; }
359
+ });
360
+ Object.defineProperty(exports, "WalletChainMismatchError", {
361
+ enumerable: true,
362
+ get: function () { return chunk67OV5CX2_cjs.WalletChainMismatchError; }
363
+ });
364
+ Object.defineProperty(exports, "WalletRejectedError", {
365
+ enumerable: true,
366
+ get: function () { return chunk67OV5CX2_cjs.WalletRejectedError; }
367
+ });
368
+ Object.defineProperty(exports, "isTokenOpsSdkError", {
369
+ enumerable: true,
370
+ get: function () { return chunk67OV5CX2_cjs.isTokenOpsSdkError; }
371
+ });
372
+ exports.TESTNET_FAUCET_KEY = TESTNET_FAUCET_KEY;
373
+ exports.TESTNET_FAUCET_NAMESPACE = TESTNET_FAUCET_NAMESPACE;
374
+ exports.useConfidentialBalance = useConfidentialBalance;
375
+ exports.useFaucetDecimals = useFaucetDecimals;
376
+ exports.useFaucetMetadata = useFaucetMetadata;
377
+ exports.useFaucetRate = useFaucetRate;
378
+ exports.useInferredTotalSupply = useInferredTotalSupply;
379
+ exports.useMaxTotalSupply = useMaxTotalSupply;
380
+ exports.useMintConfidential = useMintConfidential;
381
+ exports.useMintUnderlying = useMintUnderlying;
382
+ exports.useUnderlyingBalance = useUnderlyingBalance;
383
+ exports.useUnderlyingDecimals = useUnderlyingDecimals;
384
+ exports.useUnderlyingTokenAddress = useUnderlyingTokenAddress;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * React/wagmi hooks for `@tokenops/sdk/testnet-faucet`.
3
+ *
4
+ * Every public method on the headless `TestnetFaucetClient` is wrapped as
5
+ * a hook here. Hooks compose with wagmi (`usePublicClient`, `useWalletClient`,
6
+ * and the account hook — v2 `useAccount` / v3 `useConnection`) and TanStack
7
+ * Query (`useQuery`, `useMutation`) — no extra
8
+ * provider needed beyond the standard wagmi `<WagmiProvider>` +
9
+ * `<QueryClientProvider>`.
10
+ *
11
+ * The CTTT proxy address is resolved per-chain via
12
+ * `getConfidentialTestTokenAddress`. Pass `address` to
13
+ * {@link BaseHookOptions} to override (e.g. for forks or local deployments).
14
+ *
15
+ * **No encryptor.** Unlike the FHE products, the faucet mints take PUBLIC
16
+ * plaintext amounts — no `encryptor`, no ACL address, and nothing imported
17
+ * from `@zama-fhe/react-sdk`. A pure-Node or pure-React consumer needs none of
18
+ * the Zama optional peer to use the faucet.
19
+ *
20
+ * Mutations do NOT auto-invalidate read queries — that's a consumer decision.
21
+ * Each mutation's TSDoc documents the recommended
22
+ * `queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "testnet-faucet"] })`.
23
+ */
24
+ export { useConfidentialBalance, type UseConfidentialBalanceArgs, } from "./useConfidentialBalance.js";
25
+ export { useUnderlyingBalance, type UseUnderlyingBalanceArgs } from "./useUnderlyingBalance.js";
26
+ export { useFaucetRate } from "./useFaucetRate.js";
27
+ export { useFaucetDecimals } from "./useFaucetDecimals.js";
28
+ export { useUnderlyingDecimals } from "./useUnderlyingDecimals.js";
29
+ export { useUnderlyingTokenAddress } from "./useUnderlyingTokenAddress.js";
30
+ export { useInferredTotalSupply } from "./useInferredTotalSupply.js";
31
+ export { useMaxTotalSupply } from "./useMaxTotalSupply.js";
32
+ export { useFaucetMetadata } from "./useFaucetMetadata.js";
33
+ export { useMintConfidential, type UseMintConfidentialArgs } from "./useMintConfidential.js";
34
+ export { useMintUnderlying, type UseMintUnderlyingArgs } from "./useMintUnderlying.js";
35
+ export type { BaseHookOptions } from "./_shared.js";
36
+ export { TESTNET_FAUCET_KEY, TESTNET_FAUCET_NAMESPACE } from "./_shared.js";
37
+ export type { FaucetMetadata, FaucetTokenMetadata, MintConfidentialArgs, MintConfidentialResult, MintUnderlyingArgs, MintUnderlyingResult, } from "../types.js";
38
+ export { TokenOpsSdkError, isTokenOpsSdkError, DeploymentAddressUnavailableError, UnsupportedChainError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, InvalidArgumentError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ContractRevertError, TokenOpsContractError, PausedError, AccessDeniedError, OperatorNotApprovedError, InsufficientFeeError, InsufficientBalanceError, BatchTooLargeError, FeatureDisabledError, TransferFailedError, FheHandleNotAllowedError, AlreadyInitializedError, ReentrancyError, InvalidSignatureError, WalletRejectedError, WalletChainMismatchError, NetworkError, InsufficientGasFundsError, UnknownWriteFailureError, UserRejectedSignatureError, SigningFailedError, RelayerUnreachableError, EncryptionFailedError, DecryptionFailedError, UserDecryptNotAllowedError, type DeploymentAddressUnavailableReason, type TokenOpsSdkErrorCode, } from "../../core/errors.js";
39
+ export { FaucetSupplyExhaustedError } from "../errors.js";
@@ -0,0 +1,39 @@
1
+ /**
2
+ * React/wagmi hooks for `@tokenops/sdk/testnet-faucet`.
3
+ *
4
+ * Every public method on the headless `TestnetFaucetClient` is wrapped as
5
+ * a hook here. Hooks compose with wagmi (`usePublicClient`, `useWalletClient`,
6
+ * and the account hook — v2 `useAccount` / v3 `useConnection`) and TanStack
7
+ * Query (`useQuery`, `useMutation`) — no extra
8
+ * provider needed beyond the standard wagmi `<WagmiProvider>` +
9
+ * `<QueryClientProvider>`.
10
+ *
11
+ * The CTTT proxy address is resolved per-chain via
12
+ * `getConfidentialTestTokenAddress`. Pass `address` to
13
+ * {@link BaseHookOptions} to override (e.g. for forks or local deployments).
14
+ *
15
+ * **No encryptor.** Unlike the FHE products, the faucet mints take PUBLIC
16
+ * plaintext amounts — no `encryptor`, no ACL address, and nothing imported
17
+ * from `@zama-fhe/react-sdk`. A pure-Node or pure-React consumer needs none of
18
+ * the Zama optional peer to use the faucet.
19
+ *
20
+ * Mutations do NOT auto-invalidate read queries — that's a consumer decision.
21
+ * Each mutation's TSDoc documents the recommended
22
+ * `queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "testnet-faucet"] })`.
23
+ */
24
+ export { useConfidentialBalance, type UseConfidentialBalanceArgs, } from "./useConfidentialBalance.js";
25
+ export { useUnderlyingBalance, type UseUnderlyingBalanceArgs } from "./useUnderlyingBalance.js";
26
+ export { useFaucetRate } from "./useFaucetRate.js";
27
+ export { useFaucetDecimals } from "./useFaucetDecimals.js";
28
+ export { useUnderlyingDecimals } from "./useUnderlyingDecimals.js";
29
+ export { useUnderlyingTokenAddress } from "./useUnderlyingTokenAddress.js";
30
+ export { useInferredTotalSupply } from "./useInferredTotalSupply.js";
31
+ export { useMaxTotalSupply } from "./useMaxTotalSupply.js";
32
+ export { useFaucetMetadata } from "./useFaucetMetadata.js";
33
+ export { useMintConfidential, type UseMintConfidentialArgs } from "./useMintConfidential.js";
34
+ export { useMintUnderlying, type UseMintUnderlyingArgs } from "./useMintUnderlying.js";
35
+ export type { BaseHookOptions } from "./_shared.js";
36
+ export { TESTNET_FAUCET_KEY, TESTNET_FAUCET_NAMESPACE } from "./_shared.js";
37
+ export type { FaucetMetadata, FaucetTokenMetadata, MintConfidentialArgs, MintConfidentialResult, MintUnderlyingArgs, MintUnderlyingResult, } from "../types.js";
38
+ export { TokenOpsSdkError, isTokenOpsSdkError, DeploymentAddressUnavailableError, UnsupportedChainError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, InvalidArgumentError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ContractRevertError, TokenOpsContractError, PausedError, AccessDeniedError, OperatorNotApprovedError, InsufficientFeeError, InsufficientBalanceError, BatchTooLargeError, FeatureDisabledError, TransferFailedError, FheHandleNotAllowedError, AlreadyInitializedError, ReentrancyError, InvalidSignatureError, WalletRejectedError, WalletChainMismatchError, NetworkError, InsufficientGasFundsError, UnknownWriteFailureError, UserRejectedSignatureError, SigningFailedError, RelayerUnreachableError, EncryptionFailedError, DecryptionFailedError, UserDecryptNotAllowedError, type DeploymentAddressUnavailableReason, type TokenOpsSdkErrorCode, } from "../../core/errors.js";
39
+ export { FaucetSupplyExhaustedError } from "../errors.js";