@zama-fhe/react-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +383 -114
- package/dist/index.d.ts +771 -1102
- package/dist/index.js +1 -977
- package/dist/index.js.map +1 -1
- package/dist/wagmi/index.d.ts +25 -7125
- package/dist/wagmi/index.js +1 -268
- package/dist/wagmi/index.js.map +1 -1
- package/package.json +13 -27
- package/dist/ethers/index.d.ts +0 -162
- package/dist/ethers/index.js +0 -173
- package/dist/ethers/index.js.map +0 -1
- package/dist/viem/index.d.ts +0 -162
- package/dist/viem/index.js +0 -173
- package/dist/viem/index.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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/relayer/use-public-key.ts","../src/relayer/use-public-params.ts","../src/relayer/use-user-decrypted-value.ts","../src/relayer/use-user-decrypted-values.ts","../src/token/use-token.ts","../src/token/use-readonly-token.ts","../src/token/balance-query-keys.ts","../src/token/use-confidential-balance.ts","../src/token/use-confidential-balances.ts","../src/token/use-authorize-all.ts","../src/token/use-confidential-transfer.ts","../src/token/use-confidential-transfer-from.ts","../src/token/use-confidential-is-approved.ts","../src/token/use-confidential-approve.ts","../src/token/use-wrap.ts","../src/token/use-wrap-eth.ts","../src/token/use-unwrap.ts","../src/token/use-unwrap-all.ts","../src/token/use-underlying-allowance.ts","../src/token/use-finalize-unwrap.ts","../src/token/use-unshield.ts","../src/token/use-unshield-all.ts","../src/token/use-wrapper-discovery.ts","../src/token/use-token-metadata.ts","../src/token/use-activity-feed.ts","../src/token/use-approve-underlying.ts","../src/token/use-is-confidential.ts","../src/token/use-total-supply.ts","../src/token/use-fees.ts"],"names":["useMutation","useQueryClient","useQuery","useMemo","useEffect","DEFAULT_HANDLE_REFETCH_INTERVAL","useState","ReadonlyToken","useSuspenseQuery","skipToken"],"mappings":";;;;;;;AAgBA,IAAM,eAAA,GAAkB,cAA+B,IAAI,CAAA;AAapD,SAAS,iBAAiB,EAAE,QAAA,EAAU,OAAA,EAAS,MAAA,EAAQ,SAAQ,EAA0B;AAC9F,EAAA,MAAM,GAAA,GAAM,OAAA;AAAA,IACV,MACE,IAAI,QAAA,CAAS;AAAA,MACX,OAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,IACH,CAAC,OAAA,EAAS,MAAA,EAAQ,OAAO;AAAA,GAC3B;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,OAAO,MAAM,IAAI,SAAA,EAAU;AAAA,EAC7B,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AAER,EAAA,2BAAQ,eAAA,CAAgB,QAAA,EAAhB,EAAyB,KAAA,EAAO,KAAM,QAAA,EAAS,CAAA;AACzD;AAYO,SAAS,WAAA,GAAwB;AACtC,EAAA,MAAM,OAAA,GAAU,WAAW,eAAe,CAAA;AAE1C,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,oDAAoD,CAAA;AAAA,EACtE;AAEA,EAAA,OAAO,OAAA;AACT;ACrDO,SAAS,uBAAuB,GAAA,EAAe;AACpD,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,CAAC,SAAS,CAAA;AAAA,IACvB,YAAY,CAAC,MAAA,KAA0B,GAAA,CAAI,OAAA,CAAQ,QAAQ,MAAM;AAAA,GACnE;AACF;AAcO,SAAS,UAAA,GAAa;AAC3B,EAAA,MAAM,MAAM,WAAA,EAAY;AACxB,EAAA,OAAO,WAAA,CAAiD,sBAAA,CAAuB,GAAG,CAAC,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AAA,IAC7B,GAAG,4BAAA,CAA6B,GAAA,CAAI,MAAA,EAAQ,iBAAiB,CAAA;AAAA,IAC7D,GAAG;AAAA,GACJ,CAAA;AACH;AAcO,SAAS,eAAA,CACd,mBACA,OAAA,EACgC;AAChC,EAAA,MAAM,MAAM,WAAA,EAAY;AAExB,EAAA,OAAOA,QAAAA,CAAyB;AAAA,IAC9B,GAAG,wBAAA,CAAyB,GAAA,CAAI,MAAA,EAAQ,iBAAiB,CAAA;AAAA,IACzD,GAAG;AAAA,GACJ,CAAA;AACH","file":"index.js","sourcesContent":["\"use client\";\n\nimport type { GenericSigner, GenericStringStorage, RelayerSDK } from \"@zama-fhe/sdk\";\nimport { TokenSDK } from \"@zama-fhe/sdk\";\nimport { createContext, type PropsWithChildren, useContext, useEffect, useMemo } from \"react\";\n\n/** Props for {@link TokenSDKProvider}. */\ninterface TokenSDKProviderProps extends PropsWithChildren {\n /** FHE relayer backend (RelayerWeb for browser, RelayerNode for server). */\n relayer: RelayerSDK;\n /** Wallet signer (ViemSigner, EthersSigner, or custom GenericSigner). */\n signer: GenericSigner;\n /** Credential storage backend (IndexedDBStorage for browser, MemoryStorage for tests). */\n storage: GenericStringStorage;\n}\n\nconst TokenSDKContext = createContext<TokenSDK | null>(null);\n\n/**\n * Provides a {@link TokenSDK} instance to all descendant hooks.\n * Terminates the relayer on unmount.\n *\n * @example\n * ```tsx\n * <TokenSDKProvider relayer={relayer} signer={signer} storage={storage}>\n * <App />\n * </TokenSDKProvider>\n * ```\n */\nexport function TokenSDKProvider({ children, relayer, signer, storage }: TokenSDKProviderProps) {\n const sdk = useMemo(\n () =>\n new TokenSDK({\n relayer,\n signer,\n storage,\n }),\n [relayer, signer, storage],\n );\n\n useEffect(() => {\n return () => sdk.terminate();\n }, [sdk]);\n\n return <TokenSDKContext.Provider value={sdk}>{children}</TokenSDKContext.Provider>;\n}\n\n/**\n * Access the {@link TokenSDK} instance from context.\n * Must be used within a {@link TokenSDKProvider}.\n *\n * @example\n * ```tsx\n * const sdk = useTokenSDK();\n * const token = sdk.createReadonlyToken(\"0x...\");\n * ```\n */\nexport function useTokenSDK(): TokenSDK {\n const context = useContext(TokenSDKContext);\n\n if (!context) {\n throw new Error(\"useTokenSDK must be used within a TokenSDKProvider\");\n }\n\n return context;\n}\n","\"use client\";\n\nimport type { EncryptParams, EncryptResult, TokenSDK } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useTokenSDK } from \"../provider\";\n\n/**\n * TanStack Query mutation options factory for FHE encrypt.\n *\n * @param sdk - A `TokenSDK` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function encryptMutationOptions(sdk: TokenSDK) {\n return {\n mutationKey: [\"encrypt\"] as const,\n mutationFn: (params: EncryptParams) => sdk.relayer.encrypt(params),\n };\n}\n\n/**\n * Encrypt a plaintext value using FHE.\n * Calls the relayer's `encrypt` method via a mutation.\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 = useTokenSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(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: string) => [\"decryptedValue\", handle] as const,\n};\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { UserDecryptParams } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useTokenSDK } 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 * On success, populates the decryption cache so useUserDecryptedValue/useUserDecryptedValues\n * can read the results.\n */\nexport function useUserDecrypt() {\n const sdk = useTokenSDK();\n const queryClient = useQueryClient();\n\n return useMutation<Record<string, bigint>, Error, UserDecryptParams>({\n mutationFn: (params) => sdk.relayer.userDecrypt(params),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data)) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useTokenSDK } 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 = useTokenSDK();\n const queryClient = useQueryClient();\n return useMutation<PublicDecryptResult, Error, string[]>({\n mutationFn: (handles) => sdk.relayer.publicDecrypt(handles),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data.clearValues)) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport type { FHEKeypair } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useTokenSDK } 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 * @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 = useTokenSDK();\n return useMutation<FHEKeypair, Error, void>({\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 { useTokenSDK } from \"../provider\";\n\n/** Parameters for {@link useCreateEIP712}. */\nexport interface CreateEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: string;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: `0x${string}`[];\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 = useTokenSDK();\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 { useTokenSDK } from \"../provider\";\n\n/** Parameters for {@link useCreateDelegatedUserDecryptEIP712}. */\nexport interface CreateDelegatedUserDecryptEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: string;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Address of the wallet that delegated decrypt authority. */\n delegatorAddress: string;\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 = useTokenSDK();\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 } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useTokenSDK } 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 = useTokenSDK();\n return useMutation<Record<string, bigint>, 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 { useTokenSDK } 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 = useTokenSDK();\n return useMutation<InputProofBytesType, Error, ZKProofLike>({\n mutationFn: (zkProof) => sdk.relayer.requestZKProofVerification(zkProof),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { TokenSDK } from \"@zama-fhe/sdk\";\nimport { useTokenSDK } from \"../provider\";\n\n/**\n * Query key factory for the FHE public key query.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const publicKeyQueryKeys = {\n /** Match the public key query. */\n all: [\"publicKey\"] as const,\n} as const;\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\ntype PublicKeyResult = PublicKeyData | null;\n\n/**\n * TanStack Query options factory for the FHE public key.\n *\n * @param sdk - A `TokenSDK` instance.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function publicKeyQueryOptions(sdk: TokenSDK) {\n return {\n queryKey: publicKeyQueryKeys.all,\n queryFn: () => sdk.relayer.getPublicKey() as Promise<PublicKeyResult>,\n staleTime: Infinity,\n } as const;\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 = useTokenSDK();\n return useQuery<PublicKeyResult, Error>(publicKeyQueryOptions(sdk));\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { TokenSDK } from \"@zama-fhe/sdk\";\nimport { useTokenSDK } from \"../provider\";\n\n/**\n * Query key factory for FHE public params queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const publicParamsQueryKeys = {\n /** Match all public params queries. */\n all: [\"publicParams\"] as const,\n /** Match public params query for a specific bit size. */\n bits: (bits: number) => [\"publicParams\", bits] as const,\n} as const;\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\ntype PublicParamsResult = PublicParamsData | null;\n\n/**\n * TanStack Query options factory for FHE public parameters.\n *\n * @param sdk - A `TokenSDK` instance.\n * @param bits - The FHE bit size to fetch parameters for (e.g. 2048).\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function publicParamsQueryOptions(sdk: TokenSDK, bits: number) {\n return {\n queryKey: publicParamsQueryKeys.bits(bits),\n queryFn: () => sdk.relayer.getPublicParams(bits) as Promise<PublicParamsResult>,\n staleTime: Infinity,\n } as const;\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 = useTokenSDK();\n return useQuery<PublicParamsResult, Error>(publicParamsQueryOptions(sdk, bits));\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\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: string | undefined) {\n return useQuery<bigint>({\n queryKey: decryptionKeys.value(handle ?? \"\"),\n queryFn: () => undefined as never,\n enabled: false,\n });\n}\n","\"use client\";\n\nimport { useQueries } from \"@tanstack/react-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: string[]) {\n const results = useQueries({\n queries: handles.map((handle) => ({\n queryKey: decryptionKeys.value(handle),\n queryFn: () => undefined as never,\n enabled: false,\n })),\n });\n\n const data: Record<string, bigint | undefined> = {};\n for (let i = 0; i < handles.length; i++) {\n data[handles[i]!] = results[i]!.data as bigint | 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 { useTokenSDK } from \"../provider\";\n\n/** Base configuration shared by all mutation hooks that need a Token instance. */\nexport interface UseTokenConfig {\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 TokenSDKProvider}.\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: UseTokenConfig) {\n const sdk = useTokenSDK();\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 { useTokenSDK } 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 TokenSDKProvider}.\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 = useTokenSDK();\n\n return useMemo(() => sdk.createReadonlyToken(address), [sdk, address]);\n}\n","import { Query } from \"@tanstack/react-query\";\nimport { Address } from \"@zama-fhe/sdk\";\n\n/**\n * Query key factories for confidential balance queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()` / `removeQueries()`.\n *\n * @example\n * ```ts\n * // Invalidate all balance queries\n * queryClient.invalidateQueries({ queryKey: confidentialBalanceQueryKeys.all });\n *\n * // Reset balance for a specific token + owner\n * queryClient.resetQueries({\n * queryKey: confidentialBalanceQueryKeys.owner(\"0xToken\", \"0xOwner\"),\n * });\n * ```\n */\nexport const confidentialBalanceQueryKeys = {\n /** Match all single-token balance queries. */\n all: [\"confidentialBalance\"] as const,\n /** Match balance queries for a specific token (any owner). */\n token: (tokenAddress: string) => [\"confidentialBalance\", tokenAddress] as const,\n /** Match balance query for a specific token + owner. */\n owner: (tokenAddress: string, owner: string) =>\n [\"confidentialBalance\", tokenAddress, owner] as const,\n} as const;\n\n/**\n * Query key factory for batch balance queries (multiple tokens).\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const confidentialBalancesQueryKeys = {\n /** Match all batch balance queries. */\n all: [\"confidentialBalances\"] as const,\n /** Match batch balance query for a specific token set + owner. */\n tokens: (tokenAddresses: string[], owner: string) =>\n [\"confidentialBalances\", tokenAddresses, owner] as const,\n} as const;\n\n/**\n * Query key factory for encrypted handle queries (Phase 1 of two-phase polling).\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const confidentialHandleQueryKeys = {\n /** Match all single-token handle queries. */\n all: [\"confidentialHandle\"] as const,\n /** Match handle queries for a specific token (any owner). */\n token: (tokenAddress: string) => [\"confidentialHandle\", tokenAddress] as const,\n /** Match handle query for a specific token + owner. */\n owner: (tokenAddress: string, owner: string) =>\n [\"confidentialHandle\", tokenAddress, owner] as const,\n} as const;\n\n/**\n * Query key factory for batch encrypted handle queries (Phase 1, multiple tokens).\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const confidentialHandlesQueryKeys = {\n /** Match all batch handle queries. */\n all: [\"confidentialHandles\"] as const,\n /** Match batch handle query for a specific token set + owner. */\n tokens: (tokenAddresses: string[], owner: string) =>\n [\"confidentialHandles\", tokenAddresses, owner] as const,\n} as const;\n\n/**\n * Query key matching wagmi's `useBalance` cache (`['balance', ...]`).\n * Invalidate after operations that change the underlying ERC-20 balance\n * (e.g. unshield, finalize unwrap) so wagmi refetches automatically.\n *\n * Requires the app to share the same `QueryClient` between wagmi and `TokenSDKProvider`.\n */\nexport const wagmiBalancePredicates = {\n /** Match all wagmi balance queries. */\n balanceOf: (query: Query) =>\n Array.isArray(query.queryKey) &&\n query.queryKey.some(\n (key) =>\n typeof key === \"object\" &&\n key !== null &&\n \"functionName\" in key &&\n key.functionName === \"balanceOf\",\n ),\n balanceOfAddress: (address: Address) => (query: Query) =>\n query.queryKey[0] === \"readContracts\" &&\n typeof query.queryKey[1] === \"object\" &&\n query.queryKey[1] !== null &&\n \"contracts\" in query.queryKey[1] &&\n Array.isArray(query.queryKey[1].contracts) &&\n query.queryKey[1].contracts.some(\n (c) => c.address === address && c.functionName === \"balanceOf\",\n ),\n} as const;\n","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useQuery, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\nimport { confidentialBalanceQueryKeys, confidentialHandleQueryKeys } from \"./balance-query-keys\";\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\nconst DEFAULT_HANDLE_REFETCH_INTERVAL = 10_000;\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 token = useReadonlyToken(tokenAddress);\n // Resolve the signer address for stable query keys.\n // This prevents cache collisions when wallet switches.\n const [signerAddress, setSignerAddress] = useState<Address | undefined>();\n\n const [signerError, setSignerError] = useState<Error | undefined>();\n\n useEffect(() => {\n let cancelled = false;\n setSignerError(undefined);\n token.signer\n .getAddress()\n .then((addr) => {\n if (!cancelled) setSignerAddress(addr);\n })\n .catch((error: unknown) => {\n if (!cancelled) {\n setSignerAddress(undefined);\n setSignerError(error instanceof Error ? error : new Error(String(error)));\n }\n });\n return () => {\n cancelled = true;\n };\n }, [token.signer]);\n\n const ownerKey = signerAddress ?? \"\";\n\n // Phase 1: Poll the encrypted handle (cheap RPC read, no signing)\n const handleQuery = useQuery<Address, Error>({\n queryKey: confidentialHandleQueryKeys.owner(tokenAddress, ownerKey),\n queryFn: () => token.confidentialBalanceOf(),\n enabled: !!signerAddress,\n refetchInterval: handleRefetchInterval ?? DEFAULT_HANDLE_REFETCH_INTERVAL,\n });\n\n const handle = handleQuery.data;\n\n // Phase 2: Decrypt only when handle changes (expensive relayer roundtrip)\n const balanceQuery = useQuery<bigint, Error>({\n queryKey: [...confidentialBalanceQueryKeys.owner(tokenAddress, ownerKey), handle ?? \"\"],\n queryFn: () => token.decryptBalance(handle!),\n enabled: !!signerAddress && !!handle,\n staleTime: Infinity,\n ...options,\n });\n\n return { ...balanceQuery, handleQuery, signerError };\n}\n","\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useQuery, type UseQueryOptions } from \"@tanstack/react-query\";\nimport { ReadonlyToken, type Address } from \"@zama-fhe/sdk\";\nimport { useTokenSDK } from \"../provider\";\nimport { confidentialBalancesQueryKeys, confidentialHandlesQueryKeys } from \"./balance-query-keys\";\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}\n\n/** Query options for the decrypt phase of {@link useConfidentialBalances}. */\nexport type UseConfidentialBalancesOptions = Omit<\n UseQueryOptions<Map<Address, bigint>, Error>,\n \"queryKey\" | \"queryFn\"\n>;\n\nconst DEFAULT_HANDLE_REFETCH_INTERVAL = 10_000;\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 * @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 (Map of address → balance) plus `handlesQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data: balances } = useConfidentialBalances({\n * tokenAddresses: [\"0xTokenA\", \"0xTokenB\"],\n * });\n * const balance = balances?.get(\"0xTokenA\");\n * ```\n */\nexport function useConfidentialBalances(\n config: UseConfidentialBalancesConfig,\n options?: UseConfidentialBalancesOptions,\n) {\n const { tokenAddresses, handleRefetchInterval } = config;\n const sdk = useTokenSDK();\n // Resolve the signer address for stable query keys.\n // This prevents cache collisions when wallet switches.\n const [signerAddress, setSignerAddress] = useState<Address | undefined>();\n\n const [signerError, setSignerError] = useState<Error | undefined>();\n\n useEffect(() => {\n let cancelled = false;\n setSignerError(undefined);\n sdk.signer\n .getAddress()\n .then((addr) => {\n if (!cancelled) setSignerAddress(addr);\n })\n .catch((error: unknown) => {\n if (!cancelled) {\n setSignerAddress(undefined);\n setSignerError(error instanceof Error ? error : new Error(String(error)));\n }\n });\n return () => {\n cancelled = true;\n };\n }, [sdk.signer]);\n\n const ownerKey = signerAddress ?? \"\";\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 handlesQuery = useQuery<Address[], Error>({\n queryKey: confidentialHandlesQueryKeys.tokens(tokenAddresses, ownerKey),\n queryFn: () => Promise.all(tokens.map((t) => t.confidentialBalanceOf())),\n enabled: tokenAddresses.length > 0 && !!signerAddress,\n refetchInterval: handleRefetchInterval ?? DEFAULT_HANDLE_REFETCH_INTERVAL,\n });\n\n const handles = handlesQuery.data;\n const handlesKey = handles?.join(\",\") ?? \"\";\n\n // Phase 2: Batch decrypt only when any handle changes\n const balancesQuery = useQuery<Map<Address, bigint>, Error>({\n queryKey: [...confidentialBalancesQueryKeys.tokens(tokenAddresses, ownerKey), handlesKey],\n queryFn: async () => {\n const raw = await ReadonlyToken.batchDecryptBalances(tokens, handles!);\n // Re-key the Map with the caller's original addresses so lookups\n // work regardless of address casing (tokens normalize to lowercase).\n const result = new Map<Address, bigint>();\n for (let i = 0; i < tokens.length; i++) {\n const balance = raw.get(tokens[i]!.address);\n if (balance !== undefined) result.set(tokenAddresses[i]!, balance);\n }\n return result;\n },\n enabled: tokenAddresses.length > 0 && !!signerAddress && !!handles,\n staleTime: Infinity,\n ...options,\n });\n\n return { ...balancesQuery, handlesQuery, signerError };\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { ReadonlyToken, type Address, type TokenSDK } from \"@zama-fhe/sdk\";\nimport { useTokenSDK } from \"../provider\";\n\n/**\n * TanStack Query mutation options factory for authorize-all.\n *\n * @param sdk - A `TokenSDK` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function authorizeAllMutationOptions(sdk: TokenSDK) {\n return {\n mutationKey: [\"authorizeAll\"] as const,\n mutationFn: async (tokenAddresses: Address[]) => {\n const tokens = tokenAddresses.map((addr) => sdk.createReadonlyToken(addr));\n return ReadonlyToken.authorizeAll(tokens);\n },\n };\n}\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 * @example\n * ```tsx\n * const { mutateAsync: authorizeAll, isPending } = useAuthorizeAll();\n * // Call authorizeAll(allTokenAddresses) before any individual reveal\n * ```\n */\nexport function useAuthorizeAll() {\n const sdk = useTokenSDK();\n\n return useMutation<void, Error, Address[]>(authorizeAllMutationOptions(sdk));\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n} from \"./balance-query-keys\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/** Parameters passed to the `mutate` function of {@link useConfidentialTransfer}. */\nexport interface ConfidentialTransferParams {\n /** Recipient address. */\n to: Address;\n /** Amount to transfer (plaintext — encrypted automatically). */\n amount: bigint;\n}\n\n/** Configuration for {@link useConfidentialTransfer}. */\nexport interface UseConfidentialTransferConfig extends UseTokenConfig {\n /**\n * When `true`, optimistically subtracts the transfer amount from cached balance\n * before the transaction confirms. Rolls back on error.\n * @default false\n */\n optimistic?: boolean;\n}\n\n/**\n * TanStack Query mutation options factory for confidential transfer.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function confidentialTransferMutationOptions(token: Token) {\n return {\n mutationKey: [\"confidentialTransfer\", token.address] as const,\n mutationFn: ({ to, amount }: ConfidentialTransferParams) =>\n token.confidentialTransfer(to, amount),\n };\n}\n\n/**\n * Encrypt and send a confidential transfer. Invalidates balance caches on success.\n *\n * Errors are {@link TokenError} 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(\n config: UseConfidentialTransferConfig,\n options?: UseMutationOptions<Address, Error, ConfidentialTransferParams, Address>,\n) {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation<Address, Error, ConfidentialTransferParams, Address>({\n mutationKey: [\"confidentialTransfer\", config.tokenAddress],\n mutationFn: ({ to, amount }) => token.confidentialTransfer(to, amount),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const balanceKey = confidentialBalanceQueryKeys.token(config.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 queryClient.setQueryData(key, value - variables.amount);\n }\n }\n return (options?.onMutate?.(variables, mutationContext) ??\n config.tokenAddress) as Address;\n }\n : options?.onMutate,\n onError: (error, variables, onMutateResult, context) => {\n if (config.optimistic) {\n // Rollback: invalidate to refetch actual values\n queryClient.invalidateQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n }\n options?.onError?.(error, variables, onMutateResult, context);\n },\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n} from \"./balance-query-keys\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/** Parameters passed to the `mutate` function of {@link useConfidentialTransferFrom}. */\nexport interface ConfidentialTransferFromParams {\n /** Address to transfer from. Caller must be an approved operator. */\n from: Address;\n /** Recipient address. */\n to: Address;\n /** Amount to transfer (plaintext — encrypted automatically). */\n amount: bigint;\n}\n\n/**\n * TanStack Query mutation options factory for confidential transfer-from.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function confidentialTransferFromMutationOptions(token: Token) {\n return {\n mutationKey: [\"confidentialTransferFrom\", token.address] as const,\n mutationFn: ({ from, to, amount }: ConfidentialTransferFromParams) =>\n token.confidentialTransferFrom(from, to, amount),\n };\n}\n\n/**\n * Operator transfer on behalf of another address. Caller must be an approved operator.\n * Invalidates balance caches on success.\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: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, ConfidentialTransferFromParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, ConfidentialTransferFromParams, Address>({\n mutationKey: [\"confidentialTransferFrom\", config.tokenAddress],\n mutationFn: ({ from, to, amount }) => token.confidentialTransferFrom(from, to, amount),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery, skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/**\n * Query key factory for confidential approval queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const confidentialIsApprovedQueryKeys = {\n /** Match all approval queries. */\n all: [\"confidentialIsApproved\"] as const,\n /** Match approval queries for a specific token. */\n token: (tokenAddress: string) => [\"confidentialIsApproved\", tokenAddress] as const,\n /** Match approval queries for a specific token + spender pair. */\n spender: (tokenAddress: string, spender: string) =>\n [\"confidentialIsApproved\", tokenAddress, spender] as const,\n} as const;\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig extends UseTokenConfig {\n /** Address to check approval for. Pass `undefined` to disable the query. */\n spender: Address | undefined;\n}\n\n/** Configuration for {@link useConfidentialIsApprovedSuspense}. */\nexport interface UseConfidentialIsApprovedSuspenseConfig extends UseTokenConfig {\n /** Address to check approval for. */\n spender: Address;\n}\n\n/**\n * TanStack Query options factory for confidential approval check.\n *\n * @param token - A `Token` instance.\n * @param spender - Address to check approval for.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function confidentialIsApprovedQueryOptions(token: Token, spender: Address) {\n return {\n queryKey: confidentialIsApprovedQueryKeys.spender(token.address, spender),\n queryFn: () => token.isApproved(spender),\n staleTime: 30_000,\n } as const;\n}\n\n/**\n * Check if a spender is an approved operator for the connected wallet.\n *\n * @param config - Token address and spender 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 * });\n * ```\n */\nexport function useConfidentialIsApproved(\n config: UseConfidentialIsApprovedConfig,\n options?: Omit<UseQueryOptions<boolean, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { spender, ...tokenConfig } = config;\n const token = useToken(tokenConfig);\n\n return useQuery<boolean, Error>({\n ...(spender\n ? confidentialIsApprovedQueryOptions(token, spender)\n : {\n queryKey: confidentialIsApprovedQueryKeys.spender(config.tokenAddress, \"\"),\n queryFn: skipToken,\n }),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useConfidentialIsApproved}.\n * Suspends rendering until the approval check resolves.\n *\n * @param config - Token address and spender 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 * });\n * ```\n */\nexport function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig) {\n const { spender, ...tokenConfig } = config;\n const token = useToken(tokenConfig);\n\n return useSuspenseQuery<boolean, Error>(confidentialIsApprovedQueryOptions(token, spender));\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\nimport { confidentialIsApprovedQueryKeys } from \"./use-confidential-is-approved\";\n\n/** Parameters passed to the `mutate` function of {@link useConfidentialApprove}. */\nexport interface ConfidentialApproveParams {\n /** Address to approve as operator. */\n spender: Address;\n /** Unix timestamp until which the approval is valid. Defaults to 1 hour from now. */\n until?: number;\n}\n\n/**\n * TanStack Query mutation options factory for confidential approve.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function confidentialApproveMutationOptions(token: Token) {\n return {\n mutationKey: [\"confidentialApprove\", token.address] as const,\n mutationFn: ({ spender, until }: ConfidentialApproveParams) => token.approve(spender, until),\n };\n}\n\n/**\n * Set operator approval for a confidential token. Defaults to 1 hour.\n *\n * Errors are {@link TokenError} 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: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, ConfidentialApproveParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, ConfidentialApproveParams, Address>({\n mutationKey: [\"confidentialApprove\", config.tokenAddress],\n mutationFn: ({ spender, until }) => token.approve(spender, until),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialIsApprovedQueryKeys.token(config.tokenAddress),\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n wagmiBalancePredicates,\n} from \"./balance-query-keys\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/** Parameters passed to the `mutate` function of {@link useWrap}. */\nexport interface WrapParams {\n /** Amount of underlying ERC-20 tokens to wrap. */\n amount: bigint;\n /** Optional fee amount (for native ETH wrapping with fees). */\n fees?: bigint;\n /** ERC-20 approval strategy: `\"exact\"` (default), `\"max\"`, or `\"skip\"`. */\n approvalStrategy?: \"max\" | \"exact\" | \"skip\";\n}\n\n/** Configuration for {@link useWrap}. */\nexport interface UseWrapConfig extends UseTokenConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @default false\n */\n optimistic?: boolean;\n}\n\n/**\n * TanStack Query mutation options factory for wrap (shield).\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function wrapMutationOptions(token: Token) {\n return {\n mutationKey: [\"wrap\", token.address] as const,\n mutationFn: async ({ amount, fees, approvalStrategy }: WrapParams) =>\n token.wrap(amount, { fees, approvalStrategy }),\n };\n}\n\n/**\n * Wrap (shield) public ERC-20 tokens into confidential tokens.\n * Handles ERC-20 approval automatically. Invalidates balance caches on success.\n *\n * Errors are {@link TokenError} 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} — wrap 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 wrap = useWrap({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * wrap.mutate({ amount: 1000n });\n * ```\n */\nexport function useWrap(\n config: UseWrapConfig,\n options?: UseMutationOptions<Address, Error, WrapParams, Address>,\n) {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation<Address, Error, WrapParams, Address>({\n mutationKey: [\"wrap\", config.tokenAddress],\n mutationFn: async ({ amount, fees, approvalStrategy }) =>\n token.wrap(amount, { fees, approvalStrategy }),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const balanceKey = confidentialBalanceQueryKeys.token(config.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 queryClient.setQueryData(key, value + variables.amount);\n }\n }\n return (options?.onMutate?.(variables, mutationContext) ??\n config.tokenAddress) as Address;\n }\n : options?.onMutate,\n onError: (error, variables, onMutateResult, context) => {\n if (config.optimistic) {\n // Rollback: invalidate to refetch actual values\n queryClient.invalidateQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n }\n options?.onError?.(error, variables, onMutateResult, context);\n },\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n // Underlying ERC-20 balance changes after shield — invalidate wagmi useBalance cache\n context.client.invalidateQueries({\n predicate: wagmiBalancePredicates.balanceOf,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n} from \"./balance-query-keys\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/** Parameters passed to the `mutate` function of {@link useWrapETH}. */\nexport interface WrapETHParams {\n /** Amount of ETH to wrap (in wei). */\n amount: bigint;\n /** ETH value to send with the transaction. Defaults to `amount`. */\n value?: bigint;\n}\n\n/**\n * TanStack Query mutation options factory for wrap ETH (shield).\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function wrapETHMutationOptions(token: Token) {\n return {\n mutationKey: [\"wrapETH\", token.address] as const,\n mutationFn: ({ amount, value }: WrapETHParams) => token.wrapETH(amount, value),\n };\n}\n\n/**\n * Wrap (shield) native ETH into confidential tokens.\n * Invalidates balance caches on success.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const wrapETH = useWrapETH({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * wrapETH.mutate({ amount: 1000000000000000000n }); // 1 ETH\n * ```\n */\nexport function useWrapETH(\n config: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, WrapETHParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, WrapETHParams, Address>({\n mutationKey: [\"wrapETH\", config.tokenAddress],\n mutationFn: ({ amount, value }) => token.wrapETH(amount, value),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n} from \"./balance-query-keys\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/** Parameters passed to the `mutate` function of {@link useUnwrap}. */\nexport interface UnwrapParams {\n /** Amount to unwrap (plaintext — encrypted automatically). */\n amount: bigint;\n}\n\n/**\n * TanStack Query mutation options factory for unwrap.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function unwrapMutationOptions(token: Token) {\n return {\n mutationKey: [\"unwrap\", token.address] as const,\n mutationFn: ({ amount }: UnwrapParams) => token.unwrap(amount),\n };\n}\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 * @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: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, UnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, UnwrapParams, Address>({\n mutationKey: [\"unwrap\", config.tokenAddress],\n mutationFn: ({ amount }) => token.unwrap(amount),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n} from \"./balance-query-keys\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/**\n * TanStack Query mutation options factory for unwrap-all.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function unwrapAllMutationOptions(token: Token) {\n return {\n mutationKey: [\"unwrapAll\", token.address] as const,\n mutationFn: () => token.unwrapAll(),\n };\n}\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 * @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: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, void, Address>({\n mutationKey: [\"unwrapAll\", config.tokenAddress],\n mutationFn: () => token.unwrapAll(),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, ReadonlyToken } from \"@zama-fhe/sdk\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/**\n * Query key factory for underlying ERC-20 allowance queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const underlyingAllowanceQueryKeys = {\n /** Match all underlying allowance queries. */\n all: [\"underlyingAllowance\"] as const,\n /** Match allowance query for a specific token + wrapper pair. */\n token: (tokenAddress: string, wrapper: string) =>\n [\"underlyingAllowance\", tokenAddress, wrapper] as const,\n} as const;\n\n/** Configuration for {@link useUnderlyingAllowance}. */\nexport interface UseUnderlyingAllowanceConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper contract (the spender). */\n wrapperAddress: Address;\n}\n\n/**\n * TanStack Query options factory for underlying ERC-20 allowance.\n *\n * @param token - A `ReadonlyToken` instance.\n * @param wrapperAddress - Address of the wrapper contract (the spender).\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function underlyingAllowanceQueryOptions(token: ReadonlyToken, wrapperAddress: Address) {\n return {\n queryKey: underlyingAllowanceQueryKeys.token(token.address, wrapperAddress),\n queryFn: () => token.allowance(wrapperAddress),\n staleTime: 30_000,\n } as const;\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: \"0xUnderlying\",\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\n return useQuery<bigint, Error>({\n ...underlyingAllowanceQueryOptions(token, wrapperAddress),\n ...options,\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: \"0xUnderlying\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowanceSuspense(config: UseUnderlyingAllowanceConfig) {\n const { tokenAddress, wrapperAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<bigint, Error>(underlyingAllowanceQueryOptions(token, wrapperAddress));\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n wagmiBalancePredicates,\n} from \"./balance-query-keys\";\nimport { underlyingAllowanceQueryKeys } from \"./use-underlying-allowance\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/** Parameters passed to the `mutate` function of {@link useFinalizeUnwrap}. */\nexport interface FinalizeUnwrapParams {\n /** Encrypted amount handle from the UnwrapRequested event. */\n burnAmountHandle: Address;\n}\n\n/**\n * TanStack Query mutation options factory for finalize-unwrap.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function finalizeUnwrapMutationOptions(token: Token) {\n return {\n mutationKey: [\"finalizeUnwrap\", token.address] as const,\n mutationFn: ({ burnAmountHandle }: FinalizeUnwrapParams) =>\n token.finalizeUnwrap(burnAmountHandle),\n };\n}\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 * @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: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, FinalizeUnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, FinalizeUnwrapParams, Address>({\n mutationKey: [\"finalizeUnwrap\", config.tokenAddress],\n mutationFn: ({ burnAmountHandle }) => token.finalizeUnwrap(burnAmountHandle),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n context.client.invalidateQueries({\n queryKey: underlyingAllowanceQueryKeys.all,\n });\n context.client.invalidateQueries({ predicate: wagmiBalancePredicates.balanceOf });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n wagmiBalancePredicates,\n} from \"./balance-query-keys\";\nimport { underlyingAllowanceQueryKeys } from \"./use-underlying-allowance\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/** Parameters passed to the `mutate` function of {@link useUnshield}. */\nexport interface UnshieldParams {\n /** Amount to unshield (plaintext — encrypted automatically). */\n amount: bigint;\n}\n\n/**\n * TanStack Query mutation options factory for unshield.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function unshieldMutationOptions(token: Token) {\n return {\n mutationKey: [\"unshield\", token.address] as const,\n mutationFn: ({ amount }: UnshieldParams) => token.unshield(amount),\n };\n}\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 TokenError} 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: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, UnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, UnshieldParams, Address>({\n mutationKey: [\"unshield\", config.tokenAddress],\n mutationFn: ({ amount }) => token.unshield(amount),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n context.client.invalidateQueries({\n queryKey: underlyingAllowanceQueryKeys.all,\n });\n context.client.invalidateQueries({\n predicate: wagmiBalancePredicates.balanceOf,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryKeys,\n confidentialBalancesQueryKeys,\n confidentialHandleQueryKeys,\n confidentialHandlesQueryKeys,\n wagmiBalancePredicates,\n} from \"./balance-query-keys\";\nimport { underlyingAllowanceQueryKeys } from \"./use-underlying-allowance\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/**\n * TanStack Query mutation options factory for unshield-all.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function unshieldAllMutationOptions(token: Token) {\n return {\n mutationKey: [\"unshieldAll\", token.address] as const,\n mutationFn: () => token.unshieldAll(),\n };\n}\n\n/**\n * Unshield the entire balance and finalize in one call.\n * Orchestrates: unwrapAll → wait for receipt → parse event → finalize.\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: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, void, Address>({\n mutationKey: [\"unshieldAll\", config.tokenAddress],\n mutationFn: () => token.unshieldAll(),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: confidentialHandleQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialHandlesQueryKeys.all,\n });\n context.client.resetQueries({\n queryKey: confidentialBalanceQueryKeys.token(config.tokenAddress),\n });\n context.client.invalidateQueries({\n queryKey: confidentialBalancesQueryKeys.all,\n });\n context.client.invalidateQueries({\n queryKey: underlyingAllowanceQueryKeys.all,\n });\n context.client.invalidateQueries({\n predicate: wagmiBalancePredicates.balanceOf,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport {\n useQuery,\n useSuspenseQuery,\n skipToken,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport type { Address, ReadonlyToken } from \"@zama-fhe/sdk\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/**\n * Query key factory for wrapper discovery queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const wrapperDiscoveryQueryKeys = {\n /** Match all wrapper discovery queries. */\n all: [\"wrapperDiscovery\"] as const,\n /** Match wrapper discovery queries for a specific token. */\n token: (tokenAddress: string) => [\"wrapperDiscovery\", tokenAddress] as const,\n /** Match wrapper discovery query for a specific token + coordinator pair. */\n tokenCoordinator: (tokenAddress: string, coordinatorAddress: string) =>\n [\"wrapperDiscovery\", tokenAddress, coordinatorAddress] as const,\n} as const;\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 * TanStack Query options factory for wrapper discovery.\n *\n * @param token - A `ReadonlyToken` instance.\n * @param coordinatorAddress - Address of the wrapper coordinator.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function wrapperDiscoveryQueryOptions(token: ReadonlyToken, coordinatorAddress: Address) {\n return {\n queryKey: wrapperDiscoveryQueryKeys.tokenCoordinator(token.address, coordinatorAddress),\n queryFn: () => token.discoverWrapper(coordinatorAddress),\n staleTime: Infinity,\n } as const;\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): UseQueryResult<Address | null, Error> {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<Address | null, Error>({\n ...(coordinatorAddress\n ? wrapperDiscoveryQueryOptions(token, coordinatorAddress)\n : {\n queryKey: wrapperDiscoveryQueryKeys.tokenCoordinator(tokenAddress, \"\"),\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(\n config: UseWrapperDiscoverySuspenseConfig,\n): UseSuspenseQueryResult<Address | null, Error> {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<Address | null, Error>(\n wrapperDiscoveryQueryOptions(token, coordinatorAddress),\n );\n}\n","\"use client\";\n\nimport {\n useQuery,\n useSuspenseQuery,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport type { Address, ReadonlyToken } from \"@zama-fhe/sdk\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/**\n * Query key factory for token metadata queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const tokenMetadataQueryKeys = {\n /** Match all token metadata queries. */\n all: [\"tokenMetadata\"] as const,\n /** Match metadata query for a specific token. */\n token: (tokenAddress: string) => [\"tokenMetadata\", tokenAddress] as const,\n} as const;\n\n/** ERC-20 token metadata (name, symbol, decimals). */\nexport interface TokenMetadata {\n /** Human-readable token name (e.g. \"Wrapped Ether\"). */\n name: string;\n /** Short ticker symbol (e.g. \"WETH\"). */\n symbol: string;\n /** Number of decimal places (e.g. 18). */\n decimals: number;\n}\n\n/**\n * TanStack Query options factory for token metadata.\n * Returns a config object usable with `useQuery`, `prefetchQuery`, `useQueries`, etc.\n *\n * @param token - A `ReadonlyToken` instance.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n *\n * @example\n * ```ts\n * const options = tokenMetadataQueryOptions(token);\n * await queryClient.prefetchQuery(options);\n * ```\n */\nexport function tokenMetadataQueryOptions(token: ReadonlyToken) {\n return {\n queryKey: tokenMetadataQueryKeys.token(token.address),\n queryFn: async () => {\n const [name, symbol, decimals] = await Promise.all([\n token.name(),\n token.symbol(),\n token.decimals(),\n ]);\n return { name, symbol, decimals } as TokenMetadata;\n },\n staleTime: Infinity,\n } as const;\n}\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 } = useTokenMetadata(\"0xToken\");\n * // metadata?.name, metadata?.symbol, metadata?.decimals\n * ```\n */\nexport function useTokenMetadata(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<TokenMetadata, Error>, \"queryKey\" | \"queryFn\">,\n): UseQueryResult<TokenMetadata, Error> {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<TokenMetadata, Error>({\n ...tokenMetadataQueryOptions(token),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useTokenMetadata}.\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 } = useTokenMetadataSuspense(\"0xToken\");\n * ```\n */\nexport function useTokenMetadataSuspense(\n tokenAddress: Address,\n): UseSuspenseQueryResult<TokenMetadata, Error> {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<TokenMetadata, Error>(tokenMetadataQueryOptions(token));\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport type { Address, RawLog, ActivityLogMetadata, ActivityItem } from \"@zama-fhe/sdk\";\nimport {\n parseActivityFeed,\n extractEncryptedHandles,\n applyDecryptedValues,\n sortByBlockNumber,\n} from \"@zama-fhe/sdk\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/**\n * Query key factory for activity feed queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const activityFeedQueryKeys = {\n /** Match all activity feed queries. */\n all: [\"activityFeed\"] as const,\n /** Match activity feed queries for a specific token. */\n token: (tokenAddress: string) => [\"activityFeed\", tokenAddress] as const,\n} as const;\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(\n config: UseActivityFeedConfig,\n): UseQueryResult<ActivityItem[], Error> {\n const { tokenAddress, userAddress, logs, decrypt: decryptOpt } = config;\n const token = useReadonlyToken(tokenAddress);\n const decrypt = decryptOpt ?? true;\n const enabled = logs !== undefined && userAddress !== undefined;\n\n return useQuery<ActivityItem[], Error>({\n queryKey: [\n ...activityFeedQueryKeys.token(tokenAddress),\n userAddress ?? \"\",\n logs?.map((l) => `${l.transactionHash ?? \"\"}:${l.logIndex ?? \"\"}`).join(\",\") ?? \"\",\n ],\n queryFn: async () => {\n if (!logs || !userAddress) return [];\n\n // Phase 1: Parse and classify (sync)\n const items = sortByBlockNumber(parseActivityFeed(logs, userAddress));\n\n if (!decrypt) return items;\n\n // Phase 2: Batch decrypt encrypted handles\n const handles = extractEncryptedHandles(items);\n if (handles.length === 0) return items;\n\n const decryptedMap = await token.decryptHandles(handles as Address[], userAddress);\n\n return applyDecryptedValues(items, decryptedMap);\n },\n enabled: enabled,\n staleTime: Infinity,\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, Token } from \"@zama-fhe/sdk\";\nimport { underlyingAllowanceQueryKeys } from \"./use-underlying-allowance\";\nimport { useToken, type UseTokenConfig } from \"./use-token\";\n\n/** Parameters passed to the `mutate` function of {@link useApproveUnderlying}. */\nexport interface ApproveUnderlyingParams {\n /** Approval amount. Defaults to max uint256 if omitted. */\n amount?: bigint;\n}\n\n/**\n * TanStack Query mutation options factory for approve-underlying.\n *\n * @param token - A `Token` instance.\n * @returns Mutation options with `mutationKey` and `mutationFn`.\n */\nexport function approveUnderlyingMutationOptions(token: Token) {\n return {\n mutationKey: [\"approveUnderlying\", token.address] as const,\n mutationFn: ({ amount }: ApproveUnderlyingParams) => token.approveUnderlying(amount),\n };\n}\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 * @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: UseTokenConfig,\n options?: UseMutationOptions<Address, Error, ApproveUnderlyingParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<Address, Error, ApproveUnderlyingParams, Address>({\n mutationKey: [\"approveUnderlying\", config.tokenAddress],\n mutationFn: ({ amount }) => token.approveUnderlying(amount),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({\n queryKey: underlyingAllowanceQueryKeys.all,\n });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport {\n useQuery,\n useSuspenseQuery,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport type { Address, ReadonlyToken } from \"@zama-fhe/sdk\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/**\n * Query key factory for ERC-165 confidential interface checks.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const isConfidentialQueryKeys = {\n /** Match all confidential interface queries. */\n all: [\"isConfidential\"] as const,\n /** Match confidential interface query for a specific token. */\n token: (tokenAddress: string) => [\"isConfidential\", tokenAddress] as const,\n} as const;\n\n/**\n * Query key factory for ERC-165 wrapper interface checks.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const isWrapperQueryKeys = {\n /** Match all wrapper interface queries. */\n all: [\"isWrapper\"] as const,\n /** Match wrapper interface query for a specific token. */\n token: (tokenAddress: string) => [\"isWrapper\", tokenAddress] as const,\n} as const;\n\n/**\n * TanStack Query options factory for ERC-165 confidential interface check.\n *\n * @param token - A `ReadonlyToken` instance.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function isConfidentialQueryOptions(token: ReadonlyToken) {\n return {\n queryKey: isConfidentialQueryKeys.token(token.address),\n queryFn: () => token.isConfidential(),\n staleTime: Infinity,\n } as const;\n}\n\n/**\n * TanStack Query options factory for ERC-165 wrapper interface check.\n *\n * @param token - A `ReadonlyToken` instance.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function isWrapperQueryOptions(token: ReadonlyToken) {\n return {\n queryKey: isWrapperQueryKeys.token(token.address),\n queryFn: () => token.isWrapper(),\n staleTime: Infinity,\n } as const;\n}\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): UseQueryResult<boolean, Error> {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean, Error>({\n ...isConfidentialQueryOptions(token),\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(\n tokenAddress: Address,\n): UseSuspenseQueryResult<boolean, Error> {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean, Error>(isConfidentialQueryOptions(token));\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): UseQueryResult<boolean, Error> {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean, Error>({\n ...isWrapperQueryOptions(token),\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(\n tokenAddress: Address,\n): UseSuspenseQueryResult<boolean, Error> {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean, Error>(isWrapperQueryOptions(token));\n}\n","\"use client\";\n\nimport {\n useQuery,\n useSuspenseQuery,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport { totalSupplyContract, type Address, type ReadonlyToken } from \"@zama-fhe/sdk\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/**\n * Query key factory for total supply queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const totalSupplyQueryKeys = {\n /** Match all total supply queries. */\n all: [\"totalSupply\"] as const,\n /** Match total supply query for a specific token. */\n token: (tokenAddress: string) => [\"totalSupply\", tokenAddress] as const,\n} as const;\n\n/**\n * TanStack Query options factory for total supply.\n *\n * @param token - A `ReadonlyToken` instance.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function totalSupplyQueryOptions(token: ReadonlyToken) {\n return {\n queryKey: totalSupplyQueryKeys.token(token.address),\n queryFn: () => token.signer.readContract<bigint>(totalSupplyContract(token.address)),\n staleTime: 30_000,\n } as const;\n}\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): UseQueryResult<bigint, Error> {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<bigint, Error>({\n ...totalSupplyQueryOptions(token),\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(\n tokenAddress: Address,\n): UseSuspenseQueryResult<bigint, Error> {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<bigint, Error>(totalSupplyQueryOptions(token));\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryOptions, type UseQueryResult } from \"@tanstack/react-query\";\nimport {\n getWrapFeeContract,\n getUnwrapFeeContract,\n getBatchTransferFeeContract,\n getFeeRecipientContract,\n type Address,\n type GenericSigner,\n} from \"@zama-fhe/sdk\";\nimport { useTokenSDK } from \"../provider\";\n\n/**\n * Query key factory for fee-related queries.\n * Use with `queryClient.invalidateQueries()` / `resetQueries()`.\n */\nexport const feeQueryKeys = {\n /** Match wrap fee query for given parameters. */\n wrapFee: (feeManagerAddress: string, amount?: string, from?: string, to?: string) =>\n [\"wrapFee\", feeManagerAddress, ...(amount !== undefined ? [amount, from, to] : [])] as const,\n /** Match unwrap fee query for given parameters. */\n unwrapFee: (feeManagerAddress: string, amount?: string, from?: string, to?: string) =>\n [\"unwrapFee\", feeManagerAddress, ...(amount !== undefined ? [amount, from, to] : [])] as const,\n /** Match batch transfer fee query for a specific fee manager. */\n batchTransferFee: (feeManagerAddress: string) => [\"batchTransferFee\", feeManagerAddress] as const,\n /** Match fee recipient query for a specific fee manager. */\n feeRecipient: (feeManagerAddress: string) => [\"feeRecipient\", feeManagerAddress] as const,\n} as const;\n\n/** Configuration for {@link useWrapFee} and {@link useUnwrapFee}. */\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 * TanStack Query options factory for wrap fee.\n *\n * @param signer - A `GenericSigner` instance.\n * @param config - {@link UseFeeConfig} with fee manager address, amount, from, and to.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function wrapFeeQueryOptions(signer: GenericSigner, config: UseFeeConfig) {\n const { feeManagerAddress, amount, from, to } = config;\n return {\n queryKey: feeQueryKeys.wrapFee(feeManagerAddress, amount.toString(), from, to),\n queryFn: () =>\n signer.readContract<bigint>(getWrapFeeContract(feeManagerAddress, amount, from, to)),\n staleTime: 30_000,\n } as const;\n}\n\n/**\n * TanStack Query options factory for unwrap fee.\n *\n * @param signer - A `GenericSigner` instance.\n * @param config - Fee manager address, amount, from, and to.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function unwrapFeeQueryOptions(signer: GenericSigner, config: UseFeeConfig) {\n const { feeManagerAddress, amount, from, to } = config;\n return {\n queryKey: feeQueryKeys.unwrapFee(feeManagerAddress, amount.toString(), from, to),\n queryFn: () =>\n signer.readContract<bigint>(getUnwrapFeeContract(feeManagerAddress, amount, from, to)),\n staleTime: 30_000,\n } as const;\n}\n\n/**\n * TanStack Query options factory for batch transfer fee.\n *\n * @param signer - A `GenericSigner` instance.\n * @param feeManagerAddress - Address of the fee manager contract.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function batchTransferFeeQueryOptions(signer: GenericSigner, feeManagerAddress: Address) {\n return {\n queryKey: feeQueryKeys.batchTransferFee(feeManagerAddress),\n queryFn: () => signer.readContract<bigint>(getBatchTransferFeeContract(feeManagerAddress)),\n staleTime: 30_000,\n } as const;\n}\n\n/**\n * TanStack Query options factory for fee recipient.\n *\n * @param signer - A `GenericSigner` instance.\n * @param feeManagerAddress - Address of the fee manager contract.\n * @returns Query options with `queryKey`, `queryFn`, and `staleTime`.\n */\nexport function feeRecipientQueryOptions(signer: GenericSigner, feeManagerAddress: Address) {\n return {\n queryKey: feeQueryKeys.feeRecipient(feeManagerAddress),\n queryFn: () => signer.readContract<Address>(getFeeRecipientContract(feeManagerAddress)),\n staleTime: 30_000,\n } as const;\n}\n\n/**\n * Read the wrap 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 } = useWrapFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useWrapFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n): UseQueryResult<bigint, Error> {\n const sdk = useTokenSDK();\n\n return useQuery<bigint, Error>({\n ...wrapFeeQueryOptions(sdk.signer, config),\n ...options,\n });\n}\n\n/**\n * Read the unwrap 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 } = useUnwrapFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useUnwrapFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n): UseQueryResult<bigint, Error> {\n const sdk = useTokenSDK();\n\n return useQuery<bigint, Error>({\n ...unwrapFeeQueryOptions(sdk.signer, config),\n ...options,\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): UseQueryResult<bigint, Error> {\n const sdk = useTokenSDK();\n\n return useQuery<bigint, Error>({\n ...batchTransferFeeQueryOptions(sdk.signer, feeManagerAddress),\n ...options,\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): UseQueryResult<Address, Error> {\n const sdk = useTokenSDK();\n\n return useQuery<Address, Error>({\n ...feeRecipientQueryOptions(sdk.signer, feeManagerAddress),\n ...options,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ZamaSDK","encryptMutationOptions","zamaQueryKeys","publicKeyQueryOptions","hashFn","publicParamsQueryOptions","hashFn","hashFn","hashFn","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","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","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","useQuery","shieldFeeQueryOptions","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/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/utils/query.ts","../src/token/use-confidential-balance.ts","../src/token/use-confidential-balances.ts","../src/token/use-allow.ts","../src/token/use-is-allowed.ts","../src/token/use-revoke.ts","../src/token/use-revoke-session.ts","../src/token/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-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 * @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\";\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: string, contractAddress?: string) =>\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 * 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 type { KeypairType } from \"@zama-fhe/sdk\";\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 * @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<KeypairType<string>, Error, void>({\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\";\n\n/** Parameters for {@link useCreateEIP712}. */\nexport interface CreateEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: string;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: `0x${string}`[];\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: string;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Address of the wallet that delegated decrypt authority. */\n delegatorAddress: string;\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","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { hashFn, 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({\n ...publicKeyQueryOptions(sdk),\n queryKeyHashFn: hashFn,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { hashFn, 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({\n ...publicParamsQueryOptions(sdk, bits),\n queryKeyHashFn: hashFn,\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 \"@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 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 queryKeyHashFn: hashFn,\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","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: a single `as any` here replaces per-hook casts.\n *\n * TanStack's useQuery has discriminated overloads around `initialData` that make\n * it extremely hard to pass inferred types through. We bypass that by casting\n * internally — the type safety boundary is at the factory and hook levels.\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 { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Hex } 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 as Address | undefined;\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 handleFactoryEnabled = baseHandleQueryOptions.enabled ?? true;\n const handleQuery = useQuery<Hex>({\n ...baseHandleQueryOptions,\n enabled: handleFactoryEnabled && (userEnabled ?? true),\n });\n\n // Phase 2: Decrypt only when handle changes (expensive relayer roundtrip)\n const handle = handleQuery.data as Hex | undefined;\n const baseBalanceQueryOptions = confidentialBalanceQueryOptions(token, {\n handle,\n owner,\n });\n const factoryEnabled = baseBalanceQueryOptions.enabled ?? true;\n\n const balanceQuery = useQuery<bigint>({\n ...baseBalanceQueryOptions,\n ...options,\n enabled: factoryEnabled && (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, Hex } 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 as Address | undefined;\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 handlesFactoryEnabled = baseHandlesQueryOptions.enabled ?? true;\n const handlesQuery = useQuery<Hex[]>({\n ...baseHandlesQueryOptions,\n enabled: handlesFactoryEnabled && (userEnabled ?? true),\n });\n\n // Phase 2: Batch decrypt only when any handle changes\n const handles = handlesQuery.data as Hex[] | undefined;\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 * @example\n * ```tsx\n * const { mutateAsync: allow, isPending } = useAllow();\n * // Call allow(allTokenAddresses) before any individual reveal\n * ```\n */\nexport function useAllow(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...allowMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n 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 as Address | undefined;\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: revoke } = useRevoke();\n * revoke([\"0xTokenA\", \"0xTokenB\"]);\n * ```\n */\nexport function useRevoke(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...revokeMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n 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 } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { 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: OptimisticMutateContext | undefined,\n) {\n const wrappedContext = optimistic ? rawContext : undefined;\n const callerContext = optimistic ? wrappedContext?.callerContext : rawContext;\n return { wrappedContext, callerContext };\n}\n\nexport async function applyOptimisticBalanceDelta(\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","\"use client\";\n\nimport { useMutation, useQueryClient, UseMutationOptions } 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 type OptimisticMutateContext,\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(\n config: UseConfidentialTransferConfig,\n // Context type is OptimisticMutateContext because our onMutate wraps the caller's\n // context inside { snapshot, callerContext }. Caller callbacks receive the unwrapped callerContext.\n options?: UseMutationOptions<\n TransactionResult,\n Error,\n ConfidentialTransferParams,\n OptimisticMutateContext\n >,\n) {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation<TransactionResult, Error, ConfidentialTransferParams, OptimisticMutateContext>(\n {\n ...confidentialTransferMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta(\n queryClient,\n config.tokenAddress,\n variables.amount,\n \"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 if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n // callerContext is the user's original onMutate return — cast required by wrapper pattern\n options?.onError?.(\n error,\n variables,\n callerContext as OptimisticMutateContext | undefined,\n context,\n );\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as OptimisticMutateContext, 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?.(\n data,\n error,\n variables,\n callerContext as OptimisticMutateContext | undefined,\n context,\n );\n },\n },\n );\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 * @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 as Address | undefined);\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 const factoryEnabled = \"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true;\n\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: factoryEnabled && (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 as Address);\n\n return useSuspenseQuery<boolean>({\n ...confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n }),\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterShield,\n shieldMutationOptions,\n type ShieldParams,\n} from \"@zama-fhe/sdk/query\";\nimport {\n applyOptimisticBalanceDelta,\n type OptimisticMutateContext,\n rollbackOptimisticBalanceDelta,\n unwrapOptimisticCallerContext,\n} 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(\n config: UseShieldConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldParams, OptimisticMutateContext>,\n) {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation<TransactionResult, Error, ShieldParams, OptimisticMutateContext>({\n ...shieldMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta(\n queryClient,\n config.tokenAddress,\n variables.amount,\n \"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 config.optimistic,\n rawContext,\n );\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n // callerContext is the user's original onMutate return — cast required by wrapper pattern\n options?.onError?.(\n error,\n variables,\n callerContext as OptimisticMutateContext | undefined,\n context,\n );\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as OptimisticMutateContext, context);\n invalidateAfterShield(context.client, config.tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSettled?.(\n data,\n error,\n variables,\n callerContext as OptimisticMutateContext | undefined,\n context,\n );\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterShield,\n shieldETHMutationOptions,\n type ShieldETHParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Shield native ETH into confidential tokens.\n * Invalidates balance caches on success.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shieldETH = useShieldETH({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * shieldETH.mutate({ amount: 1000000000000000000n }); // 1 ETH\n * ```\n */\nexport function useShieldETH(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldETHParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ShieldETHParams, Address>({\n ...shieldETHMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterShield(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 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 * @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 * @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 * @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 * @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 userEnabled = options?.enabled;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data as Address | undefined;\n\n const baseOpts = underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n });\n const factoryEnabled = baseOpts.enabled ?? true;\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: factoryEnabled && (userEnabled ?? 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 as Address;\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 } 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 =\n logs?.map((log) => `${log.transactionHash ?? \"\"}:${log.logIndex ?? \"\"}`).join(\",\") ?? \"\";\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, 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 * @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\n return useQuery<bigint>({\n ...shieldFeeQueryOptions(sdk.signer, config),\n ...options,\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\n return useQuery<bigint>({\n ...unshieldFeeQueryOptions(sdk.signer, config),\n ...options,\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\n return useQuery<bigint>({\n ...batchTransferFeeQueryOptions(sdk.signer, feeManagerAddress),\n ...options,\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\n return useQuery<Address>({\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