@zama-fhe/react-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +735 -0
- package/dist/ethers/index.d.ts +162 -0
- package/dist/ethers/index.js +173 -0
- package/dist/ethers/index.js.map +1 -0
- package/dist/index.d.ts +1820 -0
- package/dist/index.js +978 -0
- package/dist/index.js.map +1 -0
- package/dist/viem/index.d.ts +162 -0
- package/dist/viem/index.js +173 -0
- package/dist/viem/index.js.map +1 -0
- package/dist/wagmi/index.d.ts +7133 -0
- package/dist/wagmi/index.js +269 -0
- package/dist/wagmi/index.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +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,CAAA;AACrF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,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"]}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { Address } from '@zama-fhe/sdk';
|
|
3
|
+
import { readConfidentialBalanceOfContract, writeConfidentialTransferContract, writeConfidentialBatchTransferContract, writeUnwrapContract, writeUnwrapFromBalanceContract, writeFinalizeUnwrapContract, writeSetOperatorContract, readWrapperForTokenContract, readUnderlyingTokenContract, writeWrapContract, writeWrapETHContract, readWrapperExistsContract, readSupportsInterfaceContract } from '@zama-fhe/sdk/viem';
|
|
4
|
+
export { ViemSigner } from '@zama-fhe/sdk/viem';
|
|
5
|
+
|
|
6
|
+
type Params$c = Parameters<typeof readConfidentialBalanceOfContract>;
|
|
7
|
+
interface UseConfidentialBalanceOfConfig {
|
|
8
|
+
client: Params$c[0];
|
|
9
|
+
tokenAddress: Address | undefined;
|
|
10
|
+
userAddress: Address | undefined;
|
|
11
|
+
}
|
|
12
|
+
interface UseConfidentialBalanceOfSuspenseConfig {
|
|
13
|
+
client: Params$c[0];
|
|
14
|
+
tokenAddress: Address;
|
|
15
|
+
userAddress: Address;
|
|
16
|
+
}
|
|
17
|
+
declare function useConfidentialBalanceOf(config: UseConfidentialBalanceOfConfig): _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
18
|
+
declare function useConfidentialBalanceOfSuspense(config: UseConfidentialBalanceOfSuspenseConfig): _tanstack_react_query.UseSuspenseQueryResult<`0x${string}`, Error>;
|
|
19
|
+
|
|
20
|
+
type WriteFn$7 = typeof writeConfidentialTransferContract;
|
|
21
|
+
type Params$b = Parameters<WriteFn$7>;
|
|
22
|
+
interface ConfidentialTransferParams {
|
|
23
|
+
client: Params$b[0];
|
|
24
|
+
tokenAddress: Params$b[1];
|
|
25
|
+
to: Params$b[2];
|
|
26
|
+
handle: Params$b[3];
|
|
27
|
+
inputProof: Params$b[4];
|
|
28
|
+
}
|
|
29
|
+
declare function useConfidentialTransfer(): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, ConfidentialTransferParams, unknown>;
|
|
30
|
+
|
|
31
|
+
type WriteFn$6 = typeof writeConfidentialBatchTransferContract;
|
|
32
|
+
type Params$a = Parameters<WriteFn$6>;
|
|
33
|
+
interface ConfidentialBatchTransferParams {
|
|
34
|
+
client: Params$a[0];
|
|
35
|
+
batcherAddress: Params$a[1];
|
|
36
|
+
tokenAddress: Params$a[2];
|
|
37
|
+
fromAddress: Params$a[3];
|
|
38
|
+
batchTransferData: Params$a[4];
|
|
39
|
+
fees: Params$a[5];
|
|
40
|
+
}
|
|
41
|
+
declare function useConfidentialBatchTransfer(): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, ConfidentialBatchTransferParams, unknown>;
|
|
42
|
+
|
|
43
|
+
type WriteFn$5 = typeof writeUnwrapContract;
|
|
44
|
+
type Params$9 = Parameters<WriteFn$5>;
|
|
45
|
+
interface UnwrapParams {
|
|
46
|
+
client: Params$9[0];
|
|
47
|
+
encryptedErc20: Params$9[1];
|
|
48
|
+
from: Params$9[2];
|
|
49
|
+
to: Params$9[3];
|
|
50
|
+
encryptedAmount: Params$9[4];
|
|
51
|
+
inputProof: Params$9[5];
|
|
52
|
+
}
|
|
53
|
+
declare function useUnwrap(): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, UnwrapParams, unknown>;
|
|
54
|
+
|
|
55
|
+
type WriteFn$4 = typeof writeUnwrapFromBalanceContract;
|
|
56
|
+
type Params$8 = Parameters<WriteFn$4>;
|
|
57
|
+
interface UnwrapFromBalanceParams {
|
|
58
|
+
client: Params$8[0];
|
|
59
|
+
encryptedErc20: Params$8[1];
|
|
60
|
+
from: Params$8[2];
|
|
61
|
+
to: Params$8[3];
|
|
62
|
+
encryptedBalance: Params$8[4];
|
|
63
|
+
}
|
|
64
|
+
declare function useUnwrapFromBalance(): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, UnwrapFromBalanceParams, unknown>;
|
|
65
|
+
|
|
66
|
+
type WriteFn$3 = typeof writeFinalizeUnwrapContract;
|
|
67
|
+
type Params$7 = Parameters<WriteFn$3>;
|
|
68
|
+
interface FinalizeUnwrapParams {
|
|
69
|
+
client: Params$7[0];
|
|
70
|
+
wrapper: Params$7[1];
|
|
71
|
+
burntAmount: Params$7[2];
|
|
72
|
+
burntAmountCleartext: Params$7[3];
|
|
73
|
+
decryptionProof: Params$7[4];
|
|
74
|
+
}
|
|
75
|
+
declare function useFinalizeUnwrap(): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, FinalizeUnwrapParams, unknown>;
|
|
76
|
+
|
|
77
|
+
type WriteFn$2 = typeof writeSetOperatorContract;
|
|
78
|
+
type Params$6 = Parameters<WriteFn$2>;
|
|
79
|
+
interface SetOperatorParams {
|
|
80
|
+
client: Params$6[0];
|
|
81
|
+
tokenAddress: Params$6[1];
|
|
82
|
+
spender: Params$6[2];
|
|
83
|
+
timestamp?: Params$6[3];
|
|
84
|
+
}
|
|
85
|
+
declare function useSetOperator(): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, SetOperatorParams, unknown>;
|
|
86
|
+
|
|
87
|
+
type Params$5 = Parameters<typeof readWrapperForTokenContract>;
|
|
88
|
+
interface UseWrapperForTokenConfig {
|
|
89
|
+
client: Params$5[0];
|
|
90
|
+
coordinator: Address | undefined;
|
|
91
|
+
tokenAddress: Address | undefined;
|
|
92
|
+
}
|
|
93
|
+
interface UseWrapperForTokenSuspenseConfig {
|
|
94
|
+
client: Params$5[0];
|
|
95
|
+
coordinator: Address;
|
|
96
|
+
tokenAddress: Address;
|
|
97
|
+
}
|
|
98
|
+
declare function useWrapperForToken(config: UseWrapperForTokenConfig): _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
99
|
+
declare function useWrapperForTokenSuspense(config: UseWrapperForTokenSuspenseConfig): _tanstack_react_query.UseSuspenseQueryResult<`0x${string}`, Error>;
|
|
100
|
+
|
|
101
|
+
type Params$4 = Parameters<typeof readUnderlyingTokenContract>;
|
|
102
|
+
interface UseUnderlyingTokenConfig {
|
|
103
|
+
client: Params$4[0];
|
|
104
|
+
wrapperAddress: Address | undefined;
|
|
105
|
+
}
|
|
106
|
+
interface UseUnderlyingTokenSuspenseConfig {
|
|
107
|
+
client: Params$4[0];
|
|
108
|
+
wrapperAddress: Address;
|
|
109
|
+
}
|
|
110
|
+
declare function useUnderlyingToken(config: UseUnderlyingTokenConfig): _tanstack_react_query.UseQueryResult<`0x${string}`, Error>;
|
|
111
|
+
declare function useUnderlyingTokenSuspense(config: UseUnderlyingTokenSuspenseConfig): _tanstack_react_query.UseSuspenseQueryResult<`0x${string}`, Error>;
|
|
112
|
+
|
|
113
|
+
type WriteFn$1 = typeof writeWrapContract;
|
|
114
|
+
type Params$3 = Parameters<WriteFn$1>;
|
|
115
|
+
interface WrapParams {
|
|
116
|
+
client: Params$3[0];
|
|
117
|
+
wrapperAddress: Params$3[1];
|
|
118
|
+
to: Params$3[2];
|
|
119
|
+
amount: Params$3[3];
|
|
120
|
+
}
|
|
121
|
+
declare function useWrap(): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, WrapParams, unknown>;
|
|
122
|
+
|
|
123
|
+
type WriteFn = typeof writeWrapETHContract;
|
|
124
|
+
type Params$2 = Parameters<WriteFn>;
|
|
125
|
+
interface WrapETHParams {
|
|
126
|
+
client: Params$2[0];
|
|
127
|
+
wrapperAddress: Params$2[1];
|
|
128
|
+
to: Params$2[2];
|
|
129
|
+
amount: Params$2[3];
|
|
130
|
+
value: Params$2[4];
|
|
131
|
+
}
|
|
132
|
+
declare function useWrapETH(): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, WrapETHParams, unknown>;
|
|
133
|
+
|
|
134
|
+
type Params$1 = Parameters<typeof readWrapperExistsContract>;
|
|
135
|
+
interface UseWrapperExistsConfig {
|
|
136
|
+
client: Params$1[0];
|
|
137
|
+
coordinator: Address | undefined;
|
|
138
|
+
tokenAddress: Address | undefined;
|
|
139
|
+
}
|
|
140
|
+
interface UseWrapperExistsSuspenseConfig {
|
|
141
|
+
client: Params$1[0];
|
|
142
|
+
coordinator: Address;
|
|
143
|
+
tokenAddress: Address;
|
|
144
|
+
}
|
|
145
|
+
declare function useWrapperExists(config: UseWrapperExistsConfig): _tanstack_react_query.UseQueryResult<boolean, Error>;
|
|
146
|
+
declare function useWrapperExistsSuspense(config: UseWrapperExistsSuspenseConfig): _tanstack_react_query.UseSuspenseQueryResult<boolean, Error>;
|
|
147
|
+
|
|
148
|
+
type Params = Parameters<typeof readSupportsInterfaceContract>;
|
|
149
|
+
interface UseSupportsInterfaceConfig {
|
|
150
|
+
client: Params[0];
|
|
151
|
+
tokenAddress: Params[1] | undefined;
|
|
152
|
+
interfaceId: Params[2] | undefined;
|
|
153
|
+
}
|
|
154
|
+
interface UseSupportsInterfaceSuspenseConfig {
|
|
155
|
+
client: Params[0];
|
|
156
|
+
tokenAddress: Params[1];
|
|
157
|
+
interfaceId: Params[2];
|
|
158
|
+
}
|
|
159
|
+
declare function useSupportsInterface(config: UseSupportsInterfaceConfig): _tanstack_react_query.UseQueryResult<boolean, Error>;
|
|
160
|
+
declare function useSupportsInterfaceSuspense(config: UseSupportsInterfaceSuspenseConfig): _tanstack_react_query.UseSuspenseQueryResult<boolean, Error>;
|
|
161
|
+
|
|
162
|
+
export { type ConfidentialBatchTransferParams, type ConfidentialTransferParams, type FinalizeUnwrapParams, type SetOperatorParams, type UnwrapFromBalanceParams, type UnwrapParams, type UseConfidentialBalanceOfConfig, type UseConfidentialBalanceOfSuspenseConfig, type UseSupportsInterfaceConfig, type UseSupportsInterfaceSuspenseConfig, type UseUnderlyingTokenConfig, type UseUnderlyingTokenSuspenseConfig, type UseWrapperExistsConfig, type UseWrapperExistsSuspenseConfig, type UseWrapperForTokenConfig, type UseWrapperForTokenSuspenseConfig, type WrapETHParams, type WrapParams, useConfidentialBalanceOf, useConfidentialBalanceOfSuspense, useConfidentialBatchTransfer, useConfidentialTransfer, useFinalizeUnwrap, useSetOperator, useSupportsInterface, useSupportsInterfaceSuspense, useUnderlyingToken, useUnderlyingTokenSuspense, useUnwrap, useUnwrapFromBalance, useWrap, useWrapETH, useWrapperExists, useWrapperExistsSuspense, useWrapperForToken, useWrapperForTokenSuspense };
|