@zama-fhe/react-sdk 1.1.0-alpha.2 → 1.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/index.d.ts +176 -33
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/wagmi/index.d.ts +1 -0
- package/dist/wagmi/index.js +1 -1
- package/dist/wagmi/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -566,6 +566,63 @@ interface FinalizeUnwrapParams {
|
|
|
566
566
|
}
|
|
567
567
|
```
|
|
568
568
|
|
|
569
|
+
### Delegation Hooks
|
|
570
|
+
|
|
571
|
+
#### `useDelegateDecryption`
|
|
572
|
+
|
|
573
|
+
Grant decryption delegation to another address via the on-chain ACL. ACL address is resolved automatically from the relayer transport config.
|
|
574
|
+
|
|
575
|
+
```ts
|
|
576
|
+
function useDelegateDecryption(
|
|
577
|
+
config: UseZamaConfig,
|
|
578
|
+
options?: UseMutationOptions<TransactionResult, Error, DelegateDecryptionParams>,
|
|
579
|
+
): UseMutationResult<TransactionResult, Error, DelegateDecryptionParams>;
|
|
580
|
+
|
|
581
|
+
interface DelegateDecryptionParams {
|
|
582
|
+
delegateAddress: Address;
|
|
583
|
+
expirationDate?: Date;
|
|
584
|
+
}
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
```tsx
|
|
588
|
+
const { mutateAsync: delegate, isPending } = useDelegateDecryption({
|
|
589
|
+
tokenAddress: "0xToken",
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
// Permanent delegation
|
|
593
|
+
await delegate({ delegateAddress: "0xDelegate" });
|
|
594
|
+
|
|
595
|
+
// With expiration
|
|
596
|
+
await delegate({
|
|
597
|
+
delegateAddress: "0xDelegate",
|
|
598
|
+
expirationDate: new Date("2025-12-31"),
|
|
599
|
+
});
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
#### `useDecryptBalanceAs`
|
|
603
|
+
|
|
604
|
+
Decrypt another user's balance as a delegate. Uses the delegated EIP-712 flow — the connected wallet signs as the delegate, and the relayer verifies the on-chain delegation.
|
|
605
|
+
|
|
606
|
+
```ts
|
|
607
|
+
function useDecryptBalanceAs(
|
|
608
|
+
tokenAddress: Address,
|
|
609
|
+
options?: UseMutationOptions<bigint, Error, DecryptBalanceAsParams>,
|
|
610
|
+
): UseMutationResult<bigint, Error, DecryptBalanceAsParams>;
|
|
611
|
+
|
|
612
|
+
interface DecryptBalanceAsParams {
|
|
613
|
+
delegatorAddress: Address;
|
|
614
|
+
owner?: Address;
|
|
615
|
+
}
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
```tsx
|
|
619
|
+
const { mutateAsync: decryptAs, data: balance } = useDecryptBalanceAs("0xToken");
|
|
620
|
+
|
|
621
|
+
// Decrypt the delegator's balance
|
|
622
|
+
const result = await decryptAs({ delegatorAddress: "0xDelegator" });
|
|
623
|
+
// result => bigint
|
|
624
|
+
```
|
|
625
|
+
|
|
569
626
|
### Approval Hooks
|
|
570
627
|
|
|
571
628
|
#### `useConfidentialApprove`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as _zama_fhe_sdk0 from "@zama-fhe/sdk";
|
|
4
|
-
import { ActivityAmount, ActivityDirection, ActivityItem, ActivityItem as ActivityItem$1, ActivityLogMetadata, ActivityLogMetadata as ActivityLogMetadata$1, ActivityType, Address, Address as Address$1, ApprovalFailedError, ApproveSubmittedEvent, ApproveUnderlyingSubmittedEvent, BATCH_SWAP_ABI, BaseEvent, BatchDecryptOptions, BatchTransferData, ChromeSessionStorage, ClearValueType, ClearValueType as ClearValueType$1, ConfidentialTransferEvent, ContractAbi, CredentialsAllowedEvent, CredentialsCachedEvent, CredentialsCreatedEvent, CredentialsCreatingEvent, CredentialsExpiredEvent, CredentialsLoadingEvent, CredentialsManager, CredentialsManagerConfig, CredentialsRevokedEvent, DEPLOYMENT_COORDINATOR_ABI, DecryptEndEvent, DecryptErrorEvent, DecryptStartEvent, DecryptionFailedError, DelegatedUserDecryptParams, DelegatedUserDecryptParams as DelegatedUserDecryptParams$1, EIP712TypedData, EIP712TypedData as EIP712TypedData$1, ENCRYPTION_ABI, ERC165_ABI, ERC20_ABI, ERC20_METADATA_ABI, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, EncryptEndEvent, EncryptErrorEvent, EncryptInput, EncryptParams, EncryptParams as EncryptParams$1, EncryptResult, EncryptResult as EncryptResult$1, EncryptStartEvent, EncryptionFailedError, FEE_MANAGER_ABI, FheTypeName, FhevmInstanceConfig, FinalizeUnwrapSubmittedEvent, GenericSigner, GenericSigner as GenericSigner$1, GenericStorage, GenericStorage as GenericStorage$1, Handle, Handle as Handle$1, HardhatConfig, Hex, Hex as Hex$1, IndexedDBStorage, InputProofBytesType, InvalidKeypairError, KeypairExpiredError, KeypairType, KmsDelegatedUserDecryptEIP712Type, MainnetConfig, MemoryStorage, NetworkType, NoCiphertextError, OnChainEvent, PublicDecryptResult, PublicDecryptResult as PublicDecryptResult$1, RawLog, RawLog as RawLog$1, ReadContractArgs, ReadContractConfig, ReadContractReturnType, ReadFunctionName, ReadonlyToken, ReadonlyTokenConfig, RelayerRequestFailedError, RelayerSDK, RelayerSDK as RelayerSDK$1, RelayerSDKStatus, RelayerWeb, RelayerWebConfig, RelayerWebSecurityConfig, SepoliaConfig, SessionExpiredEvent, ShieldCallbacks, ShieldSubmittedEvent, SigningFailedError, SigningRejectedError, StoredCredentials, TOKEN_TOPICS, TRANSFER_BATCHER_ABI, Token, TokenConfig, Topics, TransactionErrorEvent, TransactionReceipt, TransactionResult, TransactionResult as TransactionResult$1, TransactionRevertedError, TransferCallbacks, TransferFromSubmittedEvent, TransferSubmittedEvent, UnshieldCallbacks, UnshieldPhase1SubmittedEvent, UnshieldPhase2StartedEvent, UnshieldPhase2SubmittedEvent, UnwrapRequestedEvent, UnwrapSubmittedEvent, UnwrappedFinalizedEvent, UnwrappedStartedEvent, UserDecryptParams, UserDecryptParams as UserDecryptParams$1, WRAPPER_ABI, WrappedEvent, 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, confidentialBatchTransferContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, decimalsContract, decodeConfidentialTransfer, decodeOnChainEvent, decodeOnChainEvents, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, deploymentCoordinatorContract, extractEncryptedHandles, finalizeUnwrapContract, findUnwrapRequested, findWrapped, getBatchTransferFeeContract, getFeeRecipientContract, getUnwrapFeeContract, getWrapFeeContract, getWrapperContract, indexedDBStorage, isConfidentialTokenContract, isConfidentialWrapperContract, isFinalizeUnwrapOperatorContract, isOperatorContract, loadPendingUnshield, matchZamaError, nameContract, parseActivityFeed, rateContract, savePendingUnshield, setFinalizeUnwrapOperatorContract, setOperatorContract, sortByBlockNumber, supportsInterfaceContract, symbolContract, totalSupplyContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract, wrapETHContract, wrapperExistsContract } from "@zama-fhe/sdk";
|
|
5
|
-
import { ApproveUnderlyingParams, ApproveUnderlyingParams as ApproveUnderlyingParams$1, ConfidentialApproveParams, ConfidentialApproveParams as ConfidentialApproveParams$1, ConfidentialBalancesData, ConfidentialBalancesData as ConfidentialBalancesData$1, ConfidentialTransferFromParams, ConfidentialTransferFromParams as ConfidentialTransferFromParams$1, ConfidentialTransferParams, ConfidentialTransferParams as ConfidentialTransferParams$1, FinalizeUnwrapParams, FinalizeUnwrapParams as FinalizeUnwrapParams$1, ResumeUnshieldParams, ResumeUnshieldParams as ResumeUnshieldParams$1, ShieldETHParams, ShieldETHParams as ShieldETHParams$1, ShieldParams, ShieldParams as ShieldParams$1, TokenMetadata, UnshieldAllParams, UnshieldAllParams as UnshieldAllParams$1, UnshieldParams, UnshieldParams as UnshieldParams$1, UnwrapParams, UnwrapParams as UnwrapParams$1, activityFeedQueryOptions, allowMutationOptions, approveUnderlyingMutationOptions, batchTransferFeeQueryOptions, confidentialApproveMutationOptions, confidentialBalanceQueryOptions, confidentialBalancesQueryOptions, confidentialHandleQueryOptions, confidentialHandlesQueryOptions, confidentialIsApprovedQueryOptions, confidentialTransferFromMutationOptions, confidentialTransferMutationOptions, encryptMutationOptions, feeRecipientQueryOptions, filterQueryOptions, finalizeUnwrapMutationOptions, hashFn, isAllowedQueryOptions, isConfidentialQueryOptions, isWrapperQueryOptions, publicKeyQueryOptions, publicParamsQueryOptions, resumeUnshieldMutationOptions, revokeMutationOptions, revokeSessionMutationOptions, shieldETHMutationOptions, shieldFeeQueryOptions, shieldMutationOptions, signerAddressQueryOptions, tokenMetadataQueryOptions, totalSupplyQueryOptions, underlyingAllowanceQueryOptions, unshieldAllMutationOptions, unshieldFeeQueryOptions, unshieldMutationOptions, unwrapAllMutationOptions, unwrapMutationOptions, wrapperDiscoveryQueryOptions, zamaQueryKeys } from "@zama-fhe/sdk/query";
|
|
4
|
+
import { ActivityAmount, ActivityDirection, ActivityItem, ActivityItem as ActivityItem$1, ActivityLogMetadata, ActivityLogMetadata as ActivityLogMetadata$1, ActivityType, Address, Address as Address$1, ApprovalFailedError, ApproveSubmittedEvent, ApproveUnderlyingSubmittedEvent, BATCH_SWAP_ABI, BaseEvent, BatchDecryptAsOptions, BatchDecryptAsOptions as BatchDecryptAsOptions$1, BatchDecryptOptions, BatchTransferData, ChromeSessionStorage, ClearValueType, ClearValueType as ClearValueType$1, ConfidentialTransferEvent, ContractAbi, CredentialsAllowedEvent, CredentialsCachedEvent, CredentialsCreatedEvent, CredentialsCreatingEvent, CredentialsExpiredEvent, CredentialsLoadingEvent, CredentialsManager, CredentialsManagerConfig, CredentialsRevokedEvent, DEPLOYMENT_COORDINATOR_ABI, DecryptEndEvent, DecryptErrorEvent, DecryptStartEvent, DecryptionFailedError, DelegatedCredentialsManager, DelegatedCredentialsManagerConfig, DelegatedStoredCredentials, DelegatedUserDecryptParams, DelegatedUserDecryptParams as DelegatedUserDecryptParams$1, EIP712TypedData, EIP712TypedData as EIP712TypedData$1, ENCRYPTION_ABI, ERC165_ABI, ERC20_ABI, ERC20_METADATA_ABI, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, EncryptEndEvent, EncryptErrorEvent, EncryptInput, EncryptParams, EncryptParams as EncryptParams$1, EncryptResult, EncryptResult as EncryptResult$1, EncryptStartEvent, EncryptionFailedError, FEE_MANAGER_ABI, FheTypeName, FhevmInstanceConfig, FinalizeUnwrapSubmittedEvent, GenericSigner, GenericSigner as GenericSigner$1, GenericStorage, GenericStorage as GenericStorage$1, Handle, Handle as Handle$1, HardhatConfig, Hex, Hex as Hex$1, IndexedDBStorage, InputProofBytesType, InvalidKeypairError, KeypairExpiredError, KeypairType, KmsDelegatedUserDecryptEIP712Type, MainnetConfig, MemoryStorage, NetworkType, NoCiphertextError, OnChainEvent, PublicDecryptResult, PublicDecryptResult as PublicDecryptResult$1, RawLog, RawLog as RawLog$1, ReadContractArgs, ReadContractConfig, ReadContractReturnType, ReadFunctionName, ReadonlyToken, ReadonlyToken as ReadonlyToken$1, ReadonlyTokenConfig, RelayerRequestFailedError, RelayerSDK, RelayerSDK as RelayerSDK$1, RelayerSDKStatus, RelayerWeb, RelayerWebConfig, RelayerWebSecurityConfig, SepoliaConfig, SessionExpiredEvent, ShieldCallbacks, ShieldSubmittedEvent, SigningFailedError, SigningRejectedError, StoredCredentials, TOKEN_TOPICS, TRANSFER_BATCHER_ABI, Token, TokenConfig, Topics, TransactionErrorEvent, TransactionReceipt, TransactionResult, TransactionResult as TransactionResult$1, TransactionRevertedError, TransferCallbacks, TransferFromSubmittedEvent, TransferSubmittedEvent, UnshieldCallbacks, UnshieldPhase1SubmittedEvent, UnshieldPhase2StartedEvent, UnshieldPhase2SubmittedEvent, UnwrapRequestedEvent, UnwrapSubmittedEvent, UnwrappedFinalizedEvent, UnwrappedStartedEvent, UserDecryptParams, UserDecryptParams as UserDecryptParams$1, WRAPPER_ABI, WrappedEvent, 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, confidentialBatchTransferContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, decimalsContract, decodeConfidentialTransfer, decodeOnChainEvent, decodeOnChainEvents, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, deploymentCoordinatorContract, extractEncryptedHandles, finalizeUnwrapContract, findUnwrapRequested, findWrapped, getBatchTransferFeeContract, getFeeRecipientContract, getUnwrapFeeContract, getWrapFeeContract, getWrapperContract, indexedDBStorage, isConfidentialTokenContract, isConfidentialWrapperContract, isFinalizeUnwrapOperatorContract, isOperatorContract, loadPendingUnshield, matchZamaError, nameContract, parseActivityFeed, rateContract, savePendingUnshield, setFinalizeUnwrapOperatorContract, setOperatorContract, sortByBlockNumber, supportsInterfaceContract, symbolContract, totalSupplyContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract, wrapETHContract, wrapperExistsContract } from "@zama-fhe/sdk";
|
|
5
|
+
import { ApproveUnderlyingParams, ApproveUnderlyingParams as ApproveUnderlyingParams$1, BatchDecryptBalancesAsParams, ConfidentialApproveParams, ConfidentialApproveParams as ConfidentialApproveParams$1, ConfidentialBalancesData, ConfidentialBalancesData as ConfidentialBalancesData$1, ConfidentialTransferFromParams, ConfidentialTransferFromParams as ConfidentialTransferFromParams$1, ConfidentialTransferParams, ConfidentialTransferParams as ConfidentialTransferParams$1, DecryptBalanceAsParams, DecryptBalanceAsParams as DecryptBalanceAsParams$1, DelegateDecryptionParams, DelegateDecryptionParams as DelegateDecryptionParams$1, DelegationStatusData, DelegationStatusData as DelegationStatusData$1, DelegationStatusQueryConfig, FinalizeUnwrapParams, FinalizeUnwrapParams as FinalizeUnwrapParams$1, ResumeUnshieldParams, ResumeUnshieldParams as ResumeUnshieldParams$1, RevokeDelegationParams, RevokeDelegationParams as RevokeDelegationParams$1, ShieldETHParams, ShieldETHParams as ShieldETHParams$1, ShieldParams, ShieldParams as ShieldParams$1, TokenMetadata, UnshieldAllParams, UnshieldAllParams as UnshieldAllParams$1, UnshieldParams, UnshieldParams as UnshieldParams$1, UnwrapParams, UnwrapParams as UnwrapParams$1, activityFeedQueryOptions, allowMutationOptions, approveUnderlyingMutationOptions, batchDecryptBalancesAsMutationOptions, batchTransferFeeQueryOptions, confidentialApproveMutationOptions, confidentialBalanceQueryOptions, confidentialBalancesQueryOptions, confidentialHandleQueryOptions, confidentialHandlesQueryOptions, confidentialIsApprovedQueryOptions, confidentialTransferFromMutationOptions, confidentialTransferMutationOptions, decryptBalanceAsMutationOptions, delegateDecryptionMutationOptions, delegationStatusQueryOptions, encryptMutationOptions, feeRecipientQueryOptions, filterQueryOptions, finalizeUnwrapMutationOptions, hashFn, isAllowedQueryOptions, isConfidentialQueryOptions, isWrapperQueryOptions, publicKeyQueryOptions, publicParamsQueryOptions, resumeUnshieldMutationOptions, revokeDelegationMutationOptions, revokeMutationOptions, revokeSessionMutationOptions, shieldETHMutationOptions, shieldFeeQueryOptions, shieldMutationOptions, signerAddressQueryOptions, tokenMetadataQueryOptions, totalSupplyQueryOptions, underlyingAllowanceQueryOptions, unshieldAllMutationOptions, unshieldFeeQueryOptions, unshieldMutationOptions, unwrapAllMutationOptions, unwrapMutationOptions, wrapperDiscoveryQueryOptions, zamaQueryKeys } from "@zama-fhe/sdk/query";
|
|
6
6
|
import * as _tanstack_react_query0 from "@tanstack/react-query";
|
|
7
|
-
import { QueryKey, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
7
|
+
import { QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions } from "@tanstack/react-query";
|
|
8
8
|
import { PropsWithChildren } from "react";
|
|
9
9
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
10
10
|
import * as _zama_fhe_relayer_sdk_web0 from "@zama-fhe/relayer-sdk/web";
|
|
@@ -76,6 +76,9 @@ declare function useZamaSDK(): ZamaSDK$1;
|
|
|
76
76
|
* Encrypt a plaintext value using FHE.
|
|
77
77
|
* Calls the relayer's `encrypt` method via a mutation.
|
|
78
78
|
*
|
|
79
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
80
|
+
* - {@link EncryptionFailedError} — FHE encryption failed
|
|
81
|
+
*
|
|
79
82
|
* @returns A mutation whose `mutate` accepts {@link EncryptParams}.
|
|
80
83
|
*
|
|
81
84
|
* @example
|
|
@@ -93,6 +96,11 @@ declare function useEncrypt(): _tanstack_react_query0.UseMutationResult<EncryptR
|
|
|
93
96
|
* For the full orchestration (signature management, EIP712 signing),
|
|
94
97
|
* see the app-level useUserDecryptFlow hook.
|
|
95
98
|
*
|
|
99
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
100
|
+
* - {@link DecryptionFailedError} — relayer decryption request failed
|
|
101
|
+
* - {@link InvalidKeypairError} — the provided keypair is invalid
|
|
102
|
+
* - {@link KeypairExpiredError} — the re-encryption keypair has expired
|
|
103
|
+
*
|
|
96
104
|
* On success, populates the decryption cache so useUserDecryptedValue/useUserDecryptedValues
|
|
97
105
|
* can read the results.
|
|
98
106
|
*/
|
|
@@ -120,6 +128,9 @@ declare function usePublicDecrypt(): _tanstack_react_query0.UseMutationResult<Pu
|
|
|
120
128
|
* Generate an FHE keypair via the relayer.
|
|
121
129
|
* Returns a public/private key pair for use in decrypt authorization.
|
|
122
130
|
*
|
|
131
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
132
|
+
* - {@link RelayerRequestFailedError} — relayer keypair generation request failed
|
|
133
|
+
*
|
|
123
134
|
* @returns A mutation whose `mutate` takes no parameters.
|
|
124
135
|
*
|
|
125
136
|
* @example
|
|
@@ -254,10 +265,7 @@ interface PublicKeyData {
|
|
|
254
265
|
* // publicKey?.publicKeyId, publicKey?.publicKey
|
|
255
266
|
* ```
|
|
256
267
|
*/
|
|
257
|
-
declare function usePublicKey(): _tanstack_react_query0.UseQueryResult<
|
|
258
|
-
publicKeyId: string;
|
|
259
|
-
publicKey: Uint8Array;
|
|
260
|
-
} | null, Error>;
|
|
268
|
+
declare function usePublicKey(): _tanstack_react_query0.UseQueryResult<PublicKeyData | null, Error>;
|
|
261
269
|
//#endregion
|
|
262
270
|
//#region src/relayer/use-public-params.d.ts
|
|
263
271
|
/** Shape of the FHE public parameters returned by the relayer. */
|
|
@@ -280,10 +288,7 @@ interface PublicParamsData {
|
|
|
280
288
|
* // params?.publicParams, params?.publicParamsId
|
|
281
289
|
* ```
|
|
282
290
|
*/
|
|
283
|
-
declare function usePublicParams(bits: number): _tanstack_react_query0.UseQueryResult<
|
|
284
|
-
publicParams: Uint8Array;
|
|
285
|
-
publicParamsId: string;
|
|
286
|
-
} | null, Error>;
|
|
291
|
+
declare function usePublicParams(bits: number): _tanstack_react_query0.UseQueryResult<PublicParamsData | null, Error>;
|
|
287
292
|
//#endregion
|
|
288
293
|
//#region src/relayer/use-user-decrypt-flow.d.ts
|
|
289
294
|
/** A handle to decrypt, paired with its originating contract address. */
|
|
@@ -808,19 +813,23 @@ declare function useConfidentialBalances(config: UseConfidentialBalancesConfig,
|
|
|
808
813
|
promise: Promise<ConfidentialBalancesData$1>;
|
|
809
814
|
};
|
|
810
815
|
//#endregion
|
|
811
|
-
//#region src/token/use-allow.d.ts
|
|
816
|
+
//#region src/token/use-allow-tokens.d.ts
|
|
812
817
|
/**
|
|
813
818
|
* Pre-authorize FHE decrypt credentials for a list of token addresses.
|
|
814
819
|
* A single wallet signature covers all addresses, so subsequent decrypt
|
|
815
820
|
* operations on any of these tokens reuse cached credentials.
|
|
816
821
|
*
|
|
822
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
823
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
824
|
+
* - {@link KeypairExpiredError} — the re-encryption keypair has expired
|
|
825
|
+
*
|
|
817
826
|
* @example
|
|
818
827
|
* ```tsx
|
|
819
|
-
* const { mutateAsync:
|
|
820
|
-
* // Call
|
|
828
|
+
* const { mutateAsync: allowTokens, isPending } = useAllowTokens();
|
|
829
|
+
* // Call allowTokens(allTokenAddresses) before any individual reveal
|
|
821
830
|
* ```
|
|
822
831
|
*/
|
|
823
|
-
declare function
|
|
832
|
+
declare function useAllowTokens(options?: UseMutationOptions<void, Error, Address$1[]>): _tanstack_react_query0.UseMutationResult<void, Error, `0x${string}`[], unknown>;
|
|
824
833
|
//#endregion
|
|
825
834
|
//#region src/token/use-is-allowed.d.ts
|
|
826
835
|
/**
|
|
@@ -834,18 +843,18 @@ declare function useAllow(options?: UseMutationOptions<void, Error, Address$1[]>
|
|
|
834
843
|
*/
|
|
835
844
|
declare function useIsAllowed(): _tanstack_react_query0.UseQueryResult<unknown, Error>;
|
|
836
845
|
//#endregion
|
|
837
|
-
//#region src/token/use-revoke.d.ts
|
|
846
|
+
//#region src/token/use-revoke-tokens.d.ts
|
|
838
847
|
/**
|
|
839
848
|
* Revoke stored FHE credentials for a list of token addresses.
|
|
840
849
|
* The next decrypt operation will require a fresh wallet signature.
|
|
841
850
|
*
|
|
842
851
|
* @example
|
|
843
852
|
* ```tsx
|
|
844
|
-
* const { mutate:
|
|
845
|
-
*
|
|
853
|
+
* const { mutate: revokeTokens } = useRevokeTokens();
|
|
854
|
+
* revokeTokens(["0xTokenA", "0xTokenB"]);
|
|
846
855
|
* ```
|
|
847
856
|
*/
|
|
848
|
-
declare function
|
|
857
|
+
declare function useRevokeTokens(options?: UseMutationOptions<void, Error, Address$1[]>): _tanstack_react_query0.UseMutationResult<void, Error, `0x${string}`[], unknown>;
|
|
849
858
|
//#endregion
|
|
850
859
|
//#region src/token/use-revoke-session.d.ts
|
|
851
860
|
/**
|
|
@@ -860,14 +869,6 @@ declare function useRevoke(options?: UseMutationOptions<void, Error, Address$1[]
|
|
|
860
869
|
*/
|
|
861
870
|
declare function useRevokeSession(options?: UseMutationOptions<void, Error, void>): _tanstack_react_query0.UseMutationResult<void, Error, void, unknown>;
|
|
862
871
|
//#endregion
|
|
863
|
-
//#region src/token/optimistic-balance-update.d.ts
|
|
864
|
-
type OptimisticBalanceSnapshot = Array<[QueryKey, bigint | undefined]>;
|
|
865
|
-
/** Combined context returned by optimistic `onMutate`. */
|
|
866
|
-
interface OptimisticMutateContext {
|
|
867
|
-
snapshot: OptimisticBalanceSnapshot;
|
|
868
|
-
callerContext?: unknown;
|
|
869
|
-
}
|
|
870
|
-
//#endregion
|
|
871
872
|
//#region src/token/use-confidential-transfer.d.ts
|
|
872
873
|
/** Configuration for {@link useConfidentialTransfer}. */
|
|
873
874
|
interface UseConfidentialTransferConfig extends UseZamaConfig {
|
|
@@ -908,13 +909,18 @@ interface UseConfidentialTransferConfig extends UseZamaConfig {
|
|
|
908
909
|
* );
|
|
909
910
|
* ```
|
|
910
911
|
*/
|
|
911
|
-
declare function useConfidentialTransfer(config: UseConfidentialTransferConfig, options?: UseMutationOptions<TransactionResult$1, Error, ConfidentialTransferParams$1,
|
|
912
|
+
declare function useConfidentialTransfer<TContext = unknown>(config: UseConfidentialTransferConfig, options?: UseMutationOptions<TransactionResult$1, Error, ConfidentialTransferParams$1, TContext>): UseMutationResult<TransactionResult$1, Error, ConfidentialTransferParams$1, TContext>;
|
|
912
913
|
//#endregion
|
|
913
914
|
//#region src/token/use-confidential-transfer-from.d.ts
|
|
914
915
|
/**
|
|
915
916
|
* Operator transfer on behalf of another address. Caller must be an approved operator.
|
|
916
917
|
* Invalidates balance caches on success.
|
|
917
918
|
*
|
|
919
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
920
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
921
|
+
* - {@link EncryptionFailedError} — FHE encryption of the transfer amount failed
|
|
922
|
+
* - {@link TransactionRevertedError} — on-chain transaction reverted
|
|
923
|
+
*
|
|
918
924
|
* @param config - Token address (and optional wrapper) identifying the token.
|
|
919
925
|
* @param options - React Query mutation options.
|
|
920
926
|
*
|
|
@@ -1024,23 +1030,37 @@ interface UseShieldConfig extends UseZamaConfig {
|
|
|
1024
1030
|
* shield.mutate({ amount: 1000n });
|
|
1025
1031
|
* ```
|
|
1026
1032
|
*/
|
|
1027
|
-
declare function useShield(config: UseShieldConfig, options?: UseMutationOptions<TransactionResult$1, Error, ShieldParams$1,
|
|
1033
|
+
declare function useShield<TContext = unknown>(config: UseShieldConfig, options?: UseMutationOptions<TransactionResult$1, Error, ShieldParams$1, TContext>): UseMutationResult<TransactionResult$1, Error, ShieldParams$1, TContext>;
|
|
1028
1034
|
//#endregion
|
|
1029
1035
|
//#region src/token/use-shield-eth.d.ts
|
|
1036
|
+
/** Configuration for {@link useShieldETH}. */
|
|
1037
|
+
interface UseShieldETHConfig extends UseZamaConfig {
|
|
1038
|
+
/**
|
|
1039
|
+
* When `true`, optimistically adds the wrap amount to the cached confidential balance
|
|
1040
|
+
* before the transaction confirms. Rolls back on error.
|
|
1041
|
+
* @defaultValue false
|
|
1042
|
+
*/
|
|
1043
|
+
optimistic?: boolean;
|
|
1044
|
+
}
|
|
1030
1045
|
/**
|
|
1031
1046
|
* Shield native ETH into confidential tokens.
|
|
1032
|
-
* Invalidates balance caches on success.
|
|
1047
|
+
* Handles wrapping automatically. Invalidates balance caches on success.
|
|
1048
|
+
*
|
|
1049
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
1050
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
1051
|
+
* - {@link TransactionRevertedError} — shield transaction reverted
|
|
1033
1052
|
*
|
|
1034
1053
|
* @param config - Token and wrapper addresses.
|
|
1054
|
+
* Set `optimistic: true` to add the amount to the cached balance immediately.
|
|
1035
1055
|
* @param options - React Query mutation options.
|
|
1036
1056
|
*
|
|
1037
1057
|
* @example
|
|
1038
1058
|
* ```tsx
|
|
1039
|
-
* const shieldETH = useShieldETH({ tokenAddress: "0x...", wrapperAddress: "0x..." });
|
|
1059
|
+
* const shieldETH = useShieldETH({ tokenAddress: "0x...", wrapperAddress: "0x...", optimistic: true });
|
|
1040
1060
|
* shieldETH.mutate({ amount: 1000000000000000000n }); // 1 ETH
|
|
1041
1061
|
* ```
|
|
1042
1062
|
*/
|
|
1043
|
-
declare function useShieldETH(config:
|
|
1063
|
+
declare function useShieldETH<TContext = unknown>(config: UseShieldETHConfig, options?: UseMutationOptions<TransactionResult$1, Error, ShieldETHParams$1, TContext>): UseMutationResult<TransactionResult$1, Error, ShieldETHParams$1, TContext>;
|
|
1044
1064
|
//#endregion
|
|
1045
1065
|
//#region src/token/use-unwrap.d.ts
|
|
1046
1066
|
/**
|
|
@@ -1048,6 +1068,11 @@ declare function useShieldETH(config: UseZamaConfig, options?: UseMutationOption
|
|
|
1048
1068
|
* Call {@link useFinalizeUnwrap} after the request is processed on-chain,
|
|
1049
1069
|
* or use {@link useUnshield} for a single-call orchestration.
|
|
1050
1070
|
*
|
|
1071
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
1072
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
1073
|
+
* - {@link EncryptionFailedError} — FHE encryption of the unwrap amount failed
|
|
1074
|
+
* - {@link TransactionRevertedError} — on-chain transaction reverted
|
|
1075
|
+
*
|
|
1051
1076
|
* @param config - Token address (and optional wrapper) identifying the token.
|
|
1052
1077
|
* @param options - React Query mutation options.
|
|
1053
1078
|
*
|
|
@@ -1065,6 +1090,10 @@ declare function useUnwrap(config: UseZamaConfig, options?: UseMutationOptions<T
|
|
|
1065
1090
|
* Uses the on-chain balance handle directly (no encryption needed).
|
|
1066
1091
|
* Call {@link useFinalizeUnwrap} after processing, or use {@link useUnshieldAll} for single-call orchestration.
|
|
1067
1092
|
*
|
|
1093
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
1094
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
1095
|
+
* - {@link TransactionRevertedError} — on-chain transaction reverted
|
|
1096
|
+
*
|
|
1068
1097
|
* @param config - Token address (and optional wrapper) identifying the token.
|
|
1069
1098
|
* @param options - React Query mutation options.
|
|
1070
1099
|
*
|
|
@@ -1081,6 +1110,11 @@ declare function useUnwrapAll(config: UseZamaConfig, options?: UseMutationOption
|
|
|
1081
1110
|
* Complete an unwrap by providing the public decryption proof.
|
|
1082
1111
|
* Call this after an unwrap request has been processed on-chain.
|
|
1083
1112
|
*
|
|
1113
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
1114
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
1115
|
+
* - {@link DecryptionFailedError} — public decryption of the burn amount failed
|
|
1116
|
+
* - {@link TransactionRevertedError} — on-chain finalize transaction reverted
|
|
1117
|
+
*
|
|
1084
1118
|
* @param config - Token address (and optional wrapper) identifying the token.
|
|
1085
1119
|
* @param options - React Query mutation options.
|
|
1086
1120
|
*
|
|
@@ -1119,6 +1153,11 @@ declare function useUnshield(config: UseZamaConfig, options?: UseMutationOptions
|
|
|
1119
1153
|
* Unshield the entire balance and finalize in one call.
|
|
1120
1154
|
* Orchestrates: unwrapAll → wait for receipt → parse event → finalize.
|
|
1121
1155
|
*
|
|
1156
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
1157
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
1158
|
+
* - {@link DecryptionFailedError} — public decryption failed during finalize
|
|
1159
|
+
* - {@link TransactionRevertedError} — on-chain transaction reverted
|
|
1160
|
+
*
|
|
1122
1161
|
* @param config - Token and wrapper addresses.
|
|
1123
1162
|
* @param options - React Query mutation options.
|
|
1124
1163
|
*
|
|
@@ -1307,12 +1346,108 @@ interface UseActivityFeedConfig {
|
|
|
1307
1346
|
*/
|
|
1308
1347
|
declare function useActivityFeed(config: UseActivityFeedConfig): _tanstack_react_query0.UseQueryResult<ActivityItem$1[], Error>;
|
|
1309
1348
|
//#endregion
|
|
1349
|
+
//#region src/token/use-delegate-decryption.d.ts
|
|
1350
|
+
/**
|
|
1351
|
+
* Delegate FHE decryption rights for a token to another address via the on-chain ACL.
|
|
1352
|
+
*
|
|
1353
|
+
* @param config - Token address identifying the confidential token.
|
|
1354
|
+
* @param options - React Query mutation options.
|
|
1355
|
+
*
|
|
1356
|
+
* @example
|
|
1357
|
+
* ```tsx
|
|
1358
|
+
* const delegate = useDelegateDecryption({ tokenAddress: "0x..." });
|
|
1359
|
+
* delegate.mutate({ delegateAddress: "0xDelegate" });
|
|
1360
|
+
* ```
|
|
1361
|
+
*/
|
|
1362
|
+
declare function useDelegateDecryption(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, DelegateDecryptionParams$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, DelegateDecryptionParams$1, unknown>;
|
|
1363
|
+
//#endregion
|
|
1364
|
+
//#region src/token/use-revoke-delegation.d.ts
|
|
1365
|
+
/**
|
|
1366
|
+
* Revoke FHE decryption delegation for a token from a delegate address.
|
|
1367
|
+
*
|
|
1368
|
+
* @param config - Token address identifying the confidential token.
|
|
1369
|
+
* @param options - React Query mutation options.
|
|
1370
|
+
*
|
|
1371
|
+
* @example
|
|
1372
|
+
* ```tsx
|
|
1373
|
+
* const revoke = useRevokeDelegation({ tokenAddress: "0x..." });
|
|
1374
|
+
* revoke.mutate({ delegateAddress: "0xDelegate" });
|
|
1375
|
+
* ```
|
|
1376
|
+
*/
|
|
1377
|
+
declare function useRevokeDelegation(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult$1, Error, RevokeDelegationParams$1>): _tanstack_react_query0.UseMutationResult<TransactionResult$1, Error, RevokeDelegationParams$1, unknown>;
|
|
1378
|
+
//#endregion
|
|
1379
|
+
//#region src/token/use-delegation-status.d.ts
|
|
1380
|
+
interface UseDelegationStatusConfig {
|
|
1381
|
+
/** Address of the confidential token contract. */
|
|
1382
|
+
tokenAddress: Address$1;
|
|
1383
|
+
/** The address that granted the delegation. */
|
|
1384
|
+
delegatorAddress?: Address$1;
|
|
1385
|
+
/** The address that received delegation rights. */
|
|
1386
|
+
delegateAddress?: Address$1;
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Query delegation status between a delegator and delegate for a token.
|
|
1390
|
+
*
|
|
1391
|
+
* @param config - Token address, delegator, and delegate addresses.
|
|
1392
|
+
* @param options - React Query options (forwarded to `useQuery`).
|
|
1393
|
+
* @returns `{ isDelegated, expiryTimestamp, isLoading, error }`.
|
|
1394
|
+
*
|
|
1395
|
+
* @example
|
|
1396
|
+
* ```tsx
|
|
1397
|
+
* const { data } = useDelegationStatus({
|
|
1398
|
+
* tokenAddress: "0xToken",
|
|
1399
|
+
* delegatorAddress: "0xDelegator",
|
|
1400
|
+
* delegateAddress: "0xDelegate",
|
|
1401
|
+
* });
|
|
1402
|
+
* // data?.isDelegated, data?.expiryTimestamp
|
|
1403
|
+
* ```
|
|
1404
|
+
*/
|
|
1405
|
+
declare function useDelegationStatus(config: UseDelegationStatusConfig, options?: Omit<UseQueryOptions<DelegationStatusData$1, Error>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<DelegationStatusData$1, Error>;
|
|
1406
|
+
//#endregion
|
|
1407
|
+
//#region src/token/use-decrypt-balance-as.d.ts
|
|
1408
|
+
/**
|
|
1409
|
+
* Decrypt another user's confidential balance as a delegate.
|
|
1410
|
+
*
|
|
1411
|
+
* @param tokenAddress - Address of the confidential token contract.
|
|
1412
|
+
* @param options - React Query mutation options.
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* ```tsx
|
|
1416
|
+
* const decryptAs = useDecryptBalanceAs("0xToken");
|
|
1417
|
+
* decryptAs.mutate({ delegatorAddress: "0xDelegator" });
|
|
1418
|
+
* // decryptAs.data => 1000n
|
|
1419
|
+
* ```
|
|
1420
|
+
*/
|
|
1421
|
+
declare function useDecryptBalanceAs(tokenAddress: Address$1, options?: UseMutationOptions<bigint, Error, DecryptBalanceAsParams$1>): _tanstack_react_query0.UseMutationResult<bigint, Error, DecryptBalanceAsParams$1, unknown>;
|
|
1422
|
+
//#endregion
|
|
1423
|
+
//#region src/token/use-batch-decrypt-balances-as.d.ts
|
|
1424
|
+
/**
|
|
1425
|
+
* Batch decrypt confidential balances as a delegate across multiple tokens.
|
|
1426
|
+
*
|
|
1427
|
+
* @param tokens - ReadonlyToken instances to decrypt balances for.
|
|
1428
|
+
* @param options - React Query mutation options.
|
|
1429
|
+
*
|
|
1430
|
+
* @example
|
|
1431
|
+
* ```tsx
|
|
1432
|
+
* const batchDecryptAs = useBatchDecryptBalancesAs(tokens);
|
|
1433
|
+
* batchDecryptAs.mutate({
|
|
1434
|
+
* delegatorAddress: "0xDelegator",
|
|
1435
|
+
* });
|
|
1436
|
+
* // batchDecryptAs.data => Map { "0xTokenA" => 100n, "0xTokenB" => 200n }
|
|
1437
|
+
* ```
|
|
1438
|
+
*/
|
|
1439
|
+
declare function useBatchDecryptBalancesAs(tokens: ReadonlyToken$1[], options?: UseMutationOptions<Map<Address$1, bigint>, Error, BatchDecryptAsOptions$1>): _tanstack_react_query0.UseMutationResult<Map<`0x${string}`, bigint>, Error, BatchDecryptAsOptions$1, unknown>;
|
|
1440
|
+
//#endregion
|
|
1310
1441
|
//#region src/token/use-approve-underlying.d.ts
|
|
1311
1442
|
/**
|
|
1312
1443
|
* Approve the wrapper contract to spend the underlying ERC-20.
|
|
1313
1444
|
* Defaults to max uint256. Resets to zero first if there's an existing
|
|
1314
1445
|
* non-zero allowance (required by tokens like USDT).
|
|
1315
1446
|
*
|
|
1447
|
+
* Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:
|
|
1448
|
+
* - {@link SigningRejectedError} — user rejected the wallet prompt
|
|
1449
|
+
* - {@link TransactionRevertedError} — approval transaction reverted
|
|
1450
|
+
*
|
|
1316
1451
|
* @param config - Token and wrapper addresses.
|
|
1317
1452
|
* @param options - React Query mutation options.
|
|
1318
1453
|
*
|
|
@@ -1485,5 +1620,13 @@ declare function useBatchTransferFee(feeManagerAddress: Address$1, options?: Omi
|
|
|
1485
1620
|
*/
|
|
1486
1621
|
declare function useFeeRecipient(feeManagerAddress: Address$1, options?: Omit<UseQueryOptions<Address$1, Error>, "queryKey" | "queryFn">): _tanstack_react_query0.UseQueryResult<`0x${string}`, Error>;
|
|
1487
1622
|
//#endregion
|
|
1488
|
-
|
|
1623
|
+
//#region src/token/optimistic-balance-update.d.ts
|
|
1624
|
+
type OptimisticBalanceSnapshot = Array<[QueryKey, bigint | undefined]>;
|
|
1625
|
+
/** Combined context returned by optimistic `onMutate`. */
|
|
1626
|
+
interface OptimisticMutateContext {
|
|
1627
|
+
snapshot: OptimisticBalanceSnapshot;
|
|
1628
|
+
callerContext?: unknown;
|
|
1629
|
+
}
|
|
1630
|
+
//#endregion
|
|
1631
|
+
export { type ActivityAmount, type ActivityDirection, type ActivityItem, type ActivityLogMetadata, type ActivityType, type Address, ApprovalFailedError, type ApproveSubmittedEvent, type ApproveUnderlyingParams, type ApproveUnderlyingSubmittedEvent, BATCH_SWAP_ABI, type BaseEvent, type BatchDecryptAsOptions, type BatchDecryptBalancesAsParams, type BatchDecryptOptions, type BatchTransferData, ChromeSessionStorage, type ClearValueType, type ConfidentialApproveParams, type ConfidentialBalancesData, type ConfidentialTransferEvent, type ConfidentialTransferFromParams, type ConfidentialTransferParams, type ContractAbi, type CreateDelegatedUserDecryptEIP712Params, type CreateEIP712Params, type CredentialsAllowedEvent, type CredentialsCachedEvent, type CredentialsCreatedEvent, type CredentialsCreatingEvent, type CredentialsExpiredEvent, type CredentialsLoadingEvent, CredentialsManager, type CredentialsManagerConfig, type CredentialsRevokedEvent, DEPLOYMENT_COORDINATOR_ABI, type DecryptBalanceAsParams, type DecryptEndEvent, type DecryptErrorEvent, type DecryptHandle, type DecryptStartEvent, DecryptionFailedError, type DelegateDecryptionParams, DelegatedCredentialsManager, type DelegatedCredentialsManagerConfig, type DelegatedStoredCredentials, type DelegatedUserDecryptParams, type DelegationStatusData, type DelegationStatusQueryConfig, type EIP712TypedData, ENCRYPTION_ABI, ERC165_ABI, ERC20_ABI, ERC20_METADATA_ABI, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, EncryptionFailedError, FEE_MANAGER_ABI, type FheTypeName, type FhevmInstanceConfig, type FinalizeUnwrapParams, type FinalizeUnwrapSubmittedEvent, type GenericSigner, type GenericStorage, type Handle, HardhatConfig, type Hex, IndexedDBStorage, type InputProofBytesType, InvalidKeypairError, KeypairExpiredError, type KeypairType, type KmsDelegatedUserDecryptEIP712Type, MainnetConfig, MemoryStorage, type NetworkType, NoCiphertextError, type OnChainEvent, type OptimisticBalanceSnapshot, type OptimisticMutateContext, type PublicDecryptResult, type PublicKeyData, type PublicParamsData, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, ReadonlyToken, type ReadonlyTokenConfig, RelayerRequestFailedError, type RelayerSDK, type RelayerSDKStatus, RelayerWeb, type RelayerWebConfig, type RelayerWebSecurityConfig, type ResumeUnshieldParams, type RevokeDelegationParams, SepoliaConfig, type SessionExpiredEvent, type ShieldCallbacks, type ShieldETHParams, type ShieldParams, type ShieldSubmittedEvent, SigningFailedError, SigningRejectedError, type StoredCredentials, TOKEN_TOPICS, TRANSFER_BATCHER_ABI, Token, type TokenConfig, type TokenMetadata, 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 UseFeeConfig, type UseShieldConfig, type UseShieldETHConfig, type UseUnderlyingAllowanceConfig, type UseUserDecryptFlowConfig, type UseWrapperDiscoveryConfig, type UseWrapperDiscoverySuspenseConfig, type UseZamaConfig, type UserDecryptFlowCallbacks, type UserDecryptFlowParams, type UserDecryptParams, WRAPPER_ABI, type WrappedEvent, 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, batchTransferFeeQueryOptions, chromeSessionStorage, clearPendingUnshield, confidentialApproveMutationOptions, confidentialBalanceOfContract, confidentialBalanceQueryOptions, confidentialBalancesQueryOptions, confidentialBatchTransferContract, confidentialHandleQueryOptions, confidentialHandlesQueryOptions, confidentialIsApprovedQueryOptions, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, confidentialTransferFromMutationOptions, confidentialTransferMutationOptions, decimalsContract, decodeConfidentialTransfer, decodeOnChainEvent, decodeOnChainEvents, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, decryptBalanceAsMutationOptions, decryptionKeys, delegateDecryptionMutationOptions, delegationStatusQueryOptions, deploymentCoordinatorContract, encryptMutationOptions, extractEncryptedHandles, feeRecipientQueryOptions, filterQueryOptions, finalizeUnwrapContract, finalizeUnwrapMutationOptions, findUnwrapRequested, findWrapped, getBatchTransferFeeContract, getFeeRecipientContract, getUnwrapFeeContract, getWrapFeeContract, getWrapperContract, hashFn, indexedDBStorage, isAllowedQueryOptions, isConfidentialQueryOptions, isConfidentialTokenContract, isConfidentialWrapperContract, isFinalizeUnwrapOperatorContract, isOperatorContract, isWrapperQueryOptions, loadPendingUnshield, matchZamaError, nameContract, parseActivityFeed, publicKeyQueryOptions, publicParamsQueryOptions, rateContract, resumeUnshieldMutationOptions, revokeDelegationMutationOptions, revokeMutationOptions, revokeSessionMutationOptions, savePendingUnshield, setFinalizeUnwrapOperatorContract, setOperatorContract, shieldETHMutationOptions, shieldFeeQueryOptions, shieldMutationOptions, signerAddressQueryOptions, sortByBlockNumber, supportsInterfaceContract, symbolContract, tokenMetadataQueryOptions, totalSupplyContract, totalSupplyQueryOptions, underlyingAllowanceQueryOptions, underlyingContract, unshieldAllMutationOptions, unshieldFeeQueryOptions, unshieldMutationOptions, unwrapAllMutationOptions, unwrapContract, unwrapFromBalanceContract, unwrapMutationOptions, useActivityFeed, useAllowTokens, useApproveUnderlying, useBatchDecryptBalancesAs, useBatchTransferFee, useConfidentialApprove, useConfidentialBalance, useConfidentialBalances, useConfidentialIsApproved, useConfidentialIsApprovedSuspense, useConfidentialTransfer, useConfidentialTransferFrom, useCreateDelegatedUserDecryptEIP712, useCreateEIP712, useDecryptBalanceAs, useDelegateDecryption, useDelegatedUserDecrypt, useDelegationStatus, useEncrypt, useFeeRecipient, useFinalizeUnwrap, useGenerateKeypair, useIsAllowed, useIsConfidential, useIsConfidentialSuspense, useIsWrapper, useIsWrapperSuspense, useMetadata, useMetadataSuspense, usePublicDecrypt, usePublicKey, usePublicParams, useReadonlyToken, useRequestZKProofVerification, useResumeUnshield, useRevokeDelegation, useRevokeSession, useRevokeTokens, useShield, useShieldETH, useShieldFee, useToken, useTotalSupply, useTotalSupplySuspense, useUnderlyingAllowance, useUnderlyingAllowanceSuspense, useUnshield, useUnshieldAll, useUnshieldFee, useUnwrap, useUnwrapAll, useUserDecrypt, useUserDecryptFlow, useUserDecryptedValue, useUserDecryptedValues, useWrapperDiscovery, useWrapperDiscoverySuspense, useZamaSDK, wrapContract, wrapETHContract, wrapperDiscoveryQueryOptions, wrapperExistsContract, zamaQueryKeys };
|
|
1489
1632
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{ApprovalFailedError as e,BATCH_SWAP_ABI as t,ChromeSessionStorage as n,CredentialsManager as r,DEPLOYMENT_COORDINATOR_ABI as i,DecryptionFailedError as a,ENCRYPTION_ABI as o,ERC165_ABI as s,ERC20_ABI as c,ERC20_METADATA_ABI as l,ERC7984_INTERFACE_ID as u,ERC7984_WRAPPER_INTERFACE_ID as d,EncryptionFailedError as f,FEE_MANAGER_ABI as p,HardhatConfig as m,IndexedDBStorage as h,InvalidKeypairError as ee,KeypairExpiredError as te,MainnetConfig as ne,MemoryStorage as re,NoCiphertextError as ie,ReadonlyToken as ae,RelayerRequestFailedError as oe,RelayerWeb as se,SepoliaConfig as ce,SigningFailedError as le,SigningRejectedError as ue,TOKEN_TOPICS as de,TRANSFER_BATCHER_ABI as fe,Token as pe,Topics as me,TransactionRevertedError as he,WRAPPER_ABI as ge,ZERO_HANDLE as _e,ZamaError as ve,ZamaErrorCode as ye,ZamaSDK as be,ZamaSDK as xe,ZamaSDKEvents as Se,allowanceContract as Ce,applyDecryptedValues as we,approveContract as Te,balanceOfContract as Ee,chromeSessionStorage as De,clearPendingUnshield as Oe,confidentialBalanceOfContract as ke,confidentialBatchTransferContract as Ae,confidentialTotalSupplyContract as je,confidentialTransferContract as Me,confidentialTransferFromContract as g,decimalsContract as _,decodeConfidentialTransfer as v,decodeOnChainEvent as y,decodeOnChainEvents as b,decodeUnwrapRequested as x,decodeUnwrappedFinalized as Ne,decodeUnwrappedStarted as Pe,decodeWrapped as Fe,deploymentCoordinatorContract as Ie,extractEncryptedHandles as Le,finalizeUnwrapContract as Re,findUnwrapRequested as ze,findWrapped as Be,getBatchTransferFeeContract as Ve,getFeeRecipientContract as He,getUnwrapFeeContract as Ue,getWrapFeeContract as We,getWrapperContract as Ge,indexedDBStorage as Ke,isConfidentialTokenContract as qe,isConfidentialWrapperContract as Je,isFinalizeUnwrapOperatorContract as Ye,isOperatorContract as Xe,loadPendingUnshield as Ze,matchZamaError as Qe,nameContract as $e,parseActivityFeed as et,rateContract as tt,savePendingUnshield as nt,setFinalizeUnwrapOperatorContract as rt,setOperatorContract as it,sortByBlockNumber as at,supportsInterfaceContract as ot,symbolContract as st,totalSupplyContract as ct,underlyingContract as lt,unwrapContract as ut,unwrapFromBalanceContract as dt,wrapContract as ft,wrapETHContract as pt,wrapperExistsContract as mt}from"@zama-fhe/sdk";import{activityFeedQueryOptions as ht,activityFeedQueryOptions as gt,allowMutationOptions as _t,allowMutationOptions as vt,approveUnderlyingMutationOptions as yt,approveUnderlyingMutationOptions as bt,batchTransferFeeQueryOptions as xt,batchTransferFeeQueryOptions as St,confidentialApproveMutationOptions as Ct,confidentialApproveMutationOptions as wt,confidentialBalanceQueryOptions as Tt,confidentialBalanceQueryOptions as Et,confidentialBalancesQueryOptions as Dt,confidentialBalancesQueryOptions as Ot,confidentialHandleQueryOptions as kt,confidentialHandleQueryOptions as At,confidentialHandlesQueryOptions as jt,confidentialHandlesQueryOptions as Mt,confidentialIsApprovedQueryOptions as Nt,confidentialIsApprovedQueryOptions as S,confidentialTransferFromMutationOptions as Pt,confidentialTransferFromMutationOptions as Ft,confidentialTransferMutationOptions as It,confidentialTransferMutationOptions as Lt,deriveActivityFeedLogsKey as Rt,encryptMutationOptions as zt,encryptMutationOptions as Bt,feeRecipientQueryOptions as Vt,feeRecipientQueryOptions as Ht,filterQueryOptions as Ut,finalizeUnwrapMutationOptions as Wt,finalizeUnwrapMutationOptions as Gt,hashFn as Kt,hashFn as C,invalidateAfterApprove as qt,invalidateAfterApproveUnderlying as Jt,invalidateAfterShield as w,invalidateAfterTransfer as T,invalidateAfterUnshield as E,invalidateAfterUnwrap as D,invalidateWalletLifecycleQueries as O,isAllowedQueryOptions as Yt,isAllowedQueryOptions as Xt,isConfidentialQueryOptions as Zt,isConfidentialQueryOptions as k,isWrapperQueryOptions as Qt,isWrapperQueryOptions as A,publicKeyQueryOptions as $t,publicKeyQueryOptions as en,publicParamsQueryOptions as tn,publicParamsQueryOptions as nn,resumeUnshieldMutationOptions as rn,resumeUnshieldMutationOptions as an,revokeMutationOptions as on,revokeMutationOptions as sn,revokeSessionMutationOptions as cn,revokeSessionMutationOptions as ln,shieldETHMutationOptions as un,shieldETHMutationOptions as dn,shieldFeeQueryOptions as fn,shieldFeeQueryOptions as pn,shieldMutationOptions as mn,shieldMutationOptions as hn,signerAddressQueryOptions as gn,signerAddressQueryOptions as j,tokenMetadataQueryOptions as _n,tokenMetadataQueryOptions as M,totalSupplyQueryOptions as vn,totalSupplyQueryOptions as N,underlyingAllowanceQueryOptions as yn,underlyingAllowanceQueryOptions as P,unshieldAllMutationOptions as bn,unshieldAllMutationOptions as xn,unshieldFeeQueryOptions as Sn,unshieldFeeQueryOptions as Cn,unshieldMutationOptions as wn,unshieldMutationOptions as Tn,unwrapAllMutationOptions as En,unwrapAllMutationOptions as Dn,unwrapMutationOptions as On,unwrapMutationOptions as kn,wrapperDiscoveryQueryOptions as An,wrapperDiscoveryQueryOptions as F,zamaQueryKeys as jn,zamaQueryKeys as I}from"@zama-fhe/sdk/query";import{skipToken as L,useMutation as R,useQueries as Mn,useQuery as z,useQueryClient as B,useSuspenseQuery as Nn}from"@tanstack/react-query";import{createContext as Pn,useContext as Fn,useEffect as V,useMemo as H,useRef as In}from"react";import{jsx as Ln}from"react/jsx-runtime";const U=Pn(null);function Rn({children:e,relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,onEvent:s}){let c=B(),l=In(s);V(()=>{l.current=s});let u=H(()=>n?.subscribe?{onDisconnect:()=>O(c),onAccountChange:()=>O(c),onChainChange:()=>O(c)}:void 0,[c,n]),d=H(()=>new xe({relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,onEvent:l.current,signerLifecycleCallbacks:u}),[t,n,r,i,a,o,u]);return V(()=>()=>d.dispose(),[d]),Ln(U.Provider,{value:d,children:e})}function W(){let e=Fn(U);if(!e)throw Error(`useZamaSDK must be used within a <ZamaProvider>. Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.`);return e}function zn(){return R(Bt(W()))}const G={value:(e,t)=>I.decryption.handle(e,t)};function Bn(){let e=W(),t=B();return R({mutationFn:t=>e.relayer.userDecrypt(t),onSuccess:e=>{for(let[n,r]of Object.entries(e))t.setQueryData(G.value(n),r)}})}function Vn(){let e=W(),t=B();return R({mutationFn:t=>e.relayer.publicDecrypt(t),onSuccess:e=>{for(let[n,r]of Object.entries(e.clearValues))t.setQueryData(G.value(n),r)}})}function Hn(){let e=W();return R({mutationFn:()=>e.relayer.generateKeypair()})}function Un(){let e=W();return R({mutationFn:({publicKey:t,contractAddresses:n,startTimestamp:r,durationDays:i})=>e.relayer.createEIP712(t,n,r,i)})}function Wn(){let e=W();return R({mutationFn:({publicKey:t,contractAddresses:n,delegatorAddress:r,startTimestamp:i,durationDays:a})=>e.relayer.createDelegatedUserDecryptEIP712(t,n,r,i,a)})}function Gn(){let e=W();return R({mutationFn:t=>e.relayer.delegatedUserDecrypt(t)})}function Kn(){let e=W();return R({mutationFn:t=>e.relayer.requestZKProofVerification(t)})}function qn(){return z({...en(W()),queryKeyHashFn:C})}function Jn(e){return z({...nn(W(),e),queryKeyHashFn:C})}function Yn(e){let t=W(),n=B(),r=e?.callbacks;return R({mutationKey:[`userDecryptFlow`],mutationFn:async({handles:e,durationDays:n=1})=>{let i=await t.relayer.generateKeypair();r?.onKeypairGenerated?.();let a=[...new Set(e.map(e=>e.contractAddress))],o=Math.floor(Date.now()/1e3),s=await t.relayer.createEIP712(i.publicKey,a,o,n);r?.onEIP712Created?.();let c=await t.signer.signTypedData(s);r?.onSigned?.(c);let l=await t.signer.getAddress(),u={},d=new Map;for(let t of e){let e=d.get(t.contractAddress)??[];e.push(t.handle),d.set(t.contractAddress,e)}for(let[e,r]of d){let s=await t.relayer.userDecrypt({handles:r,contractAddress:e,signedContractAddresses:a,privateKey:i.privateKey,publicKey:i.publicKey,signature:c,signerAddress:l,startTimestamp:o,durationDays:n});Object.assign(u,s)}let f=u;return r?.onDecrypted?.(f),f},onSuccess:e=>{for(let[t,r]of Object.entries(e))n.setQueryData(G.value(t),r)}})}function Xn(e){return z({queryKey:G.value(e??`0x`),queryKeyHashFn:C,queryFn:()=>void 0,enabled:!1})}function Zn(e){let t=Mn({queries:e.map(e=>({queryKey:G.value(e),queryKeyHashFn:C,queryFn:()=>void 0,enabled:!1}))}),n={};for(let r=0;r<e.length;r++)n[e[r]]=t[r].data;return{data:n,results:t}}function K(e){let t=W();return H(()=>t.createToken(e.tokenAddress,e.wrapperAddress),[t,e.tokenAddress,e.wrapperAddress])}function q(e){let t=W();return H(()=>t.createReadonlyToken(e),[t,e])}function J(e){return z({...e,queryKeyHashFn:C})}function Y(e){return Nn({...e,queryKeyHashFn:C})}function Qn(e,t){let{tokenAddress:n,handleRefetchInterval:r}=e,i=t?.enabled,a=q(n),o=J({...j(a.signer)}).data,s=At(a.signer,n,{owner:o,pollingInterval:r}),c=s.enabled??!0,l=J({...s,enabled:c&&(i??!0)}),u=l.data,d=Et(a,{handle:u,owner:o}),f=d.enabled??!0;return{...J({...d,...t,enabled:f&&(i??!0)}),handleQuery:l}}function $n(e,t){let{tokenAddresses:n,handleRefetchInterval:r,maxConcurrency:i}=e,a=t?.enabled,o=W(),s=J({...j(o.signer)}).data,c=H(()=>n.map(e=>o.createReadonlyToken(e)),[o,n]),l=Mt(o.signer,n,{owner:s,pollingInterval:r}),u=l.enabled??!0,d=J({...l,enabled:u&&(a??!0)}),f=d.data,p=Array.isArray(f)&&f.length===n.length,m=Ot(c,{owner:s,handles:f,maxConcurrency:i,resultAddresses:n}),h=m.enabled??!0;return{...J({...m,...t,enabled:h&&p&&(a??!0)}),handlesQuery:d}}function er(e){return R({...vt(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:I.isAllowed.all})}})}function tr(){let e=W(),t=J({...j(e.signer)}).data,n=t?Xt(e,{account:t}):{queryKey:I.isAllowed.all,queryFn:L},r=`enabled`in n?n.enabled??!0:!0;return J({...n,enabled:r})}function nr(e){return R({...sn(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:I.isAllowed.all})}})}function rr(e){return R({...ln(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:I.isAllowed.all})}})}function X(e,t){let n=e?t:void 0;return{wrappedContext:n,callerContext:e?n?.callerContext:t}}async function Z(e,t,n,r){let i=I.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 ir(e,t){let n=K(e),r=B();return R({...Lt(n),...t,onMutate:e.optimistic?async(n,i)=>({snapshot:await Z(r,e.tokenAddress,n.amount,`subtract`),callerContext:await t?.onMutate?.(n,i)}):t?.onMutate,onError:(n,i,a,o)=>{let{wrappedContext:s,callerContext:c}=X(e.optimistic,a);s&&Q(r,s.snapshot),t?.onError?.(n,i,c,o)},onSuccess:(n,r,i,a)=>{let{callerContext:o}=X(e.optimistic,i);t?.onSuccess?.(n,r,o,a),T(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 ar(e,t){return R({...Ft(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),T(a.client,e.tokenAddress)}})}function or(e,t){return R({...wt(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),qt(a.client,e.tokenAddress)}})}function sr(e,t){let{spender:n,holder:r,...i}=e,a=t?.enabled,o=K(i),s=J({...j(o.signer),enabled:r===void 0}),c=r??s.data,l=n&&c?S(o.signer,o.address,{holder:c,spender:n}):{queryKey:I.confidentialIsApproved.token(e.tokenAddress),queryFn:L},u=`enabled`in l?l.enabled??!0:!0;return J({...l,...t,enabled:u&&(a??!0)})}function cr(e){let{spender:t,holder:n,...r}=e,i=K(r),a=Y({...j(i.signer)}),o=n??a.data;return Y({...S(i.signer,i.address,{holder:o,spender:t})})}function lr(e,t){let n=K(e),r=B();return R({...hn(n),...t,onMutate:e.optimistic?async(n,i)=>({snapshot:await Z(r,e.tokenAddress,n.amount,`add`),callerContext:await t?.onMutate?.(n,i)}):t?.onMutate,onError:(n,i,a,o)=>{let{wrappedContext:s,callerContext:c}=X(e.optimistic,a);s&&Q(r,s.snapshot),t?.onError?.(n,i,c,o)},onSuccess:(n,r,i,a)=>{let{callerContext:o}=X(e.optimistic,i);t?.onSuccess?.(n,r,o,a),w(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 ur(e,t){return R({...dn(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),w(a.client,e.tokenAddress)}})}function dr(e,t){return R({...kn(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function fr(e,t){return R({...Dn(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function pr(e,t){return R({...Gt(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function mr(e,t){return R({...Tn(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function hr(e,t){return R({...xn(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function gr(e,t){return R({...an(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function _r(e,t){let{tokenAddress:n,wrapperAddress:r}=e,i=t?.enabled,a=q(n),o=J({...j(a.signer)}).data,s=P(a.signer,n,{owner:o,wrapperAddress:r}),c=s.enabled??!0;return J({...s,...t,enabled:c&&(i??!0)})}function vr(e){let{tokenAddress:t,wrapperAddress:n}=e,r=q(t),i=Y({...j(r.signer)}).data;return Y({...P(r.signer,t,{owner:i,wrapperAddress:n})})}function yr(e,t){let{tokenAddress:n,coordinatorAddress:r}=e,i=q(n);return J({...r?F(i.signer,n,{coordinatorAddress:r}):{queryKey:I.wrapperDiscovery.all,queryFn:L},...t})}function br(e){let{tokenAddress:t,coordinatorAddress:n}=e;return Y({...F(q(t).signer,t,{coordinatorAddress:n})})}function xr(e,t){return J({...M(q(e).signer,e),...t})}function Sr(e){return Y({...M(q(e).signer,e)})}function Cr(e){let{tokenAddress:t,userAddress:n,logs:r,decrypt:i}=e;return J({...gt(q(t),{userAddress:n,logs:r,decrypt:i??!0,logsKey:Rt(r)})})}function $(e,t){return R({...bt(K(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),Jt(a.client,e.tokenAddress)}})}function wr(e,t){return J({...k(q(e).signer,e),...t})}function Tr(e){return Y({...k(q(e).signer,e)})}function Er(e,t){return J({...A(q(e).signer,e),...t})}function Dr(e){return Y({...A(q(e).signer,e)})}function Or(e,t){return J({...N(q(e).signer,e),...t})}function kr(e){return Y({...N(q(e).signer,e)})}function Ar(e,t){let n=W(),r=t?.enabled,i=pn(n.signer,e),a=i.enabled??!0;return J({...i,...t,enabled:a&&(r??!0)})}function jr(e,t){let n=W(),r=t?.enabled,i=Cn(n.signer,e),a=i.enabled??!0;return J({...i,...t,enabled:a&&(r??!0)})}function Mr(e,t){let n=W(),r=t?.enabled,i=St(n.signer,e),a=i.enabled??!0;return J({...i,...t,enabled:a&&(r??!0)})}function Nr(e,t){let n=W(),r=t?.enabled,i=Ht(n.signer,e),a=i.enabled??!0;return J({...i,...t,enabled:a&&(r??!0)})}export{e as ApprovalFailedError,t as BATCH_SWAP_ABI,n as ChromeSessionStorage,r as CredentialsManager,i as DEPLOYMENT_COORDINATOR_ABI,a as DecryptionFailedError,o as ENCRYPTION_ABI,s as ERC165_ABI,c as ERC20_ABI,l as ERC20_METADATA_ABI,u as ERC7984_INTERFACE_ID,d as ERC7984_WRAPPER_INTERFACE_ID,f as EncryptionFailedError,p as FEE_MANAGER_ABI,m as HardhatConfig,h as IndexedDBStorage,ee as InvalidKeypairError,te as KeypairExpiredError,ne as MainnetConfig,re as MemoryStorage,ie as NoCiphertextError,ae as ReadonlyToken,oe as RelayerRequestFailedError,se as RelayerWeb,ce as SepoliaConfig,le as SigningFailedError,ue as SigningRejectedError,de as TOKEN_TOPICS,fe as TRANSFER_BATCHER_ABI,pe as Token,me as Topics,he as TransactionRevertedError,ge as WRAPPER_ABI,_e as ZERO_HANDLE,ve as ZamaError,ye as ZamaErrorCode,Rn as ZamaProvider,be as ZamaSDK,Se as ZamaSDKEvents,ht as activityFeedQueryOptions,_t as allowMutationOptions,Ce as allowanceContract,we as applyDecryptedValues,Te as approveContract,yt as approveUnderlyingMutationOptions,Ee as balanceOfContract,xt as batchTransferFeeQueryOptions,De as chromeSessionStorage,Oe as clearPendingUnshield,Ct as confidentialApproveMutationOptions,ke as confidentialBalanceOfContract,Tt as confidentialBalanceQueryOptions,Dt as confidentialBalancesQueryOptions,Ae as confidentialBatchTransferContract,kt as confidentialHandleQueryOptions,jt as confidentialHandlesQueryOptions,Nt as confidentialIsApprovedQueryOptions,je as confidentialTotalSupplyContract,Me as confidentialTransferContract,g as confidentialTransferFromContract,Pt as confidentialTransferFromMutationOptions,It as confidentialTransferMutationOptions,_ as decimalsContract,v as decodeConfidentialTransfer,y as decodeOnChainEvent,b as decodeOnChainEvents,x as decodeUnwrapRequested,Ne as decodeUnwrappedFinalized,Pe as decodeUnwrappedStarted,Fe as decodeWrapped,G as decryptionKeys,Ie as deploymentCoordinatorContract,zt as encryptMutationOptions,Le as extractEncryptedHandles,Vt as feeRecipientQueryOptions,Ut as filterQueryOptions,Re as finalizeUnwrapContract,Wt as finalizeUnwrapMutationOptions,ze as findUnwrapRequested,Be as findWrapped,Ve as getBatchTransferFeeContract,He as getFeeRecipientContract,Ue as getUnwrapFeeContract,We as getWrapFeeContract,Ge as getWrapperContract,Kt as hashFn,Ke as indexedDBStorage,Yt as isAllowedQueryOptions,Zt as isConfidentialQueryOptions,qe as isConfidentialTokenContract,Je as isConfidentialWrapperContract,Ye as isFinalizeUnwrapOperatorContract,Xe as isOperatorContract,Qt as isWrapperQueryOptions,Ze as loadPendingUnshield,Qe as matchZamaError,$e as nameContract,et as parseActivityFeed,$t as publicKeyQueryOptions,tn as publicParamsQueryOptions,tt as rateContract,rn as resumeUnshieldMutationOptions,on as revokeMutationOptions,cn as revokeSessionMutationOptions,nt as savePendingUnshield,rt as setFinalizeUnwrapOperatorContract,it as setOperatorContract,un as shieldETHMutationOptions,fn as shieldFeeQueryOptions,mn as shieldMutationOptions,gn as signerAddressQueryOptions,at as sortByBlockNumber,ot as supportsInterfaceContract,st as symbolContract,_n as tokenMetadataQueryOptions,ct as totalSupplyContract,vn as totalSupplyQueryOptions,yn as underlyingAllowanceQueryOptions,lt as underlyingContract,bn as unshieldAllMutationOptions,Sn as unshieldFeeQueryOptions,wn as unshieldMutationOptions,En as unwrapAllMutationOptions,ut as unwrapContract,dt as unwrapFromBalanceContract,On as unwrapMutationOptions,Cr as useActivityFeed,er as useAllow,$ as useApproveUnderlying,Mr as useBatchTransferFee,or as useConfidentialApprove,Qn as useConfidentialBalance,$n as useConfidentialBalances,sr as useConfidentialIsApproved,cr as useConfidentialIsApprovedSuspense,ir as useConfidentialTransfer,ar as useConfidentialTransferFrom,Wn as useCreateDelegatedUserDecryptEIP712,Un as useCreateEIP712,Gn as useDelegatedUserDecrypt,zn as useEncrypt,Nr as useFeeRecipient,pr as useFinalizeUnwrap,Hn as useGenerateKeypair,tr as useIsAllowed,wr as useIsConfidential,Tr as useIsConfidentialSuspense,Er as useIsWrapper,Dr as useIsWrapperSuspense,xr as useMetadata,Sr as useMetadataSuspense,Vn as usePublicDecrypt,qn as usePublicKey,Jn as usePublicParams,q as useReadonlyToken,Kn as useRequestZKProofVerification,gr as useResumeUnshield,nr as useRevoke,rr as useRevokeSession,lr as useShield,ur as useShieldETH,Ar as useShieldFee,K as useToken,Or as useTotalSupply,kr as useTotalSupplySuspense,_r as useUnderlyingAllowance,vr as useUnderlyingAllowanceSuspense,mr as useUnshield,hr as useUnshieldAll,jr as useUnshieldFee,dr as useUnwrap,fr as useUnwrapAll,Bn as useUserDecrypt,Yn as useUserDecryptFlow,Xn as useUserDecryptedValue,Zn as useUserDecryptedValues,yr as useWrapperDiscovery,br as useWrapperDiscoverySuspense,W as useZamaSDK,ft as wrapContract,pt as wrapETHContract,An as wrapperDiscoveryQueryOptions,mt as wrapperExistsContract,jn as zamaQueryKeys};
|
|
1
|
+
"use client";import{ApprovalFailedError as e,BATCH_SWAP_ABI as t,ChromeSessionStorage as n,CredentialsManager as r,DEPLOYMENT_COORDINATOR_ABI as i,DecryptionFailedError as a,DelegatedCredentialsManager as o,ENCRYPTION_ABI as s,ERC165_ABI as c,ERC20_ABI as l,ERC20_METADATA_ABI as u,ERC7984_INTERFACE_ID as d,ERC7984_WRAPPER_INTERFACE_ID as f,EncryptionFailedError as p,FEE_MANAGER_ABI as m,HardhatConfig as ee,IndexedDBStorage as te,InvalidKeypairError as ne,KeypairExpiredError as re,MainnetConfig as ie,MemoryStorage as ae,NoCiphertextError as oe,ReadonlyToken as se,ReadonlyToken as ce,RelayerRequestFailedError as le,RelayerWeb as ue,SepoliaConfig as de,SigningFailedError as fe,SigningRejectedError as pe,TOKEN_TOPICS as me,TRANSFER_BATCHER_ABI as he,Token as ge,Topics as _e,TransactionRevertedError as ve,WRAPPER_ABI as ye,ZERO_HANDLE as be,ZamaError as xe,ZamaErrorCode as Se,ZamaSDK as Ce,ZamaSDK as we,ZamaSDKEvents as Te,allowanceContract as Ee,applyDecryptedValues as De,approveContract as Oe,balanceOfContract as ke,chromeSessionStorage as Ae,clearPendingUnshield as je,confidentialBalanceOfContract as h,confidentialBatchTransferContract as g,confidentialTotalSupplyContract as _,confidentialTransferContract as v,confidentialTransferFromContract as y,decimalsContract as b,decodeConfidentialTransfer as x,decodeOnChainEvent as S,decodeOnChainEvents as Me,decodeUnwrapRequested as Ne,decodeUnwrappedFinalized as Pe,decodeUnwrappedStarted as Fe,decodeWrapped as Ie,deploymentCoordinatorContract as Le,extractEncryptedHandles as Re,finalizeUnwrapContract as ze,findUnwrapRequested as Be,findWrapped as Ve,getBatchTransferFeeContract as He,getFeeRecipientContract as Ue,getUnwrapFeeContract as We,getWrapFeeContract as Ge,getWrapperContract as Ke,indexedDBStorage as qe,isConfidentialTokenContract as Je,isConfidentialWrapperContract as Ye,isFinalizeUnwrapOperatorContract as Xe,isOperatorContract as Ze,loadPendingUnshield as Qe,matchZamaError as $e,nameContract as et,parseActivityFeed as tt,rateContract as nt,savePendingUnshield as rt,setFinalizeUnwrapOperatorContract as it,setOperatorContract as at,sortByBlockNumber as ot,supportsInterfaceContract as st,symbolContract as ct,totalSupplyContract as lt,underlyingContract as ut,unwrapContract as dt,unwrapFromBalanceContract as ft,wrapContract as pt,wrapETHContract as mt,wrapperExistsContract as ht}from"@zama-fhe/sdk";import{activityFeedQueryOptions as gt,activityFeedQueryOptions as _t,allowMutationOptions as vt,allowMutationOptions as yt,approveUnderlyingMutationOptions as bt,approveUnderlyingMutationOptions as xt,batchDecryptBalancesAsMutationOptions as St,batchTransferFeeQueryOptions as Ct,batchTransferFeeQueryOptions as wt,confidentialApproveMutationOptions as Tt,confidentialApproveMutationOptions as Et,confidentialBalanceQueryOptions as Dt,confidentialBalanceQueryOptions as Ot,confidentialBalancesQueryOptions as kt,confidentialBalancesQueryOptions as At,confidentialHandleQueryOptions as jt,confidentialHandleQueryOptions as Mt,confidentialHandlesQueryOptions as Nt,confidentialHandlesQueryOptions as Pt,confidentialIsApprovedQueryOptions as Ft,confidentialIsApprovedQueryOptions as C,confidentialTransferFromMutationOptions as It,confidentialTransferFromMutationOptions as Lt,confidentialTransferMutationOptions as Rt,confidentialTransferMutationOptions as zt,decryptBalanceAsMutationOptions as Bt,decryptBalanceAsMutationOptions as Vt,delegateDecryptionMutationOptions as Ht,delegateDecryptionMutationOptions as Ut,delegationStatusQueryOptions as Wt,delegationStatusQueryOptions as Gt,deriveActivityFeedLogsKey as Kt,encryptMutationOptions as qt,encryptMutationOptions as Jt,feeRecipientQueryOptions as Yt,feeRecipientQueryOptions as Xt,filterQueryOptions as Zt,finalizeUnwrapMutationOptions as Qt,finalizeUnwrapMutationOptions as $t,hashFn as en,hashFn as w,invalidateAfterApprove as tn,invalidateAfterApproveUnderlying as nn,invalidateAfterShield as rn,invalidateAfterTransfer as T,invalidateAfterUnshield as E,invalidateAfterUnwrap as D,invalidateWalletLifecycleQueries as O,isAllowedQueryOptions as an,isAllowedQueryOptions as on,isConfidentialQueryOptions as sn,isConfidentialQueryOptions as k,isWrapperQueryOptions as cn,isWrapperQueryOptions as A,publicKeyQueryOptions as ln,publicKeyQueryOptions as j,publicParamsQueryOptions as un,publicParamsQueryOptions as dn,resumeUnshieldMutationOptions as fn,resumeUnshieldMutationOptions as pn,revokeDelegationMutationOptions as mn,revokeDelegationMutationOptions as hn,revokeMutationOptions as gn,revokeMutationOptions as _n,revokeSessionMutationOptions as vn,revokeSessionMutationOptions as yn,shieldETHMutationOptions as bn,shieldETHMutationOptions as xn,shieldFeeQueryOptions as Sn,shieldFeeQueryOptions as Cn,shieldMutationOptions as wn,shieldMutationOptions as Tn,signerAddressQueryOptions as En,signerAddressQueryOptions as M,tokenMetadataQueryOptions as Dn,tokenMetadataQueryOptions as N,totalSupplyQueryOptions as On,totalSupplyQueryOptions as P,underlyingAllowanceQueryOptions as kn,underlyingAllowanceQueryOptions as F,unshieldAllMutationOptions as An,unshieldAllMutationOptions as jn,unshieldFeeQueryOptions as Mn,unshieldFeeQueryOptions as Nn,unshieldMutationOptions as Pn,unshieldMutationOptions as Fn,unwrapAllMutationOptions as In,unwrapAllMutationOptions as Ln,unwrapMutationOptions as Rn,unwrapMutationOptions as zn,wrapperDiscoveryQueryOptions as Bn,wrapperDiscoveryQueryOptions as I,zamaQueryKeys as Vn,zamaQueryKeys as L}from"@zama-fhe/sdk/query";import{skipToken as R,useMutation as z,useQueries as Hn,useQuery as Un,useQueryClient as B,useSuspenseQuery as Wn}from"@tanstack/react-query";import{createContext as Gn,useContext as Kn,useEffect as V,useMemo as H,useRef as qn}from"react";import{jsx as Jn}from"react/jsx-runtime";const U=Gn(null);function Yn({children:e,relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,onEvent:s}){let c=B(),l=qn(s);V(()=>{l.current=s});let u=H(()=>n?.subscribe?{onDisconnect:()=>O(c),onAccountChange:()=>O(c),onChainChange:()=>O(c)}:void 0,[c,n]),d=H(()=>new we({relayer:t,signer:n,storage:r,sessionStorage:i,keypairTTL:a,sessionTTL:o,onEvent:l.current,signerLifecycleCallbacks:u}),[t,n,r,i,a,o,u]);return V(()=>()=>d.dispose(),[d]),Jn(U.Provider,{value:d,children:e})}function W(){let e=Kn(U);if(!e)throw Error(`useZamaSDK must be used within a <ZamaProvider>. Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.`);return e}function Xn(){return z(Jt(W()))}const G={value:(e,t)=>L.decryption.handle(e,t)};function Zn(){let e=W(),t=B();return z({mutationFn:t=>e.relayer.userDecrypt(t),onSuccess:e=>{for(let[n,r]of Object.entries(e))t.setQueryData(G.value(n),r)}})}function Qn(){let e=W(),t=B();return z({mutationFn:t=>e.relayer.publicDecrypt(t),onSuccess:e=>{for(let[n,r]of Object.entries(e.clearValues))t.setQueryData(G.value(n),r)}})}function $n(){let e=W();return z({mutationFn:()=>e.relayer.generateKeypair()})}function er(){let e=W();return z({mutationFn:({publicKey:t,contractAddresses:n,startTimestamp:r,durationDays:i})=>e.relayer.createEIP712(t,n,r,i)})}function tr(){let e=W();return z({mutationFn:({publicKey:t,contractAddresses:n,delegatorAddress:r,startTimestamp:i,durationDays:a})=>e.relayer.createDelegatedUserDecryptEIP712(t,n,r,i,a)})}function nr(){let e=W();return z({mutationFn:t=>e.relayer.delegatedUserDecrypt(t)})}function rr(){let e=W();return z({mutationFn:t=>e.relayer.requestZKProofVerification(t)})}function K(e){return Un({...e,queryKeyHashFn:w})}function q(e){return Wn({...e,queryKeyHashFn:w})}function ir(){return K({...j(W())})}function ar(e){return K({...dn(W(),e)})}function or(e){let t=W(),n=B(),r=e?.callbacks;return z({mutationKey:[`userDecryptFlow`],mutationFn:async({handles:e,durationDays:n=1})=>{let i=await t.relayer.generateKeypair();r?.onKeypairGenerated?.();let a=[...new Set(e.map(e=>e.contractAddress))],o=Math.floor(Date.now()/1e3),s=await t.relayer.createEIP712(i.publicKey,a,o,n);r?.onEIP712Created?.();let c=await t.signer.signTypedData(s);r?.onSigned?.(c);let l=await t.signer.getAddress(),u={},d=new Map;for(let t of e){let e=d.get(t.contractAddress)??[];e.push(t.handle),d.set(t.contractAddress,e)}for(let[e,r]of d){let s=await t.relayer.userDecrypt({handles:r,contractAddress:e,signedContractAddresses:a,privateKey:i.privateKey,publicKey:i.publicKey,signature:c,signerAddress:l,startTimestamp:o,durationDays:n});Object.assign(u,s)}let f=u;return r?.onDecrypted?.(f),f},onSuccess:e=>{for(let[t,r]of Object.entries(e))n.setQueryData(G.value(t),r)}})}function sr(e){return K({queryKey:G.value(e??`0x`),queryFn:()=>void 0,enabled:!1})}function cr(e){let t=Hn({queries:e.map(e=>({queryKey:G.value(e),queryKeyHashFn:w,queryFn:()=>void 0,enabled:!1}))}),n={};for(let r=0;r<e.length;r++)n[e[r]]=t[r].data;return{data:n,results:t}}function J(e){let t=W();return H(()=>t.createToken(e.tokenAddress,e.wrapperAddress),[t,e.tokenAddress,e.wrapperAddress])}function Y(e){let t=W();return H(()=>t.createReadonlyToken(e),[t,e])}function lr(e,t){let{tokenAddress:n,handleRefetchInterval:r}=e,i=t?.enabled,a=Y(n),o=K({...M(a.signer)}).data,s=Mt(a.signer,n,{owner:o,pollingInterval:r}),c=K({...s,enabled:(s.enabled??!0)&&(i??!0)}),l=c.data,u=Ot(a,{handle:l,owner:o});return{...K({...u,...t,enabled:(u.enabled??!0)&&(i??!0)}),handleQuery:c}}function ur(e,t){let{tokenAddresses:n,handleRefetchInterval:r,maxConcurrency:i}=e,a=t?.enabled,o=W(),s=K({...M(o.signer)}).data,c=H(()=>n.map(e=>o.createReadonlyToken(e)),[o,n]),l=Pt(o.signer,n,{owner:s,pollingInterval:r}),u=K({...l,enabled:(l.enabled??!0)&&(a??!0)}),d=u.data,f=Array.isArray(d)&&d.length===n.length,p=At(c,{owner:s,handles:d,maxConcurrency:i,resultAddresses:n}),m=p.enabled??!0;return{...K({...p,...t,enabled:m&&f&&(a??!0)}),handlesQuery:u}}function dr(e){return z({...yt(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}function fr(){let e=W(),t=K({...M(e.signer)}).data,n=t?on(e,{account:t}):{queryKey:L.isAllowed.all,queryFn:R},r=`enabled`in n?n.enabled??!0:!0;return K({...n,enabled:r})}function pr(e){return z({..._n(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}function mr(e){return z({...yn(W()),...e,onSuccess:(t,n,r,i)=>{e?.onSuccess?.(t,n,r,i),i.client.invalidateQueries({queryKey:L.isAllowed.all})}})}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=L.confidentialBalance.token(t);await e.cancelQueries({queryKey:i});let a=e.getQueriesData({queryKey:i});for(let[t,i]of a)i!==void 0&&e.setQueryData(t,r===`add`?i+n:i-n);return a}function Q(e,t){for(let[n,r]of t)e.setQueryData(n,r)}function $({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),rn(o.client,t)},onSettled:(t,n,i,a,o)=>{let{callerContext:s}=X(e,a);r?.onSettled?.(t,n,i,s,o)}}}function hr(e,t){let n=J(e),r=B();return z({...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),T(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 gr(e,t){return z({...Lt(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),T(a.client,e.tokenAddress)}})}function _r(e,t){return z({...Et(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),tn(a.client,e.tokenAddress)}})}function vr(e,t){let{spender:n,holder:r,...i}=e,a=t?.enabled,o=J(i),s=K({...M(o.signer),enabled:r===void 0}),c=r??s.data,l=n&&c?C(o.signer,o.address,{holder:c,spender:n}):{queryKey:L.confidentialIsApproved.token(e.tokenAddress),queryFn:R};return K({...l,...t,enabled:(`enabled`in l?l.enabled??!0:!0)&&(a??!0)})}function yr(e){let{spender:t,holder:n,...r}=e,i=J(r),a=q({...M(i.signer)}),o=n??a.data;return q({...C(i.signer,i.address,{holder:o,spender:t})})}function br(e,t){let n=J(e),r=B();return z({...Tn(n),...t,...$({optimistic:e.optimistic,tokenAddress:e.tokenAddress,queryClient:r,options:t})})}function xr(e,t){let n=J(e),r=B();return z({...xn(n),...t,...$({optimistic:e.optimistic,tokenAddress:e.tokenAddress,queryClient:r,options:t})})}function Sr(e,t){return z({...zn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function Cr(e,t){return z({...Ln(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),D(a.client,e.tokenAddress)}})}function wr(e,t){return z({...$t(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Tr(e,t){return z({...Fn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Er(e,t){return z({...jn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Dr(e,t){return z({...pn(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),E(a.client,e.tokenAddress)}})}function Or(e,t){let{tokenAddress:n,wrapperAddress:r}=e,i=Y(n),a=K({...M(i.signer)}).data,o=F(i.signer,n,{owner:a,wrapperAddress:r});return K({...o,...t,enabled:(o.enabled??!0)&&(t?.enabled??!0)})}function kr(e){let{tokenAddress:t,wrapperAddress:n}=e,r=Y(t),i=q({...M(r.signer)}).data;return q({...F(r.signer,t,{owner:i,wrapperAddress:n})})}function Ar(e,t){let{tokenAddress:n,coordinatorAddress:r}=e,i=Y(n);return K({...r?I(i.signer,n,{coordinatorAddress:r}):{queryKey:L.wrapperDiscovery.all,queryFn:R},...t})}function jr(e){let{tokenAddress:t,coordinatorAddress:n}=e;return q({...I(Y(t).signer,t,{coordinatorAddress:n})})}function Mr(e,t){return K({...N(Y(e).signer,e),...t})}function Nr(e){return q({...N(Y(e).signer,e)})}function Pr(e){let{tokenAddress:t,userAddress:n,logs:r,decrypt:i}=e;return K({..._t(Y(t),{userAddress:n,logs:r,decrypt:i??!0,logsKey:Kt(r)})})}function Fr(e,t){return z({...Ut(J(e)),...t,onSuccess:(e,n,r,i)=>{i.client.invalidateQueries({queryKey:L.delegationStatus.all}),t?.onSuccess?.(e,n,r,i)}})}function Ir(e,t){return z({...hn(J(e)),...t,onSuccess:(e,n,r,i)=>{i.client.invalidateQueries({queryKey:L.delegationStatus.all}),t?.onSuccess?.(e,n,r,i)}})}function Lr(e,t){let n=Y(e.tokenAddress),r=!!(e.delegatorAddress&&e.delegateAddress);return K({...e.delegatorAddress&&e.delegateAddress?Gt(n,{delegatorAddress:e.delegatorAddress,delegateAddress:e.delegateAddress}):{queryKey:L.delegationStatus.all,queryFn:R},enabled:r,...t})}function Rr(e,t){return z({...Vt(Y(e)),...t})}function zr(e,t){return z({mutationKey:[`zama.batchDecryptBalancesAs`,...e.map(e=>e.address)],mutationFn:async t=>ce.batchDecryptBalancesAs(e,t),...t})}function Br(e,t){return z({...xt(J(e)),...t,onSuccess:(n,r,i,a)=>{t?.onSuccess?.(n,r,i,a),nn(a.client,e.tokenAddress)}})}function Vr(e,t){return K({...k(Y(e).signer,e),...t})}function Hr(e){return q({...k(Y(e).signer,e)})}function Ur(e,t){return K({...A(Y(e).signer,e),...t})}function Wr(e){return q({...A(Y(e).signer,e)})}function Gr(e,t){return K({...P(Y(e).signer,e),...t})}function Kr(e){return q({...P(Y(e).signer,e)})}function qr(e,t){let n=Cn(W().signer,e);return K({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function Jr(e,t){let n=Nn(W().signer,e);return K({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function Yr(e,t){let n=wt(W().signer,e);return K({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}function Xr(e,t){let n=Xt(W().signer,e);return K({...n,...t,enabled:(n.enabled??!0)&&(t?.enabled??!0)})}export{e as ApprovalFailedError,t as BATCH_SWAP_ABI,n as ChromeSessionStorage,r as CredentialsManager,i as DEPLOYMENT_COORDINATOR_ABI,a as DecryptionFailedError,o as DelegatedCredentialsManager,s as ENCRYPTION_ABI,c as ERC165_ABI,l as ERC20_ABI,u as ERC20_METADATA_ABI,d as ERC7984_INTERFACE_ID,f as ERC7984_WRAPPER_INTERFACE_ID,p as EncryptionFailedError,m as FEE_MANAGER_ABI,ee as HardhatConfig,te as IndexedDBStorage,ne as InvalidKeypairError,re as KeypairExpiredError,ie as MainnetConfig,ae as MemoryStorage,oe as NoCiphertextError,se as ReadonlyToken,le as RelayerRequestFailedError,ue as RelayerWeb,de as SepoliaConfig,fe as SigningFailedError,pe as SigningRejectedError,me as TOKEN_TOPICS,he as TRANSFER_BATCHER_ABI,ge as Token,_e as Topics,ve as TransactionRevertedError,ye as WRAPPER_ABI,be as ZERO_HANDLE,xe as ZamaError,Se as ZamaErrorCode,Yn as ZamaProvider,Ce as ZamaSDK,Te as ZamaSDKEvents,gt as activityFeedQueryOptions,vt as allowMutationOptions,Ee as allowanceContract,De as applyDecryptedValues,Oe as approveContract,bt as approveUnderlyingMutationOptions,ke as balanceOfContract,St as batchDecryptBalancesAsMutationOptions,Ct as batchTransferFeeQueryOptions,Ae as chromeSessionStorage,je as clearPendingUnshield,Tt as confidentialApproveMutationOptions,h as confidentialBalanceOfContract,Dt as confidentialBalanceQueryOptions,kt as confidentialBalancesQueryOptions,g as confidentialBatchTransferContract,jt as confidentialHandleQueryOptions,Nt as confidentialHandlesQueryOptions,Ft as confidentialIsApprovedQueryOptions,_ as confidentialTotalSupplyContract,v as confidentialTransferContract,y as confidentialTransferFromContract,It as confidentialTransferFromMutationOptions,Rt as confidentialTransferMutationOptions,b as decimalsContract,x as decodeConfidentialTransfer,S as decodeOnChainEvent,Me as decodeOnChainEvents,Ne as decodeUnwrapRequested,Pe as decodeUnwrappedFinalized,Fe as decodeUnwrappedStarted,Ie as decodeWrapped,Bt as decryptBalanceAsMutationOptions,G as decryptionKeys,Ht as delegateDecryptionMutationOptions,Wt as delegationStatusQueryOptions,Le as deploymentCoordinatorContract,qt as encryptMutationOptions,Re as extractEncryptedHandles,Yt as feeRecipientQueryOptions,Zt as filterQueryOptions,ze as finalizeUnwrapContract,Qt as finalizeUnwrapMutationOptions,Be as findUnwrapRequested,Ve as findWrapped,He as getBatchTransferFeeContract,Ue as getFeeRecipientContract,We as getUnwrapFeeContract,Ge as getWrapFeeContract,Ke as getWrapperContract,en as hashFn,qe as indexedDBStorage,an as isAllowedQueryOptions,sn as isConfidentialQueryOptions,Je as isConfidentialTokenContract,Ye as isConfidentialWrapperContract,Xe as isFinalizeUnwrapOperatorContract,Ze as isOperatorContract,cn as isWrapperQueryOptions,Qe as loadPendingUnshield,$e as matchZamaError,et as nameContract,tt as parseActivityFeed,ln as publicKeyQueryOptions,un as publicParamsQueryOptions,nt as rateContract,fn as resumeUnshieldMutationOptions,mn as revokeDelegationMutationOptions,gn as revokeMutationOptions,vn as revokeSessionMutationOptions,rt as savePendingUnshield,it as setFinalizeUnwrapOperatorContract,at as setOperatorContract,bn as shieldETHMutationOptions,Sn as shieldFeeQueryOptions,wn as shieldMutationOptions,En as signerAddressQueryOptions,ot as sortByBlockNumber,st as supportsInterfaceContract,ct as symbolContract,Dn as tokenMetadataQueryOptions,lt as totalSupplyContract,On as totalSupplyQueryOptions,kn as underlyingAllowanceQueryOptions,ut as underlyingContract,An as unshieldAllMutationOptions,Mn as unshieldFeeQueryOptions,Pn as unshieldMutationOptions,In as unwrapAllMutationOptions,dt as unwrapContract,ft as unwrapFromBalanceContract,Rn as unwrapMutationOptions,Pr as useActivityFeed,dr as useAllowTokens,Br as useApproveUnderlying,zr as useBatchDecryptBalancesAs,Yr as useBatchTransferFee,_r as useConfidentialApprove,lr as useConfidentialBalance,ur as useConfidentialBalances,vr as useConfidentialIsApproved,yr as useConfidentialIsApprovedSuspense,hr as useConfidentialTransfer,gr as useConfidentialTransferFrom,tr as useCreateDelegatedUserDecryptEIP712,er as useCreateEIP712,Rr as useDecryptBalanceAs,Fr as useDelegateDecryption,nr as useDelegatedUserDecrypt,Lr as useDelegationStatus,Xn as useEncrypt,Xr as useFeeRecipient,wr as useFinalizeUnwrap,$n as useGenerateKeypair,fr as useIsAllowed,Vr as useIsConfidential,Hr as useIsConfidentialSuspense,Ur as useIsWrapper,Wr as useIsWrapperSuspense,Mr as useMetadata,Nr as useMetadataSuspense,Qn as usePublicDecrypt,ir as usePublicKey,ar as usePublicParams,Y as useReadonlyToken,rr as useRequestZKProofVerification,Dr as useResumeUnshield,Ir as useRevokeDelegation,mr as useRevokeSession,pr as useRevokeTokens,br as useShield,xr as useShieldETH,qr as useShieldFee,J as useToken,Gr as useTotalSupply,Kr as useTotalSupplySuspense,Or as useUnderlyingAllowance,kr as useUnderlyingAllowanceSuspense,Tr as useUnshield,Er as useUnshieldAll,Jr as useUnshieldFee,Sr as useUnwrap,Cr as useUnwrapAll,Zn as useUserDecrypt,or as useUserDecryptFlow,sr as useUserDecryptedValue,cr as useUserDecryptedValues,Ar as useWrapperDiscovery,jr as useWrapperDiscoverySuspense,W as useZamaSDK,pt as wrapContract,mt as wrapETHContract,Bn as wrapperDiscoveryQueryOptions,ht as wrapperExistsContract,Vn 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","zamaQueryKeys","publicKeyQueryOptions","hashFn","publicParamsQueryOptions","hashFn","hashFn","hashFn","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","useQuery","signerAddressQueryOptions","confidentialHandleQueryOptions","confidentialBalanceQueryOptions","useQuery","signerAddressQueryOptions","confidentialHandlesQueryOptions","confidentialBalancesQueryOptions","allowMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","isAllowedQueryOptions","zamaQueryKeys","revokeMutationOptions","zamaQueryKeys","revokeSessionMutationOptions","zamaQueryKeys","zamaQueryKeys","confidentialTransferMutationOptions","confidentialTransferFromMutationOptions","confidentialApproveMutationOptions","useQuery","signerAddressQueryOptions","confidentialIsApprovedQueryOptions","zamaQueryKeys","useSuspenseQuery","shieldMutationOptions","shieldETHMutationOptions","unwrapMutationOptions","unwrapAllMutationOptions","finalizeUnwrapMutationOptions","unshieldMutationOptions","unshieldAllMutationOptions","resumeUnshieldMutationOptions","useQuery","signerAddressQueryOptions","underlyingAllowanceQueryOptions","useSuspenseQuery","useQuery","wrapperDiscoveryQueryOptions","zamaQueryKeys","useSuspenseQuery","useQuery","tokenMetadataQueryOptions","useSuspenseQuery","useQuery","activityFeedQueryOptions","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","shieldFeeQueryOptions","useQuery","unshieldFeeQueryOptions","batchTransferFeeQueryOptions","feeRecipientQueryOptions"],"sources":["../src/provider.tsx","../src/relayer/use-encrypt.ts","../src/relayer/decryption-cache.ts","../src/relayer/use-user-decrypt.ts","../src/relayer/use-public-decrypt.ts","../src/relayer/use-generate-keypair.ts","../src/relayer/use-create-eip712.ts","../src/relayer/use-create-delegated-user-decrypt-eip712.ts","../src/relayer/use-delegated-user-decrypt.ts","../src/relayer/use-request-zk-proof-verification.ts","../src/relayer/use-public-key.ts","../src/relayer/use-public-params.ts","../src/relayer/use-user-decrypt-flow.ts","../src/relayer/use-user-decrypted-value.ts","../src/relayer/use-user-decrypted-values.ts","../src/token/use-token.ts","../src/token/use-readonly-token.ts","../src/utils/query.ts","../src/token/use-confidential-balance.ts","../src/token/use-confidential-balances.ts","../src/token/use-allow.ts","../src/token/use-is-allowed.ts","../src/token/use-revoke.ts","../src/token/use-revoke-session.ts","../src/token/optimistic-balance-update.ts","../src/token/use-confidential-transfer.ts","../src/token/use-confidential-transfer-from.ts","../src/token/use-confidential-approve.ts","../src/token/use-confidential-is-approved.ts","../src/token/use-shield.ts","../src/token/use-shield-eth.ts","../src/token/use-unwrap.ts","../src/token/use-unwrap-all.ts","../src/token/use-finalize-unwrap.ts","../src/token/use-unshield.ts","../src/token/use-unshield-all.ts","../src/token/use-resume-unshield.ts","../src/token/use-underlying-allowance.ts","../src/token/use-wrapper-discovery.ts","../src/token/use-metadata.ts","../src/token/use-activity-feed.ts","../src/token/use-approve-underlying.ts","../src/token/use-is-confidential.ts","../src/token/use-total-supply.ts","../src/token/use-fees.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n GenericSigner,\n GenericStorage,\n RelayerSDK,\n ZamaSDKEventListener,\n} from \"@zama-fhe/sdk\";\nimport { ZamaSDK } from \"@zama-fhe/sdk\";\nimport { invalidateWalletLifecycleQueries } from \"@zama-fhe/sdk/query\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\n/** Props for {@link ZamaProvider}. */\nexport interface ZamaProviderProps extends PropsWithChildren {\n /** FHE relayer backend (RelayerWeb for browser, RelayerNode for server). */\n relayer: RelayerSDK;\n /** Wallet signer (`ViemSigner`, `EthersSigner`, or custom {@link GenericSigner}). */\n signer: GenericSigner;\n /** Credential storage backend (IndexedDBStorage for browser, MemoryStorage for tests). */\n storage: GenericStorage;\n /**\n * Session storage for wallet signatures. Defaults to in-memory (lost on reload).\n * Pass a `chrome.storage.session`-backed store for web extensions.\n */\n sessionStorage?: GenericStorage;\n /**\n * How long the ML-KEM re-encryption keypair remains valid, in seconds.\n * Default: `86400` (1 day). Must be positive — `0` is rejected.\n */\n keypairTTL?: number;\n /**\n * Controls how long session signatures (EIP-712 wallet signatures) remain valid, in seconds.\n * Default: `2592000` (30 days).\n * - `0`: never persist — every operation triggers a signing prompt (high-security mode).\n * - Positive number: seconds until the session signature expires and requires re-authentication.\n */\n sessionTTL?: number;\n /** Callback invoked on SDK lifecycle events. */\n onEvent?: ZamaSDKEventListener;\n}\n\nconst ZamaSDKContext = createContext<ZamaSDK | null>(null);\n\n/**\n * Provides a {@link ZamaSDK} instance to all descendant hooks.\n *\n * @example\n * ```tsx\n * <ZamaProvider relayer={relayer} signer={signer} storage={storage}>\n * <App />\n * </ZamaProvider>\n * ```\n */\nexport function ZamaProvider({\n children,\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n onEvent,\n}: ZamaProviderProps) {\n const queryClient = useQueryClient();\n\n // Stabilize onEvent so an inline arrow doesn't recreate the SDK every render.\n const onEventRef = useRef(onEvent);\n useEffect(() => {\n onEventRef.current = onEvent;\n });\n\n const signerLifecycleCallbacks = useMemo(\n () =>\n signer?.subscribe\n ? {\n onDisconnect: () => invalidateWalletLifecycleQueries(queryClient),\n onAccountChange: () => invalidateWalletLifecycleQueries(queryClient),\n onChainChange: () => invalidateWalletLifecycleQueries(queryClient),\n }\n : undefined,\n [queryClient, signer],\n );\n\n const sdk = useMemo(\n () =>\n new ZamaSDK({\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n onEvent: onEventRef.current,\n signerLifecycleCallbacks,\n }),\n [relayer, signer, storage, sessionStorage, keypairTTL, sessionTTL, signerLifecycleCallbacks],\n );\n\n // Clean up signer subscriptions on unmount without terminating the\n // caller-owned relayer. dispose() only unsubscribes from wallet events\n // and is idempotent.\n useEffect(() => () => sdk.dispose(), [sdk]);\n\n return <ZamaSDKContext.Provider value={sdk}>{children}</ZamaSDKContext.Provider>;\n}\n\n/**\n * Access the {@link ZamaSDK} instance from context.\n * Throws if called outside a {@link ZamaProvider} or when no signer is provided.\n *\n * @example\n * ```tsx\n * const sdk = useZamaSDK();\n * const token = sdk.createReadonlyToken(\"0x...\");\n * ```\n */\nexport function useZamaSDK(): ZamaSDK {\n const context = useContext(ZamaSDKContext);\n\n if (!context) {\n throw new Error(\n \"useZamaSDK must be used within a <ZamaProvider>. \" +\n \"Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.\",\n );\n }\n\n return context;\n}\n","\"use client\";\n\nimport type { EncryptParams, EncryptResult } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { encryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Encrypt a plaintext value using FHE.\n * Calls the relayer's `encrypt` method via a mutation.\n *\n * @returns A mutation whose `mutate` accepts {@link EncryptParams}.\n *\n * @example\n * ```tsx\n * const encrypt = useEncrypt();\n * encrypt.mutate({ values: [1000n], bits: [64] });\n * ```\n */\nexport function useEncrypt() {\n const sdk = useZamaSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(sdk));\n}\n","import { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { type Address } from \"@zama-fhe/sdk\";\nimport { type Handle } from \"@zama-fhe/sdk\";\n\n/**\n * Query key helpers for the shared decryption cache.\n * Used by useUserDecrypt/usePublicDecrypt to populate,\n * and by useUserDecryptedValue to read.\n */\nexport const decryptionKeys = {\n value: (handle: Handle, contractAddress?: Address) =>\n zamaQueryKeys.decryption.handle(handle, contractAddress),\n};\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle, UserDecryptParams } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Thin wrapper around sdk.userDecrypt().\n * Caller is responsible for providing all params (keypair, signature, etc.).\n * For the full orchestration (signature management, EIP712 signing),\n * see the app-level useUserDecryptFlow hook.\n *\n * On success, populates the decryption cache so useUserDecryptedValue/useUserDecryptedValues\n * can read the results.\n */\nexport function useUserDecrypt() {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptParams>({\n mutationFn: (params) => sdk.relayer.userDecrypt(params),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data) as [Handle, ClearValueType][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle, PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using the network public key (no credential needed).\n * On success, populates the decryption cache so {@link useUserDecryptedValue} / {@link useUserDecryptedValues}\n * can read the results.\n *\n * @returns A mutation whose `mutate` accepts an array of handle strings.\n *\n * @example\n * ```tsx\n * const publicDecrypt = usePublicDecrypt();\n * publicDecrypt.mutate([\"0xHandle1\", \"0xHandle2\"]);\n * // publicDecrypt.data?.clearValues => { \"0xHandle1\": 500n, ... }\n * ```\n */\nexport function usePublicDecrypt() {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n return useMutation<PublicDecryptResult, Error, Handle[]>({\n mutationFn: (handles) => sdk.relayer.publicDecrypt(handles),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data.clearValues) as [\n Handle,\n ClearValueType,\n ][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Generate an FHE keypair via the relayer.\n * Returns a public/private key pair for use in decrypt authorization.\n *\n * @returns A mutation whose `mutate` takes no parameters.\n *\n * @example\n * ```tsx\n * const generateKeypair = useGenerateKeypair();\n * generateKeypair.mutate();\n * // generateKeypair.data?.publicKey, generateKeypair.data?.privateKey\n * ```\n */\nexport function useGenerateKeypair() {\n const sdk = useZamaSDK();\n return useMutation({\n mutationFn: () => sdk.relayer.generateKeypair(),\n });\n}\n","\"use client\";\n\nimport type { EIP712TypedData } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\nimport { type Address } from \"@zama-fhe/sdk\";\n\n/** Parameters for {@link useCreateEIP712}. */\nexport interface CreateEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: `0x${string}`;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Unix timestamp (seconds) when the credential becomes valid. */\n startTimestamp: number;\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\n\n/**\n * Create EIP-712 typed data for signing an FHE decrypt credential.\n * The returned typed data is signed by the wallet to authorize decryption.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateEIP712() {\n const sdk = useZamaSDK();\n return useMutation<EIP712TypedData, Error, CreateEIP712Params>({\n mutationFn: ({ publicKey, contractAddresses, startTimestamp, durationDays }) =>\n sdk.relayer.createEIP712(publicKey, contractAddresses, startTimestamp, durationDays),\n });\n}\n","\"use client\";\n\nimport type { Address, KmsDelegatedUserDecryptEIP712Type } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Parameters for {@link useCreateDelegatedUserDecryptEIP712}. */\nexport interface CreateDelegatedUserDecryptEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: `0x${string}`;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Address of the wallet that delegated decrypt authority. */\n delegatorAddress: Address;\n /** Unix timestamp (seconds) when the credential becomes valid. */\n startTimestamp: number;\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\n\n/**\n * Create EIP-712 typed data for a delegated user decrypt credential.\n * Used when one wallet authorizes another to decrypt on its behalf.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateDelegatedUserDecryptEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateDelegatedUserDecryptEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * delegatorAddress: \"0xDelegator\",\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateDelegatedUserDecryptEIP712() {\n const sdk = useZamaSDK();\n return useMutation<\n KmsDelegatedUserDecryptEIP712Type,\n Error,\n CreateDelegatedUserDecryptEIP712Params\n >({\n mutationFn: ({\n publicKey,\n contractAddresses,\n delegatorAddress,\n startTimestamp,\n durationDays,\n }) =>\n sdk.relayer.createDelegatedUserDecryptEIP712(\n publicKey,\n contractAddresses,\n delegatorAddress,\n startTimestamp,\n durationDays,\n ),\n });\n}\n","\"use client\";\n\nimport type { DelegatedUserDecryptParams, ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using delegated user credentials.\n * Returns a map of handle → plaintext bigint.\n *\n * @returns A mutation whose `mutate` accepts {@link DelegatedUserDecryptParams}.\n *\n * @example\n * ```tsx\n * const decrypt = useDelegatedUserDecrypt();\n * decrypt.mutate({ handles: [\"0xHandle1\"], ...credentials });\n * // decrypt.data => { \"0xHandle1\": 1000n }\n * ```\n */\nexport function useDelegatedUserDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<Record<Handle, ClearValueType>, Error, DelegatedUserDecryptParams>({\n mutationFn: (params) => sdk.relayer.delegatedUserDecrypt(params),\n });\n}\n","\"use client\";\n\nimport type { InputProofBytesType, ZKProofLike } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Submit a ZK proof for on-chain verification.\n * Returns the input proof bytes for use in contract calls.\n *\n * @returns A mutation whose `mutate` accepts a {@link ZKProofLike}.\n *\n * @example\n * ```tsx\n * const verify = useRequestZKProofVerification();\n * verify.mutate(zkProof);\n * // verify.data => Uint8Array (input proof bytes)\n * ```\n */\nexport function useRequestZKProofVerification() {\n const sdk = useZamaSDK();\n return useMutation<InputProofBytesType, Error, ZKProofLike>({\n mutationFn: (zkProof) => sdk.relayer.requestZKProofVerification(zkProof),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { hashFn, publicKeyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicKeyQueryOptions };\n\n/** Shape of the FHE public key data returned by the relayer. */\nexport interface PublicKeyData {\n /** Unique identifier for this public key version. */\n publicKeyId: string;\n /** The raw FHE public key bytes. */\n publicKey: Uint8Array;\n}\n\n/**\n * Fetch the FHE network public key from the relayer.\n * Cached indefinitely since the key does not change during a session.\n *\n * @returns Query result with `data: PublicKeyData | null`.\n *\n * @example\n * ```tsx\n * const { data: publicKey } = usePublicKey();\n * // publicKey?.publicKeyId, publicKey?.publicKey\n * ```\n */\nexport function usePublicKey() {\n const sdk = useZamaSDK();\n return useQuery({\n ...publicKeyQueryOptions(sdk),\n queryKeyHashFn: hashFn,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { hashFn, publicParamsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicParamsQueryOptions };\n\n/** Shape of the FHE public parameters returned by the relayer. */\nexport interface PublicParamsData {\n /** The raw public parameters bytes (WASM-ready). */\n publicParams: Uint8Array;\n /** Unique identifier for this public params version. */\n publicParamsId: string;\n}\n\n/**\n * Fetch FHE public parameters for a given bit size from the relayer.\n * Cached indefinitely since parameters do not change during a session.\n *\n * @param bits - The FHE bit size to fetch parameters for (e.g. 2048).\n * @returns Query result with `data: PublicParamsData | null`.\n *\n * @example\n * ```tsx\n * const { data: params } = usePublicParams(2048);\n * // params?.publicParams, params?.publicParamsId\n * ```\n */\nexport function usePublicParams(bits: number) {\n const sdk = useZamaSDK();\n return useQuery({\n ...publicParamsQueryOptions(sdk, bits),\n queryKeyHashFn: hashFn,\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { Address, ClearValueType, Handle, Hex } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/** A handle to decrypt, paired with its originating contract address. */\nexport interface DecryptHandle {\n handle: Handle;\n contractAddress: Address;\n}\n\n/** Parameters for {@link useUserDecryptFlow}. */\nexport interface UserDecryptFlowParams {\n /** Encrypted handles to decrypt. */\n handles: DecryptHandle[];\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\n\n/** Progress callbacks for each step of the decrypt flow. */\nexport interface UserDecryptFlowCallbacks {\n /** Fired after the keypair is generated. */\n onKeypairGenerated?: () => void;\n /** Fired after the EIP-712 typed data is created, before wallet signing. */\n onEIP712Created?: () => void;\n /** Fired after the wallet signature is obtained. */\n onSigned?: (signature: Hex) => void;\n /** Fired after decryption completes. */\n onDecrypted?: (values: Record<Handle, ClearValueType>) => void;\n}\n\n/** Configuration for {@link useUserDecryptFlow}. */\nexport interface UseUserDecryptFlowConfig {\n /** Optional progress callbacks. */\n callbacks?: UserDecryptFlowCallbacks;\n}\n\n/**\n * High-level orchestration hook for user decryption.\n * Handles the full flow: keypair generation → EIP-712 creation → wallet signature → decryption.\n *\n * On success, populates the decryption cache so `useUserDecryptedValue` / `useUserDecryptedValues`\n * can read the results.\n *\n * @param config - Optional callbacks for step-by-step UX feedback.\n * @returns A mutation whose `mutate` accepts {@link UserDecryptFlowParams}.\n *\n * @example\n * ```tsx\n * const decryptFlow = useUserDecryptFlow({\n * callbacks: { onSigned: () => setStep(\"decrypting\") },\n * });\n * decryptFlow.mutate({\n * handles: [{ handle: \"0xHandle\", contractAddress: \"0xContract\" }],\n * durationDays: 7,\n * });\n * ```\n */\nexport function useUserDecryptFlow(config?: UseUserDecryptFlowConfig) {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n const callbacks = config?.callbacks;\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptFlowParams>({\n mutationKey: [\"userDecryptFlow\"],\n mutationFn: async ({ handles, durationDays = 1 }) => {\n // Step 1: Generate keypair\n const keypair = await sdk.relayer.generateKeypair();\n callbacks?.onKeypairGenerated?.();\n\n // Step 2: Create EIP-712 typed data\n const contractAddresses = [...new Set(handles.map((h) => h.contractAddress))];\n const startTimestamp = Math.floor(Date.now() / 1000);\n const eip712 = await sdk.relayer.createEIP712(\n keypair.publicKey,\n contractAddresses,\n startTimestamp,\n durationDays,\n );\n callbacks?.onEIP712Created?.();\n\n // Step 3: Sign with wallet\n const signature = await sdk.signer.signTypedData(eip712);\n callbacks?.onSigned?.(signature);\n\n // Step 4: Decrypt — group handles by contract address\n const signerAddress = await sdk.signer.getAddress();\n const allResults: Partial<Record<Handle, ClearValueType>> = {};\n\n // Decrypt per contract address (the relayer requires handles from the same contract)\n const handlesByContract = new Map<Address, Handle[]>();\n for (const h of handles) {\n const list = handlesByContract.get(h.contractAddress) ?? [];\n list.push(h.handle);\n handlesByContract.set(h.contractAddress, list);\n }\n\n for (const [contractAddress, contractHandles] of handlesByContract) {\n const result = await sdk.relayer.userDecrypt({\n handles: contractHandles,\n contractAddress,\n signedContractAddresses: contractAddresses,\n privateKey: keypair.privateKey,\n publicKey: keypair.publicKey,\n signature,\n signerAddress,\n startTimestamp,\n durationDays,\n });\n Object.assign(allResults, result);\n }\n\n const results = allResults as Record<Handle, ClearValueType>;\n callbacks?.onDecrypted?.(results);\n return results;\n },\n onSuccess: (data) => {\n // Populate the shared decryption cache\n for (const [handle, value] of Object.entries(data) as [Handle, ClearValueType][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\nimport { decryptionKeys } from \"./decryption-cache\";\n\n/**\n * Look up a single cached decrypted value by its handle.\n * Values are populated automatically when useUserDecrypt or usePublicDecrypt succeed.\n * You can also populate manually via queryClient.setQueryData(decryptionKeys.value(handle), value).\n */\nexport function useUserDecryptedValue(handle: Handle | undefined) {\n return useQuery<ClearValueType>({\n queryKey: decryptionKeys.value(handle ?? \"0x\"),\n queryKeyHashFn: hashFn,\n queryFn: () => undefined as never,\n enabled: false,\n });\n}\n","\"use client\";\n\nimport { useQueries } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\nimport { decryptionKeys } from \"./decryption-cache\";\n\n/**\n * Look up multiple cached decrypted values by their handles.\n * Values are populated automatically when useUserDecrypt or usePublicDecrypt succeed.\n */\nexport function useUserDecryptedValues(handles: Handle[]) {\n const results = useQueries({\n queries: handles.map((handle) => ({\n queryKey: decryptionKeys.value(handle),\n queryKeyHashFn: hashFn,\n queryFn: () => undefined as never,\n enabled: false,\n })),\n });\n\n const data: Partial<Record<Handle, ClearValueType | undefined>> = {};\n for (let i = 0; i < handles.length; i++) {\n data[handles[i]!] = results[i]!.data as ClearValueType | undefined;\n }\n\n return {\n data,\n results,\n };\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Base configuration shared by all mutation hooks that need a Token instance. */\nexport interface UseZamaConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Address of the wrapper contract (required for shield/unshield operations). */\n wrapperAddress?: Address;\n}\n\n/**\n * Get a {@link Token} instance, memoized by address pair.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param config - Token and optional wrapper addresses.\n * @returns A memoized `Token` instance.\n *\n * @example\n * ```tsx\n * const token = useToken({ tokenAddress: \"0xToken\", wrapperAddress: \"0xWrapper\" });\n * ```\n */\nexport function useToken(config: UseZamaConfig) {\n const sdk = useZamaSDK();\n\n return useMemo(\n () => sdk.createToken(config.tokenAddress, config.wrapperAddress),\n [sdk, config.tokenAddress, config.wrapperAddress],\n );\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Get a {@link ReadonlyToken} instance, memoized by address.\n * Supports balance queries, ERC-165 checks, and authorization — no wrapper needed.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param address - Address of the confidential token contract.\n * @returns A memoized `ReadonlyToken` instance.\n *\n * @example\n * ```tsx\n * const token = useReadonlyToken(\"0xToken\");\n * // token.balanceOf(), token.isConfidential(), etc.\n * ```\n */\nexport function useReadonlyToken(address: Address) {\n const sdk = useZamaSDK();\n\n return useMemo(() => sdk.createReadonlyToken(address), [sdk, address]);\n}\n","import {\n type DefaultError,\n useQuery as tanstack_useQuery,\n useSuspenseQuery as tanstack_useSuspenseQuery,\n type UseQueryResult,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\n\n/**\n * Thin wrapper around TanStack's useQuery that injects our custom queryKeyHashFn.\n * Mirrors the wagmi pattern: a single `as any` here replaces per-hook casts.\n *\n * TanStack's useQuery has discriminated overloads around `initialData` that make\n * it extremely hard to pass inferred types through. We bypass that by casting\n * internally — the type safety boundary is at the factory and hook levels.\n *\n * Hooks must pass explicit generics: `useQuery<DataType>({...})`.\n */\nexport function useQuery<TData = unknown, TError = DefaultError>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: any,\n): UseQueryResult<TData, TError> {\n return tanstack_useQuery({\n ...options,\n queryKeyHashFn: hashFn,\n }) as UseQueryResult<TData, TError>;\n}\n\nexport function useSuspenseQuery<TData = unknown, TError = DefaultError>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: any,\n): UseSuspenseQueryResult<TData, TError> {\n return tanstack_useSuspenseQuery({\n ...options,\n queryKeyHashFn: hashFn,\n }) as UseSuspenseQueryResult<TData, TError>;\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryOptions,\n confidentialHandleQueryOptions,\n signerAddressQueryOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/** Configuration for {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Polling interval (ms) for the encrypted handle. Default: 10 000. */\n handleRefetchInterval?: number;\n}\n\n/** Query options for the decrypt phase of {@link useConfidentialBalance}. */\nexport type UseConfidentialBalanceOptions = Omit<\n UseQueryOptions<bigint, Error>,\n \"queryKey\" | \"queryFn\"\n>;\n\n/**\n * Declarative hook to read the connected wallet's confidential token balance.\n * Uses two-phase polling: cheaply polls the encrypted handle, then only\n * decrypts when the handle changes (new balance).\n *\n * @param config - Token address and optional polling interval.\n * @param options - React Query options forwarded to the decrypt query.\n * @returns The decrypt query result plus `handleQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data: balance, isLoading, handleQuery } = useConfidentialBalance({\n * tokenAddress: \"0x...\",\n * });\n * ```\n */\nexport function useConfidentialBalance(\n config: UseConfidentialBalanceConfig,\n options?: UseConfidentialBalanceOptions,\n) {\n const { tokenAddress, handleRefetchInterval } = config;\n const userEnabled = options?.enabled;\n const token = useReadonlyToken(tokenAddress);\n\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n\n const owner = addressQuery.data;\n\n // Phase 1: Poll the encrypted handle (cheap RPC read, no signing)\n const baseHandleQueryOptions = confidentialHandleQueryOptions(token.signer, tokenAddress, {\n owner,\n pollingInterval: handleRefetchInterval,\n });\n const handleFactoryEnabled = baseHandleQueryOptions.enabled ?? true;\n const handleQuery = useQuery<Handle>({\n ...baseHandleQueryOptions,\n enabled: handleFactoryEnabled && (userEnabled ?? true),\n });\n\n // Phase 2: Decrypt only when handle changes (expensive relayer roundtrip)\n const handle = handleQuery.data;\n const baseBalanceQueryOptions = confidentialBalanceQueryOptions(token, {\n handle,\n owner,\n });\n const factoryEnabled = baseBalanceQueryOptions.enabled ?? true;\n\n const balanceQuery = useQuery<bigint>({\n ...baseBalanceQueryOptions,\n ...options,\n enabled: factoryEnabled && (userEnabled ?? true),\n });\n\n return { ...balanceQuery, handleQuery };\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport { useQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalancesQueryOptions,\n confidentialHandlesQueryOptions,\n signerAddressQueryOptions,\n type ConfidentialBalancesData,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Configuration for {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesConfig {\n /** Addresses of the confidential token contracts to batch-query. */\n tokenAddresses: Address[];\n /** Polling interval (ms) for the encrypted handles. Default: 10 000. */\n handleRefetchInterval?: number;\n /** Maximum number of concurrent decrypt calls. Default: `Infinity` (no limit). */\n maxConcurrency?: number;\n}\n\nexport type { ConfidentialBalancesData };\n\n/** Query options for the decrypt phase of {@link useConfidentialBalances}. */\nexport type UseConfidentialBalancesOptions = Omit<\n UseQueryOptions<ConfidentialBalancesData, Error>,\n \"queryKey\" | \"queryFn\"\n>;\n\n/**\n * Declarative hook to read multiple confidential token balances in batch.\n * Uses two-phase polling: cheaply polls encrypted handles, then only\n * decrypts when any handle changes.\n *\n * Returns partial results when some tokens fail — successful balances are\n * always returned alongside per-token error information.\n *\n * @param config - Token addresses and optional polling interval.\n * @param options - React Query options forwarded to the decrypt query.\n * @returns The decrypt query result plus `handlesQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data } = useConfidentialBalances({\n * tokenAddresses: [\"0xTokenA\", \"0xTokenB\"],\n * });\n * const balance = data?.balances.get(\"0xTokenA\");\n * if (data?.isPartialError) {\n * // some tokens failed — check data.errors\n * }\n * ```\n */\nexport function useConfidentialBalances(\n config: UseConfidentialBalancesConfig,\n options?: UseConfidentialBalancesOptions,\n) {\n const { tokenAddresses, handleRefetchInterval, maxConcurrency } = config;\n const userEnabled = options?.enabled;\n const sdk = useZamaSDK();\n\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n\n const owner = addressQuery.data;\n\n const tokens = useMemo(\n () => tokenAddresses.map((addr) => sdk.createReadonlyToken(addr)),\n [sdk, tokenAddresses],\n );\n\n // Phase 1: Poll all encrypted handles (cheap RPC reads)\n const baseHandlesQueryOptions = confidentialHandlesQueryOptions(sdk.signer, tokenAddresses, {\n owner,\n pollingInterval: handleRefetchInterval,\n });\n const handlesFactoryEnabled = baseHandlesQueryOptions.enabled ?? true;\n const handlesQuery = useQuery<Handle[]>({\n ...baseHandlesQueryOptions,\n enabled: handlesFactoryEnabled && (userEnabled ?? true),\n });\n\n // Phase 2: Batch decrypt only when any handle changes\n const handles = handlesQuery.data;\n const handlesReady = Array.isArray(handles) && handles.length === tokenAddresses.length;\n const baseBalancesQueryOptions = confidentialBalancesQueryOptions(tokens, {\n owner,\n handles,\n maxConcurrency,\n resultAddresses: tokenAddresses,\n });\n const factoryEnabled = baseBalancesQueryOptions.enabled ?? true;\n\n const balancesQuery = useQuery<ConfidentialBalancesData>({\n ...baseBalancesQueryOptions,\n ...options,\n enabled: factoryEnabled && handlesReady && (userEnabled ?? true),\n });\n\n return { ...balancesQuery, handlesQuery };\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { allowMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Pre-authorize FHE decrypt credentials for a list of token addresses.\n * A single wallet signature covers all addresses, so subsequent decrypt\n * operations on any of these tokens reuse cached credentials.\n *\n * @example\n * ```tsx\n * const { mutateAsync: allow, isPending } = useAllow();\n * // Call allow(allTokenAddresses) before any individual reveal\n * ```\n */\nexport function useAllow(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...allowMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { skipToken } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n isAllowedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Check whether a session signature is cached for the connected wallet.\n * Returns `true` if decrypt operations can proceed without a wallet prompt.\n *\n * @example\n * ```tsx\n * const { data: allowed } = useIsAllowed();\n * ```\n */\nexport function useIsAllowed() {\n const sdk = useZamaSDK();\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n const account = addressQuery.data;\n const baseOpts = account\n ? isAllowedQueryOptions(sdk, { account })\n : {\n queryKey: zamaQueryKeys.isAllowed.all,\n queryFn: skipToken,\n };\n const factoryEnabled = \"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true;\n\n return useQuery({\n ...baseOpts,\n enabled: factoryEnabled,\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { revokeMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke stored FHE credentials for a list of token addresses.\n * The next decrypt operation will require a fresh wallet signature.\n *\n * @example\n * ```tsx\n * const { mutate: revoke } = useRevoke();\n * revoke([\"0xTokenA\", \"0xTokenB\"]);\n * ```\n */\nexport function useRevoke(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...revokeMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { revokeSessionMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke the session signature for the connected wallet without\n * specifying contract addresses. Useful for wallet disconnect handlers.\n *\n * @example\n * ```tsx\n * const { mutate: revokeSession } = useRevokeSession();\n * revokeSession();\n * ```\n */\nexport function useRevokeSession(options?: UseMutationOptions<void, Error, void>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, void>({\n ...revokeSessionMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","import type { QueryClient, QueryKey } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\n\ntype BalanceDeltaMode = \"add\" | \"subtract\";\nexport type OptimisticBalanceSnapshot = Array<[QueryKey, bigint | undefined]>;\n\n/** Combined context returned by optimistic `onMutate`. */\nexport interface OptimisticMutateContext {\n snapshot: OptimisticBalanceSnapshot;\n callerContext?: unknown;\n}\n\nexport function unwrapOptimisticCallerContext(\n optimistic: boolean | undefined,\n rawContext: OptimisticMutateContext | undefined,\n) {\n const wrappedContext = optimistic ? rawContext : undefined;\n const callerContext = optimistic ? wrappedContext?.callerContext : rawContext;\n return { wrappedContext, callerContext };\n}\n\nexport async function applyOptimisticBalanceDelta(\n queryClient: QueryClient,\n tokenAddress: Address,\n amount: bigint,\n mode: BalanceDeltaMode,\n): Promise<OptimisticBalanceSnapshot> {\n const balanceKey = zamaQueryKeys.confidentialBalance.token(tokenAddress);\n await queryClient.cancelQueries({ queryKey: balanceKey });\n const previous = queryClient.getQueriesData<bigint>({ queryKey: balanceKey });\n for (const [key, value] of previous) {\n if (value === undefined) continue;\n // Temporary optimistic underflow (`amount > value`) is acceptable because\n // settlement invalidates and rewrites this cache entry.\n queryClient.setQueryData(key, mode === \"add\" ? value + amount : value - amount);\n }\n return previous;\n}\n\nexport function rollbackOptimisticBalanceDelta(\n queryClient: QueryClient,\n snapshot: OptimisticBalanceSnapshot,\n) {\n for (const [key, value] of snapshot) {\n queryClient.setQueryData(key, value);\n }\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferParams,\n} from \"@zama-fhe/sdk/query\";\nimport {\n applyOptimisticBalanceDelta,\n type OptimisticMutateContext,\n rollbackOptimisticBalanceDelta,\n unwrapOptimisticCallerContext,\n} from \"./optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/** Configuration for {@link useConfidentialTransfer}. */\nexport interface UseConfidentialTransferConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically subtracts the transfer amount from cached balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Encrypt and send a confidential transfer. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * Set `optimistic: true` to subtract the amount from the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transfer = useConfidentialTransfer({\n * tokenAddress: \"0x...\",\n * optimistic: true,\n * });\n * transfer.mutate(\n * { to: \"0xRecipient\", amount: 1000n },\n * {\n * onError: (error) => {\n * if (error instanceof SigningRejectedError) {\n * // user cancelled — no action needed\n * }\n * },\n * },\n * );\n * ```\n */\nexport function useConfidentialTransfer(\n config: UseConfidentialTransferConfig,\n // Context type is OptimisticMutateContext because our onMutate wraps the caller's\n // context inside { snapshot, callerContext }. Caller callbacks receive the unwrapped callerContext.\n options?: UseMutationOptions<\n TransactionResult,\n Error,\n ConfidentialTransferParams,\n OptimisticMutateContext\n >,\n) {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation<TransactionResult, Error, ConfidentialTransferParams, OptimisticMutateContext>(\n {\n ...confidentialTransferMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta(\n queryClient,\n config.tokenAddress,\n variables.amount,\n \"subtract\",\n );\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n config.optimistic,\n rawContext,\n );\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n // callerContext is the user's original onMutate return — cast required by wrapper pattern\n options?.onError?.(\n error,\n variables,\n callerContext as OptimisticMutateContext | undefined,\n context,\n );\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as OptimisticMutateContext, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSettled?.(\n data,\n error,\n variables,\n callerContext as OptimisticMutateContext | undefined,\n context,\n );\n },\n },\n );\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferFromMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferFromParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Operator transfer on behalf of another address. Caller must be an approved operator.\n * Invalidates balance caches on success.\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transferFrom = useConfidentialTransferFrom({ tokenAddress: \"0x...\" });\n * transferFrom.mutate({ from: \"0xOwner\", to: \"0xRecipient\", amount: 500n });\n * ```\n */\nexport function useConfidentialTransferFrom(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferFromParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialTransferFromParams, Address>({\n ...confidentialTransferFromMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialApproveMutationOptions,\n invalidateAfterApprove,\n type ConfidentialApproveParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Set operator approval for a confidential token. Defaults to 1 hour.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useConfidentialApprove({ tokenAddress: \"0x...\" });\n * approve.mutate({ spender: \"0xOperator\" });\n * ```\n */\nexport function useConfidentialApprove(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialApproveParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialApproveParams, Address>({\n ...confidentialApproveMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApprove(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n confidentialIsApprovedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\nexport { confidentialIsApprovedQueryOptions };\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig extends UseZamaConfig {\n /** Address to check approval for. Pass `undefined` to disable the query. */\n spender: Address | undefined;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/** Configuration for {@link useConfidentialIsApprovedSuspense}. */\nexport interface UseConfidentialIsApprovedSuspenseConfig extends UseZamaConfig {\n /** Address to check approval for. */\n spender: Address;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/**\n * Check if a spender is an approved operator for a given holder (defaults to connected wallet).\n *\n * @param config - Token address, spender, and optional holder to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApproved({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApproved(\n config: UseConfidentialIsApprovedConfig,\n options?: Omit<UseQueryOptions<boolean, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { spender, holder, ...tokenConfig } = config;\n const userEnabled = options?.enabled;\n const token = useToken(tokenConfig);\n const holderQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n enabled: holder === undefined,\n });\n const resolvedHolder = holder ?? holderQuery.data;\n\n const baseOpts =\n spender && resolvedHolder\n ? confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n })\n : {\n queryKey: zamaQueryKeys.confidentialIsApproved.token(config.tokenAddress),\n queryFn: skipToken,\n };\n const factoryEnabled = \"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true;\n\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: factoryEnabled && (userEnabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useConfidentialIsApproved}.\n * Suspends rendering until the approval check resolves.\n *\n * @param config - Token address, spender, and optional holder to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApprovedSuspense({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig) {\n const { spender, holder, ...tokenConfig } = config;\n const token = useToken(tokenConfig);\n const addressQuery = useSuspenseQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const resolvedHolder = holder ?? addressQuery.data;\n\n return useSuspenseQuery<boolean>({\n ...confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n }),\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterShield,\n shieldMutationOptions,\n type ShieldParams,\n} from \"@zama-fhe/sdk/query\";\nimport {\n applyOptimisticBalanceDelta,\n type OptimisticMutateContext,\n rollbackOptimisticBalanceDelta,\n unwrapOptimisticCallerContext,\n} from \"./optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/** Configuration for {@link useShield}. */\nexport interface UseShieldConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield public ERC-20 tokens into confidential tokens.\n * Handles ERC-20 approval automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link ApprovalFailedError} — ERC-20 approval transaction failed\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shield = useShield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shield.mutate({ amount: 1000n });\n * ```\n */\nexport function useShield(\n config: UseShieldConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldParams, OptimisticMutateContext>,\n) {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation<TransactionResult, Error, ShieldParams, OptimisticMutateContext>({\n ...shieldMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta(\n queryClient,\n config.tokenAddress,\n variables.amount,\n \"add\",\n );\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n config.optimistic,\n rawContext,\n );\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n // callerContext is the user's original onMutate return — cast required by wrapper pattern\n options?.onError?.(\n error,\n variables,\n callerContext as OptimisticMutateContext | undefined,\n context,\n );\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as OptimisticMutateContext, context);\n invalidateAfterShield(context.client, config.tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSettled?.(\n data,\n error,\n variables,\n callerContext as OptimisticMutateContext | undefined,\n context,\n );\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterShield,\n shieldETHMutationOptions,\n type ShieldETHParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Shield native ETH into confidential tokens.\n * Invalidates balance caches on success.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shieldETH = useShieldETH({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * shieldETH.mutate({ amount: 1000000000000000000n }); // 1 ETH\n * ```\n */\nexport function useShieldETH(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldETHParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ShieldETHParams, Address>({\n ...shieldETHMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterShield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnwrap,\n type UnwrapParams,\n unwrapMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Request an unwrap for a specific amount. Encrypts the amount first.\n * Call {@link useFinalizeUnwrap} after the request is processed on-chain,\n * or use {@link useUnshield} for a single-call orchestration.\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrap = useUnwrap({ tokenAddress: \"0x...\" });\n * unwrap.mutate({ amount: 500n });\n * ```\n */\nexport function useUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnwrapParams, Address>({\n ...unwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterUnwrap, unwrapAllMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Request an unwrap for the entire confidential balance.\n * Uses the on-chain balance handle directly (no encryption needed).\n * Call {@link useFinalizeUnwrap} after processing, or use {@link useUnshieldAll} for single-call orchestration.\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrapAll = useUnwrapAll({ tokenAddress: \"0x...\" });\n * unwrapAll.mutate();\n * ```\n */\nexport function useUnwrapAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, void, Address>({\n ...unwrapAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n finalizeUnwrapMutationOptions,\n invalidateAfterUnshield,\n type FinalizeUnwrapParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Complete an unwrap by providing the public decryption proof.\n * Call this after an unwrap request has been processed on-chain.\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const finalize = useFinalizeUnwrap({ tokenAddress: \"0x...\" });\n * finalize.mutate({ burnAmountHandle: event.encryptedAmount });\n * ```\n */\nexport function useFinalizeUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, FinalizeUnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, FinalizeUnwrapParams, Address>({\n ...finalizeUnwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldParams,\n unshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Unshield a specific amount and finalize in one call.\n * Orchestrates: unwrap → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed during unwrap\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshield = useUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshield.mutate({ amount: 500n });\n * ```\n */\nexport function useUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldParams, Address>({\n ...unshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldAllParams,\n unshieldAllMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Unshield the entire balance and finalize in one call.\n * Orchestrates: unwrapAll → wait for receipt → parse event → finalize.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshieldAll = useUnshieldAll({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshieldAll.mutate();\n * ```\n */\nexport function useUnshieldAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldAllParams | void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldAllParams | void, Address>({\n ...unshieldAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type ResumeUnshieldParams,\n resumeUnshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Resume an interrupted unshield from an existing unwrap tx hash.\n * Useful when the user submitted the unwrap but the finalize step was\n * interrupted (e.g. page reload, network error).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const resumeUnshield = useResumeUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * resumeUnshield.mutate({ unwrapTxHash: \"0xabc...\" });\n * ```\n */\nexport function useResumeUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ResumeUnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ResumeUnshieldParams, Address>({\n ...resumeUnshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { signerAddressQueryOptions, underlyingAllowanceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { underlyingAllowanceQueryOptions };\n\n/** Configuration for {@link useUnderlyingAllowance}. */\nexport interface UseUnderlyingAllowanceConfig {\n /** Address of the confidential token contract used to scope the query cache. */\n tokenAddress: Address;\n /** Address of the wrapper contract whose underlying ERC-20 allowance is checked. */\n wrapperAddress: Address;\n}\n\n/**\n * Read the underlying ERC-20 allowance granted to the wrapper contract.\n * Useful to check if an approval is needed before shielding.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (current allowance).\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowance({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowance(\n config: UseUnderlyingAllowanceConfig,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, wrapperAddress } = config;\n const userEnabled = options?.enabled;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data;\n\n const baseOpts = underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n });\n const factoryEnabled = baseOpts.enabled ?? true;\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: factoryEnabled && (userEnabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useUnderlyingAllowance}.\n * Suspends rendering until the allowance is loaded.\n *\n * @param config - Token and wrapper addresses.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowanceSuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowanceSuspense(config: UseUnderlyingAllowanceConfig) {\n const { tokenAddress, wrapperAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useSuspenseQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data;\n\n return useSuspenseQuery<bigint>({\n ...underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n }),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { wrapperDiscoveryQueryOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { wrapperDiscoveryQueryOptions };\n\n/** Configuration for {@link useWrapperDiscovery}. */\nexport interface UseWrapperDiscoveryConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper coordinator. Pass `undefined` to disable the query. */\n coordinatorAddress: Address | undefined;\n}\n\n/** Configuration for {@link useWrapperDiscoverySuspense}. */\nexport interface UseWrapperDiscoverySuspenseConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper coordinator. */\n coordinatorAddress: Address;\n}\n\n/**\n * Discover the wrapper contract for an ERC-20 token.\n * Returns the wrapper address if one exists, or `null` if not.\n * Cached indefinitely since wrapper mappings are immutable.\n *\n * @param config - Token and coordinator addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscovery({\n * tokenAddress: \"0xUnderlying\",\n * coordinatorAddress: \"0xCoordinator\",\n * });\n * ```\n */\nexport function useWrapperDiscovery(\n config: UseWrapperDiscoveryConfig,\n options?: Omit<UseQueryOptions<Address | null, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<Address | null>({\n ...(coordinatorAddress\n ? wrapperDiscoveryQueryOptions(token.signer, tokenAddress, { coordinatorAddress })\n : {\n queryKey: zamaQueryKeys.wrapperDiscovery.all,\n queryFn: skipToken,\n }),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useWrapperDiscovery}.\n * Suspends rendering until the wrapper address is resolved.\n *\n * @param config - Token and coordinator addresses.\n * @returns Suspense query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscoverySuspense({\n * tokenAddress: \"0xUnderlying\",\n * coordinatorAddress: \"0xCoordinator\",\n * });\n * ```\n */\nexport function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig) {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<Address | null>({\n ...wrapperDiscoveryQueryOptions(token.signer, tokenAddress, { coordinatorAddress }),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenMetadataQueryOptions, type TokenMetadata } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { type TokenMetadata };\n\n/**\n * Read ERC-20 token metadata (name, symbol, decimals).\n * Fetches all three in parallel. Cached indefinitely since metadata is immutable.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadata(\"0xToken\");\n * // metadata?.name, metadata?.symbol, metadata?.decimals\n * ```\n */\nexport function useMetadata(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<TokenMetadata, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useMetadata}.\n * Suspends rendering until metadata is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadataSuspense(\"0xToken\");\n * ```\n */\nexport function useMetadataSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { Address, RawLog, ActivityLogMetadata, ActivityItem } from \"@zama-fhe/sdk\";\nimport { activityFeedQueryOptions, deriveActivityFeedLogsKey } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/** Configuration for {@link useActivityFeed}. */\nexport interface UseActivityFeedConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Connected wallet address. Pass `undefined` to disable the query. */\n userAddress: Address | undefined;\n /** Raw event logs from the provider (viem, ethers, etc.). Pass `undefined` to disable. */\n logs: readonly (RawLog & Partial<ActivityLogMetadata>)[] | undefined;\n /** Whether to batch-decrypt encrypted transfer amounts. Default: `true`. */\n decrypt?: boolean;\n}\n\n/**\n * Two-phase activity feed hook.\n * Phase 1: Instantly parses raw logs into classified {@link ActivityItem}s (sync, cheap).\n * Phase 2: Batch-decrypts encrypted transfer amounts via the relayer (async).\n *\n * The wallet provides logs (from its own provider — viem, ethers, etc.)\n * and this hook normalizes + decrypts them.\n *\n * @param config - Token address, user address, raw logs, and decrypt option.\n * @returns Query result with `data: ActivityItem[]`.\n *\n * @example\n * ```tsx\n * const { data: activity } = useActivityFeed({\n * tokenAddress: \"0xToken\",\n * userAddress: \"0xUser\",\n * logs: rawLogs,\n * });\n * ```\n */\nexport function useActivityFeed(config: UseActivityFeedConfig) {\n const { tokenAddress, userAddress, logs, decrypt: decryptOpt } = config;\n const token = useReadonlyToken(tokenAddress);\n const decrypt = decryptOpt ?? true;\n const logsKey = deriveActivityFeedLogsKey(logs);\n\n return useQuery<ActivityItem[]>({\n ...activityFeedQueryOptions(token, {\n userAddress,\n logs,\n decrypt,\n logsKey,\n }),\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n approveUnderlyingMutationOptions,\n invalidateAfterApproveUnderlying,\n type ApproveUnderlyingParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Approve the wrapper contract to spend the underlying ERC-20.\n * Defaults to max uint256. Resets to zero first if there's an existing\n * non-zero allowance (required by tokens like USDT).\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useApproveUnderlying({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * approve.mutate({}); // max approval\n * approve.mutate({ amount: 1000n }); // exact amount\n * ```\n */\nexport function useApproveUnderlying(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ApproveUnderlyingParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ApproveUnderlyingParams, Address>({\n ...approveUnderlyingMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApproveUnderlying(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialQueryOptions, isWrapperQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { isConfidentialQueryOptions, isWrapperQueryOptions };\n\n/**\n * Check if a token supports the ERC-7984 confidential interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidential(\"0xToken\");\n * ```\n */\nexport function useIsConfidential(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean>({\n ...isConfidentialQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsConfidential}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidentialSuspense(\"0xToken\");\n * ```\n */\nexport function useIsConfidentialSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean>({\n ...isConfidentialQueryOptions(token.signer, tokenAddress),\n });\n}\n\n/**\n * Check if a token supports the ERC-7984 wrapper interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapper(\"0xToken\");\n * ```\n */\nexport function useIsWrapper(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean>({\n ...isWrapperQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsWrapper}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapperSuspense(\"0xToken\");\n * ```\n */\nexport function useIsWrapperSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean>({\n ...isWrapperQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { totalSupplyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { totalSupplyQueryOptions };\n\n/**\n * Read the total supply of a token.\n * Stale after 30 seconds to balance freshness and RPC cost.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupply(\"0xToken\");\n * ```\n */\nexport function useTotalSupply(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<bigint>({\n ...totalSupplyQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useTotalSupply}.\n * Suspends rendering until the total supply is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupplySuspense(\"0xToken\");\n * ```\n */\nexport function useTotalSupplySuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<bigint>({\n ...totalSupplyQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n batchTransferFeeQueryOptions,\n feeRecipientQueryOptions,\n shieldFeeQueryOptions,\n unshieldFeeQueryOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport {\n batchTransferFeeQueryOptions,\n feeRecipientQueryOptions,\n shieldFeeQueryOptions,\n unshieldFeeQueryOptions,\n};\n\n/** Configuration for {@link useShieldFee} and {@link useUnshieldFee}. */\nexport interface UseFeeConfig {\n /** Address of the fee manager contract. */\n feeManagerAddress: Address;\n /** Amount to calculate the fee for. */\n amount: bigint;\n /** Sender address. */\n from: Address;\n /** Receiver address. */\n to: Address;\n}\n\n/**\n * Read the shield fee for a given amount and address pair.\n *\n * @param config - Fee manager address, amount, from, and to.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useShieldFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useShieldFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const userEnabled = options?.enabled;\n const baseOpts = shieldFeeQueryOptions(sdk.signer, config);\n const factoryEnabled = baseOpts.enabled ?? true;\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: factoryEnabled && (userEnabled ?? true),\n });\n}\n\n/**\n * Read the unshield fee for a given amount and address pair.\n *\n * @param config - Fee manager address, amount, from, and to.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useUnshieldFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useUnshieldFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const userEnabled = options?.enabled;\n const baseOpts = unshieldFeeQueryOptions(sdk.signer, config);\n const factoryEnabled = baseOpts.enabled ?? true;\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: factoryEnabled && (userEnabled ?? true),\n });\n}\n\n/**\n * Read the batch transfer fee from the fee manager.\n *\n * @param feeManagerAddress - Address of the fee manager contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useBatchTransferFee(\"0xFeeManager\");\n * ```\n */\nexport function useBatchTransferFee(\n feeManagerAddress: Address,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const userEnabled = options?.enabled;\n const baseOpts = batchTransferFeeQueryOptions(sdk.signer, feeManagerAddress);\n const factoryEnabled = baseOpts.enabled ?? true;\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: factoryEnabled && (userEnabled ?? true),\n });\n}\n\n/**\n * Read the fee recipient address from the fee manager.\n *\n * @param feeManagerAddress - Address of the fee manager contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address` (the fee recipient).\n *\n * @example\n * ```tsx\n * const { data: recipient } = useFeeRecipient(\"0xFeeManager\");\n * ```\n */\nexport function useFeeRecipient(\n feeManagerAddress: Address,\n options?: Omit<UseQueryOptions<Address, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const userEnabled = options?.enabled;\n const baseOpts = feeRecipientQueryOptions(sdk.signer, feeManagerAddress);\n const factoryEnabled = baseOpts.enabled ?? true;\n\n return useQuery<Address>({\n ...baseOpts,\n ...options,\n enabled: factoryEnabled && (userEnabled ?? true),\n });\n}\n"],"mappings":"swKAiDA,MAAM,EAAiB,GAA8B,KAAK,CAY1D,SAAgB,GAAa,CAC3B,WACA,UACA,SACA,UACA,iBACA,aACA,aACA,WACoB,CACpB,IAAM,EAAc,GAAgB,CAG9B,EAAa,GAAO,EAAQ,CAClC,MAAgB,CACd,EAAW,QAAU,GACrB,CAEF,IAAM,EAA2B,MAE7B,GAAQ,UACJ,CACE,iBAAoB,EAAiC,EAAY,CACjE,oBAAuB,EAAiC,EAAY,CACpE,kBAAqB,EAAiC,EAAY,CACnE,CACD,IAAA,GACN,CAAC,EAAa,EAAO,CACtB,CAEK,EAAM,MAER,IAAIA,GAAQ,CACV,UACA,SACA,UACA,iBACA,aACA,aACA,QAAS,EAAW,QACpB,2BACD,CAAC,CACJ,CAAC,EAAS,EAAQ,EAAS,EAAgB,EAAY,EAAY,EAAyB,CAC7F,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,ECnHT,SAAgB,IAAa,CAE3B,OAAO,EAAiDC,GAD5C,GAAY,CAC2D,CAAC,CCZtF,MAAa,EAAiB,CAC5B,OAAQ,EAAgB,IACtBC,EAAc,WAAW,OAAO,EAAQ,EAAgB,CAC3D,CCID,SAAgB,IAAiB,CAC/B,IAAM,EAAM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,CAAC,CAoBJ,SAAgB,GACd,EACA,EACA,CACA,IAAM,EAAM,GAAY,CAClB,EAAc,GAAS,QACvB,EAAWC,GAAwB,EAAI,OAAQ,EAAO,CACtD,EAAiB,EAAS,SAAW,GAE3C,OAAOD,EAAiB,CACtB,GAAG,EACH,GAAG,EACH,QAAS,IAAmB,GAAe,IAC5C,CAAC,CAeJ,SAAgB,GACd,EACA,EACA,CACA,IAAM,EAAM,GAAY,CAClB,EAAc,GAAS,QACvB,EAAWE,GAA6B,EAAI,OAAQ,EAAkB,CACtE,EAAiB,EAAS,SAAW,GAE3C,OAAOF,EAAiB,CACtB,GAAG,EACH,GAAG,EACH,QAAS,IAAmB,GAAe,IAC5C,CAAC,CAeJ,SAAgB,GACd,EACA,EACA,CACA,IAAM,EAAM,GAAY,CAClB,EAAc,GAAS,QACvB,EAAWG,GAAyB,EAAI,OAAQ,EAAkB,CAClE,EAAiB,EAAS,SAAW,GAE3C,OAAOH,EAAkB,CACvB,GAAG,EACH,GAAG,EACH,QAAS,IAAmB,GAAe,IAC5C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ZamaSDK","encryptMutationOptions","zamaQueryKeys","useQuery","tanstack_useQuery","hashFn","useSuspenseQuery","tanstack_useSuspenseQuery","useQuery","publicKeyQueryOptions","useQuery","publicParamsQueryOptions","useQuery","hashFn","useQuery","signerAddressQueryOptions","confidentialHandleQueryOptions","confidentialBalanceQueryOptions","useQuery","signerAddressQueryOptions","confidentialHandlesQueryOptions","confidentialBalancesQueryOptions","allowMutationOptions","zamaQueryKeys","useQuery","signerAddressQueryOptions","isAllowedQueryOptions","zamaQueryKeys","revokeMutationOptions","zamaQueryKeys","revokeSessionMutationOptions","zamaQueryKeys","zamaQueryKeys","confidentialTransferMutationOptions","confidentialTransferFromMutationOptions","confidentialApproveMutationOptions","useQuery","signerAddressQueryOptions","confidentialIsApprovedQueryOptions","zamaQueryKeys","useSuspenseQuery","shieldMutationOptions","shieldETHMutationOptions","unwrapMutationOptions","unwrapAllMutationOptions","finalizeUnwrapMutationOptions","unshieldMutationOptions","unshieldAllMutationOptions","resumeUnshieldMutationOptions","useQuery","signerAddressQueryOptions","underlyingAllowanceQueryOptions","useSuspenseQuery","useQuery","wrapperDiscoveryQueryOptions","zamaQueryKeys","useSuspenseQuery","useQuery","tokenMetadataQueryOptions","useSuspenseQuery","useQuery","activityFeedQueryOptions","delegateDecryptionMutationOptions","zamaQueryKeys","revokeDelegationMutationOptions","zamaQueryKeys","useQuery","delegationStatusQueryOptions","zamaQueryKeys","decryptBalanceAsMutationOptions","ReadonlyToken","approveUnderlyingMutationOptions","useQuery","isConfidentialQueryOptions","useSuspenseQuery","isWrapperQueryOptions","useQuery","totalSupplyQueryOptions","useSuspenseQuery","shieldFeeQueryOptions","useQuery","unshieldFeeQueryOptions","batchTransferFeeQueryOptions","feeRecipientQueryOptions"],"sources":["../src/provider.tsx","../src/relayer/use-encrypt.ts","../src/relayer/decryption-cache.ts","../src/relayer/use-user-decrypt.ts","../src/relayer/use-public-decrypt.ts","../src/relayer/use-generate-keypair.ts","../src/relayer/use-create-eip712.ts","../src/relayer/use-create-delegated-user-decrypt-eip712.ts","../src/relayer/use-delegated-user-decrypt.ts","../src/relayer/use-request-zk-proof-verification.ts","../src/utils/query.ts","../src/relayer/use-public-key.ts","../src/relayer/use-public-params.ts","../src/relayer/use-user-decrypt-flow.ts","../src/relayer/use-user-decrypted-value.ts","../src/relayer/use-user-decrypted-values.ts","../src/token/use-token.ts","../src/token/use-readonly-token.ts","../src/token/use-confidential-balance.ts","../src/token/use-confidential-balances.ts","../src/token/use-allow-tokens.ts","../src/token/use-is-allowed.ts","../src/token/use-revoke-tokens.ts","../src/token/use-revoke-session.ts","../src/token/optimistic-balance-update.ts","../src/token/use-confidential-transfer.ts","../src/token/use-confidential-transfer-from.ts","../src/token/use-confidential-approve.ts","../src/token/use-confidential-is-approved.ts","../src/token/use-shield.ts","../src/token/use-shield-eth.ts","../src/token/use-unwrap.ts","../src/token/use-unwrap-all.ts","../src/token/use-finalize-unwrap.ts","../src/token/use-unshield.ts","../src/token/use-unshield-all.ts","../src/token/use-resume-unshield.ts","../src/token/use-underlying-allowance.ts","../src/token/use-wrapper-discovery.ts","../src/token/use-metadata.ts","../src/token/use-activity-feed.ts","../src/token/use-delegate-decryption.ts","../src/token/use-revoke-delegation.ts","../src/token/use-delegation-status.ts","../src/token/use-decrypt-balance-as.ts","../src/token/use-batch-decrypt-balances-as.ts","../src/token/use-approve-underlying.ts","../src/token/use-is-confidential.ts","../src/token/use-total-supply.ts","../src/token/use-fees.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n Address,\n GenericSigner,\n GenericStorage,\n RelayerSDK,\n ZamaSDKEventListener,\n} from \"@zama-fhe/sdk\";\nimport { ZamaSDK } from \"@zama-fhe/sdk\";\nimport { invalidateWalletLifecycleQueries } from \"@zama-fhe/sdk/query\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\n/** Props for {@link ZamaProvider}. */\nexport interface ZamaProviderProps extends PropsWithChildren {\n /** FHE relayer backend (RelayerWeb for browser, RelayerNode for server). */\n relayer: RelayerSDK;\n /** Wallet signer (`ViemSigner`, `EthersSigner`, or custom {@link GenericSigner}). */\n signer: GenericSigner;\n /** Credential storage backend (IndexedDBStorage for browser, MemoryStorage for tests). */\n storage: GenericStorage;\n /**\n * Session storage for wallet signatures. Defaults to in-memory (lost on reload).\n * Pass a `chrome.storage.session`-backed store for web extensions.\n */\n sessionStorage?: GenericStorage;\n /**\n * How long the ML-KEM re-encryption keypair remains valid, in seconds.\n * Default: `86400` (1 day). Must be positive — `0` is rejected.\n */\n keypairTTL?: number;\n /**\n * Controls how long session signatures (EIP-712 wallet signatures) remain valid, in seconds.\n * Default: `2592000` (30 days).\n * - `0`: never persist — every operation triggers a signing prompt (high-security mode).\n * - Positive number: seconds until the session signature expires and requires re-authentication.\n */\n sessionTTL?: number;\n /** Callback invoked on SDK lifecycle events. */\n onEvent?: ZamaSDKEventListener;\n}\n\nconst ZamaSDKContext = createContext<ZamaSDK | null>(null);\n\n/**\n * Provides a {@link ZamaSDK} instance to all descendant hooks.\n *\n * @example\n * ```tsx\n * <ZamaProvider relayer={relayer} signer={signer} storage={storage}>\n * <App />\n * </ZamaProvider>\n * ```\n */\nexport function ZamaProvider({\n children,\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n onEvent,\n}: ZamaProviderProps) {\n const queryClient = useQueryClient();\n\n // Stabilize onEvent so an inline arrow doesn't recreate the SDK every render.\n const onEventRef = useRef(onEvent);\n useEffect(() => {\n onEventRef.current = onEvent;\n });\n\n const signerLifecycleCallbacks = useMemo(\n () =>\n signer?.subscribe\n ? {\n onDisconnect: () => invalidateWalletLifecycleQueries(queryClient),\n onAccountChange: () => invalidateWalletLifecycleQueries(queryClient),\n onChainChange: () => invalidateWalletLifecycleQueries(queryClient),\n }\n : undefined,\n [queryClient, signer],\n );\n\n const sdk = useMemo(\n () =>\n new ZamaSDK({\n relayer,\n signer,\n storage,\n sessionStorage,\n keypairTTL,\n sessionTTL,\n onEvent: onEventRef.current,\n signerLifecycleCallbacks,\n }),\n [relayer, signer, storage, sessionStorage, keypairTTL, sessionTTL, signerLifecycleCallbacks],\n );\n\n // Clean up signer subscriptions on unmount without terminating the\n // caller-owned relayer. dispose() only unsubscribes from wallet events\n // and is idempotent.\n useEffect(() => () => sdk.dispose(), [sdk]);\n\n return <ZamaSDKContext.Provider value={sdk}>{children}</ZamaSDKContext.Provider>;\n}\n\n/**\n * Access the {@link ZamaSDK} instance from context.\n * Throws if called outside a {@link ZamaProvider} or when no signer is provided.\n *\n * @example\n * ```tsx\n * const sdk = useZamaSDK();\n * const token = sdk.createReadonlyToken(\"0x...\");\n * ```\n */\nexport function useZamaSDK(): ZamaSDK {\n const context = useContext(ZamaSDKContext);\n\n if (!context) {\n throw new Error(\n \"useZamaSDK must be used within a <ZamaProvider>. \" +\n \"Wrap your component tree in <ZamaProvider relayer={…} signer={…} storage={…}>.\",\n );\n }\n\n return context;\n}\n","\"use client\";\n\nimport type { EncryptParams, EncryptResult } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { encryptMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Encrypt a plaintext value using FHE.\n * Calls the relayer's `encrypt` method via a mutation.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link EncryptionFailedError} — FHE encryption failed\n *\n * @returns A mutation whose `mutate` accepts {@link EncryptParams}.\n *\n * @example\n * ```tsx\n * const encrypt = useEncrypt();\n * encrypt.mutate({ values: [1000n], bits: [64] });\n * ```\n */\nexport function useEncrypt() {\n const sdk = useZamaSDK();\n return useMutation<EncryptResult, Error, EncryptParams>(encryptMutationOptions(sdk));\n}\n","import { zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { type Address } from \"@zama-fhe/sdk\";\nimport { type Handle } from \"@zama-fhe/sdk\";\n\n/**\n * Query key helpers for the shared decryption cache.\n * Used by useUserDecrypt/usePublicDecrypt to populate,\n * and by useUserDecryptedValue to read.\n */\nexport const decryptionKeys = {\n value: (handle: Handle, contractAddress?: Address) =>\n zamaQueryKeys.decryption.handle(handle, contractAddress),\n};\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle, UserDecryptParams } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Thin wrapper around sdk.userDecrypt().\n * Caller is responsible for providing all params (keypair, signature, etc.).\n * For the full orchestration (signature management, EIP712 signing),\n * see the app-level useUserDecryptFlow hook.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — relayer decryption request failed\n * - {@link InvalidKeypairError} — the provided keypair is invalid\n * - {@link KeypairExpiredError} — the re-encryption keypair has expired\n *\n * On success, populates the decryption cache so useUserDecryptedValue/useUserDecryptedValues\n * can read the results.\n */\nexport function useUserDecrypt() {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptParams>({\n mutationFn: (params) => sdk.relayer.userDecrypt(params),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data) as [Handle, ClearValueType][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle, PublicDecryptResult } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using the network public key (no credential needed).\n * On success, populates the decryption cache so {@link useUserDecryptedValue} / {@link useUserDecryptedValues}\n * can read the results.\n *\n * @returns A mutation whose `mutate` accepts an array of handle strings.\n *\n * @example\n * ```tsx\n * const publicDecrypt = usePublicDecrypt();\n * publicDecrypt.mutate([\"0xHandle1\", \"0xHandle2\"]);\n * // publicDecrypt.data?.clearValues => { \"0xHandle1\": 500n, ... }\n * ```\n */\nexport function usePublicDecrypt() {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n return useMutation<PublicDecryptResult, Error, Handle[]>({\n mutationFn: (handles) => sdk.relayer.publicDecrypt(handles),\n onSuccess: (data) => {\n for (const [handle, value] of Object.entries(data.clearValues) as [\n Handle,\n ClearValueType,\n ][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Generate an FHE keypair via the relayer.\n * Returns a public/private key pair for use in decrypt authorization.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link RelayerRequestFailedError} — relayer keypair generation request failed\n *\n * @returns A mutation whose `mutate` takes no parameters.\n *\n * @example\n * ```tsx\n * const generateKeypair = useGenerateKeypair();\n * generateKeypair.mutate();\n * // generateKeypair.data?.publicKey, generateKeypair.data?.privateKey\n * ```\n */\nexport function useGenerateKeypair() {\n const sdk = useZamaSDK();\n return useMutation({\n mutationFn: () => sdk.relayer.generateKeypair(),\n });\n}\n","\"use client\";\n\nimport type { EIP712TypedData } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\nimport { type Address } from \"@zama-fhe/sdk\";\n\n/** Parameters for {@link useCreateEIP712}. */\nexport interface CreateEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: `0x${string}`;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Unix timestamp (seconds) when the credential becomes valid. */\n startTimestamp: number;\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\n\n/**\n * Create EIP-712 typed data for signing an FHE decrypt credential.\n * The returned typed data is signed by the wallet to authorize decryption.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateEIP712() {\n const sdk = useZamaSDK();\n return useMutation<EIP712TypedData, Error, CreateEIP712Params>({\n mutationFn: ({ publicKey, contractAddresses, startTimestamp, durationDays }) =>\n sdk.relayer.createEIP712(publicKey, contractAddresses, startTimestamp, durationDays),\n });\n}\n","\"use client\";\n\nimport type { Address, KmsDelegatedUserDecryptEIP712Type } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Parameters for {@link useCreateDelegatedUserDecryptEIP712}. */\nexport interface CreateDelegatedUserDecryptEIP712Params {\n /** The FHE public key (hex-encoded). */\n publicKey: `0x${string}`;\n /** Contract addresses the credential authorizes decryption for. */\n contractAddresses: Address[];\n /** Address of the wallet that delegated decrypt authority. */\n delegatorAddress: Address;\n /** Unix timestamp (seconds) when the credential becomes valid. */\n startTimestamp: number;\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\n\n/**\n * Create EIP-712 typed data for a delegated user decrypt credential.\n * Used when one wallet authorizes another to decrypt on its behalf.\n *\n * @returns A mutation whose `mutate` accepts {@link CreateDelegatedUserDecryptEIP712Params}.\n *\n * @example\n * ```tsx\n * const createEIP712 = useCreateDelegatedUserDecryptEIP712();\n * createEIP712.mutate({\n * publicKey: keypair.publicKey,\n * contractAddresses: [\"0xToken\"],\n * delegatorAddress: \"0xDelegator\",\n * startTimestamp: Math.floor(Date.now() / 1000),\n * });\n * ```\n */\nexport function useCreateDelegatedUserDecryptEIP712() {\n const sdk = useZamaSDK();\n return useMutation<\n KmsDelegatedUserDecryptEIP712Type,\n Error,\n CreateDelegatedUserDecryptEIP712Params\n >({\n mutationFn: ({\n publicKey,\n contractAddresses,\n delegatorAddress,\n startTimestamp,\n durationDays,\n }) =>\n sdk.relayer.createDelegatedUserDecryptEIP712(\n publicKey,\n contractAddresses,\n delegatorAddress,\n startTimestamp,\n durationDays,\n ),\n });\n}\n","\"use client\";\n\nimport type { DelegatedUserDecryptParams, ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Decrypt FHE ciphertext handles using delegated user credentials.\n * Returns a map of handle → plaintext bigint.\n *\n * @returns A mutation whose `mutate` accepts {@link DelegatedUserDecryptParams}.\n *\n * @example\n * ```tsx\n * const decrypt = useDelegatedUserDecrypt();\n * decrypt.mutate({ handles: [\"0xHandle1\"], ...credentials });\n * // decrypt.data => { \"0xHandle1\": 1000n }\n * ```\n */\nexport function useDelegatedUserDecrypt() {\n const sdk = useZamaSDK();\n return useMutation<Record<Handle, ClearValueType>, Error, DelegatedUserDecryptParams>({\n mutationFn: (params) => sdk.relayer.delegatedUserDecrypt(params),\n });\n}\n","\"use client\";\n\nimport type { InputProofBytesType, ZKProofLike } from \"@zama-fhe/sdk\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Submit a ZK proof for on-chain verification.\n * Returns the input proof bytes for use in contract calls.\n *\n * @returns A mutation whose `mutate` accepts a {@link ZKProofLike}.\n *\n * @example\n * ```tsx\n * const verify = useRequestZKProofVerification();\n * verify.mutate(zkProof);\n * // verify.data => Uint8Array (input proof bytes)\n * ```\n */\nexport function useRequestZKProofVerification() {\n const sdk = useZamaSDK();\n return useMutation<InputProofBytesType, Error, ZKProofLike>({\n mutationFn: (zkProof) => sdk.relayer.requestZKProofVerification(zkProof),\n });\n}\n","import {\n type DefaultError,\n useQuery as tanstack_useQuery,\n useSuspenseQuery as tanstack_useSuspenseQuery,\n type UseQueryResult,\n type UseSuspenseQueryResult,\n} from \"@tanstack/react-query\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\n\n/**\n * Thin wrapper around TanStack's useQuery that injects our custom queryKeyHashFn.\n * Mirrors the wagmi pattern — the type safety boundary is at the factory and hook levels.\n *\n * The `options` parameter is typed as `any` because TanStack Query v5 has:\n * 1. Discriminated overloads around `initialData` (Defined vs Undefined)\n * 2. Function-typed fields (`staleTime`, `enabled`, `gcTime`) that are generic over `TQueryKey`\n *\n * Our factories produce options with specific tuple keys (e.g. `readonly [\"zama.totalSupply\", {...}]`)\n * whose function-typed fields are contravariant with `QueryKey` (`readonly unknown[]`).\n * Typing the parameter as `UseQueryOptions<TData, TError, TData, any>` still fails because\n * the query-key variance leaks through `staleTime`, `enabled`, etc.\n *\n * Hooks must pass explicit generics: `useQuery<DataType>({...})`.\n */\nexport function useQuery<TData = unknown, TError = DefaultError>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: any,\n): UseQueryResult<TData, TError> {\n return tanstack_useQuery({\n ...options,\n queryKeyHashFn: hashFn,\n }) as UseQueryResult<TData, TError>;\n}\n\nexport function useSuspenseQuery<TData = unknown, TError = DefaultError>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: any,\n): UseSuspenseQueryResult<TData, TError> {\n return tanstack_useSuspenseQuery({\n ...options,\n queryKeyHashFn: hashFn,\n }) as UseSuspenseQueryResult<TData, TError>;\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { publicKeyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicKeyQueryOptions };\n\n/** Shape of the FHE public key data returned by the relayer. */\nexport interface PublicKeyData {\n /** Unique identifier for this public key version. */\n publicKeyId: string;\n /** The raw FHE public key bytes. */\n publicKey: Uint8Array;\n}\n\n/**\n * Fetch the FHE network public key from the relayer.\n * Cached indefinitely since the key does not change during a session.\n *\n * @returns Query result with `data: PublicKeyData | null`.\n *\n * @example\n * ```tsx\n * const { data: publicKey } = usePublicKey();\n * // publicKey?.publicKeyId, publicKey?.publicKey\n * ```\n */\nexport function usePublicKey() {\n const sdk = useZamaSDK();\n return useQuery<PublicKeyData | null>({\n ...publicKeyQueryOptions(sdk),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { publicParamsQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport { publicParamsQueryOptions };\n\n/** Shape of the FHE public parameters returned by the relayer. */\nexport interface PublicParamsData {\n /** The raw public parameters bytes (WASM-ready). */\n publicParams: Uint8Array;\n /** Unique identifier for this public params version. */\n publicParamsId: string;\n}\n\n/**\n * Fetch FHE public parameters for a given bit size from the relayer.\n * Cached indefinitely since parameters do not change during a session.\n *\n * @param bits - The FHE bit size to fetch parameters for (e.g. 2048).\n * @returns Query result with `data: PublicParamsData | null`.\n *\n * @example\n * ```tsx\n * const { data: params } = usePublicParams(2048);\n * // params?.publicParams, params?.publicParamsId\n * ```\n */\nexport function usePublicParams(bits: number) {\n const sdk = useZamaSDK();\n return useQuery<PublicParamsData | null>({\n ...publicParamsQueryOptions(sdk, bits),\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { Address, ClearValueType, Handle, Hex } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\nimport { useZamaSDK } from \"../provider\";\n\n/** A handle to decrypt, paired with its originating contract address. */\nexport interface DecryptHandle {\n handle: Handle;\n contractAddress: Address;\n}\n\n/** Parameters for {@link useUserDecryptFlow}. */\nexport interface UserDecryptFlowParams {\n /** Encrypted handles to decrypt. */\n handles: DecryptHandle[];\n /** Number of days the credential remains valid. Default: 1. */\n durationDays?: number;\n}\n\n/** Progress callbacks for each step of the decrypt flow. */\nexport interface UserDecryptFlowCallbacks {\n /** Fired after the keypair is generated. */\n onKeypairGenerated?: () => void;\n /** Fired after the EIP-712 typed data is created, before wallet signing. */\n onEIP712Created?: () => void;\n /** Fired after the wallet signature is obtained. */\n onSigned?: (signature: Hex) => void;\n /** Fired after decryption completes. */\n onDecrypted?: (values: Record<Handle, ClearValueType>) => void;\n}\n\n/** Configuration for {@link useUserDecryptFlow}. */\nexport interface UseUserDecryptFlowConfig {\n /** Optional progress callbacks. */\n callbacks?: UserDecryptFlowCallbacks;\n}\n\n/**\n * High-level orchestration hook for user decryption.\n * Handles the full flow: keypair generation → EIP-712 creation → wallet signature → decryption.\n *\n * On success, populates the decryption cache so `useUserDecryptedValue` / `useUserDecryptedValues`\n * can read the results.\n *\n * @param config - Optional callbacks for step-by-step UX feedback.\n * @returns A mutation whose `mutate` accepts {@link UserDecryptFlowParams}.\n *\n * @example\n * ```tsx\n * const decryptFlow = useUserDecryptFlow({\n * callbacks: { onSigned: () => setStep(\"decrypting\") },\n * });\n * decryptFlow.mutate({\n * handles: [{ handle: \"0xHandle\", contractAddress: \"0xContract\" }],\n * durationDays: 7,\n * });\n * ```\n */\nexport function useUserDecryptFlow(config?: UseUserDecryptFlowConfig) {\n const sdk = useZamaSDK();\n const queryClient = useQueryClient();\n const callbacks = config?.callbacks;\n\n return useMutation<Record<Handle, ClearValueType>, Error, UserDecryptFlowParams>({\n mutationKey: [\"userDecryptFlow\"],\n mutationFn: async ({ handles, durationDays = 1 }) => {\n // Step 1: Generate keypair\n const keypair = await sdk.relayer.generateKeypair();\n callbacks?.onKeypairGenerated?.();\n\n // Step 2: Create EIP-712 typed data\n const contractAddresses = [...new Set(handles.map((h) => h.contractAddress))];\n const startTimestamp = Math.floor(Date.now() / 1000);\n const eip712 = await sdk.relayer.createEIP712(\n keypair.publicKey,\n contractAddresses,\n startTimestamp,\n durationDays,\n );\n callbacks?.onEIP712Created?.();\n\n // Step 3: Sign with wallet\n const signature = await sdk.signer.signTypedData(eip712);\n callbacks?.onSigned?.(signature);\n\n // Step 4: Decrypt — group handles by contract address\n const signerAddress = await sdk.signer.getAddress();\n const allResults: Partial<Record<Handle, ClearValueType>> = {};\n\n // Decrypt per contract address (the relayer requires handles from the same contract)\n const handlesByContract = new Map<Address, Handle[]>();\n for (const h of handles) {\n const list = handlesByContract.get(h.contractAddress) ?? [];\n list.push(h.handle);\n handlesByContract.set(h.contractAddress, list);\n }\n\n for (const [contractAddress, contractHandles] of handlesByContract) {\n const result = await sdk.relayer.userDecrypt({\n handles: contractHandles,\n contractAddress,\n signedContractAddresses: contractAddresses,\n privateKey: keypair.privateKey,\n publicKey: keypair.publicKey,\n signature,\n signerAddress,\n startTimestamp,\n durationDays,\n });\n Object.assign(allResults, result);\n }\n\n const results = allResults as Record<Handle, ClearValueType>;\n callbacks?.onDecrypted?.(results);\n return results;\n },\n onSuccess: (data) => {\n // Populate the shared decryption cache\n for (const [handle, value] of Object.entries(data) as [Handle, ClearValueType][]) {\n queryClient.setQueryData(decryptionKeys.value(handle), value);\n }\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { decryptionKeys } from \"./decryption-cache\";\n\n/**\n * Look up a single cached decrypted value by its handle.\n * Values are populated automatically when useUserDecrypt or usePublicDecrypt succeed.\n * You can also populate manually via queryClient.setQueryData(decryptionKeys.value(handle), value).\n */\nexport function useUserDecryptedValue(handle: Handle | undefined) {\n return useQuery<ClearValueType>({\n queryKey: decryptionKeys.value(handle ?? \"0x\"),\n queryFn: () => undefined as never,\n enabled: false,\n });\n}\n","\"use client\";\n\nimport { useQueries } from \"@tanstack/react-query\";\nimport type { ClearValueType, Handle } from \"@zama-fhe/sdk\";\nimport { hashFn } from \"@zama-fhe/sdk/query\";\nimport { decryptionKeys } from \"./decryption-cache\";\n\n/**\n * Look up multiple cached decrypted values by their handles.\n * Values are populated automatically when useUserDecrypt or usePublicDecrypt succeed.\n */\nexport function useUserDecryptedValues(handles: Handle[]) {\n const results = useQueries({\n queries: handles.map((handle) => ({\n queryKey: decryptionKeys.value(handle),\n queryKeyHashFn: hashFn,\n queryFn: () => undefined as never,\n enabled: false,\n })),\n });\n\n const data: Partial<Record<Handle, ClearValueType | undefined>> = {};\n for (let i = 0; i < handles.length; i++) {\n data[handles[i]!] = results[i]!.data as ClearValueType | undefined;\n }\n\n return {\n data,\n results,\n };\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Base configuration shared by all mutation hooks that need a Token instance. */\nexport interface UseZamaConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Address of the wrapper contract (required for shield/unshield operations). */\n wrapperAddress?: Address;\n}\n\n/**\n * Get a {@link Token} instance, memoized by address pair.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param config - Token and optional wrapper addresses.\n * @returns A memoized `Token` instance.\n *\n * @example\n * ```tsx\n * const token = useToken({ tokenAddress: \"0xToken\", wrapperAddress: \"0xWrapper\" });\n * ```\n */\nexport function useToken(config: UseZamaConfig) {\n const sdk = useZamaSDK();\n\n return useMemo(\n () => sdk.createToken(config.tokenAddress, config.wrapperAddress),\n [sdk, config.tokenAddress, config.wrapperAddress],\n );\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Get a {@link ReadonlyToken} instance, memoized by address.\n * Supports balance queries, ERC-165 checks, and authorization — no wrapper needed.\n * Reads signer and storage from the nearest {@link ZamaProvider}.\n *\n * @param address - Address of the confidential token contract.\n * @returns A memoized `ReadonlyToken` instance.\n *\n * @example\n * ```tsx\n * const token = useReadonlyToken(\"0xToken\");\n * // token.balanceOf(), token.isConfidential(), etc.\n * ```\n */\nexport function useReadonlyToken(address: Address) {\n const sdk = useZamaSDK();\n\n return useMemo(() => sdk.createReadonlyToken(address), [sdk, address]);\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalanceQueryOptions,\n confidentialHandleQueryOptions,\n signerAddressQueryOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/** Configuration for {@link useConfidentialBalance}. */\nexport interface UseConfidentialBalanceConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Polling interval (ms) for the encrypted handle. Default: 10 000. */\n handleRefetchInterval?: number;\n}\n\n/** Query options for the decrypt phase of {@link useConfidentialBalance}. */\nexport type UseConfidentialBalanceOptions = Omit<\n UseQueryOptions<bigint, Error>,\n \"queryKey\" | \"queryFn\"\n>;\n\n/**\n * Declarative hook to read the connected wallet's confidential token balance.\n * Uses two-phase polling: cheaply polls the encrypted handle, then only\n * decrypts when the handle changes (new balance).\n *\n * @param config - Token address and optional polling interval.\n * @param options - React Query options forwarded to the decrypt query.\n * @returns The decrypt query result plus `handleQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data: balance, isLoading, handleQuery } = useConfidentialBalance({\n * tokenAddress: \"0x...\",\n * });\n * ```\n */\nexport function useConfidentialBalance(\n config: UseConfidentialBalanceConfig,\n options?: UseConfidentialBalanceOptions,\n) {\n const { tokenAddress, handleRefetchInterval } = config;\n const userEnabled = options?.enabled;\n const token = useReadonlyToken(tokenAddress);\n\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n\n const owner = addressQuery.data;\n\n // Phase 1: Poll the encrypted handle (cheap RPC read, no signing)\n const baseHandleQueryOptions = confidentialHandleQueryOptions(token.signer, tokenAddress, {\n owner,\n pollingInterval: handleRefetchInterval,\n });\n const handleQuery = useQuery<Handle>({\n ...baseHandleQueryOptions,\n enabled: (baseHandleQueryOptions.enabled ?? true) && (userEnabled ?? true),\n });\n\n // Phase 2: Decrypt only when handle changes (expensive relayer roundtrip)\n const handle = handleQuery.data;\n const baseBalanceQueryOptions = confidentialBalanceQueryOptions(token, {\n handle,\n owner,\n });\n const balanceQuery = useQuery<bigint>({\n ...baseBalanceQueryOptions,\n ...options,\n enabled: (baseBalanceQueryOptions.enabled ?? true) && (userEnabled ?? true),\n });\n\n return { ...balanceQuery, handleQuery };\n}\n","\"use client\";\n\nimport { useMemo } from \"react\";\nimport { useQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address, Handle } from \"@zama-fhe/sdk\";\nimport {\n confidentialBalancesQueryOptions,\n confidentialHandlesQueryOptions,\n signerAddressQueryOptions,\n type ConfidentialBalancesData,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/** Configuration for {@link useConfidentialBalances}. */\nexport interface UseConfidentialBalancesConfig {\n /** Addresses of the confidential token contracts to batch-query. */\n tokenAddresses: Address[];\n /** Polling interval (ms) for the encrypted handles. Default: 10 000. */\n handleRefetchInterval?: number;\n /** Maximum number of concurrent decrypt calls. Default: `Infinity` (no limit). */\n maxConcurrency?: number;\n}\n\nexport type { ConfidentialBalancesData };\n\n/** Query options for the decrypt phase of {@link useConfidentialBalances}. */\nexport type UseConfidentialBalancesOptions = Omit<\n UseQueryOptions<ConfidentialBalancesData, Error>,\n \"queryKey\" | \"queryFn\"\n>;\n\n/**\n * Declarative hook to read multiple confidential token balances in batch.\n * Uses two-phase polling: cheaply polls encrypted handles, then only\n * decrypts when any handle changes.\n *\n * Returns partial results when some tokens fail — successful balances are\n * always returned alongside per-token error information.\n *\n * @param config - Token addresses and optional polling interval.\n * @param options - React Query options forwarded to the decrypt query.\n * @returns The decrypt query result plus `handlesQuery` for Phase 1 state.\n *\n * @example\n * ```tsx\n * const { data } = useConfidentialBalances({\n * tokenAddresses: [\"0xTokenA\", \"0xTokenB\"],\n * });\n * const balance = data?.balances.get(\"0xTokenA\");\n * if (data?.isPartialError) {\n * // some tokens failed — check data.errors\n * }\n * ```\n */\nexport function useConfidentialBalances(\n config: UseConfidentialBalancesConfig,\n options?: UseConfidentialBalancesOptions,\n) {\n const { tokenAddresses, handleRefetchInterval, maxConcurrency } = config;\n const userEnabled = options?.enabled;\n const sdk = useZamaSDK();\n\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n\n const owner = addressQuery.data;\n\n const tokens = useMemo(\n () => tokenAddresses.map((addr) => sdk.createReadonlyToken(addr)),\n [sdk, tokenAddresses],\n );\n\n // Phase 1: Poll all encrypted handles (cheap RPC reads)\n const baseHandlesQueryOptions = confidentialHandlesQueryOptions(sdk.signer, tokenAddresses, {\n owner,\n pollingInterval: handleRefetchInterval,\n });\n const handlesQuery = useQuery<Handle[]>({\n ...baseHandlesQueryOptions,\n enabled: (baseHandlesQueryOptions.enabled ?? true) && (userEnabled ?? true),\n });\n\n // Phase 2: Batch decrypt only when any handle changes\n const handles = handlesQuery.data;\n const handlesReady = Array.isArray(handles) && handles.length === tokenAddresses.length;\n const baseBalancesQueryOptions = confidentialBalancesQueryOptions(tokens, {\n owner,\n handles,\n maxConcurrency,\n resultAddresses: tokenAddresses,\n });\n const factoryEnabled = baseBalancesQueryOptions.enabled ?? true;\n\n const balancesQuery = useQuery<ConfidentialBalancesData>({\n ...baseBalancesQueryOptions,\n ...options,\n enabled: factoryEnabled && handlesReady && (userEnabled ?? true),\n });\n\n return { ...balancesQuery, handlesQuery };\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { allowMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Pre-authorize FHE decrypt credentials for a list of token addresses.\n * A single wallet signature covers all addresses, so subsequent decrypt\n * operations on any of these tokens reuse cached credentials.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link KeypairExpiredError} — the re-encryption keypair has expired\n *\n * @example\n * ```tsx\n * const { mutateAsync: allowTokens, isPending } = useAllowTokens();\n * // Call allowTokens(allTokenAddresses) before any individual reveal\n * ```\n */\nexport function useAllowTokens(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...allowMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { skipToken } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n isAllowedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Check whether a session signature is cached for the connected wallet.\n * Returns `true` if decrypt operations can proceed without a wallet prompt.\n *\n * @example\n * ```tsx\n * const { data: allowed } = useIsAllowed();\n * ```\n */\nexport function useIsAllowed() {\n const sdk = useZamaSDK();\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(sdk.signer),\n });\n const account = addressQuery.data;\n const baseOpts = account\n ? isAllowedQueryOptions(sdk, { account })\n : {\n queryKey: zamaQueryKeys.isAllowed.all,\n queryFn: skipToken,\n };\n const factoryEnabled = \"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true;\n\n return useQuery({\n ...baseOpts,\n enabled: factoryEnabled,\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { revokeMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke stored FHE credentials for a list of token addresses.\n * The next decrypt operation will require a fresh wallet signature.\n *\n * @example\n * ```tsx\n * const { mutate: revokeTokens } = useRevokeTokens();\n * revokeTokens([\"0xTokenA\", \"0xTokenB\"]);\n * ```\n */\nexport function useRevokeTokens(options?: UseMutationOptions<void, Error, Address[]>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, Address[]>({\n ...revokeMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { revokeSessionMutationOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\n/**\n * Revoke the session signature for the connected wallet without\n * specifying contract addresses. Useful for wallet disconnect handlers.\n *\n * @example\n * ```tsx\n * const { mutate: revokeSession } = useRevokeSession();\n * revokeSession();\n * ```\n */\nexport function useRevokeSession(options?: UseMutationOptions<void, Error, void>) {\n const sdk = useZamaSDK();\n\n return useMutation<void, Error, void>({\n ...revokeSessionMutationOptions(sdk),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.isAllowed.all });\n },\n });\n}\n","import type { QueryClient, QueryKey, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterShield, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\n\ntype BalanceDeltaMode = \"add\" | \"subtract\";\nexport type OptimisticBalanceSnapshot = Array<[QueryKey, bigint | undefined]>;\n\n/** Combined context returned by optimistic `onMutate`. */\nexport interface OptimisticMutateContext {\n snapshot: OptimisticBalanceSnapshot;\n callerContext?: unknown;\n}\n\nexport function unwrapOptimisticCallerContext(\n optimistic: boolean | undefined,\n rawContext: unknown,\n): {\n wrappedContext: OptimisticMutateContext | undefined;\n callerContext: OptimisticMutateContext | undefined;\n} {\n const typed = rawContext as OptimisticMutateContext | undefined;\n const wrappedContext = optimistic ? typed : undefined;\n const callerContext = (optimistic ? wrappedContext?.callerContext : rawContext) as\n | OptimisticMutateContext\n | undefined;\n return { wrappedContext, callerContext };\n}\n\nexport async function applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount,\n mode,\n}: {\n queryClient: QueryClient;\n tokenAddress: Address;\n amount: bigint;\n mode: BalanceDeltaMode;\n}): Promise<OptimisticBalanceSnapshot> {\n const balanceKey = zamaQueryKeys.confidentialBalance.token(tokenAddress);\n await queryClient.cancelQueries({ queryKey: balanceKey });\n const previous = queryClient.getQueriesData<bigint>({ queryKey: balanceKey });\n for (const [key, value] of previous) {\n if (value === undefined) continue;\n // Temporary optimistic underflow (`amount > value`) is acceptable because\n // settlement invalidates and rewrites this cache entry.\n queryClient.setQueryData(key, mode === \"add\" ? value + amount : value - amount);\n }\n return previous;\n}\n\nexport function rollbackOptimisticBalanceDelta(\n queryClient: QueryClient,\n snapshot: OptimisticBalanceSnapshot,\n) {\n for (const [key, value] of snapshot) {\n queryClient.setQueryData(key, value);\n }\n}\n\n/**\n * Build optimistic mutation callbacks for shield operations.\n * Wraps the caller's `onMutate`/`onError`/`onSuccess`/`onSettled` with snapshot/rollback logic\n * and returns overrides ready to spread into `useMutation`.\n */\nexport function optimisticBalanceCallbacks<TParams extends { amount: bigint }>({\n optimistic,\n tokenAddress,\n queryClient,\n options,\n}: {\n optimistic: boolean | undefined;\n tokenAddress: Address;\n queryClient: QueryClient;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: UseMutationOptions<TransactionResult, Error, TParams, any> | undefined;\n}): Pick<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n UseMutationOptions<TransactionResult, Error, TParams, any>,\n \"onMutate\" | \"onError\" | \"onSuccess\" | \"onSettled\"\n> {\n return {\n onMutate: optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress,\n amount: variables.amount,\n mode: \"add\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext, context);\n invalidateAfterShield(context.client, tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext, context);\n },\n };\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferParams,\n} from \"@zama-fhe/sdk/query\";\nimport {\n applyOptimisticBalanceDelta,\n rollbackOptimisticBalanceDelta,\n unwrapOptimisticCallerContext,\n} from \"./optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/** Configuration for {@link useConfidentialTransfer}. */\nexport interface UseConfidentialTransferConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically subtracts the transfer amount from cached balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Encrypt and send a confidential transfer. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * Set `optimistic: true` to subtract the amount from the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transfer = useConfidentialTransfer({\n * tokenAddress: \"0x...\",\n * optimistic: true,\n * });\n * transfer.mutate(\n * { to: \"0xRecipient\", amount: 1000n },\n * {\n * onError: (error) => {\n * if (error instanceof SigningRejectedError) {\n * // user cancelled — no action needed\n * }\n * },\n * },\n * );\n * ```\n */\nexport function useConfidentialTransfer<TContext = unknown>(\n config: UseConfidentialTransferConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n // Internal mutation uses `any` for TContext because optimistic mode wraps\n // the caller's context in OptimisticMutateContext; the public return type\n // is cast back to the caller's TContext.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return useMutation<TransactionResult, Error, ConfidentialTransferParams, any>({\n ...confidentialTransferMutationOptions(token),\n ...options,\n onMutate: config.optimistic\n ? async (variables, mutationContext) => {\n const snapshot = await applyOptimisticBalanceDelta({\n queryClient,\n tokenAddress: config.tokenAddress,\n amount: variables.amount,\n mode: \"subtract\",\n });\n const callerContext = await options?.onMutate?.(variables, mutationContext);\n return { snapshot, callerContext };\n }\n : options?.onMutate,\n onError: (error, variables, rawContext, context) => {\n const { wrappedContext, callerContext } = unwrapOptimisticCallerContext(\n config.optimistic,\n rawContext,\n );\n try {\n if (wrappedContext) {\n rollbackOptimisticBalanceDelta(queryClient, wrappedContext.snapshot);\n }\n } finally {\n options?.onError?.(error, variables, callerContext as TContext, context);\n }\n },\n onSuccess: (data, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSuccess?.(data, variables, callerContext as TContext, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n onSettled: (data, error, variables, rawContext, context) => {\n const { callerContext } = unwrapOptimisticCallerContext(config.optimistic, rawContext);\n options?.onSettled?.(data, error, variables, callerContext as TContext, context);\n },\n }) as UseMutationResult<TransactionResult, Error, ConfidentialTransferParams, TContext>;\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialTransferFromMutationOptions,\n invalidateAfterTransfer,\n type ConfidentialTransferFromParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Operator transfer on behalf of another address. Caller must be an approved operator.\n * Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the transfer amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const transferFrom = useConfidentialTransferFrom({ tokenAddress: \"0x...\" });\n * transferFrom.mutate({ from: \"0xOwner\", to: \"0xRecipient\", amount: 500n });\n * ```\n */\nexport function useConfidentialTransferFrom(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferFromParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialTransferFromParams, Address>({\n ...confidentialTransferFromMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterTransfer(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n confidentialApproveMutationOptions,\n invalidateAfterApprove,\n type ConfidentialApproveParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Set operator approval for a confidential token. Defaults to 1 hour.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useConfidentialApprove({ tokenAddress: \"0x...\" });\n * approve.mutate({ spender: \"0xOperator\" });\n * ```\n */\nexport function useConfidentialApprove(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ConfidentialApproveParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ConfidentialApproveParams, Address>({\n ...confidentialApproveMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApprove(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n confidentialIsApprovedQueryOptions,\n signerAddressQueryOptions,\n zamaQueryKeys,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\nexport { confidentialIsApprovedQueryOptions };\n\n/** Configuration for {@link useConfidentialIsApproved}. */\nexport interface UseConfidentialIsApprovedConfig extends UseZamaConfig {\n /** Address to check approval for. Pass `undefined` to disable the query. */\n spender: Address | undefined;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/** Configuration for {@link useConfidentialIsApprovedSuspense}. */\nexport interface UseConfidentialIsApprovedSuspenseConfig extends UseZamaConfig {\n /** Address to check approval for. */\n spender: Address;\n /** Token holder address. Defaults to the connected wallet. */\n holder?: Address;\n}\n\n/**\n * Check if a spender is an approved operator for a given holder (defaults to connected wallet).\n *\n * @param config - Token address, spender, and optional holder to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApproved({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApproved(\n config: UseConfidentialIsApprovedConfig,\n options?: Omit<UseQueryOptions<boolean, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { spender, holder, ...tokenConfig } = config;\n const userEnabled = options?.enabled;\n const token = useToken(tokenConfig);\n const holderQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n enabled: holder === undefined,\n });\n const resolvedHolder = holder ?? holderQuery.data;\n\n const baseOpts =\n spender && resolvedHolder\n ? confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n })\n : {\n queryKey: zamaQueryKeys.confidentialIsApproved.token(config.tokenAddress),\n queryFn: skipToken,\n };\n return useQuery({\n ...baseOpts,\n ...options,\n enabled: (\"enabled\" in baseOpts ? (baseOpts.enabled ?? true) : true) && (userEnabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useConfidentialIsApproved}.\n * Suspends rendering until the approval check resolves.\n *\n * @param config - Token address, spender, and optional holder to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isApproved } = useConfidentialIsApprovedSuspense({\n * tokenAddress: \"0xToken\",\n * spender: \"0xSpender\",\n * holder: \"0xHolder\", // optional\n * });\n * ```\n */\nexport function useConfidentialIsApprovedSuspense(config: UseConfidentialIsApprovedSuspenseConfig) {\n const { spender, holder, ...tokenConfig } = config;\n const token = useToken(tokenConfig);\n const addressQuery = useSuspenseQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const resolvedHolder = holder ?? addressQuery.data;\n\n return useSuspenseQuery<boolean>({\n ...confidentialIsApprovedQueryOptions(token.signer, token.address, {\n holder: resolvedHolder,\n spender,\n }),\n });\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport { shieldMutationOptions, type ShieldParams } from \"@zama-fhe/sdk/query\";\nimport { optimisticBalanceCallbacks } from \"./optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/** Configuration for {@link useShield}. */\nexport interface UseShieldConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield public ERC-20 tokens into confidential tokens.\n * Handles ERC-20 approval automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link ApprovalFailedError} — ERC-20 approval transaction failed\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shield = useShield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shield.mutate({ amount: 1000n });\n * ```\n */\nexport function useShield<TContext = unknown>(\n config: UseShieldConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ShieldParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation({\n ...shieldMutationOptions(token),\n ...options,\n ...optimisticBalanceCallbacks({\n optimistic: config.optimistic,\n tokenAddress: config.tokenAddress,\n queryClient,\n options,\n }),\n }) as UseMutationResult<TransactionResult, Error, ShieldParams, TContext>;\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQueryClient,\n UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport { shieldETHMutationOptions, type ShieldETHParams } from \"@zama-fhe/sdk/query\";\nimport { optimisticBalanceCallbacks } from \"./optimistic-balance-update\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/** Configuration for {@link useShieldETH}. */\nexport interface UseShieldETHConfig extends UseZamaConfig {\n /**\n * When `true`, optimistically adds the wrap amount to the cached confidential balance\n * before the transaction confirms. Rolls back on error.\n * @defaultValue false\n */\n optimistic?: boolean;\n}\n\n/**\n * Shield native ETH into confidential tokens.\n * Handles wrapping automatically. Invalidates balance caches on success.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — shield transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * Set `optimistic: true` to add the amount to the cached balance immediately.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const shieldETH = useShieldETH({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\", optimistic: true });\n * shieldETH.mutate({ amount: 1000000000000000000n }); // 1 ETH\n * ```\n */\nexport function useShieldETH<TContext = unknown>(\n config: UseShieldETHConfig,\n options?: UseMutationOptions<TransactionResult, Error, ShieldETHParams, TContext>,\n): UseMutationResult<TransactionResult, Error, ShieldETHParams, TContext> {\n const token = useToken(config);\n const queryClient = useQueryClient();\n\n return useMutation({\n ...shieldETHMutationOptions(token),\n ...options,\n ...optimisticBalanceCallbacks({\n optimistic: config.optimistic,\n tokenAddress: config.tokenAddress,\n queryClient,\n options,\n }),\n }) as UseMutationResult<TransactionResult, Error, ShieldETHParams, TContext>;\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnwrap,\n type UnwrapParams,\n unwrapMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Request an unwrap for a specific amount. Encrypts the amount first.\n * Call {@link useFinalizeUnwrap} after the request is processed on-chain,\n * or use {@link useUnshield} for a single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption of the unwrap amount failed\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrap = useUnwrap({ tokenAddress: \"0x...\" });\n * unwrap.mutate({ amount: 500n });\n * ```\n */\nexport function useUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnwrapParams, Address>({\n ...unwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport { invalidateAfterUnwrap, unwrapAllMutationOptions } from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Request an unwrap for the entire confidential balance.\n * Uses the on-chain balance handle directly (no encryption needed).\n * Call {@link useFinalizeUnwrap} after processing, or use {@link useUnshieldAll} for single-call orchestration.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unwrapAll = useUnwrapAll({ tokenAddress: \"0x...\" });\n * unwrapAll.mutate();\n * ```\n */\nexport function useUnwrapAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, void, Address>({\n ...unwrapAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnwrap(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n finalizeUnwrapMutationOptions,\n invalidateAfterUnshield,\n type FinalizeUnwrapParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Complete an unwrap by providing the public decryption proof.\n * Call this after an unwrap request has been processed on-chain.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption of the burn amount failed\n * - {@link TransactionRevertedError} — on-chain finalize transaction reverted\n *\n * @param config - Token address (and optional wrapper) identifying the token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const finalize = useFinalizeUnwrap({ tokenAddress: \"0x...\" });\n * finalize.mutate({ burnAmountHandle: event.encryptedAmount });\n * ```\n */\nexport function useFinalizeUnwrap(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, FinalizeUnwrapParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, FinalizeUnwrapParams, Address>({\n ...finalizeUnwrapMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldParams,\n unshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Unshield a specific amount and finalize in one call.\n * Orchestrates: unwrap → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link EncryptionFailedError} — FHE encryption failed during unwrap\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshield = useUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshield.mutate({ amount: 500n });\n * ```\n */\nexport function useUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldParams, Address>({\n ...unshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type UnshieldAllParams,\n unshieldAllMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Unshield the entire balance and finalize in one call.\n * Orchestrates: unwrapAll → wait for receipt → parse event → finalize.\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const unshieldAll = useUnshieldAll({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * unshieldAll.mutate();\n * ```\n */\nexport function useUnshieldAll(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, UnshieldAllParams | void, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, UnshieldAllParams | void, Address>({\n ...unshieldAllMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n invalidateAfterUnshield,\n type ResumeUnshieldParams,\n resumeUnshieldMutationOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Resume an interrupted unshield from an existing unwrap tx hash.\n * Useful when the user submitted the unwrap but the finalize step was\n * interrupted (e.g. page reload, network error).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link DecryptionFailedError} — public decryption failed during finalize\n * - {@link TransactionRevertedError} — on-chain transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const resumeUnshield = useResumeUnshield({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * resumeUnshield.mutate({ unwrapTxHash: \"0xabc...\" });\n * ```\n */\nexport function useResumeUnshield(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ResumeUnshieldParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ResumeUnshieldParams, Address>({\n ...resumeUnshieldMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterUnshield(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { signerAddressQueryOptions, underlyingAllowanceQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { underlyingAllowanceQueryOptions };\n\n/** Configuration for {@link useUnderlyingAllowance}. */\nexport interface UseUnderlyingAllowanceConfig {\n /** Address of the confidential token contract used to scope the query cache. */\n tokenAddress: Address;\n /** Address of the wrapper contract whose underlying ERC-20 allowance is checked. */\n wrapperAddress: Address;\n}\n\n/**\n * Read the underlying ERC-20 allowance granted to the wrapper contract.\n * Useful to check if an approval is needed before shielding.\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (current allowance).\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowance({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowance(\n config: UseUnderlyingAllowanceConfig,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, wrapperAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data;\n\n const baseOpts = underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n });\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Suspense variant of {@link useUnderlyingAllowance}.\n * Suspends rendering until the allowance is loaded.\n *\n * @param config - Token and wrapper addresses.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: allowance } = useUnderlyingAllowanceSuspense({\n * tokenAddress: \"0xConfidentialToken\",\n * wrapperAddress: \"0xWrapper\",\n * });\n * ```\n */\nexport function useUnderlyingAllowanceSuspense(config: UseUnderlyingAllowanceConfig) {\n const { tokenAddress, wrapperAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n const addressQuery = useSuspenseQuery<Address>({\n ...signerAddressQueryOptions(token.signer),\n });\n const owner = addressQuery.data;\n\n return useSuspenseQuery<bigint>({\n ...underlyingAllowanceQueryOptions(token.signer, tokenAddress, {\n owner,\n wrapperAddress,\n }),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { wrapperDiscoveryQueryOptions, zamaQueryKeys } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { wrapperDiscoveryQueryOptions };\n\n/** Configuration for {@link useWrapperDiscovery}. */\nexport interface UseWrapperDiscoveryConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper coordinator. Pass `undefined` to disable the query. */\n coordinatorAddress: Address | undefined;\n}\n\n/** Configuration for {@link useWrapperDiscoverySuspense}. */\nexport interface UseWrapperDiscoverySuspenseConfig {\n /** Address of the underlying ERC-20 token. */\n tokenAddress: Address;\n /** Address of the wrapper coordinator. */\n coordinatorAddress: Address;\n}\n\n/**\n * Discover the wrapper contract for an ERC-20 token.\n * Returns the wrapper address if one exists, or `null` if not.\n * Cached indefinitely since wrapper mappings are immutable.\n *\n * @param config - Token and coordinator addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscovery({\n * tokenAddress: \"0xUnderlying\",\n * coordinatorAddress: \"0xCoordinator\",\n * });\n * ```\n */\nexport function useWrapperDiscovery(\n config: UseWrapperDiscoveryConfig,\n options?: Omit<UseQueryOptions<Address | null, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<Address | null>({\n ...(coordinatorAddress\n ? wrapperDiscoveryQueryOptions(token.signer, tokenAddress, { coordinatorAddress })\n : {\n queryKey: zamaQueryKeys.wrapperDiscovery.all,\n queryFn: skipToken,\n }),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useWrapperDiscovery}.\n * Suspends rendering until the wrapper address is resolved.\n *\n * @param config - Token and coordinator addresses.\n * @returns Suspense query result with `data: Address | null`.\n *\n * @example\n * ```tsx\n * const { data: wrapperAddress } = useWrapperDiscoverySuspense({\n * tokenAddress: \"0xUnderlying\",\n * coordinatorAddress: \"0xCoordinator\",\n * });\n * ```\n */\nexport function useWrapperDiscoverySuspense(config: UseWrapperDiscoverySuspenseConfig) {\n const { tokenAddress, coordinatorAddress } = config;\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<Address | null>({\n ...wrapperDiscoveryQueryOptions(token.signer, tokenAddress, { coordinatorAddress }),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { tokenMetadataQueryOptions, type TokenMetadata } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { type TokenMetadata };\n\n/**\n * Read ERC-20 token metadata (name, symbol, decimals).\n * Fetches all three in parallel. Cached indefinitely since metadata is immutable.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadata(\"0xToken\");\n * // metadata?.name, metadata?.symbol, metadata?.decimals\n * ```\n */\nexport function useMetadata(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<TokenMetadata, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useMetadata}.\n * Suspends rendering until metadata is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: TokenMetadata`.\n *\n * @example\n * ```tsx\n * const { data: metadata } = useMetadataSuspense(\"0xToken\");\n * ```\n */\nexport function useMetadataSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<TokenMetadata>({\n ...tokenMetadataQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport type { Address, RawLog, ActivityLogMetadata, ActivityItem } from \"@zama-fhe/sdk\";\nimport { activityFeedQueryOptions, deriveActivityFeedLogsKey } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/** Configuration for {@link useActivityFeed}. */\nexport interface UseActivityFeedConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** Connected wallet address. Pass `undefined` to disable the query. */\n userAddress: Address | undefined;\n /** Raw event logs from the provider (viem, ethers, etc.). Pass `undefined` to disable. */\n logs: readonly (RawLog & Partial<ActivityLogMetadata>)[] | undefined;\n /** Whether to batch-decrypt encrypted transfer amounts. Default: `true`. */\n decrypt?: boolean;\n}\n\n/**\n * Two-phase activity feed hook.\n * Phase 1: Instantly parses raw logs into classified {@link ActivityItem}s (sync, cheap).\n * Phase 2: Batch-decrypts encrypted transfer amounts via the relayer (async).\n *\n * The wallet provides logs (from its own provider — viem, ethers, etc.)\n * and this hook normalizes + decrypts them.\n *\n * @param config - Token address, user address, raw logs, and decrypt option.\n * @returns Query result with `data: ActivityItem[]`.\n *\n * @example\n * ```tsx\n * const { data: activity } = useActivityFeed({\n * tokenAddress: \"0xToken\",\n * userAddress: \"0xUser\",\n * logs: rawLogs,\n * });\n * ```\n */\nexport function useActivityFeed(config: UseActivityFeedConfig) {\n const { tokenAddress, userAddress, logs, decrypt: decryptOpt } = config;\n const token = useReadonlyToken(tokenAddress);\n const decrypt = decryptOpt ?? true;\n const logsKey = deriveActivityFeedLogsKey(logs);\n\n return useQuery<ActivityItem[]>({\n ...activityFeedQueryOptions(token, {\n userAddress,\n logs,\n decrypt,\n logsKey,\n }),\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n delegateDecryptionMutationOptions,\n zamaQueryKeys,\n type DelegateDecryptionParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Delegate FHE decryption rights for a token to another address via the on-chain ACL.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const delegate = useDelegateDecryption({ tokenAddress: \"0x...\" });\n * delegate.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useDelegateDecryption(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, DelegateDecryptionParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, DelegateDecryptionParams>({\n ...delegateDecryptionMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n revokeDelegationMutationOptions,\n zamaQueryKeys,\n type RevokeDelegationParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Revoke FHE decryption delegation for a token from a delegate address.\n *\n * @param config - Token address identifying the confidential token.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const revoke = useRevokeDelegation({ tokenAddress: \"0x...\" });\n * revoke.mutate({ delegateAddress: \"0xDelegate\" });\n * ```\n */\nexport function useRevokeDelegation(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, RevokeDelegationParams>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, RevokeDelegationParams>({\n ...revokeDelegationMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n context.client.invalidateQueries({ queryKey: zamaQueryKeys.delegationStatus.all });\n options?.onSuccess?.(data, variables, onMutateResult, context);\n },\n });\n}\n","\"use client\";\n\nimport { skipToken, type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n delegationStatusQueryOptions,\n zamaQueryKeys,\n type DelegationStatusData,\n} from \"@zama-fhe/sdk/query\";\nimport { useQuery } from \"../utils/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport interface UseDelegationStatusConfig {\n /** Address of the confidential token contract. */\n tokenAddress: Address;\n /** The address that granted the delegation. */\n delegatorAddress?: Address;\n /** The address that received delegation rights. */\n delegateAddress?: Address;\n}\n\n/**\n * Query delegation status between a delegator and delegate for a token.\n *\n * @param config - Token address, delegator, and delegate addresses.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns `{ isDelegated, expiryTimestamp, isLoading, error }`.\n *\n * @example\n * ```tsx\n * const { data } = useDelegationStatus({\n * tokenAddress: \"0xToken\",\n * delegatorAddress: \"0xDelegator\",\n * delegateAddress: \"0xDelegate\",\n * });\n * // data?.isDelegated, data?.expiryTimestamp\n * ```\n */\nexport function useDelegationStatus(\n config: UseDelegationStatusConfig,\n options?: Omit<UseQueryOptions<DelegationStatusData, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const readonlyToken = useReadonlyToken(config.tokenAddress);\n\n const enabled = Boolean(config.delegatorAddress && config.delegateAddress);\n const baseOpts =\n config.delegatorAddress && config.delegateAddress\n ? delegationStatusQueryOptions(readonlyToken, {\n delegatorAddress: config.delegatorAddress,\n delegateAddress: config.delegateAddress,\n })\n : {\n queryKey: zamaQueryKeys.delegationStatus.all,\n queryFn: skipToken as unknown as () => Promise<DelegationStatusData>,\n };\n\n return useQuery<DelegationStatusData>({\n ...baseOpts,\n enabled,\n ...options,\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { decryptBalanceAsMutationOptions, type DecryptBalanceAsParams } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\n/**\n * Decrypt another user's confidential balance as a delegate.\n *\n * @param tokenAddress - Address of the confidential token contract.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const decryptAs = useDecryptBalanceAs(\"0xToken\");\n * decryptAs.mutate({ delegatorAddress: \"0xDelegator\" });\n * // decryptAs.data => 1000n\n * ```\n */\nexport function useDecryptBalanceAs(\n tokenAddress: Address,\n options?: UseMutationOptions<bigint, Error, DecryptBalanceAsParams>,\n) {\n const readonlyToken = useReadonlyToken(tokenAddress);\n\n return useMutation<bigint, Error, DecryptBalanceAsParams>({\n ...decryptBalanceAsMutationOptions(readonlyToken),\n ...options,\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\nimport { ReadonlyToken, type Address, type BatchDecryptAsOptions } from \"@zama-fhe/sdk\";\n\n/**\n * Batch decrypt confidential balances as a delegate across multiple tokens.\n *\n * @param tokens - ReadonlyToken instances to decrypt balances for.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const batchDecryptAs = useBatchDecryptBalancesAs(tokens);\n * batchDecryptAs.mutate({\n * delegatorAddress: \"0xDelegator\",\n * });\n * // batchDecryptAs.data => Map { \"0xTokenA\" => 100n, \"0xTokenB\" => 200n }\n * ```\n */\nexport function useBatchDecryptBalancesAs(\n tokens: ReadonlyToken[],\n options?: UseMutationOptions<Map<Address, bigint>, Error, BatchDecryptAsOptions>,\n) {\n return useMutation<Map<Address, bigint>, Error, BatchDecryptAsOptions>({\n mutationKey: [\"zama.batchDecryptBalancesAs\", ...tokens.map((t) => t.address)] as const,\n mutationFn: async (params) => ReadonlyToken.batchDecryptBalancesAs(tokens, params),\n ...options,\n });\n}\n","\"use client\";\n\nimport { useMutation, UseMutationOptions } from \"@tanstack/react-query\";\nimport type { Address, TransactionResult } from \"@zama-fhe/sdk\";\nimport {\n approveUnderlyingMutationOptions,\n invalidateAfterApproveUnderlying,\n type ApproveUnderlyingParams,\n} from \"@zama-fhe/sdk/query\";\nimport { useToken, type UseZamaConfig } from \"./use-token\";\n\n/**\n * Approve the wrapper contract to spend the underlying ERC-20.\n * Defaults to max uint256. Resets to zero first if there's an existing\n * non-zero allowance (required by tokens like USDT).\n *\n * Errors are {@link ZamaError} subclasses — use `instanceof` to handle specific failures:\n * - {@link SigningRejectedError} — user rejected the wallet prompt\n * - {@link TransactionRevertedError} — approval transaction reverted\n *\n * @param config - Token and wrapper addresses.\n * @param options - React Query mutation options.\n *\n * @example\n * ```tsx\n * const approve = useApproveUnderlying({ tokenAddress: \"0x...\", wrapperAddress: \"0x...\" });\n * approve.mutate({}); // max approval\n * approve.mutate({ amount: 1000n }); // exact amount\n * ```\n */\nexport function useApproveUnderlying(\n config: UseZamaConfig,\n options?: UseMutationOptions<TransactionResult, Error, ApproveUnderlyingParams, Address>,\n) {\n const token = useToken(config);\n\n return useMutation<TransactionResult, Error, ApproveUnderlyingParams, Address>({\n ...approveUnderlyingMutationOptions(token),\n ...options,\n onSuccess: (data, variables, onMutateResult, context) => {\n options?.onSuccess?.(data, variables, onMutateResult, context);\n invalidateAfterApproveUnderlying(context.client, config.tokenAddress);\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { isConfidentialQueryOptions, isWrapperQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { isConfidentialQueryOptions, isWrapperQueryOptions };\n\n/**\n * Check if a token supports the ERC-7984 confidential interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidential(\"0xToken\");\n * ```\n */\nexport function useIsConfidential(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean>({\n ...isConfidentialQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsConfidential}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isConfidential } = useIsConfidentialSuspense(\"0xToken\");\n * ```\n */\nexport function useIsConfidentialSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean>({\n ...isConfidentialQueryOptions(token.signer, tokenAddress),\n });\n}\n\n/**\n * Check if a token supports the ERC-7984 wrapper interface via ERC-165.\n * Result is cached indefinitely since interface support does not change.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapper(\"0xToken\");\n * ```\n */\nexport function useIsWrapper(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<boolean, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<boolean>({\n ...isWrapperQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useIsWrapper}.\n * Suspends rendering until the ERC-165 check resolves.\n *\n * @param tokenAddress - Address of the token contract to check.\n * @returns Suspense query result with `data: boolean`.\n *\n * @example\n * ```tsx\n * const { data: isWrapper } = useIsWrapperSuspense(\"0xToken\");\n * ```\n */\nexport function useIsWrapperSuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<boolean>({\n ...isWrapperQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { totalSupplyQueryOptions } from \"@zama-fhe/sdk/query\";\nimport { useReadonlyToken } from \"./use-readonly-token\";\n\nexport { totalSupplyQueryOptions };\n\n/**\n * Read the total supply of a token.\n * Stale after 30 seconds to balance freshness and RPC cost.\n *\n * @param tokenAddress - Address of the token contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupply(\"0xToken\");\n * ```\n */\nexport function useTotalSupply(\n tokenAddress: Address,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const token = useReadonlyToken(tokenAddress);\n\n return useQuery<bigint>({\n ...totalSupplyQueryOptions(token.signer, tokenAddress),\n ...options,\n });\n}\n\n/**\n * Suspense variant of {@link useTotalSupply}.\n * Suspends rendering until the total supply is loaded.\n *\n * @param tokenAddress - Address of the token contract.\n * @returns Suspense query result with `data: bigint`.\n *\n * @example\n * ```tsx\n * const { data: totalSupply } = useTotalSupplySuspense(\"0xToken\");\n * ```\n */\nexport function useTotalSupplySuspense(tokenAddress: Address) {\n const token = useReadonlyToken(tokenAddress);\n\n return useSuspenseQuery<bigint>({\n ...totalSupplyQueryOptions(token.signer, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"../utils/query\";\nimport { type UseQueryOptions } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport {\n batchTransferFeeQueryOptions,\n feeRecipientQueryOptions,\n shieldFeeQueryOptions,\n unshieldFeeQueryOptions,\n} from \"@zama-fhe/sdk/query\";\nimport { useZamaSDK } from \"../provider\";\n\nexport {\n batchTransferFeeQueryOptions,\n feeRecipientQueryOptions,\n shieldFeeQueryOptions,\n unshieldFeeQueryOptions,\n};\n\n/** Configuration for {@link useShieldFee} and {@link useUnshieldFee}. */\nexport interface UseFeeConfig {\n /** Address of the fee manager contract. */\n feeManagerAddress: Address;\n /** Amount to calculate the fee for. */\n amount: bigint;\n /** Sender address. */\n from: Address;\n /** Receiver address. */\n to: Address;\n}\n\n/**\n * Read the shield fee for a given amount and address pair.\n *\n * @param config - Fee manager address, amount, from, and to.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useShieldFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useShieldFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = shieldFeeQueryOptions(sdk.signer, config);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the unshield fee for a given amount and address pair.\n *\n * @param config - Fee manager address, amount, from, and to.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useUnshieldFee({\n * feeManagerAddress: \"0xFeeManager\",\n * amount: 1000n,\n * from: \"0xSender\",\n * to: \"0xReceiver\",\n * });\n * ```\n */\nexport function useUnshieldFee(\n config: UseFeeConfig,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = unshieldFeeQueryOptions(sdk.signer, config);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the batch transfer fee from the fee manager.\n *\n * @param feeManagerAddress - Address of the fee manager contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: bigint` (the fee amount).\n *\n * @example\n * ```tsx\n * const { data: fee } = useBatchTransferFee(\"0xFeeManager\");\n * ```\n */\nexport function useBatchTransferFee(\n feeManagerAddress: Address,\n options?: Omit<UseQueryOptions<bigint, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = batchTransferFeeQueryOptions(sdk.signer, feeManagerAddress);\n\n return useQuery<bigint>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n\n/**\n * Read the fee recipient address from the fee manager.\n *\n * @param feeManagerAddress - Address of the fee manager contract.\n * @param options - React Query options (forwarded to `useQuery`).\n * @returns Query result with `data: Address` (the fee recipient).\n *\n * @example\n * ```tsx\n * const { data: recipient } = useFeeRecipient(\"0xFeeManager\");\n * ```\n */\nexport function useFeeRecipient(\n feeManagerAddress: Address,\n options?: Omit<UseQueryOptions<Address, Error>, \"queryKey\" | \"queryFn\">,\n) {\n const sdk = useZamaSDK();\n const baseOpts = feeRecipientQueryOptions(sdk.signer, feeManagerAddress);\n\n return useQuery<Address>({\n ...baseOpts,\n ...options,\n enabled: (baseOpts.enabled ?? true) && (options?.enabled ?? true),\n });\n}\n"],"mappings":"spLAkDA,MAAM,EAAiB,GAA8B,KAAK,CAY1D,SAAgB,GAAa,CAC3B,WACA,UACA,SACA,UACA,iBACA,aACA,aACA,WACoB,CACpB,IAAM,EAAc,GAAgB,CAG9B,EAAa,GAAO,EAAQ,CAClC,MAAgB,CACd,EAAW,QAAU,GACrB,CAEF,IAAM,EAA2B,MAE7B,GAAQ,UACJ,CACE,iBAAoB,EAAiC,EAAY,CACjE,oBAAuB,EAAiC,EAAY,CACpE,kBAAqB,EAAiC,EAAY,CACnE,CACD,IAAA,GACN,CAAC,EAAa,EAAO,CACtB,CAEK,EAAM,MAER,IAAIA,GAAQ,CACV,UACA,SACA,UACA,iBACA,aACA,aACA,QAAS,EAAW,QACpB,2BACD,CAAC,CACJ,CAAC,EAAS,EAAQ,EAAS,EAAgB,EAAY,EAAY,EAAyB,CAC7F,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,ECjHT,SAAgB,IAAa,CAE3B,OAAO,EAAiDC,GAD5C,GAAY,CAC2D,CAAC,CCftF,M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L,GAAY,CACmB,OAAQ,EAAO,CAE1D,OAAOC,EAAiB,CACtB,GAAG,EACH,GAAG,EACH,SAAU,EAAS,SAAW,MAAU,GAAS,SAAW,IAC7D,CAAC,CAoBJ,SAAgB,GACd,EACA,EACA,CAEA,IAAM,EAAWC,GADL,GAAY,CACqB,OAAQ,EAAO,CAE5D,OAAOD,EAAiB,CACtB,GAAG,EACH,GAAG,EACH,SAAU,EAAS,SAAW,MAAU,GAAS,SAAW,IAC7D,CAAC,CAeJ,SAAgB,GACd,EACA,EACA,CAEA,IAAM,EAAWE,GADL,GAAY,CAC0B,OAAQ,EAAkB,CAE5E,OAAOF,EAAiB,CACtB,GAAG,EACH,GAAG,EACH,SAAU,EAAS,SAAW,MAAU,GAAS,SAAW,IAC7D,CAAC,CAeJ,SAAgB,GACd,EACA,EACA,CAEA,IAAM,EAAWG,GADL,GAAY,CACsB,OAAQ,EAAkB,CAExE,OAAOH,EAAkB,CACvB,GAAG,EACH,GAAG,EACH,SAAU,EAAS,SAAW,MAAU,GAAS,SAAW,IAC7D,CAAC"}
|
package/dist/wagmi/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ declare class WagmiSigner implements GenericSigner {
|
|
|
22
22
|
writeContract<const TAbi extends ContractAbi, TFunctionName extends WriteFunctionName<TAbi>, const TArgs extends WriteContractArgs<TAbi, TFunctionName>>(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex>;
|
|
23
23
|
readContract<const TAbi extends ContractAbi, TFunctionName extends ReadFunctionName<TAbi>, const TArgs extends ReadContractArgs<TAbi, TFunctionName>>(config: ReadContractConfig<TAbi, TFunctionName, TArgs>): Promise<ReadContractReturnType<TAbi, TFunctionName, TArgs>>;
|
|
24
24
|
waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt>;
|
|
25
|
+
getBlockTimestamp(): Promise<bigint>;
|
|
25
26
|
subscribe({
|
|
26
27
|
onDisconnect,
|
|
27
28
|
onAccountChange,
|
package/dist/wagmi/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{TransactionRevertedError as e}from"@zama-fhe/sdk";import{getAccount as t,
|
|
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
|
package/dist/wagmi/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 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 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":"
|
|
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,CAClC,OAAO,EAAW,KAAK,OAAO,CAGhC,MAAM,YAA+B,CACnC,IAAM,EAAU,EAAW,KAAK,OAAO,CACvC,GAAI,CAAC,GAAS,QACZ,MAAU,UAAU,kBAAkB,CAExC,OAAO,EAAQ,QAGjB,MAAM,cAAc,EAA0C,CAC5D,GAAM,CAAE,aAAc,EAAG,GAAG,GAAa,EAAU,MACnD,OAAO,EAAc,KAAK,OAAQ,CAChC,YAAa,OAAO,KAAK,EAAS,CAAC,GACnC,MAAO,EACP,OAAQ,EAAU,OAClB,QAAS,EAAU,QACpB,CAAC,CAGJ,MAAM,cAIJ,EAAuE,CACvE,OAAO,EAAc,KAAK,OAAQ,EAA8C,CAGlF,MAAM,aAKJ,EAC6D,CAC7D,OAAO,EAAa,KAAK,OAAQ,EAAO,CAG1C,MAAM,0BAA0B,EAAwC,CACtE,GAAI,CACF,OAAO,MAAM,EAA0B,KAAK,OAAQ,CAAE,OAAM,CAAC,OACtD,EAAO,CACd,IAAM,EAAU,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAStE,MARI,EAAQ,SAAS,qBAAqB,EAAI,EAAQ,SAAS,wBAAwB,CAC/E,IAAI,EACR,gDAAgD,EAAK,MAAM,EAAG,GAAG,CAAC,2HAGlE,CAAE,MAAO,aAAiB,MAAQ,EAAQ,IAAA,GAAW,CACtD,CAEG,GAIV,MAAM,mBAAqC,CAEzC,OADc,MAAM,EAAS,KAAK,OAAO,EAC5B,UAGf,UAAU,CACR,mBAAqB,GACrB,sBAAwB,GACxB,oBAAsB,IACiB,CACvC,OAAO,EAAgB,KAAK,OAAQ,CAClC,SAAS,EAAY,EAAgB,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zama-fhe/react-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-alpha.1",
|
|
4
4
|
"description": "React hooks for Zama SDK",
|
|
5
5
|
"license": "BSD-3-Clause-Clear",
|
|
6
6
|
"author": "Zama",
|
|
@@ -48,18 +48,18 @@
|
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rm -rf dist && rolldown --config rolldown.config.ts",
|
|
51
|
-
"lint": "
|
|
51
|
+
"lint": "oxlint",
|
|
52
52
|
"typecheck": "tsc --noEmit"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@zama-fhe/sdk": "workspace:*",
|
|
56
56
|
"rolldown": "1.0.0-rc.7",
|
|
57
57
|
"rolldown-plugin-dts": "^0.22.4",
|
|
58
|
-
"viem": "^2.47.
|
|
58
|
+
"viem": "^2.47.1"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@tanstack/react-query": ">=5",
|
|
62
|
-
"@zama-fhe/sdk": "^1.
|
|
62
|
+
"@zama-fhe/sdk": "^1.2.0-alpha.1",
|
|
63
63
|
"react": ">=18",
|
|
64
64
|
"viem": "^2.47.0",
|
|
65
65
|
"wagmi": ">=2"
|