@zama-fhe/react-sdk 1.0.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/LICENSE +28 -0
- package/README.md +735 -0
- package/dist/ethers/index.d.ts +162 -0
- package/dist/ethers/index.js +173 -0
- package/dist/ethers/index.js.map +1 -0
- package/dist/index.d.ts +1820 -0
- package/dist/index.js +978 -0
- package/dist/index.js.map +1 -0
- package/dist/viem/index.d.ts +162 -0
- package/dist/viem/index.js +173 -0
- package/dist/viem/index.js.map +1 -0
- package/dist/wagmi/index.d.ts +7133 -0
- package/dist/wagmi/index.js +269 -0
- package/dist/wagmi/index.js.map +1 -0
- package/package.json +88 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1820 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as _zama_fhe_sdk from '@zama-fhe/sdk';
|
|
3
|
+
import { RelayerSDK, GenericSigner, GenericStringStorage, TokenSDK, EncryptParams, EncryptResult, UserDecryptParams, PublicDecryptResult, FHEKeypair, EIP712TypedData, Address, DelegatedUserDecryptParams, ZKProofLike, Token, ReadonlyToken, RawLog, ActivityLogMetadata, ActivityItem } from '@zama-fhe/sdk';
|
|
4
|
+
export { ActivityAmount, ActivityDirection, ActivityItem, ActivityLogMetadata, ActivityType, Address, BATCH_SWAP_ABI, BatchTransferData, ConfidentialTransferEvent, ContractCallConfig, CredentialsManager, DEPLOYMENT_COORDINATOR_ABI, DelegatedUserDecryptParams, EIP712TypedData, ENCRYPTION_ABI, ERC165_ABI, ERC20_ABI, ERC20_METADATA_ABI, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, EncryptParams, EncryptResult, FEE_MANAGER_ABI, FHEKeypair, FhevmInstanceConfig, GenericSigner, GenericStringStorage, HardhatConfig, Hex, IndexedDBStorage, InputProofBytesType, InvalidCredentialsError, KmsDelegatedUserDecryptEIP712Type, MainnetConfig, MemoryStorage, NetworkType, NoCiphertextError, PublicDecryptResult, RawLog, ReadonlyToken, ReadonlyTokenConfig, RelayerRequestFailedError, RelayerSDK, RelayerSDKStatus, RelayerWeb, RelayerWebConfig, SepoliaConfig, StoredCredentials, TOKEN_TOPICS, TRANSFER_BATCHER_ABI, Token, TokenConfig, TokenError, TokenErrorCode, TokenEvent, TokenSDK, TokenSDKConfig, Topics, TransactionReceipt, UnwrapRequestedEvent, UnwrappedFinalizedEvent, UnwrappedStartedEvent, UserDecryptParams, WRAPPER_ABI, WrappedEvent, ZERO_HANDLE, ZKProofLike, allowanceContract, applyDecryptedValues, approveContract, balanceOfContract, confidentialBalanceOfContract, confidentialBatchTransferContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, decimalsContract, decodeConfidentialTransfer, decodeTokenEvent, decodeTokenEvents, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, deploymentCoordinatorContract, extractEncryptedHandles, finalizeUnwrapContract, findUnwrapRequested, findWrapped, getBatchTransferFeeContract, getFeeRecipientContract, getUnwrapFeeContract, getWrapFeeContract, getWrapperContract, indexedDBStorage, isFinalizeUnwrapOperatorContract, isOperatorContract, nameContract, parseActivityFeed, rateContract, setFinalizeUnwrapOperatorContract, setOperatorContract, sortByBlockNumber, supportsInterfaceContract, symbolContract, totalSupplyContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract, wrapETHContract, wrapperExistsContract } from '@zama-fhe/sdk';
|
|
5
|
+
import { PropsWithChildren } from 'react';
|
|
6
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
|
+
import { UseQueryOptions, UseMutationOptions, UseQueryResult, UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
8
|
+
import * as _zama_fhe_relayer_sdk_web from '@zama-fhe/relayer-sdk/web';
|
|
9
|
+
|
|
10
|
+
/** Props for {@link TokenSDKProvider}. */
|
|
11
|
+
interface TokenSDKProviderProps extends PropsWithChildren {
|
|
12
|
+
/** FHE relayer backend (RelayerWeb for browser, RelayerNode for server). */
|
|
13
|
+
relayer: RelayerSDK;
|
|
14
|
+
/** Wallet signer (ViemSigner, EthersSigner, or custom GenericSigner). */
|
|
15
|
+
signer: GenericSigner;
|
|
16
|
+
/** Credential storage backend (IndexedDBStorage for browser, MemoryStorage for tests). */
|
|
17
|
+
storage: GenericStringStorage;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Provides a {@link TokenSDK} instance to all descendant hooks.
|
|
21
|
+
* Terminates the relayer on unmount.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <TokenSDKProvider relayer={relayer} signer={signer} storage={storage}>
|
|
26
|
+
* <App />
|
|
27
|
+
* </TokenSDKProvider>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function TokenSDKProvider({ children, relayer, signer, storage }: TokenSDKProviderProps): react_jsx_runtime.JSX.Element;
|
|
31
|
+
/**
|
|
32
|
+
* Access the {@link TokenSDK} instance from context.
|
|
33
|
+
* Must be used within a {@link TokenSDKProvider}.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* const sdk = useTokenSDK();
|
|
38
|
+
* const token = sdk.createReadonlyToken("0x...");
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function useTokenSDK(): TokenSDK;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* TanStack Query mutation options factory for FHE encrypt.
|
|
45
|
+
*
|
|
46
|
+
* @param sdk - A `TokenSDK` instance.
|
|
47
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
48
|
+
*/
|
|
49
|
+
declare function encryptMutationOptions(sdk: TokenSDK): {
|
|
50
|
+
mutationKey: readonly ["encrypt"];
|
|
51
|
+
mutationFn: (params: EncryptParams) => Promise<EncryptResult>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Encrypt a plaintext value using FHE.
|
|
55
|
+
* Calls the relayer's `encrypt` method via a mutation.
|
|
56
|
+
*
|
|
57
|
+
* @returns A mutation whose `mutate` accepts {@link EncryptParams}.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* const encrypt = useEncrypt();
|
|
62
|
+
* encrypt.mutate({ values: [1000n], bits: [64] });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare function useEncrypt(): _tanstack_react_query.UseMutationResult<EncryptResult, Error, EncryptParams, unknown>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Thin wrapper around sdk.userDecrypt().
|
|
69
|
+
* Caller is responsible for providing all params (keypair, signature, etc.).
|
|
70
|
+
* For the full orchestration (signature management, EIP712 signing),
|
|
71
|
+
* see the app-level useUserDecryptFlow hook.
|
|
72
|
+
*
|
|
73
|
+
* On success, populates the decryption cache so useUserDecryptedValue/useUserDecryptedValues
|
|
74
|
+
* can read the results.
|
|
75
|
+
*/
|
|
76
|
+
declare function useUserDecrypt(): _tanstack_react_query.UseMutationResult<Record<string, bigint>, Error, UserDecryptParams, unknown>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Decrypt FHE ciphertext handles using the network public key (no credential needed).
|
|
80
|
+
* On success, populates the decryption cache so {@link useUserDecryptedValue} / {@link useUserDecryptedValues}
|
|
81
|
+
* can read the results.
|
|
82
|
+
*
|
|
83
|
+
* @returns A mutation whose `mutate` accepts an array of handle strings.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* const publicDecrypt = usePublicDecrypt();
|
|
88
|
+
* publicDecrypt.mutate(["0xHandle1", "0xHandle2"]);
|
|
89
|
+
* // publicDecrypt.data?.clearValues => { "0xHandle1": 500n, ... }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function usePublicDecrypt(): _tanstack_react_query.UseMutationResult<PublicDecryptResult, Error, string[], unknown>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Generate an FHE keypair via the relayer.
|
|
96
|
+
* Returns a public/private key pair for use in decrypt authorization.
|
|
97
|
+
*
|
|
98
|
+
* @returns A mutation whose `mutate` takes no parameters.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```tsx
|
|
102
|
+
* const generateKeypair = useGenerateKeypair();
|
|
103
|
+
* generateKeypair.mutate();
|
|
104
|
+
* // generateKeypair.data?.publicKey, generateKeypair.data?.privateKey
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function useGenerateKeypair(): _tanstack_react_query.UseMutationResult<FHEKeypair, Error, void, unknown>;
|
|
108
|
+
|
|
109
|
+
/** Parameters for {@link useCreateEIP712}. */
|
|
110
|
+
interface CreateEIP712Params {
|
|
111
|
+
/** The FHE public key (hex-encoded). */
|
|
112
|
+
publicKey: string;
|
|
113
|
+
/** Contract addresses the credential authorizes decryption for. */
|
|
114
|
+
contractAddresses: `0x${string}`[];
|
|
115
|
+
/** Unix timestamp (seconds) when the credential becomes valid. */
|
|
116
|
+
startTimestamp: number;
|
|
117
|
+
/** Number of days the credential remains valid. Default: 1. */
|
|
118
|
+
durationDays?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create EIP-712 typed data for signing an FHE decrypt credential.
|
|
122
|
+
* The returned typed data is signed by the wallet to authorize decryption.
|
|
123
|
+
*
|
|
124
|
+
* @returns A mutation whose `mutate` accepts {@link CreateEIP712Params}.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
128
|
+
* const createEIP712 = useCreateEIP712();
|
|
129
|
+
* createEIP712.mutate({
|
|
130
|
+
* publicKey: keypair.publicKey,
|
|
131
|
+
* contractAddresses: ["0xToken"],
|
|
132
|
+
* startTimestamp: Math.floor(Date.now() / 1000),
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function useCreateEIP712(): _tanstack_react_query.UseMutationResult<EIP712TypedData, Error, CreateEIP712Params, unknown>;
|
|
137
|
+
|
|
138
|
+
/** Parameters for {@link useCreateDelegatedUserDecryptEIP712}. */
|
|
139
|
+
interface CreateDelegatedUserDecryptEIP712Params {
|
|
140
|
+
/** The FHE public key (hex-encoded). */
|
|
141
|
+
publicKey: string;
|
|
142
|
+
/** Contract addresses the credential authorizes decryption for. */
|
|
143
|
+
contractAddresses: Address[];
|
|
144
|
+
/** Address of the wallet that delegated decrypt authority. */
|
|
145
|
+
delegatorAddress: string;
|
|
146
|
+
/** Unix timestamp (seconds) when the credential becomes valid. */
|
|
147
|
+
startTimestamp: number;
|
|
148
|
+
/** Number of days the credential remains valid. Default: 1. */
|
|
149
|
+
durationDays?: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Create EIP-712 typed data for a delegated user decrypt credential.
|
|
153
|
+
* Used when one wallet authorizes another to decrypt on its behalf.
|
|
154
|
+
*
|
|
155
|
+
* @returns A mutation whose `mutate` accepts {@link CreateDelegatedUserDecryptEIP712Params}.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```tsx
|
|
159
|
+
* const createEIP712 = useCreateDelegatedUserDecryptEIP712();
|
|
160
|
+
* createEIP712.mutate({
|
|
161
|
+
* publicKey: keypair.publicKey,
|
|
162
|
+
* contractAddresses: ["0xToken"],
|
|
163
|
+
* delegatorAddress: "0xDelegator",
|
|
164
|
+
* startTimestamp: Math.floor(Date.now() / 1000),
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
declare function useCreateDelegatedUserDecryptEIP712(): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
169
|
+
types: _zama_fhe_relayer_sdk_web.KmsDelegatedUserDecryptEIP712TypesType;
|
|
170
|
+
primaryType: "DelegatedUserDecryptRequestVerification";
|
|
171
|
+
domain: _zama_fhe_relayer_sdk_web.KmsEIP712DomainType;
|
|
172
|
+
message: _zama_fhe_relayer_sdk_web.KmsDelegatedUserDecryptEIP712MessageType;
|
|
173
|
+
}>, Error, CreateDelegatedUserDecryptEIP712Params, unknown>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Decrypt FHE ciphertext handles using delegated user credentials.
|
|
177
|
+
* Returns a map of handle → plaintext bigint.
|
|
178
|
+
*
|
|
179
|
+
* @returns A mutation whose `mutate` accepts {@link DelegatedUserDecryptParams}.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```tsx
|
|
183
|
+
* const decrypt = useDelegatedUserDecrypt();
|
|
184
|
+
* decrypt.mutate({ handles: ["0xHandle1"], ...credentials });
|
|
185
|
+
* // decrypt.data => { "0xHandle1": 1000n }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function useDelegatedUserDecrypt(): _tanstack_react_query.UseMutationResult<Record<string, bigint>, Error, DelegatedUserDecryptParams, unknown>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Submit a ZK proof for on-chain verification.
|
|
192
|
+
* Returns the input proof bytes for use in contract calls.
|
|
193
|
+
*
|
|
194
|
+
* @returns A mutation whose `mutate` accepts a {@link ZKProofLike}.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```tsx
|
|
198
|
+
* const verify = useRequestZKProofVerification();
|
|
199
|
+
* verify.mutate(zkProof);
|
|
200
|
+
* // verify.data => Uint8Array (input proof bytes)
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
declare function useRequestZKProofVerification(): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
204
|
+
handles: Uint8Array[];
|
|
205
|
+
inputProof: Uint8Array;
|
|
206
|
+
}>, Error, ZKProofLike, unknown>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Query key factory for the FHE public key query.
|
|
210
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
211
|
+
*/
|
|
212
|
+
declare const publicKeyQueryKeys: {
|
|
213
|
+
/** Match the public key query. */
|
|
214
|
+
readonly all: readonly ["publicKey"];
|
|
215
|
+
};
|
|
216
|
+
/** Shape of the FHE public key data returned by the relayer. */
|
|
217
|
+
interface PublicKeyData {
|
|
218
|
+
/** Unique identifier for this public key version. */
|
|
219
|
+
publicKeyId: string;
|
|
220
|
+
/** The raw FHE public key bytes. */
|
|
221
|
+
publicKey: Uint8Array;
|
|
222
|
+
}
|
|
223
|
+
type PublicKeyResult = PublicKeyData | null;
|
|
224
|
+
/**
|
|
225
|
+
* TanStack Query options factory for the FHE public key.
|
|
226
|
+
*
|
|
227
|
+
* @param sdk - A `TokenSDK` instance.
|
|
228
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
229
|
+
*/
|
|
230
|
+
declare function publicKeyQueryOptions(sdk: TokenSDK): {
|
|
231
|
+
readonly queryKey: readonly ["publicKey"];
|
|
232
|
+
readonly queryFn: () => Promise<PublicKeyResult>;
|
|
233
|
+
readonly staleTime: number;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Fetch the FHE network public key from the relayer.
|
|
237
|
+
* Cached indefinitely since the key does not change during a session.
|
|
238
|
+
*
|
|
239
|
+
* @returns Query result with `data: PublicKeyData | null`.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```tsx
|
|
243
|
+
* const { data: publicKey } = usePublicKey();
|
|
244
|
+
* // publicKey?.publicKeyId, publicKey?.publicKey
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
declare function usePublicKey(): _tanstack_react_query.UseQueryResult<PublicKeyResult, Error>;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Query key factory for FHE public params queries.
|
|
251
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
252
|
+
*/
|
|
253
|
+
declare const publicParamsQueryKeys: {
|
|
254
|
+
/** Match all public params queries. */
|
|
255
|
+
readonly all: readonly ["publicParams"];
|
|
256
|
+
/** Match public params query for a specific bit size. */
|
|
257
|
+
readonly bits: (bits: number) => readonly ["publicParams", number];
|
|
258
|
+
};
|
|
259
|
+
/** Shape of the FHE public parameters returned by the relayer. */
|
|
260
|
+
interface PublicParamsData {
|
|
261
|
+
/** The raw public parameters bytes (WASM-ready). */
|
|
262
|
+
publicParams: Uint8Array;
|
|
263
|
+
/** Unique identifier for this public params version. */
|
|
264
|
+
publicParamsId: string;
|
|
265
|
+
}
|
|
266
|
+
type PublicParamsResult = PublicParamsData | null;
|
|
267
|
+
/**
|
|
268
|
+
* TanStack Query options factory for FHE public parameters.
|
|
269
|
+
*
|
|
270
|
+
* @param sdk - A `TokenSDK` instance.
|
|
271
|
+
* @param bits - The FHE bit size to fetch parameters for (e.g. 2048).
|
|
272
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
273
|
+
*/
|
|
274
|
+
declare function publicParamsQueryOptions(sdk: TokenSDK, bits: number): {
|
|
275
|
+
readonly queryKey: readonly ["publicParams", number];
|
|
276
|
+
readonly queryFn: () => Promise<PublicParamsResult>;
|
|
277
|
+
readonly staleTime: number;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Fetch FHE public parameters for a given bit size from the relayer.
|
|
281
|
+
* Cached indefinitely since parameters do not change during a session.
|
|
282
|
+
*
|
|
283
|
+
* @param bits - The FHE bit size to fetch parameters for (e.g. 2048).
|
|
284
|
+
* @returns Query result with `data: PublicParamsData | null`.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```tsx
|
|
288
|
+
* const { data: params } = usePublicParams(2048);
|
|
289
|
+
* // params?.publicParams, params?.publicParamsId
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
declare function usePublicParams(bits: number): _tanstack_react_query.UseQueryResult<PublicParamsResult, Error>;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Look up a single cached decrypted value by its handle.
|
|
296
|
+
* Values are populated automatically when useUserDecrypt or usePublicDecrypt succeed.
|
|
297
|
+
* You can also populate manually via queryClient.setQueryData(decryptionKeys.value(handle), value).
|
|
298
|
+
*/
|
|
299
|
+
declare function useUserDecryptedValue(handle: string | undefined): _tanstack_react_query.UseQueryResult<bigint, Error>;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Look up multiple cached decrypted values by their handles.
|
|
303
|
+
* Values are populated automatically when useUserDecrypt or usePublicDecrypt succeed.
|
|
304
|
+
*/
|
|
305
|
+
declare function useUserDecryptedValues(handles: string[]): {
|
|
306
|
+
data: Record<string, bigint | undefined>;
|
|
307
|
+
results: _tanstack_react_query.UseQueryResult<never, Error>[];
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Query key helpers for the shared decryption cache.
|
|
312
|
+
* Used by useUserDecrypt/usePublicDecrypt to populate,
|
|
313
|
+
* and by useUserDecryptedValue to read.
|
|
314
|
+
*/
|
|
315
|
+
declare const decryptionKeys: {
|
|
316
|
+
value: (handle: string) => readonly ["decryptedValue", string];
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
/** Base configuration shared by all mutation hooks that need a Token instance. */
|
|
320
|
+
interface UseTokenConfig {
|
|
321
|
+
/** Address of the confidential token contract. */
|
|
322
|
+
tokenAddress: Address;
|
|
323
|
+
/** Address of the wrapper contract (required for shield/unshield operations). */
|
|
324
|
+
wrapperAddress?: Address;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Get a {@link Token} instance, memoized by address pair.
|
|
328
|
+
* Reads signer and storage from the nearest {@link TokenSDKProvider}.
|
|
329
|
+
*
|
|
330
|
+
* @param config - Token and optional wrapper addresses.
|
|
331
|
+
* @returns A memoized `Token` instance.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```tsx
|
|
335
|
+
* const token = useToken({ tokenAddress: "0xToken", wrapperAddress: "0xWrapper" });
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
declare function useToken(config: UseTokenConfig): _zama_fhe_sdk.Token;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Get a {@link ReadonlyToken} instance, memoized by address.
|
|
342
|
+
* Supports balance queries, ERC-165 checks, and authorization — no wrapper needed.
|
|
343
|
+
* Reads signer and storage from the nearest {@link TokenSDKProvider}.
|
|
344
|
+
*
|
|
345
|
+
* @param address - Address of the confidential token contract.
|
|
346
|
+
* @returns A memoized `ReadonlyToken` instance.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```tsx
|
|
350
|
+
* const token = useReadonlyToken("0xToken");
|
|
351
|
+
* // token.balanceOf(), token.isConfidential(), etc.
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
declare function useReadonlyToken(address: Address): _zama_fhe_sdk.ReadonlyToken;
|
|
355
|
+
|
|
356
|
+
/** Configuration for {@link useConfidentialBalance}. */
|
|
357
|
+
interface UseConfidentialBalanceConfig {
|
|
358
|
+
/** Address of the confidential token contract. */
|
|
359
|
+
tokenAddress: Address;
|
|
360
|
+
/** Polling interval (ms) for the encrypted handle. Default: 10 000. */
|
|
361
|
+
handleRefetchInterval?: number;
|
|
362
|
+
}
|
|
363
|
+
/** Query options for the decrypt phase of {@link useConfidentialBalance}. */
|
|
364
|
+
type UseConfidentialBalanceOptions = Omit<UseQueryOptions<bigint, Error>, "queryKey" | "queryFn">;
|
|
365
|
+
/**
|
|
366
|
+
* Declarative hook to read the connected wallet's confidential token balance.
|
|
367
|
+
* Uses two-phase polling: cheaply polls the encrypted handle, then only
|
|
368
|
+
* decrypts when the handle changes (new balance).
|
|
369
|
+
*
|
|
370
|
+
* @param config - Token address and optional polling interval.
|
|
371
|
+
* @param options - React Query options forwarded to the decrypt query.
|
|
372
|
+
* @returns The decrypt query result plus `handleQuery` for Phase 1 state.
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```tsx
|
|
376
|
+
* const { data: balance, isLoading, handleQuery } = useConfidentialBalance({
|
|
377
|
+
* tokenAddress: "0x...",
|
|
378
|
+
* });
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
declare function useConfidentialBalance(config: UseConfidentialBalanceConfig, options?: UseConfidentialBalanceOptions): {
|
|
382
|
+
handleQuery: _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
383
|
+
signerError: Error | undefined;
|
|
384
|
+
data: bigint;
|
|
385
|
+
error: Error;
|
|
386
|
+
isError: true;
|
|
387
|
+
isPending: false;
|
|
388
|
+
isLoading: false;
|
|
389
|
+
isLoadingError: false;
|
|
390
|
+
isRefetchError: true;
|
|
391
|
+
isSuccess: false;
|
|
392
|
+
isPlaceholderData: false;
|
|
393
|
+
status: "error";
|
|
394
|
+
dataUpdatedAt: number;
|
|
395
|
+
errorUpdatedAt: number;
|
|
396
|
+
failureCount: number;
|
|
397
|
+
failureReason: Error | null;
|
|
398
|
+
errorUpdateCount: number;
|
|
399
|
+
isFetched: boolean;
|
|
400
|
+
isFetchedAfterMount: boolean;
|
|
401
|
+
isFetching: boolean;
|
|
402
|
+
isInitialLoading: boolean;
|
|
403
|
+
isPaused: boolean;
|
|
404
|
+
isRefetching: boolean;
|
|
405
|
+
isStale: boolean;
|
|
406
|
+
isEnabled: boolean;
|
|
407
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<bigint, Error>>;
|
|
408
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
409
|
+
promise: Promise<bigint>;
|
|
410
|
+
} | {
|
|
411
|
+
handleQuery: _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
412
|
+
signerError: Error | undefined;
|
|
413
|
+
data: bigint;
|
|
414
|
+
error: null;
|
|
415
|
+
isError: false;
|
|
416
|
+
isPending: false;
|
|
417
|
+
isLoading: false;
|
|
418
|
+
isLoadingError: false;
|
|
419
|
+
isRefetchError: false;
|
|
420
|
+
isSuccess: true;
|
|
421
|
+
isPlaceholderData: false;
|
|
422
|
+
status: "success";
|
|
423
|
+
dataUpdatedAt: number;
|
|
424
|
+
errorUpdatedAt: number;
|
|
425
|
+
failureCount: number;
|
|
426
|
+
failureReason: Error | null;
|
|
427
|
+
errorUpdateCount: number;
|
|
428
|
+
isFetched: boolean;
|
|
429
|
+
isFetchedAfterMount: boolean;
|
|
430
|
+
isFetching: boolean;
|
|
431
|
+
isInitialLoading: boolean;
|
|
432
|
+
isPaused: boolean;
|
|
433
|
+
isRefetching: boolean;
|
|
434
|
+
isStale: boolean;
|
|
435
|
+
isEnabled: boolean;
|
|
436
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<bigint, Error>>;
|
|
437
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
438
|
+
promise: Promise<bigint>;
|
|
439
|
+
} | {
|
|
440
|
+
handleQuery: _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
441
|
+
signerError: Error | undefined;
|
|
442
|
+
data: undefined;
|
|
443
|
+
error: Error;
|
|
444
|
+
isError: true;
|
|
445
|
+
isPending: false;
|
|
446
|
+
isLoading: false;
|
|
447
|
+
isLoadingError: true;
|
|
448
|
+
isRefetchError: false;
|
|
449
|
+
isSuccess: false;
|
|
450
|
+
isPlaceholderData: false;
|
|
451
|
+
status: "error";
|
|
452
|
+
dataUpdatedAt: number;
|
|
453
|
+
errorUpdatedAt: number;
|
|
454
|
+
failureCount: number;
|
|
455
|
+
failureReason: Error | null;
|
|
456
|
+
errorUpdateCount: number;
|
|
457
|
+
isFetched: boolean;
|
|
458
|
+
isFetchedAfterMount: boolean;
|
|
459
|
+
isFetching: boolean;
|
|
460
|
+
isInitialLoading: boolean;
|
|
461
|
+
isPaused: boolean;
|
|
462
|
+
isRefetching: boolean;
|
|
463
|
+
isStale: boolean;
|
|
464
|
+
isEnabled: boolean;
|
|
465
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<bigint, Error>>;
|
|
466
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
467
|
+
promise: Promise<bigint>;
|
|
468
|
+
} | {
|
|
469
|
+
handleQuery: _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
470
|
+
signerError: Error | undefined;
|
|
471
|
+
data: undefined;
|
|
472
|
+
error: null;
|
|
473
|
+
isError: false;
|
|
474
|
+
isPending: true;
|
|
475
|
+
isLoading: true;
|
|
476
|
+
isLoadingError: false;
|
|
477
|
+
isRefetchError: false;
|
|
478
|
+
isSuccess: false;
|
|
479
|
+
isPlaceholderData: false;
|
|
480
|
+
status: "pending";
|
|
481
|
+
dataUpdatedAt: number;
|
|
482
|
+
errorUpdatedAt: number;
|
|
483
|
+
failureCount: number;
|
|
484
|
+
failureReason: Error | null;
|
|
485
|
+
errorUpdateCount: number;
|
|
486
|
+
isFetched: boolean;
|
|
487
|
+
isFetchedAfterMount: boolean;
|
|
488
|
+
isFetching: boolean;
|
|
489
|
+
isInitialLoading: boolean;
|
|
490
|
+
isPaused: boolean;
|
|
491
|
+
isRefetching: boolean;
|
|
492
|
+
isStale: boolean;
|
|
493
|
+
isEnabled: boolean;
|
|
494
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<bigint, Error>>;
|
|
495
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
496
|
+
promise: Promise<bigint>;
|
|
497
|
+
} | {
|
|
498
|
+
handleQuery: _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
499
|
+
signerError: Error | undefined;
|
|
500
|
+
data: undefined;
|
|
501
|
+
error: null;
|
|
502
|
+
isError: false;
|
|
503
|
+
isPending: true;
|
|
504
|
+
isLoadingError: false;
|
|
505
|
+
isRefetchError: false;
|
|
506
|
+
isSuccess: false;
|
|
507
|
+
isPlaceholderData: false;
|
|
508
|
+
status: "pending";
|
|
509
|
+
dataUpdatedAt: number;
|
|
510
|
+
errorUpdatedAt: number;
|
|
511
|
+
failureCount: number;
|
|
512
|
+
failureReason: Error | null;
|
|
513
|
+
errorUpdateCount: number;
|
|
514
|
+
isFetched: boolean;
|
|
515
|
+
isFetchedAfterMount: boolean;
|
|
516
|
+
isFetching: boolean;
|
|
517
|
+
isLoading: boolean;
|
|
518
|
+
isInitialLoading: boolean;
|
|
519
|
+
isPaused: boolean;
|
|
520
|
+
isRefetching: boolean;
|
|
521
|
+
isStale: boolean;
|
|
522
|
+
isEnabled: boolean;
|
|
523
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<bigint, Error>>;
|
|
524
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
525
|
+
promise: Promise<bigint>;
|
|
526
|
+
} | {
|
|
527
|
+
handleQuery: _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
528
|
+
signerError: Error | undefined;
|
|
529
|
+
data: bigint;
|
|
530
|
+
isError: false;
|
|
531
|
+
error: null;
|
|
532
|
+
isPending: false;
|
|
533
|
+
isLoading: false;
|
|
534
|
+
isLoadingError: false;
|
|
535
|
+
isRefetchError: false;
|
|
536
|
+
isSuccess: true;
|
|
537
|
+
isPlaceholderData: true;
|
|
538
|
+
status: "success";
|
|
539
|
+
dataUpdatedAt: number;
|
|
540
|
+
errorUpdatedAt: number;
|
|
541
|
+
failureCount: number;
|
|
542
|
+
failureReason: Error | null;
|
|
543
|
+
errorUpdateCount: number;
|
|
544
|
+
isFetched: boolean;
|
|
545
|
+
isFetchedAfterMount: boolean;
|
|
546
|
+
isFetching: boolean;
|
|
547
|
+
isInitialLoading: boolean;
|
|
548
|
+
isPaused: boolean;
|
|
549
|
+
isRefetching: boolean;
|
|
550
|
+
isStale: boolean;
|
|
551
|
+
isEnabled: boolean;
|
|
552
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<bigint, Error>>;
|
|
553
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
554
|
+
promise: Promise<bigint>;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
/** Configuration for {@link useConfidentialBalances}. */
|
|
558
|
+
interface UseConfidentialBalancesConfig {
|
|
559
|
+
/** Addresses of the confidential token contracts to batch-query. */
|
|
560
|
+
tokenAddresses: Address[];
|
|
561
|
+
/** Polling interval (ms) for the encrypted handles. Default: 10 000. */
|
|
562
|
+
handleRefetchInterval?: number;
|
|
563
|
+
}
|
|
564
|
+
/** Query options for the decrypt phase of {@link useConfidentialBalances}. */
|
|
565
|
+
type UseConfidentialBalancesOptions = Omit<UseQueryOptions<Map<Address, bigint>, Error>, "queryKey" | "queryFn">;
|
|
566
|
+
/**
|
|
567
|
+
* Declarative hook to read multiple confidential token balances in batch.
|
|
568
|
+
* Uses two-phase polling: cheaply polls encrypted handles, then only
|
|
569
|
+
* decrypts when any handle changes.
|
|
570
|
+
*
|
|
571
|
+
* @param config - Token addresses and optional polling interval.
|
|
572
|
+
* @param options - React Query options forwarded to the decrypt query.
|
|
573
|
+
* @returns The decrypt query result (Map of address → balance) plus `handlesQuery` for Phase 1 state.
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```tsx
|
|
577
|
+
* const { data: balances } = useConfidentialBalances({
|
|
578
|
+
* tokenAddresses: ["0xTokenA", "0xTokenB"],
|
|
579
|
+
* });
|
|
580
|
+
* const balance = balances?.get("0xTokenA");
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
declare function useConfidentialBalances(config: UseConfidentialBalancesConfig, options?: UseConfidentialBalancesOptions): {
|
|
584
|
+
handlesQuery: _tanstack_react_query.UseQueryResult<`0x${string}`[], Error>;
|
|
585
|
+
signerError: Error | undefined;
|
|
586
|
+
data: Map<`0x${string}`, bigint>;
|
|
587
|
+
error: Error;
|
|
588
|
+
isError: true;
|
|
589
|
+
isPending: false;
|
|
590
|
+
isLoading: false;
|
|
591
|
+
isLoadingError: false;
|
|
592
|
+
isRefetchError: true;
|
|
593
|
+
isSuccess: false;
|
|
594
|
+
isPlaceholderData: false;
|
|
595
|
+
status: "error";
|
|
596
|
+
dataUpdatedAt: number;
|
|
597
|
+
errorUpdatedAt: number;
|
|
598
|
+
failureCount: number;
|
|
599
|
+
failureReason: Error | null;
|
|
600
|
+
errorUpdateCount: number;
|
|
601
|
+
isFetched: boolean;
|
|
602
|
+
isFetchedAfterMount: boolean;
|
|
603
|
+
isFetching: boolean;
|
|
604
|
+
isInitialLoading: boolean;
|
|
605
|
+
isPaused: boolean;
|
|
606
|
+
isRefetching: boolean;
|
|
607
|
+
isStale: boolean;
|
|
608
|
+
isEnabled: boolean;
|
|
609
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<`0x${string}`, bigint>, Error>>;
|
|
610
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
611
|
+
promise: Promise<Map<`0x${string}`, bigint>>;
|
|
612
|
+
} | {
|
|
613
|
+
handlesQuery: _tanstack_react_query.UseQueryResult<`0x${string}`[], Error>;
|
|
614
|
+
signerError: Error | undefined;
|
|
615
|
+
data: Map<`0x${string}`, bigint>;
|
|
616
|
+
error: null;
|
|
617
|
+
isError: false;
|
|
618
|
+
isPending: false;
|
|
619
|
+
isLoading: false;
|
|
620
|
+
isLoadingError: false;
|
|
621
|
+
isRefetchError: false;
|
|
622
|
+
isSuccess: true;
|
|
623
|
+
isPlaceholderData: false;
|
|
624
|
+
status: "success";
|
|
625
|
+
dataUpdatedAt: number;
|
|
626
|
+
errorUpdatedAt: number;
|
|
627
|
+
failureCount: number;
|
|
628
|
+
failureReason: Error | null;
|
|
629
|
+
errorUpdateCount: number;
|
|
630
|
+
isFetched: boolean;
|
|
631
|
+
isFetchedAfterMount: boolean;
|
|
632
|
+
isFetching: boolean;
|
|
633
|
+
isInitialLoading: boolean;
|
|
634
|
+
isPaused: boolean;
|
|
635
|
+
isRefetching: boolean;
|
|
636
|
+
isStale: boolean;
|
|
637
|
+
isEnabled: boolean;
|
|
638
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<`0x${string}`, bigint>, Error>>;
|
|
639
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
640
|
+
promise: Promise<Map<`0x${string}`, bigint>>;
|
|
641
|
+
} | {
|
|
642
|
+
handlesQuery: _tanstack_react_query.UseQueryResult<`0x${string}`[], Error>;
|
|
643
|
+
signerError: Error | undefined;
|
|
644
|
+
data: undefined;
|
|
645
|
+
error: Error;
|
|
646
|
+
isError: true;
|
|
647
|
+
isPending: false;
|
|
648
|
+
isLoading: false;
|
|
649
|
+
isLoadingError: true;
|
|
650
|
+
isRefetchError: false;
|
|
651
|
+
isSuccess: false;
|
|
652
|
+
isPlaceholderData: false;
|
|
653
|
+
status: "error";
|
|
654
|
+
dataUpdatedAt: number;
|
|
655
|
+
errorUpdatedAt: number;
|
|
656
|
+
failureCount: number;
|
|
657
|
+
failureReason: Error | null;
|
|
658
|
+
errorUpdateCount: number;
|
|
659
|
+
isFetched: boolean;
|
|
660
|
+
isFetchedAfterMount: boolean;
|
|
661
|
+
isFetching: boolean;
|
|
662
|
+
isInitialLoading: boolean;
|
|
663
|
+
isPaused: boolean;
|
|
664
|
+
isRefetching: boolean;
|
|
665
|
+
isStale: boolean;
|
|
666
|
+
isEnabled: boolean;
|
|
667
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<`0x${string}`, bigint>, Error>>;
|
|
668
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
669
|
+
promise: Promise<Map<`0x${string}`, bigint>>;
|
|
670
|
+
} | {
|
|
671
|
+
handlesQuery: _tanstack_react_query.UseQueryResult<`0x${string}`[], Error>;
|
|
672
|
+
signerError: Error | undefined;
|
|
673
|
+
data: undefined;
|
|
674
|
+
error: null;
|
|
675
|
+
isError: false;
|
|
676
|
+
isPending: true;
|
|
677
|
+
isLoading: true;
|
|
678
|
+
isLoadingError: false;
|
|
679
|
+
isRefetchError: false;
|
|
680
|
+
isSuccess: false;
|
|
681
|
+
isPlaceholderData: false;
|
|
682
|
+
status: "pending";
|
|
683
|
+
dataUpdatedAt: number;
|
|
684
|
+
errorUpdatedAt: number;
|
|
685
|
+
failureCount: number;
|
|
686
|
+
failureReason: Error | null;
|
|
687
|
+
errorUpdateCount: number;
|
|
688
|
+
isFetched: boolean;
|
|
689
|
+
isFetchedAfterMount: boolean;
|
|
690
|
+
isFetching: boolean;
|
|
691
|
+
isInitialLoading: boolean;
|
|
692
|
+
isPaused: boolean;
|
|
693
|
+
isRefetching: boolean;
|
|
694
|
+
isStale: boolean;
|
|
695
|
+
isEnabled: boolean;
|
|
696
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<`0x${string}`, bigint>, Error>>;
|
|
697
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
698
|
+
promise: Promise<Map<`0x${string}`, bigint>>;
|
|
699
|
+
} | {
|
|
700
|
+
handlesQuery: _tanstack_react_query.UseQueryResult<`0x${string}`[], Error>;
|
|
701
|
+
signerError: Error | undefined;
|
|
702
|
+
data: undefined;
|
|
703
|
+
error: null;
|
|
704
|
+
isError: false;
|
|
705
|
+
isPending: true;
|
|
706
|
+
isLoadingError: false;
|
|
707
|
+
isRefetchError: false;
|
|
708
|
+
isSuccess: false;
|
|
709
|
+
isPlaceholderData: false;
|
|
710
|
+
status: "pending";
|
|
711
|
+
dataUpdatedAt: number;
|
|
712
|
+
errorUpdatedAt: number;
|
|
713
|
+
failureCount: number;
|
|
714
|
+
failureReason: Error | null;
|
|
715
|
+
errorUpdateCount: number;
|
|
716
|
+
isFetched: boolean;
|
|
717
|
+
isFetchedAfterMount: boolean;
|
|
718
|
+
isFetching: boolean;
|
|
719
|
+
isLoading: boolean;
|
|
720
|
+
isInitialLoading: boolean;
|
|
721
|
+
isPaused: boolean;
|
|
722
|
+
isRefetching: boolean;
|
|
723
|
+
isStale: boolean;
|
|
724
|
+
isEnabled: boolean;
|
|
725
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<`0x${string}`, bigint>, Error>>;
|
|
726
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
727
|
+
promise: Promise<Map<`0x${string}`, bigint>>;
|
|
728
|
+
} | {
|
|
729
|
+
handlesQuery: _tanstack_react_query.UseQueryResult<`0x${string}`[], Error>;
|
|
730
|
+
signerError: Error | undefined;
|
|
731
|
+
data: Map<`0x${string}`, bigint>;
|
|
732
|
+
isError: false;
|
|
733
|
+
error: null;
|
|
734
|
+
isPending: false;
|
|
735
|
+
isLoading: false;
|
|
736
|
+
isLoadingError: false;
|
|
737
|
+
isRefetchError: false;
|
|
738
|
+
isSuccess: true;
|
|
739
|
+
isPlaceholderData: true;
|
|
740
|
+
status: "success";
|
|
741
|
+
dataUpdatedAt: number;
|
|
742
|
+
errorUpdatedAt: number;
|
|
743
|
+
failureCount: number;
|
|
744
|
+
failureReason: Error | null;
|
|
745
|
+
errorUpdateCount: number;
|
|
746
|
+
isFetched: boolean;
|
|
747
|
+
isFetchedAfterMount: boolean;
|
|
748
|
+
isFetching: boolean;
|
|
749
|
+
isInitialLoading: boolean;
|
|
750
|
+
isPaused: boolean;
|
|
751
|
+
isRefetching: boolean;
|
|
752
|
+
isStale: boolean;
|
|
753
|
+
isEnabled: boolean;
|
|
754
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Map<`0x${string}`, bigint>, Error>>;
|
|
755
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
756
|
+
promise: Promise<Map<`0x${string}`, bigint>>;
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* TanStack Query mutation options factory for authorize-all.
|
|
761
|
+
*
|
|
762
|
+
* @param sdk - A `TokenSDK` instance.
|
|
763
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
764
|
+
*/
|
|
765
|
+
declare function authorizeAllMutationOptions(sdk: TokenSDK): {
|
|
766
|
+
mutationKey: readonly ["authorizeAll"];
|
|
767
|
+
mutationFn: (tokenAddresses: Address[]) => Promise<void>;
|
|
768
|
+
};
|
|
769
|
+
/**
|
|
770
|
+
* Pre-authorize FHE decrypt credentials for a list of token addresses.
|
|
771
|
+
* A single wallet signature covers all addresses, so subsequent decrypt
|
|
772
|
+
* operations on any of these tokens reuse cached credentials.
|
|
773
|
+
*
|
|
774
|
+
* @example
|
|
775
|
+
* ```tsx
|
|
776
|
+
* const { mutateAsync: authorizeAll, isPending } = useAuthorizeAll();
|
|
777
|
+
* // Call authorizeAll(allTokenAddresses) before any individual reveal
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
declare function useAuthorizeAll(): _tanstack_react_query.UseMutationResult<void, Error, `0x${string}`[], unknown>;
|
|
781
|
+
|
|
782
|
+
/** Parameters passed to the `mutate` function of {@link useConfidentialTransfer}. */
|
|
783
|
+
interface ConfidentialTransferParams {
|
|
784
|
+
/** Recipient address. */
|
|
785
|
+
to: Address;
|
|
786
|
+
/** Amount to transfer (plaintext — encrypted automatically). */
|
|
787
|
+
amount: bigint;
|
|
788
|
+
}
|
|
789
|
+
/** Configuration for {@link useConfidentialTransfer}. */
|
|
790
|
+
interface UseConfidentialTransferConfig extends UseTokenConfig {
|
|
791
|
+
/**
|
|
792
|
+
* When `true`, optimistically subtracts the transfer amount from cached balance
|
|
793
|
+
* before the transaction confirms. Rolls back on error.
|
|
794
|
+
* @default false
|
|
795
|
+
*/
|
|
796
|
+
optimistic?: boolean;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* TanStack Query mutation options factory for confidential transfer.
|
|
800
|
+
*
|
|
801
|
+
* @param token - A `Token` instance.
|
|
802
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
803
|
+
*/
|
|
804
|
+
declare function confidentialTransferMutationOptions(token: Token): {
|
|
805
|
+
mutationKey: readonly ["confidentialTransfer", `0x${string}`];
|
|
806
|
+
mutationFn: ({ to, amount }: ConfidentialTransferParams) => Promise<`0x${string}`>;
|
|
807
|
+
};
|
|
808
|
+
/**
|
|
809
|
+
* Encrypt and send a confidential transfer. Invalidates balance caches on success.
|
|
810
|
+
*
|
|
811
|
+
* Errors are {@link TokenError} subclasses — use `instanceof` to handle specific failures:
|
|
812
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
813
|
+
* - {@link EncryptionFailedError} — FHE encryption failed
|
|
814
|
+
* - {@link TransactionRevertedError} — on-chain transaction reverted
|
|
815
|
+
*
|
|
816
|
+
* @param config - Token address (and optional wrapper) identifying the token.
|
|
817
|
+
* Set `optimistic: true` to subtract the amount from the cached balance immediately.
|
|
818
|
+
* @param options - React Query mutation options.
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* ```tsx
|
|
822
|
+
* const transfer = useConfidentialTransfer({
|
|
823
|
+
* tokenAddress: "0x...",
|
|
824
|
+
* optimistic: true,
|
|
825
|
+
* });
|
|
826
|
+
* transfer.mutate(
|
|
827
|
+
* { to: "0xRecipient", amount: 1000n },
|
|
828
|
+
* {
|
|
829
|
+
* onError: (error) => {
|
|
830
|
+
* if (error instanceof SigningRejectedError) {
|
|
831
|
+
* // user cancelled — no action needed
|
|
832
|
+
* }
|
|
833
|
+
* },
|
|
834
|
+
* },
|
|
835
|
+
* );
|
|
836
|
+
* ```
|
|
837
|
+
*/
|
|
838
|
+
declare function useConfidentialTransfer(config: UseConfidentialTransferConfig, options?: UseMutationOptions<Address, Error, ConfidentialTransferParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, ConfidentialTransferParams, `0x${string}`>;
|
|
839
|
+
|
|
840
|
+
/** Parameters passed to the `mutate` function of {@link useConfidentialTransferFrom}. */
|
|
841
|
+
interface ConfidentialTransferFromParams {
|
|
842
|
+
/** Address to transfer from. Caller must be an approved operator. */
|
|
843
|
+
from: Address;
|
|
844
|
+
/** Recipient address. */
|
|
845
|
+
to: Address;
|
|
846
|
+
/** Amount to transfer (plaintext — encrypted automatically). */
|
|
847
|
+
amount: bigint;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* TanStack Query mutation options factory for confidential transfer-from.
|
|
851
|
+
*
|
|
852
|
+
* @param token - A `Token` instance.
|
|
853
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
854
|
+
*/
|
|
855
|
+
declare function confidentialTransferFromMutationOptions(token: Token): {
|
|
856
|
+
mutationKey: readonly ["confidentialTransferFrom", `0x${string}`];
|
|
857
|
+
mutationFn: ({ from, to, amount }: ConfidentialTransferFromParams) => Promise<`0x${string}`>;
|
|
858
|
+
};
|
|
859
|
+
/**
|
|
860
|
+
* Operator transfer on behalf of another address. Caller must be an approved operator.
|
|
861
|
+
* Invalidates balance caches on success.
|
|
862
|
+
*
|
|
863
|
+
* @param config - Token address (and optional wrapper) identifying the token.
|
|
864
|
+
* @param options - React Query mutation options.
|
|
865
|
+
*
|
|
866
|
+
* @example
|
|
867
|
+
* ```tsx
|
|
868
|
+
* const transferFrom = useConfidentialTransferFrom({ tokenAddress: "0x..." });
|
|
869
|
+
* transferFrom.mutate({ from: "0xOwner", to: "0xRecipient", amount: 500n });
|
|
870
|
+
* ```
|
|
871
|
+
*/
|
|
872
|
+
declare function useConfidentialTransferFrom(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, ConfidentialTransferFromParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, ConfidentialTransferFromParams, `0x${string}`>;
|
|
873
|
+
|
|
874
|
+
/** Parameters passed to the `mutate` function of {@link useConfidentialApprove}. */
|
|
875
|
+
interface ConfidentialApproveParams {
|
|
876
|
+
/** Address to approve as operator. */
|
|
877
|
+
spender: Address;
|
|
878
|
+
/** Unix timestamp until which the approval is valid. Defaults to 1 hour from now. */
|
|
879
|
+
until?: number;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* TanStack Query mutation options factory for confidential approve.
|
|
883
|
+
*
|
|
884
|
+
* @param token - A `Token` instance.
|
|
885
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
886
|
+
*/
|
|
887
|
+
declare function confidentialApproveMutationOptions(token: Token): {
|
|
888
|
+
mutationKey: readonly ["confidentialApprove", `0x${string}`];
|
|
889
|
+
mutationFn: ({ spender, until }: ConfidentialApproveParams) => Promise<`0x${string}`>;
|
|
890
|
+
};
|
|
891
|
+
/**
|
|
892
|
+
* Set operator approval for a confidential token. Defaults to 1 hour.
|
|
893
|
+
*
|
|
894
|
+
* Errors are {@link TokenError} subclasses — use `instanceof` to handle specific failures:
|
|
895
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
896
|
+
* - {@link TransactionRevertedError} — on-chain transaction reverted
|
|
897
|
+
*
|
|
898
|
+
* @param config - Token address (and optional wrapper) identifying the token.
|
|
899
|
+
* @param options - React Query mutation options.
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* ```tsx
|
|
903
|
+
* const approve = useConfidentialApprove({ tokenAddress: "0x..." });
|
|
904
|
+
* approve.mutate({ spender: "0xOperator" });
|
|
905
|
+
* ```
|
|
906
|
+
*/
|
|
907
|
+
declare function useConfidentialApprove(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, ConfidentialApproveParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, ConfidentialApproveParams, `0x${string}`>;
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Query key factory for confidential approval queries.
|
|
911
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
912
|
+
*/
|
|
913
|
+
declare const confidentialIsApprovedQueryKeys: {
|
|
914
|
+
/** Match all approval queries. */
|
|
915
|
+
readonly all: readonly ["confidentialIsApproved"];
|
|
916
|
+
/** Match approval queries for a specific token. */
|
|
917
|
+
readonly token: (tokenAddress: string) => readonly ["confidentialIsApproved", string];
|
|
918
|
+
/** Match approval queries for a specific token + spender pair. */
|
|
919
|
+
readonly spender: (tokenAddress: string, spender: string) => readonly ["confidentialIsApproved", string, string];
|
|
920
|
+
};
|
|
921
|
+
/** Configuration for {@link useConfidentialIsApproved}. */
|
|
922
|
+
interface UseConfidentialIsApprovedConfig extends UseTokenConfig {
|
|
923
|
+
/** Address to check approval for. Pass `undefined` to disable the query. */
|
|
924
|
+
spender: Address | undefined;
|
|
925
|
+
}
|
|
926
|
+
/** Configuration for {@link useConfidentialIsApprovedSuspense}. */
|
|
927
|
+
interface UseConfidentialIsApprovedSuspenseConfig extends UseTokenConfig {
|
|
928
|
+
/** Address to check approval for. */
|
|
929
|
+
spender: Address;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* TanStack Query options factory for confidential approval check.
|
|
933
|
+
*
|
|
934
|
+
* @param token - A `Token` instance.
|
|
935
|
+
* @param spender - Address to check approval for.
|
|
936
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
937
|
+
*/
|
|
938
|
+
declare function confidentialIsApprovedQueryOptions(token: Token, spender: Address): {
|
|
939
|
+
readonly queryKey: readonly ["confidentialIsApproved", string, string];
|
|
940
|
+
readonly queryFn: () => Promise<boolean>;
|
|
941
|
+
readonly staleTime: 30000;
|
|
942
|
+
};
|
|
943
|
+
/**
|
|
944
|
+
* Check if a spender is an approved operator for the connected wallet.
|
|
945
|
+
*
|
|
946
|
+
* @param config - Token address and spender to check.
|
|
947
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
948
|
+
* @returns Query result with `data: boolean`.
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
* ```tsx
|
|
952
|
+
* const { data: isApproved } = useConfidentialIsApproved({
|
|
953
|
+
* tokenAddress: "0xToken",
|
|
954
|
+
* spender: "0xSpender",
|
|
955
|
+
* });
|
|
956
|
+
* ```
|
|
957
|
+
*/
|
|
958
|
+
declare function useConfidentialIsApproved(config: UseConfidentialIsApprovedConfig, options?: Omit<UseQueryOptions<boolean, Error>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<boolean, Error>;
|
|
959
|
+
/**
|
|
960
|
+
* Suspense variant of {@link useConfidentialIsApproved}.
|
|
961
|
+
* Suspends rendering until the approval check resolves.
|
|
962
|
+
*
|
|
963
|
+
* @param config - Token address and spender to check.
|
|
964
|
+
* @returns Suspense query result with `data: boolean`.
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
* ```tsx
|
|
968
|
+
* const { data: isApproved } = useConfidentialIsApprovedSuspense({
|
|
969
|
+
* tokenAddress: "0xToken",
|
|
970
|
+
* spender: "0xSpender",
|
|
971
|
+
* });
|
|
972
|
+
* ```
|
|
973
|
+
*/
|
|
974
|
+
declare function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig): _tanstack_react_query.UseSuspenseQueryResult<boolean, Error>;
|
|
975
|
+
|
|
976
|
+
/** Parameters passed to the `mutate` function of {@link useWrap}. */
|
|
977
|
+
interface WrapParams {
|
|
978
|
+
/** Amount of underlying ERC-20 tokens to wrap. */
|
|
979
|
+
amount: bigint;
|
|
980
|
+
/** Optional fee amount (for native ETH wrapping with fees). */
|
|
981
|
+
fees?: bigint;
|
|
982
|
+
/** ERC-20 approval strategy: `"exact"` (default), `"max"`, or `"skip"`. */
|
|
983
|
+
approvalStrategy?: "max" | "exact" | "skip";
|
|
984
|
+
}
|
|
985
|
+
/** Configuration for {@link useWrap}. */
|
|
986
|
+
interface UseWrapConfig extends UseTokenConfig {
|
|
987
|
+
/**
|
|
988
|
+
* When `true`, optimistically adds the wrap amount to the cached confidential balance
|
|
989
|
+
* before the transaction confirms. Rolls back on error.
|
|
990
|
+
* @default false
|
|
991
|
+
*/
|
|
992
|
+
optimistic?: boolean;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* TanStack Query mutation options factory for wrap (shield).
|
|
996
|
+
*
|
|
997
|
+
* @param token - A `Token` instance.
|
|
998
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
999
|
+
*/
|
|
1000
|
+
declare function wrapMutationOptions(token: Token): {
|
|
1001
|
+
mutationKey: readonly ["wrap", `0x${string}`];
|
|
1002
|
+
mutationFn: ({ amount, fees, approvalStrategy }: WrapParams) => Promise<`0x${string}`>;
|
|
1003
|
+
};
|
|
1004
|
+
/**
|
|
1005
|
+
* Wrap (shield) public ERC-20 tokens into confidential tokens.
|
|
1006
|
+
* Handles ERC-20 approval automatically. Invalidates balance caches on success.
|
|
1007
|
+
*
|
|
1008
|
+
* Errors are {@link TokenError} subclasses — use `instanceof` to handle specific failures:
|
|
1009
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
1010
|
+
* - {@link ApprovalFailedError} — ERC-20 approval transaction failed
|
|
1011
|
+
* - {@link TransactionRevertedError} — wrap transaction reverted
|
|
1012
|
+
*
|
|
1013
|
+
* @param config - Token and wrapper addresses.
|
|
1014
|
+
* Set `optimistic: true` to add the amount to the cached balance immediately.
|
|
1015
|
+
* @param options - React Query mutation options.
|
|
1016
|
+
*
|
|
1017
|
+
* @example
|
|
1018
|
+
* ```tsx
|
|
1019
|
+
* const wrap = useWrap({ tokenAddress: "0x...", wrapperAddress: "0x...", optimistic: true });
|
|
1020
|
+
* wrap.mutate({ amount: 1000n });
|
|
1021
|
+
* ```
|
|
1022
|
+
*/
|
|
1023
|
+
declare function useWrap(config: UseWrapConfig, options?: UseMutationOptions<Address, Error, WrapParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, WrapParams, `0x${string}`>;
|
|
1024
|
+
|
|
1025
|
+
/** Parameters passed to the `mutate` function of {@link useWrapETH}. */
|
|
1026
|
+
interface WrapETHParams {
|
|
1027
|
+
/** Amount of ETH to wrap (in wei). */
|
|
1028
|
+
amount: bigint;
|
|
1029
|
+
/** ETH value to send with the transaction. Defaults to `amount`. */
|
|
1030
|
+
value?: bigint;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* TanStack Query mutation options factory for wrap ETH (shield).
|
|
1034
|
+
*
|
|
1035
|
+
* @param token - A `Token` instance.
|
|
1036
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
1037
|
+
*/
|
|
1038
|
+
declare function wrapETHMutationOptions(token: Token): {
|
|
1039
|
+
mutationKey: readonly ["wrapETH", `0x${string}`];
|
|
1040
|
+
mutationFn: ({ amount, value }: WrapETHParams) => Promise<`0x${string}`>;
|
|
1041
|
+
};
|
|
1042
|
+
/**
|
|
1043
|
+
* Wrap (shield) native ETH into confidential tokens.
|
|
1044
|
+
* Invalidates balance caches on success.
|
|
1045
|
+
*
|
|
1046
|
+
* @param config - Token and wrapper addresses.
|
|
1047
|
+
* @param options - React Query mutation options.
|
|
1048
|
+
*
|
|
1049
|
+
* @example
|
|
1050
|
+
* ```tsx
|
|
1051
|
+
* const wrapETH = useWrapETH({ tokenAddress: "0x...", wrapperAddress: "0x..." });
|
|
1052
|
+
* wrapETH.mutate({ amount: 1000000000000000000n }); // 1 ETH
|
|
1053
|
+
* ```
|
|
1054
|
+
*/
|
|
1055
|
+
declare function useWrapETH(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, WrapETHParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, WrapETHParams, `0x${string}`>;
|
|
1056
|
+
|
|
1057
|
+
/** Parameters passed to the `mutate` function of {@link useUnwrap}. */
|
|
1058
|
+
interface UnwrapParams {
|
|
1059
|
+
/** Amount to unwrap (plaintext — encrypted automatically). */
|
|
1060
|
+
amount: bigint;
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* TanStack Query mutation options factory for unwrap.
|
|
1064
|
+
*
|
|
1065
|
+
* @param token - A `Token` instance.
|
|
1066
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
1067
|
+
*/
|
|
1068
|
+
declare function unwrapMutationOptions(token: Token): {
|
|
1069
|
+
mutationKey: readonly ["unwrap", `0x${string}`];
|
|
1070
|
+
mutationFn: ({ amount }: UnwrapParams) => Promise<`0x${string}`>;
|
|
1071
|
+
};
|
|
1072
|
+
/**
|
|
1073
|
+
* Request an unwrap for a specific amount. Encrypts the amount first.
|
|
1074
|
+
* Call {@link useFinalizeUnwrap} after the request is processed on-chain,
|
|
1075
|
+
* or use {@link useUnshield} for a single-call orchestration.
|
|
1076
|
+
*
|
|
1077
|
+
* @param config - Token address (and optional wrapper) identifying the token.
|
|
1078
|
+
* @param options - React Query mutation options.
|
|
1079
|
+
*
|
|
1080
|
+
* @example
|
|
1081
|
+
* ```tsx
|
|
1082
|
+
* const unwrap = useUnwrap({ tokenAddress: "0x..." });
|
|
1083
|
+
* unwrap.mutate({ amount: 500n });
|
|
1084
|
+
* ```
|
|
1085
|
+
*/
|
|
1086
|
+
declare function useUnwrap(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, UnwrapParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, UnwrapParams, `0x${string}`>;
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* TanStack Query mutation options factory for unwrap-all.
|
|
1090
|
+
*
|
|
1091
|
+
* @param token - A `Token` instance.
|
|
1092
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
1093
|
+
*/
|
|
1094
|
+
declare function unwrapAllMutationOptions(token: Token): {
|
|
1095
|
+
mutationKey: readonly ["unwrapAll", `0x${string}`];
|
|
1096
|
+
mutationFn: () => Promise<`0x${string}`>;
|
|
1097
|
+
};
|
|
1098
|
+
/**
|
|
1099
|
+
* Request an unwrap for the entire confidential balance.
|
|
1100
|
+
* Uses the on-chain balance handle directly (no encryption needed).
|
|
1101
|
+
* Call {@link useFinalizeUnwrap} after processing, or use {@link useUnshieldAll} for single-call orchestration.
|
|
1102
|
+
*
|
|
1103
|
+
* @param config - Token address (and optional wrapper) identifying the token.
|
|
1104
|
+
* @param options - React Query mutation options.
|
|
1105
|
+
*
|
|
1106
|
+
* @example
|
|
1107
|
+
* ```tsx
|
|
1108
|
+
* const unwrapAll = useUnwrapAll({ tokenAddress: "0x..." });
|
|
1109
|
+
* unwrapAll.mutate();
|
|
1110
|
+
* ```
|
|
1111
|
+
*/
|
|
1112
|
+
declare function useUnwrapAll(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, void, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, void, `0x${string}`>;
|
|
1113
|
+
|
|
1114
|
+
/** Parameters passed to the `mutate` function of {@link useFinalizeUnwrap}. */
|
|
1115
|
+
interface FinalizeUnwrapParams {
|
|
1116
|
+
/** Encrypted amount handle from the UnwrapRequested event. */
|
|
1117
|
+
burnAmountHandle: Address;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* TanStack Query mutation options factory for finalize-unwrap.
|
|
1121
|
+
*
|
|
1122
|
+
* @param token - A `Token` instance.
|
|
1123
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
1124
|
+
*/
|
|
1125
|
+
declare function finalizeUnwrapMutationOptions(token: Token): {
|
|
1126
|
+
mutationKey: readonly ["finalizeUnwrap", `0x${string}`];
|
|
1127
|
+
mutationFn: ({ burnAmountHandle }: FinalizeUnwrapParams) => Promise<`0x${string}`>;
|
|
1128
|
+
};
|
|
1129
|
+
/**
|
|
1130
|
+
* Complete an unwrap by providing the public decryption proof.
|
|
1131
|
+
* Call this after an unwrap request has been processed on-chain.
|
|
1132
|
+
*
|
|
1133
|
+
* @param config - Token address (and optional wrapper) identifying the token.
|
|
1134
|
+
* @param options - React Query mutation options.
|
|
1135
|
+
*
|
|
1136
|
+
* @example
|
|
1137
|
+
* ```tsx
|
|
1138
|
+
* const finalize = useFinalizeUnwrap({ tokenAddress: "0x..." });
|
|
1139
|
+
* finalize.mutate({ burnAmountHandle: event.encryptedAmount });
|
|
1140
|
+
* ```
|
|
1141
|
+
*/
|
|
1142
|
+
declare function useFinalizeUnwrap(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, FinalizeUnwrapParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, FinalizeUnwrapParams, `0x${string}`>;
|
|
1143
|
+
|
|
1144
|
+
/** Parameters passed to the `mutate` function of {@link useUnshield}. */
|
|
1145
|
+
interface UnshieldParams {
|
|
1146
|
+
/** Amount to unshield (plaintext — encrypted automatically). */
|
|
1147
|
+
amount: bigint;
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* TanStack Query mutation options factory for unshield.
|
|
1151
|
+
*
|
|
1152
|
+
* @param token - A `Token` instance.
|
|
1153
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
1154
|
+
*/
|
|
1155
|
+
declare function unshieldMutationOptions(token: Token): {
|
|
1156
|
+
mutationKey: readonly ["unshield", `0x${string}`];
|
|
1157
|
+
mutationFn: ({ amount }: UnshieldParams) => Promise<`0x${string}`>;
|
|
1158
|
+
};
|
|
1159
|
+
/**
|
|
1160
|
+
* Unshield a specific amount and finalize in one call.
|
|
1161
|
+
* Orchestrates: unwrap → wait for receipt → parse event → finalize.
|
|
1162
|
+
*
|
|
1163
|
+
* Errors are {@link TokenError} subclasses — use `instanceof` to handle specific failures:
|
|
1164
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
1165
|
+
* - {@link EncryptionFailedError} — FHE encryption failed during unwrap
|
|
1166
|
+
* - {@link DecryptionFailedError} — public decryption failed during finalize
|
|
1167
|
+
* - {@link TransactionRevertedError} — on-chain transaction reverted
|
|
1168
|
+
*
|
|
1169
|
+
* @param config - Token and wrapper addresses.
|
|
1170
|
+
* @param options - React Query mutation options.
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```tsx
|
|
1174
|
+
* const unshield = useUnshield({ tokenAddress: "0x...", wrapperAddress: "0x..." });
|
|
1175
|
+
* unshield.mutate({ amount: 500n });
|
|
1176
|
+
* ```
|
|
1177
|
+
*/
|
|
1178
|
+
declare function useUnshield(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, UnshieldParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, UnshieldParams, `0x${string}`>;
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* TanStack Query mutation options factory for unshield-all.
|
|
1182
|
+
*
|
|
1183
|
+
* @param token - A `Token` instance.
|
|
1184
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
1185
|
+
*/
|
|
1186
|
+
declare function unshieldAllMutationOptions(token: Token): {
|
|
1187
|
+
mutationKey: readonly ["unshieldAll", `0x${string}`];
|
|
1188
|
+
mutationFn: () => Promise<`0x${string}`>;
|
|
1189
|
+
};
|
|
1190
|
+
/**
|
|
1191
|
+
* Unshield the entire balance and finalize in one call.
|
|
1192
|
+
* Orchestrates: unwrapAll → wait for receipt → parse event → finalize.
|
|
1193
|
+
*
|
|
1194
|
+
* @param config - Token and wrapper addresses.
|
|
1195
|
+
* @param options - React Query mutation options.
|
|
1196
|
+
*
|
|
1197
|
+
* @example
|
|
1198
|
+
* ```tsx
|
|
1199
|
+
* const unshieldAll = useUnshieldAll({ tokenAddress: "0x...", wrapperAddress: "0x..." });
|
|
1200
|
+
* unshieldAll.mutate();
|
|
1201
|
+
* ```
|
|
1202
|
+
*/
|
|
1203
|
+
declare function useUnshieldAll(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, void, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, void, `0x${string}`>;
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Query key factory for underlying ERC-20 allowance queries.
|
|
1207
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1208
|
+
*/
|
|
1209
|
+
declare const underlyingAllowanceQueryKeys: {
|
|
1210
|
+
/** Match all underlying allowance queries. */
|
|
1211
|
+
readonly all: readonly ["underlyingAllowance"];
|
|
1212
|
+
/** Match allowance query for a specific token + wrapper pair. */
|
|
1213
|
+
readonly token: (tokenAddress: string, wrapper: string) => readonly ["underlyingAllowance", string, string];
|
|
1214
|
+
};
|
|
1215
|
+
/** Configuration for {@link useUnderlyingAllowance}. */
|
|
1216
|
+
interface UseUnderlyingAllowanceConfig {
|
|
1217
|
+
/** Address of the underlying ERC-20 token. */
|
|
1218
|
+
tokenAddress: Address;
|
|
1219
|
+
/** Address of the wrapper contract (the spender). */
|
|
1220
|
+
wrapperAddress: Address;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* TanStack Query options factory for underlying ERC-20 allowance.
|
|
1224
|
+
*
|
|
1225
|
+
* @param token - A `ReadonlyToken` instance.
|
|
1226
|
+
* @param wrapperAddress - Address of the wrapper contract (the spender).
|
|
1227
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1228
|
+
*/
|
|
1229
|
+
declare function underlyingAllowanceQueryOptions(token: ReadonlyToken, wrapperAddress: Address): {
|
|
1230
|
+
readonly queryKey: readonly ["underlyingAllowance", string, string];
|
|
1231
|
+
readonly queryFn: () => Promise<bigint>;
|
|
1232
|
+
readonly staleTime: 30000;
|
|
1233
|
+
};
|
|
1234
|
+
/**
|
|
1235
|
+
* Read the underlying ERC-20 allowance granted to the wrapper contract.
|
|
1236
|
+
* Useful to check if an approval is needed before shielding.
|
|
1237
|
+
*
|
|
1238
|
+
* @param config - Token and wrapper addresses.
|
|
1239
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1240
|
+
* @returns Query result with `data: bigint` (current allowance).
|
|
1241
|
+
*
|
|
1242
|
+
* @example
|
|
1243
|
+
* ```tsx
|
|
1244
|
+
* const { data: allowance } = useUnderlyingAllowance({
|
|
1245
|
+
* tokenAddress: "0xUnderlying",
|
|
1246
|
+
* wrapperAddress: "0xWrapper",
|
|
1247
|
+
* });
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
declare function useUnderlyingAllowance(config: UseUnderlyingAllowanceConfig, options?: Omit<UseQueryOptions<bigint, Error>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<bigint, Error>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Suspense variant of {@link useUnderlyingAllowance}.
|
|
1253
|
+
* Suspends rendering until the allowance is loaded.
|
|
1254
|
+
*
|
|
1255
|
+
* @param config - Token and wrapper addresses.
|
|
1256
|
+
* @returns Suspense query result with `data: bigint`.
|
|
1257
|
+
*
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```tsx
|
|
1260
|
+
* const { data: allowance } = useUnderlyingAllowanceSuspense({
|
|
1261
|
+
* tokenAddress: "0xUnderlying",
|
|
1262
|
+
* wrapperAddress: "0xWrapper",
|
|
1263
|
+
* });
|
|
1264
|
+
* ```
|
|
1265
|
+
*/
|
|
1266
|
+
declare function useUnderlyingAllowanceSuspense(config: UseUnderlyingAllowanceConfig): _tanstack_react_query.UseSuspenseQueryResult<bigint, Error>;
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Query key factories for confidential balance queries.
|
|
1270
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()` / `removeQueries()`.
|
|
1271
|
+
*
|
|
1272
|
+
* @example
|
|
1273
|
+
* ```ts
|
|
1274
|
+
* // Invalidate all balance queries
|
|
1275
|
+
* queryClient.invalidateQueries({ queryKey: confidentialBalanceQueryKeys.all });
|
|
1276
|
+
*
|
|
1277
|
+
* // Reset balance for a specific token + owner
|
|
1278
|
+
* queryClient.resetQueries({
|
|
1279
|
+
* queryKey: confidentialBalanceQueryKeys.owner("0xToken", "0xOwner"),
|
|
1280
|
+
* });
|
|
1281
|
+
* ```
|
|
1282
|
+
*/
|
|
1283
|
+
declare const confidentialBalanceQueryKeys: {
|
|
1284
|
+
/** Match all single-token balance queries. */
|
|
1285
|
+
readonly all: readonly ["confidentialBalance"];
|
|
1286
|
+
/** Match balance queries for a specific token (any owner). */
|
|
1287
|
+
readonly token: (tokenAddress: string) => readonly ["confidentialBalance", string];
|
|
1288
|
+
/** Match balance query for a specific token + owner. */
|
|
1289
|
+
readonly owner: (tokenAddress: string, owner: string) => readonly ["confidentialBalance", string, string];
|
|
1290
|
+
};
|
|
1291
|
+
/**
|
|
1292
|
+
* Query key factory for batch balance queries (multiple tokens).
|
|
1293
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1294
|
+
*/
|
|
1295
|
+
declare const confidentialBalancesQueryKeys: {
|
|
1296
|
+
/** Match all batch balance queries. */
|
|
1297
|
+
readonly all: readonly ["confidentialBalances"];
|
|
1298
|
+
/** Match batch balance query for a specific token set + owner. */
|
|
1299
|
+
readonly tokens: (tokenAddresses: string[], owner: string) => readonly ["confidentialBalances", string[], string];
|
|
1300
|
+
};
|
|
1301
|
+
/**
|
|
1302
|
+
* Query key factory for encrypted handle queries (Phase 1 of two-phase polling).
|
|
1303
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1304
|
+
*/
|
|
1305
|
+
declare const confidentialHandleQueryKeys: {
|
|
1306
|
+
/** Match all single-token handle queries. */
|
|
1307
|
+
readonly all: readonly ["confidentialHandle"];
|
|
1308
|
+
/** Match handle queries for a specific token (any owner). */
|
|
1309
|
+
readonly token: (tokenAddress: string) => readonly ["confidentialHandle", string];
|
|
1310
|
+
/** Match handle query for a specific token + owner. */
|
|
1311
|
+
readonly owner: (tokenAddress: string, owner: string) => readonly ["confidentialHandle", string, string];
|
|
1312
|
+
};
|
|
1313
|
+
/**
|
|
1314
|
+
* Query key factory for batch encrypted handle queries (Phase 1, multiple tokens).
|
|
1315
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1316
|
+
*/
|
|
1317
|
+
declare const confidentialHandlesQueryKeys: {
|
|
1318
|
+
/** Match all batch handle queries. */
|
|
1319
|
+
readonly all: readonly ["confidentialHandles"];
|
|
1320
|
+
/** Match batch handle query for a specific token set + owner. */
|
|
1321
|
+
readonly tokens: (tokenAddresses: string[], owner: string) => readonly ["confidentialHandles", string[], string];
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Query key factory for wrapper discovery queries.
|
|
1326
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1327
|
+
*/
|
|
1328
|
+
declare const wrapperDiscoveryQueryKeys: {
|
|
1329
|
+
/** Match all wrapper discovery queries. */
|
|
1330
|
+
readonly all: readonly ["wrapperDiscovery"];
|
|
1331
|
+
/** Match wrapper discovery queries for a specific token. */
|
|
1332
|
+
readonly token: (tokenAddress: string) => readonly ["wrapperDiscovery", string];
|
|
1333
|
+
/** Match wrapper discovery query for a specific token + coordinator pair. */
|
|
1334
|
+
readonly tokenCoordinator: (tokenAddress: string, coordinatorAddress: string) => readonly ["wrapperDiscovery", string, string];
|
|
1335
|
+
};
|
|
1336
|
+
/** Configuration for {@link useWrapperDiscovery}. */
|
|
1337
|
+
interface UseWrapperDiscoveryConfig {
|
|
1338
|
+
/** Address of the underlying ERC-20 token. */
|
|
1339
|
+
tokenAddress: Address;
|
|
1340
|
+
/** Address of the wrapper coordinator. Pass `undefined` to disable the query. */
|
|
1341
|
+
coordinatorAddress: Address | undefined;
|
|
1342
|
+
}
|
|
1343
|
+
/** Configuration for {@link useWrapperDiscoverySuspense}. */
|
|
1344
|
+
interface UseWrapperDiscoverySuspenseConfig {
|
|
1345
|
+
/** Address of the underlying ERC-20 token. */
|
|
1346
|
+
tokenAddress: Address;
|
|
1347
|
+
/** Address of the wrapper coordinator. */
|
|
1348
|
+
coordinatorAddress: Address;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* TanStack Query options factory for wrapper discovery.
|
|
1352
|
+
*
|
|
1353
|
+
* @param token - A `ReadonlyToken` instance.
|
|
1354
|
+
* @param coordinatorAddress - Address of the wrapper coordinator.
|
|
1355
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1356
|
+
*/
|
|
1357
|
+
declare function wrapperDiscoveryQueryOptions(token: ReadonlyToken, coordinatorAddress: Address): {
|
|
1358
|
+
readonly queryKey: readonly ["wrapperDiscovery", string, string];
|
|
1359
|
+
readonly queryFn: () => Promise<`0x${string}` | null>;
|
|
1360
|
+
readonly staleTime: number;
|
|
1361
|
+
};
|
|
1362
|
+
/**
|
|
1363
|
+
* Discover the wrapper contract for an ERC-20 token.
|
|
1364
|
+
* Returns the wrapper address if one exists, or `null` if not.
|
|
1365
|
+
* Cached indefinitely since wrapper mappings are immutable.
|
|
1366
|
+
*
|
|
1367
|
+
* @param config - Token and coordinator addresses.
|
|
1368
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1369
|
+
* @returns Query result with `data: Address | null`.
|
|
1370
|
+
*
|
|
1371
|
+
* @example
|
|
1372
|
+
* ```tsx
|
|
1373
|
+
* const { data: wrapperAddress } = useWrapperDiscovery({
|
|
1374
|
+
* tokenAddress: "0xUnderlying",
|
|
1375
|
+
* coordinatorAddress: "0xCoordinator",
|
|
1376
|
+
* });
|
|
1377
|
+
* ```
|
|
1378
|
+
*/
|
|
1379
|
+
declare function useWrapperDiscovery(config: UseWrapperDiscoveryConfig, options?: Omit<UseQueryOptions<Address | null, Error>, "queryKey" | "queryFn">): UseQueryResult<Address | null, Error>;
|
|
1380
|
+
/**
|
|
1381
|
+
* Suspense variant of {@link useWrapperDiscovery}.
|
|
1382
|
+
* Suspends rendering until the wrapper address is resolved.
|
|
1383
|
+
*
|
|
1384
|
+
* @param config - Token and coordinator addresses.
|
|
1385
|
+
* @returns Suspense query result with `data: Address | null`.
|
|
1386
|
+
*
|
|
1387
|
+
* @example
|
|
1388
|
+
* ```tsx
|
|
1389
|
+
* const { data: wrapperAddress } = useWrapperDiscoverySuspense({
|
|
1390
|
+
* tokenAddress: "0xUnderlying",
|
|
1391
|
+
* coordinatorAddress: "0xCoordinator",
|
|
1392
|
+
* });
|
|
1393
|
+
* ```
|
|
1394
|
+
*/
|
|
1395
|
+
declare function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig): UseSuspenseQueryResult<Address | null, Error>;
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Query key factory for token metadata queries.
|
|
1399
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1400
|
+
*/
|
|
1401
|
+
declare const tokenMetadataQueryKeys: {
|
|
1402
|
+
/** Match all token metadata queries. */
|
|
1403
|
+
readonly all: readonly ["tokenMetadata"];
|
|
1404
|
+
/** Match metadata query for a specific token. */
|
|
1405
|
+
readonly token: (tokenAddress: string) => readonly ["tokenMetadata", string];
|
|
1406
|
+
};
|
|
1407
|
+
/** ERC-20 token metadata (name, symbol, decimals). */
|
|
1408
|
+
interface TokenMetadata {
|
|
1409
|
+
/** Human-readable token name (e.g. "Wrapped Ether"). */
|
|
1410
|
+
name: string;
|
|
1411
|
+
/** Short ticker symbol (e.g. "WETH"). */
|
|
1412
|
+
symbol: string;
|
|
1413
|
+
/** Number of decimal places (e.g. 18). */
|
|
1414
|
+
decimals: number;
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* TanStack Query options factory for token metadata.
|
|
1418
|
+
* Returns a config object usable with `useQuery`, `prefetchQuery`, `useQueries`, etc.
|
|
1419
|
+
*
|
|
1420
|
+
* @param token - A `ReadonlyToken` instance.
|
|
1421
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1422
|
+
*
|
|
1423
|
+
* @example
|
|
1424
|
+
* ```ts
|
|
1425
|
+
* const options = tokenMetadataQueryOptions(token);
|
|
1426
|
+
* await queryClient.prefetchQuery(options);
|
|
1427
|
+
* ```
|
|
1428
|
+
*/
|
|
1429
|
+
declare function tokenMetadataQueryOptions(token: ReadonlyToken): {
|
|
1430
|
+
readonly queryKey: readonly ["tokenMetadata", string];
|
|
1431
|
+
readonly queryFn: () => Promise<TokenMetadata>;
|
|
1432
|
+
readonly staleTime: number;
|
|
1433
|
+
};
|
|
1434
|
+
/**
|
|
1435
|
+
* Read ERC-20 token metadata (name, symbol, decimals).
|
|
1436
|
+
* Fetches all three in parallel. Cached indefinitely since metadata is immutable.
|
|
1437
|
+
*
|
|
1438
|
+
* @param tokenAddress - Address of the token contract.
|
|
1439
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1440
|
+
* @returns Query result with `data: TokenMetadata`.
|
|
1441
|
+
*
|
|
1442
|
+
* @example
|
|
1443
|
+
* ```tsx
|
|
1444
|
+
* const { data: metadata } = useTokenMetadata("0xToken");
|
|
1445
|
+
* // metadata?.name, metadata?.symbol, metadata?.decimals
|
|
1446
|
+
* ```
|
|
1447
|
+
*/
|
|
1448
|
+
declare function useTokenMetadata(tokenAddress: Address, options?: Omit<UseQueryOptions<TokenMetadata, Error>, "queryKey" | "queryFn">): UseQueryResult<TokenMetadata, Error>;
|
|
1449
|
+
/**
|
|
1450
|
+
* Suspense variant of {@link useTokenMetadata}.
|
|
1451
|
+
* Suspends rendering until metadata is loaded.
|
|
1452
|
+
*
|
|
1453
|
+
* @param tokenAddress - Address of the token contract.
|
|
1454
|
+
* @returns Suspense query result with `data: TokenMetadata`.
|
|
1455
|
+
*
|
|
1456
|
+
* @example
|
|
1457
|
+
* ```tsx
|
|
1458
|
+
* const { data: metadata } = useTokenMetadataSuspense("0xToken");
|
|
1459
|
+
* ```
|
|
1460
|
+
*/
|
|
1461
|
+
declare function useTokenMetadataSuspense(tokenAddress: Address): UseSuspenseQueryResult<TokenMetadata, Error>;
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* Query key factory for activity feed queries.
|
|
1465
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1466
|
+
*/
|
|
1467
|
+
declare const activityFeedQueryKeys: {
|
|
1468
|
+
/** Match all activity feed queries. */
|
|
1469
|
+
readonly all: readonly ["activityFeed"];
|
|
1470
|
+
/** Match activity feed queries for a specific token. */
|
|
1471
|
+
readonly token: (tokenAddress: string) => readonly ["activityFeed", string];
|
|
1472
|
+
};
|
|
1473
|
+
/** Configuration for {@link useActivityFeed}. */
|
|
1474
|
+
interface UseActivityFeedConfig {
|
|
1475
|
+
/** Address of the confidential token contract. */
|
|
1476
|
+
tokenAddress: Address;
|
|
1477
|
+
/** Connected wallet address. Pass `undefined` to disable the query. */
|
|
1478
|
+
userAddress: Address | undefined;
|
|
1479
|
+
/** Raw event logs from the provider (viem, ethers, etc.). Pass `undefined` to disable. */
|
|
1480
|
+
logs: readonly (RawLog & Partial<ActivityLogMetadata>)[] | undefined;
|
|
1481
|
+
/** Whether to batch-decrypt encrypted transfer amounts. Default: `true`. */
|
|
1482
|
+
decrypt?: boolean;
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Two-phase activity feed hook.
|
|
1486
|
+
* Phase 1: Instantly parses raw logs into classified {@link ActivityItem}s (sync, cheap).
|
|
1487
|
+
* Phase 2: Batch-decrypts encrypted transfer amounts via the relayer (async).
|
|
1488
|
+
*
|
|
1489
|
+
* The wallet provides logs (from its own provider — viem, ethers, etc.)
|
|
1490
|
+
* and this hook normalizes + decrypts them.
|
|
1491
|
+
*
|
|
1492
|
+
* @param config - Token address, user address, raw logs, and decrypt option.
|
|
1493
|
+
* @returns Query result with `data: ActivityItem[]`.
|
|
1494
|
+
*
|
|
1495
|
+
* @example
|
|
1496
|
+
* ```tsx
|
|
1497
|
+
* const { data: activity } = useActivityFeed({
|
|
1498
|
+
* tokenAddress: "0xToken",
|
|
1499
|
+
* userAddress: "0xUser",
|
|
1500
|
+
* logs: rawLogs,
|
|
1501
|
+
* });
|
|
1502
|
+
* ```
|
|
1503
|
+
*/
|
|
1504
|
+
declare function useActivityFeed(config: UseActivityFeedConfig): UseQueryResult<ActivityItem[], Error>;
|
|
1505
|
+
|
|
1506
|
+
/** Parameters passed to the `mutate` function of {@link useApproveUnderlying}. */
|
|
1507
|
+
interface ApproveUnderlyingParams {
|
|
1508
|
+
/** Approval amount. Defaults to max uint256 if omitted. */
|
|
1509
|
+
amount?: bigint;
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* TanStack Query mutation options factory for approve-underlying.
|
|
1513
|
+
*
|
|
1514
|
+
* @param token - A `Token` instance.
|
|
1515
|
+
* @returns Mutation options with `mutationKey` and `mutationFn`.
|
|
1516
|
+
*/
|
|
1517
|
+
declare function approveUnderlyingMutationOptions(token: Token): {
|
|
1518
|
+
mutationKey: readonly ["approveUnderlying", `0x${string}`];
|
|
1519
|
+
mutationFn: ({ amount }: ApproveUnderlyingParams) => Promise<`0x${string}`>;
|
|
1520
|
+
};
|
|
1521
|
+
/**
|
|
1522
|
+
* Approve the wrapper contract to spend the underlying ERC-20.
|
|
1523
|
+
* Defaults to max uint256. Resets to zero first if there's an existing
|
|
1524
|
+
* non-zero allowance (required by tokens like USDT).
|
|
1525
|
+
*
|
|
1526
|
+
* @param config - Token and wrapper addresses.
|
|
1527
|
+
* @param options - React Query mutation options.
|
|
1528
|
+
*
|
|
1529
|
+
* @example
|
|
1530
|
+
* ```tsx
|
|
1531
|
+
* const approve = useApproveUnderlying({ tokenAddress: "0x...", wrapperAddress: "0x..." });
|
|
1532
|
+
* approve.mutate({}); // max approval
|
|
1533
|
+
* approve.mutate({ amount: 1000n }); // exact amount
|
|
1534
|
+
* ```
|
|
1535
|
+
*/
|
|
1536
|
+
declare function useApproveUnderlying(config: UseTokenConfig, options?: UseMutationOptions<Address, Error, ApproveUnderlyingParams, Address>): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, ApproveUnderlyingParams, `0x${string}`>;
|
|
1537
|
+
|
|
1538
|
+
/**
|
|
1539
|
+
* Query key factory for ERC-165 confidential interface checks.
|
|
1540
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1541
|
+
*/
|
|
1542
|
+
declare const isConfidentialQueryKeys: {
|
|
1543
|
+
/** Match all confidential interface queries. */
|
|
1544
|
+
readonly all: readonly ["isConfidential"];
|
|
1545
|
+
/** Match confidential interface query for a specific token. */
|
|
1546
|
+
readonly token: (tokenAddress: string) => readonly ["isConfidential", string];
|
|
1547
|
+
};
|
|
1548
|
+
/**
|
|
1549
|
+
* Query key factory for ERC-165 wrapper interface checks.
|
|
1550
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1551
|
+
*/
|
|
1552
|
+
declare const isWrapperQueryKeys: {
|
|
1553
|
+
/** Match all wrapper interface queries. */
|
|
1554
|
+
readonly all: readonly ["isWrapper"];
|
|
1555
|
+
/** Match wrapper interface query for a specific token. */
|
|
1556
|
+
readonly token: (tokenAddress: string) => readonly ["isWrapper", string];
|
|
1557
|
+
};
|
|
1558
|
+
/**
|
|
1559
|
+
* TanStack Query options factory for ERC-165 confidential interface check.
|
|
1560
|
+
*
|
|
1561
|
+
* @param token - A `ReadonlyToken` instance.
|
|
1562
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1563
|
+
*/
|
|
1564
|
+
declare function isConfidentialQueryOptions(token: ReadonlyToken): {
|
|
1565
|
+
readonly queryKey: readonly ["isConfidential", string];
|
|
1566
|
+
readonly queryFn: () => Promise<boolean>;
|
|
1567
|
+
readonly staleTime: number;
|
|
1568
|
+
};
|
|
1569
|
+
/**
|
|
1570
|
+
* TanStack Query options factory for ERC-165 wrapper interface check.
|
|
1571
|
+
*
|
|
1572
|
+
* @param token - A `ReadonlyToken` instance.
|
|
1573
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1574
|
+
*/
|
|
1575
|
+
declare function isWrapperQueryOptions(token: ReadonlyToken): {
|
|
1576
|
+
readonly queryKey: readonly ["isWrapper", string];
|
|
1577
|
+
readonly queryFn: () => Promise<boolean>;
|
|
1578
|
+
readonly staleTime: number;
|
|
1579
|
+
};
|
|
1580
|
+
/**
|
|
1581
|
+
* Check if a token supports the ERC-7984 confidential interface via ERC-165.
|
|
1582
|
+
* Result is cached indefinitely since interface support does not change.
|
|
1583
|
+
*
|
|
1584
|
+
* @param tokenAddress - Address of the token contract to check.
|
|
1585
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1586
|
+
* @returns Query result with `data: boolean`.
|
|
1587
|
+
*
|
|
1588
|
+
* @example
|
|
1589
|
+
* ```tsx
|
|
1590
|
+
* const { data: isConfidential } = useIsConfidential("0xToken");
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1593
|
+
declare function useIsConfidential(tokenAddress: Address, options?: Omit<UseQueryOptions<boolean, Error>, "queryKey" | "queryFn">): UseQueryResult<boolean, Error>;
|
|
1594
|
+
/**
|
|
1595
|
+
* Suspense variant of {@link useIsConfidential}.
|
|
1596
|
+
* Suspends rendering until the ERC-165 check resolves.
|
|
1597
|
+
*
|
|
1598
|
+
* @param tokenAddress - Address of the token contract to check.
|
|
1599
|
+
* @returns Suspense query result with `data: boolean`.
|
|
1600
|
+
*
|
|
1601
|
+
* @example
|
|
1602
|
+
* ```tsx
|
|
1603
|
+
* const { data: isConfidential } = useIsConfidentialSuspense("0xToken");
|
|
1604
|
+
* ```
|
|
1605
|
+
*/
|
|
1606
|
+
declare function useIsConfidentialSuspense(tokenAddress: Address): UseSuspenseQueryResult<boolean, Error>;
|
|
1607
|
+
/**
|
|
1608
|
+
* Check if a token supports the ERC-7984 wrapper interface via ERC-165.
|
|
1609
|
+
* Result is cached indefinitely since interface support does not change.
|
|
1610
|
+
*
|
|
1611
|
+
* @param tokenAddress - Address of the token contract to check.
|
|
1612
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1613
|
+
* @returns Query result with `data: boolean`.
|
|
1614
|
+
*
|
|
1615
|
+
* @example
|
|
1616
|
+
* ```tsx
|
|
1617
|
+
* const { data: isWrapper } = useIsWrapper("0xToken");
|
|
1618
|
+
* ```
|
|
1619
|
+
*/
|
|
1620
|
+
declare function useIsWrapper(tokenAddress: Address, options?: Omit<UseQueryOptions<boolean, Error>, "queryKey" | "queryFn">): UseQueryResult<boolean, Error>;
|
|
1621
|
+
/**
|
|
1622
|
+
* Suspense variant of {@link useIsWrapper}.
|
|
1623
|
+
* Suspends rendering until the ERC-165 check resolves.
|
|
1624
|
+
*
|
|
1625
|
+
* @param tokenAddress - Address of the token contract to check.
|
|
1626
|
+
* @returns Suspense query result with `data: boolean`.
|
|
1627
|
+
*
|
|
1628
|
+
* @example
|
|
1629
|
+
* ```tsx
|
|
1630
|
+
* const { data: isWrapper } = useIsWrapperSuspense("0xToken");
|
|
1631
|
+
* ```
|
|
1632
|
+
*/
|
|
1633
|
+
declare function useIsWrapperSuspense(tokenAddress: Address): UseSuspenseQueryResult<boolean, Error>;
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* Query key factory for total supply queries.
|
|
1637
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1638
|
+
*/
|
|
1639
|
+
declare const totalSupplyQueryKeys: {
|
|
1640
|
+
/** Match all total supply queries. */
|
|
1641
|
+
readonly all: readonly ["totalSupply"];
|
|
1642
|
+
/** Match total supply query for a specific token. */
|
|
1643
|
+
readonly token: (tokenAddress: string) => readonly ["totalSupply", string];
|
|
1644
|
+
};
|
|
1645
|
+
/**
|
|
1646
|
+
* TanStack Query options factory for total supply.
|
|
1647
|
+
*
|
|
1648
|
+
* @param token - A `ReadonlyToken` instance.
|
|
1649
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1650
|
+
*/
|
|
1651
|
+
declare function totalSupplyQueryOptions(token: ReadonlyToken): {
|
|
1652
|
+
readonly queryKey: readonly ["totalSupply", string];
|
|
1653
|
+
readonly queryFn: () => Promise<bigint>;
|
|
1654
|
+
readonly staleTime: 30000;
|
|
1655
|
+
};
|
|
1656
|
+
/**
|
|
1657
|
+
* Read the total supply of a token.
|
|
1658
|
+
* Stale after 30 seconds to balance freshness and RPC cost.
|
|
1659
|
+
*
|
|
1660
|
+
* @param tokenAddress - Address of the token contract.
|
|
1661
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1662
|
+
* @returns Query result with `data: bigint`.
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* ```tsx
|
|
1666
|
+
* const { data: totalSupply } = useTotalSupply("0xToken");
|
|
1667
|
+
* ```
|
|
1668
|
+
*/
|
|
1669
|
+
declare function useTotalSupply(tokenAddress: Address, options?: Omit<UseQueryOptions<bigint, Error>, "queryKey" | "queryFn">): UseQueryResult<bigint, Error>;
|
|
1670
|
+
/**
|
|
1671
|
+
* Suspense variant of {@link useTotalSupply}.
|
|
1672
|
+
* Suspends rendering until the total supply is loaded.
|
|
1673
|
+
*
|
|
1674
|
+
* @param tokenAddress - Address of the token contract.
|
|
1675
|
+
* @returns Suspense query result with `data: bigint`.
|
|
1676
|
+
*
|
|
1677
|
+
* @example
|
|
1678
|
+
* ```tsx
|
|
1679
|
+
* const { data: totalSupply } = useTotalSupplySuspense("0xToken");
|
|
1680
|
+
* ```
|
|
1681
|
+
*/
|
|
1682
|
+
declare function useTotalSupplySuspense(tokenAddress: Address): UseSuspenseQueryResult<bigint, Error>;
|
|
1683
|
+
|
|
1684
|
+
/**
|
|
1685
|
+
* Query key factory for fee-related queries.
|
|
1686
|
+
* Use with `queryClient.invalidateQueries()` / `resetQueries()`.
|
|
1687
|
+
*/
|
|
1688
|
+
declare const feeQueryKeys: {
|
|
1689
|
+
/** Match wrap fee query for given parameters. */
|
|
1690
|
+
readonly wrapFee: (feeManagerAddress: string, amount?: string, from?: string, to?: string) => readonly ["wrapFee", string, ...(string | undefined)[]];
|
|
1691
|
+
/** Match unwrap fee query for given parameters. */
|
|
1692
|
+
readonly unwrapFee: (feeManagerAddress: string, amount?: string, from?: string, to?: string) => readonly ["unwrapFee", string, ...(string | undefined)[]];
|
|
1693
|
+
/** Match batch transfer fee query for a specific fee manager. */
|
|
1694
|
+
readonly batchTransferFee: (feeManagerAddress: string) => readonly ["batchTransferFee", string];
|
|
1695
|
+
/** Match fee recipient query for a specific fee manager. */
|
|
1696
|
+
readonly feeRecipient: (feeManagerAddress: string) => readonly ["feeRecipient", string];
|
|
1697
|
+
};
|
|
1698
|
+
/** Configuration for {@link useWrapFee} and {@link useUnwrapFee}. */
|
|
1699
|
+
interface UseFeeConfig {
|
|
1700
|
+
/** Address of the fee manager contract. */
|
|
1701
|
+
feeManagerAddress: Address;
|
|
1702
|
+
/** Amount to calculate the fee for. */
|
|
1703
|
+
amount: bigint;
|
|
1704
|
+
/** Sender address. */
|
|
1705
|
+
from: Address;
|
|
1706
|
+
/** Receiver address. */
|
|
1707
|
+
to: Address;
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* TanStack Query options factory for wrap fee.
|
|
1711
|
+
*
|
|
1712
|
+
* @param signer - A `GenericSigner` instance.
|
|
1713
|
+
* @param config - {@link UseFeeConfig} with fee manager address, amount, from, and to.
|
|
1714
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1715
|
+
*/
|
|
1716
|
+
declare function wrapFeeQueryOptions(signer: GenericSigner, config: UseFeeConfig): {
|
|
1717
|
+
readonly queryKey: readonly ["wrapFee", string, ...(string | undefined)[]];
|
|
1718
|
+
readonly queryFn: () => Promise<bigint>;
|
|
1719
|
+
readonly staleTime: 30000;
|
|
1720
|
+
};
|
|
1721
|
+
/**
|
|
1722
|
+
* TanStack Query options factory for unwrap fee.
|
|
1723
|
+
*
|
|
1724
|
+
* @param signer - A `GenericSigner` instance.
|
|
1725
|
+
* @param config - Fee manager address, amount, from, and to.
|
|
1726
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1727
|
+
*/
|
|
1728
|
+
declare function unwrapFeeQueryOptions(signer: GenericSigner, config: UseFeeConfig): {
|
|
1729
|
+
readonly queryKey: readonly ["unwrapFee", string, ...(string | undefined)[]];
|
|
1730
|
+
readonly queryFn: () => Promise<bigint>;
|
|
1731
|
+
readonly staleTime: 30000;
|
|
1732
|
+
};
|
|
1733
|
+
/**
|
|
1734
|
+
* TanStack Query options factory for batch transfer fee.
|
|
1735
|
+
*
|
|
1736
|
+
* @param signer - A `GenericSigner` instance.
|
|
1737
|
+
* @param feeManagerAddress - Address of the fee manager contract.
|
|
1738
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1739
|
+
*/
|
|
1740
|
+
declare function batchTransferFeeQueryOptions(signer: GenericSigner, feeManagerAddress: Address): {
|
|
1741
|
+
readonly queryKey: readonly ["batchTransferFee", string];
|
|
1742
|
+
readonly queryFn: () => Promise<bigint>;
|
|
1743
|
+
readonly staleTime: 30000;
|
|
1744
|
+
};
|
|
1745
|
+
/**
|
|
1746
|
+
* TanStack Query options factory for fee recipient.
|
|
1747
|
+
*
|
|
1748
|
+
* @param signer - A `GenericSigner` instance.
|
|
1749
|
+
* @param feeManagerAddress - Address of the fee manager contract.
|
|
1750
|
+
* @returns Query options with `queryKey`, `queryFn`, and `staleTime`.
|
|
1751
|
+
*/
|
|
1752
|
+
declare function feeRecipientQueryOptions(signer: GenericSigner, feeManagerAddress: Address): {
|
|
1753
|
+
readonly queryKey: readonly ["feeRecipient", string];
|
|
1754
|
+
readonly queryFn: () => Promise<`0x${string}`>;
|
|
1755
|
+
readonly staleTime: 30000;
|
|
1756
|
+
};
|
|
1757
|
+
/**
|
|
1758
|
+
* Read the wrap fee for a given amount and address pair.
|
|
1759
|
+
*
|
|
1760
|
+
* @param config - Fee manager address, amount, from, and to.
|
|
1761
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1762
|
+
* @returns Query result with `data: bigint` (the fee amount).
|
|
1763
|
+
*
|
|
1764
|
+
* @example
|
|
1765
|
+
* ```tsx
|
|
1766
|
+
* const { data: fee } = useWrapFee({
|
|
1767
|
+
* feeManagerAddress: "0xFeeManager",
|
|
1768
|
+
* amount: 1000n,
|
|
1769
|
+
* from: "0xSender",
|
|
1770
|
+
* to: "0xReceiver",
|
|
1771
|
+
* });
|
|
1772
|
+
* ```
|
|
1773
|
+
*/
|
|
1774
|
+
declare function useWrapFee(config: UseFeeConfig, options?: Omit<UseQueryOptions<bigint, Error>, "queryKey" | "queryFn">): UseQueryResult<bigint, Error>;
|
|
1775
|
+
/**
|
|
1776
|
+
* Read the unwrap fee for a given amount and address pair.
|
|
1777
|
+
*
|
|
1778
|
+
* @param config - Fee manager address, amount, from, and to.
|
|
1779
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1780
|
+
* @returns Query result with `data: bigint` (the fee amount).
|
|
1781
|
+
*
|
|
1782
|
+
* @example
|
|
1783
|
+
* ```tsx
|
|
1784
|
+
* const { data: fee } = useUnwrapFee({
|
|
1785
|
+
* feeManagerAddress: "0xFeeManager",
|
|
1786
|
+
* amount: 1000n,
|
|
1787
|
+
* from: "0xSender",
|
|
1788
|
+
* to: "0xReceiver",
|
|
1789
|
+
* });
|
|
1790
|
+
* ```
|
|
1791
|
+
*/
|
|
1792
|
+
declare function useUnwrapFee(config: UseFeeConfig, options?: Omit<UseQueryOptions<bigint, Error>, "queryKey" | "queryFn">): UseQueryResult<bigint, Error>;
|
|
1793
|
+
/**
|
|
1794
|
+
* Read the batch transfer fee from the fee manager.
|
|
1795
|
+
*
|
|
1796
|
+
* @param feeManagerAddress - Address of the fee manager contract.
|
|
1797
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1798
|
+
* @returns Query result with `data: bigint` (the fee amount).
|
|
1799
|
+
*
|
|
1800
|
+
* @example
|
|
1801
|
+
* ```tsx
|
|
1802
|
+
* const { data: fee } = useBatchTransferFee("0xFeeManager");
|
|
1803
|
+
* ```
|
|
1804
|
+
*/
|
|
1805
|
+
declare function useBatchTransferFee(feeManagerAddress: Address, options?: Omit<UseQueryOptions<bigint, Error>, "queryKey" | "queryFn">): UseQueryResult<bigint, Error>;
|
|
1806
|
+
/**
|
|
1807
|
+
* Read the fee recipient address from the fee manager.
|
|
1808
|
+
*
|
|
1809
|
+
* @param feeManagerAddress - Address of the fee manager contract.
|
|
1810
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1811
|
+
* @returns Query result with `data: Address` (the fee recipient).
|
|
1812
|
+
*
|
|
1813
|
+
* @example
|
|
1814
|
+
* ```tsx
|
|
1815
|
+
* const { data: recipient } = useFeeRecipient("0xFeeManager");
|
|
1816
|
+
* ```
|
|
1817
|
+
*/
|
|
1818
|
+
declare function useFeeRecipient(feeManagerAddress: Address, options?: Omit<UseQueryOptions<Address, Error>, "queryKey" | "queryFn">): UseQueryResult<Address, Error>;
|
|
1819
|
+
|
|
1820
|
+
export { type ApproveUnderlyingParams, type ConfidentialApproveParams, type ConfidentialTransferFromParams, type ConfidentialTransferParams, type CreateDelegatedUserDecryptEIP712Params, type CreateEIP712Params, type FinalizeUnwrapParams, type PublicKeyData, type PublicParamsData, type TokenMetadata, TokenSDKProvider, type UnshieldParams, type UnwrapParams, type UseActivityFeedConfig, type UseConfidentialBalanceConfig, type UseConfidentialBalanceOptions, type UseConfidentialBalancesConfig, type UseConfidentialBalancesOptions, type UseConfidentialIsApprovedConfig, type UseConfidentialIsApprovedSuspenseConfig, type UseConfidentialTransferConfig, type UseFeeConfig, type UseTokenConfig, type UseUnderlyingAllowanceConfig, type UseWrapConfig, type UseWrapperDiscoveryConfig, type UseWrapperDiscoverySuspenseConfig, type WrapETHParams, type WrapParams, activityFeedQueryKeys, approveUnderlyingMutationOptions, authorizeAllMutationOptions, batchTransferFeeQueryOptions, confidentialApproveMutationOptions, confidentialBalanceQueryKeys, confidentialBalancesQueryKeys, confidentialHandleQueryKeys, confidentialHandlesQueryKeys, confidentialIsApprovedQueryKeys, confidentialIsApprovedQueryOptions, confidentialTransferFromMutationOptions, confidentialTransferMutationOptions, decryptionKeys, encryptMutationOptions, feeQueryKeys, feeRecipientQueryOptions, finalizeUnwrapMutationOptions, isConfidentialQueryKeys, isConfidentialQueryOptions, isWrapperQueryKeys, isWrapperQueryOptions, publicKeyQueryKeys, publicKeyQueryOptions, publicParamsQueryKeys, publicParamsQueryOptions, tokenMetadataQueryKeys, tokenMetadataQueryOptions, totalSupplyQueryKeys, totalSupplyQueryOptions, underlyingAllowanceQueryKeys, underlyingAllowanceQueryOptions, unshieldAllMutationOptions, unshieldMutationOptions, unwrapAllMutationOptions, unwrapFeeQueryOptions, unwrapMutationOptions, useActivityFeed, useApproveUnderlying, useAuthorizeAll, useBatchTransferFee, useConfidentialApprove, useConfidentialBalance, useConfidentialBalances, useConfidentialIsApproved, useConfidentialIsApprovedSuspense, useConfidentialTransfer, useConfidentialTransferFrom, useCreateDelegatedUserDecryptEIP712, useCreateEIP712, useDelegatedUserDecrypt, useEncrypt, useFeeRecipient, useFinalizeUnwrap, useGenerateKeypair, useIsConfidential, useIsConfidentialSuspense, useIsWrapper, useIsWrapperSuspense, usePublicDecrypt, usePublicKey, usePublicParams, useReadonlyToken, useRequestZKProofVerification, useWrap as useShield, useWrapETH as useShieldETH, useToken, useTokenMetadata, useTokenMetadataSuspense, useTokenSDK, useTotalSupply, useTotalSupplySuspense, useUnderlyingAllowance, useUnderlyingAllowanceSuspense, useUnshield, useUnshieldAll, useUnwrap, useUnwrapAll, useUnwrapFee, useUserDecrypt, useUserDecryptedValue, useUserDecryptedValues, useWrap, useWrapETH, useWrapFee, useWrapperDiscovery, useWrapperDiscoverySuspense, wrapETHMutationOptions, wrapFeeQueryOptions, wrapMutationOptions, wrapperDiscoveryQueryKeys, wrapperDiscoveryQueryOptions };
|