@zama-fhe/react-sdk 3.0.0-alpha.8 → 3.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/README.md CHANGED
@@ -698,6 +698,38 @@ const { data: meta } = useTokenMetadata("0xTokenAddress");
698
698
  // meta?.name, meta?.symbol, meta?.decimals
699
699
  ```
700
700
 
701
+ ### Activity Feed
702
+
703
+ #### `useActivityFeed`
704
+
705
+ Parse raw event logs into a classified, optionally decrypted activity feed.
706
+
707
+ ```ts
708
+ function useActivityFeed(config: UseActivityFeedConfig): UseQueryResult<ActivityItem[], Error>;
709
+
710
+ interface UseActivityFeedConfig {
711
+ tokenAddress: Address;
712
+ userAddress: Address | undefined;
713
+ logs: readonly (RawLog & Partial<ActivityLogMetadata>)[] | undefined;
714
+ decrypt?: boolean; // default: true — batch-decrypt encrypted amounts
715
+ }
716
+ ```
717
+
718
+ Enabled when both `logs` and `userAddress` are defined. When `decrypt` is `true` (default), encrypted transfer amounts are automatically decrypted via the relayer.
719
+
720
+ ```tsx
721
+ const { data: feed } = useActivityFeed({
722
+ tokenAddress: "0xTokenAddress",
723
+ logs, // from getLogs or a similar source
724
+ userAddress,
725
+ decrypt: true,
726
+ });
727
+
728
+ feed?.forEach((item) => {
729
+ console.log(item.type, item.direction, item.amount);
730
+ });
731
+ ```
732
+
701
733
  ### Low-Level FHE Hooks
702
734
 
703
735
  These hooks are for **custom FHE contracts** (non-token contracts that use encrypted types directly). For confidential ERC-20 tokens, use the high-level token hooks above instead. For detailed usage examples, see the [Encrypt & Decrypt guide](../../docs/gitbook/src/guides/encrypt-decrypt.md).
@@ -766,13 +798,14 @@ Use `zamaQueryKeys` for manual cache management (invalidation, prefetching, remo
766
798
  import { zamaQueryKeys, decryptionKeys } from "@zama-fhe/react-sdk";
767
799
  ```
768
800
 
769
- | Factory | Keys | Description |
770
- | ------------------------------------ | ------------------------------------------------------------ | ----------------------------------- |
771
- | `zamaQueryKeys.confidentialBalance` | `.all`, `.token(address)`, `.owner(address, owner)` | Single-token decrypted balance. |
772
- | `zamaQueryKeys.confidentialBalances` | `.all`, `.tokens(addresses, owner)` | Multi-token batch balances. |
773
- | `zamaQueryKeys.isAllowed` | `.all` | Session signature status. |
774
- | `zamaQueryKeys.underlyingAllowance` | `.all`, `.token(address)`, `.scope(address, owner, wrapper)` | Underlying ERC-20 allowance. |
775
- | `decryptionKeys` | `.value(handle)` | Individual decrypted handle values. |
801
+ | Factory | Keys | Description |
802
+ | ------------------------------------ | --------------------------------------------------------------------------- | ----------------------------------- |
803
+ | `zamaQueryKeys.confidentialBalance` | `.all`, `.token(address)`, `.owner(address, owner)` | Single-token decrypted balance. |
804
+ | `zamaQueryKeys.confidentialBalances` | `.all`, `.tokens(addresses, owner)` | Multi-token batch balances. |
805
+ | `zamaQueryKeys.isAllowed` | `.all` | Session signature status. |
806
+ | `zamaQueryKeys.underlyingAllowance` | `.all`, `.token(address)`, `.scope(address, owner, wrapper)` | Underlying ERC-20 allowance. |
807
+ | `zamaQueryKeys.activityFeed` | `.all`, `.token(address)`, `.scope(address, userAddress, logsKey, decrypt)` | Activity feed items. |
808
+ | `decryptionKeys` | `.value(handle)` | Individual decrypted handle values. |
776
809
 
777
810
  ```tsx
778
811
  import { useQueryClient } from "@tanstack/react-query";
@@ -926,4 +959,6 @@ All public exports from `@zama-fhe/sdk` are re-exported from the main entry poin
926
959
 
927
960
  **Event decoders:** `decodeConfidentialTransfer`, `decodeWrapped`, `decodeUnwrapRequested`, `decodeUnwrappedFinalized`, `decodeUnwrappedStarted`, `decodeOnChainEvent`, `decodeOnChainEvents`, `findUnwrapRequested`, `findWrapped`.
928
961
 
962
+ **Activity feed:** `ActivityDirection`, `ActivityType`, `ActivityAmount`, `ActivityLogMetadata`, `ActivityItem`, `parseActivityFeed`, `extractEncryptedHandles`, `applyDecryptedValues`, `sortByBlockNumber`.
963
+
929
964
  **Contract call builders:** `confidentialBalanceOfContract`, `confidentialTransferContract`, `confidentialTransferFromContract`, `isOperatorContract`, `unwrapContract`, `unwrapFromBalanceContract`, `finalizeUnwrapContract`, `setOperatorContract`, `underlyingContract`, `inferredTotalSupplyContract`, `wrapContract`, `supportsInterfaceContract`, `isConfidentialTokenContract`, `isConfidentialWrapperContract`, `nameContract`, `symbolContract`, `decimalsContract`, `allowanceContract`, `approveContract`, `confidentialTotalSupplyContract`, `totalSupplyContract`, `rateContract`.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
 
3
3
  import * as _$_zama_fhe_sdk0 from "@zama-fhe/sdk";
4
- import { ACL_TOPICS, AclEvent, AclPausedError, Address, Address as Address$1, ApprovalFailedError, ApproveSubmittedEvent, ApproveUnderlyingSubmittedEvent, BalanceCheckUnavailableError, BaseEvent, BatchBalancesResult, BatchBalancesResult as BatchBalancesResult$1, BatchDecryptAsOptions, ChromeSessionStorage, ClearValueType, ClearValueType as ClearValueType$1, ConfidentialTransferEvent, ConfigurationError, ContractAbi, CredentialsAllowedEvent, CredentialsCachedEvent, CredentialsCreatedEvent, CredentialsCreatingEvent, CredentialsExpiredEvent, CredentialsLoadingEvent, CredentialsManager, CredentialsManagerConfig, CredentialsRevokedEvent, DecryptEndEvent, DecryptErrorEvent, DecryptStartEvent, DecryptionFailedError, DefaultRegistryAddresses, DelegatedCredentialsManager, DelegatedCredentialsManagerConfig, DelegatedForUserDecryptionEvent, DelegatedStoredCredentials, DelegatedUserDecryptParams, DelegatedUserDecryptParams as DelegatedUserDecryptParams$1, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, EIP712TypedData, EIP712TypedData as EIP712TypedData$1, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID_LEGACY, EncryptEndEvent, EncryptErrorEvent, EncryptInput, EncryptParams, EncryptParams as EncryptParams$1, EncryptResult, EncryptStartEvent, EncryptionFailedError, FheTypeName, FhevmInstanceConfig, FinalizeUnwrapSubmittedEvent, GenericSigner, GenericSigner as GenericSigner$1, GenericStorage, GenericStorage as GenericStorage$1, Handle, HardhatConfig, Hex, IndexedDBStorage, InputProofBytesType, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidKeypairError, KeypairExpiredError, KeypairType, KmsDelegatedUserDecryptEIP712Type, ListPairsOptions, MainnetConfig, MemoryStorage, NetworkType, NoCiphertextError, OnChainEvent, PaginatedResult, PaginatedResult as PaginatedResult$1, PublicDecryptResult, PublicKeyData, RawLog, ReadContractArgs, ReadContractConfig, ReadContractReturnType, ReadFunctionName, ReadonlyToken, ReadonlyToken as ReadonlyToken$1, RelayerRequestFailedError, RelayerSDK, RelayerSDK as RelayerSDK$1, RelayerSDKStatus, RelayerWeb, RelayerWebConfig, RelayerWebSecurityConfig, RevokedDelegationForUserDecryptionEvent, SepoliaConfig, SessionExpiredEvent, ShieldCallbacks, ShieldSubmittedEvent, SigningFailedError, SigningRejectedError, StoredCredentials, TOKEN_TOPICS, Token, TokenWrapperPair, TokenWrapperPair as TokenWrapperPair$1, TokenWrapperPairWithMetadata, TokenWrapperPairWithMetadata as TokenWrapperPairWithMetadata$1, Topics, TransactionErrorEvent, TransactionReceipt, TransactionResult, TransactionResult as TransactionResult$1, TransactionRevertedError, TransferCallbacks, TransferFromSubmittedEvent, TransferSubmittedEvent, UnshieldCallbacks, UnshieldPhase1SubmittedEvent, UnshieldPhase2StartedEvent, UnshieldPhase2SubmittedEvent, UnwrapRequestedEvent, UnwrapSubmittedEvent, UnwrappedFinalizedEvent, UnwrappedStartedEvent, UserDecryptParams, WrappedEvent, WrappersRegistry, WrappersRegistryConfig, WriteContractArgs, WriteContractConfig, WriteFunctionName, ZERO_HANDLE, ZKProofLike, ZKProofLike as ZKProofLike$1, ZamaError, ZamaErrorCode, ZamaSDK, ZamaSDK as ZamaSDK$1, ZamaSDKConfig, ZamaSDKEvent, ZamaSDKEventInput, ZamaSDKEventListener, ZamaSDKEventListener as ZamaSDKEventListener$1, ZamaSDKEventType, ZamaSDKEvents, allowanceContract, approveContract, balanceOfContract, chromeSessionStorage, clearPendingUnshield, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrapped, getDelegationExpiryContract, indexedDBStorage, inferredTotalSupplyContract, isConfidentialTokenContract, isConfidentialWrapperContract, isHandleDelegatedContract, isOperatorContract, isZeroHandle, loadPendingUnshield, matchAclRevert, matchZamaError, memoryStorage, nameContract, rateContract, revokeDelegationContract, savePendingUnshield, setOperatorContract, supportsInterfaceContract, symbolContract, totalSupplyContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract } from "@zama-fhe/sdk";
5
- import { ApproveUnderlyingParams, ApproveUnderlyingParams as ApproveUnderlyingParams$1, BatchDecryptBalancesAsParams, BatchDecryptBalancesAsParams as BatchDecryptBalancesAsParams$1, ConfidentialApproveParams, ConfidentialApproveParams as ConfidentialApproveParams$1, ConfidentialTransferFromParams, ConfidentialTransferFromParams as ConfidentialTransferFromParams$1, ConfidentialTransferParams, ConfidentialTransferParams as ConfidentialTransferParams$1, CreateDelegatedUserDecryptEIP712Params, CreateEIP712Params, DecryptBalanceAsParams, DecryptBalanceAsParams as DecryptBalanceAsParams$1, DecryptHandle, DecryptResult, DecryptResult as DecryptResult$1, DelegateDecryptionParams, DelegateDecryptionParams as DelegateDecryptionParams$1, DelegationStatusData, DelegationStatusData as DelegationStatusData$1, DelegationStatusQueryConfig, FinalizeUnwrapParams, FinalizeUnwrapParams as FinalizeUnwrapParams$1, ListPairsQueryConfig, ResumeUnshieldParams, ResumeUnshieldParams as ResumeUnshieldParams$1, RevokeDelegationParams, RevokeDelegationParams as RevokeDelegationParams$1, ShieldParams, ShieldParams as ShieldParams$1, TokenMetadata, UnshieldAllParams, UnshieldAllParams as UnshieldAllParams$1, UnshieldParams, UnshieldParams as UnshieldParams$1, UnwrapParams, UnwrapParams as UnwrapParams$1, UserDecryptQueryConfig, UserDecryptQueryConfig as UserDecryptQueryConfig$1, allowMutationOptions, approveUnderlyingMutationOptions, batchDecryptBalancesAsMutationOptions, confidentialApproveMutationOptions, confidentialBalanceQueryOptions, confidentialBalancesQueryOptions, confidentialIsApprovedQueryOptions, confidentialTransferFromMutationOptions, confidentialTransferMutationOptions, createDelegatedUserDecryptEIP712MutationOptions, createEIP712MutationOptions, decryptBalanceAsMutationOptions, delegateDecryptionMutationOptions, delegatedUserDecryptMutationOptions, delegationStatusQueryOptions, encryptMutationOptions, filterQueryOptions, finalizeUnwrapMutationOptions, generateKeypairMutationOptions, hashFn, isAllowedQueryOptions, isConfidentialQueryOptions, isWrapperQueryOptions, listPairsQueryOptions, publicDecryptMutationOptions, publicKeyQueryOptions, publicParamsQueryOptions, requestZKProofVerificationMutationOptions, resumeUnshieldMutationOptions, revokeDelegationMutationOptions, revokeMutationOptions, revokeSessionMutationOptions, shieldMutationOptions, signerAddressQueryOptions, tokenMetadataQueryOptions, totalSupplyQueryOptions, underlyingAllowanceQueryOptions, unshieldAllMutationOptions, unshieldMutationOptions, unwrapAllMutationOptions, unwrapMutationOptions, userDecryptQueryOptions, wrapperDiscoveryQueryOptions, zamaQueryKeys } from "@zama-fhe/sdk/query";
4
+ import { ACL_TOPICS, AclEvent, AclPausedError, ActivityAmount, ActivityDirection, ActivityItem, ActivityItem as ActivityItem$1, ActivityLogMetadata, ActivityLogMetadata as ActivityLogMetadata$1, ActivityType, Address, Address as Address$1, ApprovalFailedError, ApproveSubmittedEvent, ApproveUnderlyingSubmittedEvent, BalanceCheckUnavailableError, BaseEvent, BatchBalancesResult, BatchBalancesResult as BatchBalancesResult$1, BatchDecryptAsOptions, ChromeSessionStorage, ClearValueType, ClearValueType as ClearValueType$1, ConfidentialTransferEvent, ConfigurationError, ContractAbi, CredentialsAllowedEvent, CredentialsCachedEvent, CredentialsCreatedEvent, CredentialsCreatingEvent, CredentialsExpiredEvent, CredentialsLoadingEvent, CredentialsManager, CredentialsManagerConfig, CredentialsRevokedEvent, DecryptEndEvent, DecryptErrorEvent, DecryptStartEvent, DecryptionFailedError, DefaultRegistryAddresses, DelegatedCredentialsManager, DelegatedCredentialsManagerConfig, DelegatedForUserDecryptionEvent, DelegatedStoredCredentials, DelegatedUserDecryptParams, DelegatedUserDecryptParams as DelegatedUserDecryptParams$1, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, EIP712TypedData, EIP712TypedData as EIP712TypedData$1, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, EncryptEndEvent, EncryptErrorEvent, EncryptInput, EncryptParams, EncryptParams as EncryptParams$1, EncryptResult, EncryptResult as EncryptResult$1, EncryptStartEvent, EncryptionFailedError, FheTypeName, FhevmInstanceConfig, FinalizeUnwrapSubmittedEvent, GenericSigner, GenericSigner as GenericSigner$1, GenericStorage, GenericStorage as GenericStorage$1, Handle, HardhatConfig, Hex, IndexedDBStorage, InputProofBytesType, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidKeypairError, KeypairExpiredError, KeypairType, KmsDelegatedUserDecryptEIP712Type, ListPairsOptions, MainnetConfig, MemoryStorage, NetworkType, NoCiphertextError, OnChainEvent, PaginatedResult, PaginatedResult as PaginatedResult$1, PublicDecryptResult, PublicDecryptResult as PublicDecryptResult$1, RawLog, RawLog as RawLog$1, ReadContractArgs, ReadContractConfig, ReadContractReturnType, ReadFunctionName, ReadonlyToken, ReadonlyToken as ReadonlyToken$1, RelayerRequestFailedError, RelayerSDK, RelayerSDK as RelayerSDK$1, RelayerSDKStatus, RelayerWeb, RelayerWebConfig, RelayerWebSecurityConfig, RevokedDelegationForUserDecryptionEvent, SepoliaConfig, SessionExpiredEvent, ShieldCallbacks, ShieldSubmittedEvent, SigningFailedError, SigningRejectedError, StoredCredentials, TOKEN_TOPICS, Token, TokenWrapperPair, TokenWrapperPair as TokenWrapperPair$1, TokenWrapperPairWithMetadata, TokenWrapperPairWithMetadata as TokenWrapperPairWithMetadata$1, Topics, TransactionErrorEvent, TransactionReceipt, TransactionResult, TransactionResult as TransactionResult$1, TransactionRevertedError, TransferCallbacks, TransferFromSubmittedEvent, TransferSubmittedEvent, UnshieldCallbacks, UnshieldPhase1SubmittedEvent, UnshieldPhase2StartedEvent, UnshieldPhase2SubmittedEvent, UnwrapRequestedEvent, UnwrapSubmittedEvent, UnwrappedFinalizedEvent, UnwrappedStartedEvent, UserDecryptParams, WrappedEvent, WrappersRegistry, WrappersRegistryConfig, WriteContractArgs, WriteContractConfig, WriteFunctionName, ZERO_HANDLE, ZKProofLike, ZKProofLike as ZKProofLike$1, ZamaError, ZamaErrorCode, ZamaSDK, ZamaSDK as ZamaSDK$1, ZamaSDKConfig, ZamaSDKEvent, ZamaSDKEventInput, ZamaSDKEventListener, ZamaSDKEventListener as ZamaSDKEventListener$1, ZamaSDKEventType, ZamaSDKEvents, allowanceContract, applyDecryptedValues, approveContract, balanceOfContract, chromeSessionStorage, clearPendingUnshield, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, delegateForUserDecryptionContract, extractEncryptedHandles, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrapped, getDelegationExpiryContract, indexedDBStorage, inferredTotalSupplyContract, isConfidentialTokenContract, isConfidentialWrapperContract, isHandleDelegatedContract, isOperatorContract, isZeroHandle, loadPendingUnshield, matchAclRevert, matchZamaError, memoryStorage, nameContract, parseActivityFeed, rateContract, revokeDelegationContract, savePendingUnshield, setOperatorContract, sortByBlockNumber, supportsInterfaceContract, symbolContract, totalSupplyContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract } from "@zama-fhe/sdk";
5
+ import { ApproveUnderlyingParams, ApproveUnderlyingParams as ApproveUnderlyingParams$1, BatchDecryptBalancesAsParams, BatchDecryptBalancesAsParams as BatchDecryptBalancesAsParams$1, ConfidentialApproveParams, ConfidentialApproveParams as ConfidentialApproveParams$1, ConfidentialTransferFromParams, ConfidentialTransferFromParams as ConfidentialTransferFromParams$1, ConfidentialTransferParams, ConfidentialTransferParams as ConfidentialTransferParams$1, CreateDelegatedUserDecryptEIP712Params, CreateEIP712Params, DecryptBalanceAsParams, DecryptBalanceAsParams as DecryptBalanceAsParams$1, DecryptHandle, DecryptResult, DecryptResult as DecryptResult$1, DelegateDecryptionParams, DelegateDecryptionParams as DelegateDecryptionParams$1, DelegationStatusData, DelegationStatusData as DelegationStatusData$1, DelegationStatusQueryConfig, FinalizeUnwrapParams, FinalizeUnwrapParams as FinalizeUnwrapParams$1, ListPairsQueryConfig, ResumeUnshieldParams, ResumeUnshieldParams as ResumeUnshieldParams$1, RevokeDelegationParams, RevokeDelegationParams as RevokeDelegationParams$1, ShieldParams, ShieldParams as ShieldParams$1, TokenMetadata, UnshieldAllParams, UnshieldAllParams as UnshieldAllParams$1, UnshieldParams, UnshieldParams as UnshieldParams$1, UnwrapParams, UnwrapParams as UnwrapParams$1, UserDecryptQueryConfig, UserDecryptQueryConfig as UserDecryptQueryConfig$1, activityFeedQueryOptions, allowMutationOptions, approveUnderlyingMutationOptions, batchDecryptBalancesAsMutationOptions, confidentialApproveMutationOptions, confidentialBalanceQueryOptions, confidentialBalancesQueryOptions, confidentialIsApprovedQueryOptions, confidentialTransferFromMutationOptions, confidentialTransferMutationOptions, createDelegatedUserDecryptEIP712MutationOptions, createEIP712MutationOptions, decryptBalanceAsMutationOptions, delegateDecryptionMutationOptions, delegatedUserDecryptMutationOptions, delegationStatusQueryOptions, encryptMutationOptions, filterQueryOptions, finalizeUnwrapMutationOptions, generateKeypairMutationOptions, hashFn, isAllowedQueryOptions, isConfidentialQueryOptions, isWrapperQueryOptions, listPairsQueryOptions, publicDecryptMutationOptions, publicKeyQueryOptions, publicParamsQueryOptions, requestZKProofVerificationMutationOptions, resumeUnshieldMutationOptions, revokeDelegationMutationOptions, revokeMutationOptions, revokeSessionMutationOptions, shieldMutationOptions, signerAddressQueryOptions, tokenMetadataQueryOptions, totalSupplyQueryOptions, underlyingAllowanceQueryOptions, unshieldAllMutationOptions, unshieldMutationOptions, unwrapAllMutationOptions, unwrapMutationOptions, userDecryptQueryOptions, wrapperDiscoveryQueryOptions, zamaQueryKeys } from "@zama-fhe/sdk/query";
6
6
  import * as _$_tanstack_react_query0 from "@tanstack/react-query";
7
7
  import { QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions } from "@tanstack/react-query";
8
8
  import { PropsWithChildren } from "react";
@@ -98,17 +98,14 @@ declare function useZamaSDK(): ZamaSDK$1;
98
98
  * encrypt.mutate({ values: [{ value: 1000n, type: "euint64" }], contractAddress: "0x...", userAddress: "0x..." });
99
99
  * ```
100
100
  */
101
- declare function useEncrypt(): _$_tanstack_react_query0.UseMutationResult<Readonly<{
102
- handles: Uint8Array[];
103
- inputProof: Uint8Array;
104
- }>, Error, EncryptParams$1, unknown>;
101
+ declare function useEncrypt(): _$_tanstack_react_query0.UseMutationResult<EncryptResult$1, Error, EncryptParams$1, unknown>;
105
102
  //#endregion
106
103
  //#region src/relayer/use-user-decrypt.d.ts
107
104
  /**
108
105
  * React hook for FHE user decryption. Thin wrapper around
109
106
  * `userDecryptQueryOptions` with `useQuery` semantics.
110
107
  */
111
- declare function useUserDecrypt(config: UserDecryptQueryConfig$1, options?: Omit<UseQueryOptions<DecryptResult$1>, "queryKey" | "queryFn">): _$_tanstack_react_query0.UseQueryResult<Readonly<Record<`0x${string}`, _$_zama_fhe_sdk0.ClearValueType>>, Error>;
108
+ declare function useUserDecrypt(config: UserDecryptQueryConfig$1, options?: Omit<UseQueryOptions<DecryptResult$1>, "queryKey" | "queryFn">): _$_tanstack_react_query0.UseQueryResult<DecryptResult$1, Error>;
112
109
  /** Return type of {@link useUserDecrypt}. */
113
110
  type UseUserDecryptResult = ReturnType<typeof useUserDecrypt>;
114
111
  //#endregion
@@ -127,11 +124,7 @@ type UseUserDecryptResult = ReturnType<typeof useUserDecrypt>;
127
124
  * // publicDecrypt.data?.clearValues => { "0xHandle1": 500n, ... }
128
125
  * ```
129
126
  */
130
- declare function usePublicDecrypt(): _$_tanstack_react_query0.UseMutationResult<Readonly<{
131
- clearValues: _$_zama_fhe_relayer_sdk_web0.ClearValues;
132
- abiEncodedClearValues: `0x${string}`;
133
- decryptionProof: `0x${string}`;
134
- }>, Error, `0x${string}`[], unknown>;
127
+ declare function usePublicDecrypt(): _$_tanstack_react_query0.UseMutationResult<PublicDecryptResult$1, Error, `0x${string}`[], unknown>;
135
128
  //#endregion
136
129
  //#region src/relayer/use-generate-keypair.d.ts
137
130
  /**
@@ -232,6 +225,13 @@ declare function useRequestZKProofVerification(): _$_tanstack_react_query0.UseMu
232
225
  }>, Error, ZKProofLike$1, unknown>;
233
226
  //#endregion
234
227
  //#region src/relayer/use-public-key.d.ts
228
+ /** Shape of the FHE public key data returned by the relayer. */
229
+ interface PublicKeyData {
230
+ /** Unique identifier for this public key version. */
231
+ publicKeyId: string;
232
+ /** The raw FHE public key bytes. */
233
+ publicKey: Uint8Array;
234
+ }
235
235
  /**
236
236
  * Fetch the FHE network public key from the relayer.
237
237
  * Cached indefinitely since the key does not change during a session.
@@ -247,6 +247,13 @@ declare function useRequestZKProofVerification(): _$_tanstack_react_query0.UseMu
247
247
  declare function usePublicKey(): _$_tanstack_react_query0.UseQueryResult<PublicKeyData | null, Error>;
248
248
  //#endregion
249
249
  //#region src/relayer/use-public-params.d.ts
250
+ /** Shape of the FHE public parameters returned by the relayer. */
251
+ interface PublicParamsData {
252
+ /** The raw public parameters bytes (WASM-ready). */
253
+ publicParams: Uint8Array;
254
+ /** Unique identifier for this public params version. */
255
+ publicParamsId: string;
256
+ }
250
257
  /**
251
258
  * Fetch FHE public parameters for a given bit size from the relayer.
252
259
  * Cached indefinitely since parameters do not change during a session.
@@ -260,10 +267,7 @@ declare function usePublicKey(): _$_tanstack_react_query0.UseQueryResult<PublicK
260
267
  * // params?.publicParams, params?.publicParamsId
261
268
  * ```
262
269
  */
263
- declare function usePublicParams(bits: number): _$_tanstack_react_query0.UseQueryResult<{
264
- publicParams: Uint8Array<ArrayBufferLike>;
265
- publicParamsId: string;
266
- } | null, Error>;
270
+ declare function usePublicParams(bits: number): _$_tanstack_react_query0.UseQueryResult<PublicParamsData | null, Error>;
267
271
  //#endregion
268
272
  //#region src/authorization/use-allow.d.ts
269
273
  /**
@@ -666,7 +670,7 @@ declare function useUnwrapAll(config: UseZamaConfig, options?: UseMutationOption
666
670
  * @example
667
671
  * ```tsx
668
672
  * const finalize = useFinalizeUnwrap({ tokenAddress: "0x..." });
669
- * finalize.mutate({ unwrapRequestId: event.unwrapRequestId });
673
+ * finalize.mutate({ burnAmountHandle: event.encryptedAmount });
670
674
  * ```
671
675
  */
672
676
  declare function useFinalizeUnwrap(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, FinalizeUnwrapParams$1, Address$1>): _$_tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, FinalizeUnwrapParams$1, `0x${string}`>;
@@ -865,6 +869,40 @@ declare function useMetadata(tokenAddress: Address$1, options?: Omit<UseQueryOpt
865
869
  */
866
870
  declare function useMetadataSuspense(tokenAddress: Address$1): _$_tanstack_react_query0.UseSuspenseQueryResult<TokenMetadata, Error>;
867
871
  //#endregion
872
+ //#region src/balance/use-activity-feed.d.ts
873
+ /** Configuration for {@link useActivityFeed}. */
874
+ interface UseActivityFeedConfig {
875
+ /** Address of the confidential token contract. */
876
+ tokenAddress: Address$1;
877
+ /** Connected wallet address. Pass `undefined` to disable the query. */
878
+ userAddress: Address$1 | undefined;
879
+ /** Raw event logs from the provider (viem, ethers, etc.). Pass `undefined` to disable. */
880
+ logs: readonly (RawLog$1 & Partial<ActivityLogMetadata$1>)[] | undefined;
881
+ /** Whether to batch-decrypt encrypted transfer amounts. Default: `true`. */
882
+ decrypt?: boolean;
883
+ }
884
+ /**
885
+ * Two-phase activity feed hook.
886
+ * Phase 1: Instantly parses raw logs into classified {@link ActivityItem}s (sync, cheap).
887
+ * Phase 2: Batch-decrypts encrypted transfer amounts via the relayer (async).
888
+ *
889
+ * The wallet provides logs (from its own provider — viem, ethers, etc.)
890
+ * and this hook normalizes + decrypts them.
891
+ *
892
+ * @param config - Token address, user address, raw logs, and decrypt option.
893
+ * @returns Query result with `data: ActivityItem[]`.
894
+ *
895
+ * @example
896
+ * ```tsx
897
+ * const { data: activity } = useActivityFeed({
898
+ * tokenAddress: "0xToken",
899
+ * userAddress: "0xUser",
900
+ * logs: rawLogs,
901
+ * });
902
+ * ```
903
+ */
904
+ declare function useActivityFeed(config: UseActivityFeedConfig): _$_tanstack_react_query0.UseQueryResult<ActivityItem$1[], Error>;
905
+ //#endregion
868
906
  //#region src/delegation/use-delegate-decryption.d.ts
869
907
  /**
870
908
  * Delegate FHE decryption rights for a token to another address via the on-chain ACL.
@@ -1183,5 +1221,5 @@ interface OptimisticMutateContext {
1183
1221
  callerContext?: unknown;
1184
1222
  }
1185
1223
  //#endregion
1186
- export { ACL_TOPICS, type AclEvent, AclPausedError, type Address, ApprovalFailedError, type ApproveSubmittedEvent, type ApproveUnderlyingParams, type ApproveUnderlyingSubmittedEvent, BalanceCheckUnavailableError, type BaseEvent, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptBalancesAsParams, ChromeSessionStorage, type ClearValueType, type ConfidentialApproveParams, type ConfidentialTransferEvent, type ConfidentialTransferFromParams, type ConfidentialTransferParams, ConfigurationError, type ContractAbi, type CreateDelegatedUserDecryptEIP712Params, type CreateEIP712Params, type CredentialsAllowedEvent, type CredentialsCachedEvent, type CredentialsCreatedEvent, type CredentialsCreatingEvent, type CredentialsExpiredEvent, type CredentialsLoadingEvent, CredentialsManager, type CredentialsManagerConfig, type CredentialsRevokedEvent, type DecryptBalanceAsParams, type DecryptEndEvent, type DecryptErrorEvent, type DecryptHandle, type DecryptResult, type DecryptStartEvent, DecryptionFailedError, DefaultRegistryAddresses, type DelegateDecryptionParams, DelegatedCredentialsManager, type DelegatedCredentialsManagerConfig, type DelegatedForUserDecryptionEvent, type DelegatedStoredCredentials, type DelegatedUserDecryptParams, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatusData, type DelegationStatusQueryConfig, type EIP712TypedData, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID_LEGACY, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, EncryptionFailedError, type FheTypeName, type FhevmInstanceConfig, type FinalizeUnwrapParams, type FinalizeUnwrapSubmittedEvent, type GenericSigner, type GenericStorage, type Handle, HardhatConfig, type Hex, IndexedDBStorage, type InputProofBytesType, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidKeypairError, KeypairExpiredError, type KeypairType, type KmsDelegatedUserDecryptEIP712Type, type ListPairsOptions, type ListPairsQueryConfig, MainnetConfig, MemoryStorage, type NetworkType, NoCiphertextError, type OnChainEvent, type OptimisticBalanceSnapshot, type OptimisticMutateContext, type PaginatedResult, type PublicDecryptResult, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, ReadonlyToken, RelayerRequestFailedError, type RelayerSDK, type RelayerSDKStatus, RelayerWeb, type RelayerWebConfig, type RelayerWebSecurityConfig, type ResumeUnshieldParams, type RevokeDelegationParams, type RevokedDelegationForUserDecryptionEvent, SepoliaConfig, type SessionExpiredEvent, type ShieldCallbacks, type ShieldParams, type ShieldSubmittedEvent, SigningFailedError, SigningRejectedError, type StoredCredentials, TOKEN_TOPICS, Token, type TokenMetadata, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferSubmittedEvent, type UnshieldAllParams, type UnshieldCallbacks, type UnshieldParams, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapParams, type UnwrapRequestedEvent, type UnwrapSubmittedEvent, type UnwrappedFinalizedEvent, type UnwrappedStartedEvent, type UseConfidentialBalanceConfig, type UseConfidentialBalanceOptions, type UseConfidentialBalancesConfig, type UseConfidentialBalancesOptions, type UseConfidentialIsApprovedConfig, type UseConfidentialIsApprovedSuspenseConfig, type UseConfidentialTransferConfig, type UseDelegationStatusConfig, type UseIsAllowedConfig, type UseShieldConfig, type UseUnderlyingAllowanceConfig, type UseUserDecryptResult, type UseWrapperDiscoveryConfig, type UseWrapperDiscoverySuspenseConfig, type UseZamaConfig, type UserDecryptParams, type UserDecryptQueryConfig, type WrappedEvent, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_HANDLE, type ZKProofLike, ZamaError, ZamaErrorCode, ZamaProvider, type ZamaProviderProps, ZamaSDK, type ZamaSDKConfig, type ZamaSDKEvent, type ZamaSDKEventInput, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, allowMutationOptions, allowanceContract, approveContract, approveUnderlyingMutationOptions, balanceOfContract, batchDecryptBalancesAsMutationOptions, chromeSessionStorage, clearPendingUnshield, confidentialApproveMutationOptions, confidentialBalanceOfContract, confidentialBalanceQueryOptions, confidentialBalancesQueryOptions, confidentialIsApprovedQueryOptions, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, confidentialTransferFromMutationOptions, confidentialTransferMutationOptions, createDelegatedUserDecryptEIP712MutationOptions, createEIP712MutationOptions, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, decryptBalanceAsMutationOptions, delegateDecryptionMutationOptions, delegateForUserDecryptionContract, delegatedUserDecryptMutationOptions, delegationStatusQueryOptions, encryptMutationOptions, filterQueryOptions, finalizeUnwrapContract, finalizeUnwrapMutationOptions, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrapped, generateKeypairMutationOptions, getDelegationExpiryContract, hashFn, indexedDBStorage, inferredTotalSupplyContract, isAllowedQueryOptions, isConfidentialQueryOptions, isConfidentialTokenContract, isConfidentialWrapperContract, isHandleDelegatedContract, isOperatorContract, isWrapperQueryOptions, isZeroHandle, listPairsQueryOptions, loadPendingUnshield, matchAclRevert, matchZamaError, memoryStorage, nameContract, publicDecryptMutationOptions, publicKeyQueryOptions, publicParamsQueryOptions, rateContract, requestZKProofVerificationMutationOptions, resumeUnshieldMutationOptions, revokeDelegationContract, revokeDelegationMutationOptions, revokeMutationOptions, revokeSessionMutationOptions, savePendingUnshield, setOperatorContract, shieldMutationOptions, signerAddressQueryOptions, supportsInterfaceContract, symbolContract, tokenMetadataQueryOptions, totalSupplyContract, totalSupplyQueryOptions, underlyingAllowanceQueryOptions, underlyingContract, unshieldAllMutationOptions, unshieldMutationOptions, unwrapAllMutationOptions, unwrapContract, unwrapFromBalanceContract, unwrapMutationOptions, useAllow, useApproveUnderlying, useBatchDecryptBalancesAs, useConfidentialApprove, useConfidentialBalance, useConfidentialBalances, useConfidentialIsApproved, useConfidentialIsApprovedSuspense, useConfidentialTokenAddress, useConfidentialTransfer, useConfidentialTransferFrom, useCreateDelegatedUserDecryptEIP712, useCreateEIP712, useDecryptBalanceAs, useDelegateDecryption, useDelegatedUserDecrypt, useDelegationStatus, useEncrypt, useFinalizeUnwrap, useGenerateKeypair, useIsAllowed, useIsConfidential, useIsConfidentialSuspense, useIsConfidentialTokenValid, useIsWrapper, useIsWrapperSuspense, useListPairs, useMetadata, useMetadataSuspense, usePublicDecrypt, usePublicKey, usePublicParams, useReadonlyToken, useRequestZKProofVerification, useResumeUnshield, useRevoke, useRevokeDelegation, useRevokeSession, useShield, useToken, useTokenAddress, useTokenPair, useTokenPairsLength, useTokenPairsRegistry, useTokenPairsSlice, useTotalSupply, useTotalSupplySuspense, useUnderlyingAllowance, useUnderlyingAllowanceSuspense, useUnshield, useUnshieldAll, useUnwrap, useUnwrapAll, useUserDecrypt, useWrapperDiscovery, useWrapperDiscoverySuspense, useWrappersRegistryAddress, useZamaSDK, userDecryptQueryOptions, wrapContract, wrapperDiscoveryQueryOptions, zamaQueryKeys };
1224
+ export { ACL_TOPICS, type AclEvent, AclPausedError, type ActivityAmount, type ActivityDirection, type ActivityItem, type ActivityLogMetadata, type ActivityType, type Address, ApprovalFailedError, type ApproveSubmittedEvent, type ApproveUnderlyingParams, type ApproveUnderlyingSubmittedEvent, BalanceCheckUnavailableError, type BaseEvent, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptBalancesAsParams, ChromeSessionStorage, type ClearValueType, type ConfidentialApproveParams, type ConfidentialTransferEvent, type ConfidentialTransferFromParams, type ConfidentialTransferParams, ConfigurationError, type ContractAbi, type CreateDelegatedUserDecryptEIP712Params, type CreateEIP712Params, type CredentialsAllowedEvent, type CredentialsCachedEvent, type CredentialsCreatedEvent, type CredentialsCreatingEvent, type CredentialsExpiredEvent, type CredentialsLoadingEvent, CredentialsManager, type CredentialsManagerConfig, type CredentialsRevokedEvent, type DecryptBalanceAsParams, type DecryptEndEvent, type DecryptErrorEvent, type DecryptHandle, type DecryptResult, type DecryptStartEvent, DecryptionFailedError, DefaultRegistryAddresses, type DelegateDecryptionParams, DelegatedCredentialsManager, type DelegatedCredentialsManagerConfig, type DelegatedForUserDecryptionEvent, type DelegatedStoredCredentials, type DelegatedUserDecryptParams, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatusData, type DelegationStatusQueryConfig, type EIP712TypedData, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, EncryptionFailedError, type FheTypeName, type FhevmInstanceConfig, type FinalizeUnwrapParams, type FinalizeUnwrapSubmittedEvent, type GenericSigner, type GenericStorage, type Handle, HardhatConfig, type Hex, IndexedDBStorage, type InputProofBytesType, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidKeypairError, KeypairExpiredError, type KeypairType, type KmsDelegatedUserDecryptEIP712Type, type ListPairsOptions, type ListPairsQueryConfig, MainnetConfig, MemoryStorage, type NetworkType, NoCiphertextError, type OnChainEvent, type OptimisticBalanceSnapshot, type OptimisticMutateContext, type PaginatedResult, type PublicDecryptResult, type PublicKeyData, type PublicParamsData, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, ReadonlyToken, RelayerRequestFailedError, type RelayerSDK, type RelayerSDKStatus, RelayerWeb, type RelayerWebConfig, type RelayerWebSecurityConfig, type ResumeUnshieldParams, type RevokeDelegationParams, type RevokedDelegationForUserDecryptionEvent, SepoliaConfig, type SessionExpiredEvent, type ShieldCallbacks, type ShieldParams, type ShieldSubmittedEvent, SigningFailedError, SigningRejectedError, type StoredCredentials, TOKEN_TOPICS, Token, type TokenMetadata, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferSubmittedEvent, type UnshieldAllParams, type UnshieldCallbacks, type UnshieldParams, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapParams, type UnwrapRequestedEvent, type UnwrapSubmittedEvent, type UnwrappedFinalizedEvent, type UnwrappedStartedEvent, type UseActivityFeedConfig, type UseConfidentialBalanceConfig, type UseConfidentialBalanceOptions, type UseConfidentialBalancesConfig, type UseConfidentialBalancesOptions, type UseConfidentialIsApprovedConfig, type UseConfidentialIsApprovedSuspenseConfig, type UseConfidentialTransferConfig, type UseDelegationStatusConfig, type UseIsAllowedConfig, type UseShieldConfig, type UseUnderlyingAllowanceConfig, type UseUserDecryptResult, type UseWrapperDiscoveryConfig, type UseWrapperDiscoverySuspenseConfig, type UseZamaConfig, type UserDecryptParams, type UserDecryptQueryConfig, type WrappedEvent, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_HANDLE, type ZKProofLike, ZamaError, ZamaErrorCode, ZamaProvider, type ZamaProviderProps, ZamaSDK, type ZamaSDKConfig, type ZamaSDKEvent, type ZamaSDKEventInput, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, activityFeedQueryOptions, allowMutationOptions, allowanceContract, applyDecryptedValues, approveContract, approveUnderlyingMutationOptions, balanceOfContract, batchDecryptBalancesAsMutationOptions, chromeSessionStorage, clearPendingUnshield, confidentialApproveMutationOptions, confidentialBalanceOfContract, confidentialBalanceQueryOptions, confidentialBalancesQueryOptions, confidentialIsApprovedQueryOptions, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, confidentialTransferFromMutationOptions, confidentialTransferMutationOptions, createDelegatedUserDecryptEIP712MutationOptions, createEIP712MutationOptions, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, decryptBalanceAsMutationOptions, delegateDecryptionMutationOptions, delegateForUserDecryptionContract, delegatedUserDecryptMutationOptions, delegationStatusQueryOptions, encryptMutationOptions, extractEncryptedHandles, filterQueryOptions, finalizeUnwrapContract, finalizeUnwrapMutationOptions, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrapped, generateKeypairMutationOptions, getDelegationExpiryContract, hashFn, indexedDBStorage, inferredTotalSupplyContract, isAllowedQueryOptions, isConfidentialQueryOptions, isConfidentialTokenContract, isConfidentialWrapperContract, isHandleDelegatedContract, isOperatorContract, isWrapperQueryOptions, isZeroHandle, listPairsQueryOptions, loadPendingUnshield, matchAclRevert, matchZamaError, memoryStorage, nameContract, parseActivityFeed, publicDecryptMutationOptions, publicKeyQueryOptions, publicParamsQueryOptions, rateContract, requestZKProofVerificationMutationOptions, resumeUnshieldMutationOptions, revokeDelegationContract, revokeDelegationMutationOptions, revokeMutationOptions, revokeSessionMutationOptions, savePendingUnshield, setOperatorContract, shieldMutationOptions, signerAddressQueryOptions, sortByBlockNumber, supportsInterfaceContract, symbolContract, tokenMetadataQueryOptions, totalSupplyContract, totalSupplyQueryOptions, underlyingAllowanceQueryOptions, underlyingContract, unshieldAllMutationOptions, unshieldMutationOptions, unwrapAllMutationOptions, unwrapContract, unwrapFromBalanceContract, unwrapMutationOptions, useActivityFeed, useAllow, useApproveUnderlying, useBatchDecryptBalancesAs, useConfidentialApprove, useConfidentialBalance, useConfidentialBalances, useConfidentialIsApproved, useConfidentialIsApprovedSuspense, useConfidentialTokenAddress, useConfidentialTransfer, useConfidentialTransferFrom, useCreateDelegatedUserDecryptEIP712, useCreateEIP712, useDecryptBalanceAs, useDelegateDecryption, useDelegatedUserDecrypt, useDelegationStatus, useEncrypt, useFinalizeUnwrap, useGenerateKeypair, useIsAllowed, useIsConfidential, useIsConfidentialSuspense, useIsConfidentialTokenValid, useIsWrapper, useIsWrapperSuspense, useListPairs, useMetadata, useMetadataSuspense, usePublicDecrypt, usePublicKey, usePublicParams, useReadonlyToken, useRequestZKProofVerification, useResumeUnshield, useRevoke, useRevokeDelegation, useRevokeSession, useShield, useToken, useTokenAddress, useTokenPair, useTokenPairsLength, useTokenPairsRegistry, useTokenPairsSlice, useTotalSupply, useTotalSupplySuspense, useUnderlyingAllowance, useUnderlyingAllowanceSuspense, useUnshield, useUnshieldAll, useUnwrap, useUnwrapAll, useUserDecrypt, useWrapperDiscovery, useWrapperDiscoverySuspense, useWrappersRegistryAddress, useZamaSDK, userDecryptQueryOptions, wrapContract, wrapperDiscoveryQueryOptions, zamaQueryKeys };
1187
1225
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use client";import{ACL_TOPICS as e,AclPausedError as t,ApprovalFailedError as n,BalanceCheckUnavailableError as r,ChromeSessionStorage as i,ConfigurationError as a,CredentialsManager as o,DecryptionFailedError as s,DefaultRegistryAddresses as c,DelegatedCredentialsManager as l,DelegationContractIsSelfError as u,DelegationCooldownError as d,DelegationDelegateEqualsContractError as f,DelegationExpirationTooSoonError as p,DelegationExpiredError as ee,DelegationExpiryUnchangedError as te,DelegationNotFoundError as ne,DelegationNotPropagatedError as re,DelegationSelfNotAllowedError as ie,ERC20ReadFailedError as ae,ERC7984_INTERFACE_ID as oe,ERC7984_WRAPPER_INTERFACE_ID as se,ERC7984_WRAPPER_INTERFACE_ID_LEGACY as ce,EncryptionFailedError as le,HardhatConfig as ue,IndexedDBStorage as de,InsufficientConfidentialBalanceError as fe,InsufficientERC20BalanceError as pe,InvalidKeypairError as me,KeypairExpiredError as he,MainnetConfig as ge,MemoryStorage as _e,NoCiphertextError as ve,ReadonlyToken as ye,RelayerRequestFailedError as be,RelayerWeb as xe,SepoliaConfig as Se,SigningFailedError as Ce,SigningRejectedError as we,TOKEN_TOPICS as Te,Token as Ee,Topics as De,TransactionRevertedError as Oe,WrappersRegistry as ke,ZERO_HANDLE as m,ZamaError as h,ZamaErrorCode as g,ZamaSDK as _,ZamaSDK as v,ZamaSDKEvents as y,allowanceContract as b,approveContract as x,balanceOfContract as S,chromeSessionStorage as C,clearPendingUnshield as w,confidentialBalanceOfContract as Ae,confidentialTotalSupplyContract as je,confidentialTransferContract as Me,confidentialTransferFromContract as Ne,decimalsContract as Pe,decodeAclEvent as Fe,decodeAclEvents as Ie,decodeConfidentialTransfer as Le,decodeDelegatedForUserDecryption as Re,decodeOnChainEvent as ze,decodeOnChainEvents as Be,decodeRevokedDelegationForUserDecryption as Ve,decodeUnwrapRequested as He,decodeUnwrappedFinalized as Ue,decodeUnwrappedStarted as We,decodeWrapped as Ge,delegateForUserDecryptionContract as Ke,finalizeUnwrapContract as qe,findDelegatedForUserDecryption as Je,findRevokedDelegationForUserDecryption as Ye,findUnwrapRequested as Xe,findWrapped as Ze,getDelegationExpiryContract as Qe,indexedDBStorage as $e,inferredTotalSupplyContract as et,isConfidentialTokenContract as tt,isConfidentialWrapperContract as nt,isHandleDelegatedContract as rt,isOperatorContract as it,isZeroHandle as at,loadPendingUnshield as ot,matchAclRevert as st,matchZamaError as ct,memoryStorage as lt,nameContract as ut,rateContract as dt,revokeDelegationContract as ft,savePendingUnshield as pt,setOperatorContract as mt,supportsInterfaceContract as ht,symbolContract as gt,totalSupplyContract as _t,underlyingContract as vt,unwrapContract as yt,unwrapFromBalanceContract as bt,wrapContract as xt}from"@zama-fhe/sdk";import{allowMutationOptions as St,allowMutationOptions as Ct,approveUnderlyingMutationOptions as wt,approveUnderlyingMutationOptions as Tt,batchDecryptBalancesAsMutationOptions as Et,batchDecryptBalancesAsMutationOptions as Dt,confidentialApproveMutationOptions as Ot,confidentialApproveMutationOptions as kt,confidentialBalanceQueryOptions as At,confidentialBalanceQueryOptions as jt,confidentialBalancesQueryOptions as Mt,confidentialBalancesQueryOptions as Nt,confidentialIsApprovedQueryOptions as Pt,confidentialIsApprovedQueryOptions as T,confidentialTokenAddressQueryOptions as Ft,confidentialTransferFromMutationOptions as It,confidentialTransferFromMutationOptions as Lt,confidentialTransferMutationOptions as Rt,confidentialTransferMutationOptions as zt,createDelegatedUserDecryptEIP712MutationOptions as Bt,createDelegatedUserDecryptEIP712MutationOptions as Vt,createEIP712MutationOptions as Ht,createEIP712MutationOptions as Ut,decryptBalanceAsMutationOptions as Wt,decryptBalanceAsMutationOptions as Gt,delegateDecryptionMutationOptions as Kt,delegateDecryptionMutationOptions as qt,delegatedUserDecryptMutationOptions as Jt,delegatedUserDecryptMutationOptions as Yt,delegationStatusQueryOptions as Xt,delegationStatusQueryOptions as Zt,encryptMutationOptions as Qt,encryptMutationOptions as $t,filterQueryOptions as en,finalizeUnwrapMutationOptions as tn,finalizeUnwrapMutationOptions as nn,generateKeypairMutationOptions as rn,generateKeypairMutationOptions as an,hashFn as on,hashFn as E,invalidateAfterApprove as sn,invalidateAfterApproveUnderlying as cn,invalidateAfterShield as ln,invalidateAfterTransfer as D,invalidateAfterUnshield as O,invalidateAfterUnwrap as k,invalidateWalletLifecycleQueries as A,isAllowedQueryOptions as un,isAllowedQueryOptions as dn,isConfidentialQueryOptions as fn,isConfidentialQueryOptions as j,isConfidentialTokenValidQueryOptions as M,isWrapperQueryOptions as pn,isWrapperQueryOptions as N,listPairsQueryOptions as mn,listPairsQueryOptions as hn,publicDecryptMutationOptions as gn,publicDecryptMutationOptions as _n,publicKeyQueryOptions as vn,publicKeyQueryOptions as yn,publicParamsQueryOptions as bn,publicParamsQueryOptions as xn,requestZKProofVerificationMutationOptions as Sn,requestZKProofVerificationMutationOptions as Cn,resumeUnshieldMutationOptions as wn,resumeUnshieldMutationOptions as Tn,revokeDelegationMutationOptions as En,revokeDelegationMutationOptions as Dn,revokeMutationOptions as On,revokeMutationOptions as kn,revokeSessionMutationOptions as An,revokeSessionMutationOptions as jn,shieldMutationOptions as Mn,shieldMutationOptions as Nn,signerAddressQueryOptions as Pn,signerAddressQueryOptions as P,tokenAddressQueryOptions as Fn,tokenMetadataQueryOptions as In,tokenMetadataQueryOptions as F,tokenPairQueryOptions as Ln,tokenPairsLengthQueryOptions as Rn,tokenPairsQueryOptions as zn,tokenPairsSliceQueryOptions as Bn,totalSupplyQueryOptions as Vn,totalSupplyQueryOptions as I,underlyingAllowanceQueryOptions as Hn,underlyingAllowanceQueryOptions as L,unshieldAllMutationOptions as Un,unshieldAllMutationOptions as Wn,unshieldMutationOptions as Gn,unshieldMutationOptions as Kn,unwrapAllMutationOptions as qn,unwrapAllMutationOptions as Jn,unwrapMutationOptions as Yn,unwrapMutationOptions as Xn,userDecryptQueryOptions as Zn,userDecryptQueryOptions as Qn,wrapperDiscoveryQueryOptions as $n,wrapperDiscoveryQueryOptions as R,zamaQueryKeys as er,zamaQueryKeys as z}from"@zama-fhe/sdk/query";import{skipToken as tr,useMutation as B,useQuery as nr,useQueryClient as V,useSuspenseQuery as rr}from"@tanstack/react-query";import{createContext as ir,useContext as ar,useEffect as H,useMemo as U,useRef as or}from"react";import{jsx as sr}from"react/jsx-runtime";const W=ir(null);function cr({children:e,relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,registryAddresses:s,registryTTL:c,onEvent:l}){let u=V(),d=or(l);H(()=>{d.current=l});let f=U(()=>n?.subscribe?{onDisconnect:()=>A(u),onAccountChange:()=>A(u),onChainChange:()=>A(u)}:void 0,[u,n]),p=U(()=>new v({relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,registryAddresses:s,registryTTL:c,onEvent:d.current,signerLifecycleCallbacks:f}),[t,n,r,i,a,o,s,c,f]);return H(()=>()=>p.dispose(),[p]),sr(W.Provider,{value:p,children:e})}function G(){let e=ar(W);if(!e)throw Error(`useZamaSDK must be used within a <ZamaProvider>. Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.`);return e}function lr(){return B($t(G()))}function K(e){return nr({...e,queryKeyHashFn:E})}function q(e){return rr({...e,queryKeyHashFn:E})}function ur(e,t){let n=Qn(G(),e);return K({...n,...t,enabled:n.enabled&&(t?.enabled??!1)})}function dr(){return B(_n(G()))}function fr(){return B(an(G()))}function pr(){return B(Ut(G()))}function mr(){return B(Vt(G()))}function hr(){return B(Yt(G()))}function gr(){return B(Cn(G()))}function _r(){return K(yn(G()))}function vr(e){return K(xn(G(),e))}function yr(e){return B({...Ct(G()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:z.isAllowed.all})}})}function br(e){let t=G(),n=K({...P(t.signer)}).data;return K(n?dn(t,{account:n,contractAddresses:e.contractAddresses}):{queryKey:z.isAllowed.all,queryFn:tr,enabled:!1})}function xr(e){return B({...kn(G()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.removeQueries({queryKey:z.isAllowed.all}),i.client.removeQueries({queryKey:z.decryption.all})}})}function Sr(e){return B({...jn(G()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.removeQueries({queryKey:z.isAllowed.all}),i.client.removeQueries({queryKey:z.decryption.all})}})}function J(e){let t=G();return U(()=>t.createToken(e.tokenAddress,e.wrapperAddress),[t,e.tokenAddress,e.wrapperAddress])}function Y(e){let t=G();return U(()=>t.createReadonlyToken(e),[t,e])}function Cr(e,t){let{tokenAddress:n}=e,{enabled:r=!0}=t??{},i=G(),a=Y(n),o=K(P(i.signer)).data,s=jt(a,{tokenAddress:n,owner:o});return K({...s,...t,enabled:s.enabled&&r})}function wr(e,t){let{tokenAddresses:n}=e,{enabled:r=!0}=t??{},i=G(),a=K(P(i.signer)).data,o=Nt(U(()=>n.map(e=>i.createReadonlyToken(e)),[i,n]),{owner:a});return K({...o,...t,enabled:(o.enabled??!0)&&r})}function X(e,t){let n=e?t:void 0;return{wrappedContext:n,callerContext:e?n?.callerContext:t}}async function Z({queryClient:e,tokenAddress:t,amount:n,mode:r}){let i=z.confidentialBalance.token(t);await e.cancelQueries({queryKey:i});let a=e.getQueriesData({queryKey:i});for(let[t,i]of a)i!==void 0&&e.setQueryData(t,r===`add`?i+n:i-n);return a}function Q(e,t){for(let[n,r]of t)e.setQueryData(n,r)}function Tr({optimistic:e,tokenAddress:t,queryClient:n,options:r}){return{onMutate:e?async(e,i)=>({snapshot:await Z({queryClient:n,tokenAddress:t,amount:e.amount,mode:`add`}),callerContext:await r?.onMutate?.(e,i)}):r?.onMutate,onError:(t,i,a,o)=>{let{wrappedContext:s,callerContext:c}=X(e,a);try{s&&Q(n,s.snapshot)}finally{r?.onError?.(t,i,c,o)}},onSuccess:(n,i,a,o)=>{let{callerContext:s}=X(e,a);r?.onSuccess?.(n,i,s,o),ln(o.client,t)},onSettled:(t,n,i,a,o)=>{let{callerContext:s}=X(e,a);r?.onSettled?.(t,n,i,s,o)}}}function Er(e,t){let n=J(e),r=V();return B({...zt(n),...t,onMutate:e.optimistic?async(n,i)=>({snapshot:await Z({queryClient:r,tokenAddress:e.tokenAddress,amount:n.amount,mode:`subtract`}),callerContext:await t?.onMutate?.(n,i)}):t?.onMutate,onError:(n,i,a,o)=>{let{wrappedContext:s,callerContext:c}=X(e.optimistic,a);try{s&&Q(r,s.snapshot)}finally{t?.onError?.(n,i,c,o)}},onSuccess:(n,r,i,a)=>{let{callerContext:o}=X(e.optimistic,i);t?.onSuccess?.(n,r,o,a),D(a.client,e.tokenAddress)},onSettled:(n,r,i,a,o)=>{let{callerContext:s}=X(e.optimistic,a);t?.onSettled?.(n,r,i,s,o)}})}function Dr(e,t){return B({...Lt(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function Or(e,t){return B({...kt(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),sn(a.client,e.tokenAddress)}})}function kr(e,t){let{tokenAddress:n,spender:r,holder:i}=e,a=G(),o=K({...P(a.signer),enabled:n!==void 0&&r!==void 0&&i===void 0}),s=i??o.data,c=T(a.signer,n,{holder:s,spender:r});return K({...c,...t,enabled:(c.enabled??!0)&&(t?.enabled??!0)})}function Ar(e){let{spender:t,holder:n,...r}=e,i=G(),a=J(r),o=q(P(i.signer)),s=n??o.data;return q(T(i.signer,a.address,{holder:s,spender:t}))}function jr(e,t){let n=J(e),r=V();return B({...Nn(n),...t,...Tr({optimistic:e.optimistic,tokenAddress:e.tokenAddress,queryClient:r,options:t})})}function Mr(e,t){return B({...Xn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),k(a.client,e.tokenAddress)}})}function Nr(e,t){return B({...Jn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),k(a.client,e.tokenAddress)}})}function Pr(e,t){return B({...nn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),O(a.client,e.tokenAddress)}})}function Fr(e,t){return B({...Kn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),O(a.client,e.tokenAddress)}})}function Ir(e,t){return B({...Wn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),O(a.client,e.tokenAddress)}})}function Lr(e,t){return B({...Tn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),O(a.client,e.tokenAddress)}})}function Rr(e,t){let{tokenAddress:n,wrapperAddress:r}=e,i=G(),a=K(P(i.signer)).data,o=L(i.signer,n,{owner:a,wrapperAddress:r});return K({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function zr(e){let{tokenAddress:t,wrapperAddress:n}=e,r=G(),i=q(P(r.signer)).data;return q(L(r.signer,t,{owner:i,wrapperAddress:n}))}function $(){let e=G(),{data:t}=K({queryKey:z.wrappersRegistry.chainId(),queryFn:()=>e.signer.getChainId(),staleTime:3e4});return t===void 0?void 0:e.registry.getAddress(t)}function Br(e,t){let{tokenAddress:n,erc20Address:r}=e,i=G(),a=$(),o=R(i.registry,{tokenAddress:n,erc20Address:r,registryAddress:a});return K({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function Vr(e){let{tokenAddress:t,erc20Address:n}=e,r=G(),i=$();return q(R(r.registry,{tokenAddress:t,erc20Address:n,registryAddress:i}))}function Hr(e,t){return K({...F(G().signer,e),...t})}function Ur(e){return q(F(G().signer,e))}function Wr(e,t){return B({...qt(J(e)),...t,onSuccess:(e,n,r,i)=>{try{t?.onSuccess?.(e,n,r,i)}finally{i.client.invalidateQueries({queryKey:z.delegationStatus.all})}}})}function Gr(e,t){return B({...Dn(J(e)),...t,onSuccess:(e,n,r,i)=>{try{t?.onSuccess?.(e,n,r,i)}finally{i.client.invalidateQueries({queryKey:z.delegationStatus.all})}}})}function Kr(e,t){let n=Zt(G(),e);return K({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function qr(e,t){return B({...Gt(Y(e)),...t})}function Jr(e,t){return B({...Dt(e),...t})}function Yr(e,t){return B({...Tt(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),cn(a.client,e.tokenAddress)}})}function Xr(e,t){return K({...j(G().signer,e),...t})}function Zr(e){return q(j(G().signer,e))}function Qr(e,t){return K({...N(G().signer,e),...t})}function $r(e){return q(N(G().signer,e))}function ei(e,t){return K({...I(G().signer,e),...t})}function ti(e){return q(I(G().signer,e))}function ni(){let e=G(),t=$();return K(zn(e.signer,{registryAddress:t}))}function ri(){let e=G(),t=$();return K(Rn(e.signer,{registryAddress:t}))}function ii({fromIndex:e,toIndex:t}){let n=G(),r=$();return K(Bn(n.signer,{registryAddress:r,fromIndex:e,toIndex:t}))}function ai({index:e}){let t=G(),n=$();return K(Ln(t.signer,{registryAddress:n,index:e}))}function oi({tokenAddress:e}){let t=G(),n=$();return K(Ft(t.signer,{registryAddress:n,tokenAddress:e}))}function si({confidentialTokenAddress:e}){let t=G(),n=$();return K(Fn(t.signer,{registryAddress:n,confidentialTokenAddress:e}))}function ci({confidentialTokenAddress:e}){let t=G(),n=$();return K(M(t.signer,{registryAddress:n,confidentialTokenAddress:e}))}function li({page:e=1,pageSize:t=100,metadata:n=!1}={}){let r=G(),i=$();return K(hn(r.registry,{registryAddress:i,page:e,pageSize:t,metadata:n}))}export{e as ACL_TOPICS,t as AclPausedError,n as ApprovalFailedError,r as BalanceCheckUnavailableError,i as ChromeSessionStorage,a as ConfigurationError,o as CredentialsManager,s as DecryptionFailedError,c as DefaultRegistryAddresses,l as DelegatedCredentialsManager,u as DelegationContractIsSelfError,d as DelegationCooldownError,f as DelegationDelegateEqualsContractError,p as DelegationExpirationTooSoonError,ee as DelegationExpiredError,te as DelegationExpiryUnchangedError,ne as DelegationNotFoundError,re as DelegationNotPropagatedError,ie as DelegationSelfNotAllowedError,ae as ERC20ReadFailedError,oe as ERC7984_INTERFACE_ID,se as ERC7984_WRAPPER_INTERFACE_ID,ce as ERC7984_WRAPPER_INTERFACE_ID_LEGACY,le as EncryptionFailedError,ue as HardhatConfig,de as IndexedDBStorage,fe as InsufficientConfidentialBalanceError,pe as InsufficientERC20BalanceError,me as InvalidKeypairError,he as KeypairExpiredError,ge as MainnetConfig,_e as MemoryStorage,ve as NoCiphertextError,ye as ReadonlyToken,be as RelayerRequestFailedError,xe as RelayerWeb,Se as SepoliaConfig,Ce as SigningFailedError,we as SigningRejectedError,Te as TOKEN_TOPICS,Ee as Token,De as Topics,Oe as TransactionRevertedError,ke as WrappersRegistry,m as ZERO_HANDLE,h as ZamaError,g as ZamaErrorCode,cr as ZamaProvider,_ as ZamaSDK,y as ZamaSDKEvents,St as allowMutationOptions,b as allowanceContract,x as approveContract,wt as approveUnderlyingMutationOptions,S as balanceOfContract,Et as batchDecryptBalancesAsMutationOptions,C as chromeSessionStorage,w as clearPendingUnshield,Ot as confidentialApproveMutationOptions,Ae as confidentialBalanceOfContract,At as confidentialBalanceQueryOptions,Mt as confidentialBalancesQueryOptions,Pt as confidentialIsApprovedQueryOptions,je as confidentialTotalSupplyContract,Me as confidentialTransferContract,Ne as confidentialTransferFromContract,It as confidentialTransferFromMutationOptions,Rt as confidentialTransferMutationOptions,Bt as createDelegatedUserDecryptEIP712MutationOptions,Ht as createEIP712MutationOptions,Pe as decimalsContract,Fe as decodeAclEvent,Ie as decodeAclEvents,Le as decodeConfidentialTransfer,Re as decodeDelegatedForUserDecryption,ze as decodeOnChainEvent,Be as decodeOnChainEvents,Ve as decodeRevokedDelegationForUserDecryption,He as decodeUnwrapRequested,Ue as decodeUnwrappedFinalized,We as decodeUnwrappedStarted,Ge as decodeWrapped,Wt as decryptBalanceAsMutationOptions,Kt as delegateDecryptionMutationOptions,Ke as delegateForUserDecryptionContract,Jt as delegatedUserDecryptMutationOptions,Xt as delegationStatusQueryOptions,Qt as encryptMutationOptions,en as filterQueryOptions,qe as finalizeUnwrapContract,tn as finalizeUnwrapMutationOptions,Je as findDelegatedForUserDecryption,Ye as findRevokedDelegationForUserDecryption,Xe as findUnwrapRequested,Ze as findWrapped,rn as generateKeypairMutationOptions,Qe as getDelegationExpiryContract,on as hashFn,$e as indexedDBStorage,et as inferredTotalSupplyContract,un as isAllowedQueryOptions,fn as isConfidentialQueryOptions,tt as isConfidentialTokenContract,nt as isConfidentialWrapperContract,rt as isHandleDelegatedContract,it as isOperatorContract,pn as isWrapperQueryOptions,at as isZeroHandle,mn as listPairsQueryOptions,ot as loadPendingUnshield,st as matchAclRevert,ct as matchZamaError,lt as memoryStorage,ut as nameContract,gn as publicDecryptMutationOptions,vn as publicKeyQueryOptions,bn as publicParamsQueryOptions,dt as rateContract,Sn as requestZKProofVerificationMutationOptions,wn as resumeUnshieldMutationOptions,ft as revokeDelegationContract,En as revokeDelegationMutationOptions,On as revokeMutationOptions,An as revokeSessionMutationOptions,pt as savePendingUnshield,mt as setOperatorContract,Mn as shieldMutationOptions,Pn as signerAddressQueryOptions,ht as supportsInterfaceContract,gt as symbolContract,In as tokenMetadataQueryOptions,_t as totalSupplyContract,Vn as totalSupplyQueryOptions,Hn as underlyingAllowanceQueryOptions,vt as underlyingContract,Un as unshieldAllMutationOptions,Gn as unshieldMutationOptions,qn as unwrapAllMutationOptions,yt as unwrapContract,bt as unwrapFromBalanceContract,Yn as unwrapMutationOptions,yr as useAllow,Yr as useApproveUnderlying,Jr as useBatchDecryptBalancesAs,Or as useConfidentialApprove,Cr as useConfidentialBalance,wr as useConfidentialBalances,kr as useConfidentialIsApproved,Ar as useConfidentialIsApprovedSuspense,oi as useConfidentialTokenAddress,Er as useConfidentialTransfer,Dr as useConfidentialTransferFrom,mr as useCreateDelegatedUserDecryptEIP712,pr as useCreateEIP712,qr as useDecryptBalanceAs,Wr as useDelegateDecryption,hr as useDelegatedUserDecrypt,Kr as useDelegationStatus,lr as useEncrypt,Pr as useFinalizeUnwrap,fr as useGenerateKeypair,br as useIsAllowed,Xr as useIsConfidential,Zr as useIsConfidentialSuspense,ci as useIsConfidentialTokenValid,Qr as useIsWrapper,$r as useIsWrapperSuspense,li as useListPairs,Hr as useMetadata,Ur as useMetadataSuspense,dr as usePublicDecrypt,_r as usePublicKey,vr as usePublicParams,Y as useReadonlyToken,gr as useRequestZKProofVerification,Lr as useResumeUnshield,xr as useRevoke,Gr as useRevokeDelegation,Sr as useRevokeSession,jr as useShield,J as useToken,si as useTokenAddress,ai as useTokenPair,ri as useTokenPairsLength,ni as useTokenPairsRegistry,ii as useTokenPairsSlice,ei as useTotalSupply,ti as useTotalSupplySuspense,Rr as useUnderlyingAllowance,zr as useUnderlyingAllowanceSuspense,Fr as useUnshield,Ir as useUnshieldAll,Mr as useUnwrap,Nr as useUnwrapAll,ur as useUserDecrypt,Br as useWrapperDiscovery,Vr as useWrapperDiscoverySuspense,$ as useWrappersRegistryAddress,G as useZamaSDK,Zn as userDecryptQueryOptions,xt as wrapContract,$n as wrapperDiscoveryQueryOptions,er as zamaQueryKeys};
1
+ "use client";import{ACL_TOPICS as e,AclPausedError as t,ApprovalFailedError as n,BalanceCheckUnavailableError as r,ChromeSessionStorage as i,ConfigurationError as a,CredentialsManager as o,DecryptionFailedError as s,DefaultRegistryAddresses as c,DelegatedCredentialsManager as l,DelegationContractIsSelfError as u,DelegationCooldownError as d,DelegationDelegateEqualsContractError as f,DelegationExpirationTooSoonError as p,DelegationExpiredError as ee,DelegationExpiryUnchangedError as te,DelegationNotFoundError as ne,DelegationNotPropagatedError as re,DelegationSelfNotAllowedError as ie,ERC20ReadFailedError as ae,ERC7984_INTERFACE_ID as oe,ERC7984_WRAPPER_INTERFACE_ID as se,EncryptionFailedError as ce,HardhatConfig as le,IndexedDBStorage as ue,InsufficientConfidentialBalanceError as de,InsufficientERC20BalanceError as fe,InvalidKeypairError as pe,KeypairExpiredError as me,MainnetConfig as he,MemoryStorage as ge,NoCiphertextError as _e,ReadonlyToken as ve,RelayerRequestFailedError as ye,RelayerWeb as be,SepoliaConfig as xe,SigningFailedError as Se,SigningRejectedError as Ce,TOKEN_TOPICS as we,Token as Te,Topics as Ee,TransactionRevertedError as De,WrappersRegistry as Oe,ZERO_HANDLE as ke,ZamaError as m,ZamaErrorCode as h,ZamaSDK as g,ZamaSDK as _,ZamaSDKEvents as v,allowanceContract as y,applyDecryptedValues as b,approveContract as x,balanceOfContract as S,chromeSessionStorage as C,clearPendingUnshield as w,confidentialBalanceOfContract as Ae,confidentialTotalSupplyContract as je,confidentialTransferContract as Me,confidentialTransferFromContract as Ne,decimalsContract as Pe,decodeAclEvent as Fe,decodeAclEvents as Ie,decodeConfidentialTransfer as Le,decodeDelegatedForUserDecryption as Re,decodeOnChainEvent as ze,decodeOnChainEvents as Be,decodeRevokedDelegationForUserDecryption as Ve,decodeUnwrapRequested as He,decodeUnwrappedFinalized as Ue,decodeUnwrappedStarted as We,decodeWrapped as Ge,delegateForUserDecryptionContract as Ke,extractEncryptedHandles as qe,finalizeUnwrapContract as Je,findDelegatedForUserDecryption as Ye,findRevokedDelegationForUserDecryption as Xe,findUnwrapRequested as Ze,findWrapped as Qe,getDelegationExpiryContract as $e,indexedDBStorage as et,inferredTotalSupplyContract as tt,isConfidentialTokenContract as nt,isConfidentialWrapperContract as rt,isHandleDelegatedContract as it,isOperatorContract as at,isZeroHandle as ot,loadPendingUnshield as st,matchAclRevert as ct,matchZamaError as lt,memoryStorage as ut,nameContract as dt,parseActivityFeed as ft,rateContract as pt,revokeDelegationContract as mt,savePendingUnshield as ht,setOperatorContract as gt,sortByBlockNumber as _t,supportsInterfaceContract as vt,symbolContract as yt,totalSupplyContract as bt,underlyingContract as xt,unwrapContract as St,unwrapFromBalanceContract as Ct,wrapContract as wt}from"@zama-fhe/sdk";import{activityFeedQueryOptions as Tt,activityFeedQueryOptions as Et,allowMutationOptions as Dt,allowMutationOptions as Ot,approveUnderlyingMutationOptions as kt,approveUnderlyingMutationOptions as At,batchDecryptBalancesAsMutationOptions as jt,batchDecryptBalancesAsMutationOptions as Mt,confidentialApproveMutationOptions as Nt,confidentialApproveMutationOptions as Pt,confidentialBalanceQueryOptions as Ft,confidentialBalanceQueryOptions as It,confidentialBalancesQueryOptions as Lt,confidentialBalancesQueryOptions as Rt,confidentialIsApprovedQueryOptions as zt,confidentialIsApprovedQueryOptions as T,confidentialTokenAddressQueryOptions as Bt,confidentialTransferFromMutationOptions as Vt,confidentialTransferFromMutationOptions as Ht,confidentialTransferMutationOptions as Ut,confidentialTransferMutationOptions as Wt,createDelegatedUserDecryptEIP712MutationOptions as Gt,createDelegatedUserDecryptEIP712MutationOptions as Kt,createEIP712MutationOptions as qt,createEIP712MutationOptions as Jt,decryptBalanceAsMutationOptions as Yt,decryptBalanceAsMutationOptions as Xt,delegateDecryptionMutationOptions as Zt,delegateDecryptionMutationOptions as Qt,delegatedUserDecryptMutationOptions as $t,delegatedUserDecryptMutationOptions as en,delegationStatusQueryOptions as tn,delegationStatusQueryOptions as nn,deriveActivityFeedLogsKey as rn,encryptMutationOptions as an,encryptMutationOptions as on,filterQueryOptions as sn,finalizeUnwrapMutationOptions as cn,finalizeUnwrapMutationOptions as ln,generateKeypairMutationOptions as un,generateKeypairMutationOptions as dn,hashFn as fn,hashFn as E,invalidateAfterApprove as pn,invalidateAfterApproveUnderlying as mn,invalidateAfterShield as hn,invalidateAfterTransfer as D,invalidateAfterUnshield as O,invalidateAfterUnwrap as k,invalidateWalletLifecycleQueries as A,isAllowedQueryOptions as gn,isAllowedQueryOptions as _n,isConfidentialQueryOptions as j,isConfidentialQueryOptions as M,isConfidentialTokenValidQueryOptions as vn,isWrapperQueryOptions as yn,isWrapperQueryOptions as N,listPairsQueryOptions as bn,listPairsQueryOptions as xn,publicDecryptMutationOptions as Sn,publicDecryptMutationOptions as Cn,publicKeyQueryOptions as wn,publicKeyQueryOptions as Tn,publicParamsQueryOptions as En,publicParamsQueryOptions as Dn,requestZKProofVerificationMutationOptions as On,requestZKProofVerificationMutationOptions as kn,resumeUnshieldMutationOptions as An,resumeUnshieldMutationOptions as jn,revokeDelegationMutationOptions as Mn,revokeDelegationMutationOptions as Nn,revokeMutationOptions as Pn,revokeMutationOptions as Fn,revokeSessionMutationOptions as In,revokeSessionMutationOptions as Ln,shieldMutationOptions as Rn,shieldMutationOptions as zn,signerAddressQueryOptions as Bn,signerAddressQueryOptions as P,tokenAddressQueryOptions as Vn,tokenMetadataQueryOptions as Hn,tokenMetadataQueryOptions as F,tokenPairQueryOptions as Un,tokenPairsLengthQueryOptions as Wn,tokenPairsQueryOptions as Gn,tokenPairsSliceQueryOptions as Kn,totalSupplyQueryOptions as qn,totalSupplyQueryOptions as I,underlyingAllowanceQueryOptions as Jn,underlyingAllowanceQueryOptions as L,unshieldAllMutationOptions as Yn,unshieldAllMutationOptions as Xn,unshieldMutationOptions as Zn,unshieldMutationOptions as Qn,unwrapAllMutationOptions as $n,unwrapAllMutationOptions as er,unwrapMutationOptions as tr,unwrapMutationOptions as nr,userDecryptQueryOptions as rr,userDecryptQueryOptions as ir,wrapperDiscoveryQueryOptions as ar,wrapperDiscoveryQueryOptions as R,zamaQueryKeys as or,zamaQueryKeys as z}from"@zama-fhe/sdk/query";import{skipToken as sr,useMutation as B,useQuery as cr,useQueryClient as V,useSuspenseQuery as lr}from"@tanstack/react-query";import{createContext as ur,useContext as dr,useEffect as H,useMemo as U,useRef as fr}from"react";import{jsx as pr}from"react/jsx-runtime";const W=ur(null);function mr({children:e,relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,registryAddresses:s,registryTTL:c,onEvent:l}){let u=V(),d=fr(l);H(()=>{d.current=l});let f=U(()=>n?.subscribe?{onDisconnect:()=>A(u),onAccountChange:()=>A(u),onChainChange:()=>A(u)}:void 0,[u,n]),p=U(()=>new _({relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,registryAddresses:s,registryTTL:c,onEvent:d.current,signerLifecycleCallbacks:f}),[t,n,r,i,a,o,s,c,f]);return H(()=>()=>p.dispose(),[p]),pr(W.Provider,{value:p,children:e})}function G(){let e=dr(W);if(!e)throw Error(`useZamaSDK must be used within a <ZamaProvider>. Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.`);return e}function hr(){return B(on(G()))}function K(e){return cr({...e,queryKeyHashFn:E})}function q(e){return lr({...e,queryKeyHashFn:E})}function gr(e,t){let n=ir(G(),e);return K({...n,...t,enabled:n.enabled&&(t?.enabled??!1)})}function _r(){return B(Cn(G()))}function vr(){return B(dn(G()))}function yr(){return B(Jt(G()))}function br(){return B(Kt(G()))}function xr(){return B(en(G()))}function Sr(){return B(kn(G()))}function Cr(){return K(Tn(G()))}function wr(e){return K(Dn(G(),e))}function Tr(e){return B({...Ot(G()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:z.isAllowed.all})}})}function Er(e){let t=G(),n=K({...P(t.signer)}).data;return K(n?_n(t,{account:n,contractAddresses:e.contractAddresses}):{queryKey:z.isAllowed.all,queryFn:sr,enabled:!1})}function Dr(e){return B({...Fn(G()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.removeQueries({queryKey:z.isAllowed.all}),i.client.removeQueries({queryKey:z.decryption.all})}})}function Or(e){return B({...Ln(G()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.removeQueries({queryKey:z.isAllowed.all}),i.client.removeQueries({queryKey:z.decryption.all})}})}function J(e){let t=G();return U(()=>t.createToken(e.tokenAddress,e.wrapperAddress),[t,e.tokenAddress,e.wrapperAddress])}function Y(e){let t=G();return U(()=>t.createReadonlyToken(e),[t,e])}function kr(e,t){let{tokenAddress:n}=e,{enabled:r=!0}=t??{},i=G(),a=Y(n),o=K(P(i.signer)).data,s=It(a,{tokenAddress:n,owner:o});return K({...s,...t,enabled:s.enabled&&r})}function Ar(e,t){let{tokenAddresses:n}=e,{enabled:r=!0}=t??{},i=G(),a=K(P(i.signer)).data,o=Rt(U(()=>n.map(e=>i.createReadonlyToken(e)),[i,n]),{owner:a});return K({...o,...t,enabled:(o.enabled??!0)&&r})}function X(e,t){let n=e?t:void 0;return{wrappedContext:n,callerContext:e?n?.callerContext:t}}async function Z({queryClient:e,tokenAddress:t,amount:n,mode:r}){let i=z.confidentialBalance.token(t);await e.cancelQueries({queryKey:i});let a=e.getQueriesData({queryKey:i});for(let[t,i]of a)i!==void 0&&e.setQueryData(t,r===`add`?i+n:i-n);return a}function Q(e,t){for(let[n,r]of t)e.setQueryData(n,r)}function jr({optimistic:e,tokenAddress:t,queryClient:n,options:r}){return{onMutate:e?async(e,i)=>({snapshot:await Z({queryClient:n,tokenAddress:t,amount:e.amount,mode:`add`}),callerContext:await r?.onMutate?.(e,i)}):r?.onMutate,onError:(t,i,a,o)=>{let{wrappedContext:s,callerContext:c}=X(e,a);try{s&&Q(n,s.snapshot)}finally{r?.onError?.(t,i,c,o)}},onSuccess:(n,i,a,o)=>{let{callerContext:s}=X(e,a);r?.onSuccess?.(n,i,s,o),hn(o.client,t)},onSettled:(t,n,i,a,o)=>{let{callerContext:s}=X(e,a);r?.onSettled?.(t,n,i,s,o)}}}function Mr(e,t){let n=J(e),r=V();return B({...Wt(n),...t,onMutate:e.optimistic?async(n,i)=>({snapshot:await Z({queryClient:r,tokenAddress:e.tokenAddress,amount:n.amount,mode:`subtract`}),callerContext:await t?.onMutate?.(n,i)}):t?.onMutate,onError:(n,i,a,o)=>{let{wrappedContext:s,callerContext:c}=X(e.optimistic,a);try{s&&Q(r,s.snapshot)}finally{t?.onError?.(n,i,c,o)}},onSuccess:(n,r,i,a)=>{let{callerContext:o}=X(e.optimistic,i);t?.onSuccess?.(n,r,o,a),D(a.client,e.tokenAddress)},onSettled:(n,r,i,a,o)=>{let{callerContext:s}=X(e.optimistic,a);t?.onSettled?.(n,r,i,s,o)}})}function Nr(e,t){return B({...Ht(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function Pr(e,t){return B({...Pt(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),pn(a.client,e.tokenAddress)}})}function Fr(e,t){let{tokenAddress:n,spender:r,holder:i}=e,a=G(),o=K({...P(a.signer),enabled:n!==void 0&&r!==void 0&&i===void 0}),s=i??o.data,c=T(a.signer,n,{holder:s,spender:r});return K({...c,...t,enabled:(c.enabled??!0)&&(t?.enabled??!0)})}function Ir(e){let{spender:t,holder:n,...r}=e,i=G(),a=J(r),o=q(P(i.signer)),s=n??o.data;return q(T(i.signer,a.address,{holder:s,spender:t}))}function Lr(e,t){let n=J(e),r=V();return B({...zn(n),...t,...jr({optimistic:e.optimistic,tokenAddress:e.tokenAddress,queryClient:r,options:t})})}function Rr(e,t){return B({...nr(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),k(a.client,e.tokenAddress)}})}function zr(e,t){return B({...er(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),k(a.client,e.tokenAddress)}})}function Br(e,t){return B({...ln(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),O(a.client,e.tokenAddress)}})}function Vr(e,t){return B({...Qn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),O(a.client,e.tokenAddress)}})}function Hr(e,t){return B({...Xn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),O(a.client,e.tokenAddress)}})}function Ur(e,t){return B({...jn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),O(a.client,e.tokenAddress)}})}function Wr(e,t){let{tokenAddress:n,wrapperAddress:r}=e,i=G(),a=K(P(i.signer)).data,o=L(i.signer,n,{owner:a,wrapperAddress:r});return K({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function Gr(e){let{tokenAddress:t,wrapperAddress:n}=e,r=G(),i=q(P(r.signer)).data;return q(L(r.signer,t,{owner:i,wrapperAddress:n}))}function $(){let e=G(),{data:t}=K({queryKey:z.wrappersRegistry.chainId(),queryFn:()=>e.signer.getChainId(),staleTime:3e4});return t===void 0?void 0:e.registry.getAddress(t)}function Kr(e,t){let{tokenAddress:n,erc20Address:r}=e,i=G(),a=$(),o=R(i.registry,{tokenAddress:n,erc20Address:r,registryAddress:a});return K({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function qr(e){let{tokenAddress:t,erc20Address:n}=e,r=G(),i=$();return q(R(r.registry,{tokenAddress:t,erc20Address:n,registryAddress:i}))}function Jr(e,t){return K({...F(G().signer,e),...t})}function Yr(e){return q(F(G().signer,e))}function Xr(e){let{tokenAddress:t,userAddress:n,logs:r,decrypt:i}=e;return K(Et(Y(t),{userAddress:n,logs:r,decrypt:i??!0,logsKey:rn(r)}))}function Zr(e,t){return B({...Qt(J(e)),...t,onSuccess:(e,n,r,i)=>{try{t?.onSuccess?.(e,n,r,i)}finally{i.client.invalidateQueries({queryKey:z.delegationStatus.all})}}})}function Qr(e,t){return B({...Nn(J(e)),...t,onSuccess:(e,n,r,i)=>{try{t?.onSuccess?.(e,n,r,i)}finally{i.client.invalidateQueries({queryKey:z.delegationStatus.all})}}})}function $r(e,t){let n=nn(G(),e);return K({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function ei(e,t){return B({...Xt(Y(e)),...t})}function ti(e,t){return B({...Mt(e),...t})}function ni(e,t){return B({...At(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),mn(a.client,e.tokenAddress)}})}function ri(e,t){return K({...M(G().signer,e),...t})}function ii(e){return q(M(G().signer,e))}function ai(e,t){return K({...N(G().signer,e),...t})}function oi(e){return q(N(G().signer,e))}function si(e,t){return K({...I(G().signer,e),...t})}function ci(e){return q(I(G().signer,e))}function li(){let e=G(),t=$();return K(Gn(e.signer,{registryAddress:t}))}function ui(){let e=G(),t=$();return K(Wn(e.signer,{registryAddress:t}))}function di({fromIndex:e,toIndex:t}){let n=G(),r=$();return K(Kn(n.signer,{registryAddress:r,fromIndex:e,toIndex:t}))}function fi({index:e}){let t=G(),n=$();return K(Un(t.signer,{registryAddress:n,index:e}))}function pi({tokenAddress:e}){let t=G(),n=$();return K(Bt(t.signer,{registryAddress:n,tokenAddress:e}))}function mi({confidentialTokenAddress:e}){let t=G(),n=$();return K(Vn(t.signer,{registryAddress:n,confidentialTokenAddress:e}))}function hi({confidentialTokenAddress:e}){let t=G(),n=$();return K(vn(t.signer,{registryAddress:n,confidentialTokenAddress:e}))}function gi({page:e=1,pageSize:t=100,metadata:n=!1}={}){let r=G(),i=$();return K(xn(r.registry,{registryAddress:i,page:e,pageSize:t,metadata:n}))}export{e as ACL_TOPICS,t as AclPausedError,n as ApprovalFailedError,r as BalanceCheckUnavailableError,i as ChromeSessionStorage,a as ConfigurationError,o as CredentialsManager,s as DecryptionFailedError,c as DefaultRegistryAddresses,l as DelegatedCredentialsManager,u as DelegationContractIsSelfError,d as DelegationCooldownError,f as DelegationDelegateEqualsContractError,p as DelegationExpirationTooSoonError,ee as DelegationExpiredError,te as DelegationExpiryUnchangedError,ne as DelegationNotFoundError,re as DelegationNotPropagatedError,ie as DelegationSelfNotAllowedError,ae as ERC20ReadFailedError,oe as ERC7984_INTERFACE_ID,se as ERC7984_WRAPPER_INTERFACE_ID,ce as EncryptionFailedError,le as HardhatConfig,ue as IndexedDBStorage,de as InsufficientConfidentialBalanceError,fe as InsufficientERC20BalanceError,pe as InvalidKeypairError,me as KeypairExpiredError,he as MainnetConfig,ge as MemoryStorage,_e as NoCiphertextError,ve as ReadonlyToken,ye as RelayerRequestFailedError,be as RelayerWeb,xe as SepoliaConfig,Se as SigningFailedError,Ce as SigningRejectedError,we as TOKEN_TOPICS,Te as Token,Ee as Topics,De as TransactionRevertedError,Oe as WrappersRegistry,ke as ZERO_HANDLE,m as ZamaError,h as ZamaErrorCode,mr as ZamaProvider,g as ZamaSDK,v as ZamaSDKEvents,Tt as activityFeedQueryOptions,Dt as allowMutationOptions,y as allowanceContract,b as applyDecryptedValues,x as approveContract,kt as approveUnderlyingMutationOptions,S as balanceOfContract,jt as batchDecryptBalancesAsMutationOptions,C as chromeSessionStorage,w as clearPendingUnshield,Nt as confidentialApproveMutationOptions,Ae as confidentialBalanceOfContract,Ft as confidentialBalanceQueryOptions,Lt as confidentialBalancesQueryOptions,zt as confidentialIsApprovedQueryOptions,je as confidentialTotalSupplyContract,Me as confidentialTransferContract,Ne as confidentialTransferFromContract,Vt as confidentialTransferFromMutationOptions,Ut as confidentialTransferMutationOptions,Gt as createDelegatedUserDecryptEIP712MutationOptions,qt as createEIP712MutationOptions,Pe as decimalsContract,Fe as decodeAclEvent,Ie as decodeAclEvents,Le as decodeConfidentialTransfer,Re as decodeDelegatedForUserDecryption,ze as decodeOnChainEvent,Be as decodeOnChainEvents,Ve as decodeRevokedDelegationForUserDecryption,He as decodeUnwrapRequested,Ue as decodeUnwrappedFinalized,We as decodeUnwrappedStarted,Ge as decodeWrapped,Yt as decryptBalanceAsMutationOptions,Zt as delegateDecryptionMutationOptions,Ke as delegateForUserDecryptionContract,$t as delegatedUserDecryptMutationOptions,tn as delegationStatusQueryOptions,an as encryptMutationOptions,qe as extractEncryptedHandles,sn as filterQueryOptions,Je as finalizeUnwrapContract,cn as finalizeUnwrapMutationOptions,Ye as findDelegatedForUserDecryption,Xe as findRevokedDelegationForUserDecryption,Ze as findUnwrapRequested,Qe as findWrapped,un as generateKeypairMutationOptions,$e as getDelegationExpiryContract,fn as hashFn,et as indexedDBStorage,tt as inferredTotalSupplyContract,gn as isAllowedQueryOptions,j as isConfidentialQueryOptions,nt as isConfidentialTokenContract,rt as isConfidentialWrapperContract,it as isHandleDelegatedContract,at as isOperatorContract,yn as isWrapperQueryOptions,ot as isZeroHandle,bn as listPairsQueryOptions,st as loadPendingUnshield,ct as matchAclRevert,lt as matchZamaError,ut as memoryStorage,dt as nameContract,ft as parseActivityFeed,Sn as publicDecryptMutationOptions,wn as publicKeyQueryOptions,En as publicParamsQueryOptions,pt as rateContract,On as requestZKProofVerificationMutationOptions,An as resumeUnshieldMutationOptions,mt as revokeDelegationContract,Mn as revokeDelegationMutationOptions,Pn as revokeMutationOptions,In as revokeSessionMutationOptions,ht as savePendingUnshield,gt as setOperatorContract,Rn as shieldMutationOptions,Bn as signerAddressQueryOptions,_t as sortByBlockNumber,vt as supportsInterfaceContract,yt as symbolContract,Hn as tokenMetadataQueryOptions,bt as totalSupplyContract,qn as totalSupplyQueryOptions,Jn as underlyingAllowanceQueryOptions,xt as underlyingContract,Yn as unshieldAllMutationOptions,Zn as unshieldMutationOptions,$n as unwrapAllMutationOptions,St as unwrapContract,Ct as unwrapFromBalanceContract,tr as unwrapMutationOptions,Xr as useActivityFeed,Tr as useAllow,ni as useApproveUnderlying,ti as useBatchDecryptBalancesAs,Pr as useConfidentialApprove,kr as useConfidentialBalance,Ar as useConfidentialBalances,Fr as useConfidentialIsApproved,Ir as useConfidentialIsApprovedSuspense,pi as useConfidentialTokenAddress,Mr as useConfidentialTransfer,Nr as useConfidentialTransferFrom,br as useCreateDelegatedUserDecryptEIP712,yr as useCreateEIP712,ei as useDecryptBalanceAs,Zr as useDelegateDecryption,xr as useDelegatedUserDecrypt,$r as useDelegationStatus,hr as useEncrypt,Br as useFinalizeUnwrap,vr as useGenerateKeypair,Er as useIsAllowed,ri as useIsConfidential,ii as useIsConfidentialSuspense,hi as useIsConfidentialTokenValid,ai as useIsWrapper,oi as useIsWrapperSuspense,gi as useListPairs,Jr as useMetadata,Yr as useMetadataSuspense,_r as usePublicDecrypt,Cr as usePublicKey,wr as usePublicParams,Y as useReadonlyToken,Sr as useRequestZKProofVerification,Ur as useResumeUnshield,Dr as useRevoke,Qr as useRevokeDelegation,Or as useRevokeSession,Lr as useShield,J as useToken,mi as useTokenAddress,fi as useTokenPair,ui as useTokenPairsLength,li as useTokenPairsRegistry,di as useTokenPairsSlice,si as useTotalSupply,ci as useTotalSupplySuspense,Wr as useUnderlyingAllowance,Gr as useUnderlyingAllowanceSuspense,Vr as useUnshield,Hr as useUnshieldAll,Rr as useUnwrap,zr as useUnwrapAll,gr as useUserDecrypt,Kr as useWrapperDiscovery,qr as useWrapperDiscoverySuspense,$ as useWrappersRegistryAddress,G as useZamaSDK,rr as userDecryptQueryOptions,wt as wrapContract,ar as wrapperDiscoveryQueryOptions,or as zamaQueryKeys};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ZamaSDK","encryptMutationOptions","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","userDecryptQueryOptions","useQuery","publicDecryptMutationOptions","generateKeypairMutationOptions","createEIP712MutationOptions","createDelegatedUserDecryptEIP712MutationOptions","delegatedUserDecryptMutationOptions","requestZKProofVerificationMutationOptions","useQuery","publicKeyQueryOptions","useQuery","publicParamsQueryOptions","allowMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","isAllowedQueryOptions","zamaQueryKeys","revokeMutationOptions","zamaQueryKeys","revokeSessionMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","confidentialBalanceQueryOptions","useQuery","signerAddressQueryOptions","confidentialBalancesQueryOptions","zamaQueryKeys","confidentialTransferMutationOptions","confidentialTransferFromMutationOptions","confidentialApproveMutationOptions","useQuery","signerAddressQueryOptions","confidentialIsApprovedQueryOptions","useSuspenseQuery","shieldMutationOptions","unwrapMutationOptions","unwrapAllMutationOptions","finalizeUnwrapMutationOptions","unshieldMutationOptions","unshieldAllMutationOptions","resumeUnshieldMutationOptions","useQuery","signerAddressQueryOptions","underlyingAllowanceQueryOptions","useSuspenseQuery","useQuery","zamaQueryKeys","wrapperDiscoveryQueryOptions","useQuery","useSuspenseQuery","useQuery","tokenMetadataQueryOptions","useSuspenseQuery","delegateDecryptionMutationOptions","zamaQueryKeys","revokeDelegationMutationOptions","zamaQueryKeys","delegationStatusQueryOptions","useQuery","decryptBalanceAsMutationOptions","batchDecryptBalancesAsMutationOptions","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","listPairsQueryOptions"],"sources":["../src/provider.tsx","../src/relayer/use-encrypt.ts","../src/utils/query.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/authorization/use-allow.ts","../src/authorization/use-is-allowed.ts","../src/authorization/use-revoke.ts","../src/authorization/use-revoke-session.ts","../src/token/use-token.ts","../src/token/use-readonly-token.ts","../src/balance/use-confidential-balance.ts","../src/balance/use-confidential-balances.ts","../src/balance/optimistic-balance-update.ts","../src/transfer/use-confidential-transfer.ts","../src/transfer/use-confidential-transfer-from.ts","../src/transfer/use-confidential-approve.ts","../src/transfer/use-confidential-is-approved.ts","../src/shield/use-shield.ts","../src/unwrap/use-unwrap.ts","../src/unwrap/use-unwrap-all.ts","../src/unwrap/use-finalize-unwrap.ts","../src/unshield/use-unshield.ts","../src/unshield/use-unshield-all.ts","../src/unshield/use-resume-unshield.ts","../src/shield/use-underlying-allowance.ts","../src/wrappers-registry/use-wrappers-registry-address.ts","../src/token/use-wrapper-discovery.ts","../src/token/use-metadata.ts","../src/delegation/use-delegate-decryption.ts","../src/delegation/use-revoke-delegation.ts","../src/delegation/use-delegation-status.ts","../src/delegation/use-decrypt-balance-as.ts","../src/delegation/use-batch-decrypt-balances-as.ts","../src/shield/use-approve-underlying.ts","../src/token/use-is-confidential.ts","../src/token/use-total-supply.ts","../src/wrappers-registry/use-token-pairs-registry.ts","../src/wrappers-registry/use-token-pairs-length.ts","../src/wrappers-registry/use-token-pairs-slice.ts","../src/wrappers-registry/use-token-pair.ts","../src/wrappers-registry/use-confidential-token-address.ts","../src/wrappers-registry/use-token-address.ts","../src/wrappers-registry/use-is-confidential-token-valid.ts","../src/wrappers-registry/use-list-pairs.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n Address,\n GenericSigner,\n GenericStorage,\n RelayerSDK,\n ZamaSDKEventListener,\n} from \"@zama-fhe/sdk\";\nimport { ZamaSDK } from \"@zama-fhe/sdk\";\nimport { invalidateWalletLifecycleQueries } from \"@zama-fhe/sdk/query\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\n/** Props for {@link ZamaProvider}. */\nexport interface ZamaProviderProps extends PropsWithChildren {\n /** FHE relayer backend (RelayerWeb for browser, RelayerNode for server). */\n relayer: RelayerSDK;\n /** Wallet signer (`ViemSigner`, `EthersSigner`, or custom {@link GenericSigner}). */\n signer: GenericSigner;\n /** Credential storage backend (IndexedDBStorage for browser, MemoryStorage for tests). */\n storage: GenericStorage;\n /**\n * Session storage for wallet signatures. Defaults to in-memory (lost on reload).\n * Pass a `chrome.storage.session`-backed store for web extensions.\n */\n sessionStorage?: GenericStorage;\n /**\n * How long the ML-KEM re-encryption keypair remains valid, in seconds.\n * Default: `86400` (1 day). Must be positive — `0` is rejected.\n */\n keypairTTL?: number;\n /**\n * Controls how long session signatures (EIP-712 wallet signatures) remain valid, in seconds.\n * Default: `2592000` (30 days).\n * - `0`: never persist — every operation triggers a signing prompt (high-security mode).\n * - Positive number: seconds until the session signature expires and requires re-authentication.\n */\n sessionTTL?: number;\n /**\n * Per-chain wrappers registry address overrides, merged on top of built-in defaults.\n * Use this for custom or local chains (e.g. Hardhat) where no default registry exists.\n */\n registryAddresses?: Record<number, Address>;\n /**\n * How long cached registry results remain valid, in seconds.\n * Default: `86400` (24 hours).\n */\n registryTTL?: number;\n /** Callback invoked on SDK lifecycle events. */\n onEvent?: ZamaSDKEventListener;\n}\n\nconst ZamaSDKContext = createContext<ZamaSDK | null>(null);\n\n/**\n * Provides a {@link ZamaSDK} instance to all descendant hooks.\n *\n * @example\n * ```tsx\n * <ZamaProvider relayer={relayer} signer={signer} storage={storage}>\n * <App />\n * </ZamaProvider>\n * ```\n */\nexport function ZamaProvider({\n children,\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses,\n registryTTL,\n onEvent,\n}: ZamaProviderProps) {\n const queryClient = useQueryClient();\n\n // Stabilize onEvent so an inline arrow doesn't recreate the SDK every render.\n const onEventRef = useRef(onEvent);\n\n useEffect(() => {\n onEventRef.current = onEvent;\n });\n\n const signerLifecycleCallbacks = useMemo(\n () =>\n signer?.subscribe\n ? {\n onDisconnect: () => invalidateWalletLifecycleQueries(queryClient),\n onAccountChange: () => invalidateWalletLifecycleQueries(queryClient),\n onChainChange: () => invalidateWalletLifecycleQueries(queryClient),\n }\n : undefined,\n [queryClient, signer],\n );\n\n const sdk = useMemo(\n () =>\n new ZamaSDK({\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses,\n registryTTL,\n onEvent: onEventRef.current,\n signerLifecycleCallbacks,\n }),\n [\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses,\n registryTTL,\n signerLifecycleCallbacks,\n ],\n );\n\n // Clean up signer subscriptions on unmount without terminating the\n // caller-owned relayer. dispose() only unsubscribes from wallet events\n // and is idempotent.\n useEffect(() => () => sdk.dispose(), [sdk]);\n\n return <ZamaSDKContext.Provider value={sdk}>{children}</ZamaSDKContext.Provider>;\n}\n\n/**\n * Access the {@link ZamaSDK} instance from context.\n * Throws if called outside a {@link ZamaProvider} or when no signer is provided.\n *\n * @example\n * ```tsx\n * const sdk = useZamaSDK();\n * const token = sdk.createReadonlyToken(\"0x...\");\n * ```\n */\nexport function useZamaSDK(): ZamaSDK {\n const context = useContext(ZamaSDKContext);\n\n if (!context) {\n throw new Error(\n \"useZamaSDK must be used within a <ZamaProvider>. \" +\n \"Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.\",\n );\n }\n\n return context;\n}\n","\"use client\";\n\nimport type { EncryptParams, EncryptResult } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { encryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Encrypt a plaintext value using FHE.\n * Calls the relayer's `encrypt` method via a mutation.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link EncryptionFailedError} — FHE encryption failed\n *\n * @returns A mutation whose `mutate` accepts {@link EncryptParams}.\n *\n * @example\n * ```tsx\n * const encrypt = useEncrypt();\n * encrypt.mutate({ values: [{ value: 1000n, type: \"euint64\" }], contractAddress: \"0x...\", userAddress: \"0x...\" });\n * ```\n */\nexport function useEncrypt() {\n const sdk = useZamaSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(sdk));\n}\n","import {\n type DefaultError,\n type QueriesOptions,\n type QueriesResults,\n useQueries as tanstack_useQueries,\n useQuery as tanstack_useQuery,\n useSuspenseQuery as tanstack_useSuspenseQuery,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryOptions,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\n\n/**\n * Thin wrapper around TanStack's useQuery that injects our custom queryKeyHashFn.\n * Mirrors the wagmi pattern — the type safety boundary is at the factory and hook levels.\n *\n * Callers typically specify only `<TData>` (e.g. `useQuery<PublicKeyData>(...)`) while\n * factory options carry specific tuple keys (e.g. `readonly [\"zama.publicKey\"]`).\n * We erase the QueryKey param via `AnyKeyQueryOptions` so callers don't need to\n * spell out the key type — any QueryKey subtype is accepted.\n */\ntype AnyKeyQueryOptions<TData, TError> = UseQueryOptions<\n TData,\n TError,\n TData,\n // oxlint-disable-next-line typescript/no-explicit-any\n any\n>;\ntype AnyKeySuspenseOptions<TData, TError> = UseSuspenseQueryOptions<\n TData,\n TError,\n TData,\n // oxlint-disable-next-line typescript/no-explicit-any\n any\n>;\n\nexport function useQuery<TData = unknown, TError = DefaultError>(\n options: AnyKeyQueryOptions<TData, TError>,\n): UseQueryResult<TData, TError> {\n return tanstack_useQuery({\n ...options,\n queryKeyHashFn: hashFn,\n });\n}\n\nexport function useSuspenseQuery<TData = unknown, TError = DefaultError>(\n options: AnyKeySuspenseOptions<TData, TError>,\n): UseSuspenseQueryResult<TData, TError> {\n return tanstack_useSuspenseQuery({\n ...options,\n queryKeyHashFn: hashFn,\n });\n}\n\n/**\n * Thin wrapper around TanStack's useQueries that injects our custom queryKeyHashFn\n * on every query in the array.\n */\nexport function useQueries<\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>({\n queries,\n ...options\n}: {\n queries: readonly [...QueriesOptions<T>];\n combine?: (result: QueriesResults<T>) => TCombinedResult;\n subscribed?: boolean;\n}): TCombinedResult {\n return tanstack_useQueries({\n ...options,\n queries: queries.map((q) => ({\n ...q,\n queryKeyHashFn: hashFn,\n })) as [...QueriesOptions<T>],\n });\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { DecryptResult, UserDecryptQueryConfig } from \"@zama-fhe/sdk/query\";\nimport { userDecryptQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\n\n/**\n * React hook for FHE user decryption. Thin wrapper around\n * `userDecryptQueryOptions` with `useQuery` semantics.\n */\nexport function useUserDecrypt(\n config: UserDecryptQueryConfig,\n options?: Omit<UseQueryOptions<DecryptResult>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const queryOpts = userDecryptQueryOptions(sdk, config);\n return useQuery<DecryptResult>({\n ...queryOpts,\n ...options,\n enabled: queryOpts.enabled && (options?.enabled ?? false),\n });\n}\n\n/** Return type of {@link useUserDecrypt}. */\nexport type UseUserDecryptResult = ReturnType<typeof useUserDecrypt>;\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Handle, PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { publicDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using the network public key (no credential needed).\n * On success, results are available via `data.clearValues` and written to the\n * persistent decrypt cache.\n *\n * @returns A mutation whose `mutate` accepts an array of handle strings.\n *\n * @example\n * ```tsx\n * const publicDecrypt = usePublicDecrypt();\n * publicDecrypt.mutate([\"0xHandle1\", \"0xHandle2\"]);\n * // publicDecrypt.data?.clearValues => { \"0xHandle1\": 500n, ... }\n * ```\n */\nexport function usePublicDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<PublicDecryptResult, Error, Handle[]>(publicDecryptMutationOptions(sdk));\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { generateKeypairMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Generate an FHE keypair via the relayer.\n * Returns a public/private key pair for use in decrypt authorization.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link RelayerRequestFailedError} — relayer keypair generation request failed\n *\n * @returns A mutation whose `mutate` takes no parameters.\n *\n * @example\n * ```tsx\n * const generateKeypair = useGenerateKeypair();\n * generateKeypair.mutate();\n * // generateKeypair.data?.publicKey, generateKeypair.data?.privateKey\n * ```\n */\nexport function useGenerateKeypair() {\n const sdk = useZamaSDK();\n return useMutation(generateKeypairMutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { EIP712TypedData } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { createEIP712MutationOptions } from \"@zama-fhe/sdk/query\";\nimport type { CreateEIP712Params } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type { CreateEIP712Params };\n\n/**\n * Create EIP-712 typed data for signing an FHE decrypt credential.\n * The returned typed data is signed by the wallet to authorize decryption.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateEIP712() {\n const sdk = useZamaSDK();\n return useMutation<EIP712TypedData, Error, CreateEIP712Params>(createEIP712MutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { KmsDelegatedUserDecryptEIP712Type } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { createDelegatedUserDecryptEIP712MutationOptions } from \"@zama-fhe/sdk/query\";\nimport type { CreateDelegatedUserDecryptEIP712Params } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type { CreateDelegatedUserDecryptEIP712Params };\n\n/**\n * Create EIP-712 typed data for a delegated user decrypt credential.\n * Used when one wallet authorizes another to decrypt on its behalf.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateDelegatedUserDecryptEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateDelegatedUserDecryptEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * delegatorAddress: \"0xDelegator\",\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateDelegatedUserDecryptEIP712() {\n const sdk = useZamaSDK();\n return useMutation<\n KmsDelegatedUserDecryptEIP712Type,\n Error,\n CreateDelegatedUserDecryptEIP712Params\n >(createDelegatedUserDecryptEIP712MutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { DelegatedUserDecryptParams, ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { delegatedUserDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using delegated user credentials.\n * Returns a map of handle → plaintext bigint.\n *\n * @returns A mutation whose `mutate` accepts {@link DelegatedUserDecryptParams}.\n *\n * @example\n * ```tsx\n * const decrypt = useDelegatedUserDecrypt();\n * decrypt.mutate({ handles: [\"0xHandle1\"], ...credentials });\n * // decrypt.data => { \"0xHandle1\": 1000n }\n * ```\n */\nexport function useDelegatedUserDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<Record<Handle, ClearValueType>, Error, DelegatedUserDecryptParams>(\n delegatedUserDecryptMutationOptions(sdk),\n );\n}\n","\"use client\";\n\nimport type { InputProofBytesType, ZKProofLike } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { requestZKProofVerificationMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Submit a ZK proof for on-chain verification.\n * Returns the input proof bytes for use in contract calls.\n *\n * @returns A mutation whose `mutate` accepts a {@link ZKProofLike}.\n *\n * @example\n * ```tsx\n * const verify = useRequestZKProofVerification();\n * verify.mutate(zkProof);\n * // verify.data => Uint8Array (input proof bytes)\n * ```\n */\nexport function useRequestZKProofVerification() {\n const sdk = useZamaSDK();\n return useMutation<InputProofBytesType, Error, ZKProofLike>(\n requestZKProofVerificationMutationOptions(sdk),\n );\n}\n","\"use client\";\n\nimport type { PublicKeyData } from \"@zama-fhe/sdk\";\nimport { useQuery } from \"../utils/query\";\nimport { publicKeyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Fetch the FHE network public key from the relayer.\n * Cached indefinitely since the key does not change during a session.\n *\n * @returns Query result with `data: PublicKeyData | null`.\n *\n * @example\n * ```tsx\n * const { data: publicKey } = usePublicKey();\n * // publicKey?.publicKeyId, publicKey?.publicKey\n * ```\n */\nexport function usePublicKey() {\n const sdk = useZamaSDK();\n return useQuery<PublicKeyData | null>(publicKeyQueryOptions(sdk));\n}\n","\"use client\";\n\nimport type { PublicParamsData } from \"@zama-fhe/sdk\";\nimport { useQuery } from \"../utils/query\";\nimport { publicParamsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Fetch FHE public parameters for a given bit size from the relayer.\n * Cached indefinitely since parameters do not change during a session.\n *\n * @param bits - The FHE bit size to fetch parameters for (e.g. 2048).\n * @returns Query result with `data: PublicParamsData | null`.\n *\n * @example\n * ```tsx\n * const { data: params } = usePublicParams(2048);\n * // params?.publicParams, params?.publicParamsId\n * ```\n */\nexport function usePublicParams(bits: number) {\n const sdk = useZamaSDK();\n return useQuery<PublicParamsData | null>(publicParamsQueryOptions(sdk, bits));\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { allowMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Sign an EIP-712 message authorizing decryption of confidential handles\n * for a list of contract addresses. This is not token-specific — any\n * contract that uses FHE-encrypted values (tokens, DeFi vaults, games, etc.)\n * can be authorized in a single wallet signature. Subsequent decrypt\n * operations on any of these contracts reuse cached credentials.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link KeypairExpiredError} — the re-encryption keypair has expired\n *\n * @example\n * ```tsx\n * const { mutateAsync: allow, isPending } = useAllow();\n *\n * // Authorize decryption for any contracts with encrypted state:\n * // confidential tokens, auction contracts, governance contracts, etc.\n * await allow([tokenAddress, auctionAddress, governanceAddress]);\n * ```\n */\nexport function useAllow(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...allowMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n void context.client.invalidateQueries({\n queryKey: zamaQueryKeys.isAllowed.all,\n });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { skipToken } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n isAllowedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Configuration for {@link useIsAllowed}. */\nexport interface UseIsAllowedConfig {\n /** Contract addresses to check credentials against (at least one required). */\n contractAddresses: [Address, ...Address[]];\n}\n\n/**\n * Check whether a session signature is cached for the connected wallet\n * and covers the given contract addresses.\n * Returns `true` if decrypt operations can proceed without a wallet prompt.\n *\n * @example\n * ```tsx\n * const { data: allowed } = useIsAllowed({ contractAddresses: [\"0xToken\"] });\n * ```\n */\nexport function useIsAllowed(config: UseIsAllowedConfig) {\n const sdk = useZamaSDK();\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n const account = addressQuery.data;\n const baseOpts = account\n ? isAllowedQueryOptions(sdk, { account, contractAddresses: config.contractAddresses })\n : ({\n queryKey: zamaQueryKeys.isAllowed.all,\n queryFn: skipToken,\n enabled: false,\n } as const);\n\n return useQuery<boolean>(baseOpts);\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { revokeMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke stored FHE decrypt credentials for a list of contract addresses.\n * This is not token-specific — it revokes the EIP-712 authorization for\n * any contract that uses FHE-encrypted values. The next decrypt operation\n * on these contracts will require a fresh wallet signature.\n *\n * @example\n * ```tsx\n * const { mutate: revoke } = useRevoke();\n *\n * // Revoke for any contracts: tokens, auctions, governance, etc.\n * revoke([tokenAddress, auctionAddress]);\n * ```\n */\nexport function useRevoke(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...revokeMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.removeQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n context.client.removeQueries({ queryKey: zamaQueryKeys.decryption.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { revokeSessionMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke the session signature for the connected wallet without\n * specifying contract addresses. Useful for wallet disconnect handlers.\n *\n * @example\n * ```tsx\n * const { mutate: revokeSession } = useRevokeSession();\n * revokeSession();\n * ```\n */\nexport function useRevokeSession(options?: UseMutationOptions<void>) {\n const sdk = useZamaSDK();\n\n return useMutation<void>({\n ...revokeSessionMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.removeQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n context.client.removeQueries({ queryKey: zamaQueryKeys.decryption.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Base configuration shared by all mutation hooks that need a Token instance. */\nexport interface UseZamaConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Address of the wrapper contract (required for shield/unshield operations). */\n wrapperAddress?: Address;\n}\n\n/**\n * Get a {@link Token} instance, memoized by address pair.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param config - Token and optional wrapper addresses.\n * @returns A memoized `Token` instance.\n *\n * @example\n * ```tsx\n * const token = useToken({ tokenAddress: \"0xToken\", wrapperAddress: \"0xWrapper\" });\n * ```\n */\nexport function useToken(config: UseZamaConfig) {\n const sdk = useZamaSDK();\n\n return useMemo(\n () => sdk.createToken(config.tokenAddress, config.wrapperAddress),\n [sdk, config.tokenAddress, config.wrapperAddress],\n );\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Get a {@link ReadonlyToken} instance, memoized by address.\n * Supports balance queries, ERC-165 checks, and authorization — no wrapper needed.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param address - Address of the confidential token contract.\n * @returns A memoized `ReadonlyToken` instance.\n *\n * @example\n * ```tsx\n * const token = useReadonlyToken(\"0xToken\");\n * // token.balanceOf(), token.isConfidential(), etc.\n * ```\n */\nexport function useReadonlyToken(address: Address) {\n const sdk = useZamaSDK();\n\n return useMemo(() => sdk.createReadonlyToken(address), [sdk, address]);\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialBalanceQueryOptions, signerAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\nimport { useQuery } from \"../utils/query\";\n\n/** Configuration for {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n}\n\n/** Query options for {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceOptions extends Omit<\n UseQueryOptions<bigint>,\n \"queryKey\" | \"queryFn\" | \"enabled\"\n> {\n /** Whether the query is enabled. Callback form is not supported in composite hooks. */\n enabled?: boolean;\n}\n\n/**\n * Declarative hook to read the connected wallet's confidential token balance.\n * Calls `token.balanceOf(owner)` which reads the on-chain handle and decrypts\n * via the SDK. Cached values are returned instantly — the relayer is only hit\n * when the handle changes.\n *\n * @param config - Token address configuration.\n * @param options - React Query options forwarded to the balance query.\n * @returns The balance query result.\n *\n * @example\n * ```tsx\n * const { data: balance, isLoading } = useConfidentialBalance({\n * tokenAddress: \"0x...\",\n * });\n * ```\n */\nexport function useConfidentialBalance(\n config: UseConfidentialBalanceConfig,\n options?: UseConfidentialBalanceOptions,\n) {\n const { tokenAddress } = config;\n const { enabled = true } = options ?? {};\n const sdk = useZamaSDK();\n const token = useReadonlyToken(tokenAddress);\n\n const addressQuery = useQuery<Address>(signerAddressQueryOptions(sdk.signer));\n\n const owner = addressQuery.data;\n\n const baseOptions = confidentialBalanceQueryOptions(token, {\n tokenAddress,\n owner,\n });\n\n return useQuery<bigint>({\n ...baseOptions,\n ...options,\n enabled: baseOptions.enabled && enabled,\n });\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport { useQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, BatchBalancesResult } from \"@zama-fhe/sdk\";\nimport { confidentialBalancesQueryOptions, signerAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Configuration for {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesConfig {\n /** Addresses of the confidential token contracts to batch-query. */\n tokenAddresses: Address[];\n}\n\n/** Query options for {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesOptions extends Omit<\n UseQueryOptions<BatchBalancesResult>,\n \"queryKey\" | \"queryFn\" | \"enabled\"\n> {\n /** Whether the query is enabled. Callback form is not supported in composite hooks. */\n enabled?: boolean;\n}\n\n/**\n * Declarative hook to read multiple confidential token balances in batch.\n * Calls `ReadonlyToken.batchBalancesOf()` which decrypts each token via the\n * SDK. Cached values are returned instantly — the relayer is only hit for\n * changed handles.\n *\n * Returns partial results when some tokens fail — successful balances are\n * always returned alongside per-token error information.\n *\n * @param config - Token addresses configuration.\n * @param options - React Query options forwarded to the balance query.\n * @returns The balance query result.\n *\n * @example\n * ```tsx\n * const { data } = useConfidentialBalances({\n * tokenAddresses: [\"0xTokenA\", \"0xTokenB\"],\n * });\n * const balance = data?.results.get(\"0xTokenA\");\n * if (data && data.errors.size > 0) {\n * // some tokens failed — check data.errors\n * }\n * ```\n */\nexport function useConfidentialBalances(\n config: UseConfidentialBalancesConfig,\n options?: UseConfidentialBalancesOptions,\n) {\n const { tokenAddresses } = config;\n const { enabled = true } = options ?? {};\n const sdk = useZamaSDK();\n\n const addressQuery = useQuery<Address>(signerAddressQueryOptions(sdk.signer));\n\n const owner = addressQuery.data;\n\n const tokens = useMemo(\n () => tokenAddresses.map((addr) => sdk.createReadonlyToken(addr)),\n [sdk, tokenAddresses],\n );\n\n const baseOptions = confidentialBalancesQueryOptions(tokens, {\n owner,\n });\n\n return useQuery<BatchBalancesResult>({\n ...baseOptions,\n ...options,\n enabled: (baseOptions.enabled ?? true) && enabled,\n });\n}\n","import type { QueryClient, QueryKey, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterShield, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\n\ntype BalanceDeltaMode = \"add\" | \"subtract\";\nexport type OptimisticBalanceSnapshot = [QueryKey, bigint | undefined][];\n\n/** Combined context returned by optimistic `onMutate`. */\nexport interface OptimisticMutateContext {\n snapshot: OptimisticBalanceSnapshot;\n callerContext?: unknown;\n}\n\nexport function unwrapOptimisticCallerContext(\n optimistic: boolean | undefined,\n rawContext: unknown,\n): {\n wrappedContext: OptimisticMutateContext | undefined;\n callerContext: OptimisticMutateContext | undefined;\n} {\n const typed = rawContext as OptimisticMutateContext | undefined;\n const wrappedContext = optimistic ? typed : undefined;\n const callerContext = (optimistic ? wrappedContext?.callerContext : rawContext) as\n | OptimisticMutateContext\n | undefined;\n return { wrappedContext, callerContext };\n}\n\nexport async function applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount,\n mode,\n}: {\n queryClient: QueryClient;\n tokenAddress: Address;\n amount: bigint;\n mode: BalanceDeltaMode;\n}): Promise<OptimisticBalanceSnapshot> {\n const balanceKey = zamaQueryKeys.confidentialBalance.token(tokenAddress);\n await queryClient.cancelQueries({ queryKey: balanceKey });\n const previous = queryClient.getQueriesData<bigint>({ queryKey: balanceKey });\n for (const [key, value] of previous) {\n if (value === undefined) {\n continue;\n }\n // Temporary optimistic underflow (`amount > value`) is acceptable because\n // settlement invalidates and rewrites this cache entry.\n queryClient.setQueryData(key, mode === \"add\" ? value + amount : value - amount);\n }\n return previous;\n}\n\nexport function rollbackOptimisticBalanceDelta(\n queryClient: QueryClient,\n snapshot: OptimisticBalanceSnapshot,\n) {\n for (const [key, value] of snapshot) {\n queryClient.setQueryData(key, value);\n }\n}\n\n/**\n * Build optimistic mutation callbacks for shield operations.\n * Wraps the caller's `onMutate`/`onError`/`onSuccess`/`onSettled` with snapshot/rollback logic\n * and returns overrides ready to spread into `useMutation`.\n */\nexport function optimisticBalanceCallbacks<TParams extends { amount: bigint }>({\n optimistic,\n tokenAddress,\n queryClient,\n options,\n}: {\n optimistic: boolean | undefined;\n tokenAddress: Address;\n queryClient: QueryClient;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: UseMutationOptions<TransactionResult, Error, TParams, any> | undefined;\n}): Pick<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n UseMutationOptions<TransactionResult, Error, TParams, any>,\n \"onMutate\" | \"onError\" | \"onSuccess\" | \"onSettled\"\n> {\n return {\n onMutate: optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount: variables.amount,\n mode: \"add\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext, context);\n invalidateAfterShield(context.client, tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext, context);\n },\n };\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferParams,\n} from \"@zama-fhe/sdk/query\";\nimport {\n applyOptimisticBalanceDelta,\n rollbackOptimisticBalanceDelta,\n unwrapOptimisticCallerContext,\n} from \"../balance/optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/** Configuration for {@link useConfidentialTransfer}. */\nexport interface UseConfidentialTransferConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically subtracts the transfer amount from cached balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Encrypt and send a confidential transfer. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * Set `optimistic: true` to subtract the amount from the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transfer = useConfidentialTransfer({\n * tokenAddress: \"0x...\",\n * optimistic: true,\n * });\n * transfer.mutate(\n * { to: \"0xRecipient\", amount: 1000n },\n * {\n * onError: (error) => {\n * if (error instanceof SigningRejectedError) {\n * // user cancelled — no action needed\n * }\n * },\n * },\n * );\n * ```\n */\nexport function useConfidentialTransfer<TContext = unknown>(\n config: UseConfidentialTransferConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n // Internal mutation uses `any` for TContext because optimistic mode wraps\n // the caller's context in OptimisticMutateContext; the public return type\n // is cast back to the caller's TContext.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return useMutation<TransactionResult, Error, ConfidentialTransferParams, any>({\n ...confidentialTransferMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress: config.tokenAddress,\n amount: variables.amount,\n mode: \"subtract\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n config.optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext as TContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as TContext, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext as TContext, context);\n },\n }) as UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext>;\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferFromMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferFromParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Operator transfer on behalf of another address. Caller must be an approved operator.\n * Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the transfer amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transferFrom = useConfidentialTransferFrom({ tokenAddress: \"0x...\" });\n * transferFrom.mutate({ from: \"0xOwner\", to: \"0xRecipient\", amount: 500n });\n * ```\n */\nexport function useConfidentialTransferFrom(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferFromParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialTransferFromParams, Address>({\n ...confidentialTransferFromMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialApproveMutationOptions,\n invalidateAfterApprove,\n type ConfidentialApproveParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Set operator approval for a confidential token. Defaults to 1 hour.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useConfidentialApprove({ tokenAddress: \"0x...\" });\n * approve.mutate({ spender: \"0xOperator\" });\n * ```\n */\nexport function useConfidentialApprove(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialApproveParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialApproveParams, Address>({\n ...confidentialApproveMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApprove(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialIsApprovedQueryOptions, signerAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\nexport { confidentialIsApprovedQueryOptions };\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig {\n /** Address of the confidential token contract. Pass `undefined` to disable the query. */\n tokenAddress: Address | undefined;\n /** Address to check approval for. Pass `undefined` to disable the query. */\n spender: Address | undefined;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/** Configuration for {@link useConfidentialIsApprovedSuspense}. */\nexport interface UseConfidentialIsApprovedSuspenseConfig extends UseZamaConfig {\n /** Address to check approval for. */\n spender: Address;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/**\n * Check if a spender is an approved operator for a given holder (defaults to connected wallet).\n *\n * @param config - Token address, spender, and optional holder to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApproved({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApproved(\n config: UseConfidentialIsApprovedConfig,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, spender, holder } = config;\n const sdk = useZamaSDK();\n const holderQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n enabled: tokenAddress !== undefined && spender !== undefined && holder === undefined,\n });\n const resolvedHolder = holder ?? holderQuery.data;\n const baseOpts = confidentialIsApprovedQueryOptions(sdk.signer, tokenAddress, {\n holder: resolvedHolder,\n spender,\n });\n\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useConfidentialIsApproved}.\n * Suspends rendering until the approval check resolves.\n *\n * @param config - Token address, spender, and optional holder to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApprovedSuspense({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig) {\n const { spender, holder, ...tokenConfig } = config;\n const sdk = useZamaSDK();\n const token = useToken(tokenConfig);\n const addressQuery = useSuspenseQuery<Address>(signerAddressQueryOptions(sdk.signer));\n const resolvedHolder = holder ?? addressQuery.data;\n\n return useSuspenseQuery<boolean>(\n confidentialIsApprovedQueryOptions(sdk.signer, token.address, {\n holder: resolvedHolder,\n spender,\n }),\n );\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport { shieldMutationOptions, type ShieldParams } from \"@zama-fhe/sdk/query\";\nimport { optimisticBalanceCallbacks } from \"../balance/optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/** Configuration for {@link useShield}. */\nexport interface UseShieldConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield public ERC-20 tokens into confidential tokens.\n * Handles ERC-20 approval automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link ApprovalFailedError} — ERC-20 approval transaction failed\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shield = useShield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shield.mutate({ amount: 1000n });\n * ```\n */\nexport function useShield<TContext = unknown>(\n config: UseShieldConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ShieldParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation({\n ...shieldMutationOptions(token),\n ...options,\n ...optimisticBalanceCallbacks({\n optimistic: config.optimistic,\n tokenAddress: config.tokenAddress,\n queryClient,\n options,\n }),\n }) as UseMutationResult<TransactionResult, Error, ShieldParams, TContext>;\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnwrap,\n type UnwrapParams,\n unwrapMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Request an unwrap for a specific amount. Encrypts the amount first.\n * Call {@link useFinalizeUnwrap} after the request is processed on-chain,\n * or use {@link useUnshield} for a single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the unwrap amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrap = useUnwrap({ tokenAddress: \"0x...\" });\n * unwrap.mutate({ amount: 500n });\n * ```\n */\nexport function useUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnwrapParams, Address>({\n ...unwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterUnwrap, unwrapAllMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Request an unwrap for the entire confidential balance.\n * Uses the on-chain balance handle directly (no encryption needed).\n * Call {@link useFinalizeUnwrap} after processing, or use {@link useUnshieldAll} for single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrapAll = useUnwrapAll({ tokenAddress: \"0x...\" });\n * unwrapAll.mutate();\n * ```\n */\nexport function useUnwrapAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, void, Address>({\n ...unwrapAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n finalizeUnwrapMutationOptions,\n invalidateAfterUnshield,\n type FinalizeUnwrapParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Complete an unwrap by providing the public decryption proof.\n * Call this after an unwrap request has been processed on-chain.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption of the burn amount failed\n * - {@link TransactionRevertedError} — on-chain finalize transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const finalize = useFinalizeUnwrap({ tokenAddress: \"0x...\" });\n * finalize.mutate({ unwrapRequestId: event.unwrapRequestId });\n * ```\n */\nexport function useFinalizeUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, FinalizeUnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, FinalizeUnwrapParams, Address>({\n ...finalizeUnwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldParams,\n unshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Unshield a specific amount and finalize in one call.\n * Orchestrates: unwrap → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed during unwrap\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshield = useUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshield.mutate({ amount: 500n });\n * ```\n */\nexport function useUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldParams, Address>({\n ...unshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldAllParams,\n unshieldAllMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Unshield the entire balance and finalize in one call.\n * Orchestrates: unwrapAll → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshieldAll = useUnshieldAll({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshieldAll.mutate();\n * ```\n */\nexport function useUnshieldAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldAllParams | void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldAllParams | void, Address>({\n ...unshieldAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type ResumeUnshieldParams,\n resumeUnshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Resume an interrupted unshield from an existing unwrap tx hash.\n * Useful when the user submitted the unwrap but the finalize step was\n * interrupted (e.g. page reload, network error).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const resumeUnshield = useResumeUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * resumeUnshield.mutate({ unwrapTxHash: \"0xabc...\" });\n * ```\n */\nexport function useResumeUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ResumeUnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ResumeUnshieldParams, Address>({\n ...resumeUnshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { signerAddressQueryOptions, underlyingAllowanceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { underlyingAllowanceQueryOptions };\n\n/** Configuration for {@link useUnderlyingAllowance}. */\nexport interface UseUnderlyingAllowanceConfig {\n /** Address of the confidential token contract used to scope the query cache. */\n tokenAddress: Address;\n /** Address of the wrapper contract whose underlying ERC-20 allowance is checked. */\n wrapperAddress: Address;\n}\n\n/**\n * Read the underlying ERC-20 allowance granted to the wrapper contract.\n * Useful to check if an approval is needed before shielding.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (current allowance).\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowance({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowance(\n config: UseUnderlyingAllowanceConfig,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, wrapperAddress } = config;\n const sdk = useZamaSDK();\n const addressQuery = useQuery<Address>(signerAddressQueryOptions(sdk.signer));\n const owner = addressQuery.data;\n\n const baseOpts = underlyingAllowanceQueryOptions(sdk.signer, tokenAddress, {\n owner,\n wrapperAddress,\n });\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useUnderlyingAllowance}.\n * Suspends rendering until the allowance is loaded.\n *\n * @param config - Token and wrapper addresses.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowanceSuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowanceSuspense(config: UseUnderlyingAllowanceConfig) {\n const { tokenAddress, wrapperAddress } = config;\n const sdk = useZamaSDK();\n const addressQuery = useSuspenseQuery<Address>(signerAddressQueryOptions(sdk.signer));\n const owner = addressQuery.data;\n\n return useSuspenseQuery<bigint>(\n underlyingAllowanceQueryOptions(sdk.signer, tokenAddress, {\n owner,\n wrapperAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\n\n/**\n * Resolves the wrappers registry address for the current chain.\n * Uses the merged registry addresses from `sdk.registry` (built-in defaults\n * plus any `registryAddresses` overrides passed to `ZamaSDKConfig`).\n *\n * Returns `undefined` when the chain ID hasn't been fetched yet\n * or when no registry is configured for the connected chain.\n *\n * The chain ID is cached for 30 seconds (`staleTime`), so chain\n * switches may take up to 30s to reflect.\n */\nexport function useWrappersRegistryAddress(): Address | undefined {\n const sdk = useZamaSDK();\n\n const { data: chainId } = useQuery<number>({\n queryKey: zamaQueryKeys.wrappersRegistry.chainId(),\n queryFn: () => sdk.signer.getChainId(),\n staleTime: 30_000,\n });\n\n return chainId !== undefined ? sdk.registry.getAddress(chainId) : undefined;\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { wrapperDiscoveryQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"../wrappers-registry/use-wrappers-registry-address\";\n\nexport { wrapperDiscoveryQueryOptions };\n\n/** Configuration for {@link useWrapperDiscovery}. */\nexport interface UseWrapperDiscoveryConfig {\n /**\n * Address of any confidential token you control.\n * Used only to derive the signer context and to scope the query cache key —\n * it does not affect which wrapper the registry returns.\n */\n tokenAddress: Address;\n /** ERC-20 address to discover the wrapper for. Pass `undefined` to disable the query. */\n erc20Address: Address | undefined;\n}\n\n/** Configuration for {@link useWrapperDiscoverySuspense}. */\nexport interface UseWrapperDiscoverySuspenseConfig {\n /**\n * Address of any confidential token you control.\n * Used only to derive the signer context and to scope the query cache key —\n * it does not affect which wrapper the registry returns.\n */\n tokenAddress: Address;\n /** ERC-20 address to discover the wrapper for. */\n erc20Address: Address;\n}\n\n/**\n * Discover the confidential wrapper for an ERC-20 token via the on-chain registry.\n * Returns the wrapper address if one exists, or `null` if not.\n * Cached indefinitely since wrapper mappings are immutable.\n *\n * @param config - Token and ERC-20 addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscovery({\n * tokenAddress: \"0xConfidentialToken\",\n * erc20Address: \"0xUSDC\",\n * });\n * ```\n */\nexport function useWrapperDiscovery(\n config: UseWrapperDiscoveryConfig,\n options?: Omit<UseQueryOptions<Address | null>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, erc20Address } = config;\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n const baseOpts = wrapperDiscoveryQueryOptions(sdk.registry, {\n tokenAddress,\n erc20Address,\n registryAddress,\n });\n\n return useQuery<Address | null>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useWrapperDiscovery}.\n * Suspends rendering until the wrapper address is resolved.\n *\n * @param config - Token and ERC-20 addresses.\n * @returns Suspense query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscoverySuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * erc20Address: \"0xUSDC\",\n * });\n * ```\n */\nexport function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig) {\n const { tokenAddress, erc20Address } = config;\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useSuspenseQuery<Address | null>(\n wrapperDiscoveryQueryOptions(sdk.registry, {\n tokenAddress,\n erc20Address,\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenMetadataQueryOptions, type TokenMetadata } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\n\nexport { type TokenMetadata };\n\n/**\n * Read ERC-20 token metadata (name, symbol, decimals).\n * Fetches all three in parallel. Cached indefinitely since metadata is immutable.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadata(\"0xToken\");\n * // metadata?.name, metadata?.symbol, metadata?.decimals\n * ```\n */\nexport function useMetadata(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<TokenMetadata>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n return useQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(sdk.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useMetadata}.\n * Suspends rendering until metadata is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadataSuspense(\"0xToken\");\n * ```\n */\nexport function useMetadataSuspense(tokenAddress: Address) {\n const sdk = useZamaSDK();\n return useSuspenseQuery<TokenMetadata>(tokenMetadataQueryOptions(sdk.signer, tokenAddress));\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n delegateDecryptionMutationOptions,\n zamaQueryKeys,\n type DelegateDecryptionParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Delegate FHE decryption rights for a token to another address via the on-chain ACL.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const delegate = useDelegateDecryption({ tokenAddress: \"0x...\" });\n * delegate.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useDelegateDecryption(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, DelegateDecryptionParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, DelegateDecryptionParams>({\n ...delegateDecryptionMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n try {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n } finally {\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n revokeDelegationMutationOptions,\n zamaQueryKeys,\n type RevokeDelegationParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Revoke FHE decryption delegation for a token from a delegate address.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const revoke = useRevokeDelegation({ tokenAddress: \"0x...\" });\n * revoke.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useRevokeDelegation(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, RevokeDelegationParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, RevokeDelegationParams>({\n ...revokeDelegationMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n try {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n } finally {\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n }\n },\n });\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { delegationStatusQueryOptions, type DelegationStatusData } from \"@zama-fhe/sdk/query\";\nimport { useQuery } from \"../utils/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport interface UseDelegationStatusConfig {\n /** Address of the confidential token contract. Pass `undefined` to disable the query. */\n tokenAddress: Address | undefined;\n /** The address that granted the delegation. */\n delegatorAddress?: Address;\n /** The address that received delegation rights. */\n delegateAddress?: Address;\n}\n\n/**\n * Query delegation status between a delegator and delegate for a token.\n *\n * @param config - Token address, delegator, and delegate addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns `{ isDelegated, expiryTimestamp, isLoading, error }`.\n *\n * @example\n * ```tsx\n * const { data } = useDelegationStatus({\n * tokenAddress: \"0xToken\",\n * delegatorAddress: \"0xDelegator\",\n * delegateAddress: \"0xDelegate\",\n * });\n * // data?.isDelegated, data?.expiryTimestamp\n * ```\n */\nexport function useDelegationStatus(\n config: UseDelegationStatusConfig,\n options?: Omit<UseQueryOptions<DelegationStatusData>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = delegationStatusQueryOptions(sdk, config);\n\n return useQuery<DelegationStatusData>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { decryptBalanceAsMutationOptions, type DecryptBalanceAsParams } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\n\n/**\n * Decrypt another user's confidential balance as a delegate.\n *\n * @param tokenAddress - Address of the confidential token contract.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const decryptAs = useDecryptBalanceAs(\"0xToken\");\n * decryptAs.mutate({ delegatorAddress: \"0xDelegator\" });\n * // decryptAs.data => 1000n\n * ```\n */\nexport function useDecryptBalanceAs(\n tokenAddress: Address,\n options?: UseMutationOptions<bigint, Error, DecryptBalanceAsParams>,\n) {\n const readonlyToken = useReadonlyToken(tokenAddress);\n\n return useMutation<bigint, Error, DecryptBalanceAsParams>({\n ...decryptBalanceAsMutationOptions(readonlyToken),\n ...options,\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, ReadonlyToken } from \"@zama-fhe/sdk\";\nimport {\n batchDecryptBalancesAsMutationOptions,\n type BatchDecryptBalancesAsParams,\n} from \"@zama-fhe/sdk/query\";\n\n/**\n * Batch decrypt confidential balances as a delegate across multiple tokens.\n *\n * @param tokens - ReadonlyToken instances to decrypt balances for.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const batchDecryptAs = useBatchDecryptBalancesAs(tokens);\n * batchDecryptAs.mutate({\n * delegatorAddress: \"0xDelegator\",\n * });\n * // batchDecryptAs.data => Map { \"0xTokenA\" => 100n, \"0xTokenB\" => 200n }\n * ```\n */\nexport function useBatchDecryptBalancesAs(\n tokens: ReadonlyToken[],\n options?: UseMutationOptions<Map<Address, bigint>, Error, BatchDecryptBalancesAsParams>,\n) {\n return useMutation<Map<Address, bigint>, Error, BatchDecryptBalancesAsParams>({\n ...batchDecryptBalancesAsMutationOptions(tokens),\n ...options,\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n approveUnderlyingMutationOptions,\n invalidateAfterApproveUnderlying,\n type ApproveUnderlyingParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Approve the wrapper contract to spend the underlying ERC-20.\n * Defaults to max uint256. Resets to zero first if there's an existing\n * non-zero allowance (required by tokens like USDT).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — approval transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useApproveUnderlying({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * approve.mutate({}); // max approval\n * approve.mutate({ amount: 1000n }); // exact amount\n * ```\n */\nexport function useApproveUnderlying(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ApproveUnderlyingParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ApproveUnderlyingParams, Address>({\n ...approveUnderlyingMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApproveUnderlying(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialQueryOptions, isWrapperQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { isConfidentialQueryOptions, isWrapperQueryOptions };\n\n/**\n * Check if a token supports the ERC-7984 confidential interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidential(\"0xToken\");\n * ```\n */\nexport function useIsConfidential(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n\n return useQuery<boolean>({\n ...isConfidentialQueryOptions(sdk.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsConfidential}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidentialSuspense(\"0xToken\");\n * ```\n */\nexport function useIsConfidentialSuspense(tokenAddress: Address) {\n const sdk = useZamaSDK();\n\n return useSuspenseQuery<boolean>(isConfidentialQueryOptions(sdk.signer, tokenAddress));\n}\n\n/**\n * Check if a token supports the ERC-7984 wrapper interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapper(\"0xToken\");\n * ```\n */\nexport function useIsWrapper(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n\n return useQuery<boolean>({\n ...isWrapperQueryOptions(sdk.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsWrapper}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapperSuspense(\"0xToken\");\n * ```\n */\nexport function useIsWrapperSuspense(tokenAddress: Address) {\n const sdk = useZamaSDK();\n\n return useSuspenseQuery<boolean>(isWrapperQueryOptions(sdk.signer, tokenAddress));\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { totalSupplyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { totalSupplyQueryOptions };\n\n/**\n * Read the total supply of a token.\n * Stale after 30 seconds to balance freshness and RPC cost.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupply(\"0xToken\");\n * ```\n */\nexport function useTotalSupply(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n\n return useQuery<bigint>({\n ...totalSupplyQueryOptions(sdk.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useTotalSupply}.\n * Suspends rendering until the total supply is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupplySuspense(\"0xToken\");\n * ```\n */\nexport function useTotalSupplySuspense(tokenAddress: Address) {\n const sdk = useZamaSDK();\n\n return useSuspenseQuery<bigint>(totalSupplyQueryOptions(sdk.signer, tokenAddress));\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches all token wrapper pairs from the ConfidentialTokenWrappersRegistry\n * contract on the current chain.\n */\nexport function useTokenPairsRegistry() {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly TokenWrapperPair[]>(\n tokenPairsQueryOptions(sdk.signer, {\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport { tokenPairsLengthQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Returns the total number of token wrapper pairs in the registry.\n */\nexport function useTokenPairsLength() {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<bigint>(\n tokenPairsLengthQueryOptions(sdk.signer, {\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairsSliceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches a range of token wrapper pairs from the registry (paginated).\n *\n * @param fromIndex - Start index (inclusive). Pass `undefined` to disable.\n * @param toIndex - End index (exclusive). Pass `undefined` to disable.\n */\nexport function useTokenPairsSlice({\n fromIndex,\n toIndex,\n}: {\n fromIndex: bigint | undefined;\n toIndex: bigint | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly TokenWrapperPair[]>(\n tokenPairsSliceQueryOptions(sdk.signer, {\n registryAddress,\n fromIndex,\n toIndex,\n }),\n );\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches a single token wrapper pair by index from the registry.\n *\n * @param index - Zero-based pair index. Pass `undefined` to disable.\n */\nexport function useTokenPair({ index }: { index: bigint | undefined }) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<TokenWrapperPair>(\n tokenPairQueryOptions(sdk.signer, {\n registryAddress,\n index,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialTokenAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Looks up the confidential token address for a given plain token address.\n */\nexport function useConfidentialTokenAddress({\n tokenAddress,\n}: {\n tokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly [boolean, Address]>(\n confidentialTokenAddressQueryOptions(sdk.signer, {\n registryAddress,\n tokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Looks up the plain token address for a given confidential token address.\n */\nexport function useTokenAddress({\n confidentialTokenAddress,\n}: {\n confidentialTokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly [boolean, Address]>(\n tokenAddressQueryOptions(sdk.signer, {\n registryAddress,\n confidentialTokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialTokenValidQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Checks whether a confidential token is registered and valid in the\n * on-chain wrappers registry.\n *\n * @param confidentialTokenAddress - The confidential token to check. Pass `undefined` to disable.\n */\nexport function useIsConfidentialTokenValid({\n confidentialTokenAddress,\n}: {\n confidentialTokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<boolean>(\n isConfidentialTokenValidQueryOptions(sdk.signer, {\n registryAddress,\n confidentialTokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type {\n TokenWrapperPair,\n TokenWrapperPairWithMetadata,\n PaginatedResult,\n} from \"@zama-fhe/sdk\";\nimport { listPairsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches paginated token wrapper pairs from the registry.\n *\n * @param options - Query options: `page` (1-indexed, default `1`), `pageSize` (default `100`), `metadata` (fetch on-chain metadata for both tokens, default `false`).\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListPairs({ page: 1, pageSize: 20 });\n * if (data) {\n * console.log(`${data.total} pairs, showing page ${data.page}`);\n * }\n * ```\n */\nexport function useListPairs({\n page = 1,\n pageSize = 100,\n metadata = false,\n}: {\n page?: number;\n pageSize?: number;\n metadata?: boolean;\n} = {}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n // Pass sdk.registry (a lazy singleton) so the class-level TTL cache is shared\n // across all queryFn executions — rather than constructing a new instance each time.\n return useQuery<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>>(\n listPairsQueryOptions(sdk.registry, {\n registryAddress,\n page,\n pageSize,\n metadata,\n }),\n );\n}\n"],"mappings":"o2MA4DA,MAAM,EAAiB,GAA8B,KAAK,CAY1D,SAAgB,GAAa,CAC3B,WACA,UACA,SACA,UACA,iBACA,aACA,aACA,oBACA,cACA,WACoB,CACpB,IAAM,EAAc,GAAgB,CAG9B,EAAa,GAAO,EAAQ,CAElC,MAAgB,CACd,EAAW,QAAU,GACrB,CAEF,IAAM,EAA2B,MAE7B,GAAQ,UACJ,CACE,iBAAoB,EAAiC,EAAY,CACjE,oBAAuB,EAAiC,EAAY,CACpE,kBAAqB,EAAiC,EAAY,CACnE,CACD,IAAA,GACN,CAAC,EAAa,EAAO,CACtB,CAEK,EAAM,MAER,IAAIA,EAAQ,CACV,UACA,SACA,UACA,iBACA,aACA,aACA,oBACA,cACA,QAAS,EAAW,QACpB,2BACD,CAAC,CACJ,CACE,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAOD,OAFA,UAAsB,EAAI,SAAS,CAAE,CAAC,EAAI,CAAC,CAEpC,GAAC,EAAe,SAAhB,CAAyB,MAAO,EAAM,WAAmC,CAAA,CAalF,SAAgB,GAAsB,CACpC,IAAM,EAAU,GAAW,EAAe,CAE1C,GAAI,CAAC,EACH,MAAU,MACR,kIAED,CAGH,OAAO,EC1IT,SAAgB,IAAa,CAE3B,OAAO,EAAiDC,GAD5C,G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amaSDK","encryptMutationOptions","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","userDecryptQueryOptions","useQuery","publicDecryptMutationOptions","generateKeypairMutationOptions","createEIP712MutationOptions","createDelegatedUserDecryptEIP712MutationOptions","delegatedUserDecryptMutationOptions","requestZKProofVerificationMutationOptions","useQuery","publicKeyQueryOptions","useQuery","publicParamsQueryOptions","allowMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","isAllowedQueryOptions","zamaQueryKeys","revokeMutationOptions","zamaQueryKeys","revokeSessionMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","confidentialBalanceQueryOptions","useQuery","signerAddressQueryOptions","confidentialBalancesQueryOptions","zamaQueryKeys","confidentialTransferMutationOptions","confidentialTransferFromMutationOptions","confidentialApproveMutationOptions","useQuery","signerAddressQueryOptions","confidentialIsApprovedQueryOptions","useSuspenseQuery","shieldMutationOptions","unwrapMutationOptions","unwrapAllMutationOptions","finalizeUnwrapMutationOptions","unshieldMutationOptions","unshieldAllMutationOptions","resumeUnshieldMutationOptions","useQuery","signerAddressQueryOptions","underlyingAllowanceQueryOptions","useSuspenseQuery","useQuery","zamaQueryKeys","wrapperDiscoveryQueryOptions","useQuery","useSuspenseQuery","useQuery","tokenMetadataQueryOptions","useSuspenseQuery","useQuery","activityFeedQueryOptions","delegateDecryptionMutationOptions","zamaQueryKeys","revokeDelegationMutationOptions","zamaQueryKeys","delegationStatusQueryOptions","useQuery","decryptBalanceAsMutationOptions","batchDecryptBalancesAsMutationOptions","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","listPairsQueryOptions"],"sources":["../src/provider.tsx","../src/relayer/use-encrypt.ts","../src/utils/query.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/authorization/use-allow.ts","../src/authorization/use-is-allowed.ts","../src/authorization/use-revoke.ts","../src/authorization/use-revoke-session.ts","../src/token/use-token.ts","../src/token/use-readonly-token.ts","../src/balance/use-confidential-balance.ts","../src/balance/use-confidential-balances.ts","../src/balance/optimistic-balance-update.ts","../src/transfer/use-confidential-transfer.ts","../src/transfer/use-confidential-transfer-from.ts","../src/transfer/use-confidential-approve.ts","../src/transfer/use-confidential-is-approved.ts","../src/shield/use-shield.ts","../src/unwrap/use-unwrap.ts","../src/unwrap/use-unwrap-all.ts","../src/unwrap/use-finalize-unwrap.ts","../src/unshield/use-unshield.ts","../src/unshield/use-unshield-all.ts","../src/unshield/use-resume-unshield.ts","../src/shield/use-underlying-allowance.ts","../src/wrappers-registry/use-wrappers-registry-address.ts","../src/token/use-wrapper-discovery.ts","../src/token/use-metadata.ts","../src/balance/use-activity-feed.ts","../src/delegation/use-delegate-decryption.ts","../src/delegation/use-revoke-delegation.ts","../src/delegation/use-delegation-status.ts","../src/delegation/use-decrypt-balance-as.ts","../src/delegation/use-batch-decrypt-balances-as.ts","../src/shield/use-approve-underlying.ts","../src/token/use-is-confidential.ts","../src/token/use-total-supply.ts","../src/wrappers-registry/use-token-pairs-registry.ts","../src/wrappers-registry/use-token-pairs-length.ts","../src/wrappers-registry/use-token-pairs-slice.ts","../src/wrappers-registry/use-token-pair.ts","../src/wrappers-registry/use-confidential-token-address.ts","../src/wrappers-registry/use-token-address.ts","../src/wrappers-registry/use-is-confidential-token-valid.ts","../src/wrappers-registry/use-list-pairs.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n Address,\n GenericSigner,\n GenericStorage,\n RelayerSDK,\n ZamaSDKEventListener,\n} from \"@zama-fhe/sdk\";\nimport { ZamaSDK } from \"@zama-fhe/sdk\";\nimport { invalidateWalletLifecycleQueries } from \"@zama-fhe/sdk/query\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\n/** Props for {@link ZamaProvider}. */\nexport interface ZamaProviderProps extends PropsWithChildren {\n /** FHE relayer backend (RelayerWeb for browser, RelayerNode for server). */\n relayer: RelayerSDK;\n /** Wallet signer (`ViemSigner`, `EthersSigner`, or custom {@link GenericSigner}). */\n signer: GenericSigner;\n /** Credential storage backend (IndexedDBStorage for browser, MemoryStorage for tests). */\n storage: GenericStorage;\n /**\n * Session storage for wallet signatures. Defaults to in-memory (lost on reload).\n * Pass a `chrome.storage.session`-backed store for web extensions.\n */\n sessionStorage?: GenericStorage;\n /**\n * How long the ML-KEM re-encryption keypair remains valid, in seconds.\n * Default: `86400` (1 day). Must be positive — `0` is rejected.\n */\n keypairTTL?: number;\n /**\n * Controls how long session signatures (EIP-712 wallet signatures) remain valid, in seconds.\n * Default: `2592000` (30 days).\n * - `0`: never persist — every operation triggers a signing prompt (high-security mode).\n * - Positive number: seconds until the session signature expires and requires re-authentication.\n */\n sessionTTL?: number;\n /**\n * Per-chain wrappers registry address overrides, merged on top of built-in defaults.\n * Use this for custom or local chains (e.g. Hardhat) where no default registry exists.\n */\n registryAddresses?: Record<number, Address>;\n /**\n * How long cached registry results remain valid, in seconds.\n * Default: `86400` (24 hours).\n */\n registryTTL?: number;\n /** Callback invoked on SDK lifecycle events. */\n onEvent?: ZamaSDKEventListener;\n}\n\nconst ZamaSDKContext = createContext<ZamaSDK | null>(null);\n\n/**\n * Provides a {@link ZamaSDK} instance to all descendant hooks.\n *\n * @example\n * ```tsx\n * <ZamaProvider relayer={relayer} signer={signer} storage={storage}>\n * <App />\n * </ZamaProvider>\n * ```\n */\nexport function ZamaProvider({\n children,\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses,\n registryTTL,\n onEvent,\n}: ZamaProviderProps) {\n const queryClient = useQueryClient();\n\n // Stabilize onEvent so an inline arrow doesn't recreate the SDK every render.\n const onEventRef = useRef(onEvent);\n\n useEffect(() => {\n onEventRef.current = onEvent;\n });\n\n const signerLifecycleCallbacks = useMemo(\n () =>\n signer?.subscribe\n ? {\n onDisconnect: () => invalidateWalletLifecycleQueries(queryClient),\n onAccountChange: () => invalidateWalletLifecycleQueries(queryClient),\n onChainChange: () => invalidateWalletLifecycleQueries(queryClient),\n }\n : undefined,\n [queryClient, signer],\n );\n\n const sdk = useMemo(\n () =>\n new ZamaSDK({\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses,\n registryTTL,\n onEvent: onEventRef.current,\n signerLifecycleCallbacks,\n }),\n [\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n registryAddresses,\n registryTTL,\n signerLifecycleCallbacks,\n ],\n );\n\n // Clean up signer subscriptions on unmount without terminating the\n // caller-owned relayer. dispose() only unsubscribes from wallet events\n // and is idempotent.\n useEffect(() => () => sdk.dispose(), [sdk]);\n\n return <ZamaSDKContext.Provider value={sdk}>{children}</ZamaSDKContext.Provider>;\n}\n\n/**\n * Access the {@link ZamaSDK} instance from context.\n * Throws if called outside a {@link ZamaProvider} or when no signer is provided.\n *\n * @example\n * ```tsx\n * const sdk = useZamaSDK();\n * const token = sdk.createReadonlyToken(\"0x...\");\n * ```\n */\nexport function useZamaSDK(): ZamaSDK {\n const context = useContext(ZamaSDKContext);\n\n if (!context) {\n throw new Error(\n \"useZamaSDK must be used within a <ZamaProvider>. \" +\n \"Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.\",\n );\n }\n\n return context;\n}\n","\"use client\";\n\nimport type { EncryptParams, EncryptResult } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { encryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Encrypt a plaintext value using FHE.\n * Calls the relayer's `encrypt` method via a mutation.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link EncryptionFailedError} — FHE encryption failed\n *\n * @returns A mutation whose `mutate` accepts {@link EncryptParams}.\n *\n * @example\n * ```tsx\n * const encrypt = useEncrypt();\n * encrypt.mutate({ values: [{ value: 1000n, type: \"euint64\" }], contractAddress: \"0x...\", userAddress: \"0x...\" });\n * ```\n */\nexport function useEncrypt() {\n const sdk = useZamaSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(sdk));\n}\n","import {\n type DefaultError,\n type QueriesOptions,\n type QueriesResults,\n useQueries as tanstack_useQueries,\n useQuery as tanstack_useQuery,\n useSuspenseQuery as tanstack_useSuspenseQuery,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryOptions,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\n\n/**\n * Thin wrapper around TanStack's useQuery that injects our custom queryKeyHashFn.\n * Mirrors the wagmi pattern — the type safety boundary is at the factory and hook levels.\n *\n * Callers typically specify only `<TData>` (e.g. `useQuery<PublicKeyData>(...)`) while\n * factory options carry specific tuple keys (e.g. `readonly [\"zama.publicKey\"]`).\n * We erase the QueryKey param via `AnyKeyQueryOptions` so callers don't need to\n * spell out the key type — any QueryKey subtype is accepted.\n */\ntype AnyKeyQueryOptions<TData, TError> = UseQueryOptions<\n TData,\n TError,\n TData,\n // oxlint-disable-next-line typescript/no-explicit-any\n any\n>;\ntype AnyKeySuspenseOptions<TData, TError> = UseSuspenseQueryOptions<\n TData,\n TError,\n TData,\n // oxlint-disable-next-line typescript/no-explicit-any\n any\n>;\n\nexport function useQuery<TData = unknown, TError = DefaultError>(\n options: AnyKeyQueryOptions<TData, TError>,\n): UseQueryResult<TData, TError> {\n return tanstack_useQuery({\n ...options,\n queryKeyHashFn: hashFn,\n });\n}\n\nexport function useSuspenseQuery<TData = unknown, TError = DefaultError>(\n options: AnyKeySuspenseOptions<TData, TError>,\n): UseSuspenseQueryResult<TData, TError> {\n return tanstack_useSuspenseQuery({\n ...options,\n queryKeyHashFn: hashFn,\n });\n}\n\n/**\n * Thin wrapper around TanStack's useQueries that injects our custom queryKeyHashFn\n * on every query in the array.\n */\nexport function useQueries<\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>({\n queries,\n ...options\n}: {\n queries: readonly [...QueriesOptions<T>];\n combine?: (result: QueriesResults<T>) => TCombinedResult;\n subscribed?: boolean;\n}): TCombinedResult {\n return tanstack_useQueries({\n ...options,\n queries: queries.map((q) => ({\n ...q,\n queryKeyHashFn: hashFn,\n })) as [...QueriesOptions<T>],\n });\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { DecryptResult, UserDecryptQueryConfig } from \"@zama-fhe/sdk/query\";\nimport { userDecryptQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\n\n/**\n * React hook for FHE user decryption. Thin wrapper around\n * `userDecryptQueryOptions` with `useQuery` semantics.\n */\nexport function useUserDecrypt(\n config: UserDecryptQueryConfig,\n options?: Omit<UseQueryOptions<DecryptResult>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const queryOpts = userDecryptQueryOptions(sdk, config);\n return useQuery<DecryptResult>({\n ...queryOpts,\n ...options,\n enabled: queryOpts.enabled && (options?.enabled ?? false),\n });\n}\n\n/** Return type of {@link useUserDecrypt}. */\nexport type UseUserDecryptResult = ReturnType<typeof useUserDecrypt>;\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Handle, PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { publicDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using the network public key (no credential needed).\n * On success, results are available via `data.clearValues` and written to the\n * persistent decrypt cache.\n *\n * @returns A mutation whose `mutate` accepts an array of handle strings.\n *\n * @example\n * ```tsx\n * const publicDecrypt = usePublicDecrypt();\n * publicDecrypt.mutate([\"0xHandle1\", \"0xHandle2\"]);\n * // publicDecrypt.data?.clearValues => { \"0xHandle1\": 500n, ... }\n * ```\n */\nexport function usePublicDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<PublicDecryptResult, Error, Handle[]>(publicDecryptMutationOptions(sdk));\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { generateKeypairMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Generate an FHE keypair via the relayer.\n * Returns a public/private key pair for use in decrypt authorization.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link RelayerRequestFailedError} — relayer keypair generation request failed\n *\n * @returns A mutation whose `mutate` takes no parameters.\n *\n * @example\n * ```tsx\n * const generateKeypair = useGenerateKeypair();\n * generateKeypair.mutate();\n * // generateKeypair.data?.publicKey, generateKeypair.data?.privateKey\n * ```\n */\nexport function useGenerateKeypair() {\n const sdk = useZamaSDK();\n return useMutation(generateKeypairMutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { EIP712TypedData } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { createEIP712MutationOptions } from \"@zama-fhe/sdk/query\";\nimport type { CreateEIP712Params } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type { CreateEIP712Params };\n\n/**\n * Create EIP-712 typed data for signing an FHE decrypt credential.\n * The returned typed data is signed by the wallet to authorize decryption.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateEIP712() {\n const sdk = useZamaSDK();\n return useMutation<EIP712TypedData, Error, CreateEIP712Params>(createEIP712MutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { KmsDelegatedUserDecryptEIP712Type } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { createDelegatedUserDecryptEIP712MutationOptions } from \"@zama-fhe/sdk/query\";\nimport type { CreateDelegatedUserDecryptEIP712Params } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport type { CreateDelegatedUserDecryptEIP712Params };\n\n/**\n * Create EIP-712 typed data for a delegated user decrypt credential.\n * Used when one wallet authorizes another to decrypt on its behalf.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateDelegatedUserDecryptEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateDelegatedUserDecryptEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * delegatorAddress: \"0xDelegator\",\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateDelegatedUserDecryptEIP712() {\n const sdk = useZamaSDK();\n return useMutation<\n KmsDelegatedUserDecryptEIP712Type,\n Error,\n CreateDelegatedUserDecryptEIP712Params\n >(createDelegatedUserDecryptEIP712MutationOptions(sdk));\n}\n","\"use client\";\n\nimport type { DelegatedUserDecryptParams, ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { delegatedUserDecryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using delegated user credentials.\n * Returns a map of handle → plaintext bigint.\n *\n * @returns A mutation whose `mutate` accepts {@link DelegatedUserDecryptParams}.\n *\n * @example\n * ```tsx\n * const decrypt = useDelegatedUserDecrypt();\n * decrypt.mutate({ handles: [\"0xHandle1\"], ...credentials });\n * // decrypt.data => { \"0xHandle1\": 1000n }\n * ```\n */\nexport function useDelegatedUserDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<Record<Handle, ClearValueType>, Error, DelegatedUserDecryptParams>(\n delegatedUserDecryptMutationOptions(sdk),\n );\n}\n","\"use client\";\n\nimport type { InputProofBytesType, ZKProofLike } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { requestZKProofVerificationMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Submit a ZK proof for on-chain verification.\n * Returns the input proof bytes for use in contract calls.\n *\n * @returns A mutation whose `mutate` accepts a {@link ZKProofLike}.\n *\n * @example\n * ```tsx\n * const verify = useRequestZKProofVerification();\n * verify.mutate(zkProof);\n * // verify.data => Uint8Array (input proof bytes)\n * ```\n */\nexport function useRequestZKProofVerification() {\n const sdk = useZamaSDK();\n return useMutation<InputProofBytesType, Error, ZKProofLike>(\n requestZKProofVerificationMutationOptions(sdk),\n );\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { publicKeyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicKeyQueryOptions };\n\n/** Shape of the FHE public key data returned by the relayer. */\nexport interface PublicKeyData {\n /** Unique identifier for this public key version. */\n publicKeyId: string;\n /** The raw FHE public key bytes. */\n publicKey: Uint8Array;\n}\n\n/**\n * Fetch the FHE network public key from the relayer.\n * Cached indefinitely since the key does not change during a session.\n *\n * @returns Query result with `data: PublicKeyData | null`.\n *\n * @example\n * ```tsx\n * const { data: publicKey } = usePublicKey();\n * // publicKey?.publicKeyId, publicKey?.publicKey\n * ```\n */\nexport function usePublicKey() {\n const sdk = useZamaSDK();\n return useQuery<PublicKeyData | null>(publicKeyQueryOptions(sdk));\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { publicParamsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicParamsQueryOptions };\n\n/** Shape of the FHE public parameters returned by the relayer. */\nexport interface PublicParamsData {\n /** The raw public parameters bytes (WASM-ready). */\n publicParams: Uint8Array;\n /** Unique identifier for this public params version. */\n publicParamsId: string;\n}\n\n/**\n * Fetch FHE public parameters for a given bit size from the relayer.\n * Cached indefinitely since parameters do not change during a session.\n *\n * @param bits - The FHE bit size to fetch parameters for (e.g. 2048).\n * @returns Query result with `data: PublicParamsData | null`.\n *\n * @example\n * ```tsx\n * const { data: params } = usePublicParams(2048);\n * // params?.publicParams, params?.publicParamsId\n * ```\n */\nexport function usePublicParams(bits: number) {\n const sdk = useZamaSDK();\n return useQuery<PublicParamsData | null>(publicParamsQueryOptions(sdk, bits));\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { allowMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Sign an EIP-712 message authorizing decryption of confidential handles\n * for a list of contract addresses. This is not token-specific — any\n * contract that uses FHE-encrypted values (tokens, DeFi vaults, games, etc.)\n * can be authorized in a single wallet signature. Subsequent decrypt\n * operations on any of these contracts reuse cached credentials.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link KeypairExpiredError} — the re-encryption keypair has expired\n *\n * @example\n * ```tsx\n * const { mutateAsync: allow, isPending } = useAllow();\n *\n * // Authorize decryption for any contracts with encrypted state:\n * // confidential tokens, auction contracts, governance contracts, etc.\n * await allow([tokenAddress, auctionAddress, governanceAddress]);\n * ```\n */\nexport function useAllow(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...allowMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n void context.client.invalidateQueries({\n queryKey: zamaQueryKeys.isAllowed.all,\n });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { skipToken } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n isAllowedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Configuration for {@link useIsAllowed}. */\nexport interface UseIsAllowedConfig {\n /** Contract addresses to check credentials against (at least one required). */\n contractAddresses: [Address, ...Address[]];\n}\n\n/**\n * Check whether a session signature is cached for the connected wallet\n * and covers the given contract addresses.\n * Returns `true` if decrypt operations can proceed without a wallet prompt.\n *\n * @example\n * ```tsx\n * const { data: allowed } = useIsAllowed({ contractAddresses: [\"0xToken\"] });\n * ```\n */\nexport function useIsAllowed(config: UseIsAllowedConfig) {\n const sdk = useZamaSDK();\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n const account = addressQuery.data;\n const baseOpts = account\n ? isAllowedQueryOptions(sdk, { account, contractAddresses: config.contractAddresses })\n : ({\n queryKey: zamaQueryKeys.isAllowed.all,\n queryFn: skipToken,\n enabled: false,\n } as const);\n\n return useQuery<boolean>(baseOpts);\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { revokeMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke stored FHE decrypt credentials for a list of contract addresses.\n * This is not token-specific — it revokes the EIP-712 authorization for\n * any contract that uses FHE-encrypted values. The next decrypt operation\n * on these contracts will require a fresh wallet signature.\n *\n * @example\n * ```tsx\n * const { mutate: revoke } = useRevoke();\n *\n * // Revoke for any contracts: tokens, auctions, governance, etc.\n * revoke([tokenAddress, auctionAddress]);\n * ```\n */\nexport function useRevoke(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...revokeMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.removeQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n context.client.removeQueries({ queryKey: zamaQueryKeys.decryption.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { revokeSessionMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke the session signature for the connected wallet without\n * specifying contract addresses. Useful for wallet disconnect handlers.\n *\n * @example\n * ```tsx\n * const { mutate: revokeSession } = useRevokeSession();\n * revokeSession();\n * ```\n */\nexport function useRevokeSession(options?: UseMutationOptions<void>) {\n const sdk = useZamaSDK();\n\n return useMutation<void>({\n ...revokeSessionMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.removeQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n context.client.removeQueries({ queryKey: zamaQueryKeys.decryption.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Base configuration shared by all mutation hooks that need a Token instance. */\nexport interface UseZamaConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Address of the wrapper contract (required for shield/unshield operations). */\n wrapperAddress?: Address;\n}\n\n/**\n * Get a {@link Token} instance, memoized by address pair.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param config - Token and optional wrapper addresses.\n * @returns A memoized `Token` instance.\n *\n * @example\n * ```tsx\n * const token = useToken({ tokenAddress: \"0xToken\", wrapperAddress: \"0xWrapper\" });\n * ```\n */\nexport function useToken(config: UseZamaConfig) {\n const sdk = useZamaSDK();\n\n return useMemo(\n () => sdk.createToken(config.tokenAddress, config.wrapperAddress),\n [sdk, config.tokenAddress, config.wrapperAddress],\n );\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Get a {@link ReadonlyToken} instance, memoized by address.\n * Supports balance queries, ERC-165 checks, and authorization — no wrapper needed.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param address - Address of the confidential token contract.\n * @returns A memoized `ReadonlyToken` instance.\n *\n * @example\n * ```tsx\n * const token = useReadonlyToken(\"0xToken\");\n * // token.balanceOf(), token.isConfidential(), etc.\n * ```\n */\nexport function useReadonlyToken(address: Address) {\n const sdk = useZamaSDK();\n\n return useMemo(() => sdk.createReadonlyToken(address), [sdk, address]);\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialBalanceQueryOptions, signerAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\nimport { useQuery } from \"../utils/query\";\n\n/** Configuration for {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n}\n\n/** Query options for {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceOptions extends Omit<\n UseQueryOptions<bigint>,\n \"queryKey\" | \"queryFn\" | \"enabled\"\n> {\n /** Whether the query is enabled. Callback form is not supported in composite hooks. */\n enabled?: boolean;\n}\n\n/**\n * Declarative hook to read the connected wallet's confidential token balance.\n * Calls `token.balanceOf(owner)` which reads the on-chain handle and decrypts\n * via the SDK. Cached values are returned instantly — the relayer is only hit\n * when the handle changes.\n *\n * @param config - Token address configuration.\n * @param options - React Query options forwarded to the balance query.\n * @returns The balance query result.\n *\n * @example\n * ```tsx\n * const { data: balance, isLoading } = useConfidentialBalance({\n * tokenAddress: \"0x...\",\n * });\n * ```\n */\nexport function useConfidentialBalance(\n config: UseConfidentialBalanceConfig,\n options?: UseConfidentialBalanceOptions,\n) {\n const { tokenAddress } = config;\n const { enabled = true } = options ?? {};\n const sdk = useZamaSDK();\n const token = useReadonlyToken(tokenAddress);\n\n const addressQuery = useQuery<Address>(signerAddressQueryOptions(sdk.signer));\n\n const owner = addressQuery.data;\n\n const baseOptions = confidentialBalanceQueryOptions(token, {\n tokenAddress,\n owner,\n });\n\n return useQuery<bigint>({\n ...baseOptions,\n ...options,\n enabled: baseOptions.enabled && enabled,\n });\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport { useQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, BatchBalancesResult } from \"@zama-fhe/sdk\";\nimport { confidentialBalancesQueryOptions, signerAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Configuration for {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesConfig {\n /** Addresses of the confidential token contracts to batch-query. */\n tokenAddresses: Address[];\n}\n\n/** Query options for {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesOptions extends Omit<\n UseQueryOptions<BatchBalancesResult>,\n \"queryKey\" | \"queryFn\" | \"enabled\"\n> {\n /** Whether the query is enabled. Callback form is not supported in composite hooks. */\n enabled?: boolean;\n}\n\n/**\n * Declarative hook to read multiple confidential token balances in batch.\n * Calls `ReadonlyToken.batchBalancesOf()` which decrypts each token via the\n * SDK. Cached values are returned instantly — the relayer is only hit for\n * changed handles.\n *\n * Returns partial results when some tokens fail — successful balances are\n * always returned alongside per-token error information.\n *\n * @param config - Token addresses configuration.\n * @param options - React Query options forwarded to the balance query.\n * @returns The balance query result.\n *\n * @example\n * ```tsx\n * const { data } = useConfidentialBalances({\n * tokenAddresses: [\"0xTokenA\", \"0xTokenB\"],\n * });\n * const balance = data?.results.get(\"0xTokenA\");\n * if (data && data.errors.size > 0) {\n * // some tokens failed — check data.errors\n * }\n * ```\n */\nexport function useConfidentialBalances(\n config: UseConfidentialBalancesConfig,\n options?: UseConfidentialBalancesOptions,\n) {\n const { tokenAddresses } = config;\n const { enabled = true } = options ?? {};\n const sdk = useZamaSDK();\n\n const addressQuery = useQuery<Address>(signerAddressQueryOptions(sdk.signer));\n\n const owner = addressQuery.data;\n\n const tokens = useMemo(\n () => tokenAddresses.map((addr) => sdk.createReadonlyToken(addr)),\n [sdk, tokenAddresses],\n );\n\n const baseOptions = confidentialBalancesQueryOptions(tokens, {\n owner,\n });\n\n return useQuery<BatchBalancesResult>({\n ...baseOptions,\n ...options,\n enabled: (baseOptions.enabled ?? true) && enabled,\n });\n}\n","import type { QueryClient, QueryKey, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterShield, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\n\ntype BalanceDeltaMode = \"add\" | \"subtract\";\nexport type OptimisticBalanceSnapshot = [QueryKey, bigint | undefined][];\n\n/** Combined context returned by optimistic `onMutate`. */\nexport interface OptimisticMutateContext {\n snapshot: OptimisticBalanceSnapshot;\n callerContext?: unknown;\n}\n\nexport function unwrapOptimisticCallerContext(\n optimistic: boolean | undefined,\n rawContext: unknown,\n): {\n wrappedContext: OptimisticMutateContext | undefined;\n callerContext: OptimisticMutateContext | undefined;\n} {\n const typed = rawContext as OptimisticMutateContext | undefined;\n const wrappedContext = optimistic ? typed : undefined;\n const callerContext = (optimistic ? wrappedContext?.callerContext : rawContext) as\n | OptimisticMutateContext\n | undefined;\n return { wrappedContext, callerContext };\n}\n\nexport async function applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount,\n mode,\n}: {\n queryClient: QueryClient;\n tokenAddress: Address;\n amount: bigint;\n mode: BalanceDeltaMode;\n}): Promise<OptimisticBalanceSnapshot> {\n const balanceKey = zamaQueryKeys.confidentialBalance.token(tokenAddress);\n await queryClient.cancelQueries({ queryKey: balanceKey });\n const previous = queryClient.getQueriesData<bigint>({ queryKey: balanceKey });\n for (const [key, value] of previous) {\n if (value === undefined) {\n continue;\n }\n // Temporary optimistic underflow (`amount > value`) is acceptable because\n // settlement invalidates and rewrites this cache entry.\n queryClient.setQueryData(key, mode === \"add\" ? value + amount : value - amount);\n }\n return previous;\n}\n\nexport function rollbackOptimisticBalanceDelta(\n queryClient: QueryClient,\n snapshot: OptimisticBalanceSnapshot,\n) {\n for (const [key, value] of snapshot) {\n queryClient.setQueryData(key, value);\n }\n}\n\n/**\n * Build optimistic mutation callbacks for shield operations.\n * Wraps the caller's `onMutate`/`onError`/`onSuccess`/`onSettled` with snapshot/rollback logic\n * and returns overrides ready to spread into `useMutation`.\n */\nexport function optimisticBalanceCallbacks<TParams extends { amount: bigint }>({\n optimistic,\n tokenAddress,\n queryClient,\n options,\n}: {\n optimistic: boolean | undefined;\n tokenAddress: Address;\n queryClient: QueryClient;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: UseMutationOptions<TransactionResult, Error, TParams, any> | undefined;\n}): Pick<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n UseMutationOptions<TransactionResult, Error, TParams, any>,\n \"onMutate\" | \"onError\" | \"onSuccess\" | \"onSettled\"\n> {\n return {\n onMutate: optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount: variables.amount,\n mode: \"add\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext, context);\n invalidateAfterShield(context.client, tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext, context);\n },\n };\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferParams,\n} from \"@zama-fhe/sdk/query\";\nimport {\n applyOptimisticBalanceDelta,\n rollbackOptimisticBalanceDelta,\n unwrapOptimisticCallerContext,\n} from \"../balance/optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/** Configuration for {@link useConfidentialTransfer}. */\nexport interface UseConfidentialTransferConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically subtracts the transfer amount from cached balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Encrypt and send a confidential transfer. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * Set `optimistic: true` to subtract the amount from the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transfer = useConfidentialTransfer({\n * tokenAddress: \"0x...\",\n * optimistic: true,\n * });\n * transfer.mutate(\n * { to: \"0xRecipient\", amount: 1000n },\n * {\n * onError: (error) => {\n * if (error instanceof SigningRejectedError) {\n * // user cancelled — no action needed\n * }\n * },\n * },\n * );\n * ```\n */\nexport function useConfidentialTransfer<TContext = unknown>(\n config: UseConfidentialTransferConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n // Internal mutation uses `any` for TContext because optimistic mode wraps\n // the caller's context in OptimisticMutateContext; the public return type\n // is cast back to the caller's TContext.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return useMutation<TransactionResult, Error, ConfidentialTransferParams, any>({\n ...confidentialTransferMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress: config.tokenAddress,\n amount: variables.amount,\n mode: \"subtract\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n config.optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext as TContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as TContext, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext as TContext, context);\n },\n }) as UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext>;\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferFromMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferFromParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Operator transfer on behalf of another address. Caller must be an approved operator.\n * Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the transfer amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transferFrom = useConfidentialTransferFrom({ tokenAddress: \"0x...\" });\n * transferFrom.mutate({ from: \"0xOwner\", to: \"0xRecipient\", amount: 500n });\n * ```\n */\nexport function useConfidentialTransferFrom(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferFromParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialTransferFromParams, Address>({\n ...confidentialTransferFromMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialApproveMutationOptions,\n invalidateAfterApprove,\n type ConfidentialApproveParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Set operator approval for a confidential token. Defaults to 1 hour.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useConfidentialApprove({ tokenAddress: \"0x...\" });\n * approve.mutate({ spender: \"0xOperator\" });\n * ```\n */\nexport function useConfidentialApprove(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialApproveParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialApproveParams, Address>({\n ...confidentialApproveMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApprove(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialIsApprovedQueryOptions, signerAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\nexport { confidentialIsApprovedQueryOptions };\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig {\n /** Address of the confidential token contract. Pass `undefined` to disable the query. */\n tokenAddress: Address | undefined;\n /** Address to check approval for. Pass `undefined` to disable the query. */\n spender: Address | undefined;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/** Configuration for {@link useConfidentialIsApprovedSuspense}. */\nexport interface UseConfidentialIsApprovedSuspenseConfig extends UseZamaConfig {\n /** Address to check approval for. */\n spender: Address;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/**\n * Check if a spender is an approved operator for a given holder (defaults to connected wallet).\n *\n * @param config - Token address, spender, and optional holder to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApproved({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApproved(\n config: UseConfidentialIsApprovedConfig,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, spender, holder } = config;\n const sdk = useZamaSDK();\n const holderQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n enabled: tokenAddress !== undefined && spender !== undefined && holder === undefined,\n });\n const resolvedHolder = holder ?? holderQuery.data;\n const baseOpts = confidentialIsApprovedQueryOptions(sdk.signer, tokenAddress, {\n holder: resolvedHolder,\n spender,\n });\n\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useConfidentialIsApproved}.\n * Suspends rendering until the approval check resolves.\n *\n * @param config - Token address, spender, and optional holder to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApprovedSuspense({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig) {\n const { spender, holder, ...tokenConfig } = config;\n const sdk = useZamaSDK();\n const token = useToken(tokenConfig);\n const addressQuery = useSuspenseQuery<Address>(signerAddressQueryOptions(sdk.signer));\n const resolvedHolder = holder ?? addressQuery.data;\n\n return useSuspenseQuery<boolean>(\n confidentialIsApprovedQueryOptions(sdk.signer, token.address, {\n holder: resolvedHolder,\n spender,\n }),\n );\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport { shieldMutationOptions, type ShieldParams } from \"@zama-fhe/sdk/query\";\nimport { optimisticBalanceCallbacks } from \"../balance/optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/** Configuration for {@link useShield}. */\nexport interface UseShieldConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield public ERC-20 tokens into confidential tokens.\n * Handles ERC-20 approval automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link ApprovalFailedError} — ERC-20 approval transaction failed\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shield = useShield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shield.mutate({ amount: 1000n });\n * ```\n */\nexport function useShield<TContext = unknown>(\n config: UseShieldConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ShieldParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation({\n ...shieldMutationOptions(token),\n ...options,\n ...optimisticBalanceCallbacks({\n optimistic: config.optimistic,\n tokenAddress: config.tokenAddress,\n queryClient,\n options,\n }),\n }) as UseMutationResult<TransactionResult, Error, ShieldParams, TContext>;\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnwrap,\n type UnwrapParams,\n unwrapMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Request an unwrap for a specific amount. Encrypts the amount first.\n * Call {@link useFinalizeUnwrap} after the request is processed on-chain,\n * or use {@link useUnshield} for a single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the unwrap amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrap = useUnwrap({ tokenAddress: \"0x...\" });\n * unwrap.mutate({ amount: 500n });\n * ```\n */\nexport function useUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnwrapParams, Address>({\n ...unwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterUnwrap, unwrapAllMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Request an unwrap for the entire confidential balance.\n * Uses the on-chain balance handle directly (no encryption needed).\n * Call {@link useFinalizeUnwrap} after processing, or use {@link useUnshieldAll} for single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrapAll = useUnwrapAll({ tokenAddress: \"0x...\" });\n * unwrapAll.mutate();\n * ```\n */\nexport function useUnwrapAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, void, Address>({\n ...unwrapAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n finalizeUnwrapMutationOptions,\n invalidateAfterUnshield,\n type FinalizeUnwrapParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Complete an unwrap by providing the public decryption proof.\n * Call this after an unwrap request has been processed on-chain.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption of the burn amount failed\n * - {@link TransactionRevertedError} — on-chain finalize transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const finalize = useFinalizeUnwrap({ tokenAddress: \"0x...\" });\n * finalize.mutate({ burnAmountHandle: event.encryptedAmount });\n * ```\n */\nexport function useFinalizeUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, FinalizeUnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, FinalizeUnwrapParams, Address>({\n ...finalizeUnwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldParams,\n unshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Unshield a specific amount and finalize in one call.\n * Orchestrates: unwrap → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed during unwrap\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshield = useUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshield.mutate({ amount: 500n });\n * ```\n */\nexport function useUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldParams, Address>({\n ...unshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldAllParams,\n unshieldAllMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Unshield the entire balance and finalize in one call.\n * Orchestrates: unwrapAll → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshieldAll = useUnshieldAll({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshieldAll.mutate();\n * ```\n */\nexport function useUnshieldAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldAllParams | void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldAllParams | void, Address>({\n ...unshieldAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type ResumeUnshieldParams,\n resumeUnshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Resume an interrupted unshield from an existing unwrap tx hash.\n * Useful when the user submitted the unwrap but the finalize step was\n * interrupted (e.g. page reload, network error).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const resumeUnshield = useResumeUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * resumeUnshield.mutate({ unwrapTxHash: \"0xabc...\" });\n * ```\n */\nexport function useResumeUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ResumeUnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ResumeUnshieldParams, Address>({\n ...resumeUnshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { signerAddressQueryOptions, underlyingAllowanceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { underlyingAllowanceQueryOptions };\n\n/** Configuration for {@link useUnderlyingAllowance}. */\nexport interface UseUnderlyingAllowanceConfig {\n /** Address of the confidential token contract used to scope the query cache. */\n tokenAddress: Address;\n /** Address of the wrapper contract whose underlying ERC-20 allowance is checked. */\n wrapperAddress: Address;\n}\n\n/**\n * Read the underlying ERC-20 allowance granted to the wrapper contract.\n * Useful to check if an approval is needed before shielding.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (current allowance).\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowance({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowance(\n config: UseUnderlyingAllowanceConfig,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, wrapperAddress } = config;\n const sdk = useZamaSDK();\n const addressQuery = useQuery<Address>(signerAddressQueryOptions(sdk.signer));\n const owner = addressQuery.data;\n\n const baseOpts = underlyingAllowanceQueryOptions(sdk.signer, tokenAddress, {\n owner,\n wrapperAddress,\n });\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useUnderlyingAllowance}.\n * Suspends rendering until the allowance is loaded.\n *\n * @param config - Token and wrapper addresses.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowanceSuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowanceSuspense(config: UseUnderlyingAllowanceConfig) {\n const { tokenAddress, wrapperAddress } = config;\n const sdk = useZamaSDK();\n const addressQuery = useSuspenseQuery<Address>(signerAddressQueryOptions(sdk.signer));\n const owner = addressQuery.data;\n\n return useSuspenseQuery<bigint>(\n underlyingAllowanceQueryOptions(sdk.signer, tokenAddress, {\n owner,\n wrapperAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\n\n/**\n * Resolves the wrappers registry address for the current chain.\n * Uses the merged registry addresses from `sdk.registry` (built-in defaults\n * plus any `registryAddresses` overrides passed to `ZamaSDKConfig`).\n *\n * Returns `undefined` when the chain ID hasn't been fetched yet\n * or when no registry is configured for the connected chain.\n *\n * The chain ID is cached for 30 seconds (`staleTime`), so chain\n * switches may take up to 30s to reflect.\n */\nexport function useWrappersRegistryAddress(): Address | undefined {\n const sdk = useZamaSDK();\n\n const { data: chainId } = useQuery<number>({\n queryKey: zamaQueryKeys.wrappersRegistry.chainId(),\n queryFn: () => sdk.signer.getChainId(),\n staleTime: 30_000,\n });\n\n return chainId !== undefined ? sdk.registry.getAddress(chainId) : undefined;\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { wrapperDiscoveryQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"../wrappers-registry/use-wrappers-registry-address\";\n\nexport { wrapperDiscoveryQueryOptions };\n\n/** Configuration for {@link useWrapperDiscovery}. */\nexport interface UseWrapperDiscoveryConfig {\n /**\n * Address of any confidential token you control.\n * Used only to derive the signer context and to scope the query cache key —\n * it does not affect which wrapper the registry returns.\n */\n tokenAddress: Address;\n /** ERC-20 address to discover the wrapper for. Pass `undefined` to disable the query. */\n erc20Address: Address | undefined;\n}\n\n/** Configuration for {@link useWrapperDiscoverySuspense}. */\nexport interface UseWrapperDiscoverySuspenseConfig {\n /**\n * Address of any confidential token you control.\n * Used only to derive the signer context and to scope the query cache key —\n * it does not affect which wrapper the registry returns.\n */\n tokenAddress: Address;\n /** ERC-20 address to discover the wrapper for. */\n erc20Address: Address;\n}\n\n/**\n * Discover the confidential wrapper for an ERC-20 token via the on-chain registry.\n * Returns the wrapper address if one exists, or `null` if not.\n * Cached indefinitely since wrapper mappings are immutable.\n *\n * @param config - Token and ERC-20 addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscovery({\n * tokenAddress: \"0xConfidentialToken\",\n * erc20Address: \"0xUSDC\",\n * });\n * ```\n */\nexport function useWrapperDiscovery(\n config: UseWrapperDiscoveryConfig,\n options?: Omit<UseQueryOptions<Address | null>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, erc20Address } = config;\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n const baseOpts = wrapperDiscoveryQueryOptions(sdk.registry, {\n tokenAddress,\n erc20Address,\n registryAddress,\n });\n\n return useQuery<Address | null>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useWrapperDiscovery}.\n * Suspends rendering until the wrapper address is resolved.\n *\n * @param config - Token and ERC-20 addresses.\n * @returns Suspense query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscoverySuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * erc20Address: \"0xUSDC\",\n * });\n * ```\n */\nexport function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig) {\n const { tokenAddress, erc20Address } = config;\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useSuspenseQuery<Address | null>(\n wrapperDiscoveryQueryOptions(sdk.registry, {\n tokenAddress,\n erc20Address,\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenMetadataQueryOptions, type TokenMetadata } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\n\nexport { type TokenMetadata };\n\n/**\n * Read ERC-20 token metadata (name, symbol, decimals).\n * Fetches all three in parallel. Cached indefinitely since metadata is immutable.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadata(\"0xToken\");\n * // metadata?.name, metadata?.symbol, metadata?.decimals\n * ```\n */\nexport function useMetadata(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<TokenMetadata>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n return useQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(sdk.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useMetadata}.\n * Suspends rendering until metadata is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadataSuspense(\"0xToken\");\n * ```\n */\nexport function useMetadataSuspense(tokenAddress: Address) {\n const sdk = useZamaSDK();\n return useSuspenseQuery<TokenMetadata>(tokenMetadataQueryOptions(sdk.signer, tokenAddress));\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { Address, RawLog, ActivityLogMetadata, ActivityItem } from \"@zama-fhe/sdk\";\nimport { activityFeedQueryOptions, deriveActivityFeedLogsKey } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\n\n/** Configuration for {@link useActivityFeed}. */\nexport interface UseActivityFeedConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Connected wallet address. Pass `undefined` to disable the query. */\n userAddress: Address | undefined;\n /** Raw event logs from the provider (viem, ethers, etc.). Pass `undefined` to disable. */\n logs: readonly (RawLog & Partial<ActivityLogMetadata>)[] | undefined;\n /** Whether to batch-decrypt encrypted transfer amounts. Default: `true`. */\n decrypt?: boolean;\n}\n\n/**\n * Two-phase activity feed hook.\n * Phase 1: Instantly parses raw logs into classified {@link ActivityItem}s (sync, cheap).\n * Phase 2: Batch-decrypts encrypted transfer amounts via the relayer (async).\n *\n * The wallet provides logs (from its own provider — viem, ethers, etc.)\n * and this hook normalizes + decrypts them.\n *\n * @param config - Token address, user address, raw logs, and decrypt option.\n * @returns Query result with `data: ActivityItem[]`.\n *\n * @example\n * ```tsx\n * const { data: activity } = useActivityFeed({\n * tokenAddress: \"0xToken\",\n * userAddress: \"0xUser\",\n * logs: rawLogs,\n * });\n * ```\n */\nexport function useActivityFeed(config: UseActivityFeedConfig) {\n const { tokenAddress, userAddress, logs, decrypt: decryptOpt } = config;\n const token = useReadonlyToken(tokenAddress);\n const decrypt = decryptOpt ?? true;\n const logsKey = deriveActivityFeedLogsKey(logs);\n\n return useQuery<ActivityItem[]>(\n activityFeedQueryOptions(token, {\n userAddress,\n logs,\n decrypt,\n logsKey,\n }),\n );\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n delegateDecryptionMutationOptions,\n zamaQueryKeys,\n type DelegateDecryptionParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Delegate FHE decryption rights for a token to another address via the on-chain ACL.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const delegate = useDelegateDecryption({ tokenAddress: \"0x...\" });\n * delegate.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useDelegateDecryption(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, DelegateDecryptionParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, DelegateDecryptionParams>({\n ...delegateDecryptionMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n try {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n } finally {\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n revokeDelegationMutationOptions,\n zamaQueryKeys,\n type RevokeDelegationParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Revoke FHE decryption delegation for a token from a delegate address.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const revoke = useRevokeDelegation({ tokenAddress: \"0x...\" });\n * revoke.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useRevokeDelegation(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, RevokeDelegationParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, RevokeDelegationParams>({\n ...revokeDelegationMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n try {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n } finally {\n void context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n }\n },\n });\n}\n","\"use client\";\n\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { delegationStatusQueryOptions, type DelegationStatusData } from \"@zama-fhe/sdk/query\";\nimport { useQuery } from \"../utils/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport interface UseDelegationStatusConfig {\n /** Address of the confidential token contract. Pass `undefined` to disable the query. */\n tokenAddress: Address | undefined;\n /** The address that granted the delegation. */\n delegatorAddress?: Address;\n /** The address that received delegation rights. */\n delegateAddress?: Address;\n}\n\n/**\n * Query delegation status between a delegator and delegate for a token.\n *\n * @param config - Token address, delegator, and delegate addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns `{ isDelegated, expiryTimestamp, isLoading, error }`.\n *\n * @example\n * ```tsx\n * const { data } = useDelegationStatus({\n * tokenAddress: \"0xToken\",\n * delegatorAddress: \"0xDelegator\",\n * delegateAddress: \"0xDelegate\",\n * });\n * // data?.isDelegated, data?.expiryTimestamp\n * ```\n */\nexport function useDelegationStatus(\n config: UseDelegationStatusConfig,\n options?: Omit<UseQueryOptions<DelegationStatusData>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = delegationStatusQueryOptions(sdk, config);\n\n return useQuery<DelegationStatusData>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { decryptBalanceAsMutationOptions, type DecryptBalanceAsParams } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"../token/use-readonly-token\";\n\n/**\n * Decrypt another user's confidential balance as a delegate.\n *\n * @param tokenAddress - Address of the confidential token contract.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const decryptAs = useDecryptBalanceAs(\"0xToken\");\n * decryptAs.mutate({ delegatorAddress: \"0xDelegator\" });\n * // decryptAs.data => 1000n\n * ```\n */\nexport function useDecryptBalanceAs(\n tokenAddress: Address,\n options?: UseMutationOptions<bigint, Error, DecryptBalanceAsParams>,\n) {\n const readonlyToken = useReadonlyToken(tokenAddress);\n\n return useMutation<bigint, Error, DecryptBalanceAsParams>({\n ...decryptBalanceAsMutationOptions(readonlyToken),\n ...options,\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, ReadonlyToken } from \"@zama-fhe/sdk\";\nimport {\n batchDecryptBalancesAsMutationOptions,\n type BatchDecryptBalancesAsParams,\n} from \"@zama-fhe/sdk/query\";\n\n/**\n * Batch decrypt confidential balances as a delegate across multiple tokens.\n *\n * @param tokens - ReadonlyToken instances to decrypt balances for.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const batchDecryptAs = useBatchDecryptBalancesAs(tokens);\n * batchDecryptAs.mutate({\n * delegatorAddress: \"0xDelegator\",\n * });\n * // batchDecryptAs.data => Map { \"0xTokenA\" => 100n, \"0xTokenB\" => 200n }\n * ```\n */\nexport function useBatchDecryptBalancesAs(\n tokens: ReadonlyToken[],\n options?: UseMutationOptions<Map<Address, bigint>, Error, BatchDecryptBalancesAsParams>,\n) {\n return useMutation<Map<Address, bigint>, Error, BatchDecryptBalancesAsParams>({\n ...batchDecryptBalancesAsMutationOptions(tokens),\n ...options,\n });\n}\n","\"use client\";\n\nimport type { UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n approveUnderlyingMutationOptions,\n invalidateAfterApproveUnderlying,\n type ApproveUnderlyingParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"../token/use-token\";\n\n/**\n * Approve the wrapper contract to spend the underlying ERC-20.\n * Defaults to max uint256. Resets to zero first if there's an existing\n * non-zero allowance (required by tokens like USDT).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — approval transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useApproveUnderlying({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * approve.mutate({}); // max approval\n * approve.mutate({ amount: 1000n }); // exact amount\n * ```\n */\nexport function useApproveUnderlying(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ApproveUnderlyingParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ApproveUnderlyingParams, Address>({\n ...approveUnderlyingMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApproveUnderlying(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialQueryOptions, isWrapperQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { isConfidentialQueryOptions, isWrapperQueryOptions };\n\n/**\n * Check if a token supports the ERC-7984 confidential interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidential(\"0xToken\");\n * ```\n */\nexport function useIsConfidential(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n\n return useQuery<boolean>({\n ...isConfidentialQueryOptions(sdk.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsConfidential}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidentialSuspense(\"0xToken\");\n * ```\n */\nexport function useIsConfidentialSuspense(tokenAddress: Address) {\n const sdk = useZamaSDK();\n\n return useSuspenseQuery<boolean>(isConfidentialQueryOptions(sdk.signer, tokenAddress));\n}\n\n/**\n * Check if a token supports the ERC-7984 wrapper interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapper(\"0xToken\");\n * ```\n */\nexport function useIsWrapper(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n\n return useQuery<boolean>({\n ...isWrapperQueryOptions(sdk.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsWrapper}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapperSuspense(\"0xToken\");\n * ```\n */\nexport function useIsWrapperSuspense(tokenAddress: Address) {\n const sdk = useZamaSDK();\n\n return useSuspenseQuery<boolean>(isWrapperQueryOptions(sdk.signer, tokenAddress));\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport type { UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { totalSupplyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { totalSupplyQueryOptions };\n\n/**\n * Read the total supply of a token.\n * Stale after 30 seconds to balance freshness and RPC cost.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupply(\"0xToken\");\n * ```\n */\nexport function useTotalSupply(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<bigint>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n\n return useQuery<bigint>({\n ...totalSupplyQueryOptions(sdk.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useTotalSupply}.\n * Suspends rendering until the total supply is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupplySuspense(\"0xToken\");\n * ```\n */\nexport function useTotalSupplySuspense(tokenAddress: Address) {\n const sdk = useZamaSDK();\n\n return useSuspenseQuery<bigint>(totalSupplyQueryOptions(sdk.signer, tokenAddress));\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches all token wrapper pairs from the ConfidentialTokenWrappersRegistry\n * contract on the current chain.\n */\nexport function useTokenPairsRegistry() {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly TokenWrapperPair[]>(\n tokenPairsQueryOptions(sdk.signer, {\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport { tokenPairsLengthQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Returns the total number of token wrapper pairs in the registry.\n */\nexport function useTokenPairsLength() {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<bigint>(\n tokenPairsLengthQueryOptions(sdk.signer, {\n registryAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairsSliceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches a range of token wrapper pairs from the registry (paginated).\n *\n * @param fromIndex - Start index (inclusive). Pass `undefined` to disable.\n * @param toIndex - End index (exclusive). Pass `undefined` to disable.\n */\nexport function useTokenPairsSlice({\n fromIndex,\n toIndex,\n}: {\n fromIndex: bigint | undefined;\n toIndex: bigint | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly TokenWrapperPair[]>(\n tokenPairsSliceQueryOptions(sdk.signer, {\n registryAddress,\n fromIndex,\n toIndex,\n }),\n );\n}\n","\"use client\";\n\nimport type { TokenWrapperPair } from \"@zama-fhe/sdk\";\nimport { tokenPairQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches a single token wrapper pair by index from the registry.\n *\n * @param index - Zero-based pair index. Pass `undefined` to disable.\n */\nexport function useTokenPair({ index }: { index: bigint | undefined }) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<TokenWrapperPair>(\n tokenPairQueryOptions(sdk.signer, {\n registryAddress,\n index,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { confidentialTokenAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Looks up the confidential token address for a given plain token address.\n */\nexport function useConfidentialTokenAddress({\n tokenAddress,\n}: {\n tokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly [boolean, Address]>(\n confidentialTokenAddressQueryOptions(sdk.signer, {\n registryAddress,\n tokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenAddressQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Looks up the plain token address for a given confidential token address.\n */\nexport function useTokenAddress({\n confidentialTokenAddress,\n}: {\n confidentialTokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<readonly [boolean, Address]>(\n tokenAddressQueryOptions(sdk.signer, {\n registryAddress,\n confidentialTokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialTokenValidQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Checks whether a confidential token is registered and valid in the\n * on-chain wrappers registry.\n *\n * @param confidentialTokenAddress - The confidential token to check. Pass `undefined` to disable.\n */\nexport function useIsConfidentialTokenValid({\n confidentialTokenAddress,\n}: {\n confidentialTokenAddress: Address | undefined;\n}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n return useQuery<boolean>(\n isConfidentialTokenValidQueryOptions(sdk.signer, {\n registryAddress,\n confidentialTokenAddress,\n }),\n );\n}\n","\"use client\";\n\nimport type {\n TokenWrapperPair,\n TokenWrapperPairWithMetadata,\n PaginatedResult,\n} from \"@zama-fhe/sdk\";\nimport { listPairsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\nimport { useQuery } from \"../utils/query\";\nimport { useWrappersRegistryAddress } from \"./use-wrappers-registry-address\";\n\n/**\n * Fetches paginated token wrapper pairs from the registry.\n *\n * @param options - Query options: `page` (1-indexed, default `1`), `pageSize` (default `100`), `metadata` (fetch on-chain metadata for both tokens, default `false`).\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListPairs({ page: 1, pageSize: 20 });\n * if (data) {\n * console.log(`${data.total} pairs, showing page ${data.page}`);\n * }\n * ```\n */\nexport function useListPairs({\n page = 1,\n pageSize = 100,\n metadata = false,\n}: {\n page?: number;\n pageSize?: number;\n metadata?: boolean;\n} = {}) {\n const sdk = useZamaSDK();\n const registryAddress = useWrappersRegistryAddress();\n\n // Pass sdk.registry (a lazy singleton) so the class-level TTL cache is shared\n // across all queryFn executions — rather than constructing a new instance each time.\n return useQuery<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>>(\n listPairsQueryOptions(sdk.registry, {\n registryAddress,\n page,\n pageSize,\n metadata,\n }),\n );\n}\n"],"mappings":"igNA4DA,MAAM,EAAiB,GAA8B,KAAK,CAY1D,SAAgB,GAAa,CAC3B,WACA,UACA,SACA,UACA,iBACA,aACA,aACA,oBACA,cACA,WACoB,CACpB,IAAM,EAAc,GAAgB,CAG9B,EAAa,GAAO,EAAQ,CAElC,MAAgB,CACd,EAAW,QAAU,GACrB,CAEF,IAAM,EAA2B,MAE7B,GAAQ,UACJ,CACE,iBAAoB,EAAiC,EAAY,CACjE,oBAAuB,EAAiC,EAAY,CACpE,kBAAqB,EAAiC,EAAY,CACnE,CACD,IAAA,GACN,CAAC,EAAa,EAAO,CACtB,CAEK,EAAM,MAER,IAAIA,EAAQ,CACV,UACA,SACA,UACA,iBACA,aACA,aACA,oBACA,cACA,QAAS,EAAW,QACpB,2BACD,CAAC,CACJ,CACE,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAOD,OAFA,UAAsB,EAAI,SAAS,CAAE,CAAC,EAAI,CAAC,CAEpC,GAAC,EAAe,SAAhB,CAAyB,MAAO,EAAM,WAAmC,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,GAA4B,CAC1C,4BAGC,CACD,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAEpD,OAAOC,EACL,GAAqC,EAAI,OAAQ,CAC/C,kBACA,2BACD,CAAC,CACH,CCFH,SAAgB,GAAa,CAC3B,OAAO,EACP,WAAW,IACX,WAAW,IAKT,EAAE,CAAE,CACN,IAAM,EAAM,GAAY,CAClB,EAAkB,GAA4B,CAIpD,OAAOC,EACLC,GAAsB,EAAI,SAAU,CAClC,kBACA,OACA,WACA,WACD,CAAC,CACH"}
@@ -1,2 +1,2 @@
1
- "use client";import{TransactionRevertedError as e}from"@zama-fhe/sdk";import*as t from"wagmi/actions";import{getAccount as n,getBlock as r,getChainId as i,readContract as a,signTypedData as o,waitForTransactionReceipt as s,watchAccount as c,writeContract as l}from"wagmi/actions";import*as u from"wagmi";import"wagmi";`useConnection`in u&&u.useConnection;const d=`getConnection`in t?t.getConnection:n,f=`watchConnection`in t?t.watchConnection:c;var p=class{config;constructor(e){this.config=e.config}async getChainId(){return i(this.config)}async getAddress(){let e=d(this.config);if(!e?.address)throw TypeError(`Invalid address`);return e.address}async signTypedData(e){let{EIP712Domain:t,...n}=e.types;return o(this.config,{primaryType:e.primaryType,types:n,domain:e.domain,message:{...e.message,startTimestamp:BigInt(e.message.startTimestamp),durationDays:BigInt(e.message.durationDays)}})}async writeContract(e){return l(this.config,e)}async readContract(e){return a(this.config,e)}async waitForTransactionReceipt(t){try{return await s(this.config,{hash:t})}catch(n){let r=n instanceof Error?n.message:String(n);throw r.includes(`could not be found`)||r.includes(`Transaction not found`)?new e(`Could not find transaction receipt for hash "${t.slice(0,10)}…". If using ERC-4337 with a bundler, your connector may be returning a UserOperation hash instead of a transaction hash.`,{cause:n instanceof Error?n:void 0}):n}}async getBlockTimestamp(){return(await r(this.config)).timestamp}subscribe({onDisconnect:e=()=>{},onAccountChange:t=()=>{},onChainChange:n=()=>{}}){return f(this.config,{onChange(r,i){r.status===`disconnected`&&i.status!==`disconnected`&&e(),i.address&&r.address&&r.address!==i.address&&t(r.address),typeof i.chainId==`number`&&typeof r.chainId==`number`&&r.chainId!==i.chainId&&n(r.chainId)}})}};export{p as WagmiSigner};
1
+ "use client";import{TransactionRevertedError as e}from"@zama-fhe/sdk";import{getAccount as t,getBlock as n,getChainId as r,readContract as i,signTypedData as a,waitForTransactionReceipt as o,watchConnection as s,writeContract as c}from"wagmi/actions";var l=class{config;constructor(e){this.config=e.config}async getChainId(){return r(this.config)}async getAddress(){let e=t(this.config);if(!e?.address)throw TypeError(`Invalid address`);return e.address}async signTypedData(e){let{EIP712Domain:t,...n}=e.types;return a(this.config,{primaryType:Object.keys(n)[0],types:n,domain:e.domain,message:e.message})}async writeContract(e){return c(this.config,e)}async readContract(e){return i(this.config,e)}async waitForTransactionReceipt(t){try{return await o(this.config,{hash:t})}catch(n){let r=n instanceof Error?n.message:String(n);throw r.includes(`could not be found`)||r.includes(`Transaction not found`)?new e(`Could not find transaction receipt for hash "${t.slice(0,10)}…". If using ERC-4337 with a bundler, your connector may be returning a UserOperation hash instead of a transaction hash.`,{cause:n instanceof Error?n:void 0}):n}}async getBlockTimestamp(){return(await n(this.config)).timestamp}subscribe({onDisconnect:e=()=>{},onAccountChange:t=()=>{},onChainChange:n=()=>{}}){return s(this.config,{onChange(r,i){r.status===`disconnected`&&i.status!==`disconnected`&&e(),i.address&&r.address&&r.address!==i.address&&t(r.address),typeof i.chainId==`number`&&typeof r.chainId==`number`&&r.chainId!==i.chainId&&n(r.chainId)}})}};export{l as WagmiSigner};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/wagmi/compat.ts","../../src/wagmi/wagmi-signer.ts"],"sourcesContent":["import * as wagmi from \"wagmi\";\nimport { useAccount } from \"wagmi\";\nimport * as actions from \"wagmi/actions\";\nimport { getAccount, watchAccount } from \"wagmi/actions\";\n\n// wagmi v3 renamed useAccount → useConnection\nexport const useConnection = \"useConnection\" in wagmi ? wagmi.useConnection : useAccount;\n\n// wagmi v3 renamed getAccount → getConnection\nexport const getConnection = \"getConnection\" in actions ? actions.getConnection : getAccount;\n\n// wagmi v3 renamed watchAccount → watchConnection\nexport const watchConnection =\n \"watchConnection\" in actions ? actions.watchConnection : watchAccount;\n","import type {\n Address,\n ContractAbi,\n EIP712TypedData,\n GenericSigner,\n Hex,\n ReadContractArgs,\n ReadContractConfig,\n ReadContractReturnType,\n ReadFunctionName,\n SignerLifecycleCallbacks,\n TransactionReceipt,\n WriteContractArgs,\n WriteFunctionName,\n WriteContractConfig,\n} from \"@zama-fhe/sdk\";\nimport { TransactionRevertedError } from \"@zama-fhe/sdk\";\nimport type { Config } from \"wagmi\";\nimport {\n getBlock,\n getChainId,\n readContract,\n signTypedData,\n waitForTransactionReceipt,\n writeContract,\n} from \"wagmi/actions\";\nimport { getConnection, watchConnection } from \"./compat\";\n\n/** Configuration for {@link WagmiSigner}. */\nexport interface WagmiSignerConfig {\n config: Config;\n}\n\n/**\n * GenericSigner backed by wagmi.\n *\n * @param signerConfig - {@link WagmiSignerConfig} with wagmi config\n */\nexport class WagmiSigner implements GenericSigner {\n private readonly config: Config;\n\n constructor(signerConfig: WagmiSignerConfig) {\n this.config = signerConfig.config;\n }\n\n async getChainId(): Promise<number> {\n return getChainId(this.config);\n }\n\n async getAddress(): Promise<Address> {\n const account = getConnection(this.config);\n if (!account?.address) {\n throw new TypeError(\"Invalid address\");\n }\n return account.address;\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { EIP712Domain: _, ...sigTypes } = typedData.types;\n return signTypedData(this.config, {\n primaryType: typedData.primaryType,\n types: sigTypes,\n domain: typedData.domain,\n message: {\n ...typedData.message,\n startTimestamp: BigInt(typedData.message.startTimestamp),\n durationDays: BigInt(typedData.message.durationDays),\n },\n // Cast: EIP712TypedData is a union; viem cannot correlate primaryType/types/message across union members, so the inferred `message` collapses to `never`.\n } as Parameters<typeof signTypedData>[1]);\n }\n\n async writeContract<\n const TAbi extends ContractAbi,\n TFunctionName extends WriteFunctionName<TAbi>,\n const TArgs extends WriteContractArgs<TAbi, TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n return writeContract(this.config, config as Parameters<typeof writeContract>[1]);\n }\n\n async readContract<\n const TAbi extends ContractAbi,\n TFunctionName extends ReadFunctionName<TAbi>,\n const TArgs extends ReadContractArgs<TAbi, TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ReadContractReturnType<TAbi, TFunctionName, TArgs>> {\n return readContract(this.config, config);\n }\n\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n try {\n return await waitForTransactionReceipt(this.config, { hash });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes(\"could not be found\") || message.includes(\"Transaction not found\")) {\n throw new TransactionRevertedError(\n `Could not find transaction receipt for hash \"${hash.slice(0, 10)}…\". ` +\n \"If using ERC-4337 with a bundler, your connector may be returning a UserOperation hash \" +\n \"instead of a transaction hash.\",\n { cause: error instanceof Error ? error : undefined },\n );\n }\n throw error;\n }\n }\n\n async getBlockTimestamp(): Promise<bigint> {\n const block = await getBlock(this.config);\n return block.timestamp;\n }\n\n subscribe({\n onDisconnect = () => {},\n onAccountChange = () => {},\n onChainChange = () => {},\n }: SignerLifecycleCallbacks): () => void {\n return watchConnection(this.config, {\n onChange(connection, prevConnection) {\n if (connection.status === \"disconnected\" && prevConnection.status !== \"disconnected\") {\n onDisconnect();\n }\n if (\n prevConnection.address &&\n connection.address &&\n connection.address !== prevConnection.address\n ) {\n onAccountChange(connection.address);\n }\n if (\n typeof prevConnection.chainId === \"number\" &&\n typeof connection.chainId === \"number\" &&\n connection.chainId !== prevConnection.chainId\n ) {\n onChainChange(connection.chainId);\n }\n },\n });\n }\n}\n"],"mappings":"8TAM6B,kBAAmB,GAAQ,EAAM,cAG9D,MAAa,EAAgB,kBAAmB,EAAU,EAAQ,cAAgB,E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gB,CAC/B,EAAW,SAAW,gBAAkB,EAAe,SAAW,gBACpE,GAAc,CAGd,EAAe,SACf,EAAW,SACX,EAAW,UAAY,EAAe,SAEtC,EAAgB,EAAW,QAAQ,CAGnC,OAAO,EAAe,SAAY,UAClC,OAAO,EAAW,SAAY,UAC9B,EAAW,UAAY,EAAe,SAEtC,EAAc,EAAW,QAAQ,EAGtC,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/wagmi/wagmi-signer.ts"],"sourcesContent":["import type {\n Address,\n ContractAbi,\n EIP712TypedData,\n GenericSigner,\n Hex,\n ReadContractArgs,\n ReadContractConfig,\n ReadContractReturnType,\n ReadFunctionName,\n SignerLifecycleCallbacks,\n TransactionReceipt,\n WriteContractArgs,\n WriteFunctionName,\n WriteContractConfig,\n} from \"@zama-fhe/sdk\";\nimport { TransactionRevertedError } from \"@zama-fhe/sdk\";\nimport type { Config } from \"wagmi\";\nimport {\n getBlock,\n getChainId,\n getAccount,\n readContract,\n signTypedData,\n waitForTransactionReceipt,\n watchConnection,\n writeContract,\n} from \"wagmi/actions\";\n\n/** Configuration for {@link WagmiSigner}. */\nexport interface WagmiSignerConfig {\n config: Config;\n}\n\n/**\n * GenericSigner backed by wagmi.\n *\n * @param signerConfig - {@link WagmiSignerConfig} with wagmi config\n */\nexport class WagmiSigner implements GenericSigner {\n private readonly config: Config;\n\n constructor(signerConfig: WagmiSignerConfig) {\n this.config = signerConfig.config;\n }\n\n async getChainId(): Promise<number> {\n return getChainId(this.config);\n }\n\n async getAddress(): Promise<Address> {\n const account = getAccount(this.config);\n if (!account?.address) {\n throw new TypeError(\"Invalid address\");\n }\n return account.address;\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { EIP712Domain: _, ...sigTypes } = typedData.types;\n return signTypedData(this.config, {\n primaryType: Object.keys(sigTypes)[0]!,\n types: sigTypes,\n domain: typedData.domain,\n message: typedData.message,\n });\n }\n\n async writeContract<\n const TAbi extends ContractAbi,\n TFunctionName extends WriteFunctionName<TAbi>,\n const TArgs extends WriteContractArgs<TAbi, TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n return writeContract(this.config, config as Parameters<typeof writeContract>[1]);\n }\n\n async readContract<\n const TAbi extends ContractAbi,\n TFunctionName extends ReadFunctionName<TAbi>,\n const TArgs extends ReadContractArgs<TAbi, TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ReadContractReturnType<TAbi, TFunctionName, TArgs>> {\n return readContract(this.config, config);\n }\n\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n try {\n return await waitForTransactionReceipt(this.config, { hash });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes(\"could not be found\") || message.includes(\"Transaction not found\")) {\n throw new TransactionRevertedError(\n `Could not find transaction receipt for hash \"${hash.slice(0, 10)}…\". ` +\n \"If using ERC-4337 with a bundler, your connector may be returning a UserOperation hash \" +\n \"instead of a transaction hash.\",\n { cause: error instanceof Error ? error : undefined },\n );\n }\n throw error;\n }\n }\n\n async getBlockTimestamp(): Promise<bigint> {\n const block = await getBlock(this.config);\n return block.timestamp;\n }\n\n subscribe({\n onDisconnect = () => {},\n onAccountChange = () => {},\n onChainChange = () => {},\n }: SignerLifecycleCallbacks): () => void {\n return watchConnection(this.config, {\n onChange(connection, prevConnection) {\n if (connection.status === \"disconnected\" && prevConnection.status !== \"disconnected\") {\n onDisconnect();\n }\n if (\n prevConnection.address &&\n connection.address &&\n connection.address !== prevConnection.address\n ) {\n onAccountChange(connection.address);\n }\n if (\n typeof prevConnection.chainId === \"number\" &&\n typeof connection.chainId === \"number\" &&\n connection.chainId !== prevConnection.chainId\n ) {\n onChainChange(connection.chainId);\n }\n },\n });\n }\n}\n"],"mappings":"2PAuCA,IAAa,EAAb,KAAkD,CAChD,OAEA,YAAY,EAAiC,CAC3C,KAAK,OAAS,EAAa,OAG7B,MAAM,YAA8B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Ac,EAAW,QAAQ,EAGtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zama-fhe/react-sdk",
3
- "version": "3.0.0-alpha.8",
3
+ "version": "3.0.0",
4
4
  "description": "React hooks for Zama SDK",
5
5
  "license": "BSD-3-Clause-Clear",
6
6
  "author": "Zama",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@tanstack/react-query": ">=5",
67
- "@zama-fhe/sdk": "^3.0.0-alpha.8",
67
+ "@zama-fhe/sdk": "^3.0.0",
68
68
  "react": ">=18",
69
69
  "viem": "^2.47.0",
70
70
  "wagmi": ">=2"