@zama-fhe/sdk 3.7.0-beta.2 → 3.7.0-beta.4

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.
Files changed (61) hide show
  1. package/dist/cjs/base-signer.cjs +1 -1
  2. package/dist/cjs/base-signer.cjs.map +1 -1
  3. package/dist/cjs/chains/index.cjs +1 -1
  4. package/dist/cjs/chains.cjs +1 -1
  5. package/dist/cjs/chains.cjs.map +1 -1
  6. package/dist/cjs/index.cjs +1 -1
  7. package/dist/cjs/index.cjs.map +1 -1
  8. package/dist/cjs/node/index.cjs +1 -1
  9. package/dist/cjs/relayer.cjs +1 -1
  10. package/dist/cjs/relayer.cjs.map +1 -1
  11. package/dist/esm/base-signer-CwsN9lXD.js +2 -0
  12. package/dist/esm/{base-signer-D5Cwv7yb.js.map → base-signer-CwsN9lXD.js.map} +1 -1
  13. package/dist/esm/{base-signer-DIYZwDnc.d.ts → base-signer-D902THgk.d.ts} +2 -2
  14. package/dist/esm/chains/index.d.ts +2 -2
  15. package/dist/esm/chains/index.js +1 -1
  16. package/dist/esm/{chains-ByyCdrrd.js → chains-iPpnjXql.js} +2 -2
  17. package/dist/esm/{chains-ByyCdrrd.js.map → chains-iPpnjXql.js.map} +1 -1
  18. package/dist/esm/cleartext/index.d.ts +2 -2
  19. package/dist/esm/cleartext/index.js +1 -1
  20. package/dist/esm/{cleartext-PCpNqRGV.js → cleartext-B58fIRPQ.js} +2 -2
  21. package/dist/esm/{cleartext-PCpNqRGV.js.map → cleartext-B58fIRPQ.js.map} +1 -1
  22. package/dist/esm/{cleartext-3HOk1BAg.d.ts → cleartext-B6vrnBzO.d.ts} +2 -2
  23. package/dist/esm/{encryption-BKoalB4o.js → encryption-6AVd-82z.js} +2 -2
  24. package/dist/esm/{encryption-BKoalB4o.js.map → encryption-6AVd-82z.js.map} +1 -1
  25. package/dist/esm/{erc165-DbMOt-s6.js → erc165-rAtrIcS8.js} +2 -2
  26. package/dist/esm/{erc165-DbMOt-s6.js.map → erc165-rAtrIcS8.js.map} +1 -1
  27. package/dist/esm/ethers/index.d.ts +4 -4
  28. package/dist/esm/ethers/index.js +1 -1
  29. package/dist/esm/{fhevm-relayer-CtrnKjJf.js → fhevm-relayer-Y5XYNOcs.js} +2 -2
  30. package/dist/esm/{fhevm-relayer-CtrnKjJf.js.map → fhevm-relayer-Y5XYNOcs.js.map} +1 -1
  31. package/dist/esm/{index-ijgDL4IC.d.ts → index-Cdbp_93f.d.ts} +24 -4
  32. package/dist/esm/{index-BHrjck_q.d.ts → index-CsuDB4UI.d.ts} +4 -4
  33. package/dist/esm/{index-DJYq1rAB.d.ts → index-DlpdjcMQ.d.ts} +1542 -1091
  34. package/dist/esm/index.d.ts +108 -8
  35. package/dist/esm/index.js +1 -1
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/node/index.d.ts +5 -5
  38. package/dist/esm/node/index.js +1 -1
  39. package/dist/esm/node/index.js.map +1 -1
  40. package/dist/esm/query/index.d.ts +4 -495
  41. package/dist/esm/query/index.js +1 -1
  42. package/dist/esm/{relayer-CVKO9GmQ.js → relayer-C3jVhqSK.js} +2 -2
  43. package/dist/esm/{relayer-CVKO9GmQ.js.map → relayer-C3jVhqSK.js.map} +1 -1
  44. package/dist/esm/{token-CRJ8eCr7.js → token-CBG_zTyz.js} +2 -2
  45. package/dist/esm/{token-CRJ8eCr7.js.map → token-CBG_zTyz.js.map} +1 -1
  46. package/dist/esm/{types-Bz5-wHPv.d.ts → types-Crf7ymyj.d.ts} +2 -2
  47. package/dist/esm/{types-v0_sfkli.d.ts → types-CuldbZne.d.ts} +3 -3
  48. package/dist/esm/{types-CI6BtpB7.d.ts → types-DnJSNoEC.d.ts} +3 -3
  49. package/dist/esm/{validation-BRu06AM_.js → validation-ClSvPh6P.js} +2 -2
  50. package/dist/esm/{validation-BRu06AM_.js.map → validation-ClSvPh6P.js.map} +1 -1
  51. package/dist/esm/vaults/index.d.ts +2 -3
  52. package/dist/esm/vaults/index.js +1 -1
  53. package/dist/esm/viem/index.d.ts +4 -4
  54. package/dist/esm/viem/index.js +1 -1
  55. package/dist/esm/web/index.d.ts +1 -1
  56. package/dist/esm/web/index.js +1 -1
  57. package/dist/esm/{wrapped-token-BOtzaSAY.js → wrapped-token-BpvG7nqK.js} +2 -2
  58. package/dist/esm/{wrapped-token-BOtzaSAY.js.map → wrapped-token-BpvG7nqK.js.map} +1 -1
  59. package/package.json +1 -1
  60. package/dist/esm/base-signer-D5Cwv7yb.js +0 -2
  61. package/dist/esm/invalidation-CJ-pzOUG.d.ts +0 -46
@@ -1,10 +1,10 @@
1
- import { f as FheChain } from "./index-ijgDL4IC.js";
2
- import { D as GenericSigner, O as WalletAccount, S as TransactionKind, St as WrapOptions, Tt as UnshieldCallbacks, _ as PrepareTransactionRequest, _t as ShieldOptions, bt as UnshieldOptions, c as GenericStorage, cn as EncryptedValue, dn as FhevmRelayerOptions, en as TransactionResult, g as PrepareOptions, i as ZamaConfig, l as GenericProvider, mn as RelayerSDK, nn as DecryptPublicValuesResult, o as ZamaConfigGeneric, on as EncryptParams, sn as EncryptResult, tn as ClearValue, v as PreparedFor, wt as TransferCallbacks, xt as UnwrapResult, yt as TransferOptions } from "./types-Bz5-wHPv.js";
3
- import "./cleartext-3HOk1BAg.js";
4
- import "./types-v0_sfkli.js";
5
- import "./base-signer-DIYZwDnc.js";
6
- import "./types-CI6BtpB7.js";
7
- import { Address, Address as Address$1, Hex, Hex as Hex$1 } from "viem";
1
+ import { p as FheChain } from "./index-Cdbp_93f.js";
2
+ import { D as GenericSigner, O as WalletAccount, S as TransactionKind, St as WrapOptions, Tt as UnshieldCallbacks, _ as PrepareTransactionRequest, _t as ShieldOptions, bt as UnshieldOptions, c as GenericStorage, cn as EncryptedValue, dn as FhevmRelayerOptions, en as TransactionResult, g as PrepareOptions, i as ZamaConfig, l as GenericProvider, mn as RelayerSDK, nn as DecryptPublicValuesResult, o as ZamaConfigGeneric, on as EncryptParams, sn as EncryptResult, tn as ClearValue, v as PreparedFor, wt as TransferCallbacks, xt as UnwrapResult, yt as TransferOptions } from "./types-Crf7ymyj.js";
3
+ import "./cleartext-B6vrnBzO.js";
4
+ import "./types-CuldbZne.js";
5
+ import "./types-DnJSNoEC.js";
6
+ import "./index-CsuDB4UI.js";
7
+ import { Address, Hex } from "viem";
8
8
  import { z } from "zod/mini";
9
9
  import { MutationFunctionContext, QueryKey, QueryObserverOptions, skipToken } from "@tanstack/query-core";
10
10
  //#region src/config/create.d.ts
@@ -19789,6 +19789,8 @@ declare const ZamaErrorCode: {
19789
19789
  readonly DelegationExpiryUnchanged: "DELEGATION_EXPIRY_UNCHANGED";
19790
19790
  /** Delegate address cannot be the contract address. */
19791
19791
  readonly DelegationDelegateEqualsContract: "DELEGATION_DELEGATE_EQUALS_CONTRACT";
19792
+ /** Delegate address cannot be the wildcard address — it's only valid as `contractAddress`. */
19793
+ readonly DelegationDelegateCannotBeWildcard: "DELEGATION_DELEGATE_CANNOT_BE_WILDCARD";
19792
19794
  /** Contract address cannot be the sender address. */
19793
19795
  readonly DelegationContractIsSelf: "DELEGATION_CONTRACT_IS_SELF";
19794
19796
  /** The ACL contract is paused. */
@@ -20000,6 +20002,10 @@ declare class DelegationExpiryUnchangedError extends ZamaError {
20000
20002
  declare class DelegationDelegateEqualsContractError extends ZamaError {
20001
20003
  constructor(message: string, options?: ErrorOptions);
20002
20004
  }
20005
+ /** Delegate address cannot be the wildcard address — it's only valid as `contractAddress`. */
20006
+ declare class DelegationDelegateCannotBeWildcardError extends ZamaError {
20007
+ constructor(message: string, options?: ErrorOptions);
20008
+ }
20003
20009
  /** Contract address cannot be the sender address. */
20004
20010
  declare class DelegationContractIsSelfError extends ZamaError {
20005
20011
  constructor(message: string, options?: ErrorOptions);
@@ -20358,6 +20364,8 @@ interface ErrorForCode {
20358
20364
  [ZamaErrorCode.DelegationExpiryUnchanged]: DelegationExpiryUnchangedError;
20359
20365
  /** Thrown for {@link ZamaErrorCode.DelegationDelegateEqualsContract}. */
20360
20366
  [ZamaErrorCode.DelegationDelegateEqualsContract]: DelegationDelegateEqualsContractError;
20367
+ /** Thrown for {@link ZamaErrorCode.DelegationDelegateCannotBeWildcard}. */
20368
+ [ZamaErrorCode.DelegationDelegateCannotBeWildcard]: DelegationDelegateCannotBeWildcardError;
20361
20369
  /** Thrown for {@link ZamaErrorCode.DelegationContractIsSelf}. */
20362
20370
  [ZamaErrorCode.DelegationContractIsSelf]: DelegationContractIsSelfError;
20363
20371
  /** Thrown for {@link ZamaErrorCode.AclPaused}. */
@@ -20569,7 +20577,7 @@ declare class Permits {
20569
20577
  }
20570
20578
  //#endregion
20571
20579
  //#region src/services/delegation-service.d.ts
20572
- /** Delegation activity and expiry, resolved from a single expiry read. */
20580
+ /** Delegation activity and expiry, resolved from the active contract or wildcard grant. */
20573
20581
  interface DelegationStatus {
20574
20582
  /** Whether the delegation is currently active (exists and not expired). */
20575
20583
  isActive: boolean;
@@ -20602,7 +20610,8 @@ declare class Delegations {
20602
20610
  * window with a bounded internal retry, so you can decrypt right after this
20603
20611
  * resolves.
20604
20612
  *
20605
- * @param contractAddress - The confidential contract address to delegate on.
20613
+ * @param contractAddress - The confidential contract address to delegate on, or
20614
+ * {@link WILDCARD_CONTRACT} to cover every contract with a single delegation.
20606
20615
  * @param delegateAddress - Address to delegate decryption rights to.
20607
20616
  * @param expirationDate - Optional expiration date (defaults to permanent delegation via `uint64.max`).
20608
20617
  * @returns The transaction hash and mined receipt.
@@ -20610,6 +20619,7 @@ declare class Delegations {
20610
20619
  * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20611
20620
  * @throws if `expirationDate` is less than 1 hour in the future. {@link DelegationExpirationTooSoonError}
20612
20621
  * @throws if the delegate equals the connected wallet. {@link DelegationSelfNotAllowedError}
20622
+ * @throws if the delegate is the wildcard address. {@link DelegationDelegateCannotBeWildcardError}
20613
20623
  * @throws if the delegate equals the contract address. {@link DelegationDelegateEqualsContractError}
20614
20624
  * @throws if the new expiry equals the current one. {@link DelegationExpiryUnchangedError}
20615
20625
  * @throws if the delegation transaction reverts. {@link TransactionRevertedError}
@@ -20683,1192 +20693,1504 @@ declare class Delegations {
20683
20693
  }): Promise<DelegationStatus>;
20684
20694
  }
20685
20695
  //#endregion
20686
- //#region src/namespaces/offline.d.ts
20696
+ //#region src/query/utils.d.ts
20697
+ /** Union of TanStack Query option keys stripped by {@link filterQueryOptions}, leaving only domain parameters. */
20698
+ type StrippedQueryOptionKeys = "gcTime" | "staleTime" | "enabled" | "select" | "refetchInterval" | "refetchOnMount" | "refetchOnWindowFocus" | "refetchOnReconnect" | "retry" | "retryDelay" | "retryOnMount" | "queryFn" | "queryKey" | "queryKeyHashFn" | "initialData" | "initialDataUpdatedAt" | "placeholderData" | "structuralSharing" | "throwOnError" | "meta" | "query" | "pollingInterval";
20687
20699
  /**
20688
- * Namespace for the offline-signing pipeline —
20689
- * `prepare → [external sign + self-publish]` — for institutional custody, HSM
20690
- * ceremonies, and policy-engine workflows where signing runs out-of-process and
20691
- * cannot happen synchronously in a single Promise.
20700
+ * Remove TanStack behavioral options from a query config object so only domain
20701
+ * parameters remain for the lower-level factory.
20702
+ *
20703
+ * @example
20704
+ * ```ts
20705
+ * const params = filterQueryOptions({
20706
+ * query: { enabled: false },
20707
+ * gcTime: 60_000,
20708
+ * owner: "0xabc",
20709
+ * });
20710
+ * // => { owner: "0xabc" }
20711
+ * ```
20692
20712
  */
20693
- declare class Offline {
20694
- #private;
20695
- /**
20696
- * Build an RLP-encoded unsigned transaction for the given request. The
20697
- * caller signs it externally — via an HSM ceremony, an out-of-process
20698
- * custodian, or any signer holding the key — and broadcasts the signed bytes
20699
- * through its own channel.
20700
- *
20701
- * Signer-optional: works without a configured signer (canonical shape for
20702
- * cross-process custody — the back-end signer service consumes
20703
- * `prepared.unsignedTx` and returns signed bytes).
20704
- *
20705
- * @remarks
20706
- * `request.from` is only a declaration — the SDK does not prove the caller
20707
- * controls it, and an EIP-1559 unsigned tx carries no `from` field at all
20708
- * (the on-chain sender is whichever key signs the bytes). Point `from` at
20709
- * the account the custodian will sign with; custodians enforce key-control
20710
- * at sign time — a signing request for a key the credential can't use fails
20711
- * there — so a mismatched `from` cannot make the custodian sign from an
20712
- * account you don't control. Verifying control of `from` up front is still
20713
- * the application's responsibility.
20714
- */
20715
- prepare<K extends TransactionKind>(request: Extract<PrepareTransactionRequest, {
20716
- kind: K;
20717
- }>, options?: PrepareOptions): Promise<PreparedFor<K>>;
20718
- /**
20719
- * Build the offline-signing payload for a decryption permit: the unsigned
20720
- * EIP-712 typed data plus everything `sdk.permits.registerPermit` needs to
20721
- * verify and persist the signature an out-of-process signer returns for it.
20722
- *
20723
- * Not a `prepare()` transaction kind: a permit is not a transaction —
20724
- * nothing is broadcast, and registering the signature is a local operation,
20725
- * not a relayer round-trip.
20726
- *
20727
- * Signer-optional, like {@link prepare}: `request.signer` is an explicit
20728
- * address, not a connected wallet account. Building the typed data still
20729
- * reads the chain's KMS signers context on-chain — signer-offline, not
20730
- * network-offline.
20731
- *
20732
- * One permit per call: unlike `sdk.permits.grantPermit`, this never widens
20733
- * an existing permit or chunks over 10 contracts — `request.contracts` maps
20734
- * to exactly one signature.
20735
- *
20736
- * @throws if `request.contracts` is empty or exceeds 10 addresses, `request.delegator`
20737
- * equals `request.signer`, or `request.durationDays` exceeds the V1 permit maximum
20738
- * of 365 days. {@link ConfigurationError}
20739
- * @throws if a concurrent `permits.revokeTransportKeyPair()` rotates the transport key
20740
- * pair while this call is generating one. {@link TransportKeyPairChangedError}
20741
- */
20742
- preparePermit(request: PreparePermitRequest): Promise<PreparedPermit>;
20743
- }
20713
+ declare function filterQueryOptions<TOptions extends Record<string, unknown>>(options: TOptions): Omit<TOptions, StrippedQueryOptionKeys>;
20714
+ /**
20715
+ * Stable hash function for query keys.
20716
+ * Sorts object keys recursively and converts bigint values to strings.
20717
+ *
20718
+ * @remarks
20719
+ * bigint values are serialized as decimal strings, so `42n` and `"42"` hash to
20720
+ * the same token when they occupy the same position. This collision is accepted
20721
+ * by design for the current query-key conventions in this package.
20722
+ */
20723
+ declare function hashFn(queryKey: readonly unknown[]): string;
20744
20724
  //#endregion
20745
- //#region src/token/token.d.ts
20746
- /** Options for {@link Token.batchDecryptBalancesAs}. */
20747
- interface BatchDecryptAsOptions {
20748
- /** The address of the account that delegated decryption rights. */
20749
- delegatorAddress: Address;
20750
- /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */
20751
- encryptedValues?: EncryptedValue[];
20752
- /**
20753
- * The account whose on-chain balance to read. Defaults to the delegator
20754
- * address, which is the common case (the delegator grants permission to
20755
- * decrypt their own balance). Only set this when the account differs
20756
- * from the delegator.
20757
- *
20758
- * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.
20759
- */
20760
- accountAddress?: Address;
20761
- /** Maximum number of concurrent decrypt calls. Default: 10. */
20762
- maxConcurrency?: number;
20763
- /** Called when decryption fails for a single token. Return a fallback bigint. */
20764
- onError?: (error: Error, address: Address) => bigint;
20725
+ //#region src/query/factory-types.d.ts
20726
+ /**
20727
+ * TanStack Query options object returned by the SDK's `*QueryOptions` factories:
20728
+ * `QueryObserverOptions` with `queryKey` and `queryFn` required and the
20729
+ * cache-internal keys (`queryHash`, `queryKeyHashFn`, `throwOnError`) removed.
20730
+ */
20731
+ type QueryFactoryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey"> & Required<Pick<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey">>, "queryFn" | "queryHash" | "queryKeyHashFn" | "throwOnError"> & {
20732
+ queryFn: Exclude<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>["queryFn"], typeof skipToken | undefined>;
20733
+ };
20734
+ /** TanStack Query mutation options object returned by the SDK's `*MutationOptions` factories. */
20735
+ interface MutationFactoryOptions<TMutationKey extends readonly unknown[], TVariables, TData, TOnMutateResult = unknown> {
20736
+ /** Cache key identifying the mutation. */
20737
+ mutationKey: TMutationKey;
20738
+ /** Runs the mutation for the given variables. */
20739
+ mutationFn: (variables: TVariables) => Promise<TData>;
20740
+ /** Optional callback invoked after the mutation succeeds. */
20741
+ onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => void;
20765
20742
  }
20766
- /** Result of {@link Token.batchBalancesOf}. */
20767
- interface BatchBalancesResult {
20768
- /** Successfully decrypted balances, keyed by token address. */
20769
- results: Map<Address, bigint>;
20770
- /** Per-token errors for tokens that failed to decrypt. */
20771
- errors: Map<Address, ZamaError>;
20743
+ //#endregion
20744
+ //#region src/query/signer-query-context.d.ts
20745
+ /** Connected-wallet context threaded into query factories to scope cache keys and gate signer-dependent queries. */
20746
+ interface SignerQueryContext {
20747
+ /** Connected wallet account; queries that need a signer stay disabled until it is set. */
20748
+ walletAccount?: WalletAccount;
20772
20749
  }
20750
+ //#endregion
20751
+ //#region src/query/query-keys.d.ts
20773
20752
  /**
20774
- * High-level interface for an ERC-7984 confidential token.
20775
- * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind
20776
- * familiar ERC-20-like methods.
20777
- *
20778
- * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —
20779
- * it extends `Token` with wrapper-specific operations.
20753
+ * Canonical query-key namespace for `@zama-fhe/sdk/query`.
20780
20754
  *
20781
- * Decryption, credentials, caching, and event emission are handled by the
20782
- * owning {@link ZamaSDK} — this class only exposes token-scoped helpers
20783
- * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.
20755
+ * @example
20756
+ * ```ts
20757
+ * queryClient.invalidateQueries({
20758
+ * queryKey: zamaQueryKeys.confidentialBalance.token("0xToken"),
20759
+ * });
20760
+ * ```
20784
20761
  */
20785
- declare class Token {
20786
- #private;
20787
- /** The SDK instance this token operates through. */
20788
- readonly sdk: ZamaSDK;
20789
- /** Checksummed address of the confidential token contract. */
20790
- readonly address: Address;
20791
- constructor(sdk: ZamaSDK, address: Address);
20792
- /** Read the token name from the contract. */
20793
- name(): Promise<string>;
20794
- /** Read the token symbol from the contract. */
20795
- symbol(): Promise<string>;
20796
- /** Read the token decimals from the contract. */
20797
- decimals(): Promise<number>;
20798
- /**
20799
- * ERC-165 check for {@link ERC7984_INTERFACE_ID} support.
20800
- *
20801
- * @returns `true` if the contract implements the ERC-7984 confidential token interface.
20802
- */
20803
- isConfidential(): Promise<boolean>;
20804
- /**
20805
- * ERC-165 check for IERC7984ERC20Wrapper support.
20806
- *
20807
- * @returns `true` if the contract implements the ERC-7984 wrapper interface
20808
- * ({@link ERC7984_WRAPPER_INTERFACE_ID}, `0x1f1c62b2`).
20809
- */
20810
- isWrapper(): Promise<boolean>;
20811
- /**
20812
- * Decrypt and return the plaintext balance for the given owner.
20813
- * Acquires FHE credentials via a wallet signature if none are cached.
20814
- *
20815
- * @param owner - Balance owner address.
20816
- * @returns The decrypted plaintext balance as a bigint.
20817
- * @throws if FHE decryption fails. {@link DecryptionFailedError}
20818
- *
20819
- * @example
20820
- * ```ts
20821
- * const balance = await token.balanceOf("0xOwner");
20822
- * ```
20823
- */
20824
- balanceOf(owner: Address): Promise<bigint>;
20825
- /**
20826
- * Return the raw encrypted balance without decrypting.
20827
- *
20828
- * @param owner - Balance owner address.
20829
- * @returns The encrypted balance as a hex string.
20830
- *
20831
- * @example
20832
- * ```ts
20833
- * const encryptedValue = await token.confidentialBalanceOf("0xOwner");
20834
- * ```
20835
- */
20836
- confidentialBalanceOf(owner: Address): Promise<EncryptedValue>;
20837
- /**
20838
- * Decrypt the balance of a delegator using delegated decryption credentials.
20839
- * The connected signer acts as the delegatee who has been granted permission
20840
- * by the delegator to decrypt their balance.
20841
- *
20842
- * Clear values are cached in storage keyed by `(account, token, encryptedValue)`.
20843
- * Because every on-chain balance change produces a new encrypted value,
20844
- * stale cache entries are never served. Cache write failures are silently
20845
- * ignored — they do not affect the returned value.
20846
- *
20847
- * @param delegatorAddress - The address of the account that delegated decryption rights.
20848
- * @param accountAddress - The account whose on-chain balance to read. Defaults
20849
- * to the delegator address.
20850
- * @returns The decrypted plaintext balance as a bigint.
20851
- * @throws if no active delegation exists. {@link DelegationNotFoundError}
20852
- * @throws if the delegation has expired. {@link DelegationExpiredError}
20853
- * @throws if delegated decryption fails. {@link DecryptionFailedError}
20854
- *
20855
- * @example
20856
- * ```ts
20857
- * const balance = await token.decryptBalanceAs({
20858
- * delegatorAddress: "0xDelegator",
20859
- * });
20860
- * ```
20861
- */
20862
- decryptBalanceAs({ delegatorAddress, accountAddress }: {
20863
- delegatorAddress: Address;
20864
- accountAddress?: Address;
20865
- }): Promise<bigint>;
20866
- /**
20867
- * Decrypt confidential balances for multiple tokens in parallel, returning
20868
- * successes and per-token errors separately. Pre-authorizes all token
20869
- * addresses in a single wallet signature, then delegates each decrypt to
20870
- * `sdk.decryption.decryptValues`.
20871
- *
20872
- * Tokens that fail to decrypt land in `errors`; the batch keeps going.
20873
- *
20874
- * @param tokens - Array of {@link Token} instances bound to the same SDK.
20875
- * @param owner - Balance owner address.
20876
- * @returns `{ results, errors }` partitioning the per-token outcomes.
20877
- * @throws A failure that affects the whole session (rejected signature,
20878
- * misconfiguration, RPC rate limit, key unwrapping failure, revoked KMS
20879
- * context) rejects the call instead of landing in `errors`.
20880
- *
20881
- * @example
20882
- * ```ts
20883
- * const { results, errors } = await Token.batchBalancesOf(tokens, owner);
20884
- * ```
20885
- */
20886
- static batchBalancesOf(tokens: Token[], owner: Address): Promise<BatchBalancesResult>;
20887
- /**
20888
- * Batch decrypt confidential balances as a delegate across multiple tokens.
20889
- * Mirrors {@link batchBalancesOf} but uses delegated credentials.
20890
- *
20891
- * **Error handling:** If a per-token decryption fails and no `onError` callback
20892
- * is provided, errors are collected and thrown as an aggregated
20893
- * `DecryptionFailedError`. When the relayer returns no value for an encrypted value,
20894
- * a `DecryptionFailedError` is thrown for that token (never silently returns `0n`).
20895
- * Pass `onError: () => 0n` to opt into the silent zero behavior.
20896
- *
20897
- * @param tokens - Array of Token instances to decrypt balances for.
20898
- * @param options - Delegated decryption configuration.
20899
- * @returns A Map from token address to decrypted balance.
20900
- * @throws if no active delegation exists. {@link DelegationNotFoundError}
20901
- * @throws if the delegation has expired. {@link DelegationExpiredError}
20902
- * @throws if any decryption fails and no `onError` is provided. {@link DecryptionFailedError}
20903
- * @throws A failure that affects the whole session (rejected signature, RPC
20904
- * rate limit, revoked KMS context) rejects the call even when `onError` is
20905
- * provided.
20906
- *
20907
- * @example
20908
- * ```ts
20909
- * const balances = await Token.batchDecryptBalancesAs(tokens, {
20910
- * delegatorAddress: "0xDelegator",
20911
- * onError: (err, addr) => { console.error(addr, err); return 0n; },
20912
- * });
20913
- * ```
20914
- */
20915
- static batchDecryptBalancesAs(tokens: Token[], options: BatchDecryptAsOptions): Promise<Map<Address, bigint>>;
20916
- private static readBalanceHandlesBatch;
20762
+ declare const zamaQueryKeys: {
20763
+ readonly confidentialBalance: {
20764
+ readonly all: readonly ["zama.confidentialBalance"];
20765
+ readonly token: (tokenAddress: Address) => readonly ["zama.confidentialBalance", {
20766
+ readonly tokenAddress: `0x${string}`;
20767
+ }];
20768
+ readonly owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalance", {
20769
+ readonly owner?: `0x${string}` | undefined;
20770
+ readonly walletAddress: `0x${string}`;
20771
+ readonly walletChainId: number;
20772
+ readonly tokenAddress: `0x${string}`;
20773
+ } | {
20774
+ readonly owner?: `0x${string}` | undefined;
20775
+ readonly walletAddress?: undefined;
20776
+ readonly walletChainId?: undefined;
20777
+ readonly tokenAddress: `0x${string}`;
20778
+ }];
20779
+ };
20780
+ readonly confidentialBalances: {
20781
+ readonly all: readonly ["zama.confidentialBalances"];
20782
+ readonly tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalances", {
20783
+ readonly owner?: `0x${string}` | undefined;
20784
+ readonly walletAddress: `0x${string}`;
20785
+ readonly walletChainId: number;
20786
+ readonly tokenAddresses: `0x${string}`[];
20787
+ } | {
20788
+ readonly owner?: `0x${string}` | undefined;
20789
+ readonly walletAddress?: undefined;
20790
+ readonly walletChainId?: undefined;
20791
+ readonly tokenAddresses: `0x${string}`[];
20792
+ }];
20793
+ };
20794
+ readonly tokenMetadata: {
20795
+ readonly all: readonly ["zama.tokenMetadata"];
20796
+ readonly token: (tokenAddress: Address) => readonly ["zama.tokenMetadata", {
20797
+ readonly tokenAddress: `0x${string}`;
20798
+ }];
20799
+ };
20800
+ readonly isConfidential: {
20801
+ readonly all: readonly ["zama.isConfidential"];
20802
+ readonly token: (tokenAddress: Address) => readonly ["zama.isConfidential", {
20803
+ readonly tokenAddress: `0x${string}`;
20804
+ }];
20805
+ };
20806
+ readonly isWrapper: {
20807
+ readonly all: readonly ["zama.isWrapper"];
20808
+ readonly token: (tokenAddress: Address) => readonly ["zama.isWrapper", {
20809
+ readonly tokenAddress: `0x${string}`;
20810
+ }];
20811
+ };
20812
+ readonly wrapperDiscovery: {
20813
+ readonly all: readonly ["zama.wrapperDiscovery"];
20814
+ readonly token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => readonly ["zama.wrapperDiscovery", {
20815
+ readonly registryAddress?: `0x${string}` | undefined;
20816
+ readonly erc20Address?: `0x${string}` | undefined;
20817
+ readonly tokenAddress?: `0x${string}` | undefined;
20818
+ }];
20819
+ };
20820
+ readonly underlyingAllowance: {
20821
+ readonly all: readonly ["zama.underlyingAllowance"];
20822
+ readonly token: (tokenAddress: Address) => readonly ["zama.underlyingAllowance", {
20823
+ readonly tokenAddress: `0x${string}`;
20824
+ }];
20825
+ readonly scope: (tokenAddress: Address, owner?: Address) => readonly ["zama.underlyingAllowance", {
20826
+ readonly owner?: `0x${string}` | undefined;
20827
+ readonly tokenAddress: `0x${string}`;
20828
+ }];
20829
+ };
20830
+ readonly confidentialIsOperator: {
20831
+ readonly all: readonly ["zama.confidentialIsOperator"];
20832
+ readonly token: (tokenAddress?: Address) => readonly ["zama.confidentialIsOperator", {
20833
+ tokenAddress: `0x${string}`;
20834
+ } | {
20835
+ tokenAddress?: undefined;
20836
+ }];
20837
+ readonly scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => readonly ["zama.confidentialIsOperator", {
20838
+ readonly spender?: `0x${string}` | undefined;
20839
+ readonly holder?: `0x${string}` | undefined;
20840
+ readonly tokenAddress?: `0x${string}` | undefined;
20841
+ }];
20842
+ };
20843
+ readonly totalSupply: {
20844
+ readonly all: readonly ["zama.totalSupply"];
20845
+ readonly token: (tokenAddress: Address) => readonly ["zama.totalSupply", {
20846
+ readonly tokenAddress: `0x${string}`;
20847
+ }];
20848
+ };
20849
+ readonly pendingUnshield: {
20850
+ readonly all: readonly ["zama.pendingUnshield"];
20851
+ readonly token: (tokenAddress: Address) => readonly ["zama.pendingUnshield", {
20852
+ readonly tokenAddress: `0x${string}`;
20853
+ }];
20854
+ };
20855
+ readonly hasPermit: {
20856
+ readonly all: readonly ["zama.hasPermit"];
20857
+ readonly scope: (contractAddresses: Address[], walletAccount?: WalletAccount) => readonly ["zama.hasPermit", {
20858
+ readonly contractAddresses: `0x${string}`[];
20859
+ readonly walletAddress: `0x${string}`;
20860
+ readonly walletChainId: number;
20861
+ } | {
20862
+ readonly contractAddresses: `0x${string}`[];
20863
+ readonly walletAddress?: undefined;
20864
+ readonly walletChainId?: undefined;
20865
+ }];
20866
+ };
20867
+ readonly delegationStatus: {
20868
+ readonly all: readonly ["zama.delegationStatus"];
20869
+ readonly contract: (contractAddress?: Address) => readonly ["zama.delegationStatus", {
20870
+ contractAddress: `0x${string}`;
20871
+ } | {
20872
+ contractAddress?: undefined;
20873
+ }];
20874
+ readonly scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => readonly ["zama.delegationStatus", {
20875
+ readonly delegateAddress?: `0x${string}` | undefined;
20876
+ readonly delegatorAddress?: `0x${string}` | undefined;
20877
+ readonly contractAddress?: `0x${string}` | undefined;
20878
+ }];
20879
+ };
20880
+ readonly decryption: {
20881
+ readonly all: readonly ["zama.decryption"];
20882
+ readonly encryptedValue: (encryptedValue: string, contractAddress?: Address) => readonly ["zama.decryption", {
20883
+ readonly contractAddress?: `0x${string}` | undefined;
20884
+ readonly encryptedValue: string;
20885
+ }];
20886
+ readonly encryptedInputs: (encryptedInputs: readonly {
20887
+ encryptedValue: string;
20888
+ contractAddress: Address;
20889
+ }[], walletAccount?: WalletAccount) => readonly ["zama.decryption", {
20890
+ readonly encryptedInputs: {
20891
+ encryptedValue: Hex;
20892
+ contractAddress: `0x${string}`;
20893
+ }[];
20894
+ readonly walletAddress: `0x${string}`;
20895
+ readonly walletChainId: number;
20896
+ } | {
20897
+ readonly encryptedInputs: {
20898
+ encryptedValue: Hex;
20899
+ contractAddress: `0x${string}`;
20900
+ }[];
20901
+ readonly walletAddress?: undefined;
20902
+ readonly walletChainId?: undefined;
20903
+ }];
20904
+ };
20905
+ readonly wrappersRegistry: {
20906
+ readonly all: readonly ["zama.wrappersRegistry"];
20907
+ readonly chainId: () => readonly ["zama.wrappersRegistry", {
20908
+ readonly type: "chainId";
20909
+ }];
20910
+ readonly tokenPairs: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
20911
+ readonly type: "tokenPairs";
20912
+ readonly registryAddress: `0x${string}`;
20913
+ }];
20914
+ readonly confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) => readonly ["zama.wrappersRegistry", {
20915
+ readonly type: "confidentialTokenAddress";
20916
+ readonly registryAddress: `0x${string}`;
20917
+ readonly tokenAddress: `0x${string}`;
20918
+ }];
20919
+ readonly tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
20920
+ readonly type: "tokenAddress";
20921
+ readonly registryAddress: `0x${string}`;
20922
+ readonly confidentialTokenAddress: `0x${string}`;
20923
+ }];
20924
+ readonly tokenPairsLength: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
20925
+ readonly type: "tokenPairsLength";
20926
+ readonly registryAddress: `0x${string}`;
20927
+ }];
20928
+ readonly tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) => readonly ["zama.wrappersRegistry", {
20929
+ readonly type: "tokenPairsSlice";
20930
+ readonly registryAddress: `0x${string}`;
20931
+ readonly fromIndex: string;
20932
+ readonly toIndex: string;
20933
+ }];
20934
+ readonly tokenPair: (registryAddress: Address, index: string) => readonly ["zama.wrappersRegistry", {
20935
+ readonly type: "tokenPair";
20936
+ readonly registryAddress: `0x${string}`;
20937
+ readonly index: string;
20938
+ }];
20939
+ readonly isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
20940
+ readonly type: "isConfidentialTokenValid";
20941
+ readonly registryAddress: `0x${string}`;
20942
+ readonly confidentialTokenAddress: `0x${string}`;
20943
+ }];
20944
+ readonly listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) => readonly ["zama.wrappersRegistry", {
20945
+ readonly type: "listPairs";
20946
+ readonly registryAddress: `0x${string}`;
20947
+ readonly page: number;
20948
+ readonly pageSize: number;
20949
+ readonly metadata: boolean;
20950
+ }];
20951
+ };
20952
+ };
20953
+ //#endregion
20954
+ //#region src/query/invalidation.d.ts
20955
+ /** Minimal query shape read by the invalidation predicates. */
20956
+ interface QueryLike {
20957
+ /** The query's cache key. */
20958
+ queryKey: readonly unknown[];
20959
+ }
20960
+ /** Minimal filter shape accepted by the invalidation helpers, matching TanStack Query's `QueryFilters`. */
20961
+ interface QueryFilterLike {
20962
+ /** Match queries whose key starts with this prefix. */
20963
+ queryKey?: readonly unknown[];
20964
+ /** Match queries for which this returns `true`. */
20965
+ predicate?: (query: QueryLike) => boolean;
20966
+ }
20967
+ /** Minimal `QueryClient` surface used by the invalidation helpers. */
20968
+ interface QueryClientLike {
20969
+ /** Mark matching queries stale so they refetch. */
20970
+ invalidateQueries(filters: QueryFilterLike): void | Promise<void>;
20971
+ /** Remove matching queries from the cache entirely. */
20972
+ removeQueries(filters: QueryFilterLike): void;
20973
+ }
20974
+ /** Invalidates the caches affected by an unwrap: confidential balances, underlying allowance, and pending unshields. */
20975
+ declare function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void;
20976
+ /** Invalidates the caches affected by a wrap: confidential balances and underlying allowance. */
20977
+ declare function invalidateAfterWrap(queryClient: QueryClientLike, tokenAddress: Address): void;
20978
+ /** Invalidates the confidential balance queries for a token (single-token and batched). */
20979
+ declare function invalidateBalanceQueries(queryClient: QueryClientLike, tokenAddress: Address): void;
20980
+ /** Invalidates the caches affected by a shield: confidential balances and underlying allowance. */
20981
+ declare function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void;
20982
+ /** Invalidates the caches affected by an unshield request: confidential balances, underlying allowance, and pending unshields. */
20983
+ declare function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void;
20984
+ /** Invalidates the pending-unshield cache once an unshield has settled on-chain. */
20985
+ declare function invalidateAfterUnshieldSettled(queryClient: QueryClientLike, tokenAddress: Address): void;
20986
+ /** Invalidates the confidential balance caches affected by a transfer. */
20987
+ declare function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void;
20988
+ /** Invalidates the underlying-allowance cache after approving the underlying ERC-20. */
20989
+ declare function invalidateAfterApproveUnderlying(queryClient: QueryClientLike, tokenAddress: Address): void;
20990
+ /** Invalidates the operator-status cache after changing a token operator. */
20991
+ declare function invalidateAfterSetOperator(queryClient: QueryClientLike, tokenAddress: Address): void;
20992
+ /** Invalidates any wagmi `useBalance`/`readContract` balance queries so ERC-20 balances refresh. */
20993
+ declare function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void;
20994
+ /** Clears wallet-local caches (decryption, permits) and invalidates all Zama queries — call on wallet connect/disconnect so a stale entitlement can't leak across accounts. */
20995
+ declare function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void;
20996
+ //#endregion
20997
+ //#region src/query/token-metadata.d.ts
20998
+ /** ERC-20 token metadata returned by {@link tokenMetadataQueryOptions}. */
20999
+ interface TokenMetadata {
21000
+ /** Human-readable token name. */
21001
+ name: string;
21002
+ /** Token ticker symbol. */
21003
+ symbol: string;
21004
+ /** Number of decimals the token uses. */
21005
+ decimals: number;
21006
+ }
21007
+ /** Configuration for {@link tokenMetadataQueryOptions}. */
21008
+ interface TokenMetadataQueryConfig {
21009
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21010
+ query?: Record<string, unknown>;
21011
+ }
21012
+ /** Builds TanStack Query options for reading an ERC-20 token's name, symbol, and decimals. */
21013
+ declare function tokenMetadataQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: TokenMetadataQueryConfig): QueryFactoryOptions<TokenMetadata, Error, TokenMetadata, ReturnType<typeof zamaQueryKeys.tokenMetadata.token>>;
21014
+ //#endregion
21015
+ //#region src/query/is-confidential.d.ts
21016
+ /** Configuration for {@link isConfidentialQueryOptions} and {@link isWrapperQueryOptions}. */
21017
+ interface IsConfidentialQueryConfig {
21018
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21019
+ query?: Record<string, unknown>;
21020
+ }
21021
+ /** Builds TanStack Query options for reading whether a token address implements the confidential (ERC-7984) token interface. */
21022
+ declare function isConfidentialQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: IsConfidentialQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isConfidential.token>>;
21023
+ /** Builds TanStack Query options for reading whether a token address is a confidential wrapper (ERC-7984 wrapper) contract. */
21024
+ declare function isWrapperQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: IsConfidentialQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isWrapper.token>>;
21025
+ //#endregion
21026
+ //#region src/query/total-supply.d.ts
21027
+ /** Configuration for {@link totalSupplyQueryOptions}. */
21028
+ interface TotalSupplyQueryConfig {
21029
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21030
+ query?: Record<string, unknown>;
21031
+ }
21032
+ /** Builds TanStack Query options for reading a token's total supply. */
21033
+ declare function totalSupplyQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: TotalSupplyQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.totalSupply.token>>;
21034
+ //#endregion
21035
+ //#region src/wrappers-registry.d.ts
21036
+ /**
21037
+ * Default wrappers registry addresses for known chains.
21038
+ * Only includes chains where a registry is deployed (excludes Hardhat).
21039
+ *
21040
+ * @deprecated Read `registryAddress` from the chain presets instead (e.g.
21041
+ * `sepolia.registryAddress`). Will be removed in the next major version.
21042
+ */
21043
+ declare const DefaultRegistryAddresses: Record<number, Address>;
21044
+ /** Configuration for {@link WrappersRegistry}. */
21045
+ interface WrappersRegistryConfig {
21046
+ /** Read-only chain provider used for every registry lookup. */
21047
+ provider: GenericProvider;
20917
21048
  /**
20918
- * Confidential transfer. Encrypts the amount via FHE, then calls the contract.
20919
- *
20920
- * By default, the SDK validates the confidential balance before submitting.
20921
- * If a cached plaintext balance exists it is used; otherwise, if credentials
20922
- * are cached, it decrypts on the fly. Set `skipBalanceCheck: true` to bypass
20923
- * this validation (e.g. for smart wallets).
20924
- *
20925
- * @param to - Recipient address.
20926
- * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
20927
- * @param options - Optional: `skipBalanceCheck` (default `false`).
20928
- * @returns The transaction hash and mined receipt.
20929
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20930
- * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
20931
- * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
20932
- * @throws if FHE encryption fails. {@link EncryptionFailedError}
20933
- * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
21049
+ * Per-chain registry address overrides, merged on top of
21050
+ * {@link DefaultRegistryAddresses}. Use this to supply a registry
21051
+ * address for custom or local chains (e.g. Hardhat).
20934
21052
  *
20935
21053
  * @example
20936
21054
  * ```ts
20937
- * const txHash = await token.confidentialTransfer("0xRecipient", 1000n);
21055
+ * new WrappersRegistry({
21056
+ * provider,
21057
+ * registryAddresses: { [31337]: "0xYourHardhatRegistry" },
21058
+ * });
20938
21059
  * ```
20939
21060
  */
20940
- confidentialTransfer(to: Address, amount: bigint, options?: TransferOptions): Promise<TransactionResult>;
21061
+ registryAddresses?: Record<number, Address>;
20941
21062
  /**
20942
- * Operator encrypted transfer on behalf of another address.
20943
- * The caller must be an approved operator for `from`.
20944
- *
20945
- * @param from - The address to transfer from (caller must be an approved operator).
20946
- * @param to - Recipient address.
20947
- * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
20948
- * @returns The transaction hash and mined receipt.
20949
- *
20950
- * @example
20951
- * ```ts
20952
- * const txHash = await token.confidentialTransferFrom("0xFrom", "0xTo", 500n);
20953
- * ```
21063
+ * How long cached registry results remain valid, in seconds.
21064
+ * Default: `86400` (24 hours).
20954
21065
  */
20955
- confidentialTransferFrom(from: Address, to: Address, amount: bigint, callbacks?: TransferCallbacks): Promise<TransactionResult>;
21066
+ registryTTL?: number;
21067
+ }
21068
+ /** Options for {@link WrappersRegistry.listPairs}. */
21069
+ interface ListPairsOptions {
21070
+ /** Page number (1-indexed). Default: `1`. */
21071
+ page?: number;
21072
+ /** Number of items per page. Default: `100`. */
21073
+ pageSize?: number;
20956
21074
  /**
20957
- * ERC-7984 `confidentialTransferAndCall`: encrypted transfer that also invokes
20958
- * the recipient's receiver hook (`onConfidentialTransferReceived`) in a single
20959
- * transaction. The caller crafts the opaque `data` payload — the SDK does not
20960
- * encode, validate, or interpret it.
20961
- *
20962
- * Balance validation follows the same rules as {@link Token.confidentialTransfer}.
20963
- *
20964
- * @param to - Recipient address. Must implement the ERC-7984 receiver hook.
20965
- * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
20966
- * @param data - Opaque bytes forwarded to the recipient's receiver hook.
20967
- * @param options - Optional: `skipBalanceCheck` (default `false`).
20968
- * @returns The transaction hash and mined receipt.
21075
+ * When `true`, fetches on-chain metadata (name, symbol, decimals) for both
21076
+ * the ERC-20 and confidential token, plus totalSupply for the ERC-20.
21077
+ * Default: `false`.
21078
+ */
21079
+ metadata?: boolean;
21080
+ }
21081
+ /**
21082
+ * High-level interface for the on-chain token wrappers registry.
21083
+ *
21084
+ * Uses the configured {@link GenericProvider} to resolve the correct registry
21085
+ * contract address for the current chain and exposes typed read helpers for
21086
+ * every registry query. Results are cached in memory with a configurable TTL
21087
+ * (default 24 hours).
21088
+ *
21089
+ * @example
21090
+ * ```ts
21091
+ * const registry = new WrappersRegistry({ provider });
21092
+ *
21093
+ * // Paginated listing
21094
+ * const page1 = await registry.listPairs({ page: 1, pageSize: 20 });
21095
+ *
21096
+ * // Structured lookups
21097
+ * const result = await registry.getConfidentialToken(erc20Address);
21098
+ * if (result) console.log(result.confidentialTokenAddress);
21099
+ *
21100
+ * // Force refresh
21101
+ * registry.refresh();
21102
+ * ```
21103
+ */
21104
+ declare class WrappersRegistry {
21105
+ #private;
21106
+ /** Read-only chain access used for registry contract reads. */
21107
+ readonly provider: GenericProvider;
21108
+ constructor(config: WrappersRegistryConfig);
21109
+ /**
21110
+ * Synchronous lookup of the registry address for a given chain ID.
21111
+ * Returns `undefined` if no address is configured for that chain.
21112
+ */
21113
+ getAddress(chainId: number): Address | undefined;
21114
+ /**
21115
+ * Force-invalidate the in-memory cache. The next call to any read method
21116
+ * will fetch fresh data from the chain.
21117
+ */
21118
+ refresh(): void;
21119
+ /**
21120
+ * The cache TTL in milliseconds.
21121
+ * Exposed so query option factories can set a matching `staleTime`.
21122
+ */
21123
+ get ttlMs(): number;
21124
+ /**
21125
+ * Resolve the registry contract address for the current chain.
20969
21126
  *
20970
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20971
- * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
20972
- * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
20973
- * @throws if FHE encryption fails. {@link EncryptionFailedError}
20974
- * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
21127
+ * Priority: `registryAddresses[chainId]` \> built-in default.
20975
21128
  *
20976
- * @example
20977
- * ```ts
20978
- * const txHash = await token.confidentialTransferAndCall(
20979
- * "0xRecipient",
20980
- * 1000n,
20981
- * "0xabcd", // caller-encoded payload forwarded to the receiver hook
20982
- * );
20983
- * ```
21129
+ * @returns The registry contract address for the connected chain.
21130
+ * @throws if no address is configured for the chain. {@link ConfigurationError}
20984
21131
  */
20985
- confidentialTransferAndCall(to: Address, amount: bigint, data: Hex, options?: TransferOptions): Promise<TransactionResult>;
21132
+ getRegistryAddress(): Promise<Address>;
20986
21133
  /**
20987
- * ERC-7984 `confidentialTransferFromAndCall`: operator-initiated encrypted
20988
- * transfer that also invokes the recipient's receiver hook in a single
20989
- * transaction. The caller must be an approved operator for `from` and crafts
20990
- * the opaque `data` payload — the SDK does not encode or interpret it.
21134
+ * List token wrapper pairs with page-based pagination.
20991
21135
  *
20992
- * @param from - The address to transfer from (caller must be an approved operator).
20993
- * @param to - Recipient address. Must implement the ERC-7984 receiver hook.
20994
- * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
20995
- * @param data - Opaque bytes forwarded to the recipient's receiver hook.
20996
- * @param callbacks - Optional progress callbacks.
20997
- * @returns The transaction hash and mined receipt.
21136
+ * Internally maps to `getTokenConfidentialTokenPairsSlice` on-chain.
21137
+ *
21138
+ * @param options - Pagination and enrichment options.
21139
+ * @returns A {@link PaginatedResult} of pairs.
20998
21140
  *
20999
21141
  * @example
21000
21142
  * ```ts
21001
- * const txHash = await token.confidentialTransferFromAndCall(
21002
- * "0xFrom",
21003
- * "0xRecipient",
21004
- * 500n,
21005
- * "0xabcd",
21006
- * );
21143
+ * const result = await registry.listPairs({ page: 1, pageSize: 20 });
21144
+ * console.log(`${result.total} pairs, showing page ${result.page}`);
21145
+ *
21146
+ * // With on-chain metadata
21147
+ * const withMeta = await registry.listPairs({ metadata: true, pageSize: 10 });
21148
+ * for (const pair of withMeta.items) {
21149
+ * console.log(pair.underlying.symbol, "→", pair.confidential.symbol);
21150
+ * }
21007
21151
  * ```
21008
21152
  */
21009
- confidentialTransferFromAndCall(from: Address, to: Address, amount: bigint, data: Hex, callbacks?: TransferCallbacks): Promise<TransactionResult>;
21153
+ listPairs(options: ListPairsOptions & {
21154
+ metadata: true;
21155
+ }): Promise<PaginatedResult<TokenWrapperPairWithMetadata>>;
21156
+ /** Lists registered underlying/confidential token pairs; pass `{ metadata: true }` to include on-chain token metadata. */
21157
+ listPairs(options?: ListPairsOptions): Promise<PaginatedResult<TokenWrapperPair>>;
21010
21158
  /**
21011
- * Set operator approval for the confidential token.
21012
- * Defaults to 1 hour from now if `until` is not specified.
21159
+ * Look up the confidential token for a given plain ERC-20 address.
21013
21160
  *
21014
- * @param operator - The address to set as an operator.
21015
- * @param until - Optional Unix timestamp for approval expiry. Defaults to now + 1 hour.
21016
- * @returns The transaction hash and mined receipt.
21161
+ * @param tokenAddress - The plain ERC-20 token address.
21162
+ * @returns The lookup result, or `null` if the token has never been registered.
21163
+ * **Note:** revoked tokens (registered then invalidated) return a non-null result
21164
+ * with `isValid: false`. Check `result.isValid` explicitly rather than using
21165
+ * `if (result)` to guard against processing revoked tokens.
21017
21166
  *
21018
21167
  * @example
21019
21168
  * ```ts
21020
- * const txHash = await token.setOperator("0xOperator");
21169
+ * const result = await registry.getConfidentialToken(usdcAddress);
21170
+ * if (result?.isValid) {
21171
+ * console.log(result.confidentialTokenAddress);
21172
+ * }
21021
21173
  * ```
21022
21174
  */
21023
- setOperator(operator: Address, until?: number): Promise<TransactionResult>;
21175
+ getConfidentialToken(tokenAddress: Address): Promise<{
21176
+ confidentialTokenAddress: Address;
21177
+ isValid: boolean;
21178
+ } | null>;
21024
21179
  /**
21025
- * Check if a spender is an approved operator for a given holder.
21180
+ * Reverse lookup — find the plain ERC-20 for a given confidential token.
21026
21181
  *
21027
- * @param holder - The token holder address.
21028
- * @param spender - The address to check operator approval for.
21029
- * @returns `true` if the spender is an approved operator for the holder.
21182
+ * @param confidentialTokenAddress - The confidential token address.
21183
+ * @returns The lookup result, or `null` if no pair is registered.
21030
21184
  *
21031
21185
  * @example
21032
21186
  * ```ts
21033
- * if (await token.isOperator("0xHolder", "0xSpender")) {
21034
- * // spender can call transferFrom on behalf of holder
21187
+ * const result = await registry.getUnderlyingToken(cUsdcAddress);
21188
+ * if (result) {
21189
+ * console.log(result.tokenAddress, result.isValid);
21035
21190
  * }
21036
21191
  * ```
21037
21192
  */
21038
- isOperator(holder: Address, spender: Address): Promise<boolean>;
21039
- /** Verify all tokens share the same SDK instance and return it. */
21040
- private static assertSameSdk;
21041
- }
21042
- //#endregion
21043
- //#region src/token/wrapped-token.d.ts
21044
- /**
21045
- * Confidential ERC-20 wrapper (ERC-7984 ERC20Wrapper).
21046
- *
21047
- * Extends {@link Token} with wrapper-specific operations:
21048
- * - `shield` / `unshield` — convert between the underlying ERC-20 and confidential balance
21049
- * - `unwrap` / `unwrapAll` / `finalizeUnwrap` — low-level two-phase primitives
21050
- * - `underlying` / `allowance` — wrapper reads
21051
- *
21052
- * `WrappedToken.address` is the wrapper contract address itself — the wrapper
21053
- * IS the confidential token.
21054
- */
21055
- declare class WrappedToken extends Token {
21056
- #private;
21193
+ getUnderlyingToken(confidentialTokenAddress: Address): Promise<{
21194
+ tokenAddress: Address;
21195
+ isValid: boolean;
21196
+ } | null>;
21057
21197
  /**
21058
- * Read the underlying ERC-20 token address from the wrapper contract.
21198
+ * Fetch all token wrapper pairs from the registry.
21059
21199
  *
21060
- * @returns The underlying ERC-20 token address.
21200
+ * @returns All registered `TokenWrapperPair` entries.
21061
21201
  */
21062
- underlying(): Promise<Address>;
21202
+ getTokenPairs(): Promise<readonly TokenWrapperPair[]>;
21063
21203
  /**
21064
- * Check whether the underlying ERC-20 supports ERC-1363 (payable token).
21065
- * Result is cached per WrappedToken instance (negative results included):
21066
- * once we know an underlying does not support ERC-1363, subsequent shields
21067
- * go straight to the `approve` + `wrap` path without re-probing.
21204
+ * Get the total number of token wrapper pairs.
21205
+ *
21206
+ * @returns The count as a bigint.
21068
21207
  */
21069
- isPayable(): Promise<boolean>;
21208
+ getTokenPairsLength(): Promise<bigint>;
21070
21209
  /**
21071
- * Read the ERC-20 allowance granted by `owner` to this wrapper for the
21072
- * underlying token.
21210
+ * Fetch a range of token wrapper pairs (paginated by index).
21073
21211
  *
21074
- * @param owner - The owner address whose allowance to read.
21075
- * @returns The current allowance as a bigint.
21212
+ * @param fromIndex - Start index (inclusive).
21213
+ * @param toIndex - End index (exclusive).
21214
+ * @returns The slice of `TokenWrapperPair` entries.
21076
21215
  */
21077
- allowance(owner: Address): Promise<bigint>;
21216
+ getTokenPairsSlice(fromIndex: bigint, toIndex: bigint): Promise<readonly TokenWrapperPair[]>;
21078
21217
  /**
21079
- * Shield public ERC-20 tokens into confidential tokens.
21080
- *
21081
- * The execution path is decided automatically by ERC-165 introspection on
21082
- * the underlying ERC-20:
21083
- * - **`transferAndCall`** (single tx): when the underlying supports
21084
- * ERC-1363, no approval is required — the wrapper's `onTransferReceived`
21085
- * callback mints confidential tokens directly. `approvalStrategy` is
21086
- * **ignored** on this path. See {@link ShieldPath}.
21087
- * - **`approveAndWrap`** (two-tx fallback): otherwise, an `approve` is
21088
- * followed by a `wrap`. Approval is controlled by `approvalStrategy`
21089
- * (`"exact"` by default, `"max"` for unlimited, `"skip"` to opt out).
21090
- *
21091
- * The ERC-20 balance is validated before submitting (public read, no
21092
- * signing required) so the call works for all wallet types, including
21093
- * smart wallets.
21094
- *
21095
- * @param amount - The plaintext amount to shield.
21096
- * @param options - Optional: `approvalStrategy`, `to`, callbacks.
21097
- * @returns The transaction hash and mined receipt.
21098
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
21099
- * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
21100
- * @throws if the ERC-20 approval or shield transaction reverts. {@link TransactionRevertedError}
21218
+ * Fetch a single token wrapper pair by index.
21101
21219
  *
21102
- * @example
21103
- * ```ts
21104
- * const txHash = await wrappedToken.shield(1000n);
21105
- * ```
21220
+ * @param index - Zero-based pair index.
21221
+ * @returns The `TokenWrapperPair` at that index.
21106
21222
  */
21107
- shield(amount: bigint, options?: ShieldOptions): Promise<TransactionResult>;
21223
+ getTokenPair(index: bigint): Promise<TokenWrapperPair>;
21108
21224
  /**
21109
- * Wrap already-approved underlying ERC-20 into confidential tokens.
21110
- *
21111
- * Escape hatch for splitting shield across two signatures: call
21112
- * {@link approveUnderlying} first, then `wrap`. Most callers should use
21113
- * {@link shield}, which routes and orchestrates approval automatically.
21114
- *
21115
- * Validates the ERC-20 balance and the allowance granted to this wrapper
21116
- * (public reads, no signing) and fails early with a clear error.
21117
- *
21118
- * @param amount - The plaintext amount to wrap.
21119
- * @param options - Optional `to` recipient and `onWrapSubmitted` callback.
21120
- * @returns The transaction hash and mined receipt.
21121
- * @throws if reading the ERC-20 balance or allowance fails. {@link ERC20ReadFailedError}
21122
- * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
21123
- * @throws if the allowance granted to the wrapper is less than `amount`. {@link InsufficientAllowanceError}
21225
+ * Look up the confidential token address for a given plain ERC-20 token.
21124
21226
  *
21125
- * @example
21126
- * ```ts
21127
- * await wrappedToken.approveUnderlying(1000n);
21128
- * await wrappedToken.wrap(1000n);
21129
- * ```
21227
+ * @param tokenAddress - The plain ERC-20 token address.
21228
+ * @returns A tuple `[isValid, confidentialTokenAddress]`. `isValid` is `true` only for a
21229
+ * registered, non-revoked wrapper. The address is the zero address when no pair is registered.
21230
+ * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
21130
21231
  */
21131
- wrap(amount: bigint, options?: WrapOptions): Promise<TransactionResult>;
21232
+ getConfidentialTokenAddress(tokenAddress: Address): Promise<readonly [boolean, Address]>;
21132
21233
  /**
21133
- * Approve this wrapper contract to spend the underlying ERC-20.
21134
- * Defaults to max uint256. Resets to zero first if there's an existing
21135
- * non-zero allowance (required by tokens like USDT).
21136
- *
21137
- * @param amount - Optional approval amount. Defaults to max uint256.
21138
- * @returns The transaction hash and mined receipt.
21234
+ * Reverse lookup — find the plain ERC-20 for a given confidential token.
21139
21235
  *
21140
- * @example
21141
- * ```ts
21142
- * await wrappedToken.approveUnderlying(); // max approval
21143
- * await wrappedToken.approveUnderlying(1000n); // exact amount
21144
- * ```
21236
+ * @param confidentialTokenAddress - The confidential token address.
21237
+ * @returns A tuple `[isValid, tokenAddress]`. `isValid` is `true` only for a registered,
21238
+ * non-revoked wrapper. The address is the zero address when no pair is registered.
21239
+ * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
21145
21240
  */
21146
- approveUnderlying(amount?: bigint): Promise<TransactionResult>;
21241
+ getTokenAddress(confidentialTokenAddress: Address): Promise<readonly [boolean, Address]>;
21147
21242
  /**
21148
- * Unshield a specific amount and finalize in one call.
21149
- * Orchestrates: unshield → wait for receipt → parse event → finalize.
21150
- *
21151
- * By default, the SDK validates the confidential balance before submitting.
21152
- * Set `skipBalanceCheck: true` to bypass this validation (e.g. for smart wallets).
21153
- *
21154
- * @param amount - The plaintext amount to unshield.
21155
- * @param options - Optional: `skipBalanceCheck` (default `false`), callbacks.
21156
- * @returns The finalize transaction hash and mined receipt.
21243
+ * Check whether a confidential token is registered and valid.
21157
21244
  *
21158
- * @example
21159
- * ```ts
21160
- * const txHash = await wrappedToken.unshield(500n);
21161
- * ```
21245
+ * @param confidentialTokenAddress - The confidential token address to check.
21246
+ * @returns `true` if the token is a known valid wrapper in the registry.
21162
21247
  */
21163
- unshield(amount: bigint, options?: UnshieldOptions): Promise<TransactionResult>;
21248
+ isConfidentialTokenValid(confidentialTokenAddress: Address): Promise<boolean>;
21249
+ }
21250
+ //#endregion
21251
+ //#region src/query/wrapper-discovery.d.ts
21252
+ /** Configuration for {@link wrapperDiscoveryQueryOptions}. */
21253
+ interface WrapperDiscoveryQueryConfig {
21164
21254
  /**
21165
- * Unshield the entire balance and finalize in one call.
21166
- * Orchestrates: unshieldAll → wait for receipt → parse event → finalize.
21167
- *
21168
- * @param callbacks - Optional progress callbacks for each phase.
21169
- * @returns The finalize transaction hash and mined receipt.
21170
- * @throws if the balance is zero. {@link DecryptionFailedError}
21255
+ * Address of any confidential token you control.
21256
+ * Used to scope the query cache key and to gate whether the query
21257
+ * is enabled — it does not affect which wrapper the registry returns.
21258
+ */
21259
+ tokenAddress?: Address;
21260
+ /**
21261
+ * The ERC-20 token address to discover the confidential wrapper for.
21262
+ * The registry is resolved automatically from chain config.
21263
+ */
21264
+ erc20Address?: Address;
21265
+ /**
21266
+ * The resolved registry contract address for the current chain.
21267
+ * Included in the query key so that switching chains invalidates
21268
+ * stale cached results. Pass `undefined` when the chain ID is not
21269
+ * yet known — the query will be disabled.
21270
+ */
21271
+ registryAddress?: Address;
21272
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21273
+ query?: Record<string, unknown>;
21274
+ }
21275
+ /** Builds TanStack Query options for discovering the confidential wrapper address for a given ERC-20 token (resolves to `null` when none is registered). */
21276
+ declare function wrapperDiscoveryQueryOptions(registry: WrappersRegistry, config: WrapperDiscoveryQueryConfig): QueryFactoryOptions<Address | null, Error, Address | null, ReturnType<typeof zamaQueryKeys.wrapperDiscovery.token>>;
21277
+ //#endregion
21278
+ //#region src/query/underlying-allowance.d.ts
21279
+ /** Configuration for {@link underlyingAllowanceQueryOptions}. */
21280
+ interface UnderlyingAllowanceQueryConfig {
21281
+ /** Owner whose underlying-token allowance to read; the query stays disabled until provided. */
21282
+ owner?: Address;
21283
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21284
+ query?: Record<string, unknown>;
21285
+ }
21286
+ /** Builds TanStack Query options for reading the ERC-20 allowance the owner has granted a confidential wrapper on its underlying token. */
21287
+ declare function underlyingAllowanceQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config: UnderlyingAllowanceQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.underlyingAllowance.scope>>;
21288
+ //#endregion
21289
+ //#region src/query/pending-unshield.d.ts
21290
+ /** Configuration for {@link pendingUnshieldQueryOptions}. */
21291
+ interface PendingUnshieldQueryConfig {
21292
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21293
+ query?: Record<string, unknown>;
21294
+ }
21295
+ /**
21296
+ * Query options for reading the unwrap tx hash of an unshield that was
21297
+ * interrupted between its two phases (returns `null` if none is pending).
21298
+ *
21299
+ * Backed by {@link ZamaSDK} storage via `WrappedToken.getPendingUnshield()`.
21300
+ * `staleTime: 0` so the value reflects storage on mount; the unshield/unwrap
21301
+ * mutations also invalidate this key on success.
21302
+ */
21303
+ declare function pendingUnshieldQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: PendingUnshieldQueryConfig): QueryFactoryOptions<Hex | null, Error, Hex | null, ReturnType<typeof zamaQueryKeys.pendingUnshield.token>>;
21304
+ //#endregion
21305
+ //#region src/query/confidential-is-operator.d.ts
21306
+ /** Configuration for {@link confidentialIsOperatorQueryOptions}. */
21307
+ interface ConfidentialIsOperatorQueryConfig {
21308
+ /** Token holder whose operator authorization to check; the query stays disabled until provided. */
21309
+ holder?: Address;
21310
+ /** Spender address to check for operator authorization; the query stays disabled until provided. */
21311
+ spender?: Address;
21312
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21313
+ query?: Record<string, unknown>;
21314
+ }
21315
+ /** Builds TanStack Query options for reading whether a spender is an authorized operator of a holder on a confidential token. */
21316
+ declare function confidentialIsOperatorQueryOptions(sdk: ZamaSDK, tokenAddress: Address | undefined, config: ConfidentialIsOperatorQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.confidentialIsOperator.scope>>;
21317
+ //#endregion
21318
+ //#region src/token/token.d.ts
21319
+ /** Options for {@link Token.batchDecryptBalancesAs}. */
21320
+ interface BatchDecryptAsOptions {
21321
+ /** The address of the account that delegated decryption rights. */
21322
+ delegatorAddress: Address;
21323
+ /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */
21324
+ encryptedValues?: EncryptedValue[];
21325
+ /**
21326
+ * The account whose on-chain balance to read. Defaults to the delegator
21327
+ * address, which is the common case (the delegator grants permission to
21328
+ * decrypt their own balance). Only set this when the account differs
21329
+ * from the delegator.
21171
21330
  *
21172
- * @example
21173
- * ```ts
21174
- * const txHash = await wrappedToken.unshieldAll();
21175
- * ```
21331
+ * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.
21176
21332
  */
21177
- unshieldAll(callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
21333
+ accountAddress?: Address;
21334
+ /** Maximum number of concurrent decrypt calls. Default: 10. */
21335
+ maxConcurrency?: number;
21336
+ /** Called when decryption fails for a single token. Return a fallback bigint. */
21337
+ onError?: (error: Error, address: Address) => bigint;
21338
+ }
21339
+ /** Result of {@link Token.batchBalancesOf}. */
21340
+ interface BatchBalancesResult {
21341
+ /** Successfully decrypted balances, keyed by token address. */
21342
+ results: Map<Address, bigint>;
21343
+ /** Per-token errors for tokens that failed to decrypt. */
21344
+ errors: Map<Address, ZamaError>;
21345
+ }
21346
+ /**
21347
+ * High-level interface for an ERC-7984 confidential token.
21348
+ * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind
21349
+ * familiar ERC-20-like methods.
21350
+ *
21351
+ * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —
21352
+ * it extends `Token` with wrapper-specific operations.
21353
+ *
21354
+ * Decryption, credentials, caching, and event emission are handled by the
21355
+ * owning {@link ZamaSDK} — this class only exposes token-scoped helpers
21356
+ * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.
21357
+ */
21358
+ declare class Token {
21359
+ #private;
21360
+ /** The SDK instance this token operates through. */
21361
+ readonly sdk: ZamaSDK;
21362
+ /** Checksummed address of the confidential token contract. */
21363
+ readonly address: Address;
21364
+ constructor(sdk: ZamaSDK, address: Address);
21365
+ /** Read the token name from the contract. */
21366
+ name(): Promise<string>;
21367
+ /** Read the token symbol from the contract. */
21368
+ symbol(): Promise<string>;
21369
+ /** Read the token decimals from the contract. */
21370
+ decimals(): Promise<number>;
21178
21371
  /**
21179
- * Resume an in-progress unshield from an existing unwrap tx hash.
21180
- * Useful when the user already submitted the unwrap but the finalize step
21181
- * was interrupted (e.g. page reload, network error).
21182
- *
21183
- * @param unwrapTxHash - The transaction hash of the previously submitted unwrap.
21184
- * @param callbacks - Optional progress callbacks.
21185
- * @returns The finalize transaction hash and mined receipt.
21186
- * @throws if the unwrap request was already finalized on-chain; the persisted
21187
- * pending-unshield state is cleared first. {@link UnshieldAlreadyFinalizedError}
21372
+ * ERC-165 check for {@link ERC7984_INTERFACE_ID} support.
21188
21373
  *
21189
- * @example
21190
- * ```ts
21191
- * const txHash = await wrappedToken.resumeUnshield(previousUnwrapTxHash);
21192
- * ```
21374
+ * @returns `true` if the contract implements the ERC-7984 confidential token interface.
21193
21375
  */
21194
- resumeUnshield(unwrapTxHash: Hex, callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
21376
+ isConfidential(): Promise<boolean>;
21195
21377
  /**
21196
- * Return the unwrap tx hash of an unshield that was interrupted between its
21197
- * two phases, or `null` if none is pending for this wrapper.
21198
- *
21199
- * The SDK persists this automatically when {@link unshield}/{@link unshieldAll}
21200
- * submit phase 1, and clears it once phase 2 finalizes. Use the returned hash
21201
- * to surface a "resume" affordance, then pass it to {@link resumeUnshield}.
21202
- * Resuming is intentionally caller-driven — auto-resuming on load would fire a
21203
- * wallet transaction unprompted.
21204
- *
21205
- * The pointer is verified on-chain before it is reported: if the unwrap
21206
- * request was already finalized (e.g. the tab closed before the SDK could
21207
- * clear storage), the stale pointer is cleared and `null` is returned. When
21208
- * the verification read fails, the pointer is returned unverified: a
21209
- * network error never deletes recovery state.
21210
- *
21211
- * @returns The pending unwrap tx hash, or `null`.
21378
+ * ERC-165 check for IERC7984ERC20Wrapper support.
21212
21379
  *
21213
- * @example
21214
- * ```ts
21215
- * const unwrapTxHash = await wrappedToken.getPendingUnshield();
21216
- * if (unwrapTxHash) await wrappedToken.resumeUnshield(unwrapTxHash);
21217
- * ```
21380
+ * @returns `true` if the contract implements the ERC-7984 wrapper interface
21381
+ * ({@link ERC7984_WRAPPER_INTERFACE_ID}, `0x1f1c62b2`).
21218
21382
  */
21219
- getPendingUnshield(): Promise<Hex | null>;
21383
+ isWrapper(): Promise<boolean>;
21220
21384
  /**
21221
- * Request an unwrap for a specific amount. Encrypts the amount first.
21222
- * Pass the result's `unwrapRequestId` to {@link finalizeUnwrap} once the
21223
- * request is processed on-chain.
21385
+ * Decrypt and return the plaintext balance for the given owner.
21386
+ * Acquires FHE credentials via a wallet signature if none are cached.
21224
21387
  *
21225
- * @param amount - The plaintext amount to unwrap (encrypted automatically).
21226
- * @returns The tx hash, mined receipt, and the `unwrapRequestId` for `finalizeUnwrap`.
21388
+ * @param owner - Balance owner address.
21389
+ * @returns The decrypted plaintext balance as a bigint.
21390
+ * @throws if FHE decryption fails. {@link DecryptionFailedError}
21227
21391
  *
21228
21392
  * @example
21229
21393
  * ```ts
21230
- * const result = await wrappedToken.unwrap(500n);
21231
- * await wrappedToken.finalizeUnwrap(result.unwrapRequestId);
21394
+ * const balance = await token.balanceOf("0xOwner");
21232
21395
  * ```
21233
21396
  */
21234
- unwrap(amount: bigint): Promise<UnwrapResult>;
21397
+ balanceOf(owner: Address): Promise<bigint>;
21235
21398
  /**
21236
- * Request an unwrap for the entire confidential balance.
21237
- * Uses the on-chain encrypted balance directly (no encryption needed).
21238
- * Throws if the balance is zero.
21399
+ * Return the raw encrypted balance without decrypting.
21239
21400
  *
21240
- * @returns The tx hash, mined receipt, and the `unwrapRequestId` for `finalizeUnwrap`.
21241
- * @throws if the balance is zero. {@link DecryptionFailedError}
21401
+ * @param owner - Balance owner address.
21402
+ * @returns The encrypted balance as a hex string.
21242
21403
  *
21243
21404
  * @example
21244
21405
  * ```ts
21245
- * const result = await wrappedToken.unwrapAll();
21246
- * await wrappedToken.finalizeUnwrap(result.unwrapRequestId);
21406
+ * const encryptedValue = await token.confidentialBalanceOf("0xOwner");
21247
21407
  * ```
21248
21408
  */
21249
- unwrapAll(): Promise<UnwrapResult>;
21409
+ confidentialBalanceOf(owner: Address): Promise<EncryptedValue>;
21250
21410
  /**
21251
- * Complete an unwrap by fetching the public decryption proof and finalizing.
21252
- * Call this once the unwrap request has been processed on-chain.
21411
+ * Decrypt the balance of a delegator using delegated decryption credentials.
21412
+ * The connected signer acts as the delegatee who has been granted permission
21413
+ * by the delegator to decrypt their balance.
21253
21414
  *
21254
- * @param unwrapRequestId - The `unwrapRequestId` from an {@link UnwrapResult}
21255
- * (`result.unwrapRequestId`) returned by {@link unwrap} / {@link unwrapAll},
21256
- * or one decoded from an `UnwrapRequested` event (e.g. when finalizing
21257
- * across sessions).
21258
- * @returns The transaction hash and mined receipt.
21415
+ * Clear values are cached in storage keyed by `(account, token, encryptedValue)`.
21416
+ * Because every on-chain balance change produces a new encrypted value,
21417
+ * stale cache entries are never served. Cache write failures are silently
21418
+ * ignored — they do not affect the returned value.
21259
21419
  *
21260
- * @example
21261
- * ```ts
21262
- * const { unwrapRequestId } = await wrappedToken.unwrap(500n);
21263
- * await wrappedToken.finalizeUnwrap(unwrapRequestId);
21264
- * ```
21265
- */
21266
- finalizeUnwrap(unwrapRequestId: EncryptedValue): Promise<TransactionResult>;
21267
- }
21268
- //#endregion
21269
- //#region src/wrappers-registry.d.ts
21270
- /**
21271
- * Default wrappers registry addresses for known chains.
21272
- * Only includes chains where a registry is deployed (excludes Hardhat).
21273
- *
21274
- * @deprecated Read `registryAddress` from the chain presets instead (e.g.
21275
- * `sepolia.registryAddress`). Will be removed in the next major version.
21276
- */
21277
- declare const DefaultRegistryAddresses: Record<number, Address>;
21278
- /** Configuration for {@link WrappersRegistry}. */
21279
- interface WrappersRegistryConfig {
21280
- /** Read-only chain provider used for every registry lookup. */
21281
- provider: GenericProvider;
21282
- /**
21283
- * Per-chain registry address overrides, merged on top of
21284
- * {@link DefaultRegistryAddresses}. Use this to supply a registry
21285
- * address for custom or local chains (e.g. Hardhat).
21420
+ * @param delegatorAddress - The address of the account that delegated decryption rights.
21421
+ * @param accountAddress - The account whose on-chain balance to read. Defaults
21422
+ * to the delegator address.
21423
+ * @returns The decrypted plaintext balance as a bigint.
21424
+ * @throws if no active delegation exists. {@link DelegationNotFoundError}
21425
+ * @throws if the delegation has expired. {@link DelegationExpiredError}
21426
+ * @throws if delegated decryption fails. {@link DecryptionFailedError}
21286
21427
  *
21287
21428
  * @example
21288
21429
  * ```ts
21289
- * new WrappersRegistry({
21290
- * provider,
21291
- * registryAddresses: { [31337]: "0xYourHardhatRegistry" },
21430
+ * const balance = await token.decryptBalanceAs({
21431
+ * delegatorAddress: "0xDelegator",
21292
21432
  * });
21293
21433
  * ```
21294
21434
  */
21295
- registryAddresses?: Record<number, Address>;
21296
- /**
21297
- * How long cached registry results remain valid, in seconds.
21298
- * Default: `86400` (24 hours).
21299
- */
21300
- registryTTL?: number;
21301
- }
21302
- /** Options for {@link WrappersRegistry.listPairs}. */
21303
- interface ListPairsOptions {
21304
- /** Page number (1-indexed). Default: `1`. */
21305
- page?: number;
21306
- /** Number of items per page. Default: `100`. */
21307
- pageSize?: number;
21308
- /**
21309
- * When `true`, fetches on-chain metadata (name, symbol, decimals) for both
21310
- * the ERC-20 and confidential token, plus totalSupply for the ERC-20.
21311
- * Default: `false`.
21312
- */
21313
- metadata?: boolean;
21314
- }
21315
- /**
21316
- * High-level interface for the on-chain token wrappers registry.
21317
- *
21318
- * Uses the configured {@link GenericProvider} to resolve the correct registry
21319
- * contract address for the current chain and exposes typed read helpers for
21320
- * every registry query. Results are cached in memory with a configurable TTL
21321
- * (default 24 hours).
21322
- *
21323
- * @example
21324
- * ```ts
21325
- * const registry = new WrappersRegistry({ provider });
21326
- *
21327
- * // Paginated listing
21328
- * const page1 = await registry.listPairs({ page: 1, pageSize: 20 });
21329
- *
21330
- * // Structured lookups
21331
- * const result = await registry.getConfidentialToken(erc20Address);
21332
- * if (result) console.log(result.confidentialTokenAddress);
21333
- *
21334
- * // Force refresh
21335
- * registry.refresh();
21336
- * ```
21337
- */
21338
- declare class WrappersRegistry {
21339
- #private;
21340
- /** Read-only chain access used for registry contract reads. */
21341
- readonly provider: GenericProvider;
21342
- constructor(config: WrappersRegistryConfig);
21343
- /**
21344
- * Synchronous lookup of the registry address for a given chain ID.
21345
- * Returns `undefined` if no address is configured for that chain.
21346
- */
21347
- getAddress(chainId: number): Address | undefined;
21348
- /**
21349
- * Force-invalidate the in-memory cache. The next call to any read method
21350
- * will fetch fresh data from the chain.
21351
- */
21352
- refresh(): void;
21353
- /**
21354
- * The cache TTL in milliseconds.
21355
- * Exposed so query option factories can set a matching `staleTime`.
21356
- */
21357
- get ttlMs(): number;
21435
+ decryptBalanceAs({ delegatorAddress, accountAddress }: {
21436
+ delegatorAddress: Address;
21437
+ accountAddress?: Address;
21438
+ }): Promise<bigint>;
21358
21439
  /**
21359
- * Resolve the registry contract address for the current chain.
21440
+ * Decrypt confidential balances for multiple tokens in parallel, returning
21441
+ * successes and per-token errors separately. Pre-authorizes all token
21442
+ * addresses in a single wallet signature, then delegates each decrypt to
21443
+ * `sdk.decryption.decryptValues`.
21360
21444
  *
21361
- * Priority: `registryAddresses[chainId]` \> built-in default.
21445
+ * Tokens that fail to decrypt land in `errors`; the batch keeps going.
21446
+ *
21447
+ * @param tokens - Array of {@link Token} instances bound to the same SDK.
21448
+ * @param owner - Balance owner address.
21449
+ * @returns `{ results, errors }` partitioning the per-token outcomes.
21450
+ * @throws A failure that affects the whole session (rejected signature,
21451
+ * misconfiguration, RPC rate limit, key unwrapping failure, revoked KMS
21452
+ * context) rejects the call instead of landing in `errors`.
21362
21453
  *
21363
- * @returns The registry contract address for the connected chain.
21364
- * @throws if no address is configured for the chain. {@link ConfigurationError}
21454
+ * @example
21455
+ * ```ts
21456
+ * const { results, errors } = await Token.batchBalancesOf(tokens, owner);
21457
+ * ```
21365
21458
  */
21366
- getRegistryAddress(): Promise<Address>;
21459
+ static batchBalancesOf(tokens: Token[], owner: Address): Promise<BatchBalancesResult>;
21367
21460
  /**
21368
- * List token wrapper pairs with page-based pagination.
21461
+ * Batch decrypt confidential balances as a delegate across multiple tokens.
21462
+ * Mirrors {@link batchBalancesOf} but uses delegated credentials.
21369
21463
  *
21370
- * Internally maps to `getTokenConfidentialTokenPairsSlice` on-chain.
21464
+ * **Error handling:** If a per-token decryption fails and no `onError` callback
21465
+ * is provided, errors are collected and thrown as an aggregated
21466
+ * `DecryptionFailedError`. When the relayer returns no value for an encrypted value,
21467
+ * a `DecryptionFailedError` is thrown for that token (never silently returns `0n`).
21468
+ * Pass `onError: () => 0n` to opt into the silent zero behavior.
21371
21469
  *
21372
- * @param options - Pagination and enrichment options.
21373
- * @returns A {@link PaginatedResult} of pairs.
21470
+ * @param tokens - Array of Token instances to decrypt balances for.
21471
+ * @param options - Delegated decryption configuration.
21472
+ * @returns A Map from token address to decrypted balance.
21473
+ * @throws if no active delegation exists. {@link DelegationNotFoundError}
21474
+ * @throws if the delegation has expired. {@link DelegationExpiredError}
21475
+ * @throws if any decryption fails and no `onError` is provided. {@link DecryptionFailedError}
21476
+ * @throws A failure that affects the whole session (rejected signature, RPC
21477
+ * rate limit, revoked KMS context) rejects the call even when `onError` is
21478
+ * provided.
21374
21479
  *
21375
21480
  * @example
21376
21481
  * ```ts
21377
- * const result = await registry.listPairs({ page: 1, pageSize: 20 });
21378
- * console.log(`${result.total} pairs, showing page ${result.page}`);
21379
- *
21380
- * // With on-chain metadata
21381
- * const withMeta = await registry.listPairs({ metadata: true, pageSize: 10 });
21382
- * for (const pair of withMeta.items) {
21383
- * console.log(pair.underlying.symbol, "→", pair.confidential.symbol);
21384
- * }
21482
+ * const balances = await Token.batchDecryptBalancesAs(tokens, {
21483
+ * delegatorAddress: "0xDelegator",
21484
+ * onError: (err, addr) => { console.error(addr, err); return 0n; },
21485
+ * });
21385
21486
  * ```
21386
21487
  */
21387
- listPairs(options: ListPairsOptions & {
21388
- metadata: true;
21389
- }): Promise<PaginatedResult<TokenWrapperPairWithMetadata>>;
21390
- /** Lists registered underlying/confidential token pairs; pass `{ metadata: true }` to include on-chain token metadata. */
21391
- listPairs(options?: ListPairsOptions): Promise<PaginatedResult<TokenWrapperPair>>;
21488
+ static batchDecryptBalancesAs(tokens: Token[], options: BatchDecryptAsOptions): Promise<Map<Address, bigint>>;
21489
+ private static readBalanceHandlesBatch;
21392
21490
  /**
21393
- * Look up the confidential token for a given plain ERC-20 address.
21491
+ * Confidential transfer. Encrypts the amount via FHE, then calls the contract.
21394
21492
  *
21395
- * @param tokenAddress - The plain ERC-20 token address.
21396
- * @returns The lookup result, or `null` if the token has never been registered.
21397
- * **Note:** revoked tokens (registered then invalidated) return a non-null result
21398
- * with `isValid: false`. Check `result.isValid` explicitly rather than using
21399
- * `if (result)` to guard against processing revoked tokens.
21493
+ * By default, the SDK validates the confidential balance before submitting.
21494
+ * If a cached plaintext balance exists it is used; otherwise, if credentials
21495
+ * are cached, it decrypts on the fly. Set `skipBalanceCheck: true` to bypass
21496
+ * this validation (e.g. for smart wallets).
21497
+ *
21498
+ * @param to - Recipient address.
21499
+ * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
21500
+ * @param options - Optional: `skipBalanceCheck` (default `false`).
21501
+ * @returns The transaction hash and mined receipt.
21502
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
21503
+ * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
21504
+ * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
21505
+ * @throws if FHE encryption fails. {@link EncryptionFailedError}
21506
+ * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
21400
21507
  *
21401
21508
  * @example
21402
21509
  * ```ts
21403
- * const result = await registry.getConfidentialToken(usdcAddress);
21404
- * if (result?.isValid) {
21405
- * console.log(result.confidentialTokenAddress);
21406
- * }
21510
+ * const txHash = await token.confidentialTransfer("0xRecipient", 1000n);
21407
21511
  * ```
21408
21512
  */
21409
- getConfidentialToken(tokenAddress: Address): Promise<{
21410
- confidentialTokenAddress: Address;
21411
- isValid: boolean;
21412
- } | null>;
21513
+ confidentialTransfer(to: Address, amount: bigint, options?: TransferOptions): Promise<TransactionResult>;
21413
21514
  /**
21414
- * Reverse lookup — find the plain ERC-20 for a given confidential token.
21515
+ * Operator encrypted transfer on behalf of another address.
21516
+ * The caller must be an approved operator for `from`.
21415
21517
  *
21416
- * @param confidentialTokenAddress - The confidential token address.
21417
- * @returns The lookup result, or `null` if no pair is registered.
21518
+ * @param from - The address to transfer from (caller must be an approved operator).
21519
+ * @param to - Recipient address.
21520
+ * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
21521
+ * @returns The transaction hash and mined receipt.
21418
21522
  *
21419
21523
  * @example
21420
21524
  * ```ts
21421
- * const result = await registry.getUnderlyingToken(cUsdcAddress);
21422
- * if (result) {
21423
- * console.log(result.tokenAddress, result.isValid);
21424
- * }
21525
+ * const txHash = await token.confidentialTransferFrom("0xFrom", "0xTo", 500n);
21425
21526
  * ```
21426
21527
  */
21427
- getUnderlyingToken(confidentialTokenAddress: Address): Promise<{
21428
- tokenAddress: Address;
21429
- isValid: boolean;
21430
- } | null>;
21528
+ confidentialTransferFrom(from: Address, to: Address, amount: bigint, callbacks?: TransferCallbacks): Promise<TransactionResult>;
21431
21529
  /**
21432
- * Fetch all token wrapper pairs from the registry.
21530
+ * ERC-7984 `confidentialTransferAndCall`: encrypted transfer that also invokes
21531
+ * the recipient's receiver hook (`onConfidentialTransferReceived`) in a single
21532
+ * transaction. The caller crafts the opaque `data` payload — the SDK does not
21533
+ * encode, validate, or interpret it.
21433
21534
  *
21434
- * @returns All registered `TokenWrapperPair` entries.
21435
- */
21436
- getTokenPairs(): Promise<readonly TokenWrapperPair[]>;
21437
- /**
21438
- * Get the total number of token wrapper pairs.
21535
+ * Balance validation follows the same rules as {@link Token.confidentialTransfer}.
21439
21536
  *
21440
- * @returns The count as a bigint.
21441
- */
21442
- getTokenPairsLength(): Promise<bigint>;
21443
- /**
21444
- * Fetch a range of token wrapper pairs (paginated by index).
21537
+ * @param to - Recipient address. Must implement the ERC-7984 receiver hook.
21538
+ * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
21539
+ * @param data - Opaque bytes forwarded to the recipient's receiver hook.
21540
+ * @param options - Optional: `skipBalanceCheck` (default `false`).
21541
+ * @returns The transaction hash and mined receipt.
21445
21542
  *
21446
- * @param fromIndex - Start index (inclusive).
21447
- * @param toIndex - End index (exclusive).
21448
- * @returns The slice of `TokenWrapperPair` entries.
21449
- */
21450
- getTokenPairsSlice(fromIndex: bigint, toIndex: bigint): Promise<readonly TokenWrapperPair[]>;
21451
- /**
21452
- * Fetch a single token wrapper pair by index.
21543
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
21544
+ * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
21545
+ * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
21546
+ * @throws if FHE encryption fails. {@link EncryptionFailedError}
21547
+ * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
21453
21548
  *
21454
- * @param index - Zero-based pair index.
21455
- * @returns The `TokenWrapperPair` at that index.
21549
+ * @example
21550
+ * ```ts
21551
+ * const txHash = await token.confidentialTransferAndCall(
21552
+ * "0xRecipient",
21553
+ * 1000n,
21554
+ * "0xabcd", // caller-encoded payload forwarded to the receiver hook
21555
+ * );
21556
+ * ```
21456
21557
  */
21457
- getTokenPair(index: bigint): Promise<TokenWrapperPair>;
21558
+ confidentialTransferAndCall(to: Address, amount: bigint, data: Hex, options?: TransferOptions): Promise<TransactionResult>;
21458
21559
  /**
21459
- * Look up the confidential token address for a given plain ERC-20 token.
21560
+ * ERC-7984 `confidentialTransferFromAndCall`: operator-initiated encrypted
21561
+ * transfer that also invokes the recipient's receiver hook in a single
21562
+ * transaction. The caller must be an approved operator for `from` and crafts
21563
+ * the opaque `data` payload — the SDK does not encode or interpret it.
21460
21564
  *
21461
- * @param tokenAddress - The plain ERC-20 token address.
21462
- * @returns A tuple `[isValid, confidentialTokenAddress]`. `isValid` is `true` only for a
21463
- * registered, non-revoked wrapper. The address is the zero address when no pair is registered.
21464
- * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
21565
+ * @param from - The address to transfer from (caller must be an approved operator).
21566
+ * @param to - Recipient address. Must implement the ERC-7984 receiver hook.
21567
+ * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
21568
+ * @param data - Opaque bytes forwarded to the recipient's receiver hook.
21569
+ * @param callbacks - Optional progress callbacks.
21570
+ * @returns The transaction hash and mined receipt.
21571
+ *
21572
+ * @example
21573
+ * ```ts
21574
+ * const txHash = await token.confidentialTransferFromAndCall(
21575
+ * "0xFrom",
21576
+ * "0xRecipient",
21577
+ * 500n,
21578
+ * "0xabcd",
21579
+ * );
21580
+ * ```
21465
21581
  */
21466
- getConfidentialTokenAddress(tokenAddress: Address): Promise<readonly [boolean, Address]>;
21582
+ confidentialTransferFromAndCall(from: Address, to: Address, amount: bigint, data: Hex, callbacks?: TransferCallbacks): Promise<TransactionResult>;
21467
21583
  /**
21468
- * Reverse lookup — find the plain ERC-20 for a given confidential token.
21584
+ * Set operator approval for the confidential token.
21585
+ * Defaults to 1 hour from now if `until` is not specified.
21469
21586
  *
21470
- * @param confidentialTokenAddress - The confidential token address.
21471
- * @returns A tuple `[isValid, tokenAddress]`. `isValid` is `true` only for a registered,
21472
- * non-revoked wrapper. The address is the zero address when no pair is registered.
21473
- * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
21587
+ * @param operator - The address to set as an operator.
21588
+ * @param until - Optional Unix timestamp for approval expiry. Defaults to now + 1 hour.
21589
+ * @returns The transaction hash and mined receipt.
21590
+ *
21591
+ * @example
21592
+ * ```ts
21593
+ * const txHash = await token.setOperator("0xOperator");
21594
+ * ```
21474
21595
  */
21475
- getTokenAddress(confidentialTokenAddress: Address): Promise<readonly [boolean, Address]>;
21596
+ setOperator(operator: Address, until?: number): Promise<TransactionResult>;
21476
21597
  /**
21477
- * Check whether a confidential token is registered and valid.
21598
+ * Check if a spender is an approved operator for a given holder.
21478
21599
  *
21479
- * @param confidentialTokenAddress - The confidential token address to check.
21480
- * @returns `true` if the token is a known valid wrapper in the registry.
21600
+ * @param holder - The token holder address.
21601
+ * @param spender - The address to check operator approval for.
21602
+ * @returns `true` if the spender is an approved operator for the holder.
21603
+ *
21604
+ * @example
21605
+ * ```ts
21606
+ * if (await token.isOperator("0xHolder", "0xSpender")) {
21607
+ * // spender can call transferFrom on behalf of holder
21608
+ * }
21609
+ * ```
21481
21610
  */
21482
- isConfidentialTokenValid(confidentialTokenAddress: Address): Promise<boolean>;
21611
+ isOperator(holder: Address, spender: Address): Promise<boolean>;
21612
+ /** Verify all tokens share the same SDK instance and return it. */
21613
+ private static assertSameSdk;
21483
21614
  }
21484
21615
  //#endregion
21485
- //#region src/zama-sdk.d.ts
21486
- /** Instance-level options that are deliberately not part of the shareable config object. */
21487
- interface ZamaSDKOptions {
21488
- /**
21489
- * Encrypts the transport key pair's private half at rest. Headless environments only
21490
- * (CLI tools, servers, agents); the constructor rejects it in browser contexts. Supply
21491
- * at least 32 random bytes, or a string of at least 64 characters, from a CSPRNG or
21492
- * secrets manager. The SDK copies a Uint8Array secret and zeroizes its own copy after
21493
- * key import; it never touches your buffer, so zeroize yours after construction.
21494
- * The SDK never persists or exposes this value. Omit for the default:
21495
- * plaintext at rest, security delegated to the storage backend.
21496
- */
21497
- transportKeyPairDerivationSecret?: string | Uint8Array;
21498
- }
21616
+ //#region src/token/wrapped-token.d.ts
21499
21617
  /**
21500
- * ZamaSDK — composes a RelayerSDK with contract abstraction.
21618
+ * Confidential ERC-20 wrapper (ERC-7984 ERC20Wrapper).
21501
21619
  *
21502
- * Exposes domain namespaces for permits, delegations, decryption, offline
21503
- * signing, and tokens, plus an unchanged registry, a top-level `encrypt`, and
21504
- * lifecycle methods. Internal `*Service` classes do the work; the namespace
21505
- * classes own SDK-level guards (chain alignment, signer requirement, event
21506
- * emission).
21620
+ * Extends {@link Token} with wrapper-specific operations:
21621
+ * - `shield` / `unshield` — convert between the underlying ERC-20 and confidential balance
21622
+ * - `unwrap` / `unwrapAll` / `finalizeUnwrap` — low-level two-phase primitives
21623
+ * - `underlying` / `allowance` — wrapper reads
21624
+ *
21625
+ * `WrappedToken.address` is the wrapper contract address itself — the wrapper
21626
+ * IS the confidential token.
21507
21627
  */
21508
- declare class ZamaSDK {
21628
+ declare class WrappedToken extends Token {
21509
21629
  #private;
21510
- /** Read-only chain access used for all contract reads. */
21511
- readonly provider: GenericProvider;
21512
- /** Wallet signer used for write operations, or `undefined` when the SDK is read-only. */
21513
- readonly signer: GenericSigner | undefined;
21514
- /** Storage for cached permits and transport key pairs. */
21515
- readonly storage: GenericStorage;
21516
21630
  /**
21517
- * A {@link WrappersRegistry} instance auto-configured for the current chain.
21518
- * Uses built-in defaults from chain configs, and the SDK's `registryTTL` if configured.
21631
+ * Read the underlying ERC-20 token address from the wrapper contract.
21632
+ *
21633
+ * @returns The underlying ERC-20 token address.
21634
+ */
21635
+ underlying(): Promise<Address>;
21636
+ /**
21637
+ * Check whether the underlying ERC-20 supports ERC-1363 (payable token).
21638
+ * Result is cached per WrappedToken instance (negative results included):
21639
+ * once we know an underlying does not support ERC-1363, subsequent shields
21640
+ * go straight to the `approve` + `wrap` path without re-probing.
21641
+ */
21642
+ isPayable(): Promise<boolean>;
21643
+ /**
21644
+ * Read the ERC-20 allowance granted by `owner` to this wrapper for the
21645
+ * underlying token.
21646
+ *
21647
+ * @param owner - The owner address whose allowance to read.
21648
+ * @returns The current allowance as a bigint.
21519
21649
  */
21520
- readonly registry: WrappersRegistry;
21521
- /** Permit and keypair management. */
21522
- readonly permits: Permits;
21523
- /** On-chain decryption-delegation management. */
21524
- readonly delegations: Delegations;
21525
- /** FHE decryption (user, delegated user, public). */
21526
- readonly decryption: Decryption;
21527
- /** Offline-signing pipeline: `prepare` builds an unsigned tx the caller signs and broadcasts out-of-process — for HSM, policy-engine, and cross-process custody workflows. */
21528
- readonly offline: Offline;
21529
- constructor(config: ZamaConfig, options?: ZamaSDKOptions);
21650
+ allowance(owner: Address): Promise<bigint>;
21530
21651
  /**
21531
- * The single-chain relayer backend for the **currently active** chain.
21652
+ * Shield public ERC-20 tokens into confidential tokens.
21653
+ *
21654
+ * The execution path is decided automatically by ERC-165 introspection on
21655
+ * the underlying ERC-20:
21656
+ * - **`transferAndCall`** (single tx): when the underlying supports
21657
+ * ERC-1363, no approval is required — the wrapper's `onTransferReceived`
21658
+ * callback mints confidential tokens directly. `approvalStrategy` is
21659
+ * **ignored** on this path. See {@link ShieldPath}.
21660
+ * - **`approveAndWrap`** (two-tx fallback): otherwise, an `approve` is
21661
+ * followed by a `wrap`. Approval is controlled by `approvalStrategy`
21662
+ * (`"exact"` by default, `"max"` for unlimited, `"skip"` to opt out).
21663
+ *
21664
+ * The ERC-20 balance is validated before submitting (public read, no
21665
+ * signing required) so the call works for all wallet types, including
21666
+ * smart wallets.
21667
+ *
21668
+ * @param amount - The plaintext amount to shield.
21669
+ * @param options - Optional: `approvalStrategy`, `to`, callbacks.
21670
+ * @returns The transaction hash and mined receipt.
21671
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
21672
+ * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
21673
+ * @throws if the ERC-20 approval or shield transaction reverts. {@link TransactionRevertedError}
21674
+ *
21675
+ * @example
21676
+ * ```ts
21677
+ * const txHash = await wrappedToken.shield(1000n);
21678
+ * ```
21532
21679
  */
21533
- get relayer(): RelayerSDK;
21680
+ shield(amount: bigint, options?: ShieldOptions): Promise<TransactionResult>;
21534
21681
  /**
21535
- * Create a {@link WrappersRegistry} instance bound to this SDK's provider.
21536
- * Inherits the registry addresses derived from the SDK's chain configs, so
21537
- * the result is consistent with {@link ZamaSDK.registry}.
21682
+ * Wrap already-approved underlying ERC-20 into confidential tokens.
21538
21683
  *
21539
- * @param registryAddresses - Optional per-chain overrides for this registry instance.
21540
- * @returns A {@link WrappersRegistry} instance.
21684
+ * Escape hatch for splitting shield across two signatures: call
21685
+ * {@link approveUnderlying} first, then `wrap`. Most callers should use
21686
+ * {@link shield}, which routes and orchestrates approval automatically.
21687
+ *
21688
+ * Validates the ERC-20 balance and the allowance granted to this wrapper
21689
+ * (public reads, no signing) and fails early with a clear error.
21690
+ *
21691
+ * @param amount - The plaintext amount to wrap.
21692
+ * @param options - Optional `to` recipient and `onWrapSubmitted` callback.
21693
+ * @returns The transaction hash and mined receipt.
21694
+ * @throws if reading the ERC-20 balance or allowance fails. {@link ERC20ReadFailedError}
21695
+ * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
21696
+ * @throws if the allowance granted to the wrapper is less than `amount`. {@link InsufficientAllowanceError}
21541
21697
  *
21542
21698
  * @example
21543
21699
  * ```ts
21544
- * // Addresses resolved from the SDK's chain configs
21545
- * const registry = sdk.createWrappersRegistry();
21700
+ * await wrappedToken.approveUnderlying(1000n);
21701
+ * await wrappedToken.wrap(1000n);
21702
+ * ```
21703
+ */
21704
+ wrap(amount: bigint, options?: WrapOptions): Promise<TransactionResult>;
21705
+ /**
21706
+ * Approve this wrapper contract to spend the underlying ERC-20.
21707
+ * Defaults to max uint256. Resets to zero first if there's an existing
21708
+ * non-zero allowance (required by tokens like USDT).
21546
21709
  *
21547
- * // Hardhat or custom chain — override per chain for this registry instance
21548
- * const registry = sdk.createWrappersRegistry({ [31337]: "0xYourRegistry" });
21710
+ * @param amount - Optional approval amount. Defaults to max uint256.
21711
+ * @returns The transaction hash and mined receipt.
21549
21712
  *
21550
- * const pairs = await registry.getTokenPairs();
21713
+ * @example
21714
+ * ```ts
21715
+ * await wrappedToken.approveUnderlying(); // max approval
21716
+ * await wrappedToken.approveUnderlying(1000n); // exact amount
21551
21717
  * ```
21552
21718
  */
21553
- createWrappersRegistry(registryAddresses?: Record<number, Address>): WrappersRegistry;
21719
+ approveUnderlying(amount?: bigint): Promise<TransactionResult>;
21554
21720
  /**
21555
- * Encrypt one or more plaintext values into FHE ciphertexts.
21721
+ * Unshield a specific amount and finalize in one call.
21722
+ * Orchestrates: unshield → wait for receipt → parse event → finalize.
21556
21723
  *
21557
- * @param params - Typed FHE inputs, the target contract address, and the user address.
21558
- * @returns External encrypted values and the input proof for on-chain submission.
21559
- * @throws if FHE encryption fails. {@link EncryptionFailedError}
21724
+ * By default, the SDK validates the confidential balance before submitting.
21725
+ * Set `skipBalanceCheck: true` to bypass this validation (e.g. for smart wallets).
21726
+ *
21727
+ * @param amount - The plaintext amount to unshield.
21728
+ * @param options - Optional: `skipBalanceCheck` (default `false`), callbacks.
21729
+ * @returns The finalize transaction hash and mined receipt.
21560
21730
  *
21561
21731
  * @example
21562
21732
  * ```ts
21563
- * const { encryptedValues, inputProof } = await sdk.encrypt({
21564
- * values: [{ value: 1000n, type: "euint64" }],
21565
- * contractAddress: "0xToken",
21566
- * userAddress: "0xUser",
21567
- * });
21733
+ * const txHash = await wrappedToken.unshield(500n);
21568
21734
  * ```
21569
21735
  */
21570
- encrypt(params: EncryptParams, options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<EncryptResult>;
21736
+ unshield(amount: bigint, options?: UnshieldOptions): Promise<TransactionResult>;
21571
21737
  /**
21572
- * Create a high-level ERC-20-style interface for an ERC-7984 confidential token.
21573
- * Supports balance queries, transfers, operator approvals, and decryption.
21738
+ * Unshield the entire balance and finalize in one call.
21739
+ * Orchestrates: unshieldAll → wait for receipt → parse event → finalize.
21574
21740
  *
21575
- * For ERC-7984 wrappers (shield/unshield/allowance), use {@link createWrappedToken} instead.
21741
+ * @param callbacks - Optional progress callbacks for each phase.
21742
+ * @returns The finalize transaction hash and mined receipt.
21743
+ * @throws if the balance is zero. {@link DecryptionFailedError}
21576
21744
  *
21577
- * @param address - The confidential token contract address.
21578
- * @returns A {@link Token} instance bound to this SDK.
21745
+ * @example
21746
+ * ```ts
21747
+ * const txHash = await wrappedToken.unshieldAll();
21748
+ * ```
21749
+ */
21750
+ unshieldAll(callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
21751
+ /**
21752
+ * Resume an in-progress unshield from an existing unwrap tx hash.
21753
+ * Useful when the user already submitted the unwrap but the finalize step
21754
+ * was interrupted (e.g. page reload, network error).
21755
+ *
21756
+ * @param unwrapTxHash - The transaction hash of the previously submitted unwrap.
21757
+ * @param callbacks - Optional progress callbacks.
21758
+ * @returns The finalize transaction hash and mined receipt.
21759
+ * @throws if the unwrap request was already finalized on-chain; the persisted
21760
+ * pending-unshield state is cleared first. {@link UnshieldAlreadyFinalizedError}
21579
21761
  *
21580
21762
  * @example
21581
21763
  * ```ts
21582
- * const token = sdk.createToken(cUSDT);
21583
- * const balance = await token.balanceOf(userAddress);
21764
+ * const txHash = await wrappedToken.resumeUnshield(previousUnwrapTxHash);
21584
21765
  * ```
21585
21766
  */
21586
- createToken(address: Address): Token;
21767
+ resumeUnshield(unwrapTxHash: Hex, callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
21587
21768
  /**
21588
- * Create a high-level interface for an ERC-7984 wrapper token.
21589
- * Extends {@link Token} with shield/unshield/allowance/finalize-unwrap operations.
21769
+ * Return the unwrap tx hash of an unshield that was interrupted between its
21770
+ * two phases, or `null` if none is pending for this wrapper.
21590
21771
  *
21591
- * @param address - The wrapper token contract address.
21592
- * @returns A {@link WrappedToken} instance bound to this SDK.
21772
+ * The SDK persists this automatically when {@link unshield}/{@link unshieldAll}
21773
+ * submit phase 1, and clears it once phase 2 finalizes. Use the returned hash
21774
+ * to surface a "resume" affordance, then pass it to {@link resumeUnshield}.
21775
+ * Resuming is intentionally caller-driven — auto-resuming on load would fire a
21776
+ * wallet transaction unprompted.
21777
+ *
21778
+ * The pointer is verified on-chain before it is reported: if the unwrap
21779
+ * request was already finalized (e.g. the tab closed before the SDK could
21780
+ * clear storage), the stale pointer is cleared and `null` is returned. When
21781
+ * the verification read fails, the pointer is returned unverified: a
21782
+ * network error never deletes recovery state.
21783
+ *
21784
+ * @returns The pending unwrap tx hash, or `null`.
21593
21785
  *
21594
21786
  * @example
21595
21787
  * ```ts
21596
- * const wrapped = sdk.createWrappedToken(wUSDT);
21597
- * await wrapped.shield(1_000_000n);
21788
+ * const unwrapTxHash = await wrappedToken.getPendingUnshield();
21789
+ * if (unwrapTxHash) await wrappedToken.resumeUnshield(unwrapTxHash);
21598
21790
  * ```
21599
21791
  */
21600
- createWrappedToken(address: Address): WrappedToken;
21792
+ getPendingUnshield(): Promise<Hex | null>;
21601
21793
  /**
21602
- * Release the SDK-owned resources: signer lifecycle subscriptions and the
21603
- * relayer backend's resources, an encrypt worker included. Call this when the
21604
- * SDK instance is being replaced (e.g. React provider unmount or a Strict Mode
21605
- * remount). Work already in flight runs to completion, and the instance stays
21606
- * usable: the next encryption spawns a fresh worker.
21794
+ * Request an unwrap for a specific amount. Encrypts the amount first.
21795
+ * Pass the result's `unwrapRequestId` to {@link finalizeUnwrap} once the
21796
+ * request is processed on-chain.
21797
+ *
21798
+ * @param amount - The plaintext amount to unwrap (encrypted automatically).
21799
+ * @returns The tx hash, mined receipt, and the `unwrapRequestId` for `finalizeUnwrap`.
21800
+ *
21801
+ * @example
21802
+ * ```ts
21803
+ * const result = await wrappedToken.unwrap(500n);
21804
+ * await wrappedToken.finalizeUnwrap(result.unwrapRequestId);
21805
+ * ```
21607
21806
  */
21608
- dispose(): void;
21807
+ unwrap(amount: bigint): Promise<UnwrapResult>;
21609
21808
  /**
21610
- * {@link dispose} plus the signer's own disposal. Call this when the SDK is no
21611
- * longer needed (e.g. on shutdown). Work already in flight runs to completion.
21809
+ * Request an unwrap for the entire confidential balance.
21810
+ * Uses the on-chain encrypted balance directly (no encryption needed).
21811
+ * Throws if the balance is zero.
21812
+ *
21813
+ * @returns The tx hash, mined receipt, and the `unwrapRequestId` for `finalizeUnwrap`.
21814
+ * @throws if the balance is zero. {@link DecryptionFailedError}
21815
+ *
21816
+ * @example
21817
+ * ```ts
21818
+ * const result = await wrappedToken.unwrapAll();
21819
+ * await wrappedToken.finalizeUnwrap(result.unwrapRequestId);
21820
+ * ```
21612
21821
  */
21613
- terminate(): void;
21822
+ unwrapAll(): Promise<UnwrapResult>;
21614
21823
  /**
21615
- * Implements the TC39 Explicit Resource Management protocol.
21616
- * Calls {@link terminate} when the `using` binding goes out of scope,
21617
- * unsubscribing signer events and releasing the relayer's resources.
21824
+ * Complete an unwrap by fetching the public decryption proof and finalizing.
21825
+ * Call this once the unwrap request has been processed on-chain.
21826
+ *
21827
+ * @param unwrapRequestId - The `unwrapRequestId` from an {@link UnwrapResult}
21828
+ * (`result.unwrapRequestId`) returned by {@link unwrap} / {@link unwrapAll},
21829
+ * or one decoded from an `UnwrapRequested` event (e.g. when finalizing
21830
+ * across sessions).
21831
+ * @returns The transaction hash and mined receipt.
21618
21832
  *
21619
21833
  * @example
21620
21834
  * ```ts
21621
- * {
21622
- * using sdk = new ZamaSDK({ relayer, provider, signer, storage });
21623
- * await sdk.permits.grantPermit([cUSDT]);
21624
- * const balance = await sdk.createToken(cUSDT).balanceOf(userAddress);
21625
- * } // sdk.terminate() called automatically here
21835
+ * const { unwrapRequestId } = await wrappedToken.unwrap(500n);
21836
+ * await wrappedToken.finalizeUnwrap(unwrapRequestId);
21626
21837
  * ```
21627
21838
  */
21628
- [Symbol.dispose](): void;
21839
+ finalizeUnwrap(unwrapRequestId: EncryptedValue): Promise<TransactionResult>;
21840
+ }
21841
+ //#endregion
21842
+ //#region src/query/confidential-balance.d.ts
21843
+ /** Configuration for {@link confidentialBalanceQueryOptions}. */
21844
+ interface ConfidentialBalanceQueryConfig {
21845
+ /** Address of the confidential token to read the balance of. */
21846
+ tokenAddress: Address;
21847
+ /** Account whose confidential balance to read; the query stays disabled until provided. */
21848
+ account?: Address;
21849
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21850
+ query?: Record<string, unknown>;
21851
+ }
21852
+ /** Query options for a single confidential token balance. Auto-gated on `account`. */
21853
+ declare function confidentialBalanceQueryOptions(token: Token, config: ConfidentialBalanceQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.confidentialBalance.owner>>;
21854
+ //#endregion
21855
+ //#region src/query/confidential-balances.d.ts
21856
+ /** Configuration for {@link confidentialBalancesQueryOptions}. */
21857
+ interface ConfidentialBalancesQueryConfig {
21858
+ /** Account whose confidential balances to read; the query stays disabled until provided. */
21859
+ account?: Address;
21860
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21861
+ query?: Record<string, unknown>;
21862
+ }
21863
+ /** Builds TanStack Query options for reading the confidential balances of several tokens for one account in a single batch. */
21864
+ declare function confidentialBalancesQueryOptions(tokens: Token[], config?: ConfidentialBalancesQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<BatchBalancesResult, Error, BatchBalancesResult, ReturnType<typeof zamaQueryKeys.confidentialBalances.tokens>>;
21865
+ //#endregion
21866
+ //#region src/query/wrappers-registry.d.ts
21867
+ /** Base configuration shared by the wrappers-registry query option factories. */
21868
+ interface WrappersRegistryQueryConfig {
21869
+ /** Registry contract address for the current chain; used as a query key discriminator. */
21870
+ registryAddress: Address | undefined;
21871
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21872
+ query?: Record<string, unknown>;
21873
+ }
21874
+ /** Builds TanStack Query options for reading all token wrapper pairs registered in the wrappers registry. */
21875
+ declare function tokenPairsQueryOptions(sdk: ZamaSDK, config: WrappersRegistryQueryConfig): QueryFactoryOptions<readonly TokenWrapperPair[], Error, readonly TokenWrapperPair[], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairs>>;
21876
+ /** Configuration for {@link confidentialTokenAddressQueryOptions}. */
21877
+ interface ConfidentialTokenAddressQueryConfig extends WrappersRegistryQueryConfig {
21878
+ /** Underlying ERC-20 token address whose confidential counterpart to look up. */
21879
+ tokenAddress?: Address;
21880
+ }
21881
+ /** Builds TanStack Query options for reading the confidential token address registered for a given underlying ERC-20 token. */
21882
+ declare function confidentialTokenAddressQueryOptions(sdk: ZamaSDK, config: ConfidentialTokenAddressQueryConfig): QueryFactoryOptions<readonly [boolean, Address], Error, readonly [boolean, Address], ReturnType<typeof zamaQueryKeys.wrappersRegistry.confidentialTokenAddress>>;
21883
+ /** Configuration for {@link tokenAddressQueryOptions}. */
21884
+ interface TokenAddressQueryConfig extends WrappersRegistryQueryConfig {
21885
+ /** Confidential token address whose underlying ERC-20 counterpart to look up. */
21886
+ confidentialTokenAddress?: Address;
21887
+ }
21888
+ /** Builds TanStack Query options for reading the underlying ERC-20 token address registered for a given confidential token. */
21889
+ declare function tokenAddressQueryOptions(sdk: ZamaSDK, config: TokenAddressQueryConfig): QueryFactoryOptions<readonly [boolean, Address], Error, readonly [boolean, Address], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenAddress>>;
21890
+ /** Builds TanStack Query options for reading the total number of token wrapper pairs in the registry. */
21891
+ declare function tokenPairsLengthQueryOptions(sdk: ZamaSDK, config: WrappersRegistryQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsLength>>;
21892
+ /** Configuration for {@link tokenPairsSliceQueryOptions}. */
21893
+ interface TokenPairsSliceQueryConfig extends WrappersRegistryQueryConfig {
21894
+ /** Zero-based index of the first pair in the slice (inclusive). */
21895
+ fromIndex?: bigint;
21896
+ /** Index bounding the end of the slice. */
21897
+ toIndex?: bigint;
21898
+ }
21899
+ /** Builds TanStack Query options for reading a contiguous slice of the registry's token wrapper pairs. */
21900
+ declare function tokenPairsSliceQueryOptions(sdk: ZamaSDK, config: TokenPairsSliceQueryConfig): QueryFactoryOptions<readonly TokenWrapperPair[], Error, readonly TokenWrapperPair[], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsSlice>>;
21901
+ /** Configuration for {@link tokenPairQueryOptions}. */
21902
+ interface TokenPairQueryConfig extends WrappersRegistryQueryConfig {
21903
+ /** Zero-based index of the token wrapper pair to read. */
21904
+ index?: bigint;
21905
+ }
21906
+ /** Builds TanStack Query options for reading a single token wrapper pair by its index in the registry. */
21907
+ declare function tokenPairQueryOptions(sdk: ZamaSDK, config: TokenPairQueryConfig): QueryFactoryOptions<TokenWrapperPair, Error, TokenWrapperPair, ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPair>>;
21908
+ /** Configuration for {@link isConfidentialTokenValidQueryOptions}. */
21909
+ interface IsConfidentialTokenValidQueryConfig extends WrappersRegistryQueryConfig {
21910
+ /** Confidential token address to validate against the registry. */
21911
+ confidentialTokenAddress?: Address;
21912
+ }
21913
+ /** Builds TanStack Query options for checking whether a confidential token is registered and valid in the registry. */
21914
+ declare function isConfidentialTokenValidQueryOptions(sdk: ZamaSDK, config: IsConfidentialTokenValidQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.wrappersRegistry.isConfidentialTokenValid>>;
21915
+ /** Configuration for {@link listPairsQueryOptions}. */
21916
+ interface ListPairsQueryConfig {
21917
+ /**
21918
+ * The registry address for this chain — used as a query key discriminator.
21919
+ * The registry instance already knows how to resolve the address for the
21920
+ * current chain; this field just keeps the TanStack Query cache isolated
21921
+ * per registry contract.
21922
+ */
21923
+ registryAddress: Address | undefined;
21924
+ /** 1-based page number to fetch; defaults to `1`. */
21925
+ page?: number;
21926
+ /** Number of pairs per page; defaults to `100`. */
21927
+ pageSize?: number;
21928
+ /** When `true`, resolve each pair's on-chain metadata; defaults to `false`. */
21929
+ metadata?: boolean;
21930
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
21931
+ query?: Record<string, unknown>;
21932
+ }
21933
+ /**
21934
+ * Query options for paginated listing of token wrapper pairs.
21935
+ *
21936
+ * Accepts a {@link WrappersRegistry} instance rather than a raw provider so that the
21937
+ * class-level TTL cache is shared across multiple `queryFn` executions. Pass
21938
+ * `sdk.registry` (the ZamaSDK lazy singleton) to ensure a single shared cache.
21939
+ */
21940
+ declare function listPairsQueryOptions(registry: WrappersRegistry, config: ListPairsQueryConfig): QueryFactoryOptions<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>, Error, PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>, ReturnType<typeof zamaQueryKeys.wrappersRegistry.listPairs>>;
21941
+ //#endregion
21942
+ //#region src/query/shield.d.ts
21943
+ /** Variables for {@link shieldMutationOptions}. */
21944
+ interface ShieldParams extends ShieldOptions {
21945
+ /** Amount of the public ERC-20 to shield, in the token's base units. */
21946
+ amount: bigint;
21947
+ }
21948
+ /** Builds TanStack Query mutation options for {@link WrappedToken.shield | shielding} a public ERC-20 into its confidential form. @see {@link ShieldParams} */
21949
+ declare function shieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.shield", Address], ShieldParams, TransactionResult>;
21950
+ //#endregion
21951
+ //#region src/query/transfer.d.ts
21952
+ /** Variables for {@link confidentialTransferMutationOptions}. */
21953
+ interface ConfidentialTransferParams extends TransferOptions {
21954
+ /** Recipient address. */
21955
+ to: Address;
21956
+ /** Amount of tokens to transfer, in the token's base units. */
21957
+ amount: bigint;
21958
+ }
21959
+ /** Builds TanStack Query mutation options for {@link Token.confidentialTransfer | transferring} confidential tokens. @see {@link ConfidentialTransferParams} */
21960
+ declare function confidentialTransferMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransfer", Address], ConfidentialTransferParams, TransactionResult>;
21961
+ //#endregion
21962
+ //#region src/query/transfer-and-call.d.ts
21963
+ /** Variables for {@link confidentialTransferAndCallMutationOptions}. */
21964
+ interface ConfidentialTransferAndCallParams extends TransferOptions {
21965
+ /** Recipient address. */
21966
+ to: Address;
21967
+ /** Amount of tokens to transfer, in the token's base units. */
21968
+ amount: bigint;
21969
+ /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */
21970
+ data: Hex;
21971
+ }
21972
+ /** Builds TanStack Query mutation options for {@link Token.confidentialTransferAndCall | transferring} confidential tokens and invoking the recipient's receiver hook. @see {@link ConfidentialTransferAndCallParams} */
21973
+ declare function confidentialTransferAndCallMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferAndCall", Address], ConfidentialTransferAndCallParams, TransactionResult>;
21974
+ //#endregion
21975
+ //#region src/query/transfer-from.d.ts
21976
+ /** Variables for {@link confidentialTransferFromMutationOptions}. */
21977
+ interface ConfidentialTransferFromParams {
21978
+ /** Address to transfer from. */
21979
+ from: Address;
21980
+ /** Recipient address. */
21981
+ to: Address;
21982
+ /** Amount of tokens to transfer, in the token's base units. */
21983
+ amount: bigint;
21984
+ /** Optional progress callbacks for the multi-step transfer flow. */
21985
+ callbacks?: TransferCallbacks;
21986
+ }
21987
+ /** Builds TanStack Query mutation options for {@link Token.confidentialTransferFrom | transferring} confidential tokens from another account (operator flow). @see {@link ConfidentialTransferFromParams} */
21988
+ declare function confidentialTransferFromMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferFrom", Address], ConfidentialTransferFromParams, TransactionResult>;
21989
+ //#endregion
21990
+ //#region src/query/transfer-from-and-call.d.ts
21991
+ /** Variables for {@link confidentialTransferFromAndCallMutationOptions}. */
21992
+ interface ConfidentialTransferFromAndCallParams {
21993
+ /** Address to transfer from. */
21994
+ from: Address;
21995
+ /** Recipient address. */
21996
+ to: Address;
21997
+ /** Amount of tokens to transfer, in the token's base units. */
21998
+ amount: bigint;
21999
+ /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */
22000
+ data: Hex;
22001
+ /** Optional progress callbacks for the multi-step transfer flow. */
22002
+ callbacks?: TransferCallbacks;
22003
+ }
22004
+ /** Builds TanStack Query mutation options for {@link Token.confidentialTransferFromAndCall | transferring} confidential tokens from another account and invoking the recipient's receiver hook. @see {@link ConfidentialTransferFromAndCallParams} */
22005
+ declare function confidentialTransferFromAndCallMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferFromAndCall", Address], ConfidentialTransferFromAndCallParams, TransactionResult>;
22006
+ //#endregion
22007
+ //#region src/query/set-operator.d.ts
22008
+ /** Variables for {@link confidentialSetOperatorMutationOptions}. */
22009
+ interface ConfidentialSetOperatorParams {
22010
+ /** Operator address to authorize. */
22011
+ operator: Address;
22012
+ /** Unix timestamp (seconds) when the operator authorization expires; defaults to one hour from now. */
22013
+ until?: number;
22014
+ }
22015
+ /** Builds TanStack Query mutation options for {@link Token.setOperator | authorizing} an operator on a confidential token. @see {@link ConfidentialSetOperatorParams} */
22016
+ declare function confidentialSetOperatorMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialSetOperator", Address], ConfidentialSetOperatorParams, TransactionResult>;
22017
+ //#endregion
22018
+ //#region src/query/approve-underlying.d.ts
22019
+ /** Variables for {@link approveUnderlyingMutationOptions}. */
22020
+ interface ApproveUnderlyingParams {
22021
+ /** Amount of the underlying ERC-20 to approve, in its base units; omit for a max approval. */
22022
+ amount?: bigint;
22023
+ }
22024
+ /** Builds TanStack Query mutation options for {@link WrappedToken.approveUnderlying | approving} the wrapper to spend the underlying ERC-20. @see {@link ApproveUnderlyingParams} */
22025
+ declare function approveUnderlyingMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.approveUnderlying", Address], ApproveUnderlyingParams, TransactionResult>;
22026
+ //#endregion
22027
+ //#region src/query/unshield.d.ts
22028
+ /** Variables for {@link unshieldMutationOptions}. */
22029
+ interface UnshieldParams extends UnshieldOptions {
22030
+ /** Amount of tokens to unshield, in the token's base units. */
22031
+ amount: bigint;
22032
+ }
22033
+ /** Builds TanStack Query mutation options for {@link WrappedToken.unshield | unshielding} a confidential token back into its public ERC-20. @see {@link UnshieldParams} */
22034
+ declare function unshieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unshield", Address], UnshieldParams, TransactionResult>;
22035
+ //#endregion
22036
+ //#region src/query/unshield-all.d.ts
22037
+ /** Variables for {@link unshieldAllMutationOptions}. */
22038
+ interface UnshieldAllParams extends UnshieldCallbacks {}
22039
+ /** Builds TanStack Query mutation options for {@link WrappedToken.unshieldAll | unshielding} the entire confidential balance back into the public ERC-20. @see {@link UnshieldAllParams} */
22040
+ declare function unshieldAllMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unshieldAll", Address], UnshieldAllParams | void, TransactionResult>;
22041
+ //#endregion
22042
+ //#region src/query/resume-unshield.d.ts
22043
+ /** Variables for {@link resumeUnshieldMutationOptions}. */
22044
+ interface ResumeUnshieldParams extends UnshieldCallbacks {
22045
+ /** Hash of the earlier unwrap request transaction to resume from. */
22046
+ unwrapTxHash: Hex;
21629
22047
  }
22048
+ /** Builds TanStack Query mutation options for {@link WrappedToken.resumeUnshield | resuming} an interrupted unshield from its unwrap request transaction. @see {@link ResumeUnshieldParams} */
22049
+ declare function resumeUnshieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.resumeUnshield", Address], ResumeUnshieldParams, TransactionResult>;
21630
22050
  //#endregion
21631
- //#region src/query/factory-types.d.ts
21632
- /**
21633
- * TanStack Query options object returned by the SDK's `*QueryOptions` factories:
21634
- * `QueryObserverOptions` with `queryKey` and `queryFn` required and the
21635
- * cache-internal keys (`queryHash`, `queryKeyHashFn`, `throwOnError`) removed.
21636
- */
21637
- type QueryFactoryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey"> & Required<Pick<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey">>, "queryFn" | "queryHash" | "queryKeyHashFn" | "throwOnError"> & {
21638
- queryFn: Exclude<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>["queryFn"], typeof skipToken | undefined>;
21639
- };
21640
- /** TanStack Query mutation options object returned by the SDK's `*MutationOptions` factories. */
21641
- interface MutationFactoryOptions<TMutationKey extends readonly unknown[], TVariables, TData, TOnMutateResult = unknown> {
21642
- /** Cache key identifying the mutation. */
21643
- mutationKey: TMutationKey;
21644
- /** Runs the mutation for the given variables. */
21645
- mutationFn: (variables: TVariables) => Promise<TData>;
21646
- /** Optional callback invoked after the mutation succeeds. */
21647
- onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => void;
22051
+ //#region src/query/unwrap.d.ts
22052
+ /** Variables for {@link unwrapMutationOptions}. */
22053
+ interface UnwrapParams {
22054
+ /** Amount of tokens to unwrap, in the token's base units. */
22055
+ amount: bigint;
21648
22056
  }
22057
+ /** Builds TanStack Query mutation options for {@link WrappedToken.unwrap | unwrapping} a confidential token (request phase of the two-phase unwrap). @see {@link UnwrapParams} */
22058
+ declare function unwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unwrap", Address], UnwrapParams, UnwrapResult>;
21649
22059
  //#endregion
21650
- //#region src/query/query-keys.d.ts
21651
- /**
21652
- * Canonical query-key namespace for `@zama-fhe/sdk/query`.
21653
- *
21654
- * @example
21655
- * ```ts
21656
- * queryClient.invalidateQueries({
21657
- * queryKey: zamaQueryKeys.confidentialBalance.token("0xToken"),
21658
- * });
21659
- * ```
21660
- */
21661
- declare const zamaQueryKeys: {
21662
- readonly confidentialBalance: {
21663
- readonly all: readonly ["zama.confidentialBalance"];
21664
- readonly token: (tokenAddress: Address) => readonly ["zama.confidentialBalance", {
21665
- readonly tokenAddress: `0x${string}`;
21666
- }];
21667
- readonly owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalance", {
21668
- readonly owner?: `0x${string}` | undefined;
21669
- readonly walletAddress: `0x${string}`;
21670
- readonly walletChainId: number;
21671
- readonly tokenAddress: `0x${string}`;
21672
- } | {
21673
- readonly owner?: `0x${string}` | undefined;
21674
- readonly walletAddress?: undefined;
21675
- readonly walletChainId?: undefined;
21676
- readonly tokenAddress: `0x${string}`;
21677
- }];
21678
- };
21679
- readonly confidentialBalances: {
21680
- readonly all: readonly ["zama.confidentialBalances"];
21681
- readonly tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalances", {
21682
- readonly owner?: `0x${string}` | undefined;
21683
- readonly walletAddress: `0x${string}`;
21684
- readonly walletChainId: number;
21685
- readonly tokenAddresses: `0x${string}`[];
21686
- } | {
21687
- readonly owner?: `0x${string}` | undefined;
21688
- readonly walletAddress?: undefined;
21689
- readonly walletChainId?: undefined;
21690
- readonly tokenAddresses: `0x${string}`[];
21691
- }];
21692
- };
21693
- readonly tokenMetadata: {
21694
- readonly all: readonly ["zama.tokenMetadata"];
21695
- readonly token: (tokenAddress: Address) => readonly ["zama.tokenMetadata", {
21696
- readonly tokenAddress: `0x${string}`;
21697
- }];
21698
- };
21699
- readonly isConfidential: {
21700
- readonly all: readonly ["zama.isConfidential"];
21701
- readonly token: (tokenAddress: Address) => readonly ["zama.isConfidential", {
21702
- readonly tokenAddress: `0x${string}`;
21703
- }];
21704
- };
21705
- readonly isWrapper: {
21706
- readonly all: readonly ["zama.isWrapper"];
21707
- readonly token: (tokenAddress: Address) => readonly ["zama.isWrapper", {
21708
- readonly tokenAddress: `0x${string}`;
21709
- }];
21710
- };
21711
- readonly wrapperDiscovery: {
21712
- readonly all: readonly ["zama.wrapperDiscovery"];
21713
- readonly token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => readonly ["zama.wrapperDiscovery", {
21714
- readonly registryAddress?: `0x${string}` | undefined;
21715
- readonly erc20Address?: `0x${string}` | undefined;
21716
- readonly tokenAddress?: `0x${string}` | undefined;
21717
- }];
21718
- };
21719
- readonly underlyingAllowance: {
21720
- readonly all: readonly ["zama.underlyingAllowance"];
21721
- readonly token: (tokenAddress: Address) => readonly ["zama.underlyingAllowance", {
21722
- readonly tokenAddress: `0x${string}`;
21723
- }];
21724
- readonly scope: (tokenAddress: Address, owner?: Address) => readonly ["zama.underlyingAllowance", {
21725
- readonly owner?: `0x${string}` | undefined;
21726
- readonly tokenAddress: `0x${string}`;
21727
- }];
21728
- };
21729
- readonly confidentialIsOperator: {
21730
- readonly all: readonly ["zama.confidentialIsOperator"];
21731
- readonly token: (tokenAddress?: Address) => readonly ["zama.confidentialIsOperator", {
21732
- tokenAddress: `0x${string}`;
21733
- } | {
21734
- tokenAddress?: undefined;
21735
- }];
21736
- readonly scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => readonly ["zama.confidentialIsOperator", {
21737
- readonly spender?: `0x${string}` | undefined;
21738
- readonly holder?: `0x${string}` | undefined;
21739
- readonly tokenAddress?: `0x${string}` | undefined;
21740
- }];
21741
- };
21742
- readonly totalSupply: {
21743
- readonly all: readonly ["zama.totalSupply"];
21744
- readonly token: (tokenAddress: Address) => readonly ["zama.totalSupply", {
21745
- readonly tokenAddress: `0x${string}`;
21746
- }];
21747
- };
21748
- readonly pendingUnshield: {
21749
- readonly all: readonly ["zama.pendingUnshield"];
21750
- readonly token: (tokenAddress: Address) => readonly ["zama.pendingUnshield", {
21751
- readonly tokenAddress: `0x${string}`;
21752
- }];
21753
- };
21754
- readonly hasPermit: {
21755
- readonly all: readonly ["zama.hasPermit"];
21756
- readonly scope: (contractAddresses: Address[], walletAccount?: WalletAccount) => readonly ["zama.hasPermit", {
21757
- readonly contractAddresses: `0x${string}`[];
21758
- readonly walletAddress: `0x${string}`;
21759
- readonly walletChainId: number;
21760
- } | {
21761
- readonly contractAddresses: `0x${string}`[];
21762
- readonly walletAddress?: undefined;
21763
- readonly walletChainId?: undefined;
21764
- }];
21765
- };
21766
- readonly delegationStatus: {
21767
- readonly all: readonly ["zama.delegationStatus"];
21768
- readonly contract: (contractAddress?: Address) => readonly ["zama.delegationStatus", {
21769
- contractAddress: `0x${string}`;
21770
- } | {
21771
- contractAddress?: undefined;
21772
- }];
21773
- readonly scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => readonly ["zama.delegationStatus", {
21774
- readonly delegateAddress?: `0x${string}` | undefined;
21775
- readonly delegatorAddress?: `0x${string}` | undefined;
21776
- readonly contractAddress?: `0x${string}` | undefined;
21777
- }];
21778
- };
21779
- readonly decryption: {
21780
- readonly all: readonly ["zama.decryption"];
21781
- readonly encryptedValue: (encryptedValue: string, contractAddress?: Address) => readonly ["zama.decryption", {
21782
- readonly contractAddress?: `0x${string}` | undefined;
21783
- readonly encryptedValue: string;
21784
- }];
21785
- readonly encryptedInputs: (encryptedInputs: readonly {
21786
- encryptedValue: string;
21787
- contractAddress: Address;
21788
- }[], walletAccount?: WalletAccount) => readonly ["zama.decryption", {
21789
- readonly encryptedInputs: {
21790
- encryptedValue: Hex;
21791
- contractAddress: `0x${string}`;
21792
- }[];
21793
- readonly walletAddress: `0x${string}`;
21794
- readonly walletChainId: number;
21795
- } | {
21796
- readonly encryptedInputs: {
21797
- encryptedValue: Hex;
21798
- contractAddress: `0x${string}`;
21799
- }[];
21800
- readonly walletAddress?: undefined;
21801
- readonly walletChainId?: undefined;
21802
- }];
21803
- };
21804
- readonly wrappersRegistry: {
21805
- readonly all: readonly ["zama.wrappersRegistry"];
21806
- readonly chainId: () => readonly ["zama.wrappersRegistry", {
21807
- readonly type: "chainId";
21808
- }];
21809
- readonly tokenPairs: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
21810
- readonly type: "tokenPairs";
21811
- readonly registryAddress: `0x${string}`;
21812
- }];
21813
- readonly confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21814
- readonly type: "confidentialTokenAddress";
21815
- readonly registryAddress: `0x${string}`;
21816
- readonly tokenAddress: `0x${string}`;
21817
- }];
21818
- readonly tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21819
- readonly type: "tokenAddress";
21820
- readonly registryAddress: `0x${string}`;
21821
- readonly confidentialTokenAddress: `0x${string}`;
21822
- }];
21823
- readonly tokenPairsLength: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
21824
- readonly type: "tokenPairsLength";
21825
- readonly registryAddress: `0x${string}`;
21826
- }];
21827
- readonly tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) => readonly ["zama.wrappersRegistry", {
21828
- readonly type: "tokenPairsSlice";
21829
- readonly registryAddress: `0x${string}`;
21830
- readonly fromIndex: string;
21831
- readonly toIndex: string;
21832
- }];
21833
- readonly tokenPair: (registryAddress: Address, index: string) => readonly ["zama.wrappersRegistry", {
21834
- readonly type: "tokenPair";
21835
- readonly registryAddress: `0x${string}`;
21836
- readonly index: string;
21837
- }];
21838
- readonly isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
21839
- readonly type: "isConfidentialTokenValid";
21840
- readonly registryAddress: `0x${string}`;
21841
- readonly confidentialTokenAddress: `0x${string}`;
21842
- }];
21843
- readonly listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) => readonly ["zama.wrappersRegistry", {
21844
- readonly type: "listPairs";
21845
- readonly registryAddress: `0x${string}`;
21846
- readonly page: number;
21847
- readonly pageSize: number;
21848
- readonly metadata: boolean;
21849
- }];
21850
- };
22060
+ //#region src/query/wrap.d.ts
22061
+ /** Variables for {@link wrapMutationOptions}. */
22062
+ interface WrapParams extends WrapOptions {
22063
+ /** Amount of the public ERC-20 to wrap, in the token's base units. */
22064
+ amount: bigint;
22065
+ }
22066
+ /** Builds TanStack Query mutation options for {@link WrappedToken.wrap | wrapping} a public ERC-20 into its confidential form. @see {@link WrapParams} */
22067
+ declare function wrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.wrap", Address], WrapParams, TransactionResult>;
22068
+ //#endregion
22069
+ //#region src/query/unwrap-all.d.ts
22070
+ /** Builds TanStack Query mutation options for {@link WrappedToken.unwrapAll | unwrapping} the entire confidential balance. */
22071
+ declare function unwrapAllMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unwrapAll", Address], void, UnwrapResult>;
22072
+ //#endregion
22073
+ //#region src/query/finalize-unwrap.d.ts
22074
+ /** Variables for {@link finalizeUnwrapMutationOptions}. */
22075
+ type FinalizeUnwrapParams = {
22076
+ /** Identifier from an `UnwrapRequested` event. */
22077
+ unwrapRequestId: EncryptedValue;
21851
22078
  };
22079
+ /** Builds TanStack Query mutation options for {@link WrappedToken.finalizeUnwrap | finalizing} a previously requested unwrap. @see {@link FinalizeUnwrapParams} */
22080
+ declare function finalizeUnwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.finalizeUnwrap", Address], FinalizeUnwrapParams, TransactionResult>;
21852
22081
  //#endregion
21853
- //#region src/query/signer-query-context.d.ts
21854
- /** Connected-wallet context threaded into query factories to scope cache keys and gate signer-dependent queries. */
21855
- interface SignerQueryContext {
21856
- /** Connected wallet account; queries that need a signer stay disabled until it is set. */
21857
- walletAccount?: WalletAccount;
22082
+ //#region src/query/encrypt.d.ts
22083
+ /** Builds TanStack Query mutation options for {@link ZamaSDK.encrypt | encrypting} plaintext inputs into an encrypted payload. */
22084
+ declare function encryptMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.encrypt"], EncryptParams, EncryptResult>;
22085
+ //#endregion
22086
+ //#region src/query/delegated-decrypt.d.ts
22087
+ /** Variables for {@link delegatedDecryptValuesMutationOptions}. */
22088
+ interface DelegatedDecryptValuesMutationParams {
22089
+ /** Encrypted values (with their contract addresses) to decrypt. */
22090
+ encryptedInputs: EncryptedInput[];
22091
+ /** Address of the account that delegated decryption rights to the connected wallet. */
22092
+ delegatorAddress: Address;
21858
22093
  }
22094
+ /** Builds TanStack Query mutation options for {@link Decryption.delegatedDecryptValues | decrypting} encrypted values via delegated decryption credentials. @see {@link DelegatedDecryptValuesMutationParams} */
22095
+ declare function delegatedDecryptValuesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.delegatedDecryptValues"], DelegatedDecryptValuesMutationParams, Readonly<Record<EncryptedValue, ClearValue>>>;
21859
22096
  //#endregion
21860
- //#region src/query/user-decrypt.d.ts
21861
- /** A single encrypted value to decrypt, paired with the contract that owns it. */
21862
- interface EncryptedInput {
21863
- /** Encrypted handle to decrypt. */
21864
- encryptedValue: EncryptedValue;
21865
- /** Address of the contract the encrypted value belongs to. */
21866
- contractAddress: Address;
22097
+ //#region src/query/public-decrypt.d.ts
22098
+ /** Builds TanStack Query mutation options for {@link Decryption.decryptPublicValues | publicly decrypting} encrypted values, caching each clear result. */
22099
+ declare function decryptPublicValuesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.decryptPublicValues"], EncryptedValue[], DecryptPublicValuesResult>;
22100
+ //#endregion
22101
+ //#region src/query/grant-permit.d.ts
22102
+ /** Builds TanStack Query mutation options for {@link Permits.grantPermit | granting} decryption permits for the given contract addresses. */
22103
+ declare function grantPermitMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.grantPermit"], Address[], void>;
22104
+ //#endregion
22105
+ //#region src/query/prepare-permit.d.ts
22106
+ /** Builds TanStack Query mutation options for {@link Offline.preparePermit | preparing} an offline decryption permit. */
22107
+ declare function preparePermitMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.preparePermit"], PreparePermitRequest, PreparedPermit>;
22108
+ //#endregion
22109
+ //#region src/query/register-permit.d.ts
22110
+ /** Parameters for {@link registerPermitMutationOptions}. */
22111
+ interface RegisterPermitParams {
22112
+ /** The payload `sdk.offline.preparePermit` returned. */
22113
+ prepared: PreparedPermit;
22114
+ /** The `eth_signTypedData_v4` signature over `prepared.eip712`. */
22115
+ signature: Hex;
22116
+ }
22117
+ /** Builds TanStack Query mutation options for {@link Permits.registerPermit | registering} a signed offline permit. */
22118
+ declare function registerPermitMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.registerPermit"], RegisterPermitParams, void>;
22119
+ //#endregion
22120
+ //#region src/query/has-permit.d.ts
22121
+ /** Configuration for {@link hasPermitQueryOptions}. */
22122
+ interface HasPermitQueryConfig {
22123
+ /** Contract addresses to check credentials against. */
22124
+ contractAddresses: Address[];
22125
+ /**
22126
+ * Standard TanStack query options. `hasPermit` intentionally overrides cache
22127
+ * timing because permit state is wallet-local, not server state: every fetch
22128
+ * should read the SDK credential service directly.
22129
+ */
22130
+ query?: Record<string, unknown>;
22131
+ }
22132
+ /** Builds TanStack Query options for reading whether the connected wallet holds a valid decryption permit for the given contracts. */
22133
+ declare function hasPermitQueryOptions(sdk: ZamaSDK, config: HasPermitQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.hasPermit.scope>>;
22134
+ //#endregion
22135
+ //#region src/query/revoke-permits.d.ts
22136
+ /** TanStack Query mutation factory for {@link Permits.revokePermits}. */
22137
+ declare function revokePermitsMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.revokePermits"], Address[] | void, void>;
22138
+ //#endregion
22139
+ //#region src/query/clear-credentials.d.ts
22140
+ /** TanStack Query mutation factory for {@link Permits.clear}. */
22141
+ declare function clearCredentialsMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.clearCredentials"], void, void>;
22142
+ //#endregion
22143
+ //#region src/query/delegate-decryption.d.ts
22144
+ /** Variables for {@link delegateDecryptionMutationOptions}. */
22145
+ interface DelegateDecryptionParams {
22146
+ /** Address to grant delegated decryption rights to. */
22147
+ delegateAddress: Address;
22148
+ /** When the delegation expires; omit for no expiry. */
22149
+ expirationDate?: Date;
22150
+ }
22151
+ /** Builds TanStack Query mutation options for {@link Delegations.delegateDecryption | granting} delegated decryption rights on a contract. @see {@link DelegateDecryptionParams} */
22152
+ declare function delegateDecryptionMutationOptions(sdk: ZamaSDK, contractAddress: Address): MutationFactoryOptions<readonly ["zama.delegateDecryption", Address], DelegateDecryptionParams, TransactionResult>;
22153
+ //#endregion
22154
+ //#region src/query/decrypt-balance-as.d.ts
22155
+ /** Variables for {@link decryptBalanceAsMutationOptions}. */
22156
+ interface DecryptBalanceAsParams {
22157
+ /** Address of the account that delegated decryption rights to the connected wallet. */
22158
+ delegatorAddress: Address;
22159
+ /** Account whose on-chain balance to read; defaults to the delegator address. */
22160
+ accountAddress?: Address;
22161
+ }
22162
+ /** Builds TanStack Query mutation options for {@link Token.decryptBalanceAs | decrypting} a balance via delegated decryption credentials. @see {@link DecryptBalanceAsParams} */
22163
+ declare function decryptBalanceAsMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.decryptBalanceAs", Address], DecryptBalanceAsParams, bigint>;
22164
+ //#endregion
22165
+ //#region src/query/batch-decrypt-balances-as.d.ts
22166
+ /** Variables for {@link batchDecryptBalancesAsMutationOptions}. */
22167
+ type BatchDecryptBalancesAsParams = BatchDecryptAsOptions;
22168
+ /** Builds TanStack Query mutation options for {@link Token.batchDecryptBalancesAs | decrypting} multiple token balances via delegated decryption credentials. @see {@link BatchDecryptBalancesAsParams} */
22169
+ declare function batchDecryptBalancesAsMutationOptions(tokens: Token[]): MutationFactoryOptions<readonly ["zama.batchDecryptBalancesAs", ...Address[]], BatchDecryptBalancesAsParams, Map<Address, bigint>>;
22170
+ //#endregion
22171
+ //#region src/query/revoke-delegation.d.ts
22172
+ /** Variables for {@link revokeDelegationMutationOptions}. */
22173
+ interface RevokeDelegationParams {
22174
+ /** Address whose delegated decryption rights to revoke. */
22175
+ delegateAddress: Address;
21867
22176
  }
21868
- /** Decrypted clear values keyed by encrypted handle. */
21869
- type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;
21870
- /** Builds TanStack Query options for decrypting a batch of encrypted handles into their clear values. */
21871
- declare function decryptValuesQueryOptions(sdk: ZamaSDK, encryptedInputs: EncryptedInput[], signerContext?: SignerQueryContext): QueryFactoryOptions<DecryptResult, Error, DecryptResult, ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>>;
22177
+ /** Builds TanStack Query mutation options for {@link Delegations.revokeDelegation | revoking} delegated decryption rights on a contract. @see {@link RevokeDelegationParams} */
22178
+ declare function revokeDelegationMutationOptions(sdk: ZamaSDK, contractAddress: Address): MutationFactoryOptions<readonly ["zama.revokeDelegation", Address], RevokeDelegationParams, TransactionResult>;
22179
+ //#endregion
22180
+ //#region src/query/delegation-status.d.ts
22181
+ /** Configuration for {@link delegationStatusQueryOptions}. */
22182
+ interface DelegationStatusQueryConfig {
22183
+ /** Contract the delegation applies to; pass `undefined` to keep the query disabled. */
22184
+ contractAddress: Address | undefined;
22185
+ /** Address granting the delegated decryption rights; the query stays disabled until provided. */
22186
+ delegatorAddress?: Address;
22187
+ /** Address receiving the delegated decryption rights; the query stays disabled until provided. */
22188
+ delegateAddress?: Address;
22189
+ /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
22190
+ query?: Record<string, unknown>;
22191
+ }
22192
+ /** Builds TanStack Query options for reading the decryption-delegation status between a delegator and a delegate on a contract. */
22193
+ declare function delegationStatusQueryOptions(sdk: ZamaSDK, config: DelegationStatusQueryConfig): QueryFactoryOptions<DelegationStatus, Error, DelegationStatus, ReturnType<typeof zamaQueryKeys.delegationStatus.scope>>;
21872
22194
  //#endregion
21873
22195
  //#region src/services/decryption-service.d.ts
21874
22196
  /** Options shared by the delegated-decrypt entry points. */
@@ -21898,6 +22220,224 @@ interface BatchDecryptResult {
21898
22220
  items: BatchDecryptItem[];
21899
22221
  }
21900
22222
  //#endregion
22223
+ //#region src/namespaces/offline.d.ts
22224
+ /**
22225
+ * Namespace for the offline-signing pipeline —
22226
+ * `prepare → [external sign + self-publish]` — for institutional custody, HSM
22227
+ * ceremonies, and policy-engine workflows where signing runs out-of-process and
22228
+ * cannot happen synchronously in a single Promise.
22229
+ */
22230
+ declare class Offline {
22231
+ #private;
22232
+ /**
22233
+ * Build an RLP-encoded unsigned transaction for the given request. The
22234
+ * caller signs it externally — via an HSM ceremony, an out-of-process
22235
+ * custodian, or any signer holding the key — and broadcasts the signed bytes
22236
+ * through its own channel.
22237
+ *
22238
+ * Signer-optional: works without a configured signer (canonical shape for
22239
+ * cross-process custody — the back-end signer service consumes
22240
+ * `prepared.unsignedTx` and returns signed bytes).
22241
+ *
22242
+ * @remarks
22243
+ * `request.from` is only a declaration — the SDK does not prove the caller
22244
+ * controls it, and an EIP-1559 unsigned tx carries no `from` field at all
22245
+ * (the on-chain sender is whichever key signs the bytes). Point `from` at
22246
+ * the account the custodian will sign with; custodians enforce key-control
22247
+ * at sign time — a signing request for a key the credential can't use fails
22248
+ * there — so a mismatched `from` cannot make the custodian sign from an
22249
+ * account you don't control. Verifying control of `from` up front is still
22250
+ * the application's responsibility.
22251
+ */
22252
+ prepare<K extends TransactionKind>(request: Extract<PrepareTransactionRequest, {
22253
+ kind: K;
22254
+ }>, options?: PrepareOptions): Promise<PreparedFor<K>>;
22255
+ /**
22256
+ * Build the offline-signing payload for a decryption permit: the unsigned
22257
+ * EIP-712 typed data plus everything `sdk.permits.registerPermit` needs to
22258
+ * verify and persist the signature an out-of-process signer returns for it.
22259
+ *
22260
+ * Not a `prepare()` transaction kind: a permit is not a transaction —
22261
+ * nothing is broadcast, and registering the signature is a local operation,
22262
+ * not a relayer round-trip.
22263
+ *
22264
+ * Signer-optional, like {@link prepare}: `request.signer` is an explicit
22265
+ * address, not a connected wallet account. Building the typed data still
22266
+ * reads the chain's KMS signers context on-chain — signer-offline, not
22267
+ * network-offline.
22268
+ *
22269
+ * One permit per call: unlike `sdk.permits.grantPermit`, this never widens
22270
+ * an existing permit or chunks over 10 contracts — `request.contracts` maps
22271
+ * to exactly one signature.
22272
+ *
22273
+ * @throws if `request.contracts` is empty or exceeds 10 addresses, `request.delegator`
22274
+ * equals `request.signer`, or `request.durationDays` exceeds the V1 permit maximum
22275
+ * of 365 days. {@link ConfigurationError}
22276
+ * @throws if a concurrent `permits.revokeTransportKeyPair()` rotates the transport key
22277
+ * pair while this call is generating one. {@link TransportKeyPairChangedError}
22278
+ */
22279
+ preparePermit(request: PreparePermitRequest): Promise<PreparedPermit>;
22280
+ }
22281
+ //#endregion
22282
+ //#region src/zama-sdk.d.ts
22283
+ /** Instance-level options that are deliberately not part of the shareable config object. */
22284
+ interface ZamaSDKOptions {
22285
+ /**
22286
+ * Encrypts the transport key pair's private half at rest. Headless environments only
22287
+ * (CLI tools, servers, agents); the constructor rejects it in browser contexts. Supply
22288
+ * at least 32 random bytes, or a string of at least 64 characters, from a CSPRNG or
22289
+ * secrets manager. The SDK copies a Uint8Array secret and zeroizes its own copy after
22290
+ * key import; it never touches your buffer, so zeroize yours after construction.
22291
+ * The SDK never persists or exposes this value. Omit for the default:
22292
+ * plaintext at rest, security delegated to the storage backend.
22293
+ */
22294
+ transportKeyPairDerivationSecret?: string | Uint8Array;
22295
+ }
22296
+ /**
22297
+ * ZamaSDK — composes a RelayerSDK with contract abstraction.
22298
+ *
22299
+ * Exposes domain namespaces for permits, delegations, decryption, offline
22300
+ * signing, and tokens, plus an unchanged registry, a top-level `encrypt`, and
22301
+ * lifecycle methods. Internal `*Service` classes do the work; the namespace
22302
+ * classes own SDK-level guards (chain alignment, signer requirement, event
22303
+ * emission).
22304
+ */
22305
+ declare class ZamaSDK {
22306
+ #private;
22307
+ /** Read-only chain access used for all contract reads. */
22308
+ readonly provider: GenericProvider;
22309
+ /** Wallet signer used for write operations, or `undefined` when the SDK is read-only. */
22310
+ readonly signer: GenericSigner | undefined;
22311
+ /** Storage for cached permits and transport key pairs. */
22312
+ readonly storage: GenericStorage;
22313
+ /**
22314
+ * A {@link WrappersRegistry} instance auto-configured for the current chain.
22315
+ * Uses built-in defaults from chain configs, and the SDK's `registryTTL` if configured.
22316
+ */
22317
+ readonly registry: WrappersRegistry;
22318
+ /** Permit and keypair management. */
22319
+ readonly permits: Permits;
22320
+ /** On-chain decryption-delegation management. */
22321
+ readonly delegations: Delegations;
22322
+ /** FHE decryption (user, delegated user, public). */
22323
+ readonly decryption: Decryption;
22324
+ /** Offline-signing pipeline: `prepare` builds an unsigned tx the caller signs and broadcasts out-of-process — for HSM, policy-engine, and cross-process custody workflows. */
22325
+ readonly offline: Offline;
22326
+ constructor(config: ZamaConfig, options?: ZamaSDKOptions);
22327
+ /**
22328
+ * The single-chain relayer backend for the **currently active** chain.
22329
+ */
22330
+ get relayer(): RelayerSDK;
22331
+ /**
22332
+ * Create a {@link WrappersRegistry} instance bound to this SDK's provider.
22333
+ * Inherits the registry addresses derived from the SDK's chain configs, so
22334
+ * the result is consistent with {@link ZamaSDK.registry}.
22335
+ *
22336
+ * @param registryAddresses - Optional per-chain overrides for this registry instance.
22337
+ * @returns A {@link WrappersRegistry} instance.
22338
+ *
22339
+ * @example
22340
+ * ```ts
22341
+ * // Addresses resolved from the SDK's chain configs
22342
+ * const registry = sdk.createWrappersRegistry();
22343
+ *
22344
+ * // Hardhat or custom chain — override per chain for this registry instance
22345
+ * const registry = sdk.createWrappersRegistry({ [31337]: "0xYourRegistry" });
22346
+ *
22347
+ * const pairs = await registry.getTokenPairs();
22348
+ * ```
22349
+ */
22350
+ createWrappersRegistry(registryAddresses?: Record<number, Address>): WrappersRegistry;
22351
+ /**
22352
+ * Encrypt one or more plaintext values into FHE ciphertexts.
22353
+ *
22354
+ * @param params - Typed FHE inputs, the target contract address, and the user address.
22355
+ * @returns External encrypted values and the input proof for on-chain submission.
22356
+ * @throws if FHE encryption fails. {@link EncryptionFailedError}
22357
+ *
22358
+ * @example
22359
+ * ```ts
22360
+ * const { encryptedValues, inputProof } = await sdk.encrypt({
22361
+ * values: [{ value: 1000n, type: "euint64" }],
22362
+ * contractAddress: "0xToken",
22363
+ * userAddress: "0xUser",
22364
+ * });
22365
+ * ```
22366
+ */
22367
+ encrypt(params: EncryptParams, options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<EncryptResult>;
22368
+ /**
22369
+ * Create a high-level ERC-20-style interface for an ERC-7984 confidential token.
22370
+ * Supports balance queries, transfers, operator approvals, and decryption.
22371
+ *
22372
+ * For ERC-7984 wrappers (shield/unshield/allowance), use {@link createWrappedToken} instead.
22373
+ *
22374
+ * @param address - The confidential token contract address.
22375
+ * @returns A {@link Token} instance bound to this SDK.
22376
+ *
22377
+ * @example
22378
+ * ```ts
22379
+ * const token = sdk.createToken(cUSDT);
22380
+ * const balance = await token.balanceOf(userAddress);
22381
+ * ```
22382
+ */
22383
+ createToken(address: Address): Token;
22384
+ /**
22385
+ * Create a high-level interface for an ERC-7984 wrapper token.
22386
+ * Extends {@link Token} with shield/unshield/allowance/finalize-unwrap operations.
22387
+ *
22388
+ * @param address - The wrapper token contract address.
22389
+ * @returns A {@link WrappedToken} instance bound to this SDK.
22390
+ *
22391
+ * @example
22392
+ * ```ts
22393
+ * const wrapped = sdk.createWrappedToken(wUSDT);
22394
+ * await wrapped.shield(1_000_000n);
22395
+ * ```
22396
+ */
22397
+ createWrappedToken(address: Address): WrappedToken;
22398
+ /**
22399
+ * Release the SDK-owned resources: signer lifecycle subscriptions and the
22400
+ * relayer backend's resources, an encrypt worker included. Call this when the
22401
+ * SDK instance is being replaced (e.g. React provider unmount or a Strict Mode
22402
+ * remount). Work already in flight runs to completion, and the instance stays
22403
+ * usable: the next encryption spawns a fresh worker.
22404
+ */
22405
+ dispose(): void;
22406
+ /**
22407
+ * {@link dispose} plus the signer's own disposal. Call this when the SDK is no
22408
+ * longer needed (e.g. on shutdown). Work already in flight runs to completion.
22409
+ */
22410
+ terminate(): void;
22411
+ /**
22412
+ * Implements the TC39 Explicit Resource Management protocol.
22413
+ * Calls {@link terminate} when the `using` binding goes out of scope,
22414
+ * unsubscribing signer events and releasing the relayer's resources.
22415
+ *
22416
+ * @example
22417
+ * ```ts
22418
+ * {
22419
+ * using sdk = new ZamaSDK({ relayer, provider, signer, storage });
22420
+ * await sdk.permits.grantPermit([cUSDT]);
22421
+ * const balance = await sdk.createToken(cUSDT).balanceOf(userAddress);
22422
+ * } // sdk.terminate() called automatically here
22423
+ * ```
22424
+ */
22425
+ [Symbol.dispose](): void;
22426
+ }
22427
+ //#endregion
22428
+ //#region src/query/user-decrypt.d.ts
22429
+ /** A single encrypted value to decrypt, paired with the contract that owns it. */
22430
+ interface EncryptedInput {
22431
+ /** Encrypted handle to decrypt. */
22432
+ encryptedValue: EncryptedValue;
22433
+ /** Address of the contract the encrypted value belongs to. */
22434
+ contractAddress: Address;
22435
+ }
22436
+ /** Decrypted clear values keyed by encrypted handle. */
22437
+ type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;
22438
+ /** Builds TanStack Query options for decrypting a batch of encrypted handles into their clear values. */
22439
+ declare function decryptValuesQueryOptions(sdk: ZamaSDK, encryptedInputs: EncryptedInput[], signerContext?: SignerQueryContext): QueryFactoryOptions<DecryptResult, Error, DecryptResult, ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>>;
22440
+ //#endregion
21901
22441
  //#region src/namespaces/decryption.d.ts
21902
22442
  /**
21903
22443
  * Public namespace for FHE decryption — the canonical way to decrypt.
@@ -22038,94 +22578,5 @@ declare class Decryption {
22038
22578
  } & DelegatedDecryptOptions): Promise<BatchDecryptResult>;
22039
22579
  }
22040
22580
  //#endregion
22041
- //#region src/storage/memory-storage.d.ts
22042
- /** In-memory credential store. Credentials are lost on page reload. */
22043
- declare class MemoryStorage implements GenericStorage {
22044
- #private;
22045
- /**
22046
- * Retrieve a value by key.
22047
- * @returns The stored value, or `null` if the key does not exist.
22048
- */
22049
- get<T = unknown>(key: string): Promise<T | null>;
22050
- /** Store a value under the given key, overwriting any existing entry. */
22051
- set<T = unknown>(key: string, value: T): Promise<void>;
22052
- /** Remove the entry for the given key (no-op if absent). */
22053
- delete(key: string): Promise<void>;
22054
- }
22055
- /** Default singleton for application-wide use. */
22056
- declare const memoryStorage: MemoryStorage;
22057
- //#endregion
22058
- //#region src/storage/indexeddb-storage.d.ts
22059
- /**
22060
- * IndexedDB-backed {@link GenericStorage}.
22061
- *
22062
- * Stores keypair and permit objects keyed by a hashed wallet address. The
22063
- * SDK delegates security to the storage backend — values are persisted
22064
- * verbatim with no SDK-layer encryption.
22065
- */
22066
- declare class IndexedDBStorage implements GenericStorage {
22067
- #private;
22068
- constructor(dbName?: string, dbVersion?: number, storeName?: string);
22069
- /**
22070
- * Retrieve a value by key.
22071
- * @returns The stored value, or `null` if the key does not exist.
22072
- */
22073
- get<T = unknown>(key: string): Promise<T | null>;
22074
- /** Store a value under the given key, overwriting any existing entry. */
22075
- set<T = unknown>(key: string, value: T): Promise<void>;
22076
- /** Remove the entry for the given key (no-op if absent). */
22077
- delete(key: string): Promise<void>;
22078
- /** Remove all stored entries. */
22079
- clear(): Promise<void>;
22080
- }
22081
- /** Default singleton for application-wide use. */
22082
- declare const indexedDBStorage: IndexedDBStorage;
22083
- //#endregion
22084
- //#region src/storage/chrome-session-storage.d.ts
22085
- /**
22086
- * {@link GenericStorage} backed by `chrome.storage.session`.
22087
- *
22088
- * Use this in MV3 web extensions so the wallet signature survives
22089
- * service worker restarts and is shared across popup, background,
22090
- * and content script contexts.
22091
- *
22092
- * @example
22093
- * ```ts
22094
- * import { ZamaSDK, indexedDBStorage, chromeSessionStorage } from "@zama-fhe/sdk";
22095
- * import { createConfig } from "@zama-fhe/sdk/viem";
22096
- *
22097
- * const config = createConfig({
22098
- * chains: [mySepolia],
22099
- * publicClient,
22100
- * walletClient,
22101
- * relayers: { [mySepolia.id]: web() },
22102
- * storage: indexedDBStorage, // encrypted transport key pair — persistent
22103
- * permitStorage: chromeSessionStorage, // signed permits — ephemeral
22104
- * });
22105
- * const sdk = new ZamaSDK(config);
22106
- * ```
22107
- */
22108
- declare class ChromeSessionStorage implements GenericStorage {
22109
- /**
22110
- * Retrieve a value by key.
22111
- * @returns The stored value, or `null` if the key does not exist.
22112
- */
22113
- get<T = unknown>(key: string): Promise<T | null>;
22114
- /** Store a value under the given key, overwriting any existing entry. */
22115
- set(key: string, value: unknown): Promise<void>;
22116
- /** Remove the entry for the given key (no-op if absent). */
22117
- delete(key: string): Promise<void>;
22118
- }
22119
- /** Default singleton for application-wide use. */
22120
- declare const chromeSessionStorage: ChromeSessionStorage;
22121
- //#endregion
22122
- //#region src/utils/handles.d.ts
22123
- /** All-zero encrypted-value sentinel — a 32-byte zero handle representing the cleartext value `0`. */
22124
- declare const ZERO_ENCRYPTED_VALUE: "0x0000000000000000000000000000000000000000000000000000000000000000";
22125
- /**
22126
- * Check whether an encrypted value represents the zero value.
22127
- */
22128
- declare function isEncryptedValueZero(encryptedValue: string): boolean;
22129
- //#endregion
22130
- export { BalanceErrorDetails as $, ERC7984_INTERFACE_ID as $t, BatchDecryptAsOptions as A, Permission as At, TransactionRevertedError as B, getConfidentialTokenAddressContract as Bt, ZamaSDKOptions as C, wrapContract as Cn, TransportKeyPairChangedError as Ct, WrappersRegistryConfig as D, ZamaErrorCode as Dt, WrappersRegistry as E, ZamaError as Et, Permits as F, SerializedTransportKeyPair as Ft, SignerRequiredError as G, getTokenPairsSliceContract as Gt, SigningFailedError as H, getTokenPairContract as Ht, ErrorForCode as I, ChecksummedAddress as It, RpcRateLimitError as J, getDelegationExpiryContract as Jt, WalletAccountNotReadyError as K, isConfidentialTokenValidContract as Kt, matchZamaError as L, PaginatedResult as Lt, Offline as M, PreparedPermit as Mt, Delegations as N, SerializedPermit as Nt, WrappedToken as O, isRetryable as Ot, DelegationStatus as P, SerializedPermitEip712 as Pt, BalanceCheckUnavailableError as Q, ERC1363_INTERFACE_ID as Qt, UnshieldAlreadyFinalizedDetails as R, TokenWrapperPair as Rt, ZamaSDK as S, unwrapRequesterContract as Sn, RevokedKmsContextError as St, ListPairsOptions as T, ChainMismatchError as Tt, SigningRejectedError as U, getTokenPairsContract as Ut, SigningErrorMetadata as V, getTokenAddressContract as Vt, SignerNotConfiguredError as W, getTokenPairsLengthContract as Wt, ConfigurationError as X, revokeDelegationContract as Xt, NotEntitledError as Y, isHandleDelegatedContract as Yt, RelayerRequestFailedError as Z, transferAndCallContract as Zt, decryptValuesQueryOptions as _, rateContract as _n, InvalidTransportKeyPairError as _t, ChromeSessionStorage as a, approveContract as an, EncryptOffloadUnavailableError as at, MutationFactoryOptions as b, unwrapContract as bn, PreparedPermitChainMismatchError as bt, indexedDBStorage as c, nameContract as cn, DelegationContractIsSelfError as ct, Decryption as d, confidentialTotalSupplyContract as dn, DelegationExpirationTooSoonError as dt, ERC7984_WRAPPER_INTERFACE_ID as en, ERC20ReadFailedError as et, BatchDecryptItem as f, confidentialTransferContract as fn, DelegationExpiredError as ft, EncryptedInput as g, isOperatorContract as gn, DelegationSelfNotAllowedError as gt, DecryptResult as h, inferredTotalSupplyContract as hn, DelegationNotPropagatedError as ht, isEncryptedValueZero as i, allowanceContract as in, DecryptionFailedError as it, Token as j, PreparePermitRequest as jt, BatchBalancesResult as k, retryAfterSeconds as kt, MemoryStorage as l, symbolContract as ln, DelegationCooldownError as lt, DelegatedDecryptOptions as m, finalizeUnwrapContract as mn, DelegationNotFoundError as mt, Hex$1 as n, isConfidentialWrapperContract as nn, InsufficientConfidentialBalanceError as nt, chromeSessionStorage as o, balanceOfContract as on, EncryptionFailedError as ot, BatchDecryptResult as p, confidentialTransferFromContract as pn, DelegationExpiryUnchangedError as pt, WalletNotConnectedError as q, delegateForUserDecryptionContract as qt, ZERO_ENCRYPTED_VALUE as r, supportsInterfaceContract as rn, InsufficientERC20BalanceError as rt, IndexedDBStorage as s, decimalsContract as sn, AclPausedError as st, Address$1 as t, isConfidentialTokenContract as tn, InsufficientAllowanceError as tt, memoryStorage as u, confidentialBalanceOfContract as un, DelegationDelegateEqualsContractError as ut, SignerQueryContext as v, setOperatorContract as vn, KeyWrappingError as vt, DefaultRegistryAddresses as w, createConfig as wn, TransportKeyPairExpiredError as wt, QueryFactoryOptions as x, unwrapFromBalanceContract as xn, PreparedPermitExpiredError as xt, zamaQueryKeys as y, underlyingContract as yn, NoCiphertextError as yt, UnshieldAlreadyFinalizedError as z, TokenWrapperPairWithMetadata as zt };
22131
- //# sourceMappingURL=index-DJYq1rAB.d.ts.map
22581
+ export { confidentialTransferFromMutationOptions as $, DelegationNotPropagatedError as $n, inferredTotalSupplyContract as $r, invalidateAfterSetOperator as $t, DelegatedDecryptValuesMutationParams as A, WalletNotConnectedError as An, isConfidentialTokenValidContract as Ar, confidentialIsOperatorQueryOptions as At, ResumeUnshieldParams as B, InsufficientERC20BalanceError as Bn, isConfidentialWrapperContract as Br, WrappersRegistryConfig as Bt, HasPermitQueryConfig as C, TransactionRevertedError as Cn, TokenWrapperPairWithMetadata as Cr, ConfidentialBalanceQueryConfig as Ct, preparePermitMutationOptions as D, SignerNotConfiguredError as Dn, getTokenPairsContract as Dr, BatchDecryptAsOptions as Dt, registerPermitMutationOptions as E, SigningRejectedError as En, getTokenPairContract as Er, BatchBalancesResult as Et, unwrapAllMutationOptions as F, BalanceCheckUnavailableError as Fn, transferAndCallContract as Fr, WrapperDiscoveryQueryConfig as Ft, unshieldMutationOptions as G, DelegationContractIsSelfError as Gn, decimalsContract as Gr, isWrapperQueryOptions as Gt, UnshieldAllParams as H, EncryptOffloadUnavailableError as Hn, allowanceContract as Hr, totalSupplyQueryOptions as Ht, WrapParams as I, BalanceErrorDetails as In, ERC1363_INTERFACE_ID as Ir, wrapperDiscoveryQueryOptions as It, ConfidentialSetOperatorParams as J, DelegationDelegateEqualsContractError as Jn, confidentialBalanceOfContract as Jr, tokenMetadataQueryOptions as Jt, ApproveUnderlyingParams as K, DelegationCooldownError as Kn, nameContract as Kr, TokenMetadata as Kt, wrapMutationOptions as L, ERC20ReadFailedError as Ln, ERC7984_INTERFACE_ID as Lr, DefaultRegistryAddresses as Lt, encryptMutationOptions as M, NotEntitledError as Mn, getDelegationExpiryContract as Mr, pendingUnshieldQueryOptions as Mt, FinalizeUnwrapParams as N, ConfigurationError as Nn, isHandleDelegatedContract as Nr, UnderlyingAllowanceQueryConfig as Nt, grantPermitMutationOptions as O, SignerRequiredError as On, getTokenPairsLengthContract as Or, Token as Ot, finalizeUnwrapMutationOptions as P, RelayerRequestFailedError as Pn, revokeDelegationContract as Pr, underlyingAllowanceQueryOptions as Pt, ConfidentialTransferFromParams as Q, DelegationNotFoundError as Qn, finalizeUnwrapContract as Qr, invalidateAfterApproveUnderlying as Qt, UnwrapParams as R, InsufficientAllowanceError as Rn, ERC7984_WRAPPER_INTERFACE_ID as Rr, ListPairsOptions as Rt, revokePermitsMutationOptions as S, UnshieldAlreadyFinalizedError as Sn, TokenWrapperPair as Sr, confidentialBalancesQueryOptions as St, RegisterPermitParams as T, SigningFailedError as Tn, getTokenAddressContract as Tr, WrappedToken as Tt, unshieldAllMutationOptions as U, EncryptionFailedError as Un, approveContract as Ur, IsConfidentialQueryConfig as Ut, resumeUnshieldMutationOptions as V, DecryptionFailedError as Vn, supportsInterfaceContract as Vr, TotalSupplyQueryConfig as Vt, UnshieldParams as W, AclPausedError as Wn, balanceOfContract as Wr, isConfidentialQueryOptions as Wt, ConfidentialTransferFromAndCallParams as X, DelegationExpiredError as Xn, confidentialTransferContract as Xr, QueryFilterLike as Xt, confidentialSetOperatorMutationOptions as Y, DelegationExpirationTooSoonError as Yn, confidentialTotalSupplyContract as Yr, QueryClientLike as Yt, confidentialTransferFromAndCallMutationOptions as Z, DelegationExpiryUnchangedError as Zn, confidentialTransferFromContract as Zr, QueryLike as Zt, DecryptBalanceAsParams as _, DelegationStatus as _n, SerializedPermit as _r, tokenPairQueryOptions as _t, ZamaSDK as a, unwrapFromBalanceContract as ai, invalidateAfterWrap as an, PreparedPermitExpiredError as ar, shieldMutationOptions as at, delegateDecryptionMutationOptions as b, matchZamaError as bn, ChecksummedAddress as br, tokenPairsSliceQueryOptions as bt, BatchDecryptItem as c, createConfig as ci, invalidateWalletLifecycleQueries as cn, TransportKeyPairExpiredError as cr, ListPairsQueryConfig as ct, DelegationStatusQueryConfig as d, MutationFactoryOptions as dn, ZamaErrorCode as dr, TokenPairsSliceQueryConfig as dt, isOperatorContract as ei, invalidateAfterShield as en, DelegationSelfNotAllowedError as er, ConfidentialTransferAndCallParams as et, delegationStatusQueryOptions as f, QueryFactoryOptions as fn, isRetryable as fr, WrappersRegistryQueryConfig as ft, batchDecryptBalancesAsMutationOptions as g, Delegations as gn, PreparedPermit as gr, tokenAddressQueryOptions as gt, BatchDecryptBalancesAsParams as h, hashFn as hn, PreparePermitRequest as hr, listPairsQueryOptions as ht, decryptValuesQueryOptions as i, unwrapContract as ii, invalidateAfterUnwrap as in, PreparedPermitChainMismatchError as ir, ShieldParams as it, delegatedDecryptValuesMutationOptions as j, RpcRateLimitError as jn, delegateForUserDecryptionContract as jr, PendingUnshieldQueryConfig as jt, decryptPublicValuesMutationOptions as k, WalletAccountNotReadyError as kn, getTokenPairsSliceContract as kr, ConfidentialIsOperatorQueryConfig as kt, BatchDecryptResult as l, zamaQueryKeys as ln, ChainMismatchError as lr, TokenAddressQueryConfig as lt, revokeDelegationMutationOptions as m, filterQueryOptions as mn, Permission as mr, isConfidentialTokenValidQueryOptions as mt, DecryptResult as n, setOperatorContract as ni, invalidateAfterUnshield as nn, KeyWrappingError as nr, ConfidentialTransferParams as nt, ZamaSDKOptions as o, unwrapRequesterContract as oi, invalidateBalanceQueries as on, RevokedKmsContextError as or, ConfidentialTokenAddressQueryConfig as ot, RevokeDelegationParams as p, StrippedQueryOptionKeys as pn, retryAfterSeconds as pr, confidentialTokenAddressQueryOptions as pt, approveUnderlyingMutationOptions as q, DelegationDelegateCannotBeWildcardError as qn, symbolContract as qr, TokenMetadataQueryConfig as qt, EncryptedInput as r, underlyingContract as ri, invalidateAfterUnshieldSettled as rn, NoCiphertextError as rr, confidentialTransferMutationOptions as rt, Offline as s, wrapContract as si, invalidateWagmiBalanceQueries as sn, TransportKeyPairChangedError as sr, IsConfidentialTokenValidQueryConfig as st, Decryption as t, rateContract as ti, invalidateAfterTransfer as tn, InvalidTransportKeyPairError as tr, confidentialTransferAndCallMutationOptions as tt, DelegatedDecryptOptions as u, SignerQueryContext as un, ZamaError as ur, TokenPairQueryConfig as ut, decryptBalanceAsMutationOptions as v, Permits as vn, SerializedPermitEip712 as vr, tokenPairsLengthQueryOptions as vt, hasPermitQueryOptions as w, SigningErrorMetadata as wn, getConfidentialTokenAddressContract as wr, confidentialBalanceQueryOptions as wt, clearCredentialsMutationOptions as x, UnshieldAlreadyFinalizedDetails as xn, PaginatedResult as xr, ConfidentialBalancesQueryConfig as xt, DelegateDecryptionParams as y, ErrorForCode as yn, SerializedTransportKeyPair as yr, tokenPairsQueryOptions as yt, unwrapMutationOptions as z, InsufficientConfidentialBalanceError as zn, isConfidentialTokenContract as zr, WrappersRegistry as zt };
22582
+ //# sourceMappingURL=index-DlpdjcMQ.d.ts.map