@zama-fhe/react-sdk 2.2.0-alpha.8 → 2.2.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/dist/index.d.ts +27 -27
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -308,7 +308,7 @@ declare function useUserDecryptedValues(handles: Handle$1[]): {
|
|
|
308
308
|
results: _tanstack_react_query0.UseQueryResult<never, Error>[];
|
|
309
309
|
};
|
|
310
310
|
//#endregion
|
|
311
|
-
//#region src/
|
|
311
|
+
//#region src/authorization/use-allow.d.ts
|
|
312
312
|
/**
|
|
313
313
|
* Sign an EIP-712 message authorizing decryption of confidential handles
|
|
314
314
|
* for a list of contract addresses. This is not token-specific — any
|
|
@@ -331,7 +331,7 @@ declare function useUserDecryptedValues(handles: Handle$1[]): {
|
|
|
331
331
|
*/
|
|
332
332
|
declare function useAllow(options?: UseMutationOptions<void, Error, Address$1[]>): _tanstack_react_query0.UseMutationResult<void, Error, `0x${string}`[], unknown>;
|
|
333
333
|
//#endregion
|
|
334
|
-
//#region src/
|
|
334
|
+
//#region src/authorization/use-is-allowed.d.ts
|
|
335
335
|
/**
|
|
336
336
|
* Check whether a session signature is cached for the connected wallet.
|
|
337
337
|
* Returns `true` if decrypt operations can proceed without a wallet prompt.
|
|
@@ -343,7 +343,7 @@ declare function useAllow(options?: UseMutationOptions<void, Error, Address$1[]>
|
|
|
343
343
|
*/
|
|
344
344
|
declare function useIsAllowed(): _tanstack_react_query0.UseQueryResult<boolean, Error>;
|
|
345
345
|
//#endregion
|
|
346
|
-
//#region src/
|
|
346
|
+
//#region src/authorization/use-revoke.d.ts
|
|
347
347
|
/**
|
|
348
348
|
* Revoke stored FHE decrypt credentials for a list of contract addresses.
|
|
349
349
|
* This is not token-specific — it revokes the EIP-712 authorization for
|
|
@@ -360,7 +360,7 @@ declare function useIsAllowed(): _tanstack_react_query0.UseQueryResult<boolean,
|
|
|
360
360
|
*/
|
|
361
361
|
declare function useRevoke(options?: UseMutationOptions<void, Error, Address$1[]>): _tanstack_react_query0.UseMutationResult<void, Error, `0x${string}`[], unknown>;
|
|
362
362
|
//#endregion
|
|
363
|
-
//#region src/
|
|
363
|
+
//#region src/authorization/use-revoke-session.d.ts
|
|
364
364
|
/**
|
|
365
365
|
* Revoke the session signature for the connected wallet without
|
|
366
366
|
* specifying contract addresses. Useful for wallet disconnect handlers.
|
|
@@ -412,7 +412,7 @@ declare function useToken(config: UseZamaConfig): _zama_fhe_sdk0.Token;
|
|
|
412
412
|
*/
|
|
413
413
|
declare function useReadonlyToken(address: Address$1): _zama_fhe_sdk0.ReadonlyToken;
|
|
414
414
|
//#endregion
|
|
415
|
-
//#region src/
|
|
415
|
+
//#region src/balance/use-confidential-balance.d.ts
|
|
416
416
|
/** Configuration for {@link useConfidentialBalance}. */
|
|
417
417
|
interface UseConfidentialBalanceConfig {
|
|
418
418
|
/** Address of the confidential token contract. */
|
|
@@ -611,7 +611,7 @@ declare function useConfidentialBalance(config: UseConfidentialBalanceConfig, op
|
|
|
611
611
|
promise: Promise<bigint>;
|
|
612
612
|
};
|
|
613
613
|
//#endregion
|
|
614
|
-
//#region src/
|
|
614
|
+
//#region src/balance/use-confidential-balances.d.ts
|
|
615
615
|
/** Configuration for {@link useConfidentialBalances}. */
|
|
616
616
|
interface UseConfidentialBalancesConfig {
|
|
617
617
|
/** Addresses of the confidential token contracts to batch-query. */
|
|
@@ -819,7 +819,7 @@ declare function useConfidentialBalances(config: UseConfidentialBalancesConfig,
|
|
|
819
819
|
promise: Promise<ConfidentialBalancesData$1>;
|
|
820
820
|
};
|
|
821
821
|
//#endregion
|
|
822
|
-
//#region src/
|
|
822
|
+
//#region src/transfer/use-confidential-transfer.d.ts
|
|
823
823
|
/** Configuration for {@link useConfidentialTransfer}. */
|
|
824
824
|
interface UseConfidentialTransferConfig extends UseZamaConfig {
|
|
825
825
|
/**
|
|
@@ -861,7 +861,7 @@ interface UseConfidentialTransferConfig extends UseZamaConfig {
|
|
|
861
861
|
*/
|
|
862
862
|
declare function useConfidentialTransfer<TContext = unknown>(config: UseConfidentialTransferConfig, options?: UseMutationOptions<TransactionResult$1, Error, ConfidentialTransferParams$1, TContext>): UseMutationResult<TransactionResult$1, Error, ConfidentialTransferParams$1, TContext>;
|
|
863
863
|
//#endregion
|
|
864
|
-
//#region src/
|
|
864
|
+
//#region src/transfer/use-confidential-transfer-from.d.ts
|
|
865
865
|
/**
|
|
866
866
|
* Operator transfer on behalf of another address. Caller must be an approved operator.
|
|
867
867
|
* Invalidates balance caches on success.
|
|
@@ -882,7 +882,7 @@ declare function useConfidentialTransfer<TContext = unknown>(config: UseConfiden
|
|
|
882
882
|
*/
|
|
883
883
|
declare function useConfidentialTransferFrom(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, ConfidentialTransferFromParams$1, Address$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, ConfidentialTransferFromParams$1, `0x${string}`>;
|
|
884
884
|
//#endregion
|
|
885
|
-
//#region src/
|
|
885
|
+
//#region src/transfer/use-confidential-approve.d.ts
|
|
886
886
|
/**
|
|
887
887
|
* Set operator approval for a confidential token. Defaults to 1 hour.
|
|
888
888
|
*
|
|
@@ -901,7 +901,7 @@ declare function useConfidentialTransferFrom(config: UseZamaConfig, options?: Us
|
|
|
901
901
|
*/
|
|
902
902
|
declare function useConfidentialApprove(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, ConfidentialApproveParams$1, Address$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, ConfidentialApproveParams$1, `0x${string}`>;
|
|
903
903
|
//#endregion
|
|
904
|
-
//#region src/
|
|
904
|
+
//#region src/transfer/use-confidential-is-approved.d.ts
|
|
905
905
|
/** Configuration for {@link useConfidentialIsApproved}. */
|
|
906
906
|
interface UseConfidentialIsApprovedConfig {
|
|
907
907
|
/** Address of the confidential token contract. Pass `undefined` to disable the query. */
|
|
@@ -953,7 +953,7 @@ declare function useConfidentialIsApproved(config: UseConfidentialIsApprovedConf
|
|
|
953
953
|
*/
|
|
954
954
|
declare function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig): _tanstack_react_query0.UseSuspenseQueryResult<boolean, Error>;
|
|
955
955
|
//#endregion
|
|
956
|
-
//#region src/
|
|
956
|
+
//#region src/shield/use-shield.d.ts
|
|
957
957
|
/** Configuration for {@link useShield}. */
|
|
958
958
|
interface UseShieldConfig extends UseZamaConfig {
|
|
959
959
|
/**
|
|
@@ -984,7 +984,7 @@ interface UseShieldConfig extends UseZamaConfig {
|
|
|
984
984
|
*/
|
|
985
985
|
declare function useShield<TContext = unknown>(config: UseShieldConfig, options?: UseMutationOptions<TransactionResult$1, Error, ShieldParams$1, TContext>): UseMutationResult<TransactionResult$1, Error, ShieldParams$1, TContext>;
|
|
986
986
|
//#endregion
|
|
987
|
-
//#region src/
|
|
987
|
+
//#region src/shield/use-shield-eth.d.ts
|
|
988
988
|
/** Configuration for {@link useShieldETH}. */
|
|
989
989
|
interface UseShieldETHConfig extends UseZamaConfig {
|
|
990
990
|
/**
|
|
@@ -1014,7 +1014,7 @@ interface UseShieldETHConfig extends UseZamaConfig {
|
|
|
1014
1014
|
*/
|
|
1015
1015
|
declare function useShieldETH<TContext = unknown>(config: UseShieldETHConfig, options?: UseMutationOptions<TransactionResult$1, Error, ShieldETHParams$1, TContext>): UseMutationResult<TransactionResult$1, Error, ShieldETHParams$1, TContext>;
|
|
1016
1016
|
//#endregion
|
|
1017
|
-
//#region src/
|
|
1017
|
+
//#region src/unwrap/use-unwrap.d.ts
|
|
1018
1018
|
/**
|
|
1019
1019
|
* Request an unwrap for a specific amount. Encrypts the amount first.
|
|
1020
1020
|
* Call {@link useFinalizeUnwrap} after the request is processed on-chain,
|
|
@@ -1036,7 +1036,7 @@ declare function useShieldETH<TContext = unknown>(config: UseShieldETHConfig, op
|
|
|
1036
1036
|
*/
|
|
1037
1037
|
declare function useUnwrap(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, UnwrapParams$1, Address$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, UnwrapParams$1, `0x${string}`>;
|
|
1038
1038
|
//#endregion
|
|
1039
|
-
//#region src/
|
|
1039
|
+
//#region src/unwrap/use-unwrap-all.d.ts
|
|
1040
1040
|
/**
|
|
1041
1041
|
* Request an unwrap for the entire confidential balance.
|
|
1042
1042
|
* Uses the on-chain balance handle directly (no encryption needed).
|
|
@@ -1057,7 +1057,7 @@ declare function useUnwrap(config: UseZamaConfig, options?: UseMutationOptions<T
|
|
|
1057
1057
|
*/
|
|
1058
1058
|
declare function useUnwrapAll(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, void, Address$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, void, `0x${string}`>;
|
|
1059
1059
|
//#endregion
|
|
1060
|
-
//#region src/
|
|
1060
|
+
//#region src/unwrap/use-finalize-unwrap.d.ts
|
|
1061
1061
|
/**
|
|
1062
1062
|
* Complete an unwrap by providing the public decryption proof.
|
|
1063
1063
|
* Call this after an unwrap request has been processed on-chain.
|
|
@@ -1078,7 +1078,7 @@ declare function useUnwrapAll(config: UseZamaConfig, options?: UseMutationOption
|
|
|
1078
1078
|
*/
|
|
1079
1079
|
declare function useFinalizeUnwrap(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, FinalizeUnwrapParams$1, Address$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, FinalizeUnwrapParams$1, `0x${string}`>;
|
|
1080
1080
|
//#endregion
|
|
1081
|
-
//#region src/
|
|
1081
|
+
//#region src/unshield/use-unshield.d.ts
|
|
1082
1082
|
/**
|
|
1083
1083
|
* Unshield a specific amount and finalize in one call.
|
|
1084
1084
|
* Orchestrates: unwrap → wait for receipt → parse event → finalize.
|
|
@@ -1100,7 +1100,7 @@ declare function useFinalizeUnwrap(config: UseZamaConfig, options?: UseMutationO
|
|
|
1100
1100
|
*/
|
|
1101
1101
|
declare function useUnshield(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, UnshieldParams$1, Address$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, UnshieldParams$1, `0x${string}`>;
|
|
1102
1102
|
//#endregion
|
|
1103
|
-
//#region src/
|
|
1103
|
+
//#region src/unshield/use-unshield-all.d.ts
|
|
1104
1104
|
/**
|
|
1105
1105
|
* Unshield the entire balance and finalize in one call.
|
|
1106
1106
|
* Orchestrates: unwrapAll → wait for receipt → parse event → finalize.
|
|
@@ -1121,7 +1121,7 @@ declare function useUnshield(config: UseZamaConfig, options?: UseMutationOptions
|
|
|
1121
1121
|
*/
|
|
1122
1122
|
declare function useUnshieldAll(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, UnshieldAllParams$1 | void, Address$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, void | UnshieldAllParams$1, `0x${string}`>;
|
|
1123
1123
|
//#endregion
|
|
1124
|
-
//#region src/
|
|
1124
|
+
//#region src/unshield/use-resume-unshield.d.ts
|
|
1125
1125
|
/**
|
|
1126
1126
|
* Resume an interrupted unshield from an existing unwrap tx hash.
|
|
1127
1127
|
* Useful when the user submitted the unwrap but the finalize step was
|
|
@@ -1142,7 +1142,7 @@ declare function useUnshieldAll(config: UseZamaConfig, options?: UseMutationOpti
|
|
|
1142
1142
|
*/
|
|
1143
1143
|
declare function useResumeUnshield(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, ResumeUnshieldParams$1, Address$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, ResumeUnshieldParams$1, `0x${string}`>;
|
|
1144
1144
|
//#endregion
|
|
1145
|
-
//#region src/
|
|
1145
|
+
//#region src/shield/use-underlying-allowance.d.ts
|
|
1146
1146
|
/** Configuration for {@link useUnderlyingAllowance}. */
|
|
1147
1147
|
interface UseUnderlyingAllowanceConfig {
|
|
1148
1148
|
/** Address of the confidential token contract used to scope the query cache. */
|
|
@@ -1272,7 +1272,7 @@ declare function useMetadata(tokenAddress: Address$1, options?: Omit<UseQueryOpt
|
|
|
1272
1272
|
*/
|
|
1273
1273
|
declare function useMetadataSuspense(tokenAddress: Address$1): _tanstack_react_query0.UseSuspenseQueryResult<TokenMetadata, Error>;
|
|
1274
1274
|
//#endregion
|
|
1275
|
-
//#region src/
|
|
1275
|
+
//#region src/balance/use-activity-feed.d.ts
|
|
1276
1276
|
/** Configuration for {@link useActivityFeed}. */
|
|
1277
1277
|
interface UseActivityFeedConfig {
|
|
1278
1278
|
/** Address of the confidential token contract. */
|
|
@@ -1306,7 +1306,7 @@ interface UseActivityFeedConfig {
|
|
|
1306
1306
|
*/
|
|
1307
1307
|
declare function useActivityFeed(config: UseActivityFeedConfig): _tanstack_react_query0.UseQueryResult<ActivityItem$1[], Error>;
|
|
1308
1308
|
//#endregion
|
|
1309
|
-
//#region src/
|
|
1309
|
+
//#region src/delegation/use-delegate-decryption.d.ts
|
|
1310
1310
|
/**
|
|
1311
1311
|
* Delegate FHE decryption rights for a token to another address via the on-chain ACL.
|
|
1312
1312
|
*
|
|
@@ -1321,7 +1321,7 @@ declare function useActivityFeed(config: UseActivityFeedConfig): _tanstack_react
|
|
|
1321
1321
|
*/
|
|
1322
1322
|
declare function useDelegateDecryption(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, DelegateDecryptionParams$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, DelegateDecryptionParams$1, unknown>;
|
|
1323
1323
|
//#endregion
|
|
1324
|
-
//#region src/
|
|
1324
|
+
//#region src/delegation/use-revoke-delegation.d.ts
|
|
1325
1325
|
/**
|
|
1326
1326
|
* Revoke FHE decryption delegation for a token from a delegate address.
|
|
1327
1327
|
*
|
|
@@ -1336,7 +1336,7 @@ declare function useDelegateDecryption(config: UseZamaConfig, options?: UseMutat
|
|
|
1336
1336
|
*/
|
|
1337
1337
|
declare function useRevokeDelegation(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, RevokeDelegationParams$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, RevokeDelegationParams$1, unknown>;
|
|
1338
1338
|
//#endregion
|
|
1339
|
-
//#region src/
|
|
1339
|
+
//#region src/delegation/use-delegation-status.d.ts
|
|
1340
1340
|
interface UseDelegationStatusConfig {
|
|
1341
1341
|
/** Address of the confidential token contract. Pass `undefined` to disable the query. */
|
|
1342
1342
|
tokenAddress: Address$1 | undefined;
|
|
@@ -1364,7 +1364,7 @@ interface UseDelegationStatusConfig {
|
|
|
1364
1364
|
*/
|
|
1365
1365
|
declare function useDelegationStatus(config: UseDelegationStatusConfig, options?: Omit<UseQueryOptions<DelegationStatusData$1>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<DelegationStatusData$1, Error>;
|
|
1366
1366
|
//#endregion
|
|
1367
|
-
//#region src/
|
|
1367
|
+
//#region src/delegation/use-decrypt-balance-as.d.ts
|
|
1368
1368
|
/**
|
|
1369
1369
|
* Decrypt another user's confidential balance as a delegate.
|
|
1370
1370
|
*
|
|
@@ -1380,7 +1380,7 @@ declare function useDelegationStatus(config: UseDelegationStatusConfig, options?
|
|
|
1380
1380
|
*/
|
|
1381
1381
|
declare function useDecryptBalanceAs(tokenAddress: Address$1, options?: UseMutationOptions<bigint, Error, DecryptBalanceAsParams$1>): _tanstack_react_query0.UseMutationResult<bigint, Error, DecryptBalanceAsParams$1, unknown>;
|
|
1382
1382
|
//#endregion
|
|
1383
|
-
//#region src/
|
|
1383
|
+
//#region src/delegation/use-batch-decrypt-balances-as.d.ts
|
|
1384
1384
|
/**
|
|
1385
1385
|
* Batch decrypt confidential balances as a delegate across multiple tokens.
|
|
1386
1386
|
*
|
|
@@ -1398,7 +1398,7 @@ declare function useDecryptBalanceAs(tokenAddress: Address$1, options?: UseMutat
|
|
|
1398
1398
|
*/
|
|
1399
1399
|
declare function useBatchDecryptBalancesAs(tokens: ReadonlyToken$1[], options?: UseMutationOptions<Map<Address$1, bigint>, Error, BatchDecryptAsOptions$1>): _tanstack_react_query0.UseMutationResult<Map<`0x${string}`, bigint>, Error, BatchDecryptAsOptions$1, unknown>;
|
|
1400
1400
|
//#endregion
|
|
1401
|
-
//#region src/
|
|
1401
|
+
//#region src/shield/use-approve-underlying.d.ts
|
|
1402
1402
|
/**
|
|
1403
1403
|
* Approve the wrapper contract to spend the underlying ERC-20.
|
|
1404
1404
|
* Defaults to max uint256. Resets to zero first if there's an existing
|
|
@@ -1691,7 +1691,7 @@ declare function useListPairs({
|
|
|
1691
1691
|
metadata?: boolean;
|
|
1692
1692
|
}): _tanstack_react_query0.UseQueryResult<PaginatedResult$1<TokenWrapperPair$1 | TokenWrapperPairWithMetadata$1>, Error>;
|
|
1693
1693
|
//#endregion
|
|
1694
|
-
//#region src/
|
|
1694
|
+
//#region src/balance/optimistic-balance-update.d.ts
|
|
1695
1695
|
type OptimisticBalanceSnapshot = [QueryKey, bigint | undefined][];
|
|
1696
1696
|
/** Combined context returned by optimistic `onMutate`. */
|
|
1697
1697
|
interface OptimisticMutateContext {
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{ApprovalFailedError as e,ChromeSessionStorage as t,ConfigurationError as n,CredentialsManager as r,DecryptionFailedError as i,DefaultRegistryAddresses as a,DelegatedCredentialsManager as o,ERC7984_INTERFACE_ID as s,ERC7984_WRAPPER_INTERFACE_ID as c,EncryptionFailedError as l,HardhatConfig as u,IndexedDBStorage as d,InvalidKeypairError as f,KeypairExpiredError as p,MainnetConfig as m,MemoryStorage as ee,NoCiphertextError as te,ReadonlyToken as ne,ReadonlyToken as re,RelayerRequestFailedError as ie,RelayerWeb as ae,SepoliaConfig as oe,SigningFailedError as se,SigningRejectedError as ce,TOKEN_TOPICS as le,Token as ue,Topics as de,TransactionRevertedError as fe,WrappersRegistry as pe,ZERO_HANDLE as me,ZamaError as he,ZamaErrorCode as ge,ZamaSDK as _e,ZamaSDK as ve,ZamaSDKEvents as ye,allowanceContract as be,applyDecryptedValues as xe,approveContract as Se,balanceOfContract as Ce,chromeSessionStorage as we,clearPendingUnshield as Te,confidentialBalanceOfContract as Ee,confidentialBatchTransferContract as De,confidentialTotalSupplyContract as Oe,confidentialTransferContract as ke,confidentialTransferFromContract as Ae,decimalsContract as je,decodeConfidentialTransfer as h,decodeOnChainEvent as g,decodeOnChainEvents as _,decodeUnwrapRequested as v,decodeUnwrappedFinalized as y,decodeUnwrappedStarted as b,decodeWrapped as x,deploymentCoordinatorContract as S,extractEncryptedHandles as Me,finalizeUnwrapContract as Ne,findUnwrapRequested as Pe,findWrapped as Fe,getBatchTransferFeeContract as Ie,getFeeRecipientContract as Le,getUnwrapFeeContract as Re,getWrapFeeContract as ze,getWrapperContract as Be,indexedDBStorage as Ve,isConfidentialTokenContract as He,isConfidentialWrapperContract as Ue,isFinalizeUnwrapOperatorContract as We,isOperatorContract as Ge,loadPendingUnshield as Ke,matchZamaError as qe,memoryStorage as Je,nameContract as Ye,parseActivityFeed as Xe,rateContract as Ze,savePendingUnshield as Qe,setFinalizeUnwrapOperatorContract as $e,setOperatorContract as et,sortByBlockNumber as tt,supportsInterfaceContract as nt,symbolContract as rt,totalSupplyContract as it,underlyingContract as at,unwrapContract as ot,unwrapFromBalanceContract as st,wrapContract as ct,wrapETHContract as lt,wrapperExistsContract as ut}from"@zama-fhe/sdk";import{activityFeedQueryOptions as dt,activityFeedQueryOptions as ft,allowMutationOptions as pt,allowMutationOptions as mt,approveUnderlyingMutationOptions as ht,approveUnderlyingMutationOptions as gt,batchDecryptBalancesAsMutationOptions as _t,batchTransferFeeQueryOptions as vt,batchTransferFeeQueryOptions as yt,confidentialApproveMutationOptions as bt,confidentialApproveMutationOptions as xt,confidentialBalanceQueryOptions as St,confidentialBalanceQueryOptions as Ct,confidentialBalancesQueryOptions as wt,confidentialBalancesQueryOptions as Tt,confidentialHandleQueryOptions as Et,confidentialHandleQueryOptions as Dt,confidentialHandlesQueryOptions as Ot,confidentialHandlesQueryOptions as kt,confidentialIsApprovedQueryOptions as At,confidentialIsApprovedQueryOptions as C,confidentialTokenAddressQueryOptions as jt,confidentialTransferFromMutationOptions as Mt,confidentialTransferFromMutationOptions as Nt,confidentialTransferMutationOptions as Pt,confidentialTransferMutationOptions as Ft,createDelegatedUserDecryptEIP712MutationOptions as It,createDelegatedUserDecryptEIP712MutationOptions as Lt,createEIP712MutationOptions as Rt,createEIP712MutationOptions as zt,decryptBalanceAsMutationOptions as Bt,decryptBalanceAsMutationOptions as Vt,delegateDecryptionMutationOptions as Ht,delegateDecryptionMutationOptions as Ut,delegatedUserDecryptMutationOptions as Wt,delegatedUserDecryptMutationOptions as Gt,delegationStatusQueryOptions as Kt,delegationStatusQueryOptions as qt,deriveActivityFeedLogsKey as Jt,encryptMutationOptions as Yt,encryptMutationOptions as Xt,feeRecipientQueryOptions as Zt,feeRecipientQueryOptions as Qt,filterQueryOptions as $t,finalizeUnwrapMutationOptions as en,finalizeUnwrapMutationOptions as tn,generateKeypairMutationOptions as nn,generateKeypairMutationOptions as rn,hashFn as an,hashFn as w,invalidateAfterApprove as on,invalidateAfterApproveUnderlying as sn,invalidateAfterShield as cn,invalidateAfterTransfer as T,invalidateAfterUnshield as E,invalidateAfterUnwrap as D,invalidateWalletLifecycleQueries as O,isAllowedQueryOptions as ln,isAllowedQueryOptions as un,isConfidentialQueryOptions as dn,isConfidentialQueryOptions as k,isConfidentialTokenValidQueryOptions as fn,isWrapperQueryOptions as pn,isWrapperQueryOptions as A,listPairsQueryOptions as mn,listPairsQueryOptions as hn,publicDecryptMutationOptions as gn,publicDecryptMutationOptions as _n,publicKeyQueryOptions as vn,publicKeyQueryOptions as yn,publicParamsQueryOptions as bn,publicParamsQueryOptions as xn,requestZKProofVerificationMutationOptions as Sn,requestZKProofVerificationMutationOptions as Cn,resumeUnshieldMutationOptions as wn,resumeUnshieldMutationOptions as Tn,revokeDelegationMutationOptions as En,revokeDelegationMutationOptions as Dn,revokeMutationOptions as On,revokeMutationOptions as kn,revokeSessionMutationOptions as An,revokeSessionMutationOptions as jn,shieldETHMutationOptions as Mn,shieldETHMutationOptions as Nn,shieldFeeQueryOptions as j,shieldFeeQueryOptions as Pn,shieldMutationOptions as Fn,shieldMutationOptions as In,signerAddressQueryOptions as Ln,signerAddressQueryOptions as M,tokenAddressQueryOptions as Rn,tokenMetadataQueryOptions as zn,tokenMetadataQueryOptions as N,tokenPairQueryOptions as Bn,tokenPairsLengthQueryOptions as Vn,tokenPairsQueryOptions as Hn,tokenPairsSliceQueryOptions as Un,totalSupplyQueryOptions as Wn,totalSupplyQueryOptions as P,underlyingAllowanceQueryOptions as Gn,underlyingAllowanceQueryOptions as F,unshieldAllMutationOptions as Kn,unshieldAllMutationOptions as qn,unshieldFeeQueryOptions as Jn,unshieldFeeQueryOptions as Yn,unshieldMutationOptions as Xn,unshieldMutationOptions as Zn,unwrapAllMutationOptions as Qn,unwrapAllMutationOptions as $n,unwrapMutationOptions as er,unwrapMutationOptions as tr,userDecryptMutationOptions as nr,userDecryptMutationOptions as rr,wrapperDiscoveryQueryOptions as ir,wrapperDiscoveryQueryOptions as I,zamaQueryKeys as ar,zamaQueryKeys as L}from"@zama-fhe/sdk/query";import{skipToken as or,useMutation as R,useQueries as sr,useQuery as cr,useQueryClient as z,useSuspenseQuery as lr}from"@tanstack/react-query";import{createContext as ur,useContext as dr,useEffect as B,useMemo as V,useRef as H}from"react";import{jsx as fr}from"react/jsx-runtime";const U=ur(null);function pr({children:e,relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,registryAddresses:s,registryTTL:c,onEvent:l}){let u=z(),d=H(l),f=H(s);B(()=>{d.current=l,f.current=s});let p=V(()=>n?.subscribe?{onDisconnect:()=>O(u),onAccountChange:()=>O(u),onChainChange:()=>O(u)}:void 0,[u,n]),m=V(()=>new ve({relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,registryAddresses:f.current,registryTTL:c,onEvent:d.current,signerLifecycleCallbacks:p}),[t,n,r,i,a,o,c,p]);return B(()=>()=>m.dispose(),[m]),fr(U.Provider,{value:m,children:e})}function W(){let e=dr(U);if(!e)throw Error(`useZamaSDK must be used within a <ZamaProvider>. Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.`);return e}function mr(){return R(Xt(W()))}function hr(e){return R(rr(W(),e))}function gr(){return R(_n(W()))}function _r(){return R(rn(W()))}function vr(){return R(zt(W()))}function yr(){return R(Lt(W()))}function br(){return R(Gt(W()))}function xr(){return R(Cn(W()))}function G(e){return cr({...e,queryKeyHashFn:w})}function K(e){return lr({...e,queryKeyHashFn:w})}function Sr({queries:e,...t}){return sr({...t,queries:e.map(e=>({...e,queryKeyHashFn:w}))})}function Cr(){return G({...yn(W())})}function wr(e){return G({...xn(W(),e)})}function Tr(e){return G({queryKey:L.decryption.handle(e??`0x`),queryFn:()=>void 0,enabled:!1})}function Er(e){let t=Sr({queries:e.map(e=>({queryKey:L.decryption.handle(e),queryFn:()=>void 0,enabled:!1}))}),n={};for(let r=0;r<e.length;r++)n[e[r]]=t[r].data;return{data:n,results:t}}function Dr(e){return R({...mt(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}function Or(){let e=W(),t=G({...M(e.signer)}).data;return G(t?un(e,{account:t}):{queryKey:L.isAllowed.all,queryFn:or,enabled:!1})}function kr(e){return R({...kn(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}function Ar(e){return R({...jn(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}function q(e){let t=W();return V(()=>t.createToken(e.tokenAddress,e.wrapperAddress),[t,e.tokenAddress,e.wrapperAddress])}function J(e){let t=W();return V(()=>t.createReadonlyToken(e),[t,e])}function jr(e,t){let{tokenAddress:n,handleRefetchInterval:r}=e,{enabled:i=!0}=t??{},a=J(n),o=G({...M(a.signer)}).data,s=Dt(a.signer,n,{owner:o,pollingInterval:r}),c=G({...s,enabled:s.enabled&&i}),l=c.data,u=Ct(a,{handle:l,owner:o});return{...G({...u,...t,enabled:u.enabled&&i}),handleQuery:c}}function Mr(e,t){let{tokenAddresses:n,handleRefetchInterval:r,maxConcurrency:i}=e,{enabled:a=!0}=t??{},o=W(),s=G({...M(o.signer)}).data,c=V(()=>n.map(e=>o.createReadonlyToken(e)),[o,n]),l=kt(o.signer,n,{owner:s,pollingInterval:r}),u=G({...l,enabled:l.enabled&&a}),d=u.data,f=Array.isArray(d)&&d.length===n.length,p=Tt(c,{owner:s,handles:d,maxConcurrency:i,resultAddresses:n}),m=p.enabled??!0;return{...G({...p,...t,enabled:m&&f&&a}),handlesQuery:u}}function Y(e,t){let n=e?t:void 0;return{wrappedContext:n,callerContext:e?n?.callerContext:t}}async function X({queryClient:e,tokenAddress:t,amount:n,mode:r}){let i=L.confidentialBalance.token(t);await e.cancelQueries({queryKey:i});let a=e.getQueriesData({queryKey:i});for(let[t,i]of a)i!==void 0&&e.setQueryData(t,r===`add`?i+n:i-n);return a}function Z(e,t){for(let[n,r]of t)e.setQueryData(n,r)}function Q({optimistic:e,tokenAddress:t,queryClient:n,options:r}){return{onMutate:e?async(e,i)=>({snapshot:await X({queryClient:n,tokenAddress:t,amount:e.amount,mode:`add`}),callerContext:await r?.onMutate?.(e,i)}):r?.onMutate,onError:(t,i,a,o)=>{let{wrappedContext:s,callerContext:c}=Y(e,a);try{s&&Z(n,s.snapshot)}finally{r?.onError?.(t,i,c,o)}},onSuccess:(n,i,a,o)=>{let{callerContext:s}=Y(e,a);r?.onSuccess?.(n,i,s,o),cn(o.client,t)},onSettled:(t,n,i,a,o)=>{let{callerContext:s}=Y(e,a);r?.onSettled?.(t,n,i,s,o)}}}function Nr(e,t){let n=q(e),r=z();return R({...Ft(n),...t,onMutate:e.optimistic?async(n,i)=>({snapshot:await X({queryClient:r,tokenAddress:e.tokenAddress,amount:n.amount,mode:`subtract`}),callerContext:await t?.onMutate?.(n,i)}):t?.onMutate,onError:(n,i,a,o)=>{let{wrappedContext:s,callerContext:c}=Y(e.optimistic,a);try{s&&Z(r,s.snapshot)}finally{t?.onError?.(n,i,c,o)}},onSuccess:(n,r,i,a)=>{let{callerContext:o}=Y(e.optimistic,i);t?.onSuccess?.(n,r,o,a),T(a.client,e.tokenAddress)},onSettled:(n,r,i,a,o)=>{let{callerContext:s}=Y(e.optimistic,a);t?.onSettled?.(n,r,i,s,o)}})}function Pr(e,t){return R({...Nt(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),T(a.client,e.tokenAddress)}})}function Fr(e,t){return R({...xt(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),on(a.client,e.tokenAddress)}})}function Ir(e,t){let{tokenAddress:n,spender:r,holder:i}=e,a=W(),o=G({...M(a.signer),enabled:n!==void 0&&r!==void 0&&i===void 0}),s=i??o.data,c=C(a.signer,n,{holder:s,spender:r});return G({...c,...t,enabled:(c.enabled??!0)&&(t?.enabled??!0)})}function Lr(e){let{spender:t,holder:n,...r}=e,i=q(r),a=K({...M(i.signer)}),o=n??a.data;return K({...C(i.signer,i.address,{holder:o,spender:t})})}function Rr(e,t){let n=q(e),r=z();return R({...In(n),...t,...Q({optimistic:e.optimistic,tokenAddress:e.tokenAddress,queryClient:r,options:t})})}function zr(e,t){let n=q(e),r=z();return R({...Nn(n),...t,...Q({optimistic:e.optimistic,tokenAddress:e.tokenAddress,queryClient:r,options:t})})}function Br(e,t){return R({...tr(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function Vr(e,t){return R({...$n(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function Hr(e,t){return R({...tn(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Ur(e,t){return R({...Zn(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Wr(e,t){return R({...qn(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Gr(e,t){return R({...Tn(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Kr(e,t){let{tokenAddress:n,wrapperAddress:r}=e,i=J(n),a=G({...M(i.signer)}).data,o=F(i.signer,n,{owner:a,wrapperAddress:r});return G({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function qr(e){let{tokenAddress:t,wrapperAddress:n}=e,r=J(t),i=K({...M(r.signer)}).data;return K({...F(r.signer,t,{owner:i,wrapperAddress:n})})}function $(){let e=W(),{data:t}=G({queryKey:L.wrappersRegistry.chainId(),queryFn:()=>e.signer.getChainId(),staleTime:3e4});return t===void 0?void 0:e.registry.getAddress(t)}function Jr(e,t){let{tokenAddress:n,erc20Address:r}=e,i=W(),a=$(),o=I(i.registry,{tokenAddress:n,erc20Address:r,registryAddress:a});return G({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function Yr(e){let{tokenAddress:t,erc20Address:n}=e,r=W(),i=$();return K({...I(r.registry,{tokenAddress:t,erc20Address:n,registryAddress:i})})}function Xr(e,t){return G({...N(J(e).signer,e),...t})}function Zr(e){return K({...N(J(e).signer,e)})}function Qr(e){let{tokenAddress:t,userAddress:n,logs:r,decrypt:i}=e;return G({...ft(J(t),{userAddress:n,logs:r,decrypt:i??!0,logsKey:Jt(r)})})}function $r(e,t){return R({...Ut(q(e)),...t,onSuccess:(e,n,r,i)=>{try{t?.onSuccess?.(e,n,r,i)}finally{i.client.invalidateQueries({queryKey:L.delegationStatus.all})}}})}function ei(e,t){return R({...Dn(q(e)),...t,onSuccess:(e,n,r,i)=>{try{t?.onSuccess?.(e,n,r,i)}finally{i.client.invalidateQueries({queryKey:L.delegationStatus.all})}}})}function ti(e,t){let n=W(),r=qt(n.signer,n.relayer,e.tokenAddress,{delegatorAddress:e.delegatorAddress,delegateAddress:e.delegateAddress});return G({...r,...t,enabled:(r.enabled??!0)&&(t?.enabled??!0)})}function ni(e,t){return R({...Vt(J(e)),...t})}function ri(e,t){return R({mutationKey:[`zama.batchDecryptBalancesAs`,...e.map(e=>e.address)],mutationFn:async t=>re.batchDecryptBalancesAs(e,t),...t})}function ii(e,t){return R({...gt(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),sn(a.client,e.tokenAddress)}})}function ai(e,t){return G({...k(J(e).signer,e),...t})}function oi(e){return K({...k(J(e).signer,e)})}function si(e,t){return G({...A(J(e).signer,e),...t})}function ci(e){return K({...A(J(e).signer,e)})}function li(e,t){return G({...P(J(e).signer,e),...t})}function ui(e){return K({...P(J(e).signer,e)})}function di(e,t){let n=Pn(W().signer,e);return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function fi(e,t){let n=Yn(W().signer,e);return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function pi(e,t){let n=yt(W().signer,e);return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function mi(e,t){let n=Qt(W().signer,e);return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function hi(){let e=W(),t=$();return G(Hn(e.signer,{registryAddress:t}))}function gi(){let e=W(),t=$();return G(Vn(e.signer,{registryAddress:t}))}function _i({fromIndex:e,toIndex:t}){let n=W(),r=$();return G(Un(n.signer,{registryAddress:r,fromIndex:e,toIndex:t}))}function vi({index:e}){let t=W(),n=$();return G(Bn(t.signer,{registryAddress:n,index:e}))}function yi({tokenAddress:e}){let t=W(),n=$();return G(jt(t.signer,{registryAddress:n,tokenAddress:e}))}function bi({confidentialTokenAddress:e}){let t=W(),n=$();return G(Rn(t.signer,{registryAddress:n,confidentialTokenAddress:e}))}function xi({confidentialTokenAddress:e}){let t=W(),n=$();return G(fn(t.signer,{registryAddress:n,confidentialTokenAddress:e}))}function Si({page:e=1,pageSize:t=100,metadata:n=!1}={}){let r=W(),i=$();return G(hn(r.registry,{registryAddress:i,page:e,pageSize:t,metadata:n}))}export{e as ApprovalFailedError,t as ChromeSessionStorage,n as ConfigurationError,r as CredentialsManager,i as DecryptionFailedError,a as DefaultRegistryAddresses,o as DelegatedCredentialsManager,s as ERC7984_INTERFACE_ID,c as ERC7984_WRAPPER_INTERFACE_ID,l as EncryptionFailedError,u as HardhatConfig,d as IndexedDBStorage,f as InvalidKeypairError,p as KeypairExpiredError,m as MainnetConfig,ee as MemoryStorage,te as NoCiphertextError,ne as ReadonlyToken,ie as RelayerRequestFailedError,ae as RelayerWeb,oe as SepoliaConfig,se as SigningFailedError,ce as SigningRejectedError,le as TOKEN_TOPICS,ue as Token,de as Topics,fe as TransactionRevertedError,pe as WrappersRegistry,me as ZERO_HANDLE,he as ZamaError,ge as ZamaErrorCode,pr as ZamaProvider,_e as ZamaSDK,ye as ZamaSDKEvents,dt as activityFeedQueryOptions,pt as allowMutationOptions,be as allowanceContract,xe as applyDecryptedValues,Se as approveContract,ht as approveUnderlyingMutationOptions,Ce as balanceOfContract,_t as batchDecryptBalancesAsMutationOptions,vt as batchTransferFeeQueryOptions,we as chromeSessionStorage,Te as clearPendingUnshield,bt as confidentialApproveMutationOptions,Ee as confidentialBalanceOfContract,St as confidentialBalanceQueryOptions,wt as confidentialBalancesQueryOptions,De as confidentialBatchTransferContract,Et as confidentialHandleQueryOptions,Ot as confidentialHandlesQueryOptions,At as confidentialIsApprovedQueryOptions,Oe as confidentialTotalSupplyContract,ke as confidentialTransferContract,Ae as confidentialTransferFromContract,Mt as confidentialTransferFromMutationOptions,Pt as confidentialTransferMutationOptions,It as createDelegatedUserDecryptEIP712MutationOptions,Rt as createEIP712MutationOptions,je as decimalsContract,h as decodeConfidentialTransfer,g as decodeOnChainEvent,_ as decodeOnChainEvents,v as decodeUnwrapRequested,y as decodeUnwrappedFinalized,b as decodeUnwrappedStarted,x as decodeWrapped,Bt as decryptBalanceAsMutationOptions,Ht as delegateDecryptionMutationOptions,Wt as delegatedUserDecryptMutationOptions,Kt as delegationStatusQueryOptions,S as deploymentCoordinatorContract,Yt as encryptMutationOptions,Me as extractEncryptedHandles,Zt as feeRecipientQueryOptions,$t as filterQueryOptions,Ne as finalizeUnwrapContract,en as finalizeUnwrapMutationOptions,Pe as findUnwrapRequested,Fe as findWrapped,nn as generateKeypairMutationOptions,Ie as getBatchTransferFeeContract,Le as getFeeRecipientContract,Re as getUnwrapFeeContract,ze as getWrapFeeContract,Be as getWrapperContract,an as hashFn,Ve as indexedDBStorage,ln as isAllowedQueryOptions,dn as isConfidentialQueryOptions,He as isConfidentialTokenContract,Ue as isConfidentialWrapperContract,We as isFinalizeUnwrapOperatorContract,Ge as isOperatorContract,pn as isWrapperQueryOptions,mn as listPairsQueryOptions,Ke as loadPendingUnshield,qe as matchZamaError,Je as memoryStorage,Ye as nameContract,Xe as parseActivityFeed,gn as publicDecryptMutationOptions,vn as publicKeyQueryOptions,bn as publicParamsQueryOptions,Ze as rateContract,Sn as requestZKProofVerificationMutationOptions,wn as resumeUnshieldMutationOptions,En as revokeDelegationMutationOptions,On as revokeMutationOptions,An as revokeSessionMutationOptions,Qe as savePendingUnshield,$e as setFinalizeUnwrapOperatorContract,et as setOperatorContract,Mn as shieldETHMutationOptions,j as shieldFeeQueryOptions,Fn as shieldMutationOptions,Ln as signerAddressQueryOptions,tt as sortByBlockNumber,nt as supportsInterfaceContract,rt as symbolContract,zn as tokenMetadataQueryOptions,it as totalSupplyContract,Wn as totalSupplyQueryOptions,Gn as underlyingAllowanceQueryOptions,at as underlyingContract,Kn as unshieldAllMutationOptions,Jn as unshieldFeeQueryOptions,Xn as unshieldMutationOptions,Qn as unwrapAllMutationOptions,ot as unwrapContract,st as unwrapFromBalanceContract,er as unwrapMutationOptions,Qr as useActivityFeed,Dr as useAllow,ii as useApproveUnderlying,ri as useBatchDecryptBalancesAs,pi as useBatchTransferFee,Fr as useConfidentialApprove,jr as useConfidentialBalance,Mr as useConfidentialBalances,Ir as useConfidentialIsApproved,Lr as useConfidentialIsApprovedSuspense,yi as useConfidentialTokenAddress,Nr as useConfidentialTransfer,Pr as useConfidentialTransferFrom,yr as useCreateDelegatedUserDecryptEIP712,vr as useCreateEIP712,ni as useDecryptBalanceAs,$r as useDelegateDecryption,br as useDelegatedUserDecrypt,ti as useDelegationStatus,mr as useEncrypt,mi as useFeeRecipient,Hr as useFinalizeUnwrap,_r as useGenerateKeypair,Or as useIsAllowed,ai as useIsConfidential,oi as useIsConfidentialSuspense,xi as useIsConfidentialTokenValid,si as useIsWrapper,ci as useIsWrapperSuspense,Si as useListPairs,Xr as useMetadata,Zr as useMetadataSuspense,gr as usePublicDecrypt,Cr as usePublicKey,wr as usePublicParams,J as useReadonlyToken,xr as useRequestZKProofVerification,Gr as useResumeUnshield,kr as useRevoke,ei as useRevokeDelegation,Ar as useRevokeSession,Rr as useShield,zr as useShieldETH,di as useShieldFee,q as useToken,bi as useTokenAddress,vi as useTokenPair,gi as useTokenPairsLength,hi as useTokenPairsRegistry,_i as useTokenPairsSlice,li as useTotalSupply,ui as useTotalSupplySuspense,Kr as useUnderlyingAllowance,qr as useUnderlyingAllowanceSuspense,Ur as useUnshield,Wr as useUnshieldAll,fi as useUnshieldFee,Br as useUnwrap,Vr as useUnwrapAll,hr as useUserDecrypt,Tr as useUserDecryptedValue,Er as useUserDecryptedValues,Jr as useWrapperDiscovery,Yr as useWrapperDiscoverySuspense,$ as useWrappersRegistryAddress,W as useZamaSDK,nr as userDecryptMutationOptions,ct as wrapContract,lt as wrapETHContract,ir as wrapperDiscoveryQueryOptions,ut as wrapperExistsContract,ar as zamaQueryKeys};
|
|
1
|
+
"use client";import{ApprovalFailedError as e,ChromeSessionStorage as t,ConfigurationError as n,CredentialsManager as r,DecryptionFailedError as i,DefaultRegistryAddresses as a,DelegatedCredentialsManager as o,ERC7984_INTERFACE_ID as s,ERC7984_WRAPPER_INTERFACE_ID as c,EncryptionFailedError as l,HardhatConfig as u,IndexedDBStorage as d,InvalidKeypairError as f,KeypairExpiredError as p,MainnetConfig as m,MemoryStorage as ee,NoCiphertextError as te,ReadonlyToken as ne,ReadonlyToken as re,RelayerRequestFailedError as ie,RelayerWeb as ae,SepoliaConfig as oe,SigningFailedError as se,SigningRejectedError as ce,TOKEN_TOPICS as le,Token as ue,Topics as de,TransactionRevertedError as fe,WrappersRegistry as pe,ZERO_HANDLE as me,ZamaError as he,ZamaErrorCode as ge,ZamaSDK as _e,ZamaSDK as ve,ZamaSDKEvents as ye,allowanceContract as be,applyDecryptedValues as xe,approveContract as Se,balanceOfContract as Ce,chromeSessionStorage as we,clearPendingUnshield as Te,confidentialBalanceOfContract as Ee,confidentialBatchTransferContract as De,confidentialTotalSupplyContract as Oe,confidentialTransferContract as ke,confidentialTransferFromContract as Ae,decimalsContract as je,decodeConfidentialTransfer as h,decodeOnChainEvent as g,decodeOnChainEvents as _,decodeUnwrapRequested as v,decodeUnwrappedFinalized as y,decodeUnwrappedStarted as b,decodeWrapped as x,deploymentCoordinatorContract as S,extractEncryptedHandles as Me,finalizeUnwrapContract as Ne,findUnwrapRequested as Pe,findWrapped as Fe,getBatchTransferFeeContract as Ie,getFeeRecipientContract as Le,getUnwrapFeeContract as Re,getWrapFeeContract as ze,getWrapperContract as Be,indexedDBStorage as Ve,isConfidentialTokenContract as He,isConfidentialWrapperContract as Ue,isFinalizeUnwrapOperatorContract as We,isOperatorContract as Ge,loadPendingUnshield as Ke,matchZamaError as qe,memoryStorage as Je,nameContract as Ye,parseActivityFeed as Xe,rateContract as Ze,savePendingUnshield as Qe,setFinalizeUnwrapOperatorContract as $e,setOperatorContract as et,sortByBlockNumber as tt,supportsInterfaceContract as nt,symbolContract as rt,totalSupplyContract as it,underlyingContract as at,unwrapContract as ot,unwrapFromBalanceContract as st,wrapContract as ct,wrapETHContract as lt,wrapperExistsContract as ut}from"@zama-fhe/sdk";import{activityFeedQueryOptions as dt,activityFeedQueryOptions as ft,allowMutationOptions as pt,allowMutationOptions as mt,approveUnderlyingMutationOptions as ht,approveUnderlyingMutationOptions as gt,batchDecryptBalancesAsMutationOptions as _t,batchTransferFeeQueryOptions as vt,batchTransferFeeQueryOptions as yt,confidentialApproveMutationOptions as bt,confidentialApproveMutationOptions as xt,confidentialBalanceQueryOptions as St,confidentialBalanceQueryOptions as Ct,confidentialBalancesQueryOptions as wt,confidentialBalancesQueryOptions as Tt,confidentialHandleQueryOptions as Et,confidentialHandleQueryOptions as Dt,confidentialHandlesQueryOptions as Ot,confidentialHandlesQueryOptions as kt,confidentialIsApprovedQueryOptions as At,confidentialIsApprovedQueryOptions as C,confidentialTokenAddressQueryOptions as jt,confidentialTransferFromMutationOptions as Mt,confidentialTransferFromMutationOptions as Nt,confidentialTransferMutationOptions as Pt,confidentialTransferMutationOptions as Ft,createDelegatedUserDecryptEIP712MutationOptions as It,createDelegatedUserDecryptEIP712MutationOptions as Lt,createEIP712MutationOptions as Rt,createEIP712MutationOptions as zt,decryptBalanceAsMutationOptions as Bt,decryptBalanceAsMutationOptions as Vt,delegateDecryptionMutationOptions as Ht,delegateDecryptionMutationOptions as Ut,delegatedUserDecryptMutationOptions as Wt,delegatedUserDecryptMutationOptions as Gt,delegationStatusQueryOptions as Kt,delegationStatusQueryOptions as qt,deriveActivityFeedLogsKey as Jt,encryptMutationOptions as Yt,encryptMutationOptions as Xt,feeRecipientQueryOptions as Zt,feeRecipientQueryOptions as Qt,filterQueryOptions as $t,finalizeUnwrapMutationOptions as en,finalizeUnwrapMutationOptions as tn,generateKeypairMutationOptions as nn,generateKeypairMutationOptions as rn,hashFn as an,hashFn as w,invalidateAfterApprove as on,invalidateAfterApproveUnderlying as sn,invalidateAfterShield as cn,invalidateAfterTransfer as T,invalidateAfterUnshield as E,invalidateAfterUnwrap as D,invalidateWalletLifecycleQueries as O,isAllowedQueryOptions as ln,isAllowedQueryOptions as un,isConfidentialQueryOptions as dn,isConfidentialQueryOptions as k,isConfidentialTokenValidQueryOptions as fn,isWrapperQueryOptions as pn,isWrapperQueryOptions as A,listPairsQueryOptions as mn,listPairsQueryOptions as hn,publicDecryptMutationOptions as gn,publicDecryptMutationOptions as _n,publicKeyQueryOptions as vn,publicKeyQueryOptions as yn,publicParamsQueryOptions as bn,publicParamsQueryOptions as xn,requestZKProofVerificationMutationOptions as Sn,requestZKProofVerificationMutationOptions as Cn,resumeUnshieldMutationOptions as wn,resumeUnshieldMutationOptions as Tn,revokeDelegationMutationOptions as En,revokeDelegationMutationOptions as Dn,revokeMutationOptions as On,revokeMutationOptions as kn,revokeSessionMutationOptions as An,revokeSessionMutationOptions as jn,shieldETHMutationOptions as Mn,shieldETHMutationOptions as Nn,shieldFeeQueryOptions as j,shieldFeeQueryOptions as Pn,shieldMutationOptions as Fn,shieldMutationOptions as In,signerAddressQueryOptions as Ln,signerAddressQueryOptions as M,tokenAddressQueryOptions as Rn,tokenMetadataQueryOptions as zn,tokenMetadataQueryOptions as N,tokenPairQueryOptions as Bn,tokenPairsLengthQueryOptions as Vn,tokenPairsQueryOptions as Hn,tokenPairsSliceQueryOptions as Un,totalSupplyQueryOptions as Wn,totalSupplyQueryOptions as P,underlyingAllowanceQueryOptions as Gn,underlyingAllowanceQueryOptions as F,unshieldAllMutationOptions as Kn,unshieldAllMutationOptions as qn,unshieldFeeQueryOptions as Jn,unshieldFeeQueryOptions as Yn,unshieldMutationOptions as Xn,unshieldMutationOptions as Zn,unwrapAllMutationOptions as Qn,unwrapAllMutationOptions as $n,unwrapMutationOptions as er,unwrapMutationOptions as tr,userDecryptMutationOptions as nr,userDecryptMutationOptions as rr,wrapperDiscoveryQueryOptions as ir,wrapperDiscoveryQueryOptions as I,zamaQueryKeys as ar,zamaQueryKeys as L}from"@zama-fhe/sdk/query";import{skipToken as or,useMutation as R,useQueries as sr,useQuery as cr,useQueryClient as z,useSuspenseQuery as lr}from"@tanstack/react-query";import{createContext as ur,useContext as dr,useEffect as B,useMemo as V,useRef as H}from"react";import{jsx as fr}from"react/jsx-runtime";const U=ur(null);function pr({children:e,relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,registryAddresses:s,registryTTL:c,onEvent:l}){let u=z(),d=H(l),f=H(s);B(()=>{d.current=l,f.current=s});let p=V(()=>n?.subscribe?{onDisconnect:()=>O(u),onAccountChange:()=>O(u),onChainChange:()=>O(u)}:void 0,[u,n]),m=V(()=>new ve({relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,registryAddresses:f.current,registryTTL:c,onEvent:d.current,signerLifecycleCallbacks:p}),[t,n,r,i,a,o,c,p]);return B(()=>()=>m.dispose(),[m]),fr(U.Provider,{value:m,children:e})}function W(){let e=dr(U);if(!e)throw Error(`useZamaSDK must be used within a <ZamaProvider>. Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.`);return e}function mr(){return R(Xt(W()))}function hr(e){return R(rr(W(),e))}function gr(){return R(_n(W()))}function _r(){return R(rn(W()))}function vr(){return R(zt(W()))}function yr(){return R(Lt(W()))}function br(){return R(Gt(W()))}function xr(){return R(Cn(W()))}function G(e){return cr({...e,queryKeyHashFn:w})}function K(e){return lr({...e,queryKeyHashFn:w})}function Sr({queries:e,...t}){return sr({...t,queries:e.map(e=>({...e,queryKeyHashFn:w}))})}function Cr(){return G({...yn(W())})}function wr(e){return G({...xn(W(),e)})}function Tr(e){return G({queryKey:L.decryption.handle(e??`0x`),queryFn:()=>void 0,enabled:!1})}function Er(e){let t=Sr({queries:e.map(e=>({queryKey:L.decryption.handle(e),queryFn:()=>void 0,enabled:!1}))}),n={};for(let r=0;r<e.length;r++)n[e[r]]=t[r].data;return{data:n,results:t}}function Dr(e){return R({...mt(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}function Or(){let e=W(),t=G({...M(e.signer)}).data;return G(t?un(e,{account:t}):{queryKey:L.isAllowed.all,queryFn:or,enabled:!1})}function kr(e){return R({...kn(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}function Ar(e){return R({...jn(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}function q(e){let t=W();return V(()=>t.createToken(e.tokenAddress,e.wrapperAddress),[t,e.tokenAddress,e.wrapperAddress])}function J(e){let t=W();return V(()=>t.createReadonlyToken(e),[t,e])}function jr(e,t){let{tokenAddress:n,handleRefetchInterval:r}=e,{enabled:i=!0}=t??{},a=J(n),o=G({...M(a.signer)}).data,s=Dt(a.signer,n,{owner:o,pollingInterval:r}),c=G({...s,enabled:s.enabled&&i}),l=c.data,u=Ct(a,{handle:l,owner:o});return{...G({...u,...t,enabled:u.enabled&&i}),handleQuery:c}}function Mr(e,t){let{tokenAddresses:n,handleRefetchInterval:r,maxConcurrency:i}=e,{enabled:a=!0}=t??{},o=W(),s=G({...M(o.signer)}).data,c=V(()=>n.map(e=>o.createReadonlyToken(e)),[o,n]),l=kt(o.signer,n,{owner:s,pollingInterval:r}),u=G({...l,enabled:l.enabled&&a}),d=u.data,f=Array.isArray(d)&&d.length===n.length,p=Tt(c,{owner:s,handles:d,maxConcurrency:i,resultAddresses:n}),m=p.enabled??!0;return{...G({...p,...t,enabled:m&&f&&a}),handlesQuery:u}}function Y(e,t){let n=e?t:void 0;return{wrappedContext:n,callerContext:e?n?.callerContext:t}}async function X({queryClient:e,tokenAddress:t,amount:n,mode:r}){let i=L.confidentialBalance.token(t);await e.cancelQueries({queryKey:i});let a=e.getQueriesData({queryKey:i});for(let[t,i]of a)i!==void 0&&e.setQueryData(t,r===`add`?i+n:i-n);return a}function Z(e,t){for(let[n,r]of t)e.setQueryData(n,r)}function Q({optimistic:e,tokenAddress:t,queryClient:n,options:r}){return{onMutate:e?async(e,i)=>({snapshot:await X({queryClient:n,tokenAddress:t,amount:e.amount,mode:`add`}),callerContext:await r?.onMutate?.(e,i)}):r?.onMutate,onError:(t,i,a,o)=>{let{wrappedContext:s,callerContext:c}=Y(e,a);try{s&&Z(n,s.snapshot)}finally{r?.onError?.(t,i,c,o)}},onSuccess:(n,i,a,o)=>{let{callerContext:s}=Y(e,a);r?.onSuccess?.(n,i,s,o),cn(o.client,t)},onSettled:(t,n,i,a,o)=>{let{callerContext:s}=Y(e,a);r?.onSettled?.(t,n,i,s,o)}}}function Nr(e,t){let n=q(e),r=z();return R({...Ft(n),...t,onMutate:e.optimistic?async(n,i)=>({snapshot:await X({queryClient:r,tokenAddress:e.tokenAddress,amount:n.amount,mode:`subtract`}),callerContext:await t?.onMutate?.(n,i)}):t?.onMutate,onError:(n,i,a,o)=>{let{wrappedContext:s,callerContext:c}=Y(e.optimistic,a);try{s&&Z(r,s.snapshot)}finally{t?.onError?.(n,i,c,o)}},onSuccess:(n,r,i,a)=>{let{callerContext:o}=Y(e.optimistic,i);t?.onSuccess?.(n,r,o,a),T(a.client,e.tokenAddress)},onSettled:(n,r,i,a,o)=>{let{callerContext:s}=Y(e.optimistic,a);t?.onSettled?.(n,r,i,s,o)}})}function Pr(e,t){return R({...Nt(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),T(a.client,e.tokenAddress)}})}function Fr(e,t){return R({...xt(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),on(a.client,e.tokenAddress)}})}function Ir(e,t){let{tokenAddress:n,spender:r,holder:i}=e,a=W(),o=G({...M(a.signer),enabled:n!==void 0&&r!==void 0&&i===void 0}),s=i??o.data,c=C(a.signer,n,{holder:s,spender:r});return G({...c,...t,enabled:(c.enabled??!0)&&(t?.enabled??!0)})}function Lr(e){let{spender:t,holder:n,...r}=e,i=q(r),a=K({...M(i.signer)}),o=n??a.data;return K({...C(i.signer,i.address,{holder:o,spender:t})})}function Rr(e,t){let n=q(e),r=z();return R({...In(n),...t,...Q({optimistic:e.optimistic,tokenAddress:e.tokenAddress,queryClient:r,options:t})})}function zr(e,t){let n=q(e),r=z();return R({...Nn(n),...t,...Q({optimistic:e.optimistic,tokenAddress:e.tokenAddress,queryClient:r,options:t})})}function Br(e,t){return R({...tr(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function Vr(e,t){return R({...$n(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function Hr(e,t){return R({...tn(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Ur(e,t){return R({...Zn(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Wr(e,t){return R({...qn(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Gr(e,t){return R({...Tn(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Kr(e,t){let{tokenAddress:n,wrapperAddress:r}=e,i=J(n),a=G({...M(i.signer)}).data,o=F(i.signer,n,{owner:a,wrapperAddress:r});return G({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function qr(e){let{tokenAddress:t,wrapperAddress:n}=e,r=J(t),i=K({...M(r.signer)}).data;return K({...F(r.signer,t,{owner:i,wrapperAddress:n})})}function $(){let e=W(),{data:t}=G({queryKey:L.wrappersRegistry.chainId(),queryFn:()=>e.signer.getChainId(),staleTime:3e4});return t===void 0?void 0:e.registry.getAddress(t)}function Jr(e,t){let{tokenAddress:n,erc20Address:r}=e,i=W(),a=$(),o=I(i.registry,{tokenAddress:n,erc20Address:r,registryAddress:a});return G({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function Yr(e){let{tokenAddress:t,erc20Address:n}=e,r=W(),i=$();return K({...I(r.registry,{tokenAddress:t,erc20Address:n,registryAddress:i})})}function Xr(e,t){return G({...N(J(e).signer,e),...t})}function Zr(e){return K({...N(J(e).signer,e)})}function Qr(e){let{tokenAddress:t,userAddress:n,logs:r,decrypt:i}=e;return G({...ft(J(t),{userAddress:n,logs:r,decrypt:i??!0,logsKey:Jt(r)})})}function $r(e,t){return R({...Ut(q(e)),...t,onSuccess:(e,n,r,i)=>{try{t?.onSuccess?.(e,n,r,i)}finally{i.client.invalidateQueries({queryKey:L.delegationStatus.all})}}})}function ei(e,t){return R({...Dn(q(e)),...t,onSuccess:(e,n,r,i)=>{try{t?.onSuccess?.(e,n,r,i)}finally{i.client.invalidateQueries({queryKey:L.delegationStatus.all})}}})}function ti(e,t){let n=qt(W(),{tokenAddress:e.tokenAddress,delegatorAddress:e.delegatorAddress,delegateAddress:e.delegateAddress});return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function ni(e,t){return R({...Vt(J(e)),...t})}function ri(e,t){return R({mutationKey:[`zama.batchDecryptBalancesAs`,...e.map(e=>e.address)],mutationFn:async t=>re.batchDecryptBalancesAs(e,t),...t})}function ii(e,t){return R({...gt(q(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),sn(a.client,e.tokenAddress)}})}function ai(e,t){return G({...k(J(e).signer,e),...t})}function oi(e){return K({...k(J(e).signer,e)})}function si(e,t){return G({...A(J(e).signer,e),...t})}function ci(e){return K({...A(J(e).signer,e)})}function li(e,t){return G({...P(J(e).signer,e),...t})}function ui(e){return K({...P(J(e).signer,e)})}function di(e,t){let n=Pn(W().signer,e);return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function fi(e,t){let n=Yn(W().signer,e);return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function pi(e,t){let n=yt(W().signer,e);return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function mi(e,t){let n=Qt(W().signer,e);return G({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function hi(){let e=W(),t=$();return G(Hn(e.signer,{registryAddress:t}))}function gi(){let e=W(),t=$();return G(Vn(e.signer,{registryAddress:t}))}function _i({fromIndex:e,toIndex:t}){let n=W(),r=$();return G(Un(n.signer,{registryAddress:r,fromIndex:e,toIndex:t}))}function vi({index:e}){let t=W(),n=$();return G(Bn(t.signer,{registryAddress:n,index:e}))}function yi({tokenAddress:e}){let t=W(),n=$();return G(jt(t.signer,{registryAddress:n,tokenAddress:e}))}function bi({confidentialTokenAddress:e}){let t=W(),n=$();return G(Rn(t.signer,{registryAddress:n,confidentialTokenAddress:e}))}function xi({confidentialTokenAddress:e}){let t=W(),n=$();return G(fn(t.signer,{registryAddress:n,confidentialTokenAddress:e}))}function Si({page:e=1,pageSize:t=100,metadata:n=!1}={}){let r=W(),i=$();return G(hn(r.registry,{registryAddress:i,page:e,pageSize:t,metadata:n}))}export{e as ApprovalFailedError,t as ChromeSessionStorage,n as ConfigurationError,r as CredentialsManager,i as DecryptionFailedError,a as DefaultRegistryAddresses,o as DelegatedCredentialsManager,s as ERC7984_INTERFACE_ID,c as ERC7984_WRAPPER_INTERFACE_ID,l as EncryptionFailedError,u as HardhatConfig,d as IndexedDBStorage,f as InvalidKeypairError,p as KeypairExpiredError,m as MainnetConfig,ee as MemoryStorage,te as NoCiphertextError,ne as ReadonlyToken,ie as RelayerRequestFailedError,ae as RelayerWeb,oe as SepoliaConfig,se as SigningFailedError,ce as SigningRejectedError,le as TOKEN_TOPICS,ue as Token,de as Topics,fe as TransactionRevertedError,pe as WrappersRegistry,me as ZERO_HANDLE,he as ZamaError,ge as ZamaErrorCode,pr as ZamaProvider,_e as ZamaSDK,ye as ZamaSDKEvents,dt as activityFeedQueryOptions,pt as allowMutationOptions,be as allowanceContract,xe as applyDecryptedValues,Se as approveContract,ht as approveUnderlyingMutationOptions,Ce as balanceOfContract,_t as batchDecryptBalancesAsMutationOptions,vt as batchTransferFeeQueryOptions,we as chromeSessionStorage,Te as clearPendingUnshield,bt as confidentialApproveMutationOptions,Ee as confidentialBalanceOfContract,St as confidentialBalanceQueryOptions,wt as confidentialBalancesQueryOptions,De as confidentialBatchTransferContract,Et as confidentialHandleQueryOptions,Ot as confidentialHandlesQueryOptions,At as confidentialIsApprovedQueryOptions,Oe as confidentialTotalSupplyContract,ke as confidentialTransferContract,Ae as confidentialTransferFromContract,Mt as confidentialTransferFromMutationOptions,Pt as confidentialTransferMutationOptions,It as createDelegatedUserDecryptEIP712MutationOptions,Rt as createEIP712MutationOptions,je as decimalsContract,h as decodeConfidentialTransfer,g as decodeOnChainEvent,_ as decodeOnChainEvents,v as decodeUnwrapRequested,y as decodeUnwrappedFinalized,b as decodeUnwrappedStarted,x as decodeWrapped,Bt as decryptBalanceAsMutationOptions,Ht as delegateDecryptionMutationOptions,Wt as delegatedUserDecryptMutationOptions,Kt as delegationStatusQueryOptions,S as deploymentCoordinatorContract,Yt as encryptMutationOptions,Me as extractEncryptedHandles,Zt as feeRecipientQueryOptions,$t as filterQueryOptions,Ne as finalizeUnwrapContract,en as finalizeUnwrapMutationOptions,Pe as findUnwrapRequested,Fe as findWrapped,nn as generateKeypairMutationOptions,Ie as getBatchTransferFeeContract,Le as getFeeRecipientContract,Re as getUnwrapFeeContract,ze as getWrapFeeContract,Be as getWrapperContract,an as hashFn,Ve as indexedDBStorage,ln as isAllowedQueryOptions,dn as isConfidentialQueryOptions,He as isConfidentialTokenContract,Ue as isConfidentialWrapperContract,We as isFinalizeUnwrapOperatorContract,Ge as isOperatorContract,pn as isWrapperQueryOptions,mn as listPairsQueryOptions,Ke as loadPendingUnshield,qe as matchZamaError,Je as memoryStorage,Ye as nameContract,Xe as parseActivityFeed,gn as publicDecryptMutationOptions,vn as publicKeyQueryOptions,bn as publicParamsQueryOptions,Ze as rateContract,Sn as requestZKProofVerificationMutationOptions,wn as resumeUnshieldMutationOptions,En as revokeDelegationMutationOptions,On as revokeMutationOptions,An as revokeSessionMutationOptions,Qe as savePendingUnshield,$e as setFinalizeUnwrapOperatorContract,et as setOperatorContract,Mn as shieldETHMutationOptions,j as shieldFeeQueryOptions,Fn as shieldMutationOptions,Ln as signerAddressQueryOptions,tt as sortByBlockNumber,nt as supportsInterfaceContract,rt as symbolContract,zn as tokenMetadataQueryOptions,it as totalSupplyContract,Wn as totalSupplyQueryOptions,Gn as underlyingAllowanceQueryOptions,at as underlyingContract,Kn as unshieldAllMutationOptions,Jn as unshieldFeeQueryOptions,Xn as unshieldMutationOptions,Qn as unwrapAllMutationOptions,ot as unwrapContract,st as unwrapFromBalanceContract,er as unwrapMutationOptions,Qr as useActivityFeed,Dr as useAllow,ii as useApproveUnderlying,ri as useBatchDecryptBalancesAs,pi as useBatchTransferFee,Fr as useConfidentialApprove,jr as useConfidentialBalance,Mr as useConfidentialBalances,Ir as useConfidentialIsApproved,Lr as useConfidentialIsApprovedSuspense,yi as useConfidentialTokenAddress,Nr as useConfidentialTransfer,Pr as useConfidentialTransferFrom,yr as useCreateDelegatedUserDecryptEIP712,vr as useCreateEIP712,ni as useDecryptBalanceAs,$r as useDelegateDecryption,br as useDelegatedUserDecrypt,ti as useDelegationStatus,mr as useEncrypt,mi as useFeeRecipient,Hr as useFinalizeUnwrap,_r as useGenerateKeypair,Or as useIsAllowed,ai as useIsConfidential,oi as useIsConfidentialSuspense,xi as useIsConfidentialTokenValid,si as useIsWrapper,ci as useIsWrapperSuspense,Si as useListPairs,Xr as useMetadata,Zr as useMetadataSuspense,gr as usePublicDecrypt,Cr as usePublicKey,wr as usePublicParams,J as useReadonlyToken,xr as useRequestZKProofVerification,Gr as useResumeUnshield,kr as useRevoke,ei as useRevokeDelegation,Ar as useRevokeSession,Rr as useShield,zr as useShieldETH,di as useShieldFee,q as useToken,bi as useTokenAddress,vi as useTokenPair,gi as useTokenPairsLength,hi as useTokenPairsRegistry,_i as useTokenPairsSlice,li as useTotalSupply,ui as useTotalSupplySuspense,Kr as useUnderlyingAllowance,qr as useUnderlyingAllowanceSuspense,Ur as useUnshield,Wr as useUnshieldAll,fi as useUnshieldFee,Br as useUnwrap,Vr as useUnwrapAll,hr as useUserDecrypt,Tr as useUserDecryptedValue,Er as useUserDecryptedValues,Jr as useWrapperDiscovery,Yr as useWrapperDiscoverySuspense,$ as useWrappersRegistryAddress,W as useZamaSDK,nr as userDecryptMutationOptions,ct as wrapContract,lt as wrapETHContract,ir as wrapperDiscoveryQueryOptions,ut as wrapperExistsContract,ar as zamaQueryKeys};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ZamaSDK","encryptMutationOptions","userDecryptMutationOptions","publicDecryptMutationOptions","generateKeypairMutationOptions","createEIP712MutationOptions","createDelegatedUserDecryptEIP712MutationOptions","delegatedUserDecryptMutationOptions","requestZKProofVerificationMutationOptions","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","useQueries","tanstack_useQueries","useQuery","publicKeyQueryOptions","useQuery","publicParamsQueryOptions","useQuery","zamaQueryKeys","useQueries","zamaQueryKeys","allowMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","isAllowedQueryOptions","zamaQueryKeys","revokeMutationOptions","zamaQueryKeys","revokeSessionMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","confidentialHandleQueryOptions","confidentialBalanceQueryOptions","useQuery","signerAddressQueryOptions","confidentialHandlesQueryOptions","confidentialBalancesQueryOptions","zamaQueryKeys","confidentialTransferMutationOptions","confidentialTransferFromMutationOptions","confidentialApproveMutationOptions","useQuery","signerAddressQueryOptions","confidentialIsApprovedQueryOptions","useSuspenseQuery","shieldMutationOptions","shieldETHMutationOptions","unwrapMutationOptions","unwrapAllMutationOptions","finalizeUnwrapMutationOptions","unshieldMutationOptions","unshieldAllMutationOptions","resumeUnshieldMutationOptions","useQuery","signerAddressQueryOptions","underlyingAllowanceQueryOptions","useSuspenseQuery","useQuery","zamaQueryKeys","wrapperDiscoveryQueryOptions","useQuery","useSuspenseQuery","useQuery","tokenMetadataQueryOptions","useSuspenseQuery","useQuery","activityFeedQueryOptions","delegateDecryptionMutationOptions","zamaQueryKeys","revokeDelegationMutationOptions","zamaQueryKeys","delegationStatusQueryOptions","useQuery","decryptBalanceAsMutationOptions","ReadonlyToken","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","shieldFeeQueryOptions","useQuery","unshieldFeeQueryOptions","batchTransferFeeQueryOptions","feeRecipientQueryOptions","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","listPairsQueryOptions"],"sources":["../src/provider.tsx","../src/relayer/use-encrypt.ts","../src/relayer/use-user-decrypt.ts","../src/relayer/use-public-decrypt.ts","../src/relayer/use-generate-keypair.ts","../src/relayer/use-create-eip712.ts","../src/relayer/use-create-delegated-user-decrypt-eip712.ts","../src/relayer/use-delegated-user-decrypt.ts","../src/relayer/use-request-zk-proof-verification.ts","../src/utils/query.ts","../src/relayer/use-public-key.ts","../src/relayer/use-public-params.ts","../src/relayer/use-user-decrypted-value.ts","../src/relayer/use-user-decrypted-values.ts","../src/token/use-allow.ts","../src/token/use-is-allowed.ts","../src/token/use-revoke.ts","../src/token/use-revoke-session.ts","../src/token/use-token.ts","../src/token/use-readonly-token.ts","../src/token/use-confidential-balance.ts","../src/token/use-confidential-balances.ts","../src/token/optimistic-balance-update.ts","../src/token/use-confidential-transfer.ts","../src/token/use-confidential-transfer-from.ts","../src/token/use-confidential-approve.ts","../src/token/use-confidential-is-approved.ts","../src/token/use-shield.ts","../src/token/use-shield-eth.ts","../src/token/use-unwrap.ts","../src/token/use-unwrap-all.ts","../src/token/use-finalize-unwrap.ts","../src/token/use-unshield.ts","../src/token/use-unshield-all.ts","../src/token/use-resume-unshield.ts","../src/token/use-underlying-allowance.ts","../src/wrappers-registry/use-wrappers-registry-address.ts","../src/token/use-wrapper-discovery.ts","../src/token/use-metadata.ts","../src/token/use-activity-feed.ts","../src/token/use-delegate-decryption.ts","../src/token/use-revoke-delegation.ts","../src/token/use-delegation-status.ts","../src/token/use-decrypt-balance-as.ts","../src/token/use-batch-decrypt-balances-as.ts","../src/token/use-approve-underlying.ts","../src/token/use-is-confidential.ts","../src/token/use-total-supply.ts","../src/token/use-fees.ts","../src/wrappers-registry/use-token-pairs-registry.ts","../src/wrappers-registry/use-token-pairs-length.ts","../src/wrappers-registry/use-token-pairs-slice.ts","../src/wrappers-registry/use-token-pair.ts","../src/wrappers-registry/use-confidential-token-address.ts","../src/wrappers-registry/use-token-address.ts","../src/wrappers-registry/use-is-confidential-token-valid.ts","../src/wrappers-registry/use-list-pairs.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n Address,\n GenericSigner,\n GenericStorage,\n RelayerSDK,\n ZamaSDKEventListener,\n} from \"@zama-fhe/sdk\";\nimport { ZamaSDK } from \"@zama-fhe/sdk\";\nimport { invalidateWalletLifecycleQueries } from \"@zama-fhe/sdk/query\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\n/** Props for {@link ZamaProvider}. */\nexport interface ZamaProviderProps extends PropsWithChildren {\n /** FHE relayer backend (RelayerWeb for browser, RelayerNode for server). */\n relayer: RelayerSDK;\n /** Wallet signer (`ViemSigner`, `EthersSigner`, or custom {@link GenericSigner}). */\n signer: GenericSigner;\n /** Credential storage backend (IndexedDBStorage for browser, MemoryStorage for tests). */\n storage: GenericStorage;\n /**\n * Session storage for wallet signatures. Defaults to in-memory (lost on reload).\n * Pass a `chrome.storage.session`-backed store for web extensions.\n */\n sessionStorage?: GenericStorage;\n /**\n * How long the ML-KEM re-encryption keypair remains valid, in seconds.\n * Default: `86400` (1 day). Must be positive — `0` is rejected.\n */\n keypairTTL?: number;\n /**\n * Controls how long session signatures (EIP-712 wallet signatures) remain valid, in seconds.\n * Default: `2592000` (30 days).\n * - `0`: never persist — every operation triggers a signing prompt (high-security mode).\n * - Positive number: seconds until the session signature expires and requires re-authentication.\n */\n sessionTTL?: number;\n /**\n * Per-chain wrappers registry address overrides, merged on top of built-in defaults.\n * Use this for custom or local chains (e.g. Hardhat) where no default registry exists.\n */\n registryAddresses?: Record<number, Address>;\n /**\n * How long cached registry results remain valid, in seconds.\n * Default: `86400` (24 hours).\n */\n registryTTL?: number;\n /** Callback invoked on SDK lifecycle events. */\n onEvent?: ZamaSDKEventListener;\n}\n\nconst ZamaSDKContext = createContext<ZamaSDK | null>(null);\n\n/**\n * Provides a {@link ZamaSDK} instance to all descendant hooks.\n *\n * @example\n * ```tsx\n * <ZamaProvider relayer={relayer} signer={signer} storage={storage}>\n * <App />\n * </ZamaProvider>\n * ```\n */\nexport function ZamaProvider({\n children,\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses,\n registryTTL,\n onEvent,\n}: ZamaProviderProps) {\n const queryClient = useQueryClient();\n\n // Stabilize onEvent so an inline arrow doesn't recreate the SDK every render.\n const onEventRef = useRef(onEvent);\n const registryAddressesRef = useRef(registryAddresses);\n\n useEffect(() => {\n onEventRef.current = onEvent;\n registryAddressesRef.current = registryAddresses;\n });\n\n const signerLifecycleCallbacks = useMemo(\n () =>\n signer?.subscribe\n ? {\n onDisconnect: () => invalidateWalletLifecycleQueries(queryClient),\n onAccountChange: () => invalidateWalletLifecycleQueries(queryClient),\n onChainChange: () => invalidateWalletLifecycleQueries(queryClient),\n }\n : undefined,\n [queryClient, signer],\n );\n\n const sdk = useMemo(\n () =>\n new ZamaSDK({\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses: registryAddressesRef.current,\n registryTTL,\n onEvent: onEventRef.current,\n signerLifecycleCallbacks,\n }),\n [\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryTTL,\n signerLifecycleCallbacks,\n ],\n );\n\n // Clean up signer subscriptions on unmount without terminating the\n // caller-owned relayer. dispose() only unsubscribes from wallet events\n // and is idempotent.\n useEffect(() => () => sdk.dispose(), [sdk]);\n\n return <ZamaSDKContext.Provider value={sdk}>{children}</ZamaSDKContext.Provider>;\n}\n\n/**\n * Access the {@link ZamaSDK} instance from context.\n * Throws if called outside a {@link ZamaProvider} or when no signer is provided.\n *\n * @example\n * ```tsx\n * const sdk = useZamaSDK();\n * const token = sdk.createReadonlyToken(\"0x...\");\n * ```\n */\nexport function useZamaSDK(): ZamaSDK {\n const context = useContext(ZamaSDKContext);\n\n if (!context) {\n throw new Error(\n \"useZamaSDK must be used within a <ZamaProvider>. \" +\n \"Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.\",\n );\n }\n\n return context;\n}\n","\"use client\";\n\nimport type { EncryptParams, EncryptResult } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { encryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Encrypt a plaintext value using FHE.\n * Calls the relayer's `encrypt` method via a mutation.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link EncryptionFailedError} — FHE encryption failed\n *\n * @returns A mutation whose `mutate` accepts {@link EncryptParams}.\n *\n * @example\n * ```tsx\n * const encrypt = useEncrypt();\n * encrypt.mutate({ values: [{ value: 1000n, type: \"euint64\" }], contractAddress: \"0x...\", userAddress: \"0x...\" });\n * ```\n */\nexport function useEncrypt() {\n const sdk = useZamaSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(sdk));\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport type {\n DecryptHandle,\n UserDecryptCallbacks,\n UserDecryptMutationParams,\n} from \"@zama-fhe/sdk/query\";\nimport { userDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type {\n UserDecryptCallbacks as DecryptCallbacks,\n DecryptHandle,\n UserDecryptMutationParams as DecryptParams,\n};\n\n/** Configuration for {@link useUserDecrypt}. */\nexport type UseUserDecryptConfig = UserDecryptCallbacks;\n\n/**\n * High-level orchestration hook for user decryption.\n *\n * Reuses cached FHE credentials from `sdk.credentials` when available,\n * falling back to generating a fresh keypair + EIP-712 signature only when\n * no valid credentials exist. This avoids redundant wallet signature prompts.\n *\n * On success, populates the decryption cache so `useUserDecryptedValue` / `useUserDecryptedValues`\n * can read the results.\n *\n * @param config - Optional callbacks for step-by-step UX feedback.\n * @returns A mutation whose `mutate` accepts {@link UserDecryptMutationParams}.\n *\n * @example\n * ```tsx\n * const decrypt = useUserDecrypt({\n * onCredentialsReady: () => setStep(\"decrypting\"),\n * onDecrypted: (values) => console.log(values),\n * });\n * decrypt.mutate({\n * handles: [{ handle: \"0xHandle\", contractAddress: \"0xContract\" }],\n * });\n * ```\n */\nexport function useUserDecrypt(config?: UseUserDecryptConfig) {\n const sdk = useZamaSDK();\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptMutationParams>(\n userDecryptMutationOptions(sdk, config),\n );\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Handle, PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { publicDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using the network public key (no credential needed).\n * On success, populates the decryption cache so {@link useUserDecryptedValue} / {@link useUserDecryptedValues}\n * can read the results.\n *\n * @returns A mutation whose `mutate` accepts an array of handle strings.\n *\n * @example\n * ```tsx\n * const publicDecrypt = usePublicDecrypt();\n * publicDecrypt.mutate([\"0xHandle1\", \"0xHandle2\"]);\n * // publicDecrypt.data?.clearValues => { \"0xHandle1\": 500n, ... }\n * ```\n */\nexport function usePublicDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<PublicDecryptResult, Error, Handle[]>(publicDecryptMutationOptions(sdk));\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { generateKeypairMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Generate an FHE keypair via the relayer.\n * Returns a public/private key pair for use in decrypt authorization.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link RelayerRequestFailedError} — relayer keypair generation request failed\n *\n * @returns A mutation whose `mutate` takes no parameters.\n *\n * @example\n * ```tsx\n * const generateKeypair = useGenerateKeypair();\n * generateKeypair.mutate();\n * // generateKeypair.data?.publicKey, generateKeypair.data?.privateKey\n * ```\n */\nexport function useGenerateKeypair() {\n const sdk = useZamaSDK();\n return useMutation(generateKeypairMutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { EIP712TypedData } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { createEIP712MutationOptions } from \"@zama-fhe/sdk/query\";\nimport type { CreateEIP712Params } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type { CreateEIP712Params };\n\n/**\n * Create EIP-712 typed data for signing an FHE decrypt credential.\n * The returned typed data is signed by the wallet to authorize decryption.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateEIP712() {\n const sdk = useZamaSDK();\n return useMutation<EIP712TypedData, Error, CreateEIP712Params>(createEIP712MutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { KmsDelegatedUserDecryptEIP712Type } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { createDelegatedUserDecryptEIP712MutationOptions } from \"@zama-fhe/sdk/query\";\nimport type { CreateDelegatedUserDecryptEIP712Params } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type { CreateDelegatedUserDecryptEIP712Params };\n\n/**\n * Create EIP-712 typed data for a delegated user decrypt credential.\n * Used when one wallet authorizes another to decrypt on its behalf.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateDelegatedUserDecryptEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateDelegatedUserDecryptEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * delegatorAddress: \"0xDelegator\",\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateDelegatedUserDecryptEIP712() {\n const sdk = useZamaSDK();\n return useMutation<\n KmsDelegatedUserDecryptEIP712Type,\n Error,\n CreateDelegatedUserDecryptEIP712Params\n >(createDelegatedUserDecryptEIP712MutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { DelegatedUserDecryptParams, ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { delegatedUserDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using delegated user credentials.\n * Returns a map of handle → plaintext bigint.\n *\n * @returns A mutation whose `mutate` accepts {@link DelegatedUserDecryptParams}.\n *\n * @example\n * ```tsx\n * const decrypt = useDelegatedUserDecrypt();\n * decrypt.mutate({ handles: [\"0xHandle1\"], ...credentials });\n * // decrypt.data => { \"0xHandle1\": 1000n }\n * ```\n */\nexport function useDelegatedUserDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<Record<Handle, ClearValueType>, Error, DelegatedUserDecryptParams>(\n delegatedUserDecryptMutationOptions(sdk),\n );\n}\n","\"use client\";\n\nimport type { InputProofBytesType, ZKProofLike } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { requestZKProofVerificationMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Submit a ZK proof for on-chain verification.\n * Returns the input proof bytes for use in contract calls.\n *\n * @returns A mutation whose `mutate` accepts a {@link ZKProofLike}.\n *\n * @example\n * ```tsx\n * const verify = useRequestZKProofVerification();\n * verify.mutate(zkProof);\n * // verify.data => Uint8Array (input proof bytes)\n * ```\n */\nexport function useRequestZKProofVerification() {\n const sdk = useZamaSDK();\n return useMutation<InputProofBytesType, Error, ZKProofLike>(\n requestZKProofVerificationMutationOptions(sdk),\n );\n}\n","import {\n type DefaultError,\n type QueriesOptions,\n type QueriesResults,\n useQueries as tanstack_useQueries,\n useQuery as tanstack_useQuery,\n useSuspenseQuery as tanstack_useSuspenseQuery,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryOptions,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\n\n/**\n * Thin wrapper around TanStack's useQuery that injects our custom queryKeyHashFn.\n * Mirrors the wagmi pattern — the type safety boundary is at the factory and hook levels.\n *\n * Callers typically specify only `<TData>` (e.g. `useQuery<PublicKeyData>(...)`) while\n * factory options carry specific tuple keys (e.g. `readonly [\"zama.publicKey\"]`).\n * We erase the QueryKey param via `AnyKeyQueryOptions` so callers don't need to\n * spell out the key type — any QueryKey subtype is accepted.\n */\ntype AnyKeyQueryOptions<TData, TError> = UseQueryOptions<\n TData,\n TError,\n TData,\n // oxlint-disable-next-line typescript/no-explicit-any\n any\n>;\ntype AnyKeySuspenseOptions<TData, TError> = UseSuspenseQueryOptions<\n TData,\n TError,\n TData,\n // oxlint-disable-next-line typescript/no-explicit-any\n any\n>;\n\nexport function useQuery<TData = unknown, TError = DefaultError>(\n options: AnyKeyQueryOptions<TData, TError>,\n): UseQueryResult<TData, TError> {\n return tanstack_useQuery({\n ...options,\n queryKeyHashFn: hashFn,\n });\n}\n\nexport function useSuspenseQuery<TData = unknown, TError = DefaultError>(\n options: AnyKeySuspenseOptions<TData, TError>,\n): UseSuspenseQueryResult<TData, TError> {\n return tanstack_useSuspenseQuery({\n ...options,\n queryKeyHashFn: hashFn,\n });\n}\n\n/**\n * Thin wrapper around TanStack's useQueries that injects our custom queryKeyHashFn\n * on every query in the array.\n */\nexport function useQueries<\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>({\n queries,\n ...options\n}: {\n queries: readonly [...QueriesOptions<T>];\n combine?: (result: QueriesResults<T>) => TCombinedResult;\n subscribed?: boolean;\n}): TCombinedResult {\n return tanstack_useQueries({\n ...options,\n queries: queries.map((q) => ({\n ...q,\n queryKeyHashFn: hashFn,\n })) as [...QueriesOptions<T>],\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { publicKeyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicKeyQueryOptions };\n\n/** Shape of the FHE public key data returned by the relayer. */\nexport interface PublicKeyData {\n /** Unique identifier for this public key version. */\n publicKeyId: string;\n /** The raw FHE public key bytes. */\n publicKey: Uint8Array;\n}\n\n/**\n * Fetch the FHE network public key from the relayer.\n * Cached indefinitely since the key does not change during a session.\n *\n * @returns Query result with `data: PublicKeyData | null`.\n *\n * @example\n * ```tsx\n * const { data: publicKey } = usePublicKey();\n * // publicKey?.publicKeyId, publicKey?.publicKey\n * ```\n */\nexport function usePublicKey() {\n const sdk = useZamaSDK();\n return useQuery<PublicKeyData | null>({\n ...publicKeyQueryOptions(sdk),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { publicParamsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicParamsQueryOptions };\n\n/** Shape of the FHE public parameters returned by the relayer. */\nexport interface PublicParamsData {\n /** The raw public parameters bytes (WASM-ready). */\n publicParams: Uint8Array;\n /** Unique identifier for this public params version. */\n publicParamsId: string;\n}\n\n/**\n * Fetch FHE public parameters for a given bit size from the relayer.\n * Cached indefinitely since parameters do not change during a session.\n *\n * @param bits - The FHE bit size to fetch parameters for (e.g. 2048).\n * @returns Query result with `data: PublicParamsData | null`.\n *\n * @example\n * ```tsx\n * const { data: params } = usePublicParams(2048);\n * // params?.publicParams, params?.publicParamsId\n * ```\n */\nexport function usePublicParams(bits: number) {\n const sdk = useZamaSDK();\n return useQuery<PublicParamsData | null>({\n ...publicParamsQueryOptions(sdk, bits),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\n\n/**\n * Look up a single cached decrypted value by its handle.\n * Values are populated automatically when `useUserDecrypt` or `usePublicDecrypt` succeed.\n * You can also populate manually via queryClient.setQueryData(zamaQueryKeys.decryption.handle(handle), value).\n */\nexport function useUserDecryptedValue(handle: Handle | undefined) {\n return useQuery<ClearValueType>({\n queryKey: zamaQueryKeys.decryption.handle(handle ?? \"0x\"),\n queryFn: () => undefined as never,\n enabled: false,\n });\n}\n","\"use client\";\n\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useQueries } from \"../utils/query\";\n\n/**\n * Look up multiple cached decrypted values by their handles.\n * Values are populated automatically when `useUserDecrypt` or `usePublicDecrypt` succeed.\n */\nexport function useUserDecryptedValues(handles: Handle[]) {\n const results = useQueries({\n queries: handles.map((handle) => ({\n queryKey: zamaQueryKeys.decryption.handle(handle),\n queryFn: () => undefined as never,\n enabled: false,\n })),\n });\n\n const data: Record<Handle, ClearValueType | undefined> = {};\n for (let i = 0; i < handles.length; i++) {\n data[handles[i]!] = results[i]!.data as ClearValueType | undefined;\n }\n\n return {\n data,\n results,\n };\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { allowMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Sign an EIP-712 message authorizing decryption of confidential handles\n * for a list of contract addresses. This is not token-specific — any\n * contract that uses FHE-encrypted values (tokens, DeFi vaults, games, etc.)\n * can be authorized in a single wallet signature. Subsequent decrypt\n * operations on any of these contracts reuse cached credentials.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link KeypairExpiredError} — the re-encryption keypair has expired\n *\n * @example\n * ```tsx\n * const { mutateAsync: allow, isPending } = useAllow();\n *\n * // Authorize decryption for any contracts with encrypted state:\n * // confidential tokens, auction contracts, governance contracts, etc.\n * await allow([tokenAddress, auctionAddress, governanceAddress]);\n * ```\n */\nexport function useAllow(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...allowMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { skipToken } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n isAllowedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Check whether a session signature is cached for the connected wallet.\n * Returns `true` if decrypt operations can proceed without a wallet prompt.\n *\n * @example\n * ```tsx\n * const { data: allowed } = useIsAllowed();\n * ```\n */\nexport function useIsAllowed() {\n const sdk = useZamaSDK();\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n const account = addressQuery.data;\n const baseOpts = account\n ? isAllowedQueryOptions(sdk, { account })\n : ({\n queryKey: zamaQueryKeys.isAllowed.all,\n queryFn: skipToken,\n enabled: false,\n } as const);\n\n return useQuery<boolean>(baseOpts);\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { revokeMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke stored FHE decrypt credentials for a list of contract addresses.\n * This is not token-specific — it revokes the EIP-712 authorization for\n * any contract that uses FHE-encrypted values. The next decrypt operation\n * on these contracts will require a fresh wallet signature.\n *\n * @example\n * ```tsx\n * const { mutate: revoke } = useRevoke();\n *\n * // Revoke for any contracts: tokens, auctions, governance, etc.\n * revoke([tokenAddress, auctionAddress]);\n * ```\n */\nexport function useRevoke(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...revokeMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { revokeSessionMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke the session signature for the connected wallet without\n * specifying contract addresses. Useful for wallet disconnect handlers.\n *\n * @example\n * ```tsx\n * const { mutate: revokeSession } = useRevokeSession();\n * revokeSession();\n * ```\n */\nexport function useRevokeSession(options?: UseMutationOptions<void>) {\n const sdk = useZamaSDK();\n\n return useMutation<void>({\n ...revokeSessionMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Base configuration shared by all mutation hooks that need a Token instance. */\nexport interface UseZamaConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Address of the wrapper contract (required for shield/unshield operations). */\n wrapperAddress?: Address;\n}\n\n/**\n * Get a {@link Token} instance, memoized by address pair.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param config - Token and optional wrapper addresses.\n * @returns A memoized `Token` instance.\n *\n * @example\n * ```tsx\n * const token = useToken({ tokenAddress: \"0xToken\", wrapperAddress: \"0xWrapper\" });\n * ```\n */\nexport function useToken(config: UseZamaConfig) {\n const sdk = useZamaSDK();\n\n return useMemo(\n () => sdk.createToken(config.tokenAddress, config.wrapperAddress),\n [sdk, config.tokenAddress, config.wrapperAddress],\n );\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Get a {@link ReadonlyToken} instance, memoized by address.\n * Supports balance queries, ERC-165 checks, and authorization — no wrapper needed.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param address - Address of the confidential token contract.\n * @returns A memoized `ReadonlyToken` instance.\n *\n * @example\n * ```tsx\n * const token = useReadonlyToken(\"0xToken\");\n * // token.balanceOf(), token.isConfidential(), etc.\n * ```\n */\nexport function useReadonlyToken(address: Address) {\n const sdk = useZamaSDK();\n\n return useMemo(() => sdk.createReadonlyToken(address), [sdk, address]);\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryOptions,\n confidentialHandleQueryOptions,\n signerAddressQueryOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/** Configuration for {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Polling interval (ms) for the encrypted handle. Default: 10 000. */\n handleRefetchInterval?: number;\n}\n\n/** Query options for the decrypt phase of {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceOptions extends Omit<\n UseQueryOptions<bigint>,\n \"queryKey\" | \"queryFn\" | \"enabled\"\n> {\n /** Whether the query is enabled. Callback form is not supported in composite hooks. */\n enabled?: boolean;\n}\n\n/**\n * Declarative hook to read the connected wallet's confidential token balance.\n * Uses two-phase polling: cheaply polls the encrypted handle, then only\n * decrypts when the handle changes (new balance).\n *\n * @param config - Token address and optional polling interval.\n * @param options - React Query options forwarded to the decrypt query.\n * @returns The decrypt query result plus `handleQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data: balance, isLoading, handleQuery } = useConfidentialBalance({\n * tokenAddress: \"0x...\",\n * });\n * ```\n */\nexport function useConfidentialBalance(\n config: UseConfidentialBalanceConfig,\n options?: UseConfidentialBalanceOptions,\n) {\n const { tokenAddress, handleRefetchInterval } = config;\n const { enabled = true } = options ?? {};\n const token = useReadonlyToken(tokenAddress);\n\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n\n const owner = addressQuery.data;\n\n // Phase 1: Poll the encrypted handle (cheap RPC read, no signing)\n const baseHandleQueryOptions = confidentialHandleQueryOptions(token.signer, tokenAddress, {\n owner,\n pollingInterval: handleRefetchInterval,\n });\n const handleQuery = useQuery<Handle>({\n ...baseHandleQueryOptions,\n enabled: baseHandleQueryOptions.enabled && enabled,\n });\n\n // Phase 2: Decrypt only when handle changes (expensive relayer roundtrip)\n const handle = handleQuery.data;\n const baseBalanceQueryOptions = confidentialBalanceQueryOptions(token, {\n handle,\n owner,\n });\n const balanceQuery = useQuery<bigint>({\n ...baseBalanceQueryOptions,\n ...options,\n enabled: baseBalanceQueryOptions.enabled && enabled,\n });\n\n return { ...balanceQuery, handleQuery };\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport { useQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalancesQueryOptions,\n confidentialHandlesQueryOptions,\n signerAddressQueryOptions,\n type ConfidentialBalancesData,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Configuration for {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesConfig {\n /** Addresses of the confidential token contracts to batch-query. */\n tokenAddresses: Address[];\n /** Polling interval (ms) for the encrypted handles. Default: 10 000. */\n handleRefetchInterval?: number;\n /** Maximum number of concurrent decrypt calls. Default: `Infinity` (no limit). */\n maxConcurrency?: number;\n}\n\nexport type { ConfidentialBalancesData };\n\n/** Query options for the decrypt phase of {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesOptions extends Omit<\n UseQueryOptions<ConfidentialBalancesData>,\n \"queryKey\" | \"queryFn\" | \"enabled\"\n> {\n /** Whether the query is enabled. Callback form is not supported in composite hooks. */\n enabled?: boolean;\n}\n\n/**\n * Declarative hook to read multiple confidential token balances in batch.\n * Uses two-phase polling: cheaply polls encrypted handles, then only\n * decrypts when any handle changes.\n *\n * Returns partial results when some tokens fail — successful balances are\n * always returned alongside per-token error information.\n *\n * @param config - Token addresses and optional polling interval.\n * @param options - React Query options forwarded to the decrypt query.\n * @returns The decrypt query result plus `handlesQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data } = useConfidentialBalances({\n * tokenAddresses: [\"0xTokenA\", \"0xTokenB\"],\n * });\n * const balance = data?.balances.get(\"0xTokenA\");\n * if (data?.isPartialError) {\n * // some tokens failed — check data.errors\n * }\n * ```\n */\nexport function useConfidentialBalances(\n config: UseConfidentialBalancesConfig,\n options?: UseConfidentialBalancesOptions,\n) {\n const { tokenAddresses, handleRefetchInterval, maxConcurrency } = config;\n const { enabled = true } = options ?? {};\n const sdk = useZamaSDK();\n\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n\n const owner = addressQuery.data;\n\n const tokens = useMemo(\n () => tokenAddresses.map((addr) => sdk.createReadonlyToken(addr)),\n [sdk, tokenAddresses],\n );\n\n // Phase 1: Poll all encrypted handles (cheap RPC reads)\n const baseHandlesQueryOptions = confidentialHandlesQueryOptions(sdk.signer, tokenAddresses, {\n owner,\n pollingInterval: handleRefetchInterval,\n });\n const handlesQuery = useQuery<Handle[]>({\n ...baseHandlesQueryOptions,\n enabled: baseHandlesQueryOptions.enabled && enabled,\n });\n\n // Phase 2: Batch decrypt only when any handle changes\n const handles = handlesQuery.data;\n const handlesReady = Array.isArray(handles) && handles.length === tokenAddresses.length;\n const baseBalancesQueryOptions = confidentialBalancesQueryOptions(tokens, {\n owner,\n handles,\n maxConcurrency,\n resultAddresses: tokenAddresses,\n });\n const factoryEnabled = baseBalancesQueryOptions.enabled ?? true;\n\n const balancesQuery = useQuery<ConfidentialBalancesData>({\n ...baseBalancesQueryOptions,\n ...options,\n enabled: factoryEnabled && handlesReady && enabled,\n });\n\n return { ...balancesQuery, handlesQuery };\n}\n","import type { QueryClient, QueryKey, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterShield, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\n\ntype BalanceDeltaMode = \"add\" | \"subtract\";\nexport type OptimisticBalanceSnapshot = [QueryKey, bigint | undefined][];\n\n/** Combined context returned by optimistic `onMutate`. */\nexport interface OptimisticMutateContext {\n snapshot: OptimisticBalanceSnapshot;\n callerContext?: unknown;\n}\n\nexport function unwrapOptimisticCallerContext(\n optimistic: boolean | undefined,\n rawContext: unknown,\n): {\n wrappedContext: OptimisticMutateContext | undefined;\n callerContext: OptimisticMutateContext | undefined;\n} {\n const typed = rawContext as OptimisticMutateContext | undefined;\n const wrappedContext = optimistic ? typed : undefined;\n const callerContext = (optimistic ? wrappedContext?.callerContext : rawContext) as\n | OptimisticMutateContext\n | undefined;\n return { wrappedContext, callerContext };\n}\n\nexport async function applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount,\n mode,\n}: {\n queryClient: QueryClient;\n tokenAddress: Address;\n amount: bigint;\n mode: BalanceDeltaMode;\n}): Promise<OptimisticBalanceSnapshot> {\n const balanceKey = zamaQueryKeys.confidentialBalance.token(tokenAddress);\n await queryClient.cancelQueries({ queryKey: balanceKey });\n const previous = queryClient.getQueriesData<bigint>({ queryKey: balanceKey });\n for (const [key, value] of previous) {\n if (value === undefined) {\n continue;\n }\n // Temporary optimistic underflow (`amount > value`) is acceptable because\n // settlement invalidates and rewrites this cache entry.\n queryClient.setQueryData(key, mode === \"add\" ? value + amount : value - amount);\n }\n return previous;\n}\n\nexport function rollbackOptimisticBalanceDelta(\n queryClient: QueryClient,\n snapshot: OptimisticBalanceSnapshot,\n) {\n for (const [key, value] of snapshot) {\n queryClient.setQueryData(key, value);\n }\n}\n\n/**\n * Build optimistic mutation callbacks for shield operations.\n * Wraps the caller's `onMutate`/`onError`/`onSuccess`/`onSettled` with snapshot/rollback logic\n * and returns overrides ready to spread into `useMutation`.\n */\nexport function optimisticBalanceCallbacks<TParams extends { amount: bigint }>({\n optimistic,\n tokenAddress,\n queryClient,\n options,\n}: {\n optimistic: boolean | undefined;\n tokenAddress: Address;\n queryClient: QueryClient;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: UseMutationOptions<TransactionResult, Error, TParams, any> | undefined;\n}): Pick<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n UseMutationOptions<TransactionResult, Error, TParams, any>,\n \"onMutate\" | \"onError\" | \"onSuccess\" | \"onSettled\"\n> {\n return {\n onMutate: optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount: variables.amount,\n mode: \"add\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext, context);\n invalidateAfterShield(context.client, tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext, context);\n },\n };\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferParams,\n} from \"@zama-fhe/sdk/query\";\nimport {\n applyOptimisticBalanceDelta,\n rollbackOptimisticBalanceDelta,\n unwrapOptimisticCallerContext,\n} from \"./optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/** Configuration for {@link useConfidentialTransfer}. */\nexport interface UseConfidentialTransferConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically subtracts the transfer amount from cached balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Encrypt and send a confidential transfer. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * Set `optimistic: true` to subtract the amount from the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transfer = useConfidentialTransfer({\n * tokenAddress: \"0x...\",\n * optimistic: true,\n * });\n * transfer.mutate(\n * { to: \"0xRecipient\", amount: 1000n },\n * {\n * onError: (error) => {\n * if (error instanceof SigningRejectedError) {\n * // user cancelled — no action needed\n * }\n * },\n * },\n * );\n * ```\n */\nexport function useConfidentialTransfer<TContext = unknown>(\n config: UseConfidentialTransferConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n // Internal mutation uses `any` for TContext because optimistic mode wraps\n // the caller's context in OptimisticMutateContext; the public return type\n // is cast back to the caller's TContext.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return useMutation<TransactionResult, Error, ConfidentialTransferParams, any>({\n ...confidentialTransferMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress: config.tokenAddress,\n amount: variables.amount,\n mode: \"subtract\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n config.optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext as TContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as TContext, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext as TContext, context);\n },\n }) as UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext>;\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferFromMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferFromParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Operator transfer on behalf of another address. Caller must be an approved operator.\n * Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the transfer amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transferFrom = useConfidentialTransferFrom({ tokenAddress: \"0x...\" });\n * transferFrom.mutate({ from: \"0xOwner\", to: \"0xRecipient\", amount: 500n });\n * ```\n */\nexport function useConfidentialTransferFrom(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferFromParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialTransferFromParams, Address>({\n ...confidentialTransferFromMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialApproveMutationOptions,\n invalidateAfterApprove,\n type ConfidentialApproveParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Set operator approval for a confidential token. Defaults to 1 hour.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useConfidentialApprove({ tokenAddress: \"0x...\" });\n * approve.mutate({ spender: \"0xOperator\" });\n * ```\n */\nexport function useConfidentialApprove(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialApproveParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialApproveParams, Address>({\n ...confidentialApproveMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApprove(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialIsApprovedQueryOptions, signerAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\nexport { confidentialIsApprovedQueryOptions };\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig {\n /** Address of the confidential token contract. Pass `undefined` to disable the query. */\n tokenAddress: Address | undefined;\n /** Address to check approval for. Pass `undefined` to disable the query. */\n spender: Address | undefined;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/** Configuration for {@link useConfidentialIsApprovedSuspense}. */\nexport interface UseConfidentialIsApprovedSuspenseConfig extends UseZamaConfig {\n /** Address to check approval for. */\n spender: Address;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/**\n * Check if a spender is an approved operator for a given holder (defaults to connected wallet).\n *\n * @param config - Token address, spender, and optional holder to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApproved({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApproved(\n config: UseConfidentialIsApprovedConfig,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, spender, holder } = config;\n const sdk = useZamaSDK();\n const holderQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n enabled: tokenAddress !== undefined && spender !== undefined && holder === undefined,\n });\n const resolvedHolder = holder ?? holderQuery.data;\n const baseOpts = confidentialIsApprovedQueryOptions(sdk.signer, tokenAddress, {\n holder: resolvedHolder,\n spender,\n });\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useConfidentialIsApproved}.\n * Suspends rendering until the approval check resolves.\n *\n * @param config - Token address, spender, and optional holder to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApprovedSuspense({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig) {\n const { spender, holder, ...tokenConfig } = config;\n const token = useToken(tokenConfig);\n const addressQuery = useSuspenseQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const resolvedHolder = holder ?? addressQuery.data;\n\n return useSuspenseQuery<boolean>({\n ...confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n }),\n });\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport { shieldMutationOptions, type ShieldParams } from \"@zama-fhe/sdk/query\";\nimport { optimisticBalanceCallbacks } from \"./optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/** Configuration for {@link useShield}. */\nexport interface UseShieldConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield public ERC-20 tokens into confidential tokens.\n * Handles ERC-20 approval automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link ApprovalFailedError} — ERC-20 approval transaction failed\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shield = useShield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shield.mutate({ amount: 1000n });\n * ```\n */\nexport function useShield<TContext = unknown>(\n config: UseShieldConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ShieldParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation({\n ...shieldMutationOptions(token),\n ...options,\n ...optimisticBalanceCallbacks({\n optimistic: config.optimistic,\n tokenAddress: config.tokenAddress,\n queryClient,\n options,\n }),\n }) as UseMutationResult<TransactionResult, Error, ShieldParams, TContext>;\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport { shieldETHMutationOptions, type ShieldETHParams } from \"@zama-fhe/sdk/query\";\nimport { optimisticBalanceCallbacks } from \"./optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/** Configuration for {@link useShieldETH}. */\nexport interface UseShieldETHConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield native ETH into confidential tokens.\n * Handles wrapping automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shieldETH = useShieldETH({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shieldETH.mutate({ amount: 1000000000000000000n }); // 1 ETH\n * ```\n */\nexport function useShieldETH<TContext = unknown>(\n config: UseShieldETHConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldETHParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ShieldETHParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation({\n ...shieldETHMutationOptions(token),\n ...options,\n ...optimisticBalanceCallbacks({\n optimistic: config.optimistic,\n tokenAddress: config.tokenAddress,\n queryClient,\n options,\n }),\n }) as UseMutationResult<TransactionResult, Error, ShieldETHParams, TContext>;\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnwrap,\n type UnwrapParams,\n unwrapMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Request an unwrap for a specific amount. Encrypts the amount first.\n * Call {@link useFinalizeUnwrap} after the request is processed on-chain,\n * or use {@link useUnshield} for a single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the unwrap amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrap = useUnwrap({ tokenAddress: \"0x...\" });\n * unwrap.mutate({ amount: 500n });\n * ```\n */\nexport function useUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnwrapParams, Address>({\n ...unwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterUnwrap, unwrapAllMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Request an unwrap for the entire confidential balance.\n * Uses the on-chain balance handle directly (no encryption needed).\n * Call {@link useFinalizeUnwrap} after processing, or use {@link useUnshieldAll} for single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrapAll = useUnwrapAll({ tokenAddress: \"0x...\" });\n * unwrapAll.mutate();\n * ```\n */\nexport function useUnwrapAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, void, Address>({\n ...unwrapAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n finalizeUnwrapMutationOptions,\n invalidateAfterUnshield,\n type FinalizeUnwrapParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Complete an unwrap by providing the public decryption proof.\n * Call this after an unwrap request has been processed on-chain.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption of the burn amount failed\n * - {@link TransactionRevertedError} — on-chain finalize transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const finalize = useFinalizeUnwrap({ tokenAddress: \"0x...\" });\n * finalize.mutate({ burnAmountHandle: event.encryptedAmount });\n * ```\n */\nexport function useFinalizeUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, FinalizeUnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, FinalizeUnwrapParams, Address>({\n ...finalizeUnwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldParams,\n unshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Unshield a specific amount and finalize in one call.\n * Orchestrates: unwrap → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed during unwrap\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshield = useUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshield.mutate({ amount: 500n });\n * ```\n */\nexport function useUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldParams, Address>({\n ...unshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldAllParams,\n unshieldAllMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Unshield the entire balance and finalize in one call.\n * Orchestrates: unwrapAll → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshieldAll = useUnshieldAll({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshieldAll.mutate();\n * ```\n */\nexport function useUnshieldAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldAllParams | void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldAllParams | void, Address>({\n ...unshieldAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type ResumeUnshieldParams,\n resumeUnshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Resume an interrupted unshield from an existing unwrap tx hash.\n * Useful when the user submitted the unwrap but the finalize step was\n * interrupted (e.g. page reload, network error).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const resumeUnshield = useResumeUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * resumeUnshield.mutate({ unwrapTxHash: \"0xabc...\" });\n * ```\n */\nexport function useResumeUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ResumeUnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ResumeUnshieldParams, Address>({\n ...resumeUnshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { signerAddressQueryOptions, underlyingAllowanceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { underlyingAllowanceQueryOptions };\n\n/** Configuration for {@link useUnderlyingAllowance}. */\nexport interface UseUnderlyingAllowanceConfig {\n /** Address of the confidential token contract used to scope the query cache. */\n tokenAddress: Address;\n /** Address of the wrapper contract whose underlying ERC-20 allowance is checked. */\n wrapperAddress: Address;\n}\n\n/**\n * Read the underlying ERC-20 allowance granted to the wrapper contract.\n * Useful to check if an approval is needed before shielding.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (current allowance).\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowance({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowance(\n config: UseUnderlyingAllowanceConfig,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, wrapperAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data;\n\n const baseOpts = underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n });\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useUnderlyingAllowance}.\n * Suspends rendering until the allowance is loaded.\n *\n * @param config - Token and wrapper addresses.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowanceSuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowanceSuspense(config: UseUnderlyingAllowanceConfig) {\n const { tokenAddress, wrapperAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useSuspenseQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data;\n\n return useSuspenseQuery<bigint>({\n ...underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n }),\n });\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\n\n/**\n * Resolves the wrappers registry address for the current chain.\n * Uses the merged registry addresses from `sdk.registry` (built-in defaults\n * plus any `registryAddresses` overrides passed to `ZamaSDKConfig`).\n *\n * Returns `undefined` when the chain ID hasn't been fetched yet\n * or when no registry is configured for the connected chain.\n *\n * The chain ID is cached for 30 seconds (`staleTime`), so chain\n * switches may take up to 30s to reflect.\n */\nexport function useWrappersRegistryAddress(): Address | undefined {\n const sdk = useZamaSDK();\n\n const { data: chainId } = useQuery<number>({\n queryKey: zamaQueryKeys.wrappersRegistry.chainId(),\n queryFn: () => sdk.signer.getChainId(),\n staleTime: 30_000,\n });\n\n return chainId !== undefined ? sdk.registry.getAddress(chainId) : undefined;\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { wrapperDiscoveryQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"../wrappers-registry/use-wrappers-registry-address\";\n\nexport { wrapperDiscoveryQueryOptions };\n\n/** Configuration for {@link useWrapperDiscovery}. */\nexport interface UseWrapperDiscoveryConfig {\n /**\n * Address of any confidential token you control.\n * Used only to derive the signer context and to scope the query cache key —\n * it does not affect which wrapper the registry returns.\n */\n tokenAddress: Address;\n /** ERC-20 address to discover the wrapper for. Pass `undefined` to disable the query. */\n erc20Address: Address | undefined;\n}\n\n/** Configuration for {@link useWrapperDiscoverySuspense}. */\nexport interface UseWrapperDiscoverySuspenseConfig {\n /**\n * Address of any confidential token you control.\n * Used only to derive the signer context and to scope the query cache key —\n * it does not affect which wrapper the registry returns.\n */\n tokenAddress: Address;\n /** ERC-20 address to discover the wrapper for. */\n erc20Address: Address;\n}\n\n/**\n * Discover the confidential wrapper for an ERC-20 token via the on-chain registry.\n * Returns the wrapper address if one exists, or `null` if not.\n * Cached indefinitely since wrapper mappings are immutable.\n *\n * @param config - Token and ERC-20 addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscovery({\n * tokenAddress: \"0xConfidentialToken\",\n * erc20Address: \"0xUSDC\",\n * });\n * ```\n */\nexport function useWrapperDiscovery(\n config: UseWrapperDiscoveryConfig,\n options?: Omit<UseQueryOptions<Address | null>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, erc20Address } = config;\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n const baseOpts = wrapperDiscoveryQueryOptions(sdk.registry, {\n tokenAddress,\n erc20Address,\n registryAddress,\n });\n\n return useQuery<Address | null>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useWrapperDiscovery}.\n * Suspends rendering until the wrapper address is resolved.\n *\n * @param config - Token and ERC-20 addresses.\n * @returns Suspense query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscoverySuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * erc20Address: \"0xUSDC\",\n * });\n * ```\n */\nexport function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig) {\n const { tokenAddress, erc20Address } = config;\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useSuspenseQuery<Address | null>({\n ...wrapperDiscoveryQueryOptions(sdk.registry, {\n tokenAddress,\n erc20Address,\n registryAddress,\n }),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenMetadataQueryOptions, type TokenMetadata } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { type TokenMetadata };\n\n/**\n * Read ERC-20 token metadata (name, symbol, decimals).\n * Fetches all three in parallel. Cached indefinitely since metadata is immutable.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadata(\"0xToken\");\n * // metadata?.name, metadata?.symbol, metadata?.decimals\n * ```\n */\nexport function useMetadata(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<TokenMetadata>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useMetadata}.\n * Suspends rendering until metadata is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadataSuspense(\"0xToken\");\n * ```\n */\nexport function useMetadataSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { Address, RawLog, ActivityLogMetadata, ActivityItem } from \"@zama-fhe/sdk\";\nimport { activityFeedQueryOptions, deriveActivityFeedLogsKey } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/** Configuration for {@link useActivityFeed}. */\nexport interface UseActivityFeedConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Connected wallet address. Pass `undefined` to disable the query. */\n userAddress: Address | undefined;\n /** Raw event logs from the provider (viem, ethers, etc.). Pass `undefined` to disable. */\n logs: readonly (RawLog & Partial<ActivityLogMetadata>)[] | undefined;\n /** Whether to batch-decrypt encrypted transfer amounts. Default: `true`. */\n decrypt?: boolean;\n}\n\n/**\n * Two-phase activity feed hook.\n * Phase 1: Instantly parses raw logs into classified {@link ActivityItem}s (sync, cheap).\n * Phase 2: Batch-decrypts encrypted transfer amounts via the relayer (async).\n *\n * The wallet provides logs (from its own provider — viem, ethers, etc.)\n * and this hook normalizes + decrypts them.\n *\n * @param config - Token address, user address, raw logs, and decrypt option.\n * @returns Query result with `data: ActivityItem[]`.\n *\n * @example\n * ```tsx\n * const { data: activity } = useActivityFeed({\n * tokenAddress: \"0xToken\",\n * userAddress: \"0xUser\",\n * logs: rawLogs,\n * });\n * ```\n */\nexport function useActivityFeed(config: UseActivityFeedConfig) {\n const { tokenAddress, userAddress, logs, decrypt: decryptOpt } = config;\n const token = useReadonlyToken(tokenAddress);\n const decrypt = decryptOpt ?? true;\n const logsKey = deriveActivityFeedLogsKey(logs);\n\n return useQuery<ActivityItem[]>({\n ...activityFeedQueryOptions(token, {\n userAddress,\n logs,\n decrypt,\n logsKey,\n }),\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n delegateDecryptionMutationOptions,\n zamaQueryKeys,\n type DelegateDecryptionParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Delegate FHE decryption rights for a token to another address via the on-chain ACL.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const delegate = useDelegateDecryption({ tokenAddress: \"0x...\" });\n * delegate.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useDelegateDecryption(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, DelegateDecryptionParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, DelegateDecryptionParams>({\n ...delegateDecryptionMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n try {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n } finally {\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n revokeDelegationMutationOptions,\n zamaQueryKeys,\n type RevokeDelegationParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Revoke FHE decryption delegation for a token from a delegate address.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const revoke = useRevokeDelegation({ tokenAddress: \"0x...\" });\n * revoke.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useRevokeDelegation(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, RevokeDelegationParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, RevokeDelegationParams>({\n ...revokeDelegationMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n try {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n } finally {\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n }\n },\n });\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { delegationStatusQueryOptions, type DelegationStatusData } from \"@zama-fhe/sdk/query\";\nimport { useQuery } from \"../utils/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport interface UseDelegationStatusConfig {\n /** Address of the confidential token contract. Pass `undefined` to disable the query. */\n tokenAddress: Address | undefined;\n /** The address that granted the delegation. */\n delegatorAddress?: Address;\n /** The address that received delegation rights. */\n delegateAddress?: Address;\n}\n\n/**\n * Query delegation status between a delegator and delegate for a token.\n *\n * @param config - Token address, delegator, and delegate addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns `{ isDelegated, expiryTimestamp, isLoading, error }`.\n *\n * @example\n * ```tsx\n * const { data } = useDelegationStatus({\n * tokenAddress: \"0xToken\",\n * delegatorAddress: \"0xDelegator\",\n * delegateAddress: \"0xDelegate\",\n * });\n * // data?.isDelegated, data?.expiryTimestamp\n * ```\n */\nexport function useDelegationStatus(\n config: UseDelegationStatusConfig,\n options?: Omit<UseQueryOptions<DelegationStatusData>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = delegationStatusQueryOptions(sdk.signer, sdk.relayer, config.tokenAddress, {\n delegatorAddress: config.delegatorAddress,\n delegateAddress: config.delegateAddress,\n });\n\n return useQuery<DelegationStatusData>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { decryptBalanceAsMutationOptions, type DecryptBalanceAsParams } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/**\n * Decrypt another user's confidential balance as a delegate.\n *\n * @param tokenAddress - Address of the confidential token contract.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const decryptAs = useDecryptBalanceAs(\"0xToken\");\n * decryptAs.mutate({ delegatorAddress: \"0xDelegator\" });\n * // decryptAs.data => 1000n\n * ```\n */\nexport function useDecryptBalanceAs(\n tokenAddress: Address,\n options?: UseMutationOptions<bigint, Error, DecryptBalanceAsParams>,\n) {\n const readonlyToken = useReadonlyToken(tokenAddress);\n\n return useMutation<bigint, Error, DecryptBalanceAsParams>({\n ...decryptBalanceAsMutationOptions(readonlyToken),\n ...options,\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { ReadonlyToken, type Address, type BatchDecryptAsOptions } from \"@zama-fhe/sdk\";\n\n/**\n * Batch decrypt confidential balances as a delegate across multiple tokens.\n *\n * @param tokens - ReadonlyToken instances to decrypt balances for.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const batchDecryptAs = useBatchDecryptBalancesAs(tokens);\n * batchDecryptAs.mutate({\n * delegatorAddress: \"0xDelegator\",\n * });\n * // batchDecryptAs.data => Map { \"0xTokenA\" => 100n, \"0xTokenB\" => 200n }\n * ```\n */\nexport function useBatchDecryptBalancesAs(\n tokens: ReadonlyToken[],\n options?: UseMutationOptions<Map<Address, bigint>, Error, BatchDecryptAsOptions>,\n) {\n return useMutation<Map<Address, bigint>, Error, BatchDecryptAsOptions>({\n mutationKey: [\"zama.batchDecryptBalancesAs\", ...tokens.map((t) => t.address)] as const,\n mutationFn: async (params) => ReadonlyToken.batchDecryptBalancesAs(tokens, params),\n ...options,\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n approveUnderlyingMutationOptions,\n invalidateAfterApproveUnderlying,\n type ApproveUnderlyingParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Approve the wrapper contract to spend the underlying ERC-20.\n * Defaults to max uint256. Resets to zero first if there's an existing\n * non-zero allowance (required by tokens like USDT).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — approval transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useApproveUnderlying({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * approve.mutate({}); // max approval\n * approve.mutate({ amount: 1000n }); // exact amount\n * ```\n */\nexport function useApproveUnderlying(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ApproveUnderlyingParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ApproveUnderlyingParams, Address>({\n ...approveUnderlyingMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApproveUnderlying(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialQueryOptions, isWrapperQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { isConfidentialQueryOptions, isWrapperQueryOptions };\n\n/**\n * Check if a token supports the ERC-7984 confidential interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidential(\"0xToken\");\n * ```\n */\nexport function useIsConfidential(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean>({\n ...isConfidentialQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsConfidential}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidentialSuspense(\"0xToken\");\n * ```\n */\nexport function useIsConfidentialSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean>({\n ...isConfidentialQueryOptions(token.signer, tokenAddress),\n });\n}\n\n/**\n * Check if a token supports the ERC-7984 wrapper interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapper(\"0xToken\");\n * ```\n */\nexport function useIsWrapper(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean>({\n ...isWrapperQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsWrapper}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapperSuspense(\"0xToken\");\n * ```\n */\nexport function useIsWrapperSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean>({\n ...isWrapperQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { totalSupplyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { totalSupplyQueryOptions };\n\n/**\n * Read the total supply of a token.\n * Stale after 30 seconds to balance freshness and RPC cost.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupply(\"0xToken\");\n * ```\n */\nexport function useTotalSupply(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<bigint>({\n ...totalSupplyQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useTotalSupply}.\n * Suspends rendering until the total supply is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupplySuspense(\"0xToken\");\n * ```\n */\nexport function useTotalSupplySuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<bigint>({\n ...totalSupplyQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n batchTransferFeeQueryOptions,\n feeRecipientQueryOptions,\n shieldFeeQueryOptions,\n unshieldFeeQueryOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport {\n batchTransferFeeQueryOptions,\n feeRecipientQueryOptions,\n shieldFeeQueryOptions,\n unshieldFeeQueryOptions,\n};\n\n/** Configuration for {@link useShieldFee} and {@link useUnshieldFee}. */\nexport interface UseFeeConfig {\n /** Address of the fee manager contract. */\n feeManagerAddress: Address;\n /** Amount to calculate the fee for. */\n amount: bigint;\n /** Sender address. */\n from: Address;\n /** Receiver address. */\n to: Address;\n}\n\n/**\n * Read the shield fee for a given amount and address pair.\n *\n * @param config - Fee manager address, amount, from, and to.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useShieldFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useShieldFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = shieldFeeQueryOptions(sdk.signer, config);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the unshield fee for a given amount and address pair.\n *\n * @param config - Fee manager address, amount, from, and to.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useUnshieldFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useUnshieldFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = unshieldFeeQueryOptions(sdk.signer, config);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the batch transfer fee from the fee manager.\n *\n * @param feeManagerAddress - Address of the fee manager contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useBatchTransferFee(\"0xFeeManager\");\n * ```\n */\nexport function useBatchTransferFee(\n feeManagerAddress: Address,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = batchTransferFeeQueryOptions(sdk.signer, feeManagerAddress);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the fee recipient address from the fee manager.\n *\n * @param feeManagerAddress - Address of the fee manager contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address` (the fee recipient).\n *\n * @example\n * ```tsx\n * const { data: recipient } = useFeeRecipient(\"0xFeeManager\");\n * ```\n */\nexport function useFeeRecipient(\n feeManagerAddress: Address,\n options?: Omit<UseQueryOptions<Address>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = feeRecipientQueryOptions(sdk.signer, feeManagerAddress);\n\n return useQuery<Address>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches all token wrapper pairs from the ConfidentialTokenWrappersRegistry\n * contract on the current chain.\n */\nexport function useTokenPairsRegistry() {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly TokenWrapperPair[]>(\n tokenPairsQueryOptions(sdk.signer, {\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport { tokenPairsLengthQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Returns the total number of token wrapper pairs in the registry.\n */\nexport function useTokenPairsLength() {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<bigint>(\n tokenPairsLengthQueryOptions(sdk.signer, {\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairsSliceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches a range of token wrapper pairs from the registry (paginated).\n *\n * @param fromIndex - Start index (inclusive). Pass `undefined` to disable.\n * @param toIndex - End index (exclusive). Pass `undefined` to disable.\n */\nexport function useTokenPairsSlice({\n fromIndex,\n toIndex,\n}: {\n fromIndex: bigint | undefined;\n toIndex: bigint | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly TokenWrapperPair[]>(\n tokenPairsSliceQueryOptions(sdk.signer, {\n registryAddress,\n fromIndex,\n toIndex,\n }),\n );\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches a single token wrapper pair by index from the registry.\n *\n * @param index - Zero-based pair index. Pass `undefined` to disable.\n */\nexport function useTokenPair({ index }: { index: bigint | undefined }) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<TokenWrapperPair>(\n tokenPairQueryOptions(sdk.signer, {\n registryAddress,\n index,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialTokenAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Looks up the confidential token address for a given plain token address.\n */\nexport function useConfidentialTokenAddress({\n tokenAddress,\n}: {\n tokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly [boolean, Address]>(\n confidentialTokenAddressQueryOptions(sdk.signer, {\n registryAddress,\n tokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Looks up the plain token address for a given confidential token address.\n */\nexport function useTokenAddress({\n confidentialTokenAddress,\n}: {\n confidentialTokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly [boolean, Address]>(\n tokenAddressQueryOptions(sdk.signer, {\n registryAddress,\n confidentialTokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialTokenValidQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Checks whether a confidential token is registered and valid in the\n * on-chain wrappers registry.\n *\n * @param confidentialTokenAddress - The confidential token to check. Pass `undefined` to disable.\n */\nexport function useIsConfidentialTokenValid({\n confidentialTokenAddress,\n}: {\n confidentialTokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<boolean>(\n isConfidentialTokenValidQueryOptions(sdk.signer, {\n registryAddress,\n confidentialTokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type {\n TokenWrapperPair,\n TokenWrapperPairWithMetadata,\n PaginatedResult,\n} from \"@zama-fhe/sdk\";\nimport { listPairsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches paginated token wrapper pairs from the registry.\n *\n * @param options - Query options: `page` (1-indexed, default `1`), `pageSize` (default `100`), `metadata` (fetch on-chain metadata for both tokens, default `false`).\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListPairs({ page: 1, pageSize: 20 });\n * if (data) {\n * console.log(`${data.total} pairs, showing page ${data.page}`);\n * }\n * ```\n */\nexport function useListPairs({\n page = 1,\n pageSize = 100,\n metadata = false,\n}: {\n page?: number;\n pageSize?: number;\n metadata?: boolean;\n} = {}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n // Pass sdk.registry (a lazy singleton) so the class-level TTL cache is shared\n // across all queryFn executions — rather than constructing a new instance each time.\n return useQuery<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>>(\n listPairsQueryOptions(sdk.registry, {\n registryAddress,\n page,\n pageSize,\n metadata,\n }),\n );\n}\n"],"mappings":"k5MA4DA,MAAM,EAAiB,GAA8B,KAAK,CAY1D,SAAgB,GAAa,CAC3B,WACA,UACA,SACA,UACA,iBACA,aACA,aACA,oBACA,cACA,WACoB,CACpB,IAAM,EAAc,GAAgB,CAG9B,EAAa,EAAO,EAAQ,CAC5B,EAAuB,EAAO,EAAkB,CAEtD,MAAgB,CACd,EAAW,QAAU,EACrB,EAAqB,QAAU,GAC/B,CAEF,IAAM,EAA2B,MAE7B,GAAQ,UACJ,CACE,iBAAoB,EAAiC,EAAY,CACjE,oBAAuB,EAAiC,EAAY,CACpE,kBAAqB,EAAiC,EAAY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L,GAAqC,EAAI,OAAQ,CAC/C,kBACA,eACD,CAAC,CACH,CCbH,SAAgB,GAAgB,CAC9B,4BAGC,CACD,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAEpD,OAAOC,EACL,GAAyB,EAAI,OAAQ,CACnC,kBACA,2BACD,CAAC,CACH,CCVH,SAAgB,GAA4B,CAC1C,4BAGC,CACD,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAEpD,OAAOC,EACL,GAAqC,EAAI,OAAQ,CAC/C,kBACA,2BACD,CAAC,CACH,CCFH,SAAgB,GAAa,CAC3B,OAAO,EACP,WAAW,IACX,WAAW,IAKT,EAAE,CAAE,CACN,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAIpD,OAAOC,EACLC,GAAsB,EAAI,SAAU,CAClC,kBACA,OACA,WACA,WACD,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ZamaSDK","encryptMutationOptions","userDecryptMutationOptions","publicDecryptMutationOptions","generateKeypairMutationOptions","createEIP712MutationOptions","createDelegatedUserDecryptEIP712MutationOptions","delegatedUserDecryptMutationOptions","requestZKProofVerificationMutationOptions","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","useQueries","tanstack_useQueries","useQuery","publicKeyQueryOptions","useQuery","publicParamsQueryOptions","useQuery","zamaQueryKeys","useQueries","zamaQueryKeys","allowMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","isAllowedQueryOptions","zamaQueryKeys","revokeMutationOptions","zamaQueryKeys","revokeSessionMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","confidentialHandleQueryOptions","confidentialBalanceQueryOptions","useQuery","signerAddressQueryOptions","confidentialHandlesQueryOptions","confidentialBalancesQueryOptions","zamaQueryKeys","confidentialTransferMutationOptions","confidentialTransferFromMutationOptions","confidentialApproveMutationOptions","useQuery","signerAddressQueryOptions","confidentialIsApprovedQueryOptions","useSuspenseQuery","shieldMutationOptions","shieldETHMutationOptions","unwrapMutationOptions","unwrapAllMutationOptions","finalizeUnwrapMutationOptions","unshieldMutationOptions","unshieldAllMutationOptions","resumeUnshieldMutationOptions","useQuery","signerAddressQueryOptions","underlyingAllowanceQueryOptions","useSuspenseQuery","useQuery","zamaQueryKeys","wrapperDiscoveryQueryOptions","useQuery","useSuspenseQuery","useQuery","tokenMetadataQueryOptions","useSuspenseQuery","useQuery","activityFeedQueryOptions","delegateDecryptionMutationOptions","zamaQueryKeys","revokeDelegationMutationOptions","zamaQueryKeys","delegationStatusQueryOptions","useQuery","decryptBalanceAsMutationOptions","ReadonlyToken","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","shieldFeeQueryOptions","useQuery","unshieldFeeQueryOptions","batchTransferFeeQueryOptions","feeRecipientQueryOptions","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","listPairsQueryOptions"],"sources":["../src/provider.tsx","../src/relayer/use-encrypt.ts","../src/relayer/use-user-decrypt.ts","../src/relayer/use-public-decrypt.ts","../src/relayer/use-generate-keypair.ts","../src/relayer/use-create-eip712.ts","../src/relayer/use-create-delegated-user-decrypt-eip712.ts","../src/relayer/use-delegated-user-decrypt.ts","../src/relayer/use-request-zk-proof-verification.ts","../src/utils/query.ts","../src/relayer/use-public-key.ts","../src/relayer/use-public-params.ts","../src/relayer/use-user-decrypted-value.ts","../src/relayer/use-user-decrypted-values.ts","../src/authorization/use-allow.ts","../src/authorization/use-is-allowed.ts","../src/authorization/use-revoke.ts","../src/authorization/use-revoke-session.ts","../src/token/use-token.ts","../src/token/use-readonly-token.ts","../src/balance/use-confidential-balance.ts","../src/balance/use-confidential-balances.ts","../src/balance/optimistic-balance-update.ts","../src/transfer/use-confidential-transfer.ts","../src/transfer/use-confidential-transfer-from.ts","../src/transfer/use-confidential-approve.ts","../src/transfer/use-confidential-is-approved.ts","../src/shield/use-shield.ts","../src/shield/use-shield-eth.ts","../src/unwrap/use-unwrap.ts","../src/unwrap/use-unwrap-all.ts","../src/unwrap/use-finalize-unwrap.ts","../src/unshield/use-unshield.ts","../src/unshield/use-unshield-all.ts","../src/unshield/use-resume-unshield.ts","../src/shield/use-underlying-allowance.ts","../src/wrappers-registry/use-wrappers-registry-address.ts","../src/token/use-wrapper-discovery.ts","../src/token/use-metadata.ts","../src/balance/use-activity-feed.ts","../src/delegation/use-delegate-decryption.ts","../src/delegation/use-revoke-delegation.ts","../src/delegation/use-delegation-status.ts","../src/delegation/use-decrypt-balance-as.ts","../src/delegation/use-batch-decrypt-balances-as.ts","../src/shield/use-approve-underlying.ts","../src/token/use-is-confidential.ts","../src/token/use-total-supply.ts","../src/token/use-fees.ts","../src/wrappers-registry/use-token-pairs-registry.ts","../src/wrappers-registry/use-token-pairs-length.ts","../src/wrappers-registry/use-token-pairs-slice.ts","../src/wrappers-registry/use-token-pair.ts","../src/wrappers-registry/use-confidential-token-address.ts","../src/wrappers-registry/use-token-address.ts","../src/wrappers-registry/use-is-confidential-token-valid.ts","../src/wrappers-registry/use-list-pairs.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n Address,\n GenericSigner,\n GenericStorage,\n RelayerSDK,\n ZamaSDKEventListener,\n} from \"@zama-fhe/sdk\";\nimport { ZamaSDK } from \"@zama-fhe/sdk\";\nimport { invalidateWalletLifecycleQueries } from \"@zama-fhe/sdk/query\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\n/** Props for {@link ZamaProvider}. */\nexport interface ZamaProviderProps extends PropsWithChildren {\n /** FHE relayer backend (RelayerWeb for browser, RelayerNode for server). */\n relayer: RelayerSDK;\n /** Wallet signer (`ViemSigner`, `EthersSigner`, or custom {@link GenericSigner}). */\n signer: GenericSigner;\n /** Credential storage backend (IndexedDBStorage for browser, MemoryStorage for tests). */\n storage: GenericStorage;\n /**\n * Session storage for wallet signatures. Defaults to in-memory (lost on reload).\n * Pass a `chrome.storage.session`-backed store for web extensions.\n */\n sessionStorage?: GenericStorage;\n /**\n * How long the ML-KEM re-encryption keypair remains valid, in seconds.\n * Default: `86400` (1 day). Must be positive — `0` is rejected.\n */\n keypairTTL?: number;\n /**\n * Controls how long session signatures (EIP-712 wallet signatures) remain valid, in seconds.\n * Default: `2592000` (30 days).\n * - `0`: never persist — every operation triggers a signing prompt (high-security mode).\n * - Positive number: seconds until the session signature expires and requires re-authentication.\n */\n sessionTTL?: number;\n /**\n * Per-chain wrappers registry address overrides, merged on top of built-in defaults.\n * Use this for custom or local chains (e.g. Hardhat) where no default registry exists.\n */\n registryAddresses?: Record<number, Address>;\n /**\n * How long cached registry results remain valid, in seconds.\n * Default: `86400` (24 hours).\n */\n registryTTL?: number;\n /** Callback invoked on SDK lifecycle events. */\n onEvent?: ZamaSDKEventListener;\n}\n\nconst ZamaSDKContext = createContext<ZamaSDK | null>(null);\n\n/**\n * Provides a {@link ZamaSDK} instance to all descendant hooks.\n *\n * @example\n * ```tsx\n * <ZamaProvider relayer={relayer} signer={signer} storage={storage}>\n * <App />\n * </ZamaProvider>\n * ```\n */\nexport function ZamaProvider({\n children,\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses,\n registryTTL,\n onEvent,\n}: ZamaProviderProps) {\n const queryClient = useQueryClient();\n\n // Stabilize onEvent so an inline arrow doesn't recreate the SDK every render.\n const onEventRef = useRef(onEvent);\n const registryAddressesRef = useRef(registryAddresses);\n\n useEffect(() => {\n onEventRef.current = onEvent;\n registryAddressesRef.current = registryAddresses;\n });\n\n const signerLifecycleCallbacks = useMemo(\n () =>\n signer?.subscribe\n ? {\n onDisconnect: () => invalidateWalletLifecycleQueries(queryClient),\n onAccountChange: () => invalidateWalletLifecycleQueries(queryClient),\n onChainChange: () => invalidateWalletLifecycleQueries(queryClient),\n }\n : undefined,\n [queryClient, signer],\n );\n\n const sdk = useMemo(\n () =>\n new ZamaSDK({\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses: registryAddressesRef.current,\n registryTTL,\n onEvent: onEventRef.current,\n signerLifecycleCallbacks,\n }),\n [\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryTTL,\n signerLifecycleCallbacks,\n ],\n );\n\n // Clean up signer subscriptions on unmount without terminating the\n // caller-owned relayer. dispose() only unsubscribes from wallet events\n // and is idempotent.\n useEffect(() => () => sdk.dispose(), [sdk]);\n\n return <ZamaSDKContext.Provider value={sdk}>{children}</ZamaSDKContext.Provider>;\n}\n\n/**\n * Access the {@link ZamaSDK} instance from context.\n * Throws if called outside a {@link ZamaProvider} or when no signer is provided.\n *\n * @example\n * ```tsx\n * const sdk = useZamaSDK();\n * const token = sdk.createReadonlyToken(\"0x...\");\n * ```\n */\nexport function useZamaSDK(): ZamaSDK {\n const context = useContext(ZamaSDKContext);\n\n if (!context) {\n throw new Error(\n \"useZamaSDK must be used within a <ZamaProvider>. \" +\n \"Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.\",\n );\n }\n\n return context;\n}\n","\"use client\";\n\nimport type { EncryptParams, EncryptResult } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { encryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Encrypt a plaintext value using FHE.\n * Calls the relayer's `encrypt` method via a mutation.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link EncryptionFailedError} — FHE encryption failed\n *\n * @returns A mutation whose `mutate` accepts {@link EncryptParams}.\n *\n * @example\n * ```tsx\n * const encrypt = useEncrypt();\n * encrypt.mutate({ values: [{ value: 1000n, type: \"euint64\" }], contractAddress: \"0x...\", userAddress: \"0x...\" });\n * ```\n */\nexport function useEncrypt() {\n const sdk = useZamaSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(sdk));\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport type {\n DecryptHandle,\n UserDecryptCallbacks,\n UserDecryptMutationParams,\n} from \"@zama-fhe/sdk/query\";\nimport { userDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type {\n UserDecryptCallbacks as DecryptCallbacks,\n DecryptHandle,\n UserDecryptMutationParams as DecryptParams,\n};\n\n/** Configuration for {@link useUserDecrypt}. */\nexport type UseUserDecryptConfig = UserDecryptCallbacks;\n\n/**\n * High-level orchestration hook for user decryption.\n *\n * Reuses cached FHE credentials from `sdk.credentials` when available,\n * falling back to generating a fresh keypair + EIP-712 signature only when\n * no valid credentials exist. This avoids redundant wallet signature prompts.\n *\n * On success, populates the decryption cache so `useUserDecryptedValue` / `useUserDecryptedValues`\n * can read the results.\n *\n * @param config - Optional callbacks for step-by-step UX feedback.\n * @returns A mutation whose `mutate` accepts {@link UserDecryptMutationParams}.\n *\n * @example\n * ```tsx\n * const decrypt = useUserDecrypt({\n * onCredentialsReady: () => setStep(\"decrypting\"),\n * onDecrypted: (values) => console.log(values),\n * });\n * decrypt.mutate({\n * handles: [{ handle: \"0xHandle\", contractAddress: \"0xContract\" }],\n * });\n * ```\n */\nexport function useUserDecrypt(config?: UseUserDecryptConfig) {\n const sdk = useZamaSDK();\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptMutationParams>(\n userDecryptMutationOptions(sdk, config),\n );\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Handle, PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { publicDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using the network public key (no credential needed).\n * On success, populates the decryption cache so {@link useUserDecryptedValue} / {@link useUserDecryptedValues}\n * can read the results.\n *\n * @returns A mutation whose `mutate` accepts an array of handle strings.\n *\n * @example\n * ```tsx\n * const publicDecrypt = usePublicDecrypt();\n * publicDecrypt.mutate([\"0xHandle1\", \"0xHandle2\"]);\n * // publicDecrypt.data?.clearValues => { \"0xHandle1\": 500n, ... }\n * ```\n */\nexport function usePublicDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<PublicDecryptResult, Error, Handle[]>(publicDecryptMutationOptions(sdk));\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { generateKeypairMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Generate an FHE keypair via the relayer.\n * Returns a public/private key pair for use in decrypt authorization.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link RelayerRequestFailedError} — relayer keypair generation request failed\n *\n * @returns A mutation whose `mutate` takes no parameters.\n *\n * @example\n * ```tsx\n * const generateKeypair = useGenerateKeypair();\n * generateKeypair.mutate();\n * // generateKeypair.data?.publicKey, generateKeypair.data?.privateKey\n * ```\n */\nexport function useGenerateKeypair() {\n const sdk = useZamaSDK();\n return useMutation(generateKeypairMutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { EIP712TypedData } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { createEIP712MutationOptions } from \"@zama-fhe/sdk/query\";\nimport type { CreateEIP712Params } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type { CreateEIP712Params };\n\n/**\n * Create EIP-712 typed data for signing an FHE decrypt credential.\n * The returned typed data is signed by the wallet to authorize decryption.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateEIP712() {\n const sdk = useZamaSDK();\n return useMutation<EIP712TypedData, Error, CreateEIP712Params>(createEIP712MutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { KmsDelegatedUserDecryptEIP712Type } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { createDelegatedUserDecryptEIP712MutationOptions } from \"@zama-fhe/sdk/query\";\nimport type { CreateDelegatedUserDecryptEIP712Params } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type { CreateDelegatedUserDecryptEIP712Params };\n\n/**\n * Create EIP-712 typed data for a delegated user decrypt credential.\n * Used when one wallet authorizes another to decrypt on its behalf.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateDelegatedUserDecryptEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateDelegatedUserDecryptEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * delegatorAddress: \"0xDelegator\",\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateDelegatedUserDecryptEIP712() {\n const sdk = useZamaSDK();\n return useMutation<\n KmsDelegatedUserDecryptEIP712Type,\n Error,\n CreateDelegatedUserDecryptEIP712Params\n >(createDelegatedUserDecryptEIP712MutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { DelegatedUserDecryptParams, ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { delegatedUserDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using delegated user credentials.\n * Returns a map of handle → plaintext bigint.\n *\n * @returns A mutation whose `mutate` accepts {@link DelegatedUserDecryptParams}.\n *\n * @example\n * ```tsx\n * const decrypt = useDelegatedUserDecrypt();\n * decrypt.mutate({ handles: [\"0xHandle1\"], ...credentials });\n * // decrypt.data => { \"0xHandle1\": 1000n }\n * ```\n */\nexport function useDelegatedUserDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<Record<Handle, ClearValueType>, Error, DelegatedUserDecryptParams>(\n delegatedUserDecryptMutationOptions(sdk),\n );\n}\n","\"use client\";\n\nimport type { InputProofBytesType, ZKProofLike } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { requestZKProofVerificationMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Submit a ZK proof for on-chain verification.\n * Returns the input proof bytes for use in contract calls.\n *\n * @returns A mutation whose `mutate` accepts a {@link ZKProofLike}.\n *\n * @example\n * ```tsx\n * const verify = useRequestZKProofVerification();\n * verify.mutate(zkProof);\n * // verify.data => Uint8Array (input proof bytes)\n * ```\n */\nexport function useRequestZKProofVerification() {\n const sdk = useZamaSDK();\n return useMutation<InputProofBytesType, Error, ZKProofLike>(\n requestZKProofVerificationMutationOptions(sdk),\n );\n}\n","import {\n type DefaultError,\n type QueriesOptions,\n type QueriesResults,\n useQueries as tanstack_useQueries,\n useQuery as tanstack_useQuery,\n useSuspenseQuery as tanstack_useSuspenseQuery,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryOptions,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\n\n/**\n * Thin wrapper around TanStack's useQuery that injects our custom queryKeyHashFn.\n * Mirrors the wagmi pattern — the type safety boundary is at the factory and hook levels.\n *\n * Callers typically specify only `<TData>` (e.g. `useQuery<PublicKeyData>(...)`) while\n * factory options carry specific tuple keys (e.g. `readonly [\"zama.publicKey\"]`).\n * We erase the QueryKey param via `AnyKeyQueryOptions` so callers don't need to\n * spell out the key type — any QueryKey subtype is accepted.\n */\ntype AnyKeyQueryOptions<TData, TError> = UseQueryOptions<\n TData,\n TError,\n TData,\n // oxlint-disable-next-line typescript/no-explicit-any\n any\n>;\ntype AnyKeySuspenseOptions<TData, TError> = UseSuspenseQueryOptions<\n TData,\n TError,\n TData,\n // oxlint-disable-next-line typescript/no-explicit-any\n any\n>;\n\nexport function useQuery<TData = unknown, TError = DefaultError>(\n options: AnyKeyQueryOptions<TData, TError>,\n): UseQueryResult<TData, TError> {\n return tanstack_useQuery({\n ...options,\n queryKeyHashFn: hashFn,\n });\n}\n\nexport function useSuspenseQuery<TData = unknown, TError = DefaultError>(\n options: AnyKeySuspenseOptions<TData, TError>,\n): UseSuspenseQueryResult<TData, TError> {\n return tanstack_useSuspenseQuery({\n ...options,\n queryKeyHashFn: hashFn,\n });\n}\n\n/**\n * Thin wrapper around TanStack's useQueries that injects our custom queryKeyHashFn\n * on every query in the array.\n */\nexport function useQueries<\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>({\n queries,\n ...options\n}: {\n queries: readonly [...QueriesOptions<T>];\n combine?: (result: QueriesResults<T>) => TCombinedResult;\n subscribed?: boolean;\n}): TCombinedResult {\n return tanstack_useQueries({\n ...options,\n queries: queries.map((q) => ({\n ...q,\n queryKeyHashFn: hashFn,\n })) as [...QueriesOptions<T>],\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { publicKeyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicKeyQueryOptions };\n\n/** Shape of the FHE public key data returned by the relayer. */\nexport interface PublicKeyData {\n /** Unique identifier for this public key version. */\n publicKeyId: string;\n /** The raw FHE public key bytes. */\n publicKey: Uint8Array;\n}\n\n/**\n * Fetch the FHE network public key from the relayer.\n * Cached indefinitely since the key does not change during a session.\n *\n * @returns Query result with `data: PublicKeyData | null`.\n *\n * @example\n * ```tsx\n * const { data: publicKey } = usePublicKey();\n * // publicKey?.publicKeyId, publicKey?.publicKey\n * ```\n */\nexport function usePublicKey() {\n const sdk = useZamaSDK();\n return useQuery<PublicKeyData | null>({\n ...publicKeyQueryOptions(sdk),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { publicParamsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicParamsQueryOptions };\n\n/** Shape of the FHE public parameters returned by the relayer. */\nexport interface PublicParamsData {\n /** The raw public parameters bytes (WASM-ready). */\n publicParams: Uint8Array;\n /** Unique identifier for this public params version. */\n publicParamsId: string;\n}\n\n/**\n * Fetch FHE public parameters for a given bit size from the relayer.\n * Cached indefinitely since parameters do not change during a session.\n *\n * @param bits - The FHE bit size to fetch parameters for (e.g. 2048).\n * @returns Query result with `data: PublicParamsData | null`.\n *\n * @example\n * ```tsx\n * const { data: params } = usePublicParams(2048);\n * // params?.publicParams, params?.publicParamsId\n * ```\n */\nexport function usePublicParams(bits: number) {\n const sdk = useZamaSDK();\n return useQuery<PublicParamsData | null>({\n ...publicParamsQueryOptions(sdk, bits),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\n\n/**\n * Look up a single cached decrypted value by its handle.\n * Values are populated automatically when `useUserDecrypt` or `usePublicDecrypt` succeed.\n * You can also populate manually via queryClient.setQueryData(zamaQueryKeys.decryption.handle(handle), value).\n */\nexport function useUserDecryptedValue(handle: Handle | undefined) {\n return useQuery<ClearValueType>({\n queryKey: zamaQueryKeys.decryption.handle(handle ?? \"0x\"),\n queryFn: () => undefined as never,\n enabled: false,\n });\n}\n","\"use client\";\n\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useQueries } from \"../utils/query\";\n\n/**\n * Look up multiple cached decrypted values by their handles.\n * Values are populated automatically when `useUserDecrypt` or `usePublicDecrypt` succeed.\n */\nexport function useUserDecryptedValues(handles: Handle[]) {\n const results = useQueries({\n queries: handles.map((handle) => ({\n queryKey: zamaQueryKeys.decryption.handle(handle),\n queryFn: () => undefined as never,\n enabled: false,\n })),\n });\n\n const data: Record<Handle, ClearValueType | undefined> = {};\n for (let i = 0; i < handles.length; i++) {\n data[handles[i]!] = results[i]!.data as ClearValueType | undefined;\n }\n\n return {\n data,\n results,\n };\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { allowMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Sign an EIP-712 message authorizing decryption of confidential handles\n * for a list of contract addresses. This is not token-specific — any\n * contract that uses FHE-encrypted values (tokens, DeFi vaults, games, etc.)\n * can be authorized in a single wallet signature. Subsequent decrypt\n * operations on any of these contracts reuse cached credentials.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link KeypairExpiredError} — the re-encryption keypair has expired\n *\n * @example\n * ```tsx\n * const { mutateAsync: allow, isPending } = useAllow();\n *\n * // Authorize decryption for any contracts with encrypted state:\n * // confidential tokens, auction contracts, governance contracts, etc.\n * await allow([tokenAddress, auctionAddress, governanceAddress]);\n * ```\n */\nexport function useAllow(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...allowMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { skipToken } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n isAllowedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Check whether a session signature is cached for the connected wallet.\n * Returns `true` if decrypt operations can proceed without a wallet prompt.\n *\n * @example\n * ```tsx\n * const { data: allowed } = useIsAllowed();\n * ```\n */\nexport function useIsAllowed() {\n const sdk = useZamaSDK();\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n const account = addressQuery.data;\n const baseOpts = account\n ? isAllowedQueryOptions(sdk, { account })\n : ({\n queryKey: zamaQueryKeys.isAllowed.all,\n queryFn: skipToken,\n enabled: false,\n } as const);\n\n return useQuery<boolean>(baseOpts);\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { revokeMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke stored FHE decrypt credentials for a list of contract addresses.\n * This is not token-specific — it revokes the EIP-712 authorization for\n * any contract that uses FHE-encrypted values. The next decrypt operation\n * on these contracts will require a fresh wallet signature.\n *\n * @example\n * ```tsx\n * const { mutate: revoke } = useRevoke();\n *\n * // Revoke for any contracts: tokens, auctions, governance, etc.\n * revoke([tokenAddress, auctionAddress]);\n * ```\n */\nexport function useRevoke(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...revokeMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { revokeSessionMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke the session signature for the connected wallet without\n * specifying contract addresses. Useful for wallet disconnect handlers.\n *\n * @example\n * ```tsx\n * const { mutate: revokeSession } = useRevokeSession();\n * revokeSession();\n * ```\n */\nexport function useRevokeSession(options?: UseMutationOptions<void>) {\n const sdk = useZamaSDK();\n\n return useMutation<void>({\n ...revokeSessionMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Base configuration shared by all mutation hooks that need a Token instance. */\nexport interface UseZamaConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Address of the wrapper contract (required for shield/unshield operations). */\n wrapperAddress?: Address;\n}\n\n/**\n * Get a {@link Token} instance, memoized by address pair.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param config - Token and optional wrapper addresses.\n * @returns A memoized `Token` instance.\n *\n * @example\n * ```tsx\n * const token = useToken({ tokenAddress: \"0xToken\", wrapperAddress: \"0xWrapper\" });\n * ```\n */\nexport function useToken(config: UseZamaConfig) {\n const sdk = useZamaSDK();\n\n return useMemo(\n () => sdk.createToken(config.tokenAddress, config.wrapperAddress),\n [sdk, config.tokenAddress, config.wrapperAddress],\n );\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Get a {@link ReadonlyToken} instance, memoized by address.\n * Supports balance queries, ERC-165 checks, and authorization — no wrapper needed.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param address - Address of the confidential token contract.\n * @returns A memoized `ReadonlyToken` instance.\n *\n * @example\n * ```tsx\n * const token = useReadonlyToken(\"0xToken\");\n * // token.balanceOf(), token.isConfidential(), etc.\n * ```\n */\nexport function useReadonlyToken(address: Address) {\n const sdk = useZamaSDK();\n\n return useMemo(() => sdk.createReadonlyToken(address), [sdk, address]);\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryOptions,\n confidentialHandleQueryOptions,\n signerAddressQueryOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\n\n/** Configuration for {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Polling interval (ms) for the encrypted handle. Default: 10 000. */\n handleRefetchInterval?: number;\n}\n\n/** Query options for the decrypt phase of {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceOptions extends Omit<\n UseQueryOptions<bigint>,\n \"queryKey\" | \"queryFn\" | \"enabled\"\n> {\n /** Whether the query is enabled. Callback form is not supported in composite hooks. */\n enabled?: boolean;\n}\n\n/**\n * Declarative hook to read the connected wallet's confidential token balance.\n * Uses two-phase polling: cheaply polls the encrypted handle, then only\n * decrypts when the handle changes (new balance).\n *\n * @param config - Token address and optional polling interval.\n * @param options - React Query options forwarded to the decrypt query.\n * @returns The decrypt query result plus `handleQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data: balance, isLoading, handleQuery } = useConfidentialBalance({\n * tokenAddress: \"0x...\",\n * });\n * ```\n */\nexport function useConfidentialBalance(\n config: UseConfidentialBalanceConfig,\n options?: UseConfidentialBalanceOptions,\n) {\n const { tokenAddress, handleRefetchInterval } = config;\n const { enabled = true } = options ?? {};\n const token = useReadonlyToken(tokenAddress);\n\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n\n const owner = addressQuery.data;\n\n // Phase 1: Poll the encrypted handle (cheap RPC read, no signing)\n const baseHandleQueryOptions = confidentialHandleQueryOptions(token.signer, tokenAddress, {\n owner,\n pollingInterval: handleRefetchInterval,\n });\n const handleQuery = useQuery<Handle>({\n ...baseHandleQueryOptions,\n enabled: baseHandleQueryOptions.enabled && enabled,\n });\n\n // Phase 2: Decrypt only when handle changes (expensive relayer roundtrip)\n const handle = handleQuery.data;\n const baseBalanceQueryOptions = confidentialBalanceQueryOptions(token, {\n handle,\n owner,\n });\n const balanceQuery = useQuery<bigint>({\n ...baseBalanceQueryOptions,\n ...options,\n enabled: baseBalanceQueryOptions.enabled && enabled,\n });\n\n return { ...balanceQuery, handleQuery };\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport { useQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalancesQueryOptions,\n confidentialHandlesQueryOptions,\n signerAddressQueryOptions,\n type ConfidentialBalancesData,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Configuration for {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesConfig {\n /** Addresses of the confidential token contracts to batch-query. */\n tokenAddresses: Address[];\n /** Polling interval (ms) for the encrypted handles. Default: 10 000. */\n handleRefetchInterval?: number;\n /** Maximum number of concurrent decrypt calls. Default: `Infinity` (no limit). */\n maxConcurrency?: number;\n}\n\nexport type { ConfidentialBalancesData };\n\n/** Query options for the decrypt phase of {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesOptions extends Omit<\n UseQueryOptions<ConfidentialBalancesData>,\n \"queryKey\" | \"queryFn\" | \"enabled\"\n> {\n /** Whether the query is enabled. Callback form is not supported in composite hooks. */\n enabled?: boolean;\n}\n\n/**\n * Declarative hook to read multiple confidential token balances in batch.\n * Uses two-phase polling: cheaply polls encrypted handles, then only\n * decrypts when any handle changes.\n *\n * Returns partial results when some tokens fail — successful balances are\n * always returned alongside per-token error information.\n *\n * @param config - Token addresses and optional polling interval.\n * @param options - React Query options forwarded to the decrypt query.\n * @returns The decrypt query result plus `handlesQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data } = useConfidentialBalances({\n * tokenAddresses: [\"0xTokenA\", \"0xTokenB\"],\n * });\n * const balance = data?.balances.get(\"0xTokenA\");\n * if (data?.isPartialError) {\n * // some tokens failed — check data.errors\n * }\n * ```\n */\nexport function useConfidentialBalances(\n config: UseConfidentialBalancesConfig,\n options?: UseConfidentialBalancesOptions,\n) {\n const { tokenAddresses, handleRefetchInterval, maxConcurrency } = config;\n const { enabled = true } = options ?? {};\n const sdk = useZamaSDK();\n\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n\n const owner = addressQuery.data;\n\n const tokens = useMemo(\n () => tokenAddresses.map((addr) => sdk.createReadonlyToken(addr)),\n [sdk, tokenAddresses],\n );\n\n // Phase 1: Poll all encrypted handles (cheap RPC reads)\n const baseHandlesQueryOptions = confidentialHandlesQueryOptions(sdk.signer, tokenAddresses, {\n owner,\n pollingInterval: handleRefetchInterval,\n });\n const handlesQuery = useQuery<Handle[]>({\n ...baseHandlesQueryOptions,\n enabled: baseHandlesQueryOptions.enabled && enabled,\n });\n\n // Phase 2: Batch decrypt only when any handle changes\n const handles = handlesQuery.data;\n const handlesReady = Array.isArray(handles) && handles.length === tokenAddresses.length;\n const baseBalancesQueryOptions = confidentialBalancesQueryOptions(tokens, {\n owner,\n handles,\n maxConcurrency,\n resultAddresses: tokenAddresses,\n });\n const factoryEnabled = baseBalancesQueryOptions.enabled ?? true;\n\n const balancesQuery = useQuery<ConfidentialBalancesData>({\n ...baseBalancesQueryOptions,\n ...options,\n enabled: factoryEnabled && handlesReady && enabled,\n });\n\n return { ...balancesQuery, handlesQuery };\n}\n","import type { QueryClient, QueryKey, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterShield, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\n\ntype BalanceDeltaMode = \"add\" | \"subtract\";\nexport type OptimisticBalanceSnapshot = [QueryKey, bigint | undefined][];\n\n/** Combined context returned by optimistic `onMutate`. */\nexport interface OptimisticMutateContext {\n snapshot: OptimisticBalanceSnapshot;\n callerContext?: unknown;\n}\n\nexport function unwrapOptimisticCallerContext(\n optimistic: boolean | undefined,\n rawContext: unknown,\n): {\n wrappedContext: OptimisticMutateContext | undefined;\n callerContext: OptimisticMutateContext | undefined;\n} {\n const typed = rawContext as OptimisticMutateContext | undefined;\n const wrappedContext = optimistic ? typed : undefined;\n const callerContext = (optimistic ? wrappedContext?.callerContext : rawContext) as\n | OptimisticMutateContext\n | undefined;\n return { wrappedContext, callerContext };\n}\n\nexport async function applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount,\n mode,\n}: {\n queryClient: QueryClient;\n tokenAddress: Address;\n amount: bigint;\n mode: BalanceDeltaMode;\n}): Promise<OptimisticBalanceSnapshot> {\n const balanceKey = zamaQueryKeys.confidentialBalance.token(tokenAddress);\n await queryClient.cancelQueries({ queryKey: balanceKey });\n const previous = queryClient.getQueriesData<bigint>({ queryKey: balanceKey });\n for (const [key, value] of previous) {\n if (value === undefined) {\n continue;\n }\n // Temporary optimistic underflow (`amount > value`) is acceptable because\n // settlement invalidates and rewrites this cache entry.\n queryClient.setQueryData(key, mode === \"add\" ? value + amount : value - amount);\n }\n return previous;\n}\n\nexport function rollbackOptimisticBalanceDelta(\n queryClient: QueryClient,\n snapshot: OptimisticBalanceSnapshot,\n) {\n for (const [key, value] of snapshot) {\n queryClient.setQueryData(key, value);\n }\n}\n\n/**\n * Build optimistic mutation callbacks for shield operations.\n * Wraps the caller's `onMutate`/`onError`/`onSuccess`/`onSettled` with snapshot/rollback logic\n * and returns overrides ready to spread into `useMutation`.\n */\nexport function optimisticBalanceCallbacks<TParams extends { amount: bigint }>({\n optimistic,\n tokenAddress,\n queryClient,\n options,\n}: {\n optimistic: boolean | undefined;\n tokenAddress: Address;\n queryClient: QueryClient;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: UseMutationOptions<TransactionResult, Error, TParams, any> | undefined;\n}): Pick<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n UseMutationOptions<TransactionResult, Error, TParams, any>,\n \"onMutate\" | \"onError\" | \"onSuccess\" | \"onSettled\"\n> {\n return {\n onMutate: optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount: variables.amount,\n mode: \"add\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext, context);\n invalidateAfterShield(context.client, tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext, context);\n },\n };\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferParams,\n} from \"@zama-fhe/sdk/query\";\nimport {\n applyOptimisticBalanceDelta,\n rollbackOptimisticBalanceDelta,\n unwrapOptimisticCallerContext,\n} from \"../balance/optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/** Configuration for {@link useConfidentialTransfer}. */\nexport interface UseConfidentialTransferConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically subtracts the transfer amount from cached balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Encrypt and send a confidential transfer. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * Set `optimistic: true` to subtract the amount from the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transfer = useConfidentialTransfer({\n * tokenAddress: \"0x...\",\n * optimistic: true,\n * });\n * transfer.mutate(\n * { to: \"0xRecipient\", amount: 1000n },\n * {\n * onError: (error) => {\n * if (error instanceof SigningRejectedError) {\n * // user cancelled — no action needed\n * }\n * },\n * },\n * );\n * ```\n */\nexport function useConfidentialTransfer<TContext = unknown>(\n config: UseConfidentialTransferConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n // Internal mutation uses `any` for TContext because optimistic mode wraps\n // the caller's context in OptimisticMutateContext; the public return type\n // is cast back to the caller's TContext.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return useMutation<TransactionResult, Error, ConfidentialTransferParams, any>({\n ...confidentialTransferMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress: config.tokenAddress,\n amount: variables.amount,\n mode: \"subtract\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n config.optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext as TContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as TContext, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext as TContext, context);\n },\n }) as UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext>;\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferFromMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferFromParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Operator transfer on behalf of another address. Caller must be an approved operator.\n * Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the transfer amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transferFrom = useConfidentialTransferFrom({ tokenAddress: \"0x...\" });\n * transferFrom.mutate({ from: \"0xOwner\", to: \"0xRecipient\", amount: 500n });\n * ```\n */\nexport function useConfidentialTransferFrom(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferFromParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialTransferFromParams, Address>({\n ...confidentialTransferFromMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialApproveMutationOptions,\n invalidateAfterApprove,\n type ConfidentialApproveParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Set operator approval for a confidential token. Defaults to 1 hour.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useConfidentialApprove({ tokenAddress: \"0x...\" });\n * approve.mutate({ spender: \"0xOperator\" });\n * ```\n */\nexport function useConfidentialApprove(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialApproveParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialApproveParams, Address>({\n ...confidentialApproveMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApprove(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialIsApprovedQueryOptions, signerAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\nexport { confidentialIsApprovedQueryOptions };\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig {\n /** Address of the confidential token contract. Pass `undefined` to disable the query. */\n tokenAddress: Address | undefined;\n /** Address to check approval for. Pass `undefined` to disable the query. */\n spender: Address | undefined;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/** Configuration for {@link useConfidentialIsApprovedSuspense}. */\nexport interface UseConfidentialIsApprovedSuspenseConfig extends UseZamaConfig {\n /** Address to check approval for. */\n spender: Address;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/**\n * Check if a spender is an approved operator for a given holder (defaults to connected wallet).\n *\n * @param config - Token address, spender, and optional holder to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApproved({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApproved(\n config: UseConfidentialIsApprovedConfig,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, spender, holder } = config;\n const sdk = useZamaSDK();\n const holderQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n enabled: tokenAddress !== undefined && spender !== undefined && holder === undefined,\n });\n const resolvedHolder = holder ?? holderQuery.data;\n const baseOpts = confidentialIsApprovedQueryOptions(sdk.signer, tokenAddress, {\n holder: resolvedHolder,\n spender,\n });\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useConfidentialIsApproved}.\n * Suspends rendering until the approval check resolves.\n *\n * @param config - Token address, spender, and optional holder to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApprovedSuspense({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig) {\n const { spender, holder, ...tokenConfig } = config;\n const token = useToken(tokenConfig);\n const addressQuery = useSuspenseQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const resolvedHolder = holder ?? addressQuery.data;\n\n return useSuspenseQuery<boolean>({\n ...confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n }),\n });\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport { shieldMutationOptions, type ShieldParams } from \"@zama-fhe/sdk/query\";\nimport { optimisticBalanceCallbacks } from \"../balance/optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/** Configuration for {@link useShield}. */\nexport interface UseShieldConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield public ERC-20 tokens into confidential tokens.\n * Handles ERC-20 approval automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link ApprovalFailedError} — ERC-20 approval transaction failed\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shield = useShield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shield.mutate({ amount: 1000n });\n * ```\n */\nexport function useShield<TContext = unknown>(\n config: UseShieldConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ShieldParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation({\n ...shieldMutationOptions(token),\n ...options,\n ...optimisticBalanceCallbacks({\n optimistic: config.optimistic,\n tokenAddress: config.tokenAddress,\n queryClient,\n options,\n }),\n }) as UseMutationResult<TransactionResult, Error, ShieldParams, TContext>;\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport { shieldETHMutationOptions, type ShieldETHParams } from \"@zama-fhe/sdk/query\";\nimport { optimisticBalanceCallbacks } from \"../balance/optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/** Configuration for {@link useShieldETH}. */\nexport interface UseShieldETHConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield native ETH into confidential tokens.\n * Handles wrapping automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shieldETH = useShieldETH({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shieldETH.mutate({ amount: 1000000000000000000n }); // 1 ETH\n * ```\n */\nexport function useShieldETH<TContext = unknown>(\n config: UseShieldETHConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldETHParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ShieldETHParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation({\n ...shieldETHMutationOptions(token),\n ...options,\n ...optimisticBalanceCallbacks({\n optimistic: config.optimistic,\n tokenAddress: config.tokenAddress,\n queryClient,\n options,\n }),\n }) as UseMutationResult<TransactionResult, Error, ShieldETHParams, TContext>;\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnwrap,\n type UnwrapParams,\n unwrapMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Request an unwrap for a specific amount. Encrypts the amount first.\n * Call {@link useFinalizeUnwrap} after the request is processed on-chain,\n * or use {@link useUnshield} for a single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the unwrap amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrap = useUnwrap({ tokenAddress: \"0x...\" });\n * unwrap.mutate({ amount: 500n });\n * ```\n */\nexport function useUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnwrapParams, Address>({\n ...unwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterUnwrap, unwrapAllMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Request an unwrap for the entire confidential balance.\n * Uses the on-chain balance handle directly (no encryption needed).\n * Call {@link useFinalizeUnwrap} after processing, or use {@link useUnshieldAll} for single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrapAll = useUnwrapAll({ tokenAddress: \"0x...\" });\n * unwrapAll.mutate();\n * ```\n */\nexport function useUnwrapAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, void, Address>({\n ...unwrapAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n finalizeUnwrapMutationOptions,\n invalidateAfterUnshield,\n type FinalizeUnwrapParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Complete an unwrap by providing the public decryption proof.\n * Call this after an unwrap request has been processed on-chain.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption of the burn amount failed\n * - {@link TransactionRevertedError} — on-chain finalize transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const finalize = useFinalizeUnwrap({ tokenAddress: \"0x...\" });\n * finalize.mutate({ burnAmountHandle: event.encryptedAmount });\n * ```\n */\nexport function useFinalizeUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, FinalizeUnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, FinalizeUnwrapParams, Address>({\n ...finalizeUnwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldParams,\n unshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Unshield a specific amount and finalize in one call.\n * Orchestrates: unwrap → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed during unwrap\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshield = useUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshield.mutate({ amount: 500n });\n * ```\n */\nexport function useUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldParams, Address>({\n ...unshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldAllParams,\n unshieldAllMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Unshield the entire balance and finalize in one call.\n * Orchestrates: unwrapAll → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshieldAll = useUnshieldAll({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshieldAll.mutate();\n * ```\n */\nexport function useUnshieldAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldAllParams | void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldAllParams | void, Address>({\n ...unshieldAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type ResumeUnshieldParams,\n resumeUnshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Resume an interrupted unshield from an existing unwrap tx hash.\n * Useful when the user submitted the unwrap but the finalize step was\n * interrupted (e.g. page reload, network error).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const resumeUnshield = useResumeUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * resumeUnshield.mutate({ unwrapTxHash: \"0xabc...\" });\n * ```\n */\nexport function useResumeUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ResumeUnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ResumeUnshieldParams, Address>({\n ...resumeUnshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { signerAddressQueryOptions, underlyingAllowanceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\n\nexport { underlyingAllowanceQueryOptions };\n\n/** Configuration for {@link useUnderlyingAllowance}. */\nexport interface UseUnderlyingAllowanceConfig {\n /** Address of the confidential token contract used to scope the query cache. */\n tokenAddress: Address;\n /** Address of the wrapper contract whose underlying ERC-20 allowance is checked. */\n wrapperAddress: Address;\n}\n\n/**\n * Read the underlying ERC-20 allowance granted to the wrapper contract.\n * Useful to check if an approval is needed before shielding.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (current allowance).\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowance({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowance(\n config: UseUnderlyingAllowanceConfig,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, wrapperAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data;\n\n const baseOpts = underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n });\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useUnderlyingAllowance}.\n * Suspends rendering until the allowance is loaded.\n *\n * @param config - Token and wrapper addresses.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowanceSuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowanceSuspense(config: UseUnderlyingAllowanceConfig) {\n const { tokenAddress, wrapperAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useSuspenseQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data;\n\n return useSuspenseQuery<bigint>({\n ...underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n }),\n });\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\n\n/**\n * Resolves the wrappers registry address for the current chain.\n * Uses the merged registry addresses from `sdk.registry` (built-in defaults\n * plus any `registryAddresses` overrides passed to `ZamaSDKConfig`).\n *\n * Returns `undefined` when the chain ID hasn't been fetched yet\n * or when no registry is configured for the connected chain.\n *\n * The chain ID is cached for 30 seconds (`staleTime`), so chain\n * switches may take up to 30s to reflect.\n */\nexport function useWrappersRegistryAddress(): Address | undefined {\n const sdk = useZamaSDK();\n\n const { data: chainId } = useQuery<number>({\n queryKey: zamaQueryKeys.wrappersRegistry.chainId(),\n queryFn: () => sdk.signer.getChainId(),\n staleTime: 30_000,\n });\n\n return chainId !== undefined ? sdk.registry.getAddress(chainId) : undefined;\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { wrapperDiscoveryQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"../wrappers-registry/use-wrappers-registry-address\";\n\nexport { wrapperDiscoveryQueryOptions };\n\n/** Configuration for {@link useWrapperDiscovery}. */\nexport interface UseWrapperDiscoveryConfig {\n /**\n * Address of any confidential token you control.\n * Used only to derive the signer context and to scope the query cache key —\n * it does not affect which wrapper the registry returns.\n */\n tokenAddress: Address;\n /** ERC-20 address to discover the wrapper for. Pass `undefined` to disable the query. */\n erc20Address: Address | undefined;\n}\n\n/** Configuration for {@link useWrapperDiscoverySuspense}. */\nexport interface UseWrapperDiscoverySuspenseConfig {\n /**\n * Address of any confidential token you control.\n * Used only to derive the signer context and to scope the query cache key —\n * it does not affect which wrapper the registry returns.\n */\n tokenAddress: Address;\n /** ERC-20 address to discover the wrapper for. */\n erc20Address: Address;\n}\n\n/**\n * Discover the confidential wrapper for an ERC-20 token via the on-chain registry.\n * Returns the wrapper address if one exists, or `null` if not.\n * Cached indefinitely since wrapper mappings are immutable.\n *\n * @param config - Token and ERC-20 addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscovery({\n * tokenAddress: \"0xConfidentialToken\",\n * erc20Address: \"0xUSDC\",\n * });\n * ```\n */\nexport function useWrapperDiscovery(\n config: UseWrapperDiscoveryConfig,\n options?: Omit<UseQueryOptions<Address | null>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, erc20Address } = config;\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n const baseOpts = wrapperDiscoveryQueryOptions(sdk.registry, {\n tokenAddress,\n erc20Address,\n registryAddress,\n });\n\n return useQuery<Address | null>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useWrapperDiscovery}.\n * Suspends rendering until the wrapper address is resolved.\n *\n * @param config - Token and ERC-20 addresses.\n * @returns Suspense query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscoverySuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * erc20Address: \"0xUSDC\",\n * });\n * ```\n */\nexport function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig) {\n const { tokenAddress, erc20Address } = config;\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useSuspenseQuery<Address | null>({\n ...wrapperDiscoveryQueryOptions(sdk.registry, {\n tokenAddress,\n erc20Address,\n registryAddress,\n }),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenMetadataQueryOptions, type TokenMetadata } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { type TokenMetadata };\n\n/**\n * Read ERC-20 token metadata (name, symbol, decimals).\n * Fetches all three in parallel. Cached indefinitely since metadata is immutable.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadata(\"0xToken\");\n * // metadata?.name, metadata?.symbol, metadata?.decimals\n * ```\n */\nexport function useMetadata(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<TokenMetadata>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useMetadata}.\n * Suspends rendering until metadata is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadataSuspense(\"0xToken\");\n * ```\n */\nexport function useMetadataSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { Address, RawLog, ActivityLogMetadata, ActivityItem } from \"@zama-fhe/sdk\";\nimport { activityFeedQueryOptions, deriveActivityFeedLogsKey } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\n\n/** Configuration for {@link useActivityFeed}. */\nexport interface UseActivityFeedConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Connected wallet address. Pass `undefined` to disable the query. */\n userAddress: Address | undefined;\n /** Raw event logs from the provider (viem, ethers, etc.). Pass `undefined` to disable. */\n logs: readonly (RawLog & Partial<ActivityLogMetadata>)[] | undefined;\n /** Whether to batch-decrypt encrypted transfer amounts. Default: `true`. */\n decrypt?: boolean;\n}\n\n/**\n * Two-phase activity feed hook.\n * Phase 1: Instantly parses raw logs into classified {@link ActivityItem}s (sync, cheap).\n * Phase 2: Batch-decrypts encrypted transfer amounts via the relayer (async).\n *\n * The wallet provides logs (from its own provider — viem, ethers, etc.)\n * and this hook normalizes + decrypts them.\n *\n * @param config - Token address, user address, raw logs, and decrypt option.\n * @returns Query result with `data: ActivityItem[]`.\n *\n * @example\n * ```tsx\n * const { data: activity } = useActivityFeed({\n * tokenAddress: \"0xToken\",\n * userAddress: \"0xUser\",\n * logs: rawLogs,\n * });\n * ```\n */\nexport function useActivityFeed(config: UseActivityFeedConfig) {\n const { tokenAddress, userAddress, logs, decrypt: decryptOpt } = config;\n const token = useReadonlyToken(tokenAddress);\n const decrypt = decryptOpt ?? true;\n const logsKey = deriveActivityFeedLogsKey(logs);\n\n return useQuery<ActivityItem[]>({\n ...activityFeedQueryOptions(token, {\n userAddress,\n logs,\n decrypt,\n logsKey,\n }),\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n delegateDecryptionMutationOptions,\n zamaQueryKeys,\n type DelegateDecryptionParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Delegate FHE decryption rights for a token to another address via the on-chain ACL.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const delegate = useDelegateDecryption({ tokenAddress: \"0x...\" });\n * delegate.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useDelegateDecryption(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, DelegateDecryptionParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, DelegateDecryptionParams>({\n ...delegateDecryptionMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n try {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n } finally {\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n revokeDelegationMutationOptions,\n zamaQueryKeys,\n type RevokeDelegationParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Revoke FHE decryption delegation for a token from a delegate address.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const revoke = useRevokeDelegation({ tokenAddress: \"0x...\" });\n * revoke.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useRevokeDelegation(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, RevokeDelegationParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, RevokeDelegationParams>({\n ...revokeDelegationMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n try {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n } finally {\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n }\n },\n });\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { delegationStatusQueryOptions, type DelegationStatusData } from \"@zama-fhe/sdk/query\";\nimport { useQuery } from \"../utils/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport interface UseDelegationStatusConfig {\n /** Address of the confidential token contract. Pass `undefined` to disable the query. */\n tokenAddress: Address | undefined;\n /** The address that granted the delegation. */\n delegatorAddress?: Address;\n /** The address that received delegation rights. */\n delegateAddress?: Address;\n}\n\n/**\n * Query delegation status between a delegator and delegate for a token.\n *\n * @param config - Token address, delegator, and delegate addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns `{ isDelegated, expiryTimestamp, isLoading, error }`.\n *\n * @example\n * ```tsx\n * const { data } = useDelegationStatus({\n * tokenAddress: \"0xToken\",\n * delegatorAddress: \"0xDelegator\",\n * delegateAddress: \"0xDelegate\",\n * });\n * // data?.isDelegated, data?.expiryTimestamp\n * ```\n */\nexport function useDelegationStatus(\n config: UseDelegationStatusConfig,\n options?: Omit<UseQueryOptions<DelegationStatusData>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = delegationStatusQueryOptions(sdk, {\n tokenAddress: config.tokenAddress,\n delegatorAddress: config.delegatorAddress,\n delegateAddress: config.delegateAddress,\n });\n\n return useQuery<DelegationStatusData>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { decryptBalanceAsMutationOptions, type DecryptBalanceAsParams } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\n\n/**\n * Decrypt another user's confidential balance as a delegate.\n *\n * @param tokenAddress - Address of the confidential token contract.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const decryptAs = useDecryptBalanceAs(\"0xToken\");\n * decryptAs.mutate({ delegatorAddress: \"0xDelegator\" });\n * // decryptAs.data => 1000n\n * ```\n */\nexport function useDecryptBalanceAs(\n tokenAddress: Address,\n options?: UseMutationOptions<bigint, Error, DecryptBalanceAsParams>,\n) {\n const readonlyToken = useReadonlyToken(tokenAddress);\n\n return useMutation<bigint, Error, DecryptBalanceAsParams>({\n ...decryptBalanceAsMutationOptions(readonlyToken),\n ...options,\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { ReadonlyToken, type Address, type BatchDecryptAsOptions } from \"@zama-fhe/sdk\";\n\n/**\n * Batch decrypt confidential balances as a delegate across multiple tokens.\n *\n * @param tokens - ReadonlyToken instances to decrypt balances for.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const batchDecryptAs = useBatchDecryptBalancesAs(tokens);\n * batchDecryptAs.mutate({\n * delegatorAddress: \"0xDelegator\",\n * });\n * // batchDecryptAs.data => Map { \"0xTokenA\" => 100n, \"0xTokenB\" => 200n }\n * ```\n */\nexport function useBatchDecryptBalancesAs(\n tokens: ReadonlyToken[],\n options?: UseMutationOptions<Map<Address, bigint>, Error, BatchDecryptAsOptions>,\n) {\n return useMutation<Map<Address, bigint>, Error, BatchDecryptAsOptions>({\n mutationKey: [\"zama.batchDecryptBalancesAs\", ...tokens.map((t) => t.address)] as const,\n mutationFn: async (params) => ReadonlyToken.batchDecryptBalancesAs(tokens, params),\n ...options,\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n approveUnderlyingMutationOptions,\n invalidateAfterApproveUnderlying,\n type ApproveUnderlyingParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Approve the wrapper contract to spend the underlying ERC-20.\n * Defaults to max uint256. Resets to zero first if there's an existing\n * non-zero allowance (required by tokens like USDT).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — approval transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useApproveUnderlying({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * approve.mutate({}); // max approval\n * approve.mutate({ amount: 1000n }); // exact amount\n * ```\n */\nexport function useApproveUnderlying(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ApproveUnderlyingParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ApproveUnderlyingParams, Address>({\n ...approveUnderlyingMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApproveUnderlying(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialQueryOptions, isWrapperQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { isConfidentialQueryOptions, isWrapperQueryOptions };\n\n/**\n * Check if a token supports the ERC-7984 confidential interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidential(\"0xToken\");\n * ```\n */\nexport function useIsConfidential(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean>({\n ...isConfidentialQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsConfidential}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidentialSuspense(\"0xToken\");\n * ```\n */\nexport function useIsConfidentialSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean>({\n ...isConfidentialQueryOptions(token.signer, tokenAddress),\n });\n}\n\n/**\n * Check if a token supports the ERC-7984 wrapper interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapper(\"0xToken\");\n * ```\n */\nexport function useIsWrapper(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean>({\n ...isWrapperQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsWrapper}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapperSuspense(\"0xToken\");\n * ```\n */\nexport function useIsWrapperSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean>({\n ...isWrapperQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { totalSupplyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { totalSupplyQueryOptions };\n\n/**\n * Read the total supply of a token.\n * Stale after 30 seconds to balance freshness and RPC cost.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupply(\"0xToken\");\n * ```\n */\nexport function useTotalSupply(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<bigint>({\n ...totalSupplyQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useTotalSupply}.\n * Suspends rendering until the total supply is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupplySuspense(\"0xToken\");\n * ```\n */\nexport function useTotalSupplySuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<bigint>({\n ...totalSupplyQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n batchTransferFeeQueryOptions,\n feeRecipientQueryOptions,\n shieldFeeQueryOptions,\n unshieldFeeQueryOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport {\n batchTransferFeeQueryOptions,\n feeRecipientQueryOptions,\n shieldFeeQueryOptions,\n unshieldFeeQueryOptions,\n};\n\n/** Configuration for {@link useShieldFee} and {@link useUnshieldFee}. */\nexport interface UseFeeConfig {\n /** Address of the fee manager contract. */\n feeManagerAddress: Address;\n /** Amount to calculate the fee for. */\n amount: bigint;\n /** Sender address. */\n from: Address;\n /** Receiver address. */\n to: Address;\n}\n\n/**\n * Read the shield fee for a given amount and address pair.\n *\n * @param config - Fee manager address, amount, from, and to.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useShieldFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useShieldFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = shieldFeeQueryOptions(sdk.signer, config);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the unshield fee for a given amount and address pair.\n *\n * @param config - Fee manager address, amount, from, and to.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useUnshieldFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useUnshieldFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = unshieldFeeQueryOptions(sdk.signer, config);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the batch transfer fee from the fee manager.\n *\n * @param feeManagerAddress - Address of the fee manager contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useBatchTransferFee(\"0xFeeManager\");\n * ```\n */\nexport function useBatchTransferFee(\n feeManagerAddress: Address,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = batchTransferFeeQueryOptions(sdk.signer, feeManagerAddress);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the fee recipient address from the fee manager.\n *\n * @param feeManagerAddress - Address of the fee manager contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address` (the fee recipient).\n *\n * @example\n * ```tsx\n * const { data: recipient } = useFeeRecipient(\"0xFeeManager\");\n * ```\n */\nexport function useFeeRecipient(\n feeManagerAddress: Address,\n options?: Omit<UseQueryOptions<Address>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = feeRecipientQueryOptions(sdk.signer, feeManagerAddress);\n\n return useQuery<Address>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches all token wrapper pairs from the ConfidentialTokenWrappersRegistry\n * contract on the current chain.\n */\nexport function useTokenPairsRegistry() {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly TokenWrapperPair[]>(\n tokenPairsQueryOptions(sdk.signer, {\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport { tokenPairsLengthQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Returns the total number of token wrapper pairs in the registry.\n */\nexport function useTokenPairsLength() {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<bigint>(\n tokenPairsLengthQueryOptions(sdk.signer, {\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairsSliceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches a range of token wrapper pairs from the registry (paginated).\n *\n * @param fromIndex - Start index (inclusive). Pass `undefined` to disable.\n * @param toIndex - End index (exclusive). Pass `undefined` to disable.\n */\nexport function useTokenPairsSlice({\n fromIndex,\n toIndex,\n}: {\n fromIndex: bigint | undefined;\n toIndex: bigint | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly TokenWrapperPair[]>(\n tokenPairsSliceQueryOptions(sdk.signer, {\n registryAddress,\n fromIndex,\n toIndex,\n }),\n );\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches a single token wrapper pair by index from the registry.\n *\n * @param index - Zero-based pair index. Pass `undefined` to disable.\n */\nexport function useTokenPair({ index }: { index: bigint | undefined }) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<TokenWrapperPair>(\n tokenPairQueryOptions(sdk.signer, {\n registryAddress,\n index,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialTokenAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Looks up the confidential token address for a given plain token address.\n */\nexport function useConfidentialTokenAddress({\n tokenAddress,\n}: {\n tokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly [boolean, Address]>(\n confidentialTokenAddressQueryOptions(sdk.signer, {\n registryAddress,\n tokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Looks up the plain token address for a given confidential token address.\n */\nexport function useTokenAddress({\n confidentialTokenAddress,\n}: {\n confidentialTokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly [boolean, Address]>(\n tokenAddressQueryOptions(sdk.signer, {\n registryAddress,\n confidentialTokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialTokenValidQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Checks whether a confidential token is registered and valid in the\n * on-chain wrappers registry.\n *\n * @param confidentialTokenAddress - The confidential token to check. Pass `undefined` to disable.\n */\nexport function useIsConfidentialTokenValid({\n confidentialTokenAddress,\n}: {\n confidentialTokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<boolean>(\n isConfidentialTokenValidQueryOptions(sdk.signer, {\n registryAddress,\n confidentialTokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type {\n TokenWrapperPair,\n TokenWrapperPairWithMetadata,\n PaginatedResult,\n} from \"@zama-fhe/sdk\";\nimport { listPairsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches paginated token wrapper pairs from the registry.\n *\n * @param options - Query options: `page` (1-indexed, default `1`), `pageSize` (default `100`), `metadata` (fetch on-chain metadata for both tokens, default `false`).\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListPairs({ page: 1, pageSize: 20 });\n * if (data) {\n * console.log(`${data.total} pairs, showing page ${data.page}`);\n * }\n * ```\n */\nexport function useListPairs({\n page = 1,\n pageSize = 100,\n metadata = false,\n}: {\n page?: number;\n pageSize?: number;\n metadata?: boolean;\n} = {}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n // Pass sdk.registry (a lazy singleton) so the class-level TTL cache is shared\n // across all queryFn executions — rather than constructing a new instance each time.\n return useQuery<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>>(\n listPairsQueryOptions(sdk.registry, {\n registryAddress,\n page,\n pageSize,\n metadata,\n }),\n );\n}\n"],"mappings":"k5MA4DA,MAAM,EAAiB,GAA8B,KAAK,CAY1D,SAAgB,GAAa,CAC3B,WACA,UACA,SACA,UACA,iBACA,aACA,aACA,oBACA,cACA,WACoB,CACpB,IAAM,EAAc,GAAgB,CAG9B,EAAa,EAAO,EAAQ,CAC5B,EAAuB,EAAO,EAAkB,CAEtD,MAAgB,CACd,EAAW,QAAU,EACrB,EAAqB,QAAU,GAC/B,CAEF,IAAM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,GAA4B,CAC1C,gBAGC,CACD,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAEpD,OAAOC,EACL,GAAqC,EAAI,OAAQ,CAC/C,kBACA,eACD,CAAC,CACH,CCbH,SAAgB,GAAgB,CAC9B,4BAGC,CACD,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAEpD,OAAOC,EACL,GAAyB,EAAI,OAAQ,CACnC,kBACA,2BACD,CAAC,CACH,CCVH,SAAgB,GAA4B,CAC1C,4BAGC,CACD,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAEpD,OAAOC,EACL,GAAqC,EAAI,OAAQ,CAC/C,kBACA,2BACD,CAAC,CACH,CCFH,SAAgB,GAAa,CAC3B,OAAO,EACP,WAAW,IACX,WAAW,IAKT,EAAE,CAAE,CACN,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAIpD,OAAOC,EACLC,GAAsB,EAAI,SAAU,CAClC,kBACA,OACA,WACA,WACD,CAAC,CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zama-fhe/react-sdk",
|
|
3
|
-
"version": "2.2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "React hooks for Zama SDK",
|
|
5
5
|
"license": "BSD-3-Clause-Clear",
|
|
6
6
|
"author": "Zama",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@tanstack/react-query": ">=5",
|
|
62
|
-
"@zama-fhe/sdk": "^2.2.0
|
|
62
|
+
"@zama-fhe/sdk": "^2.2.0",
|
|
63
63
|
"react": ">=18",
|
|
64
64
|
"viem": "^2.47.0",
|
|
65
65
|
"wagmi": ">=2"
|