@tokenops/sdk 1.0.0 → 1.1.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 +102 -18
- package/dist/{chunk-HTOMTEA3.cjs → chunk-23F7JIK5.cjs} +2 -2
- package/dist/{chunk-ECT3NL2L.js → chunk-3PQ2RFPC.js} +3 -3
- package/dist/{chunk-OLDGMKW2.cjs → chunk-3ZRHDTEX.cjs} +33 -0
- package/dist/chunk-5KHIQG7Y.cjs +2180 -0
- package/dist/{chunk-T5LVV3KY.cjs → chunk-FPQBFIUW.cjs} +3 -3
- package/dist/{chunk-QIHZVLIK.js → chunk-FXCW7LVB.js} +1 -1
- package/dist/{chunk-K6MFFDBJ.cjs → chunk-G7G75C46.cjs} +6 -6
- package/dist/{chunk-72YGZEQE.js → chunk-IR5AK5U5.js} +6 -8
- package/dist/{chunk-CMRETRZO.js → chunk-ITQBDRWX.js} +1 -1
- package/dist/{chunk-ZHFLRKFY.js → chunk-JJ4R5QXF.js} +1 -1
- package/dist/{chunk-COPFW5Z4.js → chunk-M7V2EDPB.js} +30 -1
- package/dist/{chunk-UOG4PJL5.js → chunk-OQZAZIAS.js} +8 -10
- package/dist/{chunk-SUOG3BQS.cjs → chunk-OYLZEEHF.cjs} +1 -2
- package/dist/chunk-QE7ZONJ2.js +2171 -0
- package/dist/{chunk-62DF53UQ.cjs → chunk-SAGJIEQK.cjs} +7 -9
- package/dist/{chunk-JFR5J4FL.cjs → chunk-SEKC7H5Y.cjs} +8 -8
- package/dist/{chunk-6ECAHP5O.cjs → chunk-SYHXDHWX.cjs} +9 -11
- package/dist/{chunk-QCA7O2Q5.cjs → chunk-W7JHOK7G.cjs} +4 -4
- package/dist/{chunk-52TC6BF7.js → chunk-X56UVEXS.js} +1 -2
- package/dist/{chunk-HGXNRR25.js → chunk-XWDVPV42.js} +2 -2
- package/dist/core/addresses.d.ts +22 -0
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/telemetry.d.ts +0 -3
- package/dist/fhe/operators.d.ts +1 -1
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +3 -3
- package/dist/fhe-airdrop/advanced/index.cjs +5 -5
- 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 +3 -3
- package/dist/fhe-airdrop/advanced/react/index.cjs +8 -8
- 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 +4 -4
- package/dist/fhe-airdrop/factory.d.ts +8 -10
- package/dist/fhe-airdrop/index.cjs +9 -9
- package/dist/fhe-airdrop/index.js +2 -2
- package/dist/fhe-airdrop/react/index.cjs +69 -69
- package/dist/fhe-airdrop/react/index.js +4 -4
- package/dist/fhe-disperse/index.cjs +19 -19
- package/dist/fhe-disperse/index.js +2 -2
- package/dist/fhe-disperse/react/index.cjs +20 -20
- package/dist/fhe-disperse/react/index.js +3 -3
- package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +2 -2
- package/dist/fhe-vesting/advanced/factory-advanced.d.ts +2 -2
- package/dist/fhe-vesting/advanced/index.cjs +5 -5
- 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 +3 -3
- package/dist/fhe-vesting/advanced/react/index.cjs +8 -8
- 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 +5 -5
- package/dist/fhe-vesting/factory.d.ts +6 -8
- package/dist/fhe-vesting/index.cjs +25 -25
- package/dist/fhe-vesting/index.js +3 -3
- package/dist/fhe-vesting/manager.d.ts +1 -2
- package/dist/fhe-vesting/react/index.cjs +126 -126
- package/dist/fhe-vesting/react/index.js +4 -4
- package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +1 -1
- package/dist/fhe-vesting/types.d.ts +0 -2
- package/dist/index.cjs +27 -11
- package/dist/index.js +1 -1
- 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 +208 -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 +379 -0
- package/dist/testnet-faucet/react/index.d.cts +38 -0
- package/dist/testnet-faucet/react/index.d.ts +38 -0
- package/dist/testnet-faucet/react/index.js +219 -0
- package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +24 -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 +77 -29
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { FaucetSupplyExhaustedError, TESTNET_FAUCET_SUPPORTED_CHAIN_IDS, TestnetFaucetClient, assertTestnetFaucetChain, confidentialTokenopsTestTokenAbi, createTestnetFaucetClient, isTestnetFaucetChainId, tokenopsTestTokenAbi } from '../chunk-QE7ZONJ2.js';
|
|
2
|
+
import '../chunk-JFLEEXKP.js';
|
|
3
|
+
export { getConfidentialTestTokenAddress, getTestTokenAddress, requireConfidentialTestTokenAddress, requireTestTokenAddress } from '../chunk-M7V2EDPB.js';
|
|
4
|
+
import '../chunk-BE2AIZ3K.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, PausedError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ReentrancyError, RelayerUnreachableError, SigningFailedError, TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, TransferFailedError, UnknownWriteFailureError, UnsupportedChainError, UserDecryptNotAllowedError, UserRejectedSignatureError, WalletChainMismatchError, WalletRejectedError, isTokenOpsSdkError } from '../chunk-IVE3QEGD.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,379 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5KHIQG7Y_cjs = require('../../chunk-5KHIQG7Y.cjs');
|
|
4
|
+
require('../../chunk-VDXVNZCO.cjs');
|
|
5
|
+
var chunk3ZRHDTEX_cjs = require('../../chunk-3ZRHDTEX.cjs');
|
|
6
|
+
require('../../chunk-CQIPRNS7.cjs');
|
|
7
|
+
require('../../chunk-VJKZWYYJ.cjs');
|
|
8
|
+
require('../../chunk-66IHPTOK.cjs');
|
|
9
|
+
var chunk56UI7LUR_cjs = require('../../chunk-56UI7LUR.cjs');
|
|
10
|
+
var reactQuery = require('@tanstack/react-query');
|
|
11
|
+
var wagmi = require('wagmi');
|
|
12
|
+
var react = require('react');
|
|
13
|
+
|
|
14
|
+
var TESTNET_FAUCET_KEY = "tokenops-sdk";
|
|
15
|
+
var TESTNET_FAUCET_NAMESPACE = "testnet-faucet";
|
|
16
|
+
function tryResolveSingletonAddress(override, chainId) {
|
|
17
|
+
if (chainId !== void 0 && !chunk5KHIQG7Y_cjs.isTestnetFaucetChainId(chainId)) return void 0;
|
|
18
|
+
if (override) return override;
|
|
19
|
+
if (chainId === void 0) return void 0;
|
|
20
|
+
return chunk3ZRHDTEX_cjs.getConfidentialTestTokenAddress(chainId);
|
|
21
|
+
}
|
|
22
|
+
function useMemoFaucetClient(opts = {}) {
|
|
23
|
+
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
24
|
+
const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
|
|
25
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
26
|
+
const resolvedAddress = tryResolveSingletonAddress(opts.address, chainId);
|
|
27
|
+
const resolutionError = computeSingletonResolutionError(opts.address, chainId);
|
|
28
|
+
const client = react.useMemo(() => {
|
|
29
|
+
if (!publicClient) return void 0;
|
|
30
|
+
if (!resolvedAddress) return void 0;
|
|
31
|
+
return chunk5KHIQG7Y_cjs.createTestnetFaucetClient({
|
|
32
|
+
publicClient,
|
|
33
|
+
...walletClient ? { walletClient } : {},
|
|
34
|
+
...opts.address ? { address: resolvedAddress } : {},
|
|
35
|
+
...chainId !== void 0 ? { chainId } : {}
|
|
36
|
+
});
|
|
37
|
+
}, [publicClient, walletClient, resolvedAddress, chainId]);
|
|
38
|
+
return {
|
|
39
|
+
client,
|
|
40
|
+
resolutionError,
|
|
41
|
+
publicClient,
|
|
42
|
+
walletClient: walletClient ?? void 0,
|
|
43
|
+
chainId,
|
|
44
|
+
resolvedAddress
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function computeSingletonResolutionError(override, chainId) {
|
|
48
|
+
if (chainId !== void 0 && !chunk5KHIQG7Y_cjs.isTestnetFaucetChainId(chainId)) {
|
|
49
|
+
return new chunk56UI7LUR_cjs.UnsupportedChainError(chainId);
|
|
50
|
+
}
|
|
51
|
+
if (override) return void 0;
|
|
52
|
+
if (chainId === void 0) {
|
|
53
|
+
return new chunk56UI7LUR_cjs.DeploymentAddressUnavailableError({
|
|
54
|
+
reason: "chain-id-missing",
|
|
55
|
+
product: "testnetFaucet",
|
|
56
|
+
contract: "confidentialTestToken",
|
|
57
|
+
clientLabel: "TestnetFaucetClient"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const resolved = chunk3ZRHDTEX_cjs.getConfidentialTestTokenAddress(chainId);
|
|
61
|
+
if (!resolved) {
|
|
62
|
+
return new chunk56UI7LUR_cjs.DeploymentAddressUnavailableError({
|
|
63
|
+
reason: "registry-not-deployed",
|
|
64
|
+
product: "testnetFaucet",
|
|
65
|
+
contract: "confidentialTestToken",
|
|
66
|
+
chainId,
|
|
67
|
+
clientLabel: "TestnetFaucetClient"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
function buildQueryKey(method, chainId, address, ...args) {
|
|
73
|
+
return [
|
|
74
|
+
TESTNET_FAUCET_KEY,
|
|
75
|
+
TESTNET_FAUCET_NAMESPACE,
|
|
76
|
+
method,
|
|
77
|
+
chainId ?? null,
|
|
78
|
+
address ? address.toLowerCase() : null,
|
|
79
|
+
...args.map(normalizeKeyArg)
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
function normalizeKeyArg(value) {
|
|
83
|
+
if (typeof value === "bigint") return value.toString();
|
|
84
|
+
if (Array.isArray(value)) return value.map(normalizeKeyArg);
|
|
85
|
+
if (value && typeof value === "object") {
|
|
86
|
+
return Object.fromEntries(
|
|
87
|
+
Object.entries(value).map(([k, v]) => [k, normalizeKeyArg(v)])
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
if (typeof value === "string" && value.startsWith("0x")) return value.toLowerCase();
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/testnet-faucet/react/useConfidentialBalance.ts
|
|
95
|
+
function useConfidentialBalance(args = {}) {
|
|
96
|
+
const { account, ...base } = args;
|
|
97
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(base);
|
|
98
|
+
const { address: connected } = wagmi.useAccount();
|
|
99
|
+
const resolvedAccount = account ?? connected;
|
|
100
|
+
return reactQuery.useQuery({
|
|
101
|
+
queryKey: buildQueryKey("confidentialBalanceOf", chainId, resolvedAddress, resolvedAccount),
|
|
102
|
+
queryFn: () => client.confidentialBalanceOf(resolvedAccount),
|
|
103
|
+
enabled: !!client && !!resolvedAccount,
|
|
104
|
+
staleTime: 0
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function useUnderlyingBalance(args = {}) {
|
|
108
|
+
const { account, ...base } = args;
|
|
109
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(base);
|
|
110
|
+
const { address: connected } = wagmi.useAccount();
|
|
111
|
+
const resolvedAccount = account ?? connected;
|
|
112
|
+
return reactQuery.useQuery({
|
|
113
|
+
// The TTT is derived from the CTTT, which is already keyed via
|
|
114
|
+
// `resolvedAddress` — no separate underlying segment needed.
|
|
115
|
+
queryKey: buildQueryKey("underlyingBalanceOf", chainId, resolvedAddress, resolvedAccount),
|
|
116
|
+
queryFn: () => client.underlyingBalanceOf(resolvedAccount),
|
|
117
|
+
enabled: !!client && !!resolvedAccount,
|
|
118
|
+
staleTime: 0
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function useFaucetRate(options = {}) {
|
|
122
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
|
|
123
|
+
return reactQuery.useQuery({
|
|
124
|
+
queryKey: buildQueryKey("rate", chainId, resolvedAddress),
|
|
125
|
+
queryFn: () => client.rate(),
|
|
126
|
+
enabled: !!client,
|
|
127
|
+
// The conversion rate is fixed per deployment — never goes stale.
|
|
128
|
+
staleTime: Infinity
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function useFaucetDecimals(options = {}) {
|
|
132
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
|
|
133
|
+
return reactQuery.useQuery({
|
|
134
|
+
queryKey: buildQueryKey("decimals", chainId, resolvedAddress),
|
|
135
|
+
queryFn: () => client.decimals(),
|
|
136
|
+
enabled: !!client,
|
|
137
|
+
// CTTT decimals are fixed per deployment — never goes stale.
|
|
138
|
+
staleTime: Infinity
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function useUnderlyingDecimals(options = {}) {
|
|
142
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
|
|
143
|
+
return reactQuery.useQuery({
|
|
144
|
+
// The TTT is derived from the CTTT, which is already keyed via
|
|
145
|
+
// `resolvedAddress` — no separate underlying segment needed.
|
|
146
|
+
queryKey: buildQueryKey("underlyingDecimals", chainId, resolvedAddress),
|
|
147
|
+
queryFn: () => client.underlyingDecimals(),
|
|
148
|
+
enabled: !!client,
|
|
149
|
+
// TTT decimals are fixed per deployment — never goes stale.
|
|
150
|
+
staleTime: Infinity
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function useUnderlyingTokenAddress(options = {}) {
|
|
154
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
|
|
155
|
+
return reactQuery.useQuery({
|
|
156
|
+
// The TTT is derived from the CTTT, which is already keyed via
|
|
157
|
+
// `resolvedAddress` — no separate underlying segment needed.
|
|
158
|
+
queryKey: buildQueryKey("underlyingToken", chainId, resolvedAddress),
|
|
159
|
+
queryFn: () => client.underlyingToken(),
|
|
160
|
+
enabled: !!client,
|
|
161
|
+
// The backing token address is fixed per deployment — never goes stale.
|
|
162
|
+
staleTime: Infinity
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function useInferredTotalSupply(options = {}) {
|
|
166
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
|
|
167
|
+
return reactQuery.useQuery({
|
|
168
|
+
queryKey: buildQueryKey("inferredTotalSupply", chainId, resolvedAddress),
|
|
169
|
+
queryFn: () => client.inferredTotalSupply(),
|
|
170
|
+
enabled: !!client,
|
|
171
|
+
staleTime: 0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function useMaxTotalSupply(options = {}) {
|
|
175
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
|
|
176
|
+
return reactQuery.useQuery({
|
|
177
|
+
queryKey: buildQueryKey("maxTotalSupply", chainId, resolvedAddress),
|
|
178
|
+
queryFn: () => client.maxTotalSupply(),
|
|
179
|
+
enabled: !!client,
|
|
180
|
+
// `type(uint64).max` is fixed per deployment — never goes stale.
|
|
181
|
+
staleTime: Infinity
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function useFaucetMetadata(options = {}) {
|
|
185
|
+
const { client, chainId, resolvedAddress } = useMemoFaucetClient(options);
|
|
186
|
+
return reactQuery.useQuery({
|
|
187
|
+
// The `underlying` half of the metadata is derived from the CTTT, which is
|
|
188
|
+
// already keyed via `resolvedAddress` — no separate underlying segment needed.
|
|
189
|
+
queryKey: buildQueryKey("getMetadata", chainId, resolvedAddress),
|
|
190
|
+
queryFn: () => client.getMetadata(),
|
|
191
|
+
enabled: !!client,
|
|
192
|
+
// name/symbol/decimals/rate/maxTotalSupply are all fixed per deployment.
|
|
193
|
+
staleTime: Infinity
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function useMintConfidential(options = {}) {
|
|
197
|
+
const { client, resolutionError } = useMemoFaucetClient(options);
|
|
198
|
+
return reactQuery.useMutation({
|
|
199
|
+
mutationFn: async (args) => {
|
|
200
|
+
if (!client) {
|
|
201
|
+
throw resolutionError ?? new chunk56UI7LUR_cjs.MissingClientError("useMintConfidential", "testnet-faucet");
|
|
202
|
+
}
|
|
203
|
+
return client.mintConfidential(args);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function useMintUnderlying(options = {}) {
|
|
208
|
+
const { client, resolutionError } = useMemoFaucetClient(options);
|
|
209
|
+
return reactQuery.useMutation({
|
|
210
|
+
mutationFn: async (args) => {
|
|
211
|
+
if (!client) {
|
|
212
|
+
throw resolutionError ?? new chunk56UI7LUR_cjs.MissingClientError("useMintUnderlying", "testnet-faucet");
|
|
213
|
+
}
|
|
214
|
+
return client.mintUnderlying(args);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
Object.defineProperty(exports, "FaucetSupplyExhaustedError", {
|
|
220
|
+
enumerable: true,
|
|
221
|
+
get: function () { return chunk5KHIQG7Y_cjs.FaucetSupplyExhaustedError; }
|
|
222
|
+
});
|
|
223
|
+
Object.defineProperty(exports, "AccessDeniedError", {
|
|
224
|
+
enumerable: true,
|
|
225
|
+
get: function () { return chunk56UI7LUR_cjs.AccessDeniedError; }
|
|
226
|
+
});
|
|
227
|
+
Object.defineProperty(exports, "AlreadyInitializedError", {
|
|
228
|
+
enumerable: true,
|
|
229
|
+
get: function () { return chunk56UI7LUR_cjs.AlreadyInitializedError; }
|
|
230
|
+
});
|
|
231
|
+
Object.defineProperty(exports, "BatchTooLargeError", {
|
|
232
|
+
enumerable: true,
|
|
233
|
+
get: function () { return chunk56UI7LUR_cjs.BatchTooLargeError; }
|
|
234
|
+
});
|
|
235
|
+
Object.defineProperty(exports, "ContractRevertError", {
|
|
236
|
+
enumerable: true,
|
|
237
|
+
get: function () { return chunk56UI7LUR_cjs.ContractRevertError; }
|
|
238
|
+
});
|
|
239
|
+
Object.defineProperty(exports, "DecryptionFailedError", {
|
|
240
|
+
enumerable: true,
|
|
241
|
+
get: function () { return chunk56UI7LUR_cjs.DecryptionFailedError; }
|
|
242
|
+
});
|
|
243
|
+
Object.defineProperty(exports, "DeploymentAddressUnavailableError", {
|
|
244
|
+
enumerable: true,
|
|
245
|
+
get: function () { return chunk56UI7LUR_cjs.DeploymentAddressUnavailableError; }
|
|
246
|
+
});
|
|
247
|
+
Object.defineProperty(exports, "EncryptionFailedError", {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
get: function () { return chunk56UI7LUR_cjs.EncryptionFailedError; }
|
|
250
|
+
});
|
|
251
|
+
Object.defineProperty(exports, "FeatureDisabledError", {
|
|
252
|
+
enumerable: true,
|
|
253
|
+
get: function () { return chunk56UI7LUR_cjs.FeatureDisabledError; }
|
|
254
|
+
});
|
|
255
|
+
Object.defineProperty(exports, "FheHandleNotAllowedError", {
|
|
256
|
+
enumerable: true,
|
|
257
|
+
get: function () { return chunk56UI7LUR_cjs.FheHandleNotAllowedError; }
|
|
258
|
+
});
|
|
259
|
+
Object.defineProperty(exports, "InsufficientBalanceError", {
|
|
260
|
+
enumerable: true,
|
|
261
|
+
get: function () { return chunk56UI7LUR_cjs.InsufficientBalanceError; }
|
|
262
|
+
});
|
|
263
|
+
Object.defineProperty(exports, "InsufficientFeeError", {
|
|
264
|
+
enumerable: true,
|
|
265
|
+
get: function () { return chunk56UI7LUR_cjs.InsufficientFeeError; }
|
|
266
|
+
});
|
|
267
|
+
Object.defineProperty(exports, "InsufficientGasFundsError", {
|
|
268
|
+
enumerable: true,
|
|
269
|
+
get: function () { return chunk56UI7LUR_cjs.InsufficientGasFundsError; }
|
|
270
|
+
});
|
|
271
|
+
Object.defineProperty(exports, "InvalidArgumentError", {
|
|
272
|
+
enumerable: true,
|
|
273
|
+
get: function () { return chunk56UI7LUR_cjs.InvalidArgumentError; }
|
|
274
|
+
});
|
|
275
|
+
Object.defineProperty(exports, "InvalidSignatureError", {
|
|
276
|
+
enumerable: true,
|
|
277
|
+
get: function () { return chunk56UI7LUR_cjs.InvalidSignatureError; }
|
|
278
|
+
});
|
|
279
|
+
Object.defineProperty(exports, "MissingAccountError", {
|
|
280
|
+
enumerable: true,
|
|
281
|
+
get: function () { return chunk56UI7LUR_cjs.MissingAccountError; }
|
|
282
|
+
});
|
|
283
|
+
Object.defineProperty(exports, "MissingClientError", {
|
|
284
|
+
enumerable: true,
|
|
285
|
+
get: function () { return chunk56UI7LUR_cjs.MissingClientError; }
|
|
286
|
+
});
|
|
287
|
+
Object.defineProperty(exports, "MissingEncryptorError", {
|
|
288
|
+
enumerable: true,
|
|
289
|
+
get: function () { return chunk56UI7LUR_cjs.MissingEncryptorError; }
|
|
290
|
+
});
|
|
291
|
+
Object.defineProperty(exports, "MissingPublicClientError", {
|
|
292
|
+
enumerable: true,
|
|
293
|
+
get: function () { return chunk56UI7LUR_cjs.MissingPublicClientError; }
|
|
294
|
+
});
|
|
295
|
+
Object.defineProperty(exports, "MissingWalletClientError", {
|
|
296
|
+
enumerable: true,
|
|
297
|
+
get: function () { return chunk56UI7LUR_cjs.MissingWalletClientError; }
|
|
298
|
+
});
|
|
299
|
+
Object.defineProperty(exports, "NetworkError", {
|
|
300
|
+
enumerable: true,
|
|
301
|
+
get: function () { return chunk56UI7LUR_cjs.NetworkError; }
|
|
302
|
+
});
|
|
303
|
+
Object.defineProperty(exports, "PausedError", {
|
|
304
|
+
enumerable: true,
|
|
305
|
+
get: function () { return chunk56UI7LUR_cjs.PausedError; }
|
|
306
|
+
});
|
|
307
|
+
Object.defineProperty(exports, "ReceiptEventAmbiguousError", {
|
|
308
|
+
enumerable: true,
|
|
309
|
+
get: function () { return chunk56UI7LUR_cjs.ReceiptEventAmbiguousError; }
|
|
310
|
+
});
|
|
311
|
+
Object.defineProperty(exports, "ReceiptEventNotFoundError", {
|
|
312
|
+
enumerable: true,
|
|
313
|
+
get: function () { return chunk56UI7LUR_cjs.ReceiptEventNotFoundError; }
|
|
314
|
+
});
|
|
315
|
+
Object.defineProperty(exports, "ReentrancyError", {
|
|
316
|
+
enumerable: true,
|
|
317
|
+
get: function () { return chunk56UI7LUR_cjs.ReentrancyError; }
|
|
318
|
+
});
|
|
319
|
+
Object.defineProperty(exports, "RelayerUnreachableError", {
|
|
320
|
+
enumerable: true,
|
|
321
|
+
get: function () { return chunk56UI7LUR_cjs.RelayerUnreachableError; }
|
|
322
|
+
});
|
|
323
|
+
Object.defineProperty(exports, "SigningFailedError", {
|
|
324
|
+
enumerable: true,
|
|
325
|
+
get: function () { return chunk56UI7LUR_cjs.SigningFailedError; }
|
|
326
|
+
});
|
|
327
|
+
Object.defineProperty(exports, "TokenOpsContractError", {
|
|
328
|
+
enumerable: true,
|
|
329
|
+
get: function () { return chunk56UI7LUR_cjs.TokenOpsContractError; }
|
|
330
|
+
});
|
|
331
|
+
Object.defineProperty(exports, "TokenOpsSdkError", {
|
|
332
|
+
enumerable: true,
|
|
333
|
+
get: function () { return chunk56UI7LUR_cjs.TokenOpsSdkError; }
|
|
334
|
+
});
|
|
335
|
+
Object.defineProperty(exports, "TransferFailedError", {
|
|
336
|
+
enumerable: true,
|
|
337
|
+
get: function () { return chunk56UI7LUR_cjs.TransferFailedError; }
|
|
338
|
+
});
|
|
339
|
+
Object.defineProperty(exports, "UnknownWriteFailureError", {
|
|
340
|
+
enumerable: true,
|
|
341
|
+
get: function () { return chunk56UI7LUR_cjs.UnknownWriteFailureError; }
|
|
342
|
+
});
|
|
343
|
+
Object.defineProperty(exports, "UnsupportedChainError", {
|
|
344
|
+
enumerable: true,
|
|
345
|
+
get: function () { return chunk56UI7LUR_cjs.UnsupportedChainError; }
|
|
346
|
+
});
|
|
347
|
+
Object.defineProperty(exports, "UserDecryptNotAllowedError", {
|
|
348
|
+
enumerable: true,
|
|
349
|
+
get: function () { return chunk56UI7LUR_cjs.UserDecryptNotAllowedError; }
|
|
350
|
+
});
|
|
351
|
+
Object.defineProperty(exports, "UserRejectedSignatureError", {
|
|
352
|
+
enumerable: true,
|
|
353
|
+
get: function () { return chunk56UI7LUR_cjs.UserRejectedSignatureError; }
|
|
354
|
+
});
|
|
355
|
+
Object.defineProperty(exports, "WalletChainMismatchError", {
|
|
356
|
+
enumerable: true,
|
|
357
|
+
get: function () { return chunk56UI7LUR_cjs.WalletChainMismatchError; }
|
|
358
|
+
});
|
|
359
|
+
Object.defineProperty(exports, "WalletRejectedError", {
|
|
360
|
+
enumerable: true,
|
|
361
|
+
get: function () { return chunk56UI7LUR_cjs.WalletRejectedError; }
|
|
362
|
+
});
|
|
363
|
+
Object.defineProperty(exports, "isTokenOpsSdkError", {
|
|
364
|
+
enumerable: true,
|
|
365
|
+
get: function () { return chunk56UI7LUR_cjs.isTokenOpsSdkError; }
|
|
366
|
+
});
|
|
367
|
+
exports.TESTNET_FAUCET_KEY = TESTNET_FAUCET_KEY;
|
|
368
|
+
exports.TESTNET_FAUCET_NAMESPACE = TESTNET_FAUCET_NAMESPACE;
|
|
369
|
+
exports.useConfidentialBalance = useConfidentialBalance;
|
|
370
|
+
exports.useFaucetDecimals = useFaucetDecimals;
|
|
371
|
+
exports.useFaucetMetadata = useFaucetMetadata;
|
|
372
|
+
exports.useFaucetRate = useFaucetRate;
|
|
373
|
+
exports.useInferredTotalSupply = useInferredTotalSupply;
|
|
374
|
+
exports.useMaxTotalSupply = useMaxTotalSupply;
|
|
375
|
+
exports.useMintConfidential = useMintConfidential;
|
|
376
|
+
exports.useMintUnderlying = useMintUnderlying;
|
|
377
|
+
exports.useUnderlyingBalance = useUnderlyingBalance;
|
|
378
|
+
exports.useUnderlyingDecimals = useUnderlyingDecimals;
|
|
379
|
+
exports.useUnderlyingTokenAddress = useUnderlyingTokenAddress;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
* `useAccount`) and TanStack Query (`useQuery`, `useMutation`) — no extra
|
|
7
|
+
* provider needed beyond the standard wagmi `<WagmiProvider>` +
|
|
8
|
+
* `<QueryClientProvider>`.
|
|
9
|
+
*
|
|
10
|
+
* The CTTT proxy address is resolved per-chain via
|
|
11
|
+
* `getConfidentialTestTokenAddress`. Pass `address` to
|
|
12
|
+
* {@link BaseHookOptions} to override (e.g. for forks or local deployments).
|
|
13
|
+
*
|
|
14
|
+
* **No encryptor.** Unlike the FHE products, the faucet mints take PUBLIC
|
|
15
|
+
* plaintext amounts — no `encryptor`, no ACL address, and nothing imported
|
|
16
|
+
* from `@zama-fhe/react-sdk`. A pure-Node or pure-React consumer needs none of
|
|
17
|
+
* the Zama optional peer to use the faucet.
|
|
18
|
+
*
|
|
19
|
+
* Mutations do NOT auto-invalidate read queries — that's a consumer decision.
|
|
20
|
+
* Each mutation's TSDoc documents the recommended
|
|
21
|
+
* `queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "testnet-faucet"] })`.
|
|
22
|
+
*/
|
|
23
|
+
export { useConfidentialBalance, type UseConfidentialBalanceArgs, } from "./useConfidentialBalance.js";
|
|
24
|
+
export { useUnderlyingBalance, type UseUnderlyingBalanceArgs } from "./useUnderlyingBalance.js";
|
|
25
|
+
export { useFaucetRate } from "./useFaucetRate.js";
|
|
26
|
+
export { useFaucetDecimals } from "./useFaucetDecimals.js";
|
|
27
|
+
export { useUnderlyingDecimals } from "./useUnderlyingDecimals.js";
|
|
28
|
+
export { useUnderlyingTokenAddress } from "./useUnderlyingTokenAddress.js";
|
|
29
|
+
export { useInferredTotalSupply } from "./useInferredTotalSupply.js";
|
|
30
|
+
export { useMaxTotalSupply } from "./useMaxTotalSupply.js";
|
|
31
|
+
export { useFaucetMetadata } from "./useFaucetMetadata.js";
|
|
32
|
+
export { useMintConfidential, type UseMintConfidentialArgs } from "./useMintConfidential.js";
|
|
33
|
+
export { useMintUnderlying, type UseMintUnderlyingArgs } from "./useMintUnderlying.js";
|
|
34
|
+
export type { BaseHookOptions } from "./_shared.js";
|
|
35
|
+
export { TESTNET_FAUCET_KEY, TESTNET_FAUCET_NAMESPACE } from "./_shared.js";
|
|
36
|
+
export type { FaucetMetadata, FaucetTokenMetadata, MintConfidentialArgs, MintConfidentialResult, MintUnderlyingArgs, MintUnderlyingResult, } from "../types.js";
|
|
37
|
+
export { TokenOpsSdkError, isTokenOpsSdkError, DeploymentAddressUnavailableError, UnsupportedChainError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, InvalidArgumentError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ContractRevertError, TokenOpsContractError, PausedError, AccessDeniedError, 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";
|
|
38
|
+
export { FaucetSupplyExhaustedError } from "../errors.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
* `useAccount`) and TanStack Query (`useQuery`, `useMutation`) — no extra
|
|
7
|
+
* provider needed beyond the standard wagmi `<WagmiProvider>` +
|
|
8
|
+
* `<QueryClientProvider>`.
|
|
9
|
+
*
|
|
10
|
+
* The CTTT proxy address is resolved per-chain via
|
|
11
|
+
* `getConfidentialTestTokenAddress`. Pass `address` to
|
|
12
|
+
* {@link BaseHookOptions} to override (e.g. for forks or local deployments).
|
|
13
|
+
*
|
|
14
|
+
* **No encryptor.** Unlike the FHE products, the faucet mints take PUBLIC
|
|
15
|
+
* plaintext amounts — no `encryptor`, no ACL address, and nothing imported
|
|
16
|
+
* from `@zama-fhe/react-sdk`. A pure-Node or pure-React consumer needs none of
|
|
17
|
+
* the Zama optional peer to use the faucet.
|
|
18
|
+
*
|
|
19
|
+
* Mutations do NOT auto-invalidate read queries — that's a consumer decision.
|
|
20
|
+
* Each mutation's TSDoc documents the recommended
|
|
21
|
+
* `queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "testnet-faucet"] })`.
|
|
22
|
+
*/
|
|
23
|
+
export { useConfidentialBalance, type UseConfidentialBalanceArgs, } from "./useConfidentialBalance.js";
|
|
24
|
+
export { useUnderlyingBalance, type UseUnderlyingBalanceArgs } from "./useUnderlyingBalance.js";
|
|
25
|
+
export { useFaucetRate } from "./useFaucetRate.js";
|
|
26
|
+
export { useFaucetDecimals } from "./useFaucetDecimals.js";
|
|
27
|
+
export { useUnderlyingDecimals } from "./useUnderlyingDecimals.js";
|
|
28
|
+
export { useUnderlyingTokenAddress } from "./useUnderlyingTokenAddress.js";
|
|
29
|
+
export { useInferredTotalSupply } from "./useInferredTotalSupply.js";
|
|
30
|
+
export { useMaxTotalSupply } from "./useMaxTotalSupply.js";
|
|
31
|
+
export { useFaucetMetadata } from "./useFaucetMetadata.js";
|
|
32
|
+
export { useMintConfidential, type UseMintConfidentialArgs } from "./useMintConfidential.js";
|
|
33
|
+
export { useMintUnderlying, type UseMintUnderlyingArgs } from "./useMintUnderlying.js";
|
|
34
|
+
export type { BaseHookOptions } from "./_shared.js";
|
|
35
|
+
export { TESTNET_FAUCET_KEY, TESTNET_FAUCET_NAMESPACE } from "./_shared.js";
|
|
36
|
+
export type { FaucetMetadata, FaucetTokenMetadata, MintConfidentialArgs, MintConfidentialResult, MintUnderlyingArgs, MintUnderlyingResult, } from "../types.js";
|
|
37
|
+
export { TokenOpsSdkError, isTokenOpsSdkError, DeploymentAddressUnavailableError, UnsupportedChainError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, InvalidArgumentError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ContractRevertError, TokenOpsContractError, PausedError, AccessDeniedError, 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";
|
|
38
|
+
export { FaucetSupplyExhaustedError } from "../errors.js";
|