@zama-fhe/sdk 3.3.1-alpha.2 → 3.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,12 @@
1
- import { u as FheChain } from "./index-D66eC3G7.js";
2
- import { $ as TransferOptions, Bt as EncryptedValue, C as ChainRouter, Ht as FhevmRelayerOptions, K as ZamaSDKEventInput, Mt as TransactionResult, Nt as ClearValue, Pt as DecryptPublicValuesResult, R as TransactionOperation, Rt as EncryptParams, Ut as FhevmRelayerSDK, Z as ShieldOptions, c as GenericStorage, d as WalletAccount, et as UnshieldOptions, i as ZamaConfig, l as GenericProvider, n as RelayerConfig, nt as TransferCallbacks, o as ZamaConfigGeneric, p as WalletAccountListener, rt as UnshieldCallbacks, s as GenericLogger, u as GenericSigner, x as WriteContractConfig, zt as EncryptResult } from "./types-C-WTLcHZ.js";
3
- import { Address, Hex } from "viem";
1
+ import { u as FheChain } from "./index-doNE2KoX.js";
2
+ import { $ as TransferOptions, Bt as EncryptedValue, C as ChainRouter, Ht as FhevmRelayerOptions, K as ZamaSDKEventInput, Mt as TransactionResult, Nt as ClearValue, Pt as DecryptPublicValuesResult, R as TransactionOperation, Rt as EncryptParams, Ut as FhevmRelayerSDK, Z as ShieldOptions, c as GenericStorage, d as WalletAccount, et as UnshieldOptions, i as ZamaConfig, l as GenericProvider, n as RelayerConfig, nt as TransferCallbacks, o as ZamaConfigGeneric, p as WalletAccountListener, rt as UnshieldCallbacks, s as GenericLogger, u as GenericSigner, x as WriteContractConfig, zt as EncryptResult } from "./types-nwhfaUCK.js";
3
+ import "./cleartext-Bvx-0y6k.js";
4
+ import "./types-D8g0H49N.js";
5
+ import "./base-signer-D5HdiBp1.js";
6
+ import "./types-CObfaH4A.js";
7
+ import { Address, Address as Address$1, Hex, Hex as Hex$1 } from "viem";
4
8
  import { z } from "zod/mini";
5
9
  import { MutationFunctionContext, QueryKey, QueryObserverOptions, skipToken } from "@tanstack/query-core";
6
-
7
10
  //#region src/config/create.d.ts
8
11
  /**
9
12
  * Create a {@link ZamaConfig} from a custom {@link GenericSigner} and
@@ -18456,34 +18459,6 @@ declare function isConfidentialTokenValidContract(registry: Address, confidentia
18456
18459
  readonly args: readonly [`0x${string}`];
18457
18460
  };
18458
18461
  //#endregion
18459
- //#region src/query/utils.d.ts
18460
- type StrippedQueryOptionKeys = "gcTime" | "staleTime" | "enabled" | "select" | "refetchInterval" | "refetchOnMount" | "refetchOnWindowFocus" | "refetchOnReconnect" | "retry" | "retryDelay" | "retryOnMount" | "queryFn" | "queryKey" | "queryKeyHashFn" | "initialData" | "initialDataUpdatedAt" | "placeholderData" | "structuralSharing" | "throwOnError" | "meta" | "query" | "pollingInterval";
18461
- /**
18462
- * Remove TanStack behavioral options from a query config object so only domain
18463
- * parameters remain for the lower-level factory.
18464
- *
18465
- * @example
18466
- * ```ts
18467
- * const params = filterQueryOptions({
18468
- * query: { enabled: false },
18469
- * gcTime: 60_000,
18470
- * owner: "0xabc",
18471
- * });
18472
- * // => { owner: "0xabc" }
18473
- * ```
18474
- */
18475
- declare function filterQueryOptions<TOptions extends Record<string, unknown>>(options: TOptions): Omit<TOptions, StrippedQueryOptionKeys>;
18476
- /**
18477
- * Stable hash function for query keys.
18478
- * Sorts object keys recursively and converts bigint values to strings.
18479
- *
18480
- * @remarks
18481
- * bigint values are serialized as decimal strings, so `42n` and `"42"` hash to
18482
- * the same token when they occupy the same position. This collision is accepted
18483
- * by design for the current query-key conventions in this package.
18484
- */
18485
- declare function hashFn(queryKey: readonly unknown[]): string;
18486
- //#endregion
18487
18462
  //#region src/query/factory-types.d.ts
18488
18463
  type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
18489
18464
  type QueryFactoryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<RequiredBy<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey">, "queryFn" | "queryHash" | "queryKeyHashFn" | "throwOnError"> & {
@@ -18495,11 +18470,6 @@ interface MutationFactoryOptions<TMutationKey extends readonly unknown[], TVaria
18495
18470
  onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => void;
18496
18471
  }
18497
18472
  //#endregion
18498
- //#region src/query/signer-query-context.d.ts
18499
- interface SignerQueryContext {
18500
- walletAccount?: WalletAccount;
18501
- }
18502
- //#endregion
18503
18473
  //#region src/query/query-keys.d.ts
18504
18474
  /**
18505
18475
  * Canonical query-key namespace for `@zama-fhe/sdk/query`.
@@ -18703,53 +18673,19 @@ declare const zamaQueryKeys: {
18703
18673
  };
18704
18674
  };
18705
18675
  //#endregion
18706
- //#region src/query/invalidation.d.ts
18707
- interface QueryLike {
18708
- queryKey: readonly unknown[];
18709
- }
18710
- interface QueryFilterLike {
18711
- queryKey?: readonly unknown[];
18712
- predicate?: (query: QueryLike) => boolean;
18713
- }
18714
- interface QueryClientLike {
18715
- invalidateQueries(filters: QueryFilterLike): void | Promise<void>;
18716
- removeQueries(filters: QueryFilterLike): void;
18717
- }
18718
- declare function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void;
18719
- declare function invalidateBalanceQueries(queryClient: QueryClientLike, tokenAddress: Address): void;
18720
- declare function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void;
18721
- declare function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void;
18722
- declare function invalidateAfterUnshieldSettled(queryClient: QueryClientLike, tokenAddress: Address): void;
18723
- declare function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void;
18724
- declare function invalidateAfterApproveUnderlying(queryClient: QueryClientLike, tokenAddress: Address): void;
18725
- declare function invalidateAfterSetOperator(queryClient: QueryClientLike, tokenAddress: Address): void;
18726
- declare function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void;
18727
- declare function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void;
18728
- //#endregion
18729
- //#region src/query/token-metadata.d.ts
18730
- /** ERC-20 token metadata returned by {@link tokenMetadataQueryOptions}. */
18731
- interface TokenMetadata {
18732
- name: string;
18733
- symbol: string;
18734
- decimals: number;
18735
- }
18736
- interface TokenMetadataQueryConfig {
18737
- query?: Record<string, unknown>;
18738
- }
18739
- declare function tokenMetadataQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: TokenMetadataQueryConfig): QueryFactoryOptions<TokenMetadata, Error, TokenMetadata, ReturnType<typeof zamaQueryKeys.tokenMetadata.token>>;
18740
- //#endregion
18741
- //#region src/query/is-confidential.d.ts
18742
- interface IsConfidentialQueryConfig {
18743
- query?: Record<string, unknown>;
18676
+ //#region src/query/signer-query-context.d.ts
18677
+ interface SignerQueryContext {
18678
+ walletAccount?: WalletAccount;
18744
18679
  }
18745
- declare function isConfidentialQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: IsConfidentialQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isConfidential.token>>;
18746
- declare function isWrapperQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: IsConfidentialQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isWrapper.token>>;
18747
18680
  //#endregion
18748
- //#region src/query/total-supply.d.ts
18749
- interface TotalSupplyQueryConfig {
18750
- query?: Record<string, unknown>;
18681
+ //#region src/query/user-decrypt.d.ts
18682
+ interface EncryptedInput {
18683
+ encryptedValue: EncryptedValue;
18684
+ contractAddress: Address;
18751
18685
  }
18752
- declare function totalSupplyQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: TotalSupplyQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.totalSupply.token>>;
18686
+ /** Decrypted clear values keyed by encrypted handle. */
18687
+ type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;
18688
+ declare function decryptValuesQueryOptions(sdk: ZamaSDK, encryptedInputs: EncryptedInput[], signerContext?: SignerQueryContext): QueryFactoryOptions<DecryptResult, Error, DecryptResult, ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>>;
18753
18689
  //#endregion
18754
18690
  //#region src/schemas/primitives.d.ts
18755
18691
  declare const checksummedTag: unique symbol;
@@ -18817,272 +18753,91 @@ interface SerializedTransportKeyPairWithPermissions {
18817
18753
  readonly permissions: readonly Permission[];
18818
18754
  }
18819
18755
  //#endregion
18820
- //#region src/wrappers-registry.d.ts
18821
- /**
18822
- * Default wrappers registry addresses for known chains.
18823
- * Only includes chains where a registry is deployed (excludes Hardhat).
18824
- *
18825
- * @deprecated Read `registryAddress` from the chain presets instead (e.g.
18826
- * `sepolia.registryAddress`). Will be removed in the next major version.
18827
- */
18828
- declare const DefaultRegistryAddresses: Record<number, Address>;
18829
- /** Configuration for {@link WrappersRegistry}. */
18830
- interface WrappersRegistryConfig {
18831
- /** Read-only chain provider used for every registry lookup. */
18832
- provider: GenericProvider;
18833
- /**
18834
- * Per-chain registry address overrides, merged on top of
18835
- * {@link DefaultRegistryAddresses}. Use this to supply a registry
18836
- * address for custom or local chains (e.g. Hardhat).
18837
- *
18838
- * @example
18839
- * ```ts
18840
- * new WrappersRegistry({
18841
- * provider,
18842
- * registryAddresses: { [31337]: "0xYourHardhatRegistry" },
18843
- * });
18844
- * ```
18845
- */
18846
- registryAddresses?: Record<number, Address>;
18847
- /**
18848
- * How long cached registry results remain valid, in seconds.
18849
- * Default: `86400` (24 hours).
18850
- */
18851
- registryTTL?: number;
18852
- }
18853
- /** Options for {@link WrappersRegistry.listPairs}. */
18854
- interface ListPairsOptions {
18855
- /** Page number (1-indexed). Default: `1`. */
18856
- page?: number;
18857
- /** Number of items per page. Default: `100`. */
18858
- pageSize?: number;
18859
- /**
18860
- * When `true`, fetches on-chain metadata (name, symbol, decimals) for both
18861
- * the ERC-20 and confidential token, plus totalSupply for the ERC-20.
18862
- * Default: `false`.
18863
- */
18864
- metadata?: boolean;
18756
+ //#region src/credentials/credential-service.d.ts
18757
+ /** Configuration for {@link CredentialService}. TTLs are pre-validated by the caller. */
18758
+ interface CredentialServiceConfig {
18759
+ router: ChainRouter;
18760
+ signer: GenericSigner;
18761
+ /** Transport key pair lifetime in seconds. Pre-validated. */
18762
+ transportKeyPairTTL: number;
18763
+ /** Permit lifetime in days. Pre-validated. */
18764
+ permitTTL: number;
18765
+ /** Backing storage for transport key pairs (and permits if `permitStorage` is omitted). */
18766
+ storage: GenericStorage;
18767
+ /** Optional dedicated storage for permits; defaults to `storage`. */
18768
+ permitStorage?: GenericStorage;
18769
+ /** SDK-wide logger for credential-path diagnostics. */
18770
+ logger: GenericLogger;
18865
18771
  }
18866
18772
  /**
18867
- * High-level interface for the on-chain token wrappers registry.
18868
- *
18869
- * Uses the configured {@link GenericProvider} to resolve the correct registry
18870
- * contract address for the current chain and exposes typed read helpers for
18871
- * every registry query. Results are cached in memory with a configurable TTL
18872
- * (default 24 hours).
18873
- *
18874
- * @example
18875
- * ```ts
18876
- * const registry = new WrappersRegistry({ provider });
18877
- *
18878
- * // Paginated listing
18879
- * const page1 = await registry.listPairs({ page: 1, pageSize: 20 });
18880
- *
18881
- * // Structured lookups
18882
- * const result = await registry.getConfidentialToken(erc20Address);
18883
- * if (result) console.log(result.confidentialTokenAddress);
18773
+ * Single facade coordinating the keypair vault and the permission store.
18884
18774
  *
18885
- * // Force refresh
18886
- * registry.refresh();
18887
- * ```
18775
+ * `CredentialService` is the only credentials object held by `ZamaSDK`. It accepts identity
18776
+ * transitions via `handleWalletAccountChange`.
18888
18777
  */
18889
- declare class WrappersRegistry {
18778
+ declare class CredentialService {
18890
18779
  #private;
18891
- readonly provider: GenericProvider;
18892
- constructor(config: WrappersRegistryConfig);
18893
- /**
18894
- * Synchronous lookup of the registry address for a given chain ID.
18895
- * Returns `undefined` if no address is configured for that chain.
18896
- */
18897
- getAddress(chainId: number): Address | undefined;
18898
- /**
18899
- * Force-invalidate the in-memory cache. The next call to any read method
18900
- * will fetch fresh data from the chain.
18901
- */
18902
- refresh(): void;
18903
- /**
18904
- * The cache TTL in milliseconds.
18905
- * Exposed so query option factories can set a matching `staleTime`.
18906
- */
18907
- get ttlMs(): number;
18908
- /**
18909
- * Resolve the registry contract address for the current chain.
18910
- *
18911
- * Priority: `registryAddresses[chainId]` \> built-in default.
18912
- *
18913
- * @returns The registry contract address for the connected chain.
18914
- * @throws if no address is configured for the chain. {@link ConfigurationError}
18915
- */
18916
- getRegistryAddress(): Promise<Address>;
18780
+ constructor(config: CredentialServiceConfig);
18917
18781
  /**
18918
- * List token wrapper pairs with page-based pagination.
18919
- *
18920
- * Internally maps to `getTokenConfidentialTokenPairsSlice` on-chain.
18921
- *
18922
- * @param options - Pagination and enrichment options.
18923
- * @returns A {@link PaginatedResult} of pairs.
18924
- *
18925
- * @example
18926
- * ```ts
18927
- * const result = await registry.listPairs({ page: 1, pageSize: 20 });
18928
- * console.log(`${result.total} pairs, showing page ${result.page}`);
18782
+ * Resolve a keypair and permissions covering `contracts`, minimizing wallet
18783
+ * prompts by reusing or widening existing permits where possible. Empty
18784
+ * `contracts` warms the keypair without prompting.
18929
18785
  *
18930
- * // With on-chain metadata
18931
- * const withMeta = await registry.listPairs({ metadata: true, pageSize: 10 });
18932
- * for (const pair of withMeta.items) {
18933
- * console.log(pair.underlying.symbol, "→", pair.confidential.symbol);
18934
- * }
18935
- * ```
18786
+ * @returns The resolved keypair and permits covering the requested contracts.
18787
+ * @throws if the user rejects a wallet signature prompt. {@link SigningRejectedError}
18788
+ * @throws if signing fails for any other reason. {@link SigningFailedError}
18936
18789
  */
18937
- listPairs(options: ListPairsOptions & {
18938
- metadata: true;
18939
- }): Promise<PaginatedResult<TokenWrapperPairWithMetadata>>;
18940
- listPairs(options?: ListPairsOptions): Promise<PaginatedResult<TokenWrapperPair>>;
18790
+ grantPermit(contracts: readonly Address[], delegator?: Address): Promise<SerializedTransportKeyPairWithPermissions>;
18941
18791
  /**
18942
- * Look up the confidential token for a given plain ERC-20 address.
18943
- *
18944
- * @param tokenAddress - The plain ERC-20 token address.
18945
- * @returns The lookup result, or `null` if the token has never been registered.
18946
- * **Note:** revoked tokens (registered then invalidated) return a non-null result
18947
- * with `isValid: false`. Check `result.isValid` explicitly rather than using
18948
- * `if (result)` to guard against processing revoked tokens.
18792
+ * Pure store lookup: are stored permits sufficient to cover `contracts`? No wallet prompt.
18949
18793
  *
18950
- * @example
18951
- * ```ts
18952
- * const result = await registry.getConfidentialToken(usdcAddress);
18953
- * if (result?.isValid) {
18954
- * console.log(result.confidentialTokenAddress);
18955
- * }
18956
- * ```
18794
+ * @returns `true` if cached permits cover all requested contracts (vacuously
18795
+ * true for an empty list); `false` if no keypair exists or coverage is
18796
+ * incomplete.
18957
18797
  */
18958
- getConfidentialToken(tokenAddress: Address): Promise<{
18959
- confidentialTokenAddress: Address;
18960
- isValid: boolean;
18961
- } | null>;
18798
+ hasPermit(contracts: readonly Address[], delegator?: Address): Promise<boolean>;
18962
18799
  /**
18963
- * Reverse lookup — find the plain ERC-20 for a given confidential token.
18964
- *
18965
- * @param confidentialTokenAddress - The confidential token address.
18966
- * @returns The lookup result, or `null` if no pair is registered.
18800
+ * Wipe FHE permits for the current signer.
18967
18801
  *
18968
- * @example
18969
- * ```ts
18970
- * const result = await registry.getUnderlyingToken(cUsdcAddress);
18971
- * if (result) {
18972
- * console.log(result.tokenAddress, result.isValid);
18973
- * }
18974
- * ```
18975
- */
18976
- getUnderlyingToken(confidentialTokenAddress: Address): Promise<{
18977
- tokenAddress: Address;
18978
- isValid: boolean;
18979
- } | null>;
18980
- /**
18981
- * Fetch all token wrapper pairs from the registry.
18802
+ * - With no argument: every permit referencing this signer is removed across
18803
+ * all chains and delegators. The keypair survives — use
18804
+ * {@link clearCredentials} to also wipe the keypair.
18805
+ * - With a contract list: every signed permit in the direct-decrypt scope
18806
+ * (current chain) whose immutable payload touches any listed address is
18807
+ * removed. Delegated permits are not touched in this mode.
18982
18808
  *
18983
- * @returns All registered `TokenWrapperPair` entries.
18809
+ * @throws if reading the signer address fails. {@link SigningFailedError}
18984
18810
  */
18985
- getTokenPairs(): Promise<readonly TokenWrapperPair[]>;
18811
+ revokePermits(contracts?: readonly Address[]): Promise<void>;
18986
18812
  /**
18987
- * Get the total number of token wrapper pairs.
18813
+ * Wipe the keypair for the current signer and cascade-delete every
18814
+ * permission referencing it across all chains and delegators.
18988
18815
  *
18989
- * @returns The count as a bigint.
18816
+ * @throws if reading the signer address fails. {@link SigningFailedError}
18990
18817
  */
18991
- getTokenPairsLength(): Promise<bigint>;
18818
+ clearCredentials(): Promise<void>;
18992
18819
  /**
18993
- * Fetch a range of token wrapper pairs (paginated by index).
18820
+ * Warm the signer transport key pair cache for a known address.
18994
18821
  *
18995
- * @param fromIndex - Start index (inclusive).
18996
- * @param toIndex - End index (exclusive).
18997
- * @returns The slice of `TokenWrapperPair` entries.
18822
+ * Best-effort prefetch primitive: correctness still comes from `grantPermit`,
18823
+ * which lazily creates the transport key pair when needed. Errors (storage failure,
18824
+ * relayer 4xx, missing Worker in SSR) are **not** swallowed here — the caller
18825
+ * decides whether to log, ignore, or surface them.
18998
18826
  */
18999
- getTokenPairsSlice(fromIndex: bigint, toIndex: bigint): Promise<readonly TokenWrapperPair[]>;
18827
+ warmTransportKeyPair(address: Address): Promise<void>;
19000
18828
  /**
19001
- * Fetch a single token wrapper pair by index.
18829
+ * Apply a wallet account transition.
19002
18830
  *
19003
- * @param index - Zero-based pair index.
19004
- * @returns The `TokenWrapperPair` at that index.
18831
+ * Address change clears persisted credentials for the previous account.
18832
+ * Chain-only changes keep credentials intact because permits are chain-scoped
18833
+ * already and stale decrypt plaintext is cleared by `ZamaSDK`.
19005
18834
  */
19006
- getTokenPair(index: bigint): Promise<TokenWrapperPair>;
19007
- /**
19008
- * Look up the confidential token address for a given plain ERC-20 token.
19009
- *
19010
- * @param tokenAddress - The plain ERC-20 token address.
19011
- * @returns A tuple `[isValid, confidentialTokenAddress]`. `isValid` is `true` only for a
19012
- * registered, non-revoked wrapper. The address is the zero address when no pair is registered.
19013
- * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
19014
- */
19015
- getConfidentialTokenAddress(tokenAddress: Address): Promise<readonly [boolean, Address]>;
19016
- /**
19017
- * Reverse lookup — find the plain ERC-20 for a given confidential token.
19018
- *
19019
- * @param confidentialTokenAddress - The confidential token address.
19020
- * @returns A tuple `[isValid, tokenAddress]`. `isValid` is `true` only for a registered,
19021
- * non-revoked wrapper. The address is the zero address when no pair is registered.
19022
- * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
19023
- */
19024
- getTokenAddress(confidentialTokenAddress: Address): Promise<readonly [boolean, Address]>;
19025
- /**
19026
- * Check whether a confidential token is registered and valid.
19027
- *
19028
- * @param confidentialTokenAddress - The confidential token address to check.
19029
- * @returns `true` if the token is a known valid wrapper in the registry.
19030
- */
19031
- isConfidentialTokenValid(confidentialTokenAddress: Address): Promise<boolean>;
19032
- }
19033
- //#endregion
19034
- //#region src/query/wrapper-discovery.d.ts
19035
- interface WrapperDiscoveryQueryConfig {
19036
- /**
19037
- * Address of any confidential token you control.
19038
- * Used to scope the query cache key and to gate whether the query
19039
- * is enabled — it does not affect which wrapper the registry returns.
19040
- */
19041
- tokenAddress?: Address;
19042
- /**
19043
- * The ERC-20 token address to discover the confidential wrapper for.
19044
- * The registry is resolved automatically from chain config.
19045
- */
19046
- erc20Address?: Address;
19047
- /**
19048
- * The resolved registry contract address for the current chain.
19049
- * Included in the query key so that switching chains invalidates
19050
- * stale cached results. Pass `undefined` when the chain ID is not
19051
- * yet known — the query will be disabled.
19052
- */
19053
- registryAddress?: Address;
19054
- query?: Record<string, unknown>;
19055
- }
19056
- declare function wrapperDiscoveryQueryOptions(registry: WrappersRegistry, config: WrapperDiscoveryQueryConfig): QueryFactoryOptions<Address | null, Error, Address | null, ReturnType<typeof zamaQueryKeys.wrapperDiscovery.token>>;
19057
- //#endregion
19058
- //#region src/query/underlying-allowance.d.ts
19059
- interface UnderlyingAllowanceQueryConfig {
19060
- owner?: Address;
19061
- query?: Record<string, unknown>;
19062
- }
19063
- declare function underlyingAllowanceQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config: UnderlyingAllowanceQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.underlyingAllowance.scope>>;
19064
- //#endregion
19065
- //#region src/query/pending-unshield.d.ts
19066
- interface PendingUnshieldQueryConfig {
19067
- query?: Record<string, unknown>;
19068
- }
19069
- /**
19070
- * Query options for reading the unwrap tx hash of an unshield that was
19071
- * interrupted between its two phases (returns `null` if none is pending).
19072
- *
19073
- * Backed by {@link ZamaSDK} storage via `WrappedToken.getPendingUnshield()`.
19074
- * `staleTime: 0` so the value reflects storage on mount; the unshield/unwrap
19075
- * mutations also invalidate this key on success.
19076
- */
19077
- declare function pendingUnshieldQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: PendingUnshieldQueryConfig): QueryFactoryOptions<Hex | null, Error, Hex | null, ReturnType<typeof zamaQueryKeys.pendingUnshield.token>>;
19078
- //#endregion
19079
- //#region src/query/confidential-is-operator.d.ts
19080
- interface ConfidentialIsOperatorQueryConfig {
19081
- holder?: Address;
19082
- spender?: Address;
19083
- query?: Record<string, unknown>;
18835
+ handleWalletAccountChange(prev?: {
18836
+ address: Address;
18837
+ }, next?: {
18838
+ address: Address;
18839
+ }): Promise<void>;
19084
18840
  }
19085
- declare function confidentialIsOperatorQueryOptions(sdk: ZamaSDK, tokenAddress: Address | undefined, config: ConfidentialIsOperatorQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.confidentialIsOperator.scope>>;
19086
18841
  //#endregion
19087
18842
  //#region src/errors/base.d.ts
19088
18843
  /**
@@ -19101,35 +18856,65 @@ declare function confidentialIsOperatorQueryOptions(sdk: ZamaSDK, tokenAddress:
19101
18856
  * ```
19102
18857
  */
19103
18858
  declare const ZamaErrorCode: {
19104
- /** User rejected the wallet signature prompt. */readonly SigningRejected: "SIGNING_REJECTED"; /** Wallet signature failed for a reason other than rejection. */
19105
- readonly SigningFailed: "SIGNING_FAILED"; /** FHE encryption failed. */
19106
- readonly EncryptionFailed: "ENCRYPTION_FAILED"; /** FHE decryption failed. */
19107
- readonly DecryptionFailed: "DECRYPTION_FAILED"; /** On-chain transaction reverted. */
19108
- readonly TransactionReverted: "TRANSACTION_REVERTED"; /** Transport key pair has expired and needs regeneration. */
19109
- readonly TransportKeyPairExpired: "KEYPAIR_EXPIRED"; /** Relayer rejected transport key pair (stale, expired, or malformed). */
19110
- readonly InvalidTransportKeyPair: "INVALID_KEYPAIR"; /** No FHE ciphertext exists for this account (never shielded). */
19111
- readonly NoCiphertext: "NO_CIPHERTEXT"; /** Relayer HTTP request failed. */
19112
- readonly RelayerRequestFailed: "RELAYER_REQUEST_FAILED"; /** The configured signer/account is not entitled (ACL) to decrypt this encrypted value. Don't retry — wait for a grant. */
19113
- readonly NotEntitled: "NOT_ENTITLED"; /** The consumer's RPC provider rate-limited an on-chain read (e.g. HTTP 429 / JSON-RPC -32005). Retryable. */
19114
- readonly RpcRateLimited: "RPC_RATE_LIMITED"; /** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */
19115
- readonly Configuration: "CONFIGURATION"; /** Delegation cannot target self (delegate === msg.sender). */
19116
- readonly DelegationSelfNotAllowed: "DELEGATION_SELF_NOT_ALLOWED"; /** Only one delegate/revoke per (delegator, delegate, contract) per block. */
19117
- readonly DelegationCooldown: "DELEGATION_COOLDOWN"; /** No active delegation found for this (delegator, delegate, contract) tuple. */
19118
- readonly DelegationNotFound: "DELEGATION_NOT_FOUND"; /** The delegation has expired. */
19119
- readonly DelegationExpired: "DELEGATION_EXPIRED"; /** Confidential (cToken) balance is insufficient for the requested operation. */
19120
- readonly InsufficientConfidentialBalance: "INSUFFICIENT_CONFIDENTIAL_BALANCE"; /** ERC-20 balance is insufficient for the requested shield amount. */
19121
- readonly InsufficientERC20Balance: "INSUFFICIENT_ERC20_BALANCE"; /** Balance validation could not be performed (no cached credentials and decryption not possible). */
19122
- readonly BalanceCheckUnavailable: "BALANCE_CHECK_UNAVAILABLE"; /** Public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */
19123
- readonly ERC20ReadFailed: "ERC20_READ_FAILED"; /** The new expiration date equals the current one — no on-chain change needed. */
19124
- readonly DelegationExpiryUnchanged: "DELEGATION_EXPIRY_UNCHANGED"; /** Delegate address cannot be the contract address. */
19125
- readonly DelegationDelegateEqualsContract: "DELEGATION_DELEGATE_EQUALS_CONTRACT"; /** Contract address cannot be the sender address. */
19126
- readonly DelegationContractIsSelf: "DELEGATION_CONTRACT_IS_SELF"; /** The ACL contract is paused. */
19127
- readonly AclPaused: "ACL_PAUSED"; /** Expiration date is too soon (must be at least 1 hour in the future). */
19128
- readonly DelegationExpirationTooSoon: "DELEGATION_EXPIRATION_TOO_SOON"; /** Delegation exists on-chain but hasn't propagated to the gateway yet. */
19129
- readonly DelegationNotPropagated: "DELEGATION_NOT_PROPAGATED"; /** Signer and provider are connected to different chains. */
19130
- readonly ChainMismatch: "CHAIN_MISMATCH"; /** Operation requires a signer but none is configured. */
19131
- readonly SignerNotConfigured: "SIGNER_NOT_CONFIGURED"; /** Operation requires a connected wallet account. */
19132
- readonly WalletNotConnected: "WALLET_NOT_CONNECTED"; /** Wallet account discovery is still resolving. */
18859
+ /** User rejected the wallet signature prompt. */
18860
+ readonly SigningRejected: "SIGNING_REJECTED";
18861
+ /** Wallet signature failed for a reason other than rejection. */
18862
+ readonly SigningFailed: "SIGNING_FAILED";
18863
+ /** FHE encryption failed. */
18864
+ readonly EncryptionFailed: "ENCRYPTION_FAILED";
18865
+ /** FHE decryption failed. */
18866
+ readonly DecryptionFailed: "DECRYPTION_FAILED";
18867
+ /** On-chain transaction reverted. */
18868
+ readonly TransactionReverted: "TRANSACTION_REVERTED";
18869
+ /** Transport key pair has expired and needs regeneration. */
18870
+ readonly TransportKeyPairExpired: "KEYPAIR_EXPIRED";
18871
+ /** Relayer rejected transport key pair (stale, expired, or malformed). */
18872
+ readonly InvalidTransportKeyPair: "INVALID_KEYPAIR";
18873
+ /** No FHE ciphertext exists for this account (never shielded). */
18874
+ readonly NoCiphertext: "NO_CIPHERTEXT";
18875
+ /** Relayer HTTP request failed. */
18876
+ readonly RelayerRequestFailed: "RELAYER_REQUEST_FAILED";
18877
+ /** The configured signer/account is not entitled (ACL) to decrypt this encrypted value. Don't retry — wait for a grant. */
18878
+ readonly NotEntitled: "NOT_ENTITLED";
18879
+ /** The consumer's RPC provider rate-limited an on-chain read (e.g. HTTP 429 / JSON-RPC -32005). Retryable. */
18880
+ readonly RpcRateLimited: "RPC_RATE_LIMITED";
18881
+ /** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */
18882
+ readonly Configuration: "CONFIGURATION";
18883
+ /** Delegation cannot target self (delegate === msg.sender). */
18884
+ readonly DelegationSelfNotAllowed: "DELEGATION_SELF_NOT_ALLOWED";
18885
+ /** Only one delegate/revoke per (delegator, delegate, contract) per block. */
18886
+ readonly DelegationCooldown: "DELEGATION_COOLDOWN";
18887
+ /** No active delegation found for this (delegator, delegate, contract) tuple. */
18888
+ readonly DelegationNotFound: "DELEGATION_NOT_FOUND";
18889
+ /** The delegation has expired. */
18890
+ readonly DelegationExpired: "DELEGATION_EXPIRED";
18891
+ /** Confidential (cToken) balance is insufficient for the requested operation. */
18892
+ readonly InsufficientConfidentialBalance: "INSUFFICIENT_CONFIDENTIAL_BALANCE";
18893
+ /** ERC-20 balance is insufficient for the requested shield amount. */
18894
+ readonly InsufficientERC20Balance: "INSUFFICIENT_ERC20_BALANCE";
18895
+ /** Balance validation could not be performed (no cached credentials and decryption not possible). */
18896
+ readonly BalanceCheckUnavailable: "BALANCE_CHECK_UNAVAILABLE";
18897
+ /** Public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */
18898
+ readonly ERC20ReadFailed: "ERC20_READ_FAILED";
18899
+ /** The new expiration date equals the current one — no on-chain change needed. */
18900
+ readonly DelegationExpiryUnchanged: "DELEGATION_EXPIRY_UNCHANGED";
18901
+ /** Delegate address cannot be the contract address. */
18902
+ readonly DelegationDelegateEqualsContract: "DELEGATION_DELEGATE_EQUALS_CONTRACT";
18903
+ /** Contract address cannot be the sender address. */
18904
+ readonly DelegationContractIsSelf: "DELEGATION_CONTRACT_IS_SELF";
18905
+ /** The ACL contract is paused. */
18906
+ readonly AclPaused: "ACL_PAUSED";
18907
+ /** Expiration date is too soon (must be at least 1 hour in the future). */
18908
+ readonly DelegationExpirationTooSoon: "DELEGATION_EXPIRATION_TOO_SOON";
18909
+ /** Delegation exists on-chain but hasn't propagated to the gateway yet. */
18910
+ readonly DelegationNotPropagated: "DELEGATION_NOT_PROPAGATED";
18911
+ /** Signer and provider are connected to different chains. */
18912
+ readonly ChainMismatch: "CHAIN_MISMATCH";
18913
+ /** Operation requires a signer but none is configured. */
18914
+ readonly SignerNotConfigured: "SIGNER_NOT_CONFIGURED";
18915
+ /** Operation requires a connected wallet account. */
18916
+ readonly WalletNotConnected: "WALLET_NOT_CONNECTED";
18917
+ /** Wallet account discovery is still resolving. */
19133
18918
  readonly WalletAccountNotReady: "WALLET_ACCOUNT_NOT_READY";
19134
18919
  };
19135
18920
  /** Union of all {@link ZamaErrorCode} string values. */
@@ -19171,11 +18956,7 @@ declare class ChainMismatchError extends ZamaError {
19171
18956
  readonly operation: string;
19172
18957
  readonly signerChainId: number;
19173
18958
  readonly providerChainId: number;
19174
- constructor({
19175
- operation,
19176
- signerChainId,
19177
- providerChainId
19178
- }: {
18959
+ constructor({ operation, signerChainId, providerChainId }: {
19179
18960
  operation: string;
19180
18961
  signerChainId: number;
19181
18962
  providerChainId: number;
@@ -19518,1329 +19299,1161 @@ type ErrorForCode = Complete<{
19518
19299
  * });
19519
19300
  * ```
19520
19301
  */
19521
- declare function matchZamaError<R>(error: unknown, handlers: { [K in ZamaErrorCode]?: (error: ErrorForCode[K]) => R } & {
19302
+ declare function matchZamaError<R>(error: unknown, handlers: { [K in ZamaErrorCode]?: (error: ErrorForCode[K]) => R; } & {
19522
19303
  _?: (error: unknown) => R;
19523
19304
  }): R | undefined;
19524
19305
  //#endregion
19525
- //#region src/token/token.d.ts
19526
- /** Options for {@link Token.batchDecryptBalancesAs}. */
19527
- interface BatchDecryptAsOptions {
19528
- /** The address of the account that delegated decryption rights. */
19529
- delegatorAddress: Address;
19530
- /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */
19531
- encryptedValues?: EncryptedValue[];
19306
+ //#region src/services/caching-service.d.ts
19307
+ /**
19308
+ * Storage-backed cache for decrypted FHE plaintext values.
19309
+ *
19310
+ * Each entry is keyed by `(requester, contractAddress, handle)` so different
19311
+ * signers cannot read each other's cached decryptions.
19312
+ */
19313
+ declare class CachingService {
19314
+ #private;
19315
+ constructor(storage: GenericStorage, logger: GenericLogger);
19316
+ get(requester: Address, contractAddress: Address, encryptedValue: EncryptedValue): Promise<ClearValue | null>;
19317
+ set(requester: Address, contractAddress: Address, encryptedValue: EncryptedValue, value: ClearValue): Promise<void>;
19318
+ delete(requester: Address, contractAddress: Address, encryptedValue: EncryptedValue): Promise<void>;
19319
+ clearForRequester(requester: Address): Promise<void>;
19320
+ clearAll(): Promise<void>;
19321
+ }
19322
+ //#endregion
19323
+ //#region src/services/delegation-service.d.ts
19324
+ declare class DelegationService {
19325
+ #private;
19326
+ constructor({ provider, router, emitEvent, logger }: {
19327
+ provider: GenericProvider;
19328
+ router: ChainRouter;
19329
+ logger: GenericLogger;
19330
+ emitEvent?: (input: ZamaSDKEventInput, tokenAddress?: Address) => void;
19331
+ });
19332
+ delegateDecryption(signer: GenericSigner, { contractAddress, delegateAddress, delegatorAddress, expirationDate }: {
19333
+ contractAddress: Address;
19334
+ delegateAddress: Address;
19335
+ delegatorAddress: Address;
19336
+ expirationDate?: Date;
19337
+ }): Promise<TransactionResult>;
19338
+ revokeDelegation(signer: GenericSigner, { contractAddress, delegateAddress, delegatorAddress }: {
19339
+ contractAddress: Address;
19340
+ delegateAddress: Address;
19341
+ delegatorAddress: Address;
19342
+ }): Promise<TransactionResult>;
19343
+ isDelegated(params: {
19344
+ contractAddress: Address;
19345
+ delegatorAddress: Address;
19346
+ delegateAddress: Address;
19347
+ }): Promise<boolean>;
19348
+ getDelegationExpiry({ contractAddress, delegatorAddress, delegateAddress }: {
19349
+ contractAddress: Address;
19350
+ delegatorAddress: Address;
19351
+ delegateAddress: Address;
19352
+ }): Promise<bigint>;
19353
+ findInactiveDelegations(contractAddresses: readonly Address[], delegatorAddress: Address, delegateAddress: Address): Promise<Map<Address, DelegationNotFoundError | DelegationExpiredError>>;
19354
+ assertDelegationActive(contractAddress: Address, delegatorAddress: Address, delegateAddress: Address): Promise<void>;
19355
+ }
19356
+ //#endregion
19357
+ //#region src/services/decryption-service.d.ts
19358
+ /** Options shared by the delegated-decrypt entry points. */
19359
+ interface DelegatedDecryptOptions {
19532
19360
  /**
19533
- * The account whose on-chain balance to read. Defaults to the delegator
19534
- * address, which is the common case (the delegator grants permission to
19535
- * decrypt their own balance). Only set this when the account differs
19536
- * from the delegator.
19537
- *
19538
- * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.
19361
+ * Ride out the gateway propagation window: when a just-granted delegation
19362
+ * has not yet synced, the delegated decrypt is retried (bounded, ~30s) until
19363
+ * it lands instead of throwing {@link DelegationNotPropagatedError}. Defaults
19364
+ * to `true`. Pass `false` to fail fast on the first not-propagated response.
19539
19365
  */
19540
- accountAddress?: Address;
19541
- /** Maximum number of concurrent decrypt calls. Default: 10. */
19542
- maxConcurrency?: number;
19543
- /** Called when decryption fails for a single token. Return a fallback bigint. */
19544
- onError?: (error: Error, address: Address) => bigint;
19366
+ waitForPropagation?: boolean;
19545
19367
  }
19546
- /** Result of {@link Token.batchBalancesOf}. */
19547
- interface BatchBalancesResult {
19548
- /** Successfully decrypted balances, keyed by token address. */
19549
- results: Map<Address, bigint>;
19550
- /** Per-token errors for tokens that failed to decrypt. */
19551
- errors: Map<Address, ZamaError>;
19368
+ interface BatchDecryptItem {
19369
+ encryptedValue: EncryptedValue;
19370
+ contractAddress: Address;
19371
+ value?: ClearValue;
19372
+ error?: ZamaError;
19373
+ }
19374
+ interface BatchDecryptResult {
19375
+ items: BatchDecryptItem[];
19376
+ }
19377
+ declare class DecryptionService {
19378
+ #private;
19379
+ constructor({ cache, credentialService, delegationService, router, emitEvent }: {
19380
+ cache: CachingService;
19381
+ credentialService: CredentialService;
19382
+ delegationService: DelegationService;
19383
+ router: ChainRouter;
19384
+ emitEvent: (input: ZamaSDKEventInput) => void;
19385
+ });
19386
+ decryptValues(handles: EncryptedInput[], signerAddress: Address, opts?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<Record<EncryptedValue, ClearValue>>;
19387
+ delegatedDecryptValues(encryptedInputs: EncryptedInput[], delegatorAddress: Address, delegateAddress: Address, accountAddress: Address, opts?: DelegatedDecryptOptions): Promise<Record<EncryptedValue, ClearValue>>;
19388
+ delegatedBatchDecryptHandlesAs({ encryptedInputs, delegatorAddress, delegateAddress, accountAddress, maxConcurrency, waitForPropagation }: {
19389
+ encryptedInputs: EncryptedInput[];
19390
+ delegatorAddress: Address;
19391
+ delegateAddress: Address;
19392
+ accountAddress: Address;
19393
+ maxConcurrency?: number;
19394
+ waitForPropagation?: boolean;
19395
+ }): Promise<BatchDecryptResult>;
19552
19396
  }
19397
+ //#endregion
19398
+ //#region src/namespaces/decryption.d.ts
19553
19399
  /**
19554
- * High-level interface for an ERC-7984 confidential token.
19555
- * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind
19556
- * familiar ERC-20-like methods.
19400
+ * Public namespace for FHE decryption — the canonical way to decrypt.
19557
19401
  *
19558
- * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —
19559
- * it extends `Token` with wrapper-specific operations.
19402
+ * Exposed as `sdk.decryption`. Prefer these methods over the low-level
19403
+ * `sdk.relayer.decryptValues` / `decryptPublicValues`: they
19404
+ * assemble the credential bundle (transport key pair, EIP-712 permit) for you,
19405
+ * cache results, and wrap relayer errors. Reach for `sdk.relayer.*` only when
19406
+ * you must control credential assembly by hand.
19560
19407
  *
19561
- * Decryption, credentials, caching, and event emission are handled by the
19562
- * owning {@link ZamaSDK} — this class only exposes token-scoped helpers
19563
- * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.
19408
+ * Owns the SDK-level guards (signer requirement on
19409
+ * `decryptValues` and `delegatedDecryptValues`, empty-array
19410
+ * short-circuit on `decryptPublicValues`, relayer error wrapping) and delegates the
19411
+ * actual work to the internal {@link DecryptionService} or the relayer directly for
19412
+ * `decryptPublicValues`.
19413
+ *
19414
+ * **Mixed signer requirement:** `decryptValues` and
19415
+ * `delegatedDecryptValues` need a configured signer; `decryptPublicValues`
19416
+ * does not. Each method documents its requirement in its JSDoc.
19417
+ *
19418
+ * **Request chunking:** decrypt requests are split internally to stay under
19419
+ * the relayer's 2048-cleartext-bit per-request budget — callers never need to
19420
+ * size batches themselves.
19564
19421
  */
19565
- declare class Token {
19422
+ declare class Decryption {
19566
19423
  #private;
19567
- readonly sdk: ZamaSDK;
19568
- readonly address: Address;
19569
- constructor(sdk: ZamaSDK, address: Address);
19570
- /** Read the token name from the contract. */
19571
- name(): Promise<string>;
19572
- /** Read the token symbol from the contract. */
19573
- symbol(): Promise<string>;
19574
- /** Read the token decimals from the contract. */
19575
- decimals(): Promise<number>;
19576
- /**
19577
- * ERC-165 check for {@link ERC7984_INTERFACE_ID} support.
19578
- *
19579
- * @returns `true` if the contract implements the ERC-7984 confidential token interface.
19580
- */
19581
- isConfidential(): Promise<boolean>;
19424
+ /** @internal */
19425
+ constructor(opts: {
19426
+ signer: GenericSigner | undefined;
19427
+ provider: GenericProvider;
19428
+ router: ChainRouter;
19429
+ decryptionService: DecryptionService | undefined;
19430
+ });
19582
19431
  /**
19583
- * ERC-165 check for IERC7984ERC20Wrapper support.
19432
+ * Decrypt one or more FHE encrypted values. Results are cached — repeated calls
19433
+ * for the same encrypted value skip the relayer round-trip.
19584
19434
  *
19585
- * @returns `true` if the contract implements the ERC-7984 wrapper interface
19586
- * ({@link ERC7984_WRAPPER_INTERFACE_ID}, `0x1f1c62b2`).
19587
- */
19588
- isWrapper(): Promise<boolean>;
19589
- /**
19590
- * Decrypt and return the plaintext balance for the given owner.
19591
- * Acquires FHE credentials via a wallet signature if none are cached.
19435
+ * Zero encrypted values are mapped to `0n` without hitting the relayer.
19436
+ * Events (`DecryptStart/End/Error`) are emitted uniformly.
19437
+ * Relayer errors are wrapped into typed SDK errors.
19592
19438
  *
19593
- * @param owner - Balance owner address.
19594
- * @returns The decrypted plaintext balance as a bigint.
19595
- * @throws if FHE decryption fails. {@link DecryptionFailedError}
19439
+ * @param encryptedInput - Encrypted values to decrypt, each paired with its contract address.
19440
+ * @param options - Per-call `signal` and `timeout` forwarded to the relayer round-trip.
19441
+ * @returns A record mapping each encrypted value to its decrypted clear-text value.
19442
+ * @throws if no signer is configured. {@link SignerNotConfiguredError}
19443
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
19596
19444
  *
19597
19445
  * @example
19598
19446
  * ```ts
19599
- * const balance = await token.balanceOf("0xOwner");
19447
+ * const values = await sdk.decryption.decryptValues([
19448
+ * { encryptedValue: balance, contractAddress: cUSDT },
19449
+ * ]);
19450
+ * console.log(values[balance]); // 1000n
19600
19451
  * ```
19601
19452
  */
19602
- balanceOf(owner: Address): Promise<bigint>;
19453
+ decryptValues(encryptedInput: EncryptedInput[], options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<Record<EncryptedValue, ClearValue>>;
19603
19454
  /**
19604
- * Return the raw encrypted balance without decrypting.
19455
+ * Decrypt one or more FHE encrypted values using delegated credentials.
19605
19456
  *
19606
- * @param owner - Balance owner address.
19607
- * @returns The encrypted balance as a hex string.
19457
+ * Mirrors {@link decryptValues} with delegated credentials — same caching and
19458
+ * zero-value short-circuit. Before reading from cache or calling the relayer,
19459
+ * every non-zero encrypted value's contract must have an active delegation from the
19460
+ * delegator to the connected signer; missing or expired delegations fail fast.
19461
+ *
19462
+ * @param encryptedInputs - FHE encrypted values paired with their contract addresses.
19463
+ * @param delegatorAddress - The address that granted delegation rights.
19464
+ * @param accountAddress - Address used as the cache key's "requester"
19465
+ * dimension. Defaults to `delegatorAddress`. Pass the actual account address
19466
+ * when decrypting on behalf of someone whose balance is stored under a
19467
+ * different address (e.g. `decryptBalanceAs` with an explicit `accountAddress`).
19468
+ * @param options - Delegated-decrypt options. By default the call rides out the
19469
+ * gateway propagation window ({@link DelegatedDecryptOptions.waitForPropagation});
19470
+ * pass `{ waitForPropagation: false }` to fail fast instead.
19471
+ * @returns Map of encrypted value → clear-text value.
19608
19472
  *
19609
19473
  * @example
19610
19474
  * ```ts
19611
- * const encryptedValue = await token.confidentialBalanceOf("0xOwner");
19475
+ * const values = await sdk.decryption.delegatedDecryptValues([
19476
+ * { encryptedValue: balance, contractAddress: tokenAddr },
19477
+ * ], delegatorAddr);
19478
+ * console.log(values[balance]); // 1000n
19612
19479
  * ```
19613
19480
  */
19614
- confidentialBalanceOf(owner: Address): Promise<EncryptedValue>;
19481
+ delegatedDecryptValues(encryptedInputs: EncryptedInput[], delegatorAddress: Address, accountAddress?: Address, options?: DelegatedDecryptOptions): Promise<Record<EncryptedValue, ClearValue>>;
19615
19482
  /**
19616
- * Decrypt the balance of a delegator using delegated decryption credentials.
19617
- * The connected signer acts as the delegatee who has been granted permission
19618
- * by the delegator to decrypt their balance.
19483
+ * Publicly decrypt one or more FHE encrypted values.
19619
19484
  *
19620
- * Clear values are cached in storage keyed by `(account, token, encryptedValue)`.
19621
- * Because every on-chain balance change produces a new encrypted value,
19622
- * stale cache entries are never served. Cache write failures are silently
19623
- * ignored — they do not affect the returned value.
19624
- *
19625
- * @param delegatorAddress - The address of the account that delegated decryption rights.
19626
- * @param accountAddress - The account whose on-chain balance to read. Defaults
19627
- * to the delegator address.
19628
- * @returns The decrypted plaintext balance as a bigint.
19629
- * @throws if no active delegation exists. {@link DelegationNotFoundError}
19630
- * @throws if the delegation has expired. {@link DelegationExpiredError}
19631
- * @throws if delegated decryption fails. {@link DecryptionFailedError}
19632
- *
19633
- * @example
19634
- * ```ts
19635
- * const balance = await token.decryptBalanceAs({
19636
- * delegatorAddress: "0xDelegator",
19637
- * });
19638
- * ```
19639
- */
19640
- decryptBalanceAs({
19641
- delegatorAddress,
19642
- accountAddress
19643
- }: {
19644
- delegatorAddress: Address;
19645
- accountAddress?: Address;
19646
- }): Promise<bigint>;
19647
- /**
19648
- * Decrypt confidential balances for multiple tokens in parallel, returning
19649
- * successes and per-token errors separately. Pre-authorizes all token
19650
- * addresses in a single wallet signature, then delegates each decrypt to
19651
- * `sdk.decryption.decryptValues`.
19652
- *
19653
- * Tokens that fail to decrypt land in `errors` rather than aborting the
19654
- * whole batch — caller decides how to surface them.
19485
+ * Signer-independent: works without a configured signer.
19486
+ * Returns the decryption proof alongside the clear-text values so callers
19487
+ * can submit on-chain finalization transactions (e.g. `finalizeUnwrap`).
19655
19488
  *
19656
- * @param tokens - Array of {@link Token} instances bound to the same SDK.
19657
- * @param owner - Balance owner address.
19658
- * @returns `{ results, errors }` partitioning the per-token outcomes.
19489
+ * @param encryptedValues - FHE encrypted values to decrypt publicly.
19490
+ * @param options - Per-call `signal` and `timeout` forwarded to the relayer round-trip.
19491
+ * @returns Clear-text values, ABI-encoded values, and the decryption proof.
19659
19492
  *
19660
19493
  * @example
19661
19494
  * ```ts
19662
- * const { results, errors } = await Token.batchBalancesOf(tokens, owner);
19495
+ * const { clearValues, decryptionProof, abiEncodedClearValues } =
19496
+ * await sdk.decryption.decryptPublicValues([encryptedValue]);
19663
19497
  * ```
19664
19498
  */
19665
- static batchBalancesOf(tokens: Token[], owner: Address): Promise<BatchBalancesResult>;
19499
+ decryptPublicValues(encryptedValues: EncryptedValue[], options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<DecryptPublicValuesResult>;
19666
19500
  /**
19667
- * Batch decrypt confidential balances as a delegate across multiple tokens.
19668
- * Mirrors {@link batchBalancesOf} but uses delegated credentials.
19501
+ * Batch-decrypt delegated encrypted values with per-entry error isolation.
19669
19502
  *
19670
- * **Error handling:** If a per-token decryption fails and no `onError` callback
19671
- * is provided, errors are collected and thrown as an aggregated
19672
- * `DecryptionFailedError`. When the relayer returns no value for an encrypted value,
19673
- * a `DecryptionFailedError` is thrown for that token (never silently returns `0n`).
19674
- * Pass `onError: () => 0n` to opt into the silent zero behavior.
19503
+ * Attempts a single batch request first. If the batch fails with a non-fatal
19504
+ * error (e.g. one entry is invalid), falls back to per-entry decryption so
19505
+ * healthy entries still resolve. Each item in the result carries either a
19506
+ * decrypted value or an error — callers decide how to surface partial failures.
19675
19507
  *
19676
- * @param tokens - Array of Token instances to decrypt balances for.
19677
- * @param options - Delegated decryption configuration.
19678
- * @returns A Map from token address to decrypted balance.
19679
- * @throws if no active delegation exists. {@link DelegationNotFoundError}
19680
- * @throws if the delegation has expired. {@link DelegationExpiredError}
19681
- * @throws if any decryption fails and no `onError` is provided. {@link DecryptionFailedError}
19508
+ * @param encryptedInputs - FHE encrypted values paired with their contract addresses.
19509
+ * @param delegatorAddress - The address that granted delegation rights.
19510
+ * @param accountAddress - The account on whose behalf decryption is performed. Defaults to `delegatorAddress`.
19511
+ * @param maxConcurrency - Maximum parallel decrypt calls during per-entry fallback.
19512
+ * @param waitForPropagation - Ride out the gateway propagation window on the
19513
+ * initial batch attempt (default `true`). See {@link DelegatedDecryptOptions.waitForPropagation}.
19514
+ * @returns Per-entry results, each with a value or an error.
19515
+ * @throws if no signer is configured. {@link SignerNotConfiguredError}
19516
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
19682
19517
  *
19683
19518
  * @example
19684
19519
  * ```ts
19685
- * const balances = await Token.batchDecryptBalancesAs(tokens, {
19520
+ * const result = await sdk.decryption.delegatedBatchDecryptValues({
19521
+ * encryptedInputs: [
19522
+ * { encryptedValue: encryptedValue1, contractAddress: tokenA },
19523
+ * { encryptedValue: encryptedValue2, contractAddress: tokenB },
19524
+ * ],
19686
19525
  * delegatorAddress: "0xDelegator",
19687
- * onError: (err, addr) => { console.error(addr, err); return 0n; },
19526
+ * maxConcurrency: 5,
19688
19527
  * });
19528
+ * for (const item of result.items) {
19529
+ * if (item.error) console.error(item.encryptedValue, item.error);
19530
+ * else console.log(item.encryptedValue, item.value);
19531
+ * }
19689
19532
  * ```
19690
19533
  */
19691
- static batchDecryptBalancesAs(tokens: Token[], options: BatchDecryptAsOptions): Promise<Map<Address, bigint>>;
19692
- private static readBalanceHandlesBatch;
19534
+ delegatedBatchDecryptValues({ encryptedInputs, delegatorAddress, accountAddress, maxConcurrency, waitForPropagation }: {
19535
+ encryptedInputs: EncryptedInput[];
19536
+ delegatorAddress: Address;
19537
+ accountAddress?: Address;
19538
+ maxConcurrency?: number;
19539
+ } & DelegatedDecryptOptions): Promise<BatchDecryptResult>;
19540
+ }
19541
+ //#endregion
19542
+ //#region src/namespaces/delegations.d.ts
19543
+ /**
19544
+ * Public namespace for on-chain decryption-delegation management.
19545
+ *
19546
+ * Exposed as `sdk.delegations`. Owns the SDK-level guards (signer requirement, chain
19547
+ * alignment, delegator address resolution from the wallet account) and delegates the
19548
+ * actual work to the internal {@link DelegationService}.
19549
+ *
19550
+ * Delegation operations write to the host chain ACL; after a delegation is mined,
19551
+ * the gateway syncs the ACL state via cross-chain event propagation — usually
19552
+ * within ~10 blocks (a few seconds). Delegated decryption rides out that window
19553
+ * with a bounded internal retry, so callers can decrypt right after granting.
19554
+ */
19555
+ declare class Delegations {
19556
+ #private;
19557
+ /** @internal */
19558
+ constructor(opts: {
19559
+ signer: GenericSigner | undefined;
19560
+ provider: GenericProvider;
19561
+ delegationService: DelegationService;
19562
+ });
19693
19563
  /**
19694
- * Confidential transfer. Encrypts the amount via FHE, then calls the contract.
19564
+ * Delegate decryption rights for a confidential contract to another address.
19565
+ * Calls `ACL.delegateForUserDecryption()` on-chain.
19695
19566
  *
19696
- * By default, the SDK validates the confidential balance before submitting.
19697
- * If a cached plaintext balance exists it is used; otherwise, if credentials
19698
- * are cached, it decrypts on the fly. Set `skipBalanceCheck: true` to bypass
19699
- * this validation (e.g. for smart wallets).
19567
+ * The delegation is recorded on L1 immediately, but the gateway must sync the
19568
+ * ACL state via cross-chain event propagation — usually within ~10 blocks (a
19569
+ * few seconds). You do not need to wait: delegated decryption rides out that
19570
+ * window with a bounded internal retry, so you can decrypt right after this
19571
+ * resolves.
19700
19572
  *
19701
- * @param to - Recipient address.
19702
- * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
19703
- * @param options - Optional: `skipBalanceCheck` (default `false`).
19573
+ * @param contractAddress - The confidential contract address to delegate on.
19574
+ * @param delegateAddress - Address to delegate decryption rights to.
19575
+ * @param expirationDate - Optional expiration date (defaults to permanent delegation via `uint64.max`).
19704
19576
  * @returns The transaction hash and mined receipt.
19577
+ * @throws if no signer is configured. {@link SignerNotConfiguredError}
19705
19578
  * @throws if signer and provider are on different chains. {@link ChainMismatchError}
19706
- * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
19707
- * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
19708
- * @throws if FHE encryption fails. {@link EncryptionFailedError}
19709
- * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
19710
- *
19711
- * @example
19712
- * ```ts
19713
- * const txHash = await token.confidentialTransfer("0xRecipient", 1000n);
19714
- * ```
19715
- */
19716
- confidentialTransfer(to: Address, amount: bigint, options?: TransferOptions): Promise<TransactionResult>;
19717
- /**
19718
- * Operator encrypted transfer on behalf of another address.
19719
- * The caller must be an approved operator for `from`.
19720
- *
19721
- * @param from - The address to transfer from (caller must be an approved operator).
19722
- * @param to - Recipient address.
19723
- * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
19724
- * @returns The transaction hash and mined receipt.
19725
- *
19726
- * @example
19727
- * ```ts
19728
- * const txHash = await token.confidentialTransferFrom("0xFrom", "0xTo", 500n);
19729
- * ```
19579
+ * @throws if `expirationDate` is less than 1 hour in the future. {@link DelegationExpirationTooSoonError}
19580
+ * @throws if the delegate equals the connected wallet. {@link DelegationSelfNotAllowedError}
19581
+ * @throws if the delegate equals the contract address. {@link DelegationDelegateEqualsContractError}
19582
+ * @throws if the new expiry equals the current one. {@link DelegationExpiryUnchangedError}
19583
+ * @throws if the delegation transaction reverts. {@link TransactionRevertedError}
19730
19584
  */
19731
- confidentialTransferFrom(from: Address, to: Address, amount: bigint, callbacks?: TransferCallbacks): Promise<TransactionResult>;
19585
+ delegateDecryption({ contractAddress, delegateAddress, expirationDate }: {
19586
+ contractAddress: Address;
19587
+ delegateAddress: Address;
19588
+ expirationDate?: Date;
19589
+ }): Promise<TransactionResult>;
19732
19590
  /**
19733
- * ERC-7984 `confidentialTransferAndCall`: encrypted transfer that also invokes
19734
- * the recipient's receiver hook (`onConfidentialTransferReceived`) in a single
19735
- * transaction. The caller crafts the opaque `data` payload — the SDK does not
19736
- * encode, validate, or interpret it.
19737
- *
19738
- * Balance validation follows the same rules as {@link Token.confidentialTransfer}.
19591
+ * Revoke decryption delegation for a confidential contract.
19592
+ * Calls `ACL.revokeDelegationForUserDecryption()` on-chain.
19739
19593
  *
19740
- * @param to - Recipient address. Must implement the ERC-7984 receiver hook.
19741
- * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
19742
- * @param data - Opaque bytes forwarded to the recipient's receiver hook.
19743
- * @param options - Optional: `skipBalanceCheck` (default `false`).
19594
+ * @param contractAddress - The confidential contract address to revoke delegation on.
19595
+ * @param delegateAddress - Address to revoke delegation from.
19744
19596
  * @returns The transaction hash and mined receipt.
19745
- *
19597
+ * @throws if no signer is configured. {@link SignerNotConfiguredError}
19746
19598
  * @throws if signer and provider are on different chains. {@link ChainMismatchError}
19747
- * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
19748
- * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
19749
- * @throws if FHE encryption fails. {@link EncryptionFailedError}
19750
- * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
19751
- *
19752
- * @example
19753
- * ```ts
19754
- * const txHash = await token.confidentialTransferAndCall(
19755
- * "0xRecipient",
19756
- * 1000n,
19757
- * "0xabcd", // caller-encoded payload forwarded to the receiver hook
19758
- * );
19759
- * ```
19599
+ * @throws if no delegation exists for this (delegator, delegate, contract) tuple. {@link DelegationNotFoundError}
19600
+ * @throws if the revocation transaction reverts. {@link TransactionRevertedError}
19760
19601
  */
19761
- confidentialTransferAndCall(to: Address, amount: bigint, data: Hex, options?: TransferOptions): Promise<TransactionResult>;
19602
+ revokeDelegation({ contractAddress, delegateAddress }: {
19603
+ contractAddress: Address;
19604
+ delegateAddress: Address;
19605
+ }): Promise<TransactionResult>;
19762
19606
  /**
19763
- * ERC-7984 `confidentialTransferFromAndCall`: operator-initiated encrypted
19764
- * transfer that also invokes the recipient's receiver hook in a single
19765
- * transaction. The caller must be an approved operator for `from` and crafts
19766
- * the opaque `data` payload — the SDK does not encode or interpret it.
19607
+ * Check whether a delegation is active for the given contract address.
19767
19608
  *
19768
- * @param from - The address to transfer from (caller must be an approved operator).
19769
- * @param to - Recipient address. Must implement the ERC-7984 receiver hook.
19770
- * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
19771
- * @param data - Opaque bytes forwarded to the recipient's receiver hook.
19772
- * @param callbacks - Optional progress callbacks.
19773
- * @returns The transaction hash and mined receipt.
19609
+ * Signer-independent: works without a configured signer.
19774
19610
  *
19775
- * @example
19776
- * ```ts
19777
- * const txHash = await token.confidentialTransferFromAndCall(
19778
- * "0xFrom",
19779
- * "0xRecipient",
19780
- * 500n,
19781
- * "0xabcd",
19782
- * );
19783
- * ```
19611
+ * @param contractAddress - The confidential contract address.
19612
+ * @param delegatorAddress - The address that granted the delegation.
19613
+ * @param delegateAddress - The address that received delegation rights.
19614
+ * @returns `true` if the delegation exists and has not expired.
19784
19615
  */
19785
- confidentialTransferFromAndCall(from: Address, to: Address, amount: bigint, data: Hex, callbacks?: TransferCallbacks): Promise<TransactionResult>;
19616
+ isActive(params: {
19617
+ contractAddress: Address;
19618
+ delegatorAddress: Address;
19619
+ delegateAddress: Address;
19620
+ }): Promise<boolean>;
19786
19621
  /**
19787
- * Set operator approval for the confidential token.
19788
- * Defaults to 1 hour from now if `until` is not specified.
19622
+ * Get the expiration timestamp of a delegation for the given contract.
19789
19623
  *
19790
- * @param operator - The address to set as an operator.
19791
- * @param until - Optional Unix timestamp for approval expiry. Defaults to now + 1 hour.
19792
- * @returns The transaction hash and mined receipt.
19624
+ * Signer-independent: works without a configured signer.
19793
19625
  *
19794
- * @example
19795
- * ```ts
19796
- * const txHash = await token.setOperator("0xOperator");
19797
- * ```
19626
+ * @param contractAddress - The confidential contract address.
19627
+ * @param delegatorAddress - The address that granted the delegation.
19628
+ * @param delegateAddress - The address that received delegation rights.
19629
+ * @returns Unix timestamp as bigint. `0n` = no delegation. `2^64 - 1` = permanent.
19798
19630
  */
19799
- setOperator(operator: Address, until?: number): Promise<TransactionResult>;
19800
- /**
19801
- * Check if a spender is an approved operator for a given holder.
19802
- *
19803
- * @param holder - The token holder address.
19804
- * @param spender - The address to check operator approval for.
19805
- * @returns `true` if the spender is an approved operator for the holder.
19806
- *
19807
- * @example
19808
- * ```ts
19809
- * if (await token.isOperator("0xHolder", "0xSpender")) {
19810
- * // spender can call transferFrom on behalf of holder
19811
- * }
19812
- * ```
19631
+ getExpiry(params: {
19632
+ contractAddress: Address;
19633
+ delegatorAddress: Address;
19634
+ delegateAddress: Address;
19635
+ }): Promise<bigint>;
19636
+ }
19637
+ //#endregion
19638
+ //#region src/namespaces/permits.d.ts
19639
+ /**
19640
+ * Public namespace for permit and transport-key-pair management.
19641
+ *
19642
+ * Exposed as `sdk.permits`. Owns the SDK-level guards (chain alignment, empty-array
19643
+ * short-circuit, decrypt-cache invalidation) and delegates the actual work to the
19644
+ * internal {@link CredentialService}.
19645
+ *
19646
+ * The namespace is named `permits` because the user-facing concept is the signed-permit
19647
+ * store. The transport key pair is invisible plumbing — there is no `getTransportKeyPair()`
19648
+ * surfaced; the key pair exists to sign permits and is created automatically when needed.
19649
+ * {@link clear} wipes both the permit store and the transport key pair (permits
19650
+ * cascade-delete with the key pair).
19651
+ */
19652
+ declare class Permits {
19653
+ #private;
19654
+ /** @internal */
19655
+ constructor(opts: {
19656
+ signer: GenericSigner | undefined;
19657
+ provider: GenericProvider;
19658
+ cachingService: CachingService;
19659
+ credentialService: CredentialService | undefined;
19660
+ logger: GenericLogger;
19661
+ });
19662
+ /**
19663
+ * Sign and store an EIP-712 permit authorising direct decryption for the
19664
+ * given contract addresses.
19665
+ *
19666
+ * Idempotent: if a permit covering the requested set already exists, no
19667
+ * wallet prompt occurs. Otherwise the SDK chunks the uncovered subset into
19668
+ * groups of ≤10 contracts and prompts once per chunk; partial mid-flight
19669
+ * rejection is preserved (already-signed chunks are persisted before the
19670
+ * next prompt).
19671
+ *
19672
+ * @param contracts - Contract addresses to authorize.
19813
19673
  */
19814
- isOperator(holder: Address, spender: Address): Promise<boolean>;
19674
+ grantPermit(contracts: Address[]): Promise<void>;
19815
19675
  /**
19816
- * Read the on-chain encrypted balance for a given owner.
19676
+ * Sign and store an EIP-712 delegation permit authorising decryption on
19677
+ * behalf of `delegator`. Same idempotence/chunking semantics as {@link grantPermit}.
19817
19678
  *
19818
- * @internal
19679
+ * @param delegator - The address that delegated decryption rights to the connected signer.
19680
+ * @param contracts - Contract addresses to authorize.
19819
19681
  */
19820
- protected readConfidentialBalanceOf(owner: Address): Promise<EncryptedValue>;
19682
+ grantDelegationPermit(delegator: Address, contracts: Address[]): Promise<void>;
19821
19683
  /**
19822
- * Pre-flight check: decrypt the confidential balance and compare against the
19823
- * requested amount. If credentials are cached the decrypt happens silently;
19824
- * if not, throws {@link BalanceCheckUnavailableError} instead of triggering
19825
- * a surprise EIP-712 popup.
19684
+ * Pure store lookup: is there a permit covering `contracts`?
19685
+ * No wallet prompt, no transport key pair generation. Returns `false` when no signer
19686
+ * is configured.
19687
+ */
19688
+ hasPermit(contracts: Address[]): Promise<boolean>;
19689
+ /**
19690
+ * Pure store lookup for a delegation permit. See {@link hasPermit}.
19826
19691
  *
19827
- * @internal
19692
+ * @param delegator - The address that delegated decryption rights to the connected signer.
19693
+ * @param contracts - Contract addresses to check.
19694
+ * @returns `true` if cached delegation permits cover all requested contracts.
19828
19695
  */
19829
- protected assertConfidentialBalance(amount: bigint): Promise<void>;
19696
+ hasDelegationPermit(delegator: Address, contracts: Address[]): Promise<boolean>;
19830
19697
  /**
19831
- * Emit a token-scoped event through the owning {@link ZamaSDK} so that
19832
- * subscribers see a unified stream.
19698
+ * Best-effort transport-key-pair prefetch for the connected signer.
19833
19699
  *
19834
- * @internal
19700
+ * Optional latency optimization: decrypt and permit flows remain correct
19701
+ * without it because they lazily create the transport key pair when needed.
19702
+ *
19703
+ * Silent no-op when no signer is configured or no wallet account is
19704
+ * available. The transport key pair is generated through the relayer dispatcher's
19705
+ * currently active chain — see {@link LifecycleService}, which calls
19706
+ * `switchChain` before fanning the wallet-account change out to listeners,
19707
+ * so any downstream caller (including React adapters) observes the
19708
+ * dispatcher on the wallet chain by the time it invokes warmup.
19835
19709
  */
19836
- protected emit(input: ZamaSDKEventInput): void;
19710
+ warmTransportKeyPair(): Promise<void>;
19837
19711
  /**
19838
- * Submit a token-scoped write transaction through the shared SDK transaction
19839
- * pipeline. Callers keep pre-flight and operation-specific work local.
19712
+ * Wipe FHE permits for the current signer.
19840
19713
  *
19841
- * @internal
19714
+ * - With no argument: every permit referencing this signer is removed across
19715
+ * all chains and delegators. The transport key pair survives — use {@link clear} to
19716
+ * also wipe the transport key pair.
19717
+ * - With a contract list: every signed permit in the direct-decrypt scope
19718
+ * (current chain) whose immutable payload touches any listed address is
19719
+ * removed. Delegation permits are not touched in this mode.
19720
+ *
19721
+ * @throws if no signer is configured. {@link SignerNotConfiguredError}
19842
19722
  */
19843
- protected submitTransaction(params: {
19844
- operation: TransactionOperation;
19845
- config: WriteContractConfig;
19846
- onSubmitted?: (txHash: Hex) => void;
19847
- }): Promise<TransactionResult>;
19848
- /** Verify all tokens share the same SDK instance and return it. */
19849
- private static assertSameSdk;
19723
+ revokePermits(contracts?: Address[]): Promise<void>;
19724
+ /**
19725
+ * Wipe the transport key pair for the current signer and cascade-delete every permit
19726
+ * (across chains and delegators) referencing it.
19727
+ *
19728
+ * @throws if no signer is configured. {@link SignerNotConfiguredError}
19729
+ */
19730
+ clear(): Promise<void>;
19850
19731
  }
19851
19732
  //#endregion
19852
- //#region src/token/wrapped-token.d.ts
19733
+ //#region src/token/token.d.ts
19734
+ /** Options for {@link Token.batchDecryptBalancesAs}. */
19735
+ interface BatchDecryptAsOptions {
19736
+ /** The address of the account that delegated decryption rights. */
19737
+ delegatorAddress: Address;
19738
+ /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */
19739
+ encryptedValues?: EncryptedValue[];
19740
+ /**
19741
+ * The account whose on-chain balance to read. Defaults to the delegator
19742
+ * address, which is the common case (the delegator grants permission to
19743
+ * decrypt their own balance). Only set this when the account differs
19744
+ * from the delegator.
19745
+ *
19746
+ * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.
19747
+ */
19748
+ accountAddress?: Address;
19749
+ /** Maximum number of concurrent decrypt calls. Default: 10. */
19750
+ maxConcurrency?: number;
19751
+ /** Called when decryption fails for a single token. Return a fallback bigint. */
19752
+ onError?: (error: Error, address: Address) => bigint;
19753
+ }
19754
+ /** Result of {@link Token.batchBalancesOf}. */
19755
+ interface BatchBalancesResult {
19756
+ /** Successfully decrypted balances, keyed by token address. */
19757
+ results: Map<Address, bigint>;
19758
+ /** Per-token errors for tokens that failed to decrypt. */
19759
+ errors: Map<Address, ZamaError>;
19760
+ }
19853
19761
  /**
19854
- * Confidential ERC-20 wrapper (ERC-7984 ERC20Wrapper).
19762
+ * High-level interface for an ERC-7984 confidential token.
19763
+ * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind
19764
+ * familiar ERC-20-like methods.
19855
19765
  *
19856
- * Extends {@link Token} with wrapper-specific operations:
19857
- * - `shield` / `unshield` — convert between the underlying ERC-20 and confidential balance
19858
- * - `unwrap` / `unwrapAll` / `finalizeUnwrap` — low-level two-phase primitives
19859
- * - `underlying` / `allowance` — wrapper reads
19766
+ * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —
19767
+ * it extends `Token` with wrapper-specific operations.
19860
19768
  *
19861
- * `WrappedToken.address` is the wrapper contract address itself — the wrapper
19862
- * IS the confidential token.
19769
+ * Decryption, credentials, caching, and event emission are handled by the
19770
+ * owning {@link ZamaSDK} — this class only exposes token-scoped helpers
19771
+ * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.
19863
19772
  */
19864
- declare class WrappedToken extends Token {
19773
+ declare class Token {
19865
19774
  #private;
19775
+ readonly sdk: ZamaSDK;
19776
+ readonly address: Address;
19777
+ constructor(sdk: ZamaSDK, address: Address);
19778
+ /** Read the token name from the contract. */
19779
+ name(): Promise<string>;
19780
+ /** Read the token symbol from the contract. */
19781
+ symbol(): Promise<string>;
19782
+ /** Read the token decimals from the contract. */
19783
+ decimals(): Promise<number>;
19866
19784
  /**
19867
- * Read the underlying ERC-20 token address from the wrapper contract.
19785
+ * ERC-165 check for {@link ERC7984_INTERFACE_ID} support.
19868
19786
  *
19869
- * @returns The underlying ERC-20 token address.
19870
- */
19871
- underlying(): Promise<Address>;
19872
- /**
19873
- * Check whether the underlying ERC-20 supports ERC-1363 (payable token).
19874
- * Result is cached per WrappedToken instance (negative results included):
19875
- * once we know an underlying does not support ERC-1363, subsequent shields
19876
- * go straight to the `approve` + `wrap` path without re-probing.
19787
+ * @returns `true` if the contract implements the ERC-7984 confidential token interface.
19877
19788
  */
19878
- isPayable(): Promise<boolean>;
19789
+ isConfidential(): Promise<boolean>;
19879
19790
  /**
19880
- * Read the ERC-20 allowance granted by `owner` to this wrapper for the
19881
- * underlying token.
19791
+ * ERC-165 check for IERC7984ERC20Wrapper support.
19882
19792
  *
19883
- * @param owner - The owner address whose allowance to read.
19884
- * @returns The current allowance as a bigint.
19793
+ * @returns `true` if the contract implements the ERC-7984 wrapper interface
19794
+ * ({@link ERC7984_WRAPPER_INTERFACE_ID}, `0x1f1c62b2`).
19885
19795
  */
19886
- allowance(owner: Address): Promise<bigint>;
19796
+ isWrapper(): Promise<boolean>;
19887
19797
  /**
19888
- * Shield public ERC-20 tokens into confidential tokens.
19889
- *
19890
- * The execution path is decided automatically by ERC-165 introspection on
19891
- * the underlying ERC-20:
19892
- * - **`transferAndCall`** (single tx): when the underlying supports
19893
- * ERC-1363, no approval is required — the wrapper's `onTransferReceived`
19894
- * callback mints confidential tokens directly. `approvalStrategy` is
19895
- * **ignored** on this path. See {@link ShieldPath}.
19896
- * - **`approveAndWrap`** (two-tx fallback): otherwise, an `approve` is
19897
- * followed by a `wrap`. Approval is controlled by `approvalStrategy`
19898
- * (`"exact"` by default, `"max"` for unlimited, `"skip"` to opt out).
19899
- *
19900
- * The ERC-20 balance is validated before submitting (public read, no
19901
- * signing required) so the call works for all wallet types, including
19902
- * smart wallets.
19798
+ * Decrypt and return the plaintext balance for the given owner.
19799
+ * Acquires FHE credentials via a wallet signature if none are cached.
19903
19800
  *
19904
- * @param amount - The plaintext amount to shield.
19905
- * @param options - Optional: `approvalStrategy`, `to`, callbacks.
19906
- * @returns The transaction hash and mined receipt.
19907
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
19908
- * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
19909
- * @throws if the ERC-20 approval or shield transaction reverts. {@link TransactionRevertedError}
19801
+ * @param owner - Balance owner address.
19802
+ * @returns The decrypted plaintext balance as a bigint.
19803
+ * @throws if FHE decryption fails. {@link DecryptionFailedError}
19910
19804
  *
19911
19805
  * @example
19912
19806
  * ```ts
19913
- * const txHash = await wrappedToken.shield(1000n);
19807
+ * const balance = await token.balanceOf("0xOwner");
19914
19808
  * ```
19915
19809
  */
19916
- shield(amount: bigint, options?: ShieldOptions): Promise<TransactionResult>;
19810
+ balanceOf(owner: Address): Promise<bigint>;
19917
19811
  /**
19918
- * Approve this wrapper contract to spend the underlying ERC-20.
19919
- * Defaults to max uint256. Resets to zero first if there's an existing
19920
- * non-zero allowance (required by tokens like USDT).
19812
+ * Return the raw encrypted balance without decrypting.
19921
19813
  *
19922
- * @param amount - Optional approval amount. Defaults to max uint256.
19923
- * @returns The transaction hash and mined receipt.
19814
+ * @param owner - Balance owner address.
19815
+ * @returns The encrypted balance as a hex string.
19924
19816
  *
19925
19817
  * @example
19926
19818
  * ```ts
19927
- * await wrappedToken.approveUnderlying(); // max approval
19928
- * await wrappedToken.approveUnderlying(1000n); // exact amount
19819
+ * const encryptedValue = await token.confidentialBalanceOf("0xOwner");
19929
19820
  * ```
19930
19821
  */
19931
- approveUnderlying(amount?: bigint): Promise<TransactionResult>;
19822
+ confidentialBalanceOf(owner: Address): Promise<EncryptedValue>;
19932
19823
  /**
19933
- * Unshield a specific amount and finalize in one call.
19934
- * Orchestrates: unshield → wait for receipt → parse event → finalize.
19935
- *
19936
- * By default, the SDK validates the confidential balance before submitting.
19937
- * Set `skipBalanceCheck: true` to bypass this validation (e.g. for smart wallets).
19824
+ * Decrypt the balance of a delegator using delegated decryption credentials.
19825
+ * The connected signer acts as the delegatee who has been granted permission
19826
+ * by the delegator to decrypt their balance.
19938
19827
  *
19939
- * @param amount - The plaintext amount to unshield.
19940
- * @param options - Optional: `skipBalanceCheck` (default `false`), callbacks.
19941
- * @returns The finalize transaction hash and mined receipt.
19828
+ * Clear values are cached in storage keyed by `(account, token, encryptedValue)`.
19829
+ * Because every on-chain balance change produces a new encrypted value,
19830
+ * stale cache entries are never served. Cache write failures are silently
19831
+ * ignored — they do not affect the returned value.
19942
19832
  *
19943
- * @example
19944
- * ```ts
19945
- * const txHash = await wrappedToken.unshield(500n);
19946
- * ```
19947
- */
19948
- unshield(amount: bigint, options?: UnshieldOptions): Promise<TransactionResult>;
19949
- /**
19950
- * Unshield the entire balance and finalize in one call.
19951
- * Orchestrates: unshieldAll → wait for receipt → parse event → finalize.
19952
- *
19953
- * @param callbacks - Optional progress callbacks for each phase.
19954
- * @returns The finalize transaction hash and mined receipt.
19955
- * @throws if the balance is zero. {@link DecryptionFailedError}
19833
+ * @param delegatorAddress - The address of the account that delegated decryption rights.
19834
+ * @param accountAddress - The account whose on-chain balance to read. Defaults
19835
+ * to the delegator address.
19836
+ * @returns The decrypted plaintext balance as a bigint.
19837
+ * @throws if no active delegation exists. {@link DelegationNotFoundError}
19838
+ * @throws if the delegation has expired. {@link DelegationExpiredError}
19839
+ * @throws if delegated decryption fails. {@link DecryptionFailedError}
19956
19840
  *
19957
19841
  * @example
19958
19842
  * ```ts
19959
- * const txHash = await wrappedToken.unshieldAll();
19843
+ * const balance = await token.decryptBalanceAs({
19844
+ * delegatorAddress: "0xDelegator",
19845
+ * });
19960
19846
  * ```
19961
19847
  */
19962
- unshieldAll(callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
19848
+ decryptBalanceAs({ delegatorAddress, accountAddress }: {
19849
+ delegatorAddress: Address;
19850
+ accountAddress?: Address;
19851
+ }): Promise<bigint>;
19963
19852
  /**
19964
- * Resume an in-progress unshield from an existing unwrap tx hash.
19965
- * Useful when the user already submitted the unwrap but the finalize step
19966
- * was interrupted (e.g. page reload, network error).
19853
+ * Decrypt confidential balances for multiple tokens in parallel, returning
19854
+ * successes and per-token errors separately. Pre-authorizes all token
19855
+ * addresses in a single wallet signature, then delegates each decrypt to
19856
+ * `sdk.decryption.decryptValues`.
19967
19857
  *
19968
- * @param unwrapTxHash - The transaction hash of the previously submitted unwrap.
19969
- * @param callbacks - Optional progress callbacks.
19970
- * @returns The finalize transaction hash and mined receipt.
19858
+ * Tokens that fail to decrypt land in `errors` rather than aborting the
19859
+ * whole batch — caller decides how to surface them.
19860
+ *
19861
+ * @param tokens - Array of {@link Token} instances bound to the same SDK.
19862
+ * @param owner - Balance owner address.
19863
+ * @returns `{ results, errors }` partitioning the per-token outcomes.
19971
19864
  *
19972
19865
  * @example
19973
19866
  * ```ts
19974
- * const txHash = await wrappedToken.resumeUnshield(previousUnwrapTxHash);
19867
+ * const { results, errors } = await Token.batchBalancesOf(tokens, owner);
19975
19868
  * ```
19976
19869
  */
19977
- resumeUnshield(unwrapTxHash: Hex, callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
19870
+ static batchBalancesOf(tokens: Token[], owner: Address): Promise<BatchBalancesResult>;
19978
19871
  /**
19979
- * Return the unwrap tx hash of an unshield that was interrupted between its
19980
- * two phases, or `null` if none is pending for this wrapper.
19872
+ * Batch decrypt confidential balances as a delegate across multiple tokens.
19873
+ * Mirrors {@link batchBalancesOf} but uses delegated credentials.
19981
19874
  *
19982
- * The SDK persists this automatically when {@link unshield}/{@link unshieldAll}
19983
- * submit phase 1, and clears it once phase 2 finalizes. Use the returned hash
19984
- * to surface a "resume" affordance, then pass it to {@link resumeUnshield}.
19985
- * Resuming is intentionally caller-driven — auto-resuming on load would fire a
19986
- * wallet transaction unprompted.
19875
+ * **Error handling:** If a per-token decryption fails and no `onError` callback
19876
+ * is provided, errors are collected and thrown as an aggregated
19877
+ * `DecryptionFailedError`. When the relayer returns no value for an encrypted value,
19878
+ * a `DecryptionFailedError` is thrown for that token (never silently returns `0n`).
19879
+ * Pass `onError: () => 0n` to opt into the silent zero behavior.
19987
19880
  *
19988
- * @returns The pending unwrap tx hash, or `null`.
19881
+ * @param tokens - Array of Token instances to decrypt balances for.
19882
+ * @param options - Delegated decryption configuration.
19883
+ * @returns A Map from token address to decrypted balance.
19884
+ * @throws if no active delegation exists. {@link DelegationNotFoundError}
19885
+ * @throws if the delegation has expired. {@link DelegationExpiredError}
19886
+ * @throws if any decryption fails and no `onError` is provided. {@link DecryptionFailedError}
19989
19887
  *
19990
19888
  * @example
19991
19889
  * ```ts
19992
- * const unwrapTxHash = await wrappedToken.getPendingUnshield();
19993
- * if (unwrapTxHash) await wrappedToken.resumeUnshield(unwrapTxHash);
19890
+ * const balances = await Token.batchDecryptBalancesAs(tokens, {
19891
+ * delegatorAddress: "0xDelegator",
19892
+ * onError: (err, addr) => { console.error(addr, err); return 0n; },
19893
+ * });
19994
19894
  * ```
19995
19895
  */
19996
- getPendingUnshield(): Promise<Hex | null>;
19896
+ static batchDecryptBalancesAs(tokens: Token[], options: BatchDecryptAsOptions): Promise<Map<Address, bigint>>;
19897
+ private static readBalanceHandlesBatch;
19997
19898
  /**
19998
- * Request an unwrap for a specific amount. Encrypts the amount first.
19999
- * Call {@link finalizeUnwrap} after the request is processed on-chain.
19899
+ * Confidential transfer. Encrypts the amount via FHE, then calls the contract.
20000
19900
  *
20001
- * @param amount - The plaintext amount to unwrap (encrypted automatically).
19901
+ * By default, the SDK validates the confidential balance before submitting.
19902
+ * If a cached plaintext balance exists it is used; otherwise, if credentials
19903
+ * are cached, it decrypts on the fly. Set `skipBalanceCheck: true` to bypass
19904
+ * this validation (e.g. for smart wallets).
19905
+ *
19906
+ * @param to - Recipient address.
19907
+ * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
19908
+ * @param options - Optional: `skipBalanceCheck` (default `false`).
20002
19909
  * @returns The transaction hash and mined receipt.
19910
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
19911
+ * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
19912
+ * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
19913
+ * @throws if FHE encryption fails. {@link EncryptionFailedError}
19914
+ * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
20003
19915
  *
20004
19916
  * @example
20005
19917
  * ```ts
20006
- * const txHash = await wrappedToken.unwrap(500n);
19918
+ * const txHash = await token.confidentialTransfer("0xRecipient", 1000n);
20007
19919
  * ```
20008
19920
  */
20009
- unwrap(amount: bigint): Promise<TransactionResult>;
19921
+ confidentialTransfer(to: Address, amount: bigint, options?: TransferOptions): Promise<TransactionResult>;
20010
19922
  /**
20011
- * Request an unwrap for the entire confidential balance.
20012
- * Uses the on-chain encrypted balance directly (no encryption needed).
20013
- * Throws if the balance is zero.
19923
+ * Operator encrypted transfer on behalf of another address.
19924
+ * The caller must be an approved operator for `from`.
20014
19925
  *
19926
+ * @param from - The address to transfer from (caller must be an approved operator).
19927
+ * @param to - Recipient address.
19928
+ * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
20015
19929
  * @returns The transaction hash and mined receipt.
20016
- * @throws if the balance is zero. {@link DecryptionFailedError}
20017
19930
  *
20018
19931
  * @example
20019
19932
  * ```ts
20020
- * const txHash = await wrappedToken.unwrapAll();
19933
+ * const txHash = await token.confidentialTransferFrom("0xFrom", "0xTo", 500n);
20021
19934
  * ```
20022
19935
  */
20023
- unwrapAll(): Promise<TransactionResult>;
19936
+ confidentialTransferFrom(from: Address, to: Address, amount: bigint, callbacks?: TransferCallbacks): Promise<TransactionResult>;
20024
19937
  /**
20025
- * Complete an unwrap by providing the public decryption proof.
20026
- * Call this after an unshield request has been processed on-chain.
19938
+ * ERC-7984 `confidentialTransferAndCall`: encrypted transfer that also invokes
19939
+ * the recipient's receiver hook (`onConfidentialTransferReceived`) in a single
19940
+ * transaction. The caller crafts the opaque `data` payload — the SDK does not
19941
+ * encode, validate, or interpret it.
20027
19942
  *
20028
- * @param unwrapRequestId - `unwrapRequestId` from the `UnwrapRequested` event.
19943
+ * Balance validation follows the same rules as {@link Token.confidentialTransfer}.
19944
+ *
19945
+ * @param to - Recipient address. Must implement the ERC-7984 receiver hook.
19946
+ * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
19947
+ * @param data - Opaque bytes forwarded to the recipient's receiver hook.
19948
+ * @param options - Optional: `skipBalanceCheck` (default `false`).
20029
19949
  * @returns The transaction hash and mined receipt.
20030
19950
  *
19951
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
19952
+ * @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
19953
+ * @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
19954
+ * @throws if FHE encryption fails. {@link EncryptionFailedError}
19955
+ * @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
19956
+ *
20031
19957
  * @example
20032
19958
  * ```ts
20033
- * const event = findUnwrapRequested(receipt.logs);
20034
- * const txHash = await wrappedToken.finalizeUnwrap(event.unwrapRequestId);
19959
+ * const txHash = await token.confidentialTransferAndCall(
19960
+ * "0xRecipient",
19961
+ * 1000n,
19962
+ * "0xabcd", // caller-encoded payload forwarded to the receiver hook
19963
+ * );
20035
19964
  * ```
20036
19965
  */
20037
- finalizeUnwrap(unwrapRequestId: EncryptedValue): Promise<TransactionResult>;
20038
- }
20039
- //#endregion
20040
- //#region src/query/confidential-balance.d.ts
20041
- interface ConfidentialBalanceQueryConfig {
20042
- tokenAddress: Address;
20043
- account?: Address;
20044
- query?: Record<string, unknown>;
20045
- }
20046
- /** Query options for a single confidential token balance. Auto-gated on `account`. */
20047
- declare function confidentialBalanceQueryOptions(token: Token, config: ConfidentialBalanceQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.confidentialBalance.owner>>;
20048
- //#endregion
20049
- //#region src/query/confidential-balances.d.ts
20050
- interface ConfidentialBalancesQueryConfig {
20051
- account?: Address;
20052
- query?: Record<string, unknown>;
20053
- }
20054
- declare function confidentialBalancesQueryOptions(tokens: Token[], config?: ConfidentialBalancesQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<BatchBalancesResult, Error, BatchBalancesResult, ReturnType<typeof zamaQueryKeys.confidentialBalances.tokens>>;
20055
- //#endregion
20056
- //#region src/query/wrappers-registry.d.ts
20057
- interface WrappersRegistryQueryConfig {
20058
- registryAddress: Address | undefined;
20059
- query?: Record<string, unknown>;
20060
- }
20061
- declare function tokenPairsQueryOptions(sdk: ZamaSDK, config: WrappersRegistryQueryConfig): QueryFactoryOptions<readonly TokenWrapperPair[], Error, readonly TokenWrapperPair[], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairs>>;
20062
- interface ConfidentialTokenAddressQueryConfig extends WrappersRegistryQueryConfig {
20063
- tokenAddress?: Address;
20064
- }
20065
- declare function confidentialTokenAddressQueryOptions(sdk: ZamaSDK, config: ConfidentialTokenAddressQueryConfig): QueryFactoryOptions<readonly [boolean, Address], Error, readonly [boolean, Address], ReturnType<typeof zamaQueryKeys.wrappersRegistry.confidentialTokenAddress>>;
20066
- interface TokenAddressQueryConfig extends WrappersRegistryQueryConfig {
20067
- confidentialTokenAddress?: Address;
20068
- }
20069
- declare function tokenAddressQueryOptions(sdk: ZamaSDK, config: TokenAddressQueryConfig): QueryFactoryOptions<readonly [boolean, Address], Error, readonly [boolean, Address], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenAddress>>;
20070
- declare function tokenPairsLengthQueryOptions(sdk: ZamaSDK, config: WrappersRegistryQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsLength>>;
20071
- interface TokenPairsSliceQueryConfig extends WrappersRegistryQueryConfig {
20072
- fromIndex?: bigint;
20073
- toIndex?: bigint;
20074
- }
20075
- declare function tokenPairsSliceQueryOptions(sdk: ZamaSDK, config: TokenPairsSliceQueryConfig): QueryFactoryOptions<readonly TokenWrapperPair[], Error, readonly TokenWrapperPair[], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsSlice>>;
20076
- interface TokenPairQueryConfig extends WrappersRegistryQueryConfig {
20077
- index?: bigint;
20078
- }
20079
- declare function tokenPairQueryOptions(sdk: ZamaSDK, config: TokenPairQueryConfig): QueryFactoryOptions<TokenWrapperPair, Error, TokenWrapperPair, ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPair>>;
20080
- interface IsConfidentialTokenValidQueryConfig extends WrappersRegistryQueryConfig {
20081
- confidentialTokenAddress?: Address;
20082
- }
20083
- declare function isConfidentialTokenValidQueryOptions(sdk: ZamaSDK, config: IsConfidentialTokenValidQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.wrappersRegistry.isConfidentialTokenValid>>;
20084
- interface ListPairsQueryConfig {
20085
- /**
20086
- * The registry address for this chain — used as a query key discriminator.
20087
- * The registry instance already knows how to resolve the address for the
20088
- * current chain; this field just keeps the TanStack Query cache isolated
20089
- * per registry contract.
20090
- */
20091
- registryAddress: Address | undefined;
20092
- page?: number;
20093
- pageSize?: number;
20094
- metadata?: boolean;
20095
- query?: Record<string, unknown>;
20096
- }
20097
- /**
20098
- * Query options for paginated listing of token wrapper pairs.
20099
- *
20100
- * Accepts a {@link WrappersRegistry} instance rather than a raw provider so that the
20101
- * class-level TTL cache is shared across multiple `queryFn` executions. Pass
20102
- * `sdk.registry` (the ZamaSDK lazy singleton) to ensure a single shared cache.
20103
- */
20104
- declare function listPairsQueryOptions(registry: WrappersRegistry, config: ListPairsQueryConfig): QueryFactoryOptions<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>, Error, PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>, ReturnType<typeof zamaQueryKeys.wrappersRegistry.listPairs>>;
20105
- //#endregion
20106
- //#region src/query/shield.d.ts
20107
- /** Variables for {@link shieldMutationOptions}. */
20108
- interface ShieldParams extends ShieldOptions {
20109
- amount: bigint;
20110
- }
20111
- declare function shieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.shield", Address], ShieldParams, TransactionResult>;
20112
- //#endregion
20113
- //#region src/query/transfer.d.ts
20114
- /** Variables for {@link confidentialTransferMutationOptions}. */
20115
- interface ConfidentialTransferParams extends TransferOptions {
20116
- to: Address;
20117
- amount: bigint;
20118
- }
20119
- declare function confidentialTransferMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransfer", Address], ConfidentialTransferParams, TransactionResult>;
20120
- //#endregion
20121
- //#region src/query/transfer-and-call.d.ts
20122
- /** Variables for {@link confidentialTransferAndCallMutationOptions}. */
20123
- interface ConfidentialTransferAndCallParams extends TransferOptions {
20124
- to: Address;
20125
- amount: bigint;
20126
- /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */
20127
- data: Hex;
20128
- }
20129
- declare function confidentialTransferAndCallMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferAndCall", Address], ConfidentialTransferAndCallParams, TransactionResult>;
20130
- //#endregion
20131
- //#region src/query/transfer-from.d.ts
20132
- /** Variables for {@link confidentialTransferFromMutationOptions}. */
20133
- interface ConfidentialTransferFromParams {
20134
- from: Address;
20135
- to: Address;
20136
- amount: bigint;
20137
- /** Optional progress callbacks for the multi-step transfer flow. */
20138
- callbacks?: TransferCallbacks;
20139
- }
20140
- declare function confidentialTransferFromMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferFrom", Address], ConfidentialTransferFromParams, TransactionResult>;
20141
- //#endregion
20142
- //#region src/query/transfer-from-and-call.d.ts
20143
- /** Variables for {@link confidentialTransferFromAndCallMutationOptions}. */
20144
- interface ConfidentialTransferFromAndCallParams {
20145
- from: Address;
20146
- to: Address;
20147
- amount: bigint;
20148
- /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */
20149
- data: Hex;
20150
- /** Optional progress callbacks for the multi-step transfer flow. */
20151
- callbacks?: TransferCallbacks;
20152
- }
20153
- declare function confidentialTransferFromAndCallMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferFromAndCall", Address], ConfidentialTransferFromAndCallParams, TransactionResult>;
20154
- //#endregion
20155
- //#region src/query/set-operator.d.ts
20156
- /** Variables for {@link confidentialSetOperatorMutationOptions}. */
20157
- interface ConfidentialSetOperatorParams {
20158
- operator: Address;
20159
- until?: number;
20160
- }
20161
- declare function confidentialSetOperatorMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialSetOperator", Address], ConfidentialSetOperatorParams, TransactionResult>;
20162
- //#endregion
20163
- //#region src/query/approve-underlying.d.ts
20164
- /** Variables for {@link approveUnderlyingMutationOptions}. */
20165
- interface ApproveUnderlyingParams {
20166
- amount?: bigint;
20167
- }
20168
- declare function approveUnderlyingMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.approveUnderlying", Address], ApproveUnderlyingParams, TransactionResult>;
20169
- //#endregion
20170
- //#region src/query/unshield.d.ts
20171
- /** Variables for {@link unshieldMutationOptions}. */
20172
- interface UnshieldParams extends UnshieldOptions {
20173
- amount: bigint;
20174
- }
20175
- declare function unshieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unshield", Address], UnshieldParams, TransactionResult>;
20176
- //#endregion
20177
- //#region src/query/unshield-all.d.ts
20178
- /** Variables for {@link unshieldAllMutationOptions}. */
20179
- interface UnshieldAllParams extends UnshieldCallbacks {}
20180
- declare function unshieldAllMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unshieldAll", Address], UnshieldAllParams | void, TransactionResult>;
20181
- //#endregion
20182
- //#region src/query/resume-unshield.d.ts
20183
- /** Variables for {@link resumeUnshieldMutationOptions}. */
20184
- interface ResumeUnshieldParams extends UnshieldCallbacks {
20185
- unwrapTxHash: Hex;
20186
- }
20187
- declare function resumeUnshieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.resumeUnshield", Address], ResumeUnshieldParams, TransactionResult>;
20188
- //#endregion
20189
- //#region src/query/unwrap.d.ts
20190
- /** Variables for {@link unwrapMutationOptions}. */
20191
- interface UnwrapParams {
20192
- amount: bigint;
20193
- }
20194
- declare function unwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unwrap", Address], UnwrapParams, TransactionResult>;
20195
- //#endregion
20196
- //#region src/query/unwrap-all.d.ts
20197
- declare function unwrapAllMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unwrapAll", Address], void, TransactionResult>;
20198
- //#endregion
20199
- //#region src/query/finalize-unwrap.d.ts
20200
- /** Variables for {@link finalizeUnwrapMutationOptions}. */
20201
- type FinalizeUnwrapParams = {
20202
- /** Identifier from an `UnwrapRequested` event. */unwrapRequestId: EncryptedValue;
20203
- };
20204
- declare function finalizeUnwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.finalizeUnwrap", Address], FinalizeUnwrapParams, TransactionResult>;
20205
- //#endregion
20206
- //#region src/query/encrypt.d.ts
20207
- declare function encryptMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.encrypt"], EncryptParams, EncryptResult>;
20208
- //#endregion
20209
- //#region src/query/user-decrypt.d.ts
20210
- interface EncryptedInput {
20211
- encryptedValue: EncryptedValue;
20212
- contractAddress: Address;
20213
- }
20214
- /** Decrypted clear values keyed by encrypted handle. */
20215
- type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;
20216
- declare function decryptValuesQueryOptions(sdk: ZamaSDK, encryptedInputs: EncryptedInput[], signerContext?: SignerQueryContext): QueryFactoryOptions<DecryptResult, Error, DecryptResult, ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>>;
20217
- //#endregion
20218
- //#region src/query/delegated-decrypt.d.ts
20219
- interface DelegatedDecryptValuesMutationParams {
20220
- encryptedInputs: EncryptedInput[];
20221
- delegatorAddress: Address;
20222
- }
20223
- declare function delegatedDecryptValuesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.delegatedDecryptValues"], DelegatedDecryptValuesMutationParams, Readonly<Record<EncryptedValue, ClearValue>>>;
20224
- //#endregion
20225
- //#region src/query/public-decrypt.d.ts
20226
- declare function decryptPublicValuesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.decryptPublicValues"], EncryptedValue[], DecryptPublicValuesResult>;
20227
- //#endregion
20228
- //#region src/query/grant-permit.d.ts
20229
- declare function grantPermitMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.grantPermit"], Address[], void>;
20230
- //#endregion
20231
- //#region src/query/has-permit.d.ts
20232
- interface HasPermitQueryConfig {
20233
- /** Contract addresses to check credentials against. */
20234
- contractAddresses: Address[];
20235
- /**
20236
- * Standard TanStack query options. `hasPermit` intentionally overrides cache
20237
- * timing because permit state is wallet-local, not server state: every fetch
20238
- * should read the SDK credential service directly.
20239
- */
20240
- query?: Record<string, unknown>;
20241
- }
20242
- declare function hasPermitQueryOptions(sdk: ZamaSDK, config: HasPermitQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.hasPermit.scope>>;
20243
- //#endregion
20244
- //#region src/query/revoke-permits.d.ts
20245
- /** TanStack Query mutation factory for {@link Permits.revokePermits}. */
20246
- declare function revokePermitsMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.revokePermits"], Address[] | void, void>;
20247
- //#endregion
20248
- //#region src/query/clear-credentials.d.ts
20249
- /** TanStack Query mutation factory for {@link Permits.clear}. */
20250
- declare function clearCredentialsMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.clearCredentials"], void, void>;
20251
- //#endregion
20252
- //#region src/query/delegate-decryption.d.ts
20253
- /** Variables for {@link delegateDecryptionMutationOptions}. */
20254
- interface DelegateDecryptionParams {
20255
- delegateAddress: Address;
20256
- expirationDate?: Date;
20257
- }
20258
- declare function delegateDecryptionMutationOptions(sdk: ZamaSDK, contractAddress: Address): MutationFactoryOptions<readonly ["zama.delegateDecryption", Address], DelegateDecryptionParams, TransactionResult>;
20259
- //#endregion
20260
- //#region src/query/decrypt-balance-as.d.ts
20261
- /** Variables for {@link decryptBalanceAsMutationOptions}. */
20262
- interface DecryptBalanceAsParams {
20263
- delegatorAddress: Address;
20264
- accountAddress?: Address;
20265
- }
20266
- declare function decryptBalanceAsMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.decryptBalanceAs", Address], DecryptBalanceAsParams, bigint>;
20267
- //#endregion
20268
- //#region src/query/batch-decrypt-balances-as.d.ts
20269
- /** Variables for {@link batchDecryptBalancesAsMutationOptions}. */
20270
- type BatchDecryptBalancesAsParams = BatchDecryptAsOptions;
20271
- declare function batchDecryptBalancesAsMutationOptions(tokens: Token[]): MutationFactoryOptions<readonly ["zama.batchDecryptBalancesAs", ...Address[]], BatchDecryptBalancesAsParams, Map<Address, bigint>>;
20272
- //#endregion
20273
- //#region src/query/revoke-delegation.d.ts
20274
- /** Variables for {@link revokeDelegationMutationOptions}. */
20275
- interface RevokeDelegationParams {
20276
- delegateAddress: Address;
20277
- }
20278
- declare function revokeDelegationMutationOptions(sdk: ZamaSDK, contractAddress: Address): MutationFactoryOptions<readonly ["zama.revokeDelegation", Address], RevokeDelegationParams, TransactionResult>;
20279
- //#endregion
20280
- //#region src/query/delegation-status.d.ts
20281
- interface DelegationStatusData {
20282
- isActive: boolean;
20283
- expiryTimestamp: bigint;
20284
- }
20285
- interface DelegationStatusQueryConfig {
20286
- contractAddress: Address | undefined;
20287
- delegatorAddress?: Address;
20288
- delegateAddress?: Address;
20289
- query?: Record<string, unknown>;
20290
- }
20291
- declare function delegationStatusQueryOptions(sdk: ZamaSDK, config: DelegationStatusQueryConfig): QueryFactoryOptions<DelegationStatusData, Error, DelegationStatusData, ReturnType<typeof zamaQueryKeys.delegationStatus.scope>>;
20292
- //#endregion
20293
- //#region src/credentials/credential-service.d.ts
20294
- /** Configuration for {@link CredentialService}. TTLs are pre-validated by the caller. */
20295
- interface CredentialServiceConfig {
20296
- router: ChainRouter;
20297
- signer: GenericSigner;
20298
- /** Transport key pair lifetime in seconds. Pre-validated. */
20299
- transportKeyPairTTL: number;
20300
- /** Permit lifetime in days. Pre-validated. */
20301
- permitTTL: number;
20302
- /** Backing storage for transport key pairs (and permits if `permitStorage` is omitted). */
20303
- storage: GenericStorage;
20304
- /** Optional dedicated storage for permits; defaults to `storage`. */
20305
- permitStorage?: GenericStorage;
20306
- /** SDK-wide logger for credential-path diagnostics. */
20307
- logger: GenericLogger;
20308
- }
20309
- /**
20310
- * Single facade coordinating the keypair vault and the permission store.
20311
- *
20312
- * `CredentialService` is the only credentials object held by `ZamaSDK`. It accepts identity
20313
- * transitions via `handleWalletAccountChange`.
20314
- */
20315
- declare class CredentialService {
20316
- #private;
20317
- constructor(config: CredentialServiceConfig);
19966
+ confidentialTransferAndCall(to: Address, amount: bigint, data: Hex, options?: TransferOptions): Promise<TransactionResult>;
20318
19967
  /**
20319
- * Resolve a keypair and permissions covering `contracts`, minimizing wallet
20320
- * prompts by reusing or widening existing permits where possible. Empty
20321
- * `contracts` warms the keypair without prompting.
19968
+ * ERC-7984 `confidentialTransferFromAndCall`: operator-initiated encrypted
19969
+ * transfer that also invokes the recipient's receiver hook in a single
19970
+ * transaction. The caller must be an approved operator for `from` and crafts
19971
+ * the opaque `data` payload — the SDK does not encode or interpret it.
20322
19972
  *
20323
- * @returns The resolved keypair and permits covering the requested contracts.
20324
- * @throws if the user rejects a wallet signature prompt. {@link SigningRejectedError}
20325
- * @throws if signing fails for any other reason. {@link SigningFailedError}
19973
+ * @param from - The address to transfer from (caller must be an approved operator).
19974
+ * @param to - Recipient address. Must implement the ERC-7984 receiver hook.
19975
+ * @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
19976
+ * @param data - Opaque bytes forwarded to the recipient's receiver hook.
19977
+ * @param callbacks - Optional progress callbacks.
19978
+ * @returns The transaction hash and mined receipt.
19979
+ *
19980
+ * @example
19981
+ * ```ts
19982
+ * const txHash = await token.confidentialTransferFromAndCall(
19983
+ * "0xFrom",
19984
+ * "0xRecipient",
19985
+ * 500n,
19986
+ * "0xabcd",
19987
+ * );
19988
+ * ```
20326
19989
  */
20327
- grantPermit(contracts: readonly Address[], delegator?: Address): Promise<SerializedTransportKeyPairWithPermissions>;
19990
+ confidentialTransferFromAndCall(from: Address, to: Address, amount: bigint, data: Hex, callbacks?: TransferCallbacks): Promise<TransactionResult>;
20328
19991
  /**
20329
- * Pure store lookup: are stored permits sufficient to cover `contracts`? No wallet prompt.
19992
+ * Set operator approval for the confidential token.
19993
+ * Defaults to 1 hour from now if `until` is not specified.
20330
19994
  *
20331
- * @returns `true` if cached permits cover all requested contracts (vacuously
20332
- * true for an empty list); `false` if no keypair exists or coverage is
20333
- * incomplete.
19995
+ * @param operator - The address to set as an operator.
19996
+ * @param until - Optional Unix timestamp for approval expiry. Defaults to now + 1 hour.
19997
+ * @returns The transaction hash and mined receipt.
19998
+ *
19999
+ * @example
20000
+ * ```ts
20001
+ * const txHash = await token.setOperator("0xOperator");
20002
+ * ```
20334
20003
  */
20335
- hasPermit(contracts: readonly Address[], delegator?: Address): Promise<boolean>;
20004
+ setOperator(operator: Address, until?: number): Promise<TransactionResult>;
20336
20005
  /**
20337
- * Wipe FHE permits for the current signer.
20006
+ * Check if a spender is an approved operator for a given holder.
20338
20007
  *
20339
- * - With no argument: every permit referencing this signer is removed across
20340
- * all chains and delegators. The keypair survives — use
20341
- * {@link clearCredentials} to also wipe the keypair.
20342
- * - With a contract list: every signed permit in the direct-decrypt scope
20343
- * (current chain) whose immutable payload touches any listed address is
20344
- * removed. Delegated permits are not touched in this mode.
20008
+ * @param holder - The token holder address.
20009
+ * @param spender - The address to check operator approval for.
20010
+ * @returns `true` if the spender is an approved operator for the holder.
20345
20011
  *
20346
- * @throws if reading the signer address fails. {@link SigningFailedError}
20012
+ * @example
20013
+ * ```ts
20014
+ * if (await token.isOperator("0xHolder", "0xSpender")) {
20015
+ * // spender can call transferFrom on behalf of holder
20016
+ * }
20017
+ * ```
20347
20018
  */
20348
- revokePermits(contracts?: readonly Address[]): Promise<void>;
20019
+ isOperator(holder: Address, spender: Address): Promise<boolean>;
20349
20020
  /**
20350
- * Wipe the keypair for the current signer and cascade-delete every
20351
- * permission referencing it across all chains and delegators.
20021
+ * Read the on-chain encrypted balance for a given owner.
20352
20022
  *
20353
- * @throws if reading the signer address fails. {@link SigningFailedError}
20023
+ * @internal
20354
20024
  */
20355
- clearCredentials(): Promise<void>;
20025
+ protected readConfidentialBalanceOf(owner: Address): Promise<EncryptedValue>;
20356
20026
  /**
20357
- * Warm the signer transport key pair cache for a known address.
20027
+ * Pre-flight check: decrypt the confidential balance and compare against the
20028
+ * requested amount. If credentials are cached the decrypt happens silently;
20029
+ * if not, throws {@link BalanceCheckUnavailableError} instead of triggering
20030
+ * a surprise EIP-712 popup.
20358
20031
  *
20359
- * Best-effort prefetch primitive: correctness still comes from `grantPermit`,
20360
- * which lazily creates the transport key pair when needed. Errors (storage failure,
20361
- * relayer 4xx, missing Worker in SSR) are **not** swallowed here — the caller
20362
- * decides whether to log, ignore, or surface them.
20032
+ * @internal
20363
20033
  */
20364
- warmTransportKeyPair(address: Address): Promise<void>;
20034
+ protected assertConfidentialBalance(amount: bigint): Promise<void>;
20365
20035
  /**
20366
- * Apply a wallet account transition.
20036
+ * Emit a token-scoped event through the owning {@link ZamaSDK} so that
20037
+ * subscribers see a unified stream.
20367
20038
  *
20368
- * Address change clears persisted credentials for the previous account.
20369
- * Chain-only changes keep credentials intact because permits are chain-scoped
20370
- * already and stale decrypt plaintext is cleared by `ZamaSDK`.
20039
+ * @internal
20371
20040
  */
20372
- handleWalletAccountChange(prev?: {
20373
- address: Address;
20374
- }, next?: {
20375
- address: Address;
20376
- }): Promise<void>;
20377
- }
20378
- //#endregion
20379
- //#region src/services/caching-service.d.ts
20380
- /**
20381
- * Storage-backed cache for decrypted FHE plaintext values.
20382
- *
20383
- * Each entry is keyed by `(requester, contractAddress, handle)` so different
20384
- * signers cannot read each other's cached decryptions.
20385
- */
20386
- declare class CachingService {
20387
- #private;
20388
- constructor(storage: GenericStorage, logger: GenericLogger);
20389
- get(requester: Address, contractAddress: Address, encryptedValue: EncryptedValue): Promise<ClearValue | null>;
20390
- set(requester: Address, contractAddress: Address, encryptedValue: EncryptedValue, value: ClearValue): Promise<void>;
20391
- delete(requester: Address, contractAddress: Address, encryptedValue: EncryptedValue): Promise<void>;
20392
- clearForRequester(requester: Address): Promise<void>;
20393
- clearAll(): Promise<void>;
20394
- }
20395
- //#endregion
20396
- //#region src/services/delegation-service.d.ts
20397
- declare class DelegationService {
20398
- #private;
20399
- constructor({
20400
- provider,
20401
- router,
20402
- emitEvent,
20403
- logger
20404
- }: {
20405
- provider: GenericProvider;
20406
- router: ChainRouter;
20407
- logger: GenericLogger;
20408
- emitEvent?: (input: ZamaSDKEventInput, tokenAddress?: Address) => void;
20409
- });
20410
- delegateDecryption(signer: GenericSigner, {
20411
- contractAddress,
20412
- delegateAddress,
20413
- delegatorAddress,
20414
- expirationDate
20415
- }: {
20416
- contractAddress: Address;
20417
- delegateAddress: Address;
20418
- delegatorAddress: Address;
20419
- expirationDate?: Date;
20420
- }): Promise<TransactionResult>;
20421
- revokeDelegation(signer: GenericSigner, {
20422
- contractAddress,
20423
- delegateAddress,
20424
- delegatorAddress
20425
- }: {
20426
- contractAddress: Address;
20427
- delegateAddress: Address;
20428
- delegatorAddress: Address;
20429
- }): Promise<TransactionResult>;
20430
- isDelegated(params: {
20431
- contractAddress: Address;
20432
- delegatorAddress: Address;
20433
- delegateAddress: Address;
20434
- }): Promise<boolean>;
20435
- getDelegationExpiry({
20436
- contractAddress,
20437
- delegatorAddress,
20438
- delegateAddress
20439
- }: {
20440
- contractAddress: Address;
20441
- delegatorAddress: Address;
20442
- delegateAddress: Address;
20443
- }): Promise<bigint>;
20444
- findInactiveDelegations(contractAddresses: readonly Address[], delegatorAddress: Address, delegateAddress: Address): Promise<Map<Address, DelegationNotFoundError | DelegationExpiredError>>;
20445
- assertDelegationActive(contractAddress: Address, delegatorAddress: Address, delegateAddress: Address): Promise<void>;
20446
- }
20447
- //#endregion
20448
- //#region src/services/decryption-service.d.ts
20449
- /** Options shared by the delegated-decrypt entry points. */
20450
- interface DelegatedDecryptOptions {
20041
+ protected emit(input: ZamaSDKEventInput): void;
20451
20042
  /**
20452
- * Ride out the gateway propagation window: when a just-granted delegation
20453
- * has not yet synced, the delegated decrypt is retried (bounded, ~30s) until
20454
- * it lands instead of throwing {@link DelegationNotPropagatedError}. Defaults
20455
- * to `true`. Pass `false` to fail fast on the first not-propagated response.
20043
+ * Submit a token-scoped write transaction through the shared SDK transaction
20044
+ * pipeline. Callers keep pre-flight and operation-specific work local.
20045
+ *
20046
+ * @internal
20456
20047
  */
20457
- waitForPropagation?: boolean;
20458
- }
20459
- interface BatchDecryptItem {
20460
- encryptedValue: EncryptedValue;
20461
- contractAddress: Address;
20462
- value?: ClearValue;
20463
- error?: ZamaError;
20464
- }
20465
- interface BatchDecryptResult {
20466
- items: BatchDecryptItem[];
20467
- }
20468
- declare class DecryptionService {
20469
- #private;
20470
- constructor({
20471
- cache,
20472
- credentialService,
20473
- delegationService,
20474
- router,
20475
- emitEvent
20476
- }: {
20477
- cache: CachingService;
20478
- credentialService: CredentialService;
20479
- delegationService: DelegationService;
20480
- router: ChainRouter;
20481
- emitEvent: (input: ZamaSDKEventInput) => void;
20482
- });
20483
- decryptValues(handles: EncryptedInput[], signerAddress: Address, opts?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<Record<EncryptedValue, ClearValue>>;
20484
- delegatedDecryptValues(encryptedInputs: EncryptedInput[], delegatorAddress: Address, delegateAddress: Address, accountAddress: Address, opts?: DelegatedDecryptOptions): Promise<Record<EncryptedValue, ClearValue>>;
20485
- delegatedBatchDecryptHandlesAs({
20486
- encryptedInputs,
20487
- delegatorAddress,
20488
- delegateAddress,
20489
- accountAddress,
20490
- maxConcurrency,
20491
- waitForPropagation
20492
- }: {
20493
- encryptedInputs: EncryptedInput[];
20494
- delegatorAddress: Address;
20495
- delegateAddress: Address;
20496
- accountAddress: Address;
20497
- maxConcurrency?: number;
20498
- waitForPropagation?: boolean;
20499
- }): Promise<BatchDecryptResult>;
20048
+ protected submitTransaction(params: {
20049
+ operation: TransactionOperation;
20050
+ config: WriteContractConfig;
20051
+ onSubmitted?: (txHash: Hex) => void;
20052
+ }): Promise<TransactionResult>;
20053
+ /** Verify all tokens share the same SDK instance and return it. */
20054
+ private static assertSameSdk;
20500
20055
  }
20501
20056
  //#endregion
20502
- //#region src/namespaces/decryption.d.ts
20057
+ //#region src/token/wrapped-token.d.ts
20503
20058
  /**
20504
- * Public namespace for FHE decryption — the canonical way to decrypt.
20505
- *
20506
- * Exposed as `sdk.decryption`. Prefer these methods over the low-level
20507
- * `sdk.relayer.decryptValues` / `decryptPublicValues`: they
20508
- * assemble the credential bundle (transport key pair, EIP-712 permit) for you,
20509
- * cache results, and wrap relayer errors. Reach for `sdk.relayer.*` only when
20510
- * you must control credential assembly by hand.
20059
+ * Confidential ERC-20 wrapper (ERC-7984 ERC20Wrapper).
20511
20060
  *
20512
- * Owns the SDK-level guards (signer requirement on
20513
- * `decryptValues` and `delegatedDecryptValues`, empty-array
20514
- * short-circuit on `decryptPublicValues`, relayer error wrapping) and delegates the
20515
- * actual work to the internal {@link DecryptionService} or the relayer directly for
20516
- * `decryptPublicValues`.
20061
+ * Extends {@link Token} with wrapper-specific operations:
20062
+ * - `shield` / `unshield` — convert between the underlying ERC-20 and confidential balance
20063
+ * - `unwrap` / `unwrapAll` / `finalizeUnwrap` — low-level two-phase primitives
20064
+ * - `underlying` / `allowance` — wrapper reads
20517
20065
  *
20518
- * **Mixed signer requirement:** `decryptValues` and
20519
- * `delegatedDecryptValues` need a configured signer; `decryptPublicValues`
20520
- * does not. Each method documents its requirement in its JSDoc.
20066
+ * `WrappedToken.address` is the wrapper contract address itself — the wrapper
20067
+ * IS the confidential token.
20521
20068
  */
20522
- declare class Decryption {
20069
+ declare class WrappedToken extends Token {
20523
20070
  #private;
20524
- /** @internal */
20525
- constructor(opts: {
20526
- signer: GenericSigner | undefined;
20527
- provider: GenericProvider;
20528
- router: ChainRouter;
20529
- decryptionService: DecryptionService | undefined;
20530
- });
20531
20071
  /**
20532
- * Decrypt one or more FHE encrypted values. Results are cached — repeated calls
20533
- * for the same encrypted value skip the relayer round-trip.
20072
+ * Read the underlying ERC-20 token address from the wrapper contract.
20073
+ *
20074
+ * @returns The underlying ERC-20 token address.
20075
+ */
20076
+ underlying(): Promise<Address>;
20077
+ /**
20078
+ * Check whether the underlying ERC-20 supports ERC-1363 (payable token).
20079
+ * Result is cached per WrappedToken instance (negative results included):
20080
+ * once we know an underlying does not support ERC-1363, subsequent shields
20081
+ * go straight to the `approve` + `wrap` path without re-probing.
20082
+ */
20083
+ isPayable(): Promise<boolean>;
20084
+ /**
20085
+ * Read the ERC-20 allowance granted by `owner` to this wrapper for the
20086
+ * underlying token.
20087
+ *
20088
+ * @param owner - The owner address whose allowance to read.
20089
+ * @returns The current allowance as a bigint.
20090
+ */
20091
+ allowance(owner: Address): Promise<bigint>;
20092
+ /**
20093
+ * Shield public ERC-20 tokens into confidential tokens.
20094
+ *
20095
+ * The execution path is decided automatically by ERC-165 introspection on
20096
+ * the underlying ERC-20:
20097
+ * - **`transferAndCall`** (single tx): when the underlying supports
20098
+ * ERC-1363, no approval is required — the wrapper's `onTransferReceived`
20099
+ * callback mints confidential tokens directly. `approvalStrategy` is
20100
+ * **ignored** on this path. See {@link ShieldPath}.
20101
+ * - **`approveAndWrap`** (two-tx fallback): otherwise, an `approve` is
20102
+ * followed by a `wrap`. Approval is controlled by `approvalStrategy`
20103
+ * (`"exact"` by default, `"max"` for unlimited, `"skip"` to opt out).
20104
+ *
20105
+ * The ERC-20 balance is validated before submitting (public read, no
20106
+ * signing required) so the call works for all wallet types, including
20107
+ * smart wallets.
20108
+ *
20109
+ * @param amount - The plaintext amount to shield.
20110
+ * @param options - Optional: `approvalStrategy`, `to`, callbacks.
20111
+ * @returns The transaction hash and mined receipt.
20112
+ * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20113
+ * @throws if the ERC-20 balance is less than `amount`. {@link InsufficientERC20BalanceError}
20114
+ * @throws if the ERC-20 approval or shield transaction reverts. {@link TransactionRevertedError}
20115
+ *
20116
+ * @example
20117
+ * ```ts
20118
+ * const txHash = await wrappedToken.shield(1000n);
20119
+ * ```
20120
+ */
20121
+ shield(amount: bigint, options?: ShieldOptions): Promise<TransactionResult>;
20122
+ /**
20123
+ * Approve this wrapper contract to spend the underlying ERC-20.
20124
+ * Defaults to max uint256. Resets to zero first if there's an existing
20125
+ * non-zero allowance (required by tokens like USDT).
20534
20126
  *
20535
- * Zero encrypted values are mapped to `0n` without hitting the relayer.
20536
- * Events (`DecryptStart/End/Error`) are emitted uniformly.
20537
- * Relayer errors are wrapped into typed SDK errors.
20127
+ * @param amount - Optional approval amount. Defaults to max uint256.
20128
+ * @returns The transaction hash and mined receipt.
20538
20129
  *
20539
- * @param encryptedInput - Encrypted values to decrypt, each paired with its contract address.
20540
- * @param options - Per-call `signal` and `timeout` forwarded to the relayer round-trip.
20541
- * @returns A record mapping each encrypted value to its decrypted clear-text value.
20542
- * @throws if no signer is configured. {@link SignerNotConfiguredError}
20543
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20130
+ * @example
20131
+ * ```ts
20132
+ * await wrappedToken.approveUnderlying(); // max approval
20133
+ * await wrappedToken.approveUnderlying(1000n); // exact amount
20134
+ * ```
20135
+ */
20136
+ approveUnderlying(amount?: bigint): Promise<TransactionResult>;
20137
+ /**
20138
+ * Unshield a specific amount and finalize in one call.
20139
+ * Orchestrates: unshield → wait for receipt → parse event → finalize.
20140
+ *
20141
+ * By default, the SDK validates the confidential balance before submitting.
20142
+ * Set `skipBalanceCheck: true` to bypass this validation (e.g. for smart wallets).
20143
+ *
20144
+ * @param amount - The plaintext amount to unshield.
20145
+ * @param options - Optional: `skipBalanceCheck` (default `false`), callbacks.
20146
+ * @returns The finalize transaction hash and mined receipt.
20544
20147
  *
20545
20148
  * @example
20546
20149
  * ```ts
20547
- * const values = await sdk.decryption.decryptValues([
20548
- * { encryptedValue: balance, contractAddress: cUSDT },
20549
- * ]);
20550
- * console.log(values[balance]); // 1000n
20150
+ * const txHash = await wrappedToken.unshield(500n);
20551
20151
  * ```
20552
20152
  */
20553
- decryptValues(encryptedInput: EncryptedInput[], options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<Record<EncryptedValue, ClearValue>>;
20153
+ unshield(amount: bigint, options?: UnshieldOptions): Promise<TransactionResult>;
20554
20154
  /**
20555
- * Decrypt one or more FHE encrypted values using delegated credentials.
20155
+ * Unshield the entire balance and finalize in one call.
20156
+ * Orchestrates: unshieldAll → wait for receipt → parse event → finalize.
20556
20157
  *
20557
- * Mirrors {@link decryptValues} with delegated credentials — same caching and
20558
- * zero-value short-circuit. Before reading from cache or calling the relayer,
20559
- * every non-zero encrypted value's contract must have an active delegation from the
20560
- * delegator to the connected signer; missing or expired delegations fail fast.
20158
+ * @param callbacks - Optional progress callbacks for each phase.
20159
+ * @returns The finalize transaction hash and mined receipt.
20160
+ * @throws if the balance is zero. {@link DecryptionFailedError}
20561
20161
  *
20562
- * @param encryptedInputs - FHE encrypted values paired with their contract addresses.
20563
- * @param delegatorAddress - The address that granted delegation rights.
20564
- * @param accountAddress - Address used as the cache key's "requester"
20565
- * dimension. Defaults to `delegatorAddress`. Pass the actual account address
20566
- * when decrypting on behalf of someone whose balance is stored under a
20567
- * different address (e.g. `decryptBalanceAs` with an explicit `accountAddress`).
20568
- * @param options - Delegated-decrypt options. By default the call rides out the
20569
- * gateway propagation window ({@link DelegatedDecryptOptions.waitForPropagation});
20570
- * pass `{ waitForPropagation: false }` to fail fast instead.
20571
- * @returns Map of encrypted value → clear-text value.
20162
+ * @example
20163
+ * ```ts
20164
+ * const txHash = await wrappedToken.unshieldAll();
20165
+ * ```
20166
+ */
20167
+ unshieldAll(callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
20168
+ /**
20169
+ * Resume an in-progress unshield from an existing unwrap tx hash.
20170
+ * Useful when the user already submitted the unwrap but the finalize step
20171
+ * was interrupted (e.g. page reload, network error).
20172
+ *
20173
+ * @param unwrapTxHash - The transaction hash of the previously submitted unwrap.
20174
+ * @param callbacks - Optional progress callbacks.
20175
+ * @returns The finalize transaction hash and mined receipt.
20572
20176
  *
20573
20177
  * @example
20574
20178
  * ```ts
20575
- * const values = await sdk.decryption.delegatedDecryptValues([
20576
- * { encryptedValue: balance, contractAddress: tokenAddr },
20577
- * ], delegatorAddr);
20578
- * console.log(values[balance]); // 1000n
20179
+ * const txHash = await wrappedToken.resumeUnshield(previousUnwrapTxHash);
20579
20180
  * ```
20580
20181
  */
20581
- delegatedDecryptValues(encryptedInputs: EncryptedInput[], delegatorAddress: Address, accountAddress?: Address, options?: DelegatedDecryptOptions): Promise<Record<EncryptedValue, ClearValue>>;
20182
+ resumeUnshield(unwrapTxHash: Hex, callbacks?: UnshieldCallbacks): Promise<TransactionResult>;
20582
20183
  /**
20583
- * Publicly decrypt one or more FHE encrypted values.
20184
+ * Return the unwrap tx hash of an unshield that was interrupted between its
20185
+ * two phases, or `null` if none is pending for this wrapper.
20584
20186
  *
20585
- * Signer-independent: works without a configured signer.
20586
- * Returns the decryption proof alongside the clear-text values so callers
20587
- * can submit on-chain finalization transactions (e.g. `finalizeUnwrap`).
20187
+ * The SDK persists this automatically when {@link unshield}/{@link unshieldAll}
20188
+ * submit phase 1, and clears it once phase 2 finalizes. Use the returned hash
20189
+ * to surface a "resume" affordance, then pass it to {@link resumeUnshield}.
20190
+ * Resuming is intentionally caller-driven — auto-resuming on load would fire a
20191
+ * wallet transaction unprompted.
20588
20192
  *
20589
- * @param encryptedValues - FHE encrypted values to decrypt publicly.
20590
- * @param options - Per-call `signal` and `timeout` forwarded to the relayer round-trip.
20591
- * @returns Clear-text values, ABI-encoded values, and the decryption proof.
20193
+ * @returns The pending unwrap tx hash, or `null`.
20592
20194
  *
20593
20195
  * @example
20594
20196
  * ```ts
20595
- * const { clearValues, decryptionProof, abiEncodedClearValues } =
20596
- * await sdk.decryption.decryptPublicValues([encryptedValue]);
20197
+ * const unwrapTxHash = await wrappedToken.getPendingUnshield();
20198
+ * if (unwrapTxHash) await wrappedToken.resumeUnshield(unwrapTxHash);
20597
20199
  * ```
20598
20200
  */
20599
- decryptPublicValues(encryptedValues: EncryptedValue[], options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<DecryptPublicValuesResult>;
20201
+ getPendingUnshield(): Promise<Hex | null>;
20600
20202
  /**
20601
- * Batch-decrypt delegated encrypted values with per-entry error isolation.
20203
+ * Request an unwrap for a specific amount. Encrypts the amount first.
20204
+ * Call {@link finalizeUnwrap} after the request is processed on-chain.
20602
20205
  *
20603
- * Attempts a single batch request first. If the batch fails with a non-fatal
20604
- * error (e.g. one entry is invalid), falls back to per-entry decryption so
20605
- * healthy entries still resolve. Each item in the result carries either a
20606
- * decrypted value or an error — callers decide how to surface partial failures.
20206
+ * @param amount - The plaintext amount to unwrap (encrypted automatically).
20207
+ * @returns The transaction hash and mined receipt.
20607
20208
  *
20608
- * @param encryptedInputs - FHE encrypted values paired with their contract addresses.
20609
- * @param delegatorAddress - The address that granted delegation rights.
20610
- * @param accountAddress - The account on whose behalf decryption is performed. Defaults to `delegatorAddress`.
20611
- * @param maxConcurrency - Maximum parallel decrypt calls during per-entry fallback.
20612
- * @param waitForPropagation - Ride out the gateway propagation window on the
20613
- * initial batch attempt (default `true`). See {@link DelegatedDecryptOptions.waitForPropagation}.
20614
- * @returns Per-entry results, each with a value or an error.
20615
- * @throws if no signer is configured. {@link SignerNotConfiguredError}
20616
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20209
+ * @example
20210
+ * ```ts
20211
+ * const txHash = await wrappedToken.unwrap(500n);
20212
+ * ```
20213
+ */
20214
+ unwrap(amount: bigint): Promise<TransactionResult>;
20215
+ /**
20216
+ * Request an unwrap for the entire confidential balance.
20217
+ * Uses the on-chain encrypted balance directly (no encryption needed).
20218
+ * Throws if the balance is zero.
20219
+ *
20220
+ * @returns The transaction hash and mined receipt.
20221
+ * @throws if the balance is zero. {@link DecryptionFailedError}
20617
20222
  *
20618
20223
  * @example
20619
20224
  * ```ts
20620
- * const result = await sdk.decryption.delegatedBatchDecryptValues({
20621
- * encryptedInputs: [
20622
- * { encryptedValue: encryptedValue1, contractAddress: tokenA },
20623
- * { encryptedValue: encryptedValue2, contractAddress: tokenB },
20624
- * ],
20625
- * delegatorAddress: "0xDelegator",
20626
- * maxConcurrency: 5,
20627
- * });
20628
- * for (const item of result.items) {
20629
- * if (item.error) console.error(item.encryptedValue, item.error);
20630
- * else console.log(item.encryptedValue, item.value);
20631
- * }
20225
+ * const txHash = await wrappedToken.unwrapAll();
20632
20226
  * ```
20633
20227
  */
20634
- delegatedBatchDecryptValues({
20635
- encryptedInputs,
20636
- delegatorAddress,
20637
- accountAddress,
20638
- maxConcurrency,
20639
- waitForPropagation
20640
- }: {
20641
- encryptedInputs: EncryptedInput[];
20642
- delegatorAddress: Address;
20643
- accountAddress?: Address;
20644
- maxConcurrency?: number;
20645
- } & DelegatedDecryptOptions): Promise<BatchDecryptResult>;
20228
+ unwrapAll(): Promise<TransactionResult>;
20229
+ /**
20230
+ * Complete an unwrap by providing the public decryption proof.
20231
+ * Call this after an unshield request has been processed on-chain.
20232
+ *
20233
+ * @param unwrapRequestId - `unwrapRequestId` from the `UnwrapRequested` event.
20234
+ * @returns The transaction hash and mined receipt.
20235
+ *
20236
+ * @example
20237
+ * ```ts
20238
+ * const event = findUnwrapRequested(receipt.logs);
20239
+ * const txHash = await wrappedToken.finalizeUnwrap(event.unwrapRequestId);
20240
+ * ```
20241
+ */
20242
+ finalizeUnwrap(unwrapRequestId: EncryptedValue): Promise<TransactionResult>;
20646
20243
  }
20647
20244
  //#endregion
20648
- //#region src/namespaces/delegations.d.ts
20245
+ //#region src/wrappers-registry.d.ts
20649
20246
  /**
20650
- * Public namespace for on-chain decryption-delegation management.
20247
+ * Default wrappers registry addresses for known chains.
20248
+ * Only includes chains where a registry is deployed (excludes Hardhat).
20651
20249
  *
20652
- * Exposed as `sdk.delegations`. Owns the SDK-level guards (signer requirement, chain
20653
- * alignment, delegator address resolution from the wallet account) and delegates the
20654
- * actual work to the internal {@link DelegationService}.
20250
+ * @deprecated Read `registryAddress` from the chain presets instead (e.g.
20251
+ * `sepolia.registryAddress`). Will be removed in the next major version.
20252
+ */
20253
+ declare const DefaultRegistryAddresses: Record<number, Address>;
20254
+ /** Configuration for {@link WrappersRegistry}. */
20255
+ interface WrappersRegistryConfig {
20256
+ /** Read-only chain provider used for every registry lookup. */
20257
+ provider: GenericProvider;
20258
+ /**
20259
+ * Per-chain registry address overrides, merged on top of
20260
+ * {@link DefaultRegistryAddresses}. Use this to supply a registry
20261
+ * address for custom or local chains (e.g. Hardhat).
20262
+ *
20263
+ * @example
20264
+ * ```ts
20265
+ * new WrappersRegistry({
20266
+ * provider,
20267
+ * registryAddresses: { [31337]: "0xYourHardhatRegistry" },
20268
+ * });
20269
+ * ```
20270
+ */
20271
+ registryAddresses?: Record<number, Address>;
20272
+ /**
20273
+ * How long cached registry results remain valid, in seconds.
20274
+ * Default: `86400` (24 hours).
20275
+ */
20276
+ registryTTL?: number;
20277
+ }
20278
+ /** Options for {@link WrappersRegistry.listPairs}. */
20279
+ interface ListPairsOptions {
20280
+ /** Page number (1-indexed). Default: `1`. */
20281
+ page?: number;
20282
+ /** Number of items per page. Default: `100`. */
20283
+ pageSize?: number;
20284
+ /**
20285
+ * When `true`, fetches on-chain metadata (name, symbol, decimals) for both
20286
+ * the ERC-20 and confidential token, plus totalSupply for the ERC-20.
20287
+ * Default: `false`.
20288
+ */
20289
+ metadata?: boolean;
20290
+ }
20291
+ /**
20292
+ * High-level interface for the on-chain token wrappers registry.
20655
20293
  *
20656
- * Delegation operations write to the host chain ACL; after a delegation is mined,
20657
- * the gateway syncs the ACL state via cross-chain event propagation — usually
20658
- * within ~10 blocks (a few seconds). Delegated decryption rides out that window
20659
- * with a bounded internal retry, so callers can decrypt right after granting.
20294
+ * Uses the configured {@link GenericProvider} to resolve the correct registry
20295
+ * contract address for the current chain and exposes typed read helpers for
20296
+ * every registry query. Results are cached in memory with a configurable TTL
20297
+ * (default 24 hours).
20298
+ *
20299
+ * @example
20300
+ * ```ts
20301
+ * const registry = new WrappersRegistry({ provider });
20302
+ *
20303
+ * // Paginated listing
20304
+ * const page1 = await registry.listPairs({ page: 1, pageSize: 20 });
20305
+ *
20306
+ * // Structured lookups
20307
+ * const result = await registry.getConfidentialToken(erc20Address);
20308
+ * if (result) console.log(result.confidentialTokenAddress);
20309
+ *
20310
+ * // Force refresh
20311
+ * registry.refresh();
20312
+ * ```
20660
20313
  */
20661
- declare class Delegations {
20314
+ declare class WrappersRegistry {
20662
20315
  #private;
20663
- /** @internal */
20664
- constructor(opts: {
20665
- signer: GenericSigner | undefined;
20666
- provider: GenericProvider;
20667
- delegationService: DelegationService;
20668
- });
20316
+ readonly provider: GenericProvider;
20317
+ constructor(config: WrappersRegistryConfig);
20318
+ /**
20319
+ * Synchronous lookup of the registry address for a given chain ID.
20320
+ * Returns `undefined` if no address is configured for that chain.
20321
+ */
20322
+ getAddress(chainId: number): Address | undefined;
20669
20323
  /**
20670
- * Delegate decryption rights for a confidential contract to another address.
20671
- * Calls `ACL.delegateForUserDecryption()` on-chain.
20672
- *
20673
- * The delegation is recorded on L1 immediately, but the gateway must sync the
20674
- * ACL state via cross-chain event propagation — usually within ~10 blocks (a
20675
- * few seconds). You do not need to wait: delegated decryption rides out that
20676
- * window with a bounded internal retry, so you can decrypt right after this
20677
- * resolves.
20678
- *
20679
- * @param contractAddress - The confidential contract address to delegate on.
20680
- * @param delegateAddress - Address to delegate decryption rights to.
20681
- * @param expirationDate - Optional expiration date (defaults to permanent delegation via `uint64.max`).
20682
- * @returns The transaction hash and mined receipt.
20683
- * @throws if no signer is configured. {@link SignerNotConfiguredError}
20684
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20685
- * @throws if `expirationDate` is less than 1 hour in the future. {@link DelegationExpirationTooSoonError}
20686
- * @throws if the delegate equals the connected wallet. {@link DelegationSelfNotAllowedError}
20687
- * @throws if the delegate equals the contract address. {@link DelegationDelegateEqualsContractError}
20688
- * @throws if the new expiry equals the current one. {@link DelegationExpiryUnchangedError}
20689
- * @throws if the delegation transaction reverts. {@link TransactionRevertedError}
20324
+ * Force-invalidate the in-memory cache. The next call to any read method
20325
+ * will fetch fresh data from the chain.
20690
20326
  */
20691
- delegateDecryption({
20692
- contractAddress,
20693
- delegateAddress,
20694
- expirationDate
20695
- }: {
20696
- contractAddress: Address;
20697
- delegateAddress: Address;
20698
- expirationDate?: Date;
20699
- }): Promise<TransactionResult>;
20327
+ refresh(): void;
20700
20328
  /**
20701
- * Revoke decryption delegation for a confidential contract.
20702
- * Calls `ACL.revokeDelegationForUserDecryption()` on-chain.
20703
- *
20704
- * @param contractAddress - The confidential contract address to revoke delegation on.
20705
- * @param delegateAddress - Address to revoke delegation from.
20706
- * @returns The transaction hash and mined receipt.
20707
- * @throws if no signer is configured. {@link SignerNotConfiguredError}
20708
- * @throws if signer and provider are on different chains. {@link ChainMismatchError}
20709
- * @throws if no delegation exists for this (delegator, delegate, contract) tuple. {@link DelegationNotFoundError}
20710
- * @throws if the revocation transaction reverts. {@link TransactionRevertedError}
20329
+ * The cache TTL in milliseconds.
20330
+ * Exposed so query option factories can set a matching `staleTime`.
20711
20331
  */
20712
- revokeDelegation({
20713
- contractAddress,
20714
- delegateAddress
20715
- }: {
20716
- contractAddress: Address;
20717
- delegateAddress: Address;
20718
- }): Promise<TransactionResult>;
20332
+ get ttlMs(): number;
20719
20333
  /**
20720
- * Check whether a delegation is active for the given contract address.
20334
+ * Resolve the registry contract address for the current chain.
20721
20335
  *
20722
- * Signer-independent: works without a configured signer.
20336
+ * Priority: `registryAddresses[chainId]` \> built-in default.
20723
20337
  *
20724
- * @param contractAddress - The confidential contract address.
20725
- * @param delegatorAddress - The address that granted the delegation.
20726
- * @param delegateAddress - The address that received delegation rights.
20727
- * @returns `true` if the delegation exists and has not expired.
20338
+ * @returns The registry contract address for the connected chain.
20339
+ * @throws if no address is configured for the chain. {@link ConfigurationError}
20728
20340
  */
20729
- isActive(params: {
20730
- contractAddress: Address;
20731
- delegatorAddress: Address;
20732
- delegateAddress: Address;
20733
- }): Promise<boolean>;
20341
+ getRegistryAddress(): Promise<Address>;
20734
20342
  /**
20735
- * Get the expiration timestamp of a delegation for the given contract.
20343
+ * List token wrapper pairs with page-based pagination.
20736
20344
  *
20737
- * Signer-independent: works without a configured signer.
20345
+ * Internally maps to `getTokenConfidentialTokenPairsSlice` on-chain.
20738
20346
  *
20739
- * @param contractAddress - The confidential contract address.
20740
- * @param delegatorAddress - The address that granted the delegation.
20741
- * @param delegateAddress - The address that received delegation rights.
20742
- * @returns Unix timestamp as bigint. `0n` = no delegation. `2^64 - 1` = permanent.
20347
+ * @param options - Pagination and enrichment options.
20348
+ * @returns A {@link PaginatedResult} of pairs.
20349
+ *
20350
+ * @example
20351
+ * ```ts
20352
+ * const result = await registry.listPairs({ page: 1, pageSize: 20 });
20353
+ * console.log(`${result.total} pairs, showing page ${result.page}`);
20354
+ *
20355
+ * // With on-chain metadata
20356
+ * const withMeta = await registry.listPairs({ metadata: true, pageSize: 10 });
20357
+ * for (const pair of withMeta.items) {
20358
+ * console.log(pair.underlying.symbol, "→", pair.confidential.symbol);
20359
+ * }
20360
+ * ```
20743
20361
  */
20744
- getExpiry(params: {
20745
- contractAddress: Address;
20746
- delegatorAddress: Address;
20747
- delegateAddress: Address;
20748
- }): Promise<bigint>;
20749
- }
20750
- //#endregion
20751
- //#region src/namespaces/permits.d.ts
20752
- /**
20753
- * Public namespace for permit and transport-key-pair management.
20754
- *
20755
- * Exposed as `sdk.permits`. Owns the SDK-level guards (chain alignment, empty-array
20756
- * short-circuit, decrypt-cache invalidation) and delegates the actual work to the
20757
- * internal {@link CredentialService}.
20758
- *
20759
- * The namespace is named `permits` because the user-facing concept is the signed-permit
20760
- * store. The transport key pair is invisible plumbing — there is no `getTransportKeyPair()`
20761
- * surfaced; the key pair exists to sign permits and is created automatically when needed.
20762
- * {@link clear} wipes both the permit store and the transport key pair (permits
20763
- * cascade-delete with the key pair).
20764
- */
20765
- declare class Permits {
20766
- #private;
20767
- /** @internal */
20768
- constructor(opts: {
20769
- signer: GenericSigner | undefined;
20770
- provider: GenericProvider;
20771
- cachingService: CachingService;
20772
- credentialService: CredentialService | undefined;
20773
- logger: GenericLogger;
20774
- });
20362
+ listPairs(options: ListPairsOptions & {
20363
+ metadata: true;
20364
+ }): Promise<PaginatedResult<TokenWrapperPairWithMetadata>>;
20365
+ listPairs(options?: ListPairsOptions): Promise<PaginatedResult<TokenWrapperPair>>;
20775
20366
  /**
20776
- * Sign and store an EIP-712 permit authorising direct decryption for the
20777
- * given contract addresses.
20367
+ * Look up the confidential token for a given plain ERC-20 address.
20778
20368
  *
20779
- * Idempotent: if a permit covering the requested set already exists, no
20780
- * wallet prompt occurs. Otherwise the SDK chunks the uncovered subset into
20781
- * groups of ≤10 contracts and prompts once per chunk; partial mid-flight
20782
- * rejection is preserved (already-signed chunks are persisted before the
20783
- * next prompt).
20369
+ * @param tokenAddress - The plain ERC-20 token address.
20370
+ * @returns The lookup result, or `null` if the token has never been registered.
20371
+ * **Note:** revoked tokens (registered then invalidated) return a non-null result
20372
+ * with `isValid: false`. Check `result.isValid` explicitly rather than using
20373
+ * `if (result)` to guard against processing revoked tokens.
20784
20374
  *
20785
- * @param contracts - Contract addresses to authorize.
20375
+ * @example
20376
+ * ```ts
20377
+ * const result = await registry.getConfidentialToken(usdcAddress);
20378
+ * if (result?.isValid) {
20379
+ * console.log(result.confidentialTokenAddress);
20380
+ * }
20381
+ * ```
20786
20382
  */
20787
- grantPermit(contracts: Address[]): Promise<void>;
20383
+ getConfidentialToken(tokenAddress: Address): Promise<{
20384
+ confidentialTokenAddress: Address;
20385
+ isValid: boolean;
20386
+ } | null>;
20788
20387
  /**
20789
- * Sign and store an EIP-712 delegation permit authorising decryption on
20790
- * behalf of `delegator`. Same idempotence/chunking semantics as {@link grantPermit}.
20388
+ * Reverse lookup — find the plain ERC-20 for a given confidential token.
20791
20389
  *
20792
- * @param delegator - The address that delegated decryption rights to the connected signer.
20793
- * @param contracts - Contract addresses to authorize.
20390
+ * @param confidentialTokenAddress - The confidential token address.
20391
+ * @returns The lookup result, or `null` if no pair is registered.
20392
+ *
20393
+ * @example
20394
+ * ```ts
20395
+ * const result = await registry.getUnderlyingToken(cUsdcAddress);
20396
+ * if (result) {
20397
+ * console.log(result.tokenAddress, result.isValid);
20398
+ * }
20399
+ * ```
20794
20400
  */
20795
- grantDelegationPermit(delegator: Address, contracts: Address[]): Promise<void>;
20401
+ getUnderlyingToken(confidentialTokenAddress: Address): Promise<{
20402
+ tokenAddress: Address;
20403
+ isValid: boolean;
20404
+ } | null>;
20796
20405
  /**
20797
- * Pure store lookup: is there a permit covering `contracts`?
20798
- * No wallet prompt, no transport key pair generation. Returns `false` when no signer
20799
- * is configured.
20406
+ * Fetch all token wrapper pairs from the registry.
20407
+ *
20408
+ * @returns All registered `TokenWrapperPair` entries.
20800
20409
  */
20801
- hasPermit(contracts: Address[]): Promise<boolean>;
20410
+ getTokenPairs(): Promise<readonly TokenWrapperPair[]>;
20802
20411
  /**
20803
- * Pure store lookup for a delegation permit. See {@link hasPermit}.
20412
+ * Get the total number of token wrapper pairs.
20804
20413
  *
20805
- * @param delegator - The address that delegated decryption rights to the connected signer.
20806
- * @param contracts - Contract addresses to check.
20807
- * @returns `true` if cached delegation permits cover all requested contracts.
20414
+ * @returns The count as a bigint.
20808
20415
  */
20809
- hasDelegationPermit(delegator: Address, contracts: Address[]): Promise<boolean>;
20416
+ getTokenPairsLength(): Promise<bigint>;
20810
20417
  /**
20811
- * Best-effort transport-key-pair prefetch for the connected signer.
20418
+ * Fetch a range of token wrapper pairs (paginated by index).
20812
20419
  *
20813
- * Optional latency optimization: decrypt and permit flows remain correct
20814
- * without it because they lazily create the transport key pair when needed.
20420
+ * @param fromIndex - Start index (inclusive).
20421
+ * @param toIndex - End index (exclusive).
20422
+ * @returns The slice of `TokenWrapperPair` entries.
20423
+ */
20424
+ getTokenPairsSlice(fromIndex: bigint, toIndex: bigint): Promise<readonly TokenWrapperPair[]>;
20425
+ /**
20426
+ * Fetch a single token wrapper pair by index.
20815
20427
  *
20816
- * Silent no-op when no signer is configured or no wallet account is
20817
- * available. The transport key pair is generated through the relayer dispatcher's
20818
- * currently active chain — see {@link LifecycleService}, which calls
20819
- * `switchChain` before fanning the wallet-account change out to listeners,
20820
- * so any downstream caller (including React adapters) observes the
20821
- * dispatcher on the wallet chain by the time it invokes warmup.
20428
+ * @param index - Zero-based pair index.
20429
+ * @returns The `TokenWrapperPair` at that index.
20822
20430
  */
20823
- warmTransportKeyPair(): Promise<void>;
20431
+ getTokenPair(index: bigint): Promise<TokenWrapperPair>;
20824
20432
  /**
20825
- * Wipe FHE permits for the current signer.
20433
+ * Look up the confidential token address for a given plain ERC-20 token.
20826
20434
  *
20827
- * - With no argument: every permit referencing this signer is removed across
20828
- * all chains and delegators. The transport key pair survives — use {@link clear} to
20829
- * also wipe the transport key pair.
20830
- * - With a contract list: every signed permit in the direct-decrypt scope
20831
- * (current chain) whose immutable payload touches any listed address is
20832
- * removed. Delegation permits are not touched in this mode.
20435
+ * @param tokenAddress - The plain ERC-20 token address.
20436
+ * @returns A tuple `[isValid, confidentialTokenAddress]`. `isValid` is `true` only for a
20437
+ * registered, non-revoked wrapper. The address is the zero address when no pair is registered.
20438
+ * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
20439
+ */
20440
+ getConfidentialTokenAddress(tokenAddress: Address): Promise<readonly [boolean, Address]>;
20441
+ /**
20442
+ * Reverse lookup — find the plain ERC-20 for a given confidential token.
20833
20443
  *
20834
- * @throws if no signer is configured. {@link SignerNotConfiguredError}
20444
+ * @param confidentialTokenAddress - The confidential token address.
20445
+ * @returns A tuple `[isValid, tokenAddress]`. `isValid` is `true` only for a registered,
20446
+ * non-revoked wrapper. The address is the zero address when no pair is registered.
20447
+ * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
20835
20448
  */
20836
- revokePermits(contracts?: Address[]): Promise<void>;
20449
+ getTokenAddress(confidentialTokenAddress: Address): Promise<readonly [boolean, Address]>;
20837
20450
  /**
20838
- * Wipe the transport key pair for the current signer and cascade-delete every permit
20839
- * (across chains and delegators) referencing it.
20451
+ * Check whether a confidential token is registered and valid.
20840
20452
  *
20841
- * @throws if no signer is configured. {@link SignerNotConfiguredError}
20453
+ * @param confidentialTokenAddress - The confidential token address to check.
20454
+ * @returns `true` if the token is a known valid wrapper in the registry.
20842
20455
  */
20843
- clear(): Promise<void>;
20456
+ isConfidentialTokenValid(confidentialTokenAddress: Address): Promise<boolean>;
20844
20457
  }
20845
20458
  //#endregion
20846
20459
  //#region src/zama-sdk.d.ts
@@ -21001,5 +20614,74 @@ declare class ZamaSDK {
21001
20614
  [Symbol.dispose](): void;
21002
20615
  }
21003
20616
  //#endregion
21004
- export { confidentialTransferMutationOptions as $, getTokenAddressContract as $n, DelegationSelfNotAllowedError as $t, encryptMutationOptions as A, QueryFilterLike as An, setOperatorContract as Ar, SignerRequiredError as At, UnshieldParams as B, invalidateWagmiBalanceQueries as Bn, InsufficientConfidentialBalanceError as Bt, grantPermitMutationOptions as C, IsConfidentialQueryConfig as Cn, confidentialTotalSupplyContract as Cr, BatchDecryptAsOptions as Ct, DecryptResult as D, TokenMetadataQueryConfig as Dn, inferredTotalSupplyContract as Dr, SigningFailedError as Dt, delegatedDecryptValuesMutationOptions as E, TokenMetadata as En, finalizeUnwrapContract as Er, TransactionRevertedError as Et, unwrapMutationOptions as F, invalidateAfterTransfer as Fn, ResolvedChainRelayer as Fr, ConfigurationError as Ft, confidentialSetOperatorMutationOptions as G, QueryFactoryOptions as Gn, DelegationContractIsSelfError as Gt, ApproveUnderlyingParams as H, zamaQueryKeys as Hn, DecryptionFailedError as Ht, ResumeUnshieldParams as I, invalidateAfterUnshield as In, resolveChainRelayers as Ir, RelayerRequestFailedError as It, ConfidentialTransferFromParams as J, hashFn as Jn, DelegationExpirationTooSoonError as Jt, ConfidentialTransferFromAndCallParams as K, StrippedQueryOptionKeys as Kn, DelegationCooldownError as Kt, resumeUnshieldMutationOptions as L, invalidateAfterUnshieldSettled as Ln, resolveStorage as Lr, BalanceCheckUnavailableError as Lt, finalizeUnwrapMutationOptions as M, invalidateAfterApproveUnderlying as Mn, unwrapContract as Mr, WalletNotConnectedError as Mt, unwrapAllMutationOptions as N, invalidateAfterSetOperator as Nn, unwrapFromBalanceContract as Nr, RpcRateLimitError as Nt, EncryptedInput as O, tokenMetadataQueryOptions as On, isOperatorContract as Or, SigningRejectedError as Ot, UnwrapParams as P, invalidateAfterShield as Pn, wrapContract as Pr, NotEntitledError as Pt, ConfidentialTransferParams as Q, getConfidentialTokenAddressContract as Qn, DelegationNotPropagatedError as Qt, UnshieldAllParams as R, invalidateAfterUnwrap as Rn, createConfig as Rr, BalanceErrorDetails as Rt, hasPermitQueryOptions as S, totalSupplyQueryOptions as Sn, confidentialBalanceOfContract as Sr, BatchBalancesResult as St, DelegatedDecryptValuesMutationParams as T, isWrapperQueryOptions as Tn, confidentialTransferFromContract as Tr, matchZamaError as Tt, approveUnderlyingMutationOptions as U, SignerQueryContext as Un, EncryptionFailedError as Ut, unshieldMutationOptions as V, invalidateWalletLifecycleQueries as Vn, InsufficientERC20BalanceError as Vt, ConfidentialSetOperatorParams as W, MutationFactoryOptions as Wn, AclPausedError as Wt, ConfidentialTransferAndCallParams as X, TokenWrapperPair as Xn, DelegationExpiryUnchangedError as Xt, confidentialTransferFromMutationOptions as Y, PaginatedResult as Yn, DelegationExpiredError as Yt, confidentialTransferAndCallMutationOptions as Z, TokenWrapperPairWithMetadata as Zn, DelegationNotFoundError as Zt, DelegateDecryptionParams as _, WrappersRegistryConfig as _n, approveContract as _r, ConfidentialBalancesQueryConfig as _t, BatchDecryptItem as a, ZamaErrorCode as an, delegateForUserDecryptionContract as ar, TokenAddressQueryConfig as at, revokePermitsMutationOptions as b, StoredTransportKeyPair as bn, nameContract as br, confidentialBalanceQueryOptions as bt, DelegationStatusData as c, PendingUnshieldQueryConfig as cn, revokeDelegationContract as cr, WrappersRegistryQueryConfig as ct, RevokeDelegationParams as d, underlyingAllowanceQueryOptions as dn, ERC7984_INTERFACE_ID as dr, listPairsQueryOptions as dt, InvalidTransportKeyPairError as en, getTokenPairContract as er, ShieldParams as et, revokeDelegationMutationOptions as f, WrapperDiscoveryQueryConfig as fn, ERC7984_WRAPPER_INTERFACE_ID as fr, tokenAddressQueryOptions as ft, decryptBalanceAsMutationOptions as g, WrappersRegistry as gn, allowanceContract as gr, tokenPairsSliceQueryOptions as gt, DecryptBalanceAsParams as h, ListPairsOptions as hn, supportsInterfaceContract as hr, tokenPairsQueryOptions as ht, Decryption as i, ZamaError as in, isConfidentialTokenValidContract as ir, ListPairsQueryConfig as it, FinalizeUnwrapParams as j, QueryLike as jn, underlyingContract as jr, WalletAccountNotReadyError as jt, decryptValuesQueryOptions as k, QueryClientLike as kn, rateContract as kr, SignerNotConfiguredError as kt, DelegationStatusQueryConfig as l, pendingUnshieldQueryOptions as ln, transferAndCallContract as lr, confidentialTokenAddressQueryOptions as lt, batchDecryptBalancesAsMutationOptions as m, DefaultRegistryAddresses as mn, isConfidentialWrapperContract as mr, tokenPairsLengthQueryOptions as mt, Permits as n, TransportKeyPairExpiredError as nn, getTokenPairsLengthContract as nr, ConfidentialTokenAddressQueryConfig as nt, BatchDecryptResult as o, ConfidentialIsOperatorQueryConfig as on, getDelegationExpiryContract as or, TokenPairQueryConfig as ot, BatchDecryptBalancesAsParams as p, wrapperDiscoveryQueryOptions as pn, isConfidentialTokenContract as pr, tokenPairQueryOptions as pt, confidentialTransferFromAndCallMutationOptions as q, filterQueryOptions as qn, DelegationDelegateEqualsContractError as qt, Delegations as r, ChainMismatchError as rn, getTokenPairsSliceContract as rr, IsConfidentialTokenValidQueryConfig as rt, DelegatedDecryptOptions as s, confidentialIsOperatorQueryOptions as sn, isHandleDelegatedContract as sr, TokenPairsSliceQueryConfig as st, ZamaSDK as t, NoCiphertextError as tn, getTokenPairsContract as tr, shieldMutationOptions as tt, delegationStatusQueryOptions as u, UnderlyingAllowanceQueryConfig as un, ERC1363_INTERFACE_ID as ur, isConfidentialTokenValidQueryOptions as ut, delegateDecryptionMutationOptions as v, Permission as vn, balanceOfContract as vr, confidentialBalancesQueryOptions as vt, decryptPublicValuesMutationOptions as w, isConfidentialQueryOptions as wn, confidentialTransferContract as wr, Token as wt, HasPermitQueryConfig as x, TotalSupplyQueryConfig as xn, symbolContract as xr, WrappedToken as xt, clearCredentialsMutationOptions as y, SerializedTransportKeyPair as yn, decimalsContract as yr, ConfidentialBalanceQueryConfig as yt, unshieldAllMutationOptions as z, invalidateBalanceQueries as zn, ERC20ReadFailedError as zt };
21005
- //# sourceMappingURL=zama-sdk-q4_qt64Q.d.ts.map
20617
+ //#region src/utils/handles.d.ts
20618
+ declare const ZERO_ENCRYPTED_VALUE: "0x0000000000000000000000000000000000000000000000000000000000000000";
20619
+ /**
20620
+ * Check whether an encrypted value represents the zero value.
20621
+ */
20622
+ declare function isEncryptedValueZero(encryptedValue: string): boolean;
20623
+ //#endregion
20624
+ //#region src/storage/memory-storage.d.ts
20625
+ /** In-memory credential store. Credentials are lost on page reload. */
20626
+ declare class MemoryStorage implements GenericStorage {
20627
+ #private;
20628
+ get<T = unknown>(key: string): Promise<T | null>;
20629
+ set<T = unknown>(key: string, value: T): Promise<void>;
20630
+ delete(key: string): Promise<void>;
20631
+ }
20632
+ /** Default singleton for application-wide use. */
20633
+ declare const memoryStorage: MemoryStorage;
20634
+ //#endregion
20635
+ //#region src/storage/indexeddb-storage.d.ts
20636
+ /**
20637
+ * IndexedDB-backed {@link GenericStorage}.
20638
+ *
20639
+ * Stores keypair and permit objects keyed by a hashed wallet address. The
20640
+ * SDK delegates security to the storage backend — values are persisted
20641
+ * verbatim with no SDK-layer encryption.
20642
+ */
20643
+ declare class IndexedDBStorage implements GenericStorage {
20644
+ #private;
20645
+ constructor(dbName?: string, dbVersion?: number, storeName?: string);
20646
+ get<T = unknown>(key: string): Promise<T | null>;
20647
+ set<T = unknown>(key: string, value: T): Promise<void>;
20648
+ delete(key: string): Promise<void>;
20649
+ clear(): Promise<void>;
20650
+ }
20651
+ /** Default singleton for application-wide use. */
20652
+ declare const indexedDBStorage: IndexedDBStorage;
20653
+ //#endregion
20654
+ //#region src/storage/chrome-session-storage.d.ts
20655
+ /**
20656
+ * {@link GenericStorage} backed by `chrome.storage.session`.
20657
+ *
20658
+ * Use this in MV3 web extensions so the wallet signature survives
20659
+ * service worker restarts and is shared across popup, background,
20660
+ * and content script contexts.
20661
+ *
20662
+ * @example
20663
+ * ```ts
20664
+ * import { ZamaSDK, indexedDBStorage, chromeSessionStorage } from "@zama-fhe/sdk";
20665
+ * import { createConfig } from "@zama-fhe/sdk/viem";
20666
+ *
20667
+ * const config = createConfig({
20668
+ * chains: [mySepolia],
20669
+ * publicClient,
20670
+ * walletClient,
20671
+ * relayers: { [mySepolia.id]: web() },
20672
+ * storage: indexedDBStorage, // encrypted transport key pair — persistent
20673
+ * permitStorage: chromeSessionStorage, // signed permits — ephemeral
20674
+ * });
20675
+ * const sdk = new ZamaSDK(config);
20676
+ * ```
20677
+ */
20678
+ declare class ChromeSessionStorage implements GenericStorage {
20679
+ get<T = unknown>(key: string): Promise<T | null>;
20680
+ set(key: string, value: unknown): Promise<void>;
20681
+ delete(key: string): Promise<void>;
20682
+ }
20683
+ /** Default singleton for application-wide use. */
20684
+ declare const chromeSessionStorage: ChromeSessionStorage;
20685
+ //#endregion
20686
+ export { DelegationNotPropagatedError as $, underlyingContract as $t, SignerNotConfiguredError as A, revokeDelegationContract as At, ERC20ReadFailedError as B, balanceOfContract as Bt, BatchDecryptItem as C, getTokenPairsContract as Ct, TransactionRevertedError as D, delegateForUserDecryptionContract as Dt, matchZamaError as E, isConfidentialTokenValidContract as Et, NotEntitledError as F, isConfidentialTokenContract as Ft, AclPausedError as G, confidentialTotalSupplyContract as Gt, InsufficientERC20BalanceError as H, nameContract as Ht, ConfigurationError as I, isConfidentialWrapperContract as It, DelegationDelegateEqualsContractError as J, finalizeUnwrapContract as Jt, DelegationContractIsSelfError as K, confidentialTransferContract as Kt, RelayerRequestFailedError as L, supportsInterfaceContract as Lt, WalletAccountNotReadyError as M, ERC1363_INTERFACE_ID as Mt, WalletNotConnectedError as N, ERC7984_INTERFACE_ID as Nt, SigningFailedError as O, getDelegationExpiryContract as Ot, RpcRateLimitError as P, ERC7984_WRAPPER_INTERFACE_ID as Pt, DelegationNotFoundError as Q, setOperatorContract as Qt, BalanceCheckUnavailableError as R, allowanceContract as Rt, Decryption as S, getTokenPairContract as St, DelegatedDecryptOptions as T, getTokenPairsSliceContract as Tt, DecryptionFailedError as U, symbolContract as Ut, InsufficientConfidentialBalanceError as V, decimalsContract as Vt, EncryptionFailedError as W, confidentialBalanceOfContract as Wt, DelegationExpiredError as X, isOperatorContract as Xt, DelegationExpirationTooSoonError as Y, inferredTotalSupplyContract as Yt, DelegationExpiryUnchangedError as Z, rateContract as Zt, BatchBalancesResult as _, PaginatedResult as _t, IndexedDBStorage as a, resolveStorage as an, ZamaError as at, Permits as b, getConfidentialTokenAddressContract as bt, memoryStorage as c, SerializedTransportKeyPair as ct, ZamaSDK as d, EncryptedInput as dt, unwrapContract as en, DelegationSelfNotAllowedError as et, DefaultRegistryAddresses as f, decryptValuesQueryOptions as ft, WrappedToken as g, QueryFactoryOptions as gt, WrappersRegistryConfig as h, MutationFactoryOptions as ht, chromeSessionStorage as i, resolveChainRelayers as in, ChainMismatchError as it, SignerRequiredError as j, transferAndCallContract as jt, SigningRejectedError as k, isHandleDelegatedContract as kt, ZERO_ENCRYPTED_VALUE as l, StoredTransportKeyPair as lt, WrappersRegistry as m, zamaQueryKeys as mt, Hex$1 as n, wrapContract as nn, NoCiphertextError as nt, indexedDBStorage as o, createConfig as on, ZamaErrorCode as ot, ListPairsOptions as p, SignerQueryContext as pt, DelegationCooldownError as q, confidentialTransferFromContract as qt, ChromeSessionStorage as r, ResolvedChainRelayer as rn, TransportKeyPairExpiredError as rt, MemoryStorage as s, Permission as st, Address$1 as t, unwrapFromBalanceContract as tn, InvalidTransportKeyPairError as tt, isEncryptedValueZero as u, DecryptResult as ut, BatchDecryptAsOptions as v, TokenWrapperPair as vt, BatchDecryptResult as w, getTokenPairsLengthContract as wt, Delegations as x, getTokenAddressContract as xt, Token as y, TokenWrapperPairWithMetadata as yt, BalanceErrorDetails as z, approveContract as zt };
20687
+ //# sourceMappingURL=index-DqSX9TRp.d.ts.map