@zama-fhe/react-sdk 1.2.0-alpha.3 → 1.2.0-alpha.5
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 +15 -15
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -421,7 +421,7 @@ interface UseConfidentialBalanceConfig {
|
|
|
421
421
|
handleRefetchInterval?: number;
|
|
422
422
|
}
|
|
423
423
|
/** Query options for the decrypt phase of {@link useConfidentialBalance}. */
|
|
424
|
-
type UseConfidentialBalanceOptions = Omit<UseQueryOptions<bigint
|
|
424
|
+
type UseConfidentialBalanceOptions = Omit<UseQueryOptions<bigint>, "queryKey" | "queryFn">;
|
|
425
425
|
/**
|
|
426
426
|
* Declarative hook to read the connected wallet's confidential token balance.
|
|
427
427
|
* Uses two-phase polling: cheaply polls the encrypted handle, then only
|
|
@@ -619,7 +619,7 @@ interface UseConfidentialBalancesConfig {
|
|
|
619
619
|
maxConcurrency?: number;
|
|
620
620
|
}
|
|
621
621
|
/** Query options for the decrypt phase of {@link useConfidentialBalances}. */
|
|
622
|
-
type UseConfidentialBalancesOptions = Omit<UseQueryOptions<ConfidentialBalancesData$1
|
|
622
|
+
type UseConfidentialBalancesOptions = Omit<UseQueryOptions<ConfidentialBalancesData$1>, "queryKey" | "queryFn">;
|
|
623
623
|
/**
|
|
624
624
|
* Declarative hook to read multiple confidential token balances in batch.
|
|
625
625
|
* Uses two-phase polling: cheaply polls encrypted handles, then only
|
|
@@ -867,7 +867,7 @@ declare function useRevokeTokens(options?: UseMutationOptions<void, Error, Addre
|
|
|
867
867
|
* revokeSession();
|
|
868
868
|
* ```
|
|
869
869
|
*/
|
|
870
|
-
declare function useRevokeSession(options?: UseMutationOptions<void
|
|
870
|
+
declare function useRevokeSession(options?: UseMutationOptions<void>): _tanstack_react_query0.UseMutationResult<void, Error, void, unknown>;
|
|
871
871
|
//#endregion
|
|
872
872
|
//#region src/token/use-confidential-transfer.d.ts
|
|
873
873
|
/** Configuration for {@link useConfidentialTransfer}. */
|
|
@@ -982,7 +982,7 @@ interface UseConfidentialIsApprovedSuspenseConfig extends UseZamaConfig {
|
|
|
982
982
|
* });
|
|
983
983
|
* ```
|
|
984
984
|
*/
|
|
985
|
-
declare function useConfidentialIsApproved(config: UseConfidentialIsApprovedConfig, options?: Omit<UseQueryOptions<boolean
|
|
985
|
+
declare function useConfidentialIsApproved(config: UseConfidentialIsApprovedConfig, options?: Omit<UseQueryOptions<boolean>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<unknown, Error>;
|
|
986
986
|
/**
|
|
987
987
|
* Suspense variant of {@link useConfidentialIsApproved}.
|
|
988
988
|
* Suspends rendering until the approval check resolves.
|
|
@@ -1214,7 +1214,7 @@ interface UseUnderlyingAllowanceConfig {
|
|
|
1214
1214
|
* });
|
|
1215
1215
|
* ```
|
|
1216
1216
|
*/
|
|
1217
|
-
declare function useUnderlyingAllowance(config: UseUnderlyingAllowanceConfig, options?: Omit<UseQueryOptions<bigint
|
|
1217
|
+
declare function useUnderlyingAllowance(config: UseUnderlyingAllowanceConfig, options?: Omit<UseQueryOptions<bigint>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<bigint, Error>;
|
|
1218
1218
|
/**
|
|
1219
1219
|
* Suspense variant of {@link useUnderlyingAllowance}.
|
|
1220
1220
|
* Suspends rendering until the allowance is loaded.
|
|
@@ -1264,7 +1264,7 @@ interface UseWrapperDiscoverySuspenseConfig {
|
|
|
1264
1264
|
* });
|
|
1265
1265
|
* ```
|
|
1266
1266
|
*/
|
|
1267
|
-
declare function useWrapperDiscovery(config: UseWrapperDiscoveryConfig, options?: Omit<UseQueryOptions<Address$1 | null
|
|
1267
|
+
declare function useWrapperDiscovery(config: UseWrapperDiscoveryConfig, options?: Omit<UseQueryOptions<Address$1 | null>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<`0x${string}` | null, Error>;
|
|
1268
1268
|
/**
|
|
1269
1269
|
* Suspense variant of {@link useWrapperDiscovery}.
|
|
1270
1270
|
* Suspends rendering until the wrapper address is resolved.
|
|
@@ -1297,7 +1297,7 @@ declare function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspense
|
|
|
1297
1297
|
* // metadata?.name, metadata?.symbol, metadata?.decimals
|
|
1298
1298
|
* ```
|
|
1299
1299
|
*/
|
|
1300
|
-
declare function useMetadata(tokenAddress: Address$1, options?: Omit<UseQueryOptions<TokenMetadata
|
|
1300
|
+
declare function useMetadata(tokenAddress: Address$1, options?: Omit<UseQueryOptions<TokenMetadata>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<TokenMetadata, Error>;
|
|
1301
1301
|
/**
|
|
1302
1302
|
* Suspense variant of {@link useMetadata}.
|
|
1303
1303
|
* Suspends rendering until metadata is loaded.
|
|
@@ -1474,7 +1474,7 @@ declare function useApproveUnderlying(config: UseZamaConfig, options?: UseMutati
|
|
|
1474
1474
|
* const { data: isConfidential } = useIsConfidential("0xToken");
|
|
1475
1475
|
* ```
|
|
1476
1476
|
*/
|
|
1477
|
-
declare function useIsConfidential(tokenAddress: Address$1, options?: Omit<UseQueryOptions<boolean
|
|
1477
|
+
declare function useIsConfidential(tokenAddress: Address$1, options?: Omit<UseQueryOptions<boolean>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<boolean, Error>;
|
|
1478
1478
|
/**
|
|
1479
1479
|
* Suspense variant of {@link useIsConfidential}.
|
|
1480
1480
|
* Suspends rendering until the ERC-165 check resolves.
|
|
@@ -1501,7 +1501,7 @@ declare function useIsConfidentialSuspense(tokenAddress: Address$1): _tanstack_r
|
|
|
1501
1501
|
* const { data: isWrapper } = useIsWrapper("0xToken");
|
|
1502
1502
|
* ```
|
|
1503
1503
|
*/
|
|
1504
|
-
declare function useIsWrapper(tokenAddress: Address$1, options?: Omit<UseQueryOptions<boolean
|
|
1504
|
+
declare function useIsWrapper(tokenAddress: Address$1, options?: Omit<UseQueryOptions<boolean>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<boolean, Error>;
|
|
1505
1505
|
/**
|
|
1506
1506
|
* Suspense variant of {@link useIsWrapper}.
|
|
1507
1507
|
* Suspends rendering until the ERC-165 check resolves.
|
|
@@ -1530,7 +1530,7 @@ declare function useIsWrapperSuspense(tokenAddress: Address$1): _tanstack_react_
|
|
|
1530
1530
|
* const { data: totalSupply } = useTotalSupply("0xToken");
|
|
1531
1531
|
* ```
|
|
1532
1532
|
*/
|
|
1533
|
-
declare function useTotalSupply(tokenAddress: Address$1, options?: Omit<UseQueryOptions<bigint
|
|
1533
|
+
declare function useTotalSupply(tokenAddress: Address$1, options?: Omit<UseQueryOptions<bigint>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<bigint, Error>;
|
|
1534
1534
|
/**
|
|
1535
1535
|
* Suspense variant of {@link useTotalSupply}.
|
|
1536
1536
|
* Suspends rendering until the total supply is loaded.
|
|
@@ -1574,7 +1574,7 @@ interface UseFeeConfig {
|
|
|
1574
1574
|
* });
|
|
1575
1575
|
* ```
|
|
1576
1576
|
*/
|
|
1577
|
-
declare function useShieldFee(config: UseFeeConfig, options?: Omit<UseQueryOptions<bigint
|
|
1577
|
+
declare function useShieldFee(config: UseFeeConfig, options?: Omit<UseQueryOptions<bigint>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<bigint, Error>;
|
|
1578
1578
|
/**
|
|
1579
1579
|
* Read the unshield fee for a given amount and address pair.
|
|
1580
1580
|
*
|
|
@@ -1592,7 +1592,7 @@ declare function useShieldFee(config: UseFeeConfig, options?: Omit<UseQueryOptio
|
|
|
1592
1592
|
* });
|
|
1593
1593
|
* ```
|
|
1594
1594
|
*/
|
|
1595
|
-
declare function useUnshieldFee(config: UseFeeConfig, options?: Omit<UseQueryOptions<bigint
|
|
1595
|
+
declare function useUnshieldFee(config: UseFeeConfig, options?: Omit<UseQueryOptions<bigint>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<bigint, Error>;
|
|
1596
1596
|
/**
|
|
1597
1597
|
* Read the batch transfer fee from the fee manager.
|
|
1598
1598
|
*
|
|
@@ -1605,7 +1605,7 @@ declare function useUnshieldFee(config: UseFeeConfig, options?: Omit<UseQueryOpt
|
|
|
1605
1605
|
* const { data: fee } = useBatchTransferFee("0xFeeManager");
|
|
1606
1606
|
* ```
|
|
1607
1607
|
*/
|
|
1608
|
-
declare function useBatchTransferFee(feeManagerAddress: Address$1, options?: Omit<UseQueryOptions<bigint
|
|
1608
|
+
declare function useBatchTransferFee(feeManagerAddress: Address$1, options?: Omit<UseQueryOptions<bigint>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<bigint, Error>;
|
|
1609
1609
|
/**
|
|
1610
1610
|
* Read the fee recipient address from the fee manager.
|
|
1611
1611
|
*
|
|
@@ -1618,10 +1618,10 @@ declare function useBatchTransferFee(feeManagerAddress: Address$1, options?: Omi
|
|
|
1618
1618
|
* const { data: recipient } = useFeeRecipient("0xFeeManager");
|
|
1619
1619
|
* ```
|
|
1620
1620
|
*/
|
|
1621
|
-
declare function useFeeRecipient(feeManagerAddress: Address$1, options?: Omit<UseQueryOptions<Address$1
|
|
1621
|
+
declare function useFeeRecipient(feeManagerAddress: Address$1, options?: Omit<UseQueryOptions<Address$1>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<`0x${string}`, Error>;
|
|
1622
1622
|
//#endregion
|
|
1623
1623
|
//#region src/token/optimistic-balance-update.d.ts
|
|
1624
|
-
type OptimisticBalanceSnapshot =
|
|
1624
|
+
type OptimisticBalanceSnapshot = [QueryKey, bigint | undefined][];
|
|
1625
1625
|
/** Combined context returned by optimistic `onMutate`. */
|
|
1626
1626
|
interface OptimisticMutateContext {
|
|
1627
1627
|
snapshot: OptimisticBalanceSnapshot;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ZamaSDK","encryptMutationOptions","zamaQueryKeys","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","useQuery","publicKeyQueryOptions","useQuery","publicParamsQueryOptions","useQuery","hashFn","useQuery","signerAddressQueryOptions","confidentialHandleQueryOptions","confidentialBalanceQueryOptions","useQuery","signerAddressQueryOptions","confidentialHandlesQueryOptions","confidentialBalancesQueryOptions","allowMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","isAllowedQueryOptions","zamaQueryKeys","revokeMutationOptions","zamaQueryKeys","revokeSessionMutationOptions","zamaQueryKeys","zamaQueryKeys","confidentialTransferMutationOptions","confidentialTransferFromMutationOptions","confidentialApproveMutationOptions","useQuery","signerAddressQueryOptions","confidentialIsApprovedQueryOptions","zamaQueryKeys","useSuspenseQuery","shieldMutationOptions","shieldETHMutationOptions","unwrapMutationOptions","unwrapAllMutationOptions","finalizeUnwrapMutationOptions","unshieldMutationOptions","unshieldAllMutationOptions","resumeUnshieldMutationOptions","useQuery","signerAddressQueryOptions","underlyingAllowanceQueryOptions","useSuspenseQuery","useQuery","wrapperDiscoveryQueryOptions","zamaQueryKeys","useSuspenseQuery","useQuery","tokenMetadataQueryOptions","useSuspenseQuery","useQuery","activityFeedQueryOptions","delegateDecryptionMutationOptions","zamaQueryKeys","revokeDelegationMutationOptions","zamaQueryKeys","useQuery","delegationStatusQueryOptions","zamaQueryKeys","decryptBalanceAsMutationOptions","ReadonlyToken","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","shieldFeeQueryOptions","useQuery","unshieldFeeQueryOptions","batchTransferFeeQueryOptions","feeRecipientQueryOptions"],"sources":["../src/provider.tsx","../src/relayer/use-encrypt.ts","../src/relayer/decryption-cache.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-decrypt-flow.ts","../src/relayer/use-user-decrypted-value.ts","../src/relayer/use-user-decrypted-values.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/use-allow-tokens.ts","../src/token/use-is-allowed.ts","../src/token/use-revoke-tokens.ts","../src/token/use-revoke-session.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/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"],"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 /** 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 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 useEffect(() => {\n onEventRef.current = onEvent;\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 onEvent: onEventRef.current,\n signerLifecycleCallbacks,\n }),\n [relayer, signer, storage, sessionStorage, keypairTTL, sessionTTL, signerLifecycleCallbacks],\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: [1000n], bits: [64] });\n * ```\n */\nexport function useEncrypt() {\n const sdk = useZamaSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(sdk));\n}\n","import { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { type Address } from \"@zama-fhe/sdk\";\nimport { type Handle } from \"@zama-fhe/sdk\";\n\n/**\n * Query key helpers for the shared decryption cache.\n * Used by useUserDecrypt/usePublicDecrypt to populate,\n * and by useUserDecryptedValue to read.\n */\nexport const decryptionKeys = {\n value: (handle: Handle, contractAddress?: Address) =>\n zamaQueryKeys.decryption.handle(handle, contractAddress),\n};\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle, UserDecryptParams } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Thin wrapper around sdk.userDecrypt().\n * Caller is responsible for providing all params (keypair, signature, etc.).\n * For the full orchestration (signature management, EIP712 signing),\n * see the app-level useUserDecryptFlow hook.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — relayer decryption request failed\n * - {@link InvalidKeypairError} — the provided keypair is invalid\n * - {@link KeypairExpiredError} — the re-encryption keypair has expired\n *\n * On success, populates the decryption cache so useUserDecryptedValue/useUserDecryptedValues\n * can read the results.\n */\nexport function useUserDecrypt() {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptParams>({\n mutationFn: (params) => sdk.relayer.userDecrypt(params),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data) as [Handle, ClearValueType][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle, PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\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 const queryClient = useQueryClient();\n return useMutation<PublicDecryptResult, Error, Handle[]>({\n mutationFn: (handles) => sdk.relayer.publicDecrypt(handles),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data.clearValues) as [\n Handle,\n ClearValueType,\n ][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-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({\n mutationFn: () => sdk.relayer.generateKeypair(),\n });\n}\n","\"use client\";\n\nimport type { EIP712TypedData } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\nimport { type Address } from \"@zama-fhe/sdk\";\n\n/** Parameters for {@link useCreateEIP712}. */\nexport interface CreateEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: `0x${string}`;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Unix timestamp (seconds) when the credential becomes valid. */\n startTimestamp: number;\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\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>({\n mutationFn: ({ publicKey, contractAddresses, startTimestamp, durationDays }) =>\n sdk.relayer.createEIP712(publicKey, contractAddresses, startTimestamp, durationDays),\n });\n}\n","\"use client\";\n\nimport type { Address, KmsDelegatedUserDecryptEIP712Type } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Parameters for {@link useCreateDelegatedUserDecryptEIP712}. */\nexport interface CreateDelegatedUserDecryptEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: `0x${string}`;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Address of the wallet that delegated decrypt authority. */\n delegatorAddress: Address;\n /** Unix timestamp (seconds) when the credential becomes valid. */\n startTimestamp: number;\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\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 >({\n mutationFn: ({\n publicKey,\n contractAddresses,\n delegatorAddress,\n startTimestamp,\n durationDays,\n }) =>\n sdk.relayer.createDelegatedUserDecryptEIP712(\n publicKey,\n contractAddresses,\n delegatorAddress,\n startTimestamp,\n durationDays,\n ),\n });\n}\n","\"use client\";\n\nimport type { DelegatedUserDecryptParams, ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-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 mutationFn: (params) => sdk.relayer.delegatedUserDecrypt(params),\n });\n}\n","\"use client\";\n\nimport type { InputProofBytesType, ZKProofLike } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-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 mutationFn: (zkProof) => sdk.relayer.requestZKProofVerification(zkProof),\n });\n}\n","import {\n type DefaultError,\n useQuery as tanstack_useQuery,\n useSuspenseQuery as tanstack_useSuspenseQuery,\n type UseQueryResult,\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 * The `options` parameter is typed as `any` because TanStack Query v5 has:\n * 1. Discriminated overloads around `initialData` (Defined vs Undefined)\n * 2. Function-typed fields (`staleTime`, `enabled`, `gcTime`) that are generic over `TQueryKey`\n *\n * Our factories produce options with specific tuple keys (e.g. `readonly [\"zama.totalSupply\", {...}]`)\n * whose function-typed fields are contravariant with `QueryKey` (`readonly unknown[]`).\n * Typing the parameter as `UseQueryOptions<TData, TError, TData, any>` still fails because\n * the query-key variance leaks through `staleTime`, `enabled`, etc.\n *\n * Hooks must pass explicit generics: `useQuery<DataType>({...})`.\n */\nexport function useQuery<TData = unknown, TError = DefaultError>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: any,\n): UseQueryResult<TData, TError> {\n return tanstack_useQuery({\n ...options,\n queryKeyHashFn: hashFn,\n }) as UseQueryResult<TData, TError>;\n}\n\nexport function useSuspenseQuery<TData = unknown, TError = DefaultError>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: any,\n): UseSuspenseQueryResult<TData, TError> {\n return tanstack_useSuspenseQuery({\n ...options,\n queryKeyHashFn: hashFn,\n }) as UseSuspenseQueryResult<TData, TError>;\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 { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { Address, ClearValueType, Handle, Hex } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/** A handle to decrypt, paired with its originating contract address. */\nexport interface DecryptHandle {\n handle: Handle;\n contractAddress: Address;\n}\n\n/** Parameters for {@link useUserDecryptFlow}. */\nexport interface UserDecryptFlowParams {\n /** Encrypted handles to decrypt. */\n handles: DecryptHandle[];\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\n\n/** Progress callbacks for each step of the decrypt flow. */\nexport interface UserDecryptFlowCallbacks {\n /** Fired after the keypair is generated. */\n onKeypairGenerated?: () => void;\n /** Fired after the EIP-712 typed data is created, before wallet signing. */\n onEIP712Created?: () => void;\n /** Fired after the wallet signature is obtained. */\n onSigned?: (signature: Hex) => void;\n /** Fired after decryption completes. */\n onDecrypted?: (values: Record<Handle, ClearValueType>) => void;\n}\n\n/** Configuration for {@link useUserDecryptFlow}. */\nexport interface UseUserDecryptFlowConfig {\n /** Optional progress callbacks. */\n callbacks?: UserDecryptFlowCallbacks;\n}\n\n/**\n * High-level orchestration hook for user decryption.\n * Handles the full flow: keypair generation → EIP-712 creation → wallet signature → decryption.\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 UserDecryptFlowParams}.\n *\n * @example\n * ```tsx\n * const decryptFlow = useUserDecryptFlow({\n * callbacks: { onSigned: () => setStep(\"decrypting\") },\n * });\n * decryptFlow.mutate({\n * handles: [{ handle: \"0xHandle\", contractAddress: \"0xContract\" }],\n * durationDays: 7,\n * });\n * ```\n */\nexport function useUserDecryptFlow(config?: UseUserDecryptFlowConfig) {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n const callbacks = config?.callbacks;\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptFlowParams>({\n mutationKey: [\"userDecryptFlow\"],\n mutationFn: async ({ handles, durationDays = 1 }) => {\n // Step 1: Generate keypair\n const keypair = await sdk.relayer.generateKeypair();\n callbacks?.onKeypairGenerated?.();\n\n // Step 2: Create EIP-712 typed data\n const contractAddresses = [...new Set(handles.map((h) => h.contractAddress))];\n const startTimestamp = Math.floor(Date.now() / 1000);\n const eip712 = await sdk.relayer.createEIP712(\n keypair.publicKey,\n contractAddresses,\n startTimestamp,\n durationDays,\n );\n callbacks?.onEIP712Created?.();\n\n // Step 3: Sign with wallet\n const signature = await sdk.signer.signTypedData(eip712);\n callbacks?.onSigned?.(signature);\n\n // Step 4: Decrypt — group handles by contract address\n const signerAddress = await sdk.signer.getAddress();\n const allResults: Partial<Record<Handle, ClearValueType>> = {};\n\n // Decrypt per contract address (the relayer requires handles from the same contract)\n const handlesByContract = new Map<Address, Handle[]>();\n for (const h of handles) {\n const list = handlesByContract.get(h.contractAddress) ?? [];\n list.push(h.handle);\n handlesByContract.set(h.contractAddress, list);\n }\n\n for (const [contractAddress, contractHandles] of handlesByContract) {\n const result = await sdk.relayer.userDecrypt({\n handles: contractHandles,\n contractAddress,\n signedContractAddresses: contractAddresses,\n privateKey: keypair.privateKey,\n publicKey: keypair.publicKey,\n signature,\n signerAddress,\n startTimestamp,\n durationDays,\n });\n Object.assign(allResults, result);\n }\n\n const results = allResults as Record<Handle, ClearValueType>;\n callbacks?.onDecrypted?.(results);\n return results;\n },\n onSuccess: (data) => {\n // Populate the shared decryption cache\n for (const [handle, value] of Object.entries(data) as [Handle, ClearValueType][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\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(decryptionKeys.value(handle), value).\n */\nexport function useUserDecryptedValue(handle: Handle | undefined) {\n return useQuery<ClearValueType>({\n queryKey: decryptionKeys.value(handle ?? \"0x\"),\n queryFn: () => undefined as never,\n enabled: false,\n });\n}\n","\"use client\";\n\nimport { useQueries } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\nimport { decryptionKeys } from \"./decryption-cache\";\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: decryptionKeys.value(handle),\n queryKeyHashFn: hashFn,\n queryFn: () => undefined as never,\n enabled: false,\n })),\n });\n\n const data: Partial<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 { 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 type UseConfidentialBalanceOptions = Omit<\n UseQueryOptions<bigint, Error>,\n \"queryKey\" | \"queryFn\"\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 userEnabled = options?.enabled;\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 ?? true) && (userEnabled ?? true),\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 ?? true) && (userEnabled ?? true),\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 type UseConfidentialBalancesOptions = Omit<\n UseQueryOptions<ConfidentialBalancesData, Error>,\n \"queryKey\" | \"queryFn\"\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 userEnabled = options?.enabled;\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 ?? true) && (userEnabled ?? true),\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 && (userEnabled ?? true),\n });\n\n return { ...balancesQuery, handlesQuery };\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 * Pre-authorize FHE decrypt credentials for a list of token addresses.\n * A single wallet signature covers all addresses, so subsequent decrypt\n * operations on any of these tokens 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: allowTokens, isPending } = useAllowTokens();\n * // Call allowTokens(allTokenAddresses) before any individual reveal\n * ```\n */\nexport function useAllowTokens(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 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 };\n const factoryEnabled = \"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true;\n\n return useQuery({\n ...baseOpts,\n enabled: factoryEnabled,\n });\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 credentials for a list of token addresses.\n * The next decrypt operation will require a fresh wallet signature.\n *\n * @example\n * ```tsx\n * const { mutate: revokeTokens } = useRevokeTokens();\n * revokeTokens([\"0xTokenA\", \"0xTokenB\"]);\n * ```\n */\nexport function useRevokeTokens(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 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, Error, void>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, void>({\n ...revokeSessionMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\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 = Array<[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) continue;\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 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 { useMutation, UseMutationOptions } 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 { useMutation, UseMutationOptions } 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 { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n confidentialIsApprovedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\nexport { confidentialIsApprovedQueryOptions };\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig extends UseZamaConfig {\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, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { spender, holder, ...tokenConfig } = config;\n const userEnabled = options?.enabled;\n const token = useToken(tokenConfig);\n const holderQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n enabled: holder === undefined,\n });\n const resolvedHolder = holder ?? holderQuery.data;\n\n const baseOpts =\n spender && resolvedHolder\n ? confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n })\n : {\n queryKey: zamaQueryKeys.confidentialIsApproved.token(config.tokenAddress),\n queryFn: skipToken,\n };\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: (\"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true) && (userEnabled ?? 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 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 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 { useMutation, UseMutationOptions } 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 { useMutation, UseMutationOptions } 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 { useMutation, UseMutationOptions } 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 { useMutation, UseMutationOptions } 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 { useMutation, UseMutationOptions } 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 { useMutation, UseMutationOptions } 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, Error>, \"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 { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { wrapperDiscoveryQueryOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { wrapperDiscoveryQueryOptions };\n\n/** Configuration for {@link useWrapperDiscovery}. */\nexport interface UseWrapperDiscoveryConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper coordinator. Pass `undefined` to disable the query. */\n coordinatorAddress: Address | undefined;\n}\n\n/** Configuration for {@link useWrapperDiscoverySuspense}. */\nexport interface UseWrapperDiscoverySuspenseConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper coordinator. */\n coordinatorAddress: Address;\n}\n\n/**\n * Discover the wrapper contract for an ERC-20 token.\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 coordinator 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: \"0xUnderlying\",\n * coordinatorAddress: \"0xCoordinator\",\n * });\n * ```\n */\nexport function useWrapperDiscovery(\n config: UseWrapperDiscoveryConfig,\n options?: Omit<UseQueryOptions<Address | null, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<Address | null>({\n ...(coordinatorAddress\n ? wrapperDiscoveryQueryOptions(token.signer, tokenAddress, { coordinatorAddress })\n : {\n queryKey: zamaQueryKeys.wrapperDiscovery.all,\n queryFn: skipToken,\n }),\n ...options,\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 coordinator addresses.\n * @returns Suspense query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscoverySuspense({\n * tokenAddress: \"0xUnderlying\",\n * coordinatorAddress: \"0xCoordinator\",\n * });\n * ```\n */\nexport function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig) {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<Address | null>({\n ...wrapperDiscoveryQueryOptions(token.signer, tokenAddress, { coordinatorAddress }),\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, Error>, \"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 context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n options?.onSuccess?.(data, variables, onMutateResult, context);\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 context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n delegationStatusQueryOptions,\n zamaQueryKeys,\n type DelegationStatusData,\n} from \"@zama-fhe/sdk/query\";\nimport { useQuery } from \"../utils/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport interface UseDelegationStatusConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\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, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const readonlyToken = useReadonlyToken(config.tokenAddress);\n\n const enabled = Boolean(config.delegatorAddress && config.delegateAddress);\n const baseOpts =\n config.delegatorAddress && config.delegateAddress\n ? delegationStatusQueryOptions(readonlyToken, {\n delegatorAddress: config.delegatorAddress,\n delegateAddress: config.delegateAddress,\n })\n : {\n queryKey: zamaQueryKeys.delegationStatus.all,\n queryFn: skipToken as unknown as () => Promise<DelegationStatusData>,\n };\n\n return useQuery<DelegationStatusData>({\n ...baseOpts,\n enabled,\n ...options,\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 { useMutation, UseMutationOptions } 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, Error>, \"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, Error>, \"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, Error>, \"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, Error>, \"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, Error>, \"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, Error>, \"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, Error>, \"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"],"mappings":"88KAkDA,MAAM,EAAiB,GAA8B,KAAK,CAY1D,SAAgB,GAAa,CAC3B,WACA,UACA,SACA,UACA,iBACA,aACA,aACA,WACoB,CACpB,IAAM,EAAc,GAAgB,CAG9B,EAAa,GAAO,EAAQ,CAClC,MAAgB,CACd,EAAW,QAAU,GACrB,CAEF,IAAM,EAA2B,MAE7B,GAAQ,UACJ,CACE,iBAAoB,EAAiC,EAAY,CACjE,oBAAuB,EAAiC,EAAY,CACpE,kBA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ptions","zamaQueryKeys","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","useQuery","publicKeyQueryOptions","useQuery","publicParamsQueryOptions","useQuery","hashFn","useQuery","signerAddressQueryOptions","confidentialHandleQueryOptions","confidentialBalanceQueryOptions","useQuery","signerAddressQueryOptions","confidentialHandlesQueryOptions","confidentialBalancesQueryOptions","allowMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","isAllowedQueryOptions","zamaQueryKeys","revokeMutationOptions","zamaQueryKeys","revokeSessionMutationOptions","zamaQueryKeys","zamaQueryKeys","confidentialTransferMutationOptions","confidentialTransferFromMutationOptions","confidentialApproveMutationOptions","useQuery","signerAddressQueryOptions","confidentialIsApprovedQueryOptions","zamaQueryKeys","useSuspenseQuery","shieldMutationOptions","shieldETHMutationOptions","unwrapMutationOptions","unwrapAllMutationOptions","finalizeUnwrapMutationOptions","unshieldMutationOptions","unshieldAllMutationOptions","resumeUnshieldMutationOptions","useQuery","signerAddressQueryOptions","underlyingAllowanceQueryOptions","useSuspenseQuery","useQuery","wrapperDiscoveryQueryOptions","zamaQueryKeys","useSuspenseQuery","useQuery","tokenMetadataQueryOptions","useSuspenseQuery","useQuery","activityFeedQueryOptions","delegateDecryptionMutationOptions","zamaQueryKeys","revokeDelegationMutationOptions","zamaQueryKeys","useQuery","delegationStatusQueryOptions","zamaQueryKeys","decryptBalanceAsMutationOptions","ReadonlyToken","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","shieldFeeQueryOptions","useQuery","unshieldFeeQueryOptions","batchTransferFeeQueryOptions","feeRecipientQueryOptions"],"sources":["../src/provider.tsx","../src/relayer/use-encrypt.ts","../src/relayer/decryption-cache.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-decrypt-flow.ts","../src/relayer/use-user-decrypted-value.ts","../src/relayer/use-user-decrypted-values.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/use-allow-tokens.ts","../src/token/use-is-allowed.ts","../src/token/use-revoke-tokens.ts","../src/token/use-revoke-session.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/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"],"sourcesContent":["\"use client\";\n\nimport type {\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 /** 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 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 useEffect(() => {\n onEventRef.current = onEvent;\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 onEvent: onEventRef.current,\n signerLifecycleCallbacks,\n }),\n [relayer, signer, storage, sessionStorage, keypairTTL, sessionTTL, signerLifecycleCallbacks],\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: [1000n], bits: [64] });\n * ```\n */\nexport function useEncrypt() {\n const sdk = useZamaSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(sdk));\n}\n","import { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\n\n/**\n * Query key helpers for the shared decryption cache.\n * Used by useUserDecrypt/usePublicDecrypt to populate,\n * and by useUserDecryptedValue to read.\n */\nexport const decryptionKeys = {\n value: (handle: Handle, contractAddress?: Address) =>\n zamaQueryKeys.decryption.handle(handle, contractAddress),\n};\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle, UserDecryptParams } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Thin wrapper around sdk.userDecrypt().\n * Caller is responsible for providing all params (keypair, signature, etc.).\n * For the full orchestration (signature management, EIP712 signing),\n * see the app-level useUserDecryptFlow hook.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — relayer decryption request failed\n * - {@link InvalidKeypairError} — the provided keypair is invalid\n * - {@link KeypairExpiredError} — the re-encryption keypair has expired\n *\n * On success, populates the decryption cache so useUserDecryptedValue/useUserDecryptedValues\n * can read the results.\n */\nexport function useUserDecrypt() {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptParams>({\n mutationFn: (params) => sdk.relayer.userDecrypt(params),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data) as [Handle, ClearValueType][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle, PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\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 const queryClient = useQueryClient();\n return useMutation<PublicDecryptResult, Error, Handle[]>({\n mutationFn: (handles) => sdk.relayer.publicDecrypt(handles),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data.clearValues) as [\n Handle,\n ClearValueType,\n ][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-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({\n mutationFn: () => sdk.relayer.generateKeypair(),\n });\n}\n","\"use client\";\n\nimport type { EIP712TypedData, Address } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Parameters for {@link useCreateEIP712}. */\nexport interface CreateEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: `0x${string}`;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Unix timestamp (seconds) when the credential becomes valid. */\n startTimestamp: number;\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\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>({\n mutationFn: ({ publicKey, contractAddresses, startTimestamp, durationDays }) =>\n sdk.relayer.createEIP712(publicKey, contractAddresses, startTimestamp, durationDays),\n });\n}\n","\"use client\";\n\nimport type { Address, KmsDelegatedUserDecryptEIP712Type } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Parameters for {@link useCreateDelegatedUserDecryptEIP712}. */\nexport interface CreateDelegatedUserDecryptEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: `0x${string}`;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Address of the wallet that delegated decrypt authority. */\n delegatorAddress: Address;\n /** Unix timestamp (seconds) when the credential becomes valid. */\n startTimestamp: number;\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\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 >({\n mutationFn: ({\n publicKey,\n contractAddresses,\n delegatorAddress,\n startTimestamp,\n durationDays,\n }) =>\n sdk.relayer.createDelegatedUserDecryptEIP712(\n publicKey,\n contractAddresses,\n delegatorAddress,\n startTimestamp,\n durationDays,\n ),\n });\n}\n","\"use client\";\n\nimport type { DelegatedUserDecryptParams, ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-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 mutationFn: (params) => sdk.relayer.delegatedUserDecrypt(params),\n });\n}\n","\"use client\";\n\nimport type { InputProofBytesType, ZKProofLike } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-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 mutationFn: (zkProof) => sdk.relayer.requestZKProofVerification(zkProof),\n });\n}\n","import {\n type DefaultError,\n useQuery as tanstack_useQuery,\n useSuspenseQuery as tanstack_useSuspenseQuery,\n type UseQueryResult,\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 * The `options` parameter is typed as `any` because TanStack Query v5 has:\n * 1. Discriminated overloads around `initialData` (Defined vs Undefined)\n * 2. Function-typed fields (`staleTime`, `enabled`, `gcTime`) that are generic over `TQueryKey`\n *\n * Our factories produce options with specific tuple keys (e.g. `readonly [\"zama.totalSupply\", {...}]`)\n * whose function-typed fields are contravariant with `QueryKey` (`readonly unknown[]`).\n * Typing the parameter as `UseQueryOptions<TData, TError, TData, any>` still fails because\n * the query-key variance leaks through `staleTime`, `enabled`, etc.\n *\n * Hooks must pass explicit generics: `useQuery<DataType>({...})`.\n */\nexport function useQuery<TData = unknown, TError = DefaultError>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: any,\n): UseQueryResult<TData, TError> {\n return tanstack_useQuery({\n ...options,\n queryKeyHashFn: hashFn,\n }) as UseQueryResult<TData, TError>;\n}\n\nexport function useSuspenseQuery<TData = unknown, TError = DefaultError>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: any,\n): UseSuspenseQueryResult<TData, TError> {\n return tanstack_useSuspenseQuery({\n ...options,\n queryKeyHashFn: hashFn,\n }) as UseSuspenseQueryResult<TData, TError>;\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 { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { Address, ClearValueType, Handle, Hex } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/** A handle to decrypt, paired with its originating contract address. */\nexport interface DecryptHandle {\n handle: Handle;\n contractAddress: Address;\n}\n\n/** Parameters for {@link useUserDecryptFlow}. */\nexport interface UserDecryptFlowParams {\n /** Encrypted handles to decrypt. */\n handles: DecryptHandle[];\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\n\n/** Progress callbacks for each step of the decrypt flow. */\nexport interface UserDecryptFlowCallbacks {\n /** Fired after the keypair is generated. */\n onKeypairGenerated?: () => void;\n /** Fired after the EIP-712 typed data is created, before wallet signing. */\n onEIP712Created?: () => void;\n /** Fired after the wallet signature is obtained. */\n onSigned?: (signature: Hex) => void;\n /** Fired after decryption completes. */\n onDecrypted?: (values: Record<Handle, ClearValueType>) => void;\n}\n\n/** Configuration for {@link useUserDecryptFlow}. */\nexport interface UseUserDecryptFlowConfig {\n /** Optional progress callbacks. */\n callbacks?: UserDecryptFlowCallbacks;\n}\n\n/**\n * High-level orchestration hook for user decryption.\n * Handles the full flow: keypair generation → EIP-712 creation → wallet signature → decryption.\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 UserDecryptFlowParams}.\n *\n * @example\n * ```tsx\n * const decryptFlow = useUserDecryptFlow({\n * callbacks: { onSigned: () => setStep(\"decrypting\") },\n * });\n * decryptFlow.mutate({\n * handles: [{ handle: \"0xHandle\", contractAddress: \"0xContract\" }],\n * durationDays: 7,\n * });\n * ```\n */\nexport function useUserDecryptFlow(config?: UseUserDecryptFlowConfig) {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n const callbacks = config?.callbacks;\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptFlowParams>({\n mutationKey: [\"userDecryptFlow\"],\n mutationFn: async ({ handles, durationDays = 1 }) => {\n // Step 1: Generate keypair\n const keypair = await sdk.relayer.generateKeypair();\n callbacks?.onKeypairGenerated?.();\n\n // Step 2: Create EIP-712 typed data\n const contractAddresses = [...new Set(handles.map((h) => h.contractAddress))];\n const startTimestamp = Math.floor(Date.now() / 1000);\n const eip712 = await sdk.relayer.createEIP712(\n keypair.publicKey,\n contractAddresses,\n startTimestamp,\n durationDays,\n );\n callbacks?.onEIP712Created?.();\n\n // Step 3: Sign with wallet\n const signature = await sdk.signer.signTypedData(eip712);\n callbacks?.onSigned?.(signature);\n\n // Step 4: Decrypt — group handles by contract address\n const signerAddress = await sdk.signer.getAddress();\n const allResults: Partial<Record<Handle, ClearValueType>> = {};\n\n // Decrypt per contract address (the relayer requires handles from the same contract)\n const handlesByContract = new Map<Address, Handle[]>();\n for (const h of handles) {\n const list = handlesByContract.get(h.contractAddress) ?? [];\n list.push(h.handle);\n handlesByContract.set(h.contractAddress, list);\n }\n\n for (const [contractAddress, contractHandles] of handlesByContract) {\n const result = await sdk.relayer.userDecrypt({\n handles: contractHandles,\n contractAddress,\n signedContractAddresses: contractAddresses,\n privateKey: keypair.privateKey,\n publicKey: keypair.publicKey,\n signature,\n signerAddress,\n startTimestamp,\n durationDays,\n });\n Object.assign(allResults, result);\n }\n\n const results = allResults as Record<Handle, ClearValueType>;\n callbacks?.onDecrypted?.(results);\n return results;\n },\n onSuccess: (data) => {\n // Populate the shared decryption cache\n for (const [handle, value] of Object.entries(data) as [Handle, ClearValueType][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\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(decryptionKeys.value(handle), value).\n */\nexport function useUserDecryptedValue(handle: Handle | undefined) {\n return useQuery<ClearValueType>({\n queryKey: decryptionKeys.value(handle ?? \"0x\"),\n queryFn: () => undefined as never,\n enabled: false,\n });\n}\n","\"use client\";\n\nimport { useQueries } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\nimport { decryptionKeys } from \"./decryption-cache\";\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: decryptionKeys.value(handle),\n queryKeyHashFn: hashFn,\n queryFn: () => undefined as never,\n enabled: false,\n })),\n });\n\n const data: Partial<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 { 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 type UseConfidentialBalanceOptions = Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">;\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 userEnabled = options?.enabled;\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 ?? true) && (userEnabled ?? true),\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 ?? true) && (userEnabled ?? true),\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 type UseConfidentialBalancesOptions = Omit<\n UseQueryOptions<ConfidentialBalancesData>,\n \"queryKey\" | \"queryFn\"\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 userEnabled = options?.enabled;\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 ?? true) && (userEnabled ?? true),\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 && (userEnabled ?? true),\n });\n\n return { ...balancesQuery, handlesQuery };\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 * Pre-authorize FHE decrypt credentials for a list of token addresses.\n * A single wallet signature covers all addresses, so subsequent decrypt\n * operations on any of these tokens 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: allowTokens, isPending } = useAllowTokens();\n * // Call allowTokens(allTokenAddresses) before any individual reveal\n * ```\n */\nexport function useAllowTokens(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 };\n const factoryEnabled = \"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true;\n\n return useQuery({\n ...baseOpts,\n enabled: factoryEnabled,\n });\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 credentials for a list of token addresses.\n * The next decrypt operation will require a fresh wallet signature.\n *\n * @example\n * ```tsx\n * const { mutate: revokeTokens } = useRevokeTokens();\n * revokeTokens([\"0xTokenA\", \"0xTokenB\"]);\n * ```\n */\nexport function useRevokeTokens(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","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 { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n confidentialIsApprovedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\nexport { confidentialIsApprovedQueryOptions };\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig extends UseZamaConfig {\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 { spender, holder, ...tokenConfig } = config;\n const userEnabled = options?.enabled;\n const token = useToken(tokenConfig);\n const holderQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n enabled: holder === undefined,\n });\n const resolvedHolder = holder ?? holderQuery.data;\n\n const baseOpts =\n spender && resolvedHolder\n ? confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n })\n : {\n queryKey: zamaQueryKeys.confidentialIsApproved.token(config.tokenAddress),\n queryFn: skipToken,\n };\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: (\"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true) && (userEnabled ?? 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 { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { wrapperDiscoveryQueryOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { wrapperDiscoveryQueryOptions };\n\n/** Configuration for {@link useWrapperDiscovery}. */\nexport interface UseWrapperDiscoveryConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper coordinator. Pass `undefined` to disable the query. */\n coordinatorAddress: Address | undefined;\n}\n\n/** Configuration for {@link useWrapperDiscoverySuspense}. */\nexport interface UseWrapperDiscoverySuspenseConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper coordinator. */\n coordinatorAddress: Address;\n}\n\n/**\n * Discover the wrapper contract for an ERC-20 token.\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 coordinator 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: \"0xUnderlying\",\n * coordinatorAddress: \"0xCoordinator\",\n * });\n * ```\n */\nexport function useWrapperDiscovery(\n config: UseWrapperDiscoveryConfig,\n options?: Omit<UseQueryOptions<Address | null>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<Address | null>({\n ...(coordinatorAddress\n ? wrapperDiscoveryQueryOptions(token.signer, tokenAddress, { coordinatorAddress })\n : {\n queryKey: zamaQueryKeys.wrapperDiscovery.all,\n queryFn: skipToken,\n }),\n ...options,\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 coordinator addresses.\n * @returns Suspense query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscoverySuspense({\n * tokenAddress: \"0xUnderlying\",\n * coordinatorAddress: \"0xCoordinator\",\n * });\n * ```\n */\nexport function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig) {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<Address | null>({\n ...wrapperDiscoveryQueryOptions(token.signer, tokenAddress, { coordinatorAddress }),\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 context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n options?.onSuccess?.(data, variables, onMutateResult, context);\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 context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n delegationStatusQueryOptions,\n zamaQueryKeys,\n type DelegationStatusData,\n} from \"@zama-fhe/sdk/query\";\nimport { useQuery } from \"../utils/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport interface UseDelegationStatusConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\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, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const readonlyToken = useReadonlyToken(config.tokenAddress);\n\n const enabled = Boolean(config.delegatorAddress && config.delegateAddress);\n const baseOpts =\n config.delegatorAddress && config.delegateAddress\n ? delegationStatusQueryOptions(readonlyToken, {\n delegatorAddress: config.delegatorAddress,\n delegateAddress: config.delegateAddress,\n })\n : {\n queryKey: zamaQueryKeys.delegationStatus.all,\n queryFn: skipToken as unknown as () => Promise<DelegationStatusData>,\n };\n\n return useQuery<DelegationStatusData>({\n ...baseOpts,\n enabled,\n ...options,\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"],"mappings":"88KAiDA,MAAM,EAAiB,GAA8B,KAAK,CAY1D,SAAgB,GAAa,CAC3B,WACA,UACA,SACA,UACA,iBACA,aACA,aACA,WACoB,CACpB,IAAM,EAAc,GAAgB,CAG9B,EAAa,GAAO,EAAQ,CAClC,MAAgB,CACd,EAAW,QAAU,GACrB,CAE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,EAAS,SAAW,MAAU,GAAS,SAAW,IAC7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zama-fhe/react-sdk",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.5",
|
|
4
4
|
"description": "React hooks for Zama SDK",
|
|
5
5
|
"license": "BSD-3-Clause-Clear",
|
|
6
6
|
"author": "Zama",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@zama-fhe/sdk": "workspace:*",
|
|
56
56
|
"rolldown": "1.0.0-rc.7",
|
|
57
|
-
"rolldown-plugin-dts": "^0.22.
|
|
58
|
-
"viem": "^2.47.
|
|
57
|
+
"rolldown-plugin-dts": "^0.22.5",
|
|
58
|
+
"viem": "^2.47.4"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@tanstack/react-query": ">=5",
|
|
62
|
-
"@zama-fhe/sdk": "^1.2.0-alpha.
|
|
62
|
+
"@zama-fhe/sdk": "^1.2.0-alpha.5",
|
|
63
63
|
"react": ">=18",
|
|
64
64
|
"viem": "^2.47.0",
|
|
65
65
|
"wagmi": ">=2"
|