@zama-fhe/sdk 3.5.0-alpha.7 → 3.5.0-alpha.8

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.
@@ -2,9 +2,9 @@ import { d as FheChain } from "./index-B0XC8EfF.js";
2
2
  import { D as GenericSigner, O as WalletAccount, Qt as DecryptPublicValuesResult, S as TransactionKind, Xt as TransactionResult, Zt as ClearValue, _ as PrepareTransactionRequest, _t as UnwrapResult, bt as TransferCallbacks, c as GenericStorage, g as PrepareOptions, gt as UnshieldOptions, ht as TransferOptions, i as ZamaConfig, in as EncryptedValue, l as GenericProvider, nn as EncryptParams, o as ZamaConfigGeneric, pt as ShieldOptions, rn as EncryptResult, sn as FhevmRelayerOptions, un as RelayerSDK, v as PreparedFor, vt as WrapOptions, xt as UnshieldCallbacks } from "./types-GctypAZx.js";
3
3
  import "./cleartext-BEXEaFxR.js";
4
4
  import "./types-CDEEf-TG.js";
5
+ import "./base-signer-CMcmGqJV.js";
5
6
  import "./types-CViUZmxp.js";
6
- import "./index-DE92igPK.js";
7
- import { Address, Hex } from "viem";
7
+ import { Address, Address as Address$1, Hex, Hex as Hex$1 } from "viem";
8
8
  import { z } from "zod/mini";
9
9
  import { MutationFunctionContext, QueryKey, QueryObserverOptions, skipToken } from "@tanstack/query-core";
10
10
  //#region src/config/create.d.ts
@@ -19355,768 +19355,180 @@ declare class Delegations {
19355
19355
  }): Promise<DelegationStatus>;
19356
19356
  }
19357
19357
  //#endregion
19358
- //#region src/query/utils.d.ts
19359
- /** Union of TanStack Query option keys stripped by {@link filterQueryOptions}, leaving only domain parameters. */
19360
- type StrippedQueryOptionKeys = "gcTime" | "staleTime" | "enabled" | "select" | "refetchInterval" | "refetchOnMount" | "refetchOnWindowFocus" | "refetchOnReconnect" | "retry" | "retryDelay" | "retryOnMount" | "queryFn" | "queryKey" | "queryKeyHashFn" | "initialData" | "initialDataUpdatedAt" | "placeholderData" | "structuralSharing" | "throwOnError" | "meta" | "query" | "pollingInterval";
19361
- /**
19362
- * Remove TanStack behavioral options from a query config object so only domain
19363
- * parameters remain for the lower-level factory.
19364
- *
19365
- * @example
19366
- * ```ts
19367
- * const params = filterQueryOptions({
19368
- * query: { enabled: false },
19369
- * gcTime: 60_000,
19370
- * owner: "0xabc",
19371
- * });
19372
- * // => { owner: "0xabc" }
19373
- * ```
19374
- */
19375
- declare function filterQueryOptions<TOptions extends Record<string, unknown>>(options: TOptions): Omit<TOptions, StrippedQueryOptionKeys>;
19376
- /**
19377
- * Stable hash function for query keys.
19378
- * Sorts object keys recursively and converts bigint values to strings.
19379
- *
19380
- * @remarks
19381
- * bigint values are serialized as decimal strings, so `42n` and `"42"` hash to
19382
- * the same token when they occupy the same position. This collision is accepted
19383
- * by design for the current query-key conventions in this package.
19384
- */
19385
- declare function hashFn(queryKey: readonly unknown[]): string;
19386
- //#endregion
19387
- //#region src/query/factory-types.d.ts
19358
+ //#region src/namespaces/offline.d.ts
19388
19359
  /**
19389
- * TanStack Query options object returned by the SDK's `*QueryOptions` factories:
19390
- * `QueryObserverOptions` with `queryKey` and `queryFn` required and the
19391
- * cache-internal keys (`queryHash`, `queryKeyHashFn`, `throwOnError`) removed.
19360
+ * Namespace for the offline-signing pipeline —
19361
+ * `prepare → [external sign + self-publish]` — for institutional custody, HSM
19362
+ * ceremonies, and policy-engine workflows where signing runs out-of-process and
19363
+ * cannot happen synchronously in a single Promise.
19392
19364
  */
19393
- type QueryFactoryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey"> & Required<Pick<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey">>, "queryFn" | "queryHash" | "queryKeyHashFn" | "throwOnError"> & {
19394
- queryFn: Exclude<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>["queryFn"], typeof skipToken | undefined>;
19395
- };
19396
- /** TanStack Query mutation options object returned by the SDK's `*MutationOptions` factories. */
19397
- interface MutationFactoryOptions<TMutationKey extends readonly unknown[], TVariables, TData, TOnMutateResult = unknown> {
19398
- /** Cache key identifying the mutation. */
19399
- mutationKey: TMutationKey;
19400
- /** Runs the mutation for the given variables. */
19401
- mutationFn: (variables: TVariables) => Promise<TData>;
19402
- /** Optional callback invoked after the mutation succeeds. */
19403
- onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => void;
19365
+ declare class Offline {
19366
+ #private;
19367
+ /**
19368
+ * Build an RLP-encoded unsigned transaction for the given request. The
19369
+ * caller signs it externally — via an HSM ceremony, an out-of-process
19370
+ * custodian, or any signer holding the key — and broadcasts the signed bytes
19371
+ * through its own channel.
19372
+ *
19373
+ * Signer-optional: works without a configured signer (canonical shape for
19374
+ * cross-process custody — the back-end signer service consumes
19375
+ * `prepared.unsignedTx` and returns signed bytes).
19376
+ *
19377
+ * @remarks
19378
+ * `request.from` is only a declaration — the SDK does not prove the caller
19379
+ * controls it, and an EIP-1559 unsigned tx carries no `from` field at all
19380
+ * (the on-chain sender is whichever key signs the bytes). Point `from` at
19381
+ * the account the custodian will sign with; custodians enforce key-control
19382
+ * at sign time — a signing request for a key the credential can't use fails
19383
+ * there — so a mismatched `from` cannot make the custodian sign from an
19384
+ * account you don't control. Verifying control of `from` up front is still
19385
+ * the application's responsibility.
19386
+ */
19387
+ prepare<K extends TransactionKind>(request: Extract<PrepareTransactionRequest, {
19388
+ kind: K;
19389
+ }>, options?: PrepareOptions): Promise<PreparedFor<K>>;
19404
19390
  }
19405
19391
  //#endregion
19406
- //#region src/query/signer-query-context.d.ts
19407
- /** Connected-wallet context threaded into query factories to scope cache keys and gate signer-dependent queries. */
19408
- interface SignerQueryContext {
19409
- /** Connected wallet account; queries that need a signer stay disabled until it is set. */
19410
- walletAccount?: WalletAccount;
19392
+ //#region src/token/token.d.ts
19393
+ /** Options for {@link Token.batchDecryptBalancesAs}. */
19394
+ interface BatchDecryptAsOptions {
19395
+ /** The address of the account that delegated decryption rights. */
19396
+ delegatorAddress: Address;
19397
+ /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */
19398
+ encryptedValues?: EncryptedValue[];
19399
+ /**
19400
+ * The account whose on-chain balance to read. Defaults to the delegator
19401
+ * address, which is the common case (the delegator grants permission to
19402
+ * decrypt their own balance). Only set this when the account differs
19403
+ * from the delegator.
19404
+ *
19405
+ * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.
19406
+ */
19407
+ accountAddress?: Address;
19408
+ /** Maximum number of concurrent decrypt calls. Default: 10. */
19409
+ maxConcurrency?: number;
19410
+ /** Called when decryption fails for a single token. Return a fallback bigint. */
19411
+ onError?: (error: Error, address: Address) => bigint;
19412
+ }
19413
+ /** Result of {@link Token.batchBalancesOf}. */
19414
+ interface BatchBalancesResult {
19415
+ /** Successfully decrypted balances, keyed by token address. */
19416
+ results: Map<Address, bigint>;
19417
+ /** Per-token errors for tokens that failed to decrypt. */
19418
+ errors: Map<Address, ZamaError>;
19411
19419
  }
19412
- //#endregion
19413
- //#region src/query/query-keys.d.ts
19414
19420
  /**
19415
- * Canonical query-key namespace for `@zama-fhe/sdk/query`.
19421
+ * High-level interface for an ERC-7984 confidential token.
19422
+ * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind
19423
+ * familiar ERC-20-like methods.
19416
19424
  *
19417
- * @example
19418
- * ```ts
19419
- * queryClient.invalidateQueries({
19420
- * queryKey: zamaQueryKeys.confidentialBalance.token("0xToken"),
19421
- * });
19422
- * ```
19425
+ * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —
19426
+ * it extends `Token` with wrapper-specific operations.
19427
+ *
19428
+ * Decryption, credentials, caching, and event emission are handled by the
19429
+ * owning {@link ZamaSDK} — this class only exposes token-scoped helpers
19430
+ * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.
19423
19431
  */
19424
- declare const zamaQueryKeys: {
19425
- readonly confidentialBalance: {
19426
- readonly all: readonly ["zama.confidentialBalance"];
19427
- readonly token: (tokenAddress: Address) => readonly ["zama.confidentialBalance", {
19428
- readonly tokenAddress: `0x${string}`;
19429
- }];
19430
- readonly owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalance", {
19431
- readonly owner?: `0x${string}` | undefined;
19432
- readonly walletAddress: `0x${string}`;
19433
- readonly walletChainId: number;
19434
- readonly tokenAddress: `0x${string}`;
19435
- } | {
19436
- readonly owner?: `0x${string}` | undefined;
19437
- readonly walletAddress?: undefined;
19438
- readonly walletChainId?: undefined;
19439
- readonly tokenAddress: `0x${string}`;
19440
- }];
19441
- };
19442
- readonly confidentialBalances: {
19443
- readonly all: readonly ["zama.confidentialBalances"];
19444
- readonly tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalances", {
19445
- readonly owner?: `0x${string}` | undefined;
19446
- readonly walletAddress: `0x${string}`;
19447
- readonly walletChainId: number;
19448
- readonly tokenAddresses: `0x${string}`[];
19449
- } | {
19450
- readonly owner?: `0x${string}` | undefined;
19451
- readonly walletAddress?: undefined;
19452
- readonly walletChainId?: undefined;
19453
- readonly tokenAddresses: `0x${string}`[];
19454
- }];
19455
- };
19456
- readonly tokenMetadata: {
19457
- readonly all: readonly ["zama.tokenMetadata"];
19458
- readonly token: (tokenAddress: Address) => readonly ["zama.tokenMetadata", {
19459
- readonly tokenAddress: `0x${string}`;
19460
- }];
19461
- };
19462
- readonly isConfidential: {
19463
- readonly all: readonly ["zama.isConfidential"];
19464
- readonly token: (tokenAddress: Address) => readonly ["zama.isConfidential", {
19465
- readonly tokenAddress: `0x${string}`;
19466
- }];
19467
- };
19468
- readonly isWrapper: {
19469
- readonly all: readonly ["zama.isWrapper"];
19470
- readonly token: (tokenAddress: Address) => readonly ["zama.isWrapper", {
19471
- readonly tokenAddress: `0x${string}`;
19472
- }];
19473
- };
19474
- readonly wrapperDiscovery: {
19475
- readonly all: readonly ["zama.wrapperDiscovery"];
19476
- readonly token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => readonly ["zama.wrapperDiscovery", {
19477
- readonly registryAddress?: `0x${string}` | undefined;
19478
- readonly erc20Address?: `0x${string}` | undefined;
19479
- readonly tokenAddress?: `0x${string}` | undefined;
19480
- }];
19481
- };
19482
- readonly underlyingAllowance: {
19483
- readonly all: readonly ["zama.underlyingAllowance"];
19484
- readonly token: (tokenAddress: Address) => readonly ["zama.underlyingAllowance", {
19485
- readonly tokenAddress: `0x${string}`;
19486
- }];
19487
- readonly scope: (tokenAddress: Address, owner?: Address) => readonly ["zama.underlyingAllowance", {
19488
- readonly owner?: `0x${string}` | undefined;
19489
- readonly tokenAddress: `0x${string}`;
19490
- }];
19491
- };
19492
- readonly confidentialIsOperator: {
19493
- readonly all: readonly ["zama.confidentialIsOperator"];
19494
- readonly token: (tokenAddress?: Address) => readonly ["zama.confidentialIsOperator", {
19495
- tokenAddress: `0x${string}`;
19496
- } | {
19497
- tokenAddress?: undefined;
19498
- }];
19499
- readonly scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => readonly ["zama.confidentialIsOperator", {
19500
- readonly spender?: `0x${string}` | undefined;
19501
- readonly holder?: `0x${string}` | undefined;
19502
- readonly tokenAddress?: `0x${string}` | undefined;
19503
- }];
19504
- };
19505
- readonly totalSupply: {
19506
- readonly all: readonly ["zama.totalSupply"];
19507
- readonly token: (tokenAddress: Address) => readonly ["zama.totalSupply", {
19508
- readonly tokenAddress: `0x${string}`;
19509
- }];
19510
- };
19511
- readonly pendingUnshield: {
19512
- readonly all: readonly ["zama.pendingUnshield"];
19513
- readonly token: (tokenAddress: Address) => readonly ["zama.pendingUnshield", {
19514
- readonly tokenAddress: `0x${string}`;
19515
- }];
19516
- };
19517
- readonly hasPermit: {
19518
- readonly all: readonly ["zama.hasPermit"];
19519
- readonly scope: (contractAddresses: Address[], walletAccount?: WalletAccount) => readonly ["zama.hasPermit", {
19520
- readonly contractAddresses: `0x${string}`[];
19521
- readonly walletAddress: `0x${string}`;
19522
- readonly walletChainId: number;
19523
- } | {
19524
- readonly contractAddresses: `0x${string}`[];
19525
- readonly walletAddress?: undefined;
19526
- readonly walletChainId?: undefined;
19527
- }];
19528
- };
19529
- readonly delegationStatus: {
19530
- readonly all: readonly ["zama.delegationStatus"];
19531
- readonly contract: (contractAddress?: Address) => readonly ["zama.delegationStatus", {
19532
- contractAddress: `0x${string}`;
19533
- } | {
19534
- contractAddress?: undefined;
19535
- }];
19536
- readonly scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => readonly ["zama.delegationStatus", {
19537
- readonly delegateAddress?: `0x${string}` | undefined;
19538
- readonly delegatorAddress?: `0x${string}` | undefined;
19539
- readonly contractAddress?: `0x${string}` | undefined;
19540
- }];
19541
- };
19542
- readonly decryption: {
19543
- readonly all: readonly ["zama.decryption"];
19544
- readonly encryptedValue: (encryptedValue: string, contractAddress?: Address) => readonly ["zama.decryption", {
19545
- readonly contractAddress?: `0x${string}` | undefined;
19546
- readonly encryptedValue: string;
19547
- }];
19548
- readonly encryptedInputs: (encryptedInputs: readonly {
19549
- encryptedValue: string;
19550
- contractAddress: Address;
19551
- }[], walletAccount?: WalletAccount) => readonly ["zama.decryption", {
19552
- readonly encryptedInputs: {
19553
- encryptedValue: Hex;
19554
- contractAddress: `0x${string}`;
19555
- }[];
19556
- readonly walletAddress: `0x${string}`;
19557
- readonly walletChainId: number;
19558
- } | {
19559
- readonly encryptedInputs: {
19560
- encryptedValue: Hex;
19561
- contractAddress: `0x${string}`;
19562
- }[];
19563
- readonly walletAddress?: undefined;
19564
- readonly walletChainId?: undefined;
19565
- }];
19566
- };
19567
- readonly wrappersRegistry: {
19568
- readonly all: readonly ["zama.wrappersRegistry"];
19569
- readonly chainId: () => readonly ["zama.wrappersRegistry", {
19570
- readonly type: "chainId";
19571
- }];
19572
- readonly tokenPairs: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
19573
- readonly type: "tokenPairs";
19574
- readonly registryAddress: `0x${string}`;
19575
- }];
19576
- readonly confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) => readonly ["zama.wrappersRegistry", {
19577
- readonly type: "confidentialTokenAddress";
19578
- readonly registryAddress: `0x${string}`;
19579
- readonly tokenAddress: `0x${string}`;
19580
- }];
19581
- readonly tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
19582
- readonly type: "tokenAddress";
19583
- readonly registryAddress: `0x${string}`;
19584
- readonly confidentialTokenAddress: `0x${string}`;
19585
- }];
19586
- readonly tokenPairsLength: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
19587
- readonly type: "tokenPairsLength";
19588
- readonly registryAddress: `0x${string}`;
19589
- }];
19590
- readonly tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) => readonly ["zama.wrappersRegistry", {
19591
- readonly type: "tokenPairsSlice";
19592
- readonly registryAddress: `0x${string}`;
19593
- readonly fromIndex: string;
19594
- readonly toIndex: string;
19595
- }];
19596
- readonly tokenPair: (registryAddress: Address, index: string) => readonly ["zama.wrappersRegistry", {
19597
- readonly type: "tokenPair";
19598
- readonly registryAddress: `0x${string}`;
19599
- readonly index: string;
19600
- }];
19601
- readonly isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
19602
- readonly type: "isConfidentialTokenValid";
19603
- readonly registryAddress: `0x${string}`;
19604
- readonly confidentialTokenAddress: `0x${string}`;
19605
- }];
19606
- readonly listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) => readonly ["zama.wrappersRegistry", {
19607
- readonly type: "listPairs";
19608
- readonly registryAddress: `0x${string}`;
19609
- readonly page: number;
19610
- readonly pageSize: number;
19611
- readonly metadata: boolean;
19612
- }];
19613
- };
19614
- };
19615
- //#endregion
19616
- //#region src/query/invalidation.d.ts
19617
- /** Minimal query shape read by the invalidation predicates. */
19618
- interface QueryLike {
19619
- /** The query's cache key. */
19620
- queryKey: readonly unknown[];
19621
- }
19622
- /** Minimal filter shape accepted by the invalidation helpers, matching TanStack Query's `QueryFilters`. */
19623
- interface QueryFilterLike {
19624
- /** Match queries whose key starts with this prefix. */
19625
- queryKey?: readonly unknown[];
19626
- /** Match queries for which this returns `true`. */
19627
- predicate?: (query: QueryLike) => boolean;
19628
- }
19629
- /** Minimal `QueryClient` surface used by the invalidation helpers. */
19630
- interface QueryClientLike {
19631
- /** Mark matching queries stale so they refetch. */
19632
- invalidateQueries(filters: QueryFilterLike): void | Promise<void>;
19633
- /** Remove matching queries from the cache entirely. */
19634
- removeQueries(filters: QueryFilterLike): void;
19635
- }
19636
- /** Invalidates the caches affected by an unwrap: confidential balances, underlying allowance, and pending unshields. */
19637
- declare function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void;
19638
- /** Invalidates the caches affected by a wrap: confidential balances and underlying allowance. */
19639
- declare function invalidateAfterWrap(queryClient: QueryClientLike, tokenAddress: Address): void;
19640
- /** Invalidates the confidential balance queries for a token (single-token and batched). */
19641
- declare function invalidateBalanceQueries(queryClient: QueryClientLike, tokenAddress: Address): void;
19642
- /** Invalidates the caches affected by a shield: confidential balances and underlying allowance. */
19643
- declare function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void;
19644
- /** Invalidates the caches affected by an unshield request: confidential balances, underlying allowance, and pending unshields. */
19645
- declare function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void;
19646
- /** Invalidates the pending-unshield cache once an unshield has settled on-chain. */
19647
- declare function invalidateAfterUnshieldSettled(queryClient: QueryClientLike, tokenAddress: Address): void;
19648
- /** Invalidates the confidential balance caches affected by a transfer. */
19649
- declare function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void;
19650
- /** Invalidates the underlying-allowance cache after approving the underlying ERC-20. */
19651
- declare function invalidateAfterApproveUnderlying(queryClient: QueryClientLike, tokenAddress: Address): void;
19652
- /** Invalidates the operator-status cache after changing a token operator. */
19653
- declare function invalidateAfterSetOperator(queryClient: QueryClientLike, tokenAddress: Address): void;
19654
- /** Invalidates any wagmi `useBalance`/`readContract` balance queries so ERC-20 balances refresh. */
19655
- declare function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void;
19656
- /** Clears wallet-local caches (decryption, permits) and invalidates all Zama queries — call on wallet connect/disconnect so a stale entitlement can't leak across accounts. */
19657
- declare function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void;
19658
- //#endregion
19659
- //#region src/query/token-metadata.d.ts
19660
- /** ERC-20 token metadata returned by {@link tokenMetadataQueryOptions}. */
19661
- interface TokenMetadata {
19662
- /** Human-readable token name. */
19663
- name: string;
19664
- /** Token ticker symbol. */
19665
- symbol: string;
19666
- /** Number of decimals the token uses. */
19667
- decimals: number;
19668
- }
19669
- /** Configuration for {@link tokenMetadataQueryOptions}. */
19670
- interface TokenMetadataQueryConfig {
19671
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
19672
- query?: Record<string, unknown>;
19673
- }
19674
- /** Builds TanStack Query options for reading an ERC-20 token's name, symbol, and decimals. */
19675
- declare function tokenMetadataQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: TokenMetadataQueryConfig): QueryFactoryOptions<TokenMetadata, Error, TokenMetadata, ReturnType<typeof zamaQueryKeys.tokenMetadata.token>>;
19676
- //#endregion
19677
- //#region src/query/is-confidential.d.ts
19678
- /** Configuration for {@link isConfidentialQueryOptions} and {@link isWrapperQueryOptions}. */
19679
- interface IsConfidentialQueryConfig {
19680
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
19681
- query?: Record<string, unknown>;
19682
- }
19683
- /** Builds TanStack Query options for reading whether a token address implements the confidential (ERC-7984) token interface. */
19684
- declare function isConfidentialQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: IsConfidentialQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isConfidential.token>>;
19685
- /** Builds TanStack Query options for reading whether a token address is a confidential wrapper (ERC-7984 wrapper) contract. */
19686
- declare function isWrapperQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: IsConfidentialQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isWrapper.token>>;
19687
- //#endregion
19688
- //#region src/query/total-supply.d.ts
19689
- /** Configuration for {@link totalSupplyQueryOptions}. */
19690
- interface TotalSupplyQueryConfig {
19691
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
19692
- query?: Record<string, unknown>;
19693
- }
19694
- /** Builds TanStack Query options for reading a token's total supply. */
19695
- declare function totalSupplyQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: TotalSupplyQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.totalSupply.token>>;
19696
- //#endregion
19697
- //#region src/wrappers-registry.d.ts
19698
- /**
19699
- * Default wrappers registry addresses for known chains.
19700
- * Only includes chains where a registry is deployed (excludes Hardhat).
19701
- *
19702
- * @deprecated Read `registryAddress` from the chain presets instead (e.g.
19703
- * `sepolia.registryAddress`). Will be removed in the next major version.
19704
- */
19705
- declare const DefaultRegistryAddresses: Record<number, Address>;
19706
- /** Configuration for {@link WrappersRegistry}. */
19707
- interface WrappersRegistryConfig {
19708
- /** Read-only chain provider used for every registry lookup. */
19709
- provider: GenericProvider;
19710
- /**
19711
- * Per-chain registry address overrides, merged on top of
19712
- * {@link DefaultRegistryAddresses}. Use this to supply a registry
19713
- * address for custom or local chains (e.g. Hardhat).
19714
- *
19715
- * @example
19716
- * ```ts
19717
- * new WrappersRegistry({
19718
- * provider,
19719
- * registryAddresses: { [31337]: "0xYourHardhatRegistry" },
19720
- * });
19721
- * ```
19722
- */
19723
- registryAddresses?: Record<number, Address>;
19724
- /**
19725
- * How long cached registry results remain valid, in seconds.
19726
- * Default: `86400` (24 hours).
19727
- */
19728
- registryTTL?: number;
19729
- }
19730
- /** Options for {@link WrappersRegistry.listPairs}. */
19731
- interface ListPairsOptions {
19732
- /** Page number (1-indexed). Default: `1`. */
19733
- page?: number;
19734
- /** Number of items per page. Default: `100`. */
19735
- pageSize?: number;
19736
- /**
19737
- * When `true`, fetches on-chain metadata (name, symbol, decimals) for both
19738
- * the ERC-20 and confidential token, plus totalSupply for the ERC-20.
19739
- * Default: `false`.
19740
- */
19741
- metadata?: boolean;
19742
- }
19743
- /**
19744
- * High-level interface for the on-chain token wrappers registry.
19745
- *
19746
- * Uses the configured {@link GenericProvider} to resolve the correct registry
19747
- * contract address for the current chain and exposes typed read helpers for
19748
- * every registry query. Results are cached in memory with a configurable TTL
19749
- * (default 24 hours).
19750
- *
19751
- * @example
19752
- * ```ts
19753
- * const registry = new WrappersRegistry({ provider });
19754
- *
19755
- * // Paginated listing
19756
- * const page1 = await registry.listPairs({ page: 1, pageSize: 20 });
19757
- *
19758
- * // Structured lookups
19759
- * const result = await registry.getConfidentialToken(erc20Address);
19760
- * if (result) console.log(result.confidentialTokenAddress);
19761
- *
19762
- * // Force refresh
19763
- * registry.refresh();
19764
- * ```
19765
- */
19766
- declare class WrappersRegistry {
19432
+ declare class Token {
19767
19433
  #private;
19768
- /** Read-only chain access used for registry contract reads. */
19769
- readonly provider: GenericProvider;
19770
- constructor(config: WrappersRegistryConfig);
19771
- /**
19772
- * Synchronous lookup of the registry address for a given chain ID.
19773
- * Returns `undefined` if no address is configured for that chain.
19774
- */
19775
- getAddress(chainId: number): Address | undefined;
19434
+ /** The SDK instance this token operates through. */
19435
+ readonly sdk: ZamaSDK;
19436
+ /** Checksummed address of the confidential token contract. */
19437
+ readonly address: Address;
19438
+ constructor(sdk: ZamaSDK, address: Address);
19439
+ /** Read the token name from the contract. */
19440
+ name(): Promise<string>;
19441
+ /** Read the token symbol from the contract. */
19442
+ symbol(): Promise<string>;
19443
+ /** Read the token decimals from the contract. */
19444
+ decimals(): Promise<number>;
19776
19445
  /**
19777
- * Force-invalidate the in-memory cache. The next call to any read method
19778
- * will fetch fresh data from the chain.
19446
+ * ERC-165 check for {@link ERC7984_INTERFACE_ID} support.
19447
+ *
19448
+ * @returns `true` if the contract implements the ERC-7984 confidential token interface.
19779
19449
  */
19780
- refresh(): void;
19450
+ isConfidential(): Promise<boolean>;
19781
19451
  /**
19782
- * The cache TTL in milliseconds.
19783
- * Exposed so query option factories can set a matching `staleTime`.
19452
+ * ERC-165 check for IERC7984ERC20Wrapper support.
19453
+ *
19454
+ * @returns `true` if the contract implements the ERC-7984 wrapper interface
19455
+ * ({@link ERC7984_WRAPPER_INTERFACE_ID}, `0x1f1c62b2`).
19784
19456
  */
19785
- get ttlMs(): number;
19457
+ isWrapper(): Promise<boolean>;
19786
19458
  /**
19787
- * Resolve the registry contract address for the current chain.
19459
+ * Decrypt and return the plaintext balance for the given owner.
19460
+ * Acquires FHE credentials via a wallet signature if none are cached.
19788
19461
  *
19789
- * Priority: `registryAddresses[chainId]` \> built-in default.
19462
+ * @param owner - Balance owner address.
19463
+ * @returns The decrypted plaintext balance as a bigint.
19464
+ * @throws if FHE decryption fails. {@link DecryptionFailedError}
19790
19465
  *
19791
- * @returns The registry contract address for the connected chain.
19792
- * @throws if no address is configured for the chain. {@link ConfigurationError}
19466
+ * @example
19467
+ * ```ts
19468
+ * const balance = await token.balanceOf("0xOwner");
19469
+ * ```
19793
19470
  */
19794
- getRegistryAddress(): Promise<Address>;
19471
+ balanceOf(owner: Address): Promise<bigint>;
19795
19472
  /**
19796
- * List token wrapper pairs with page-based pagination.
19797
- *
19798
- * Internally maps to `getTokenConfidentialTokenPairsSlice` on-chain.
19473
+ * Return the raw encrypted balance without decrypting.
19799
19474
  *
19800
- * @param options - Pagination and enrichment options.
19801
- * @returns A {@link PaginatedResult} of pairs.
19475
+ * @param owner - Balance owner address.
19476
+ * @returns The encrypted balance as a hex string.
19802
19477
  *
19803
19478
  * @example
19804
19479
  * ```ts
19805
- * const result = await registry.listPairs({ page: 1, pageSize: 20 });
19806
- * console.log(`${result.total} pairs, showing page ${result.page}`);
19807
- *
19808
- * // With on-chain metadata
19809
- * const withMeta = await registry.listPairs({ metadata: true, pageSize: 10 });
19810
- * for (const pair of withMeta.items) {
19811
- * console.log(pair.underlying.symbol, "→", pair.confidential.symbol);
19812
- * }
19480
+ * const encryptedValue = await token.confidentialBalanceOf("0xOwner");
19813
19481
  * ```
19814
19482
  */
19815
- listPairs(options: ListPairsOptions & {
19816
- metadata: true;
19817
- }): Promise<PaginatedResult<TokenWrapperPairWithMetadata>>;
19818
- /** Lists registered underlying/confidential token pairs; pass `{ metadata: true }` to include on-chain token metadata. */
19819
- listPairs(options?: ListPairsOptions): Promise<PaginatedResult<TokenWrapperPair>>;
19483
+ confidentialBalanceOf(owner: Address): Promise<EncryptedValue>;
19820
19484
  /**
19821
- * Look up the confidential token for a given plain ERC-20 address.
19485
+ * Decrypt the balance of a delegator using delegated decryption credentials.
19486
+ * The connected signer acts as the delegatee who has been granted permission
19487
+ * by the delegator to decrypt their balance.
19822
19488
  *
19823
- * @param tokenAddress - The plain ERC-20 token address.
19824
- * @returns The lookup result, or `null` if the token has never been registered.
19825
- * **Note:** revoked tokens (registered then invalidated) return a non-null result
19826
- * with `isValid: false`. Check `result.isValid` explicitly rather than using
19827
- * `if (result)` to guard against processing revoked tokens.
19489
+ * Clear values are cached in storage keyed by `(account, token, encryptedValue)`.
19490
+ * Because every on-chain balance change produces a new encrypted value,
19491
+ * stale cache entries are never served. Cache write failures are silently
19492
+ * ignored — they do not affect the returned value.
19493
+ *
19494
+ * @param delegatorAddress - The address of the account that delegated decryption rights.
19495
+ * @param accountAddress - The account whose on-chain balance to read. Defaults
19496
+ * to the delegator address.
19497
+ * @returns The decrypted plaintext balance as a bigint.
19498
+ * @throws if no active delegation exists. {@link DelegationNotFoundError}
19499
+ * @throws if the delegation has expired. {@link DelegationExpiredError}
19500
+ * @throws if delegated decryption fails. {@link DecryptionFailedError}
19828
19501
  *
19829
19502
  * @example
19830
19503
  * ```ts
19831
- * const result = await registry.getConfidentialToken(usdcAddress);
19832
- * if (result?.isValid) {
19833
- * console.log(result.confidentialTokenAddress);
19834
- * }
19504
+ * const balance = await token.decryptBalanceAs({
19505
+ * delegatorAddress: "0xDelegator",
19506
+ * });
19835
19507
  * ```
19836
19508
  */
19837
- getConfidentialToken(tokenAddress: Address): Promise<{
19838
- confidentialTokenAddress: Address;
19839
- isValid: boolean;
19840
- } | null>;
19509
+ decryptBalanceAs({ delegatorAddress, accountAddress }: {
19510
+ delegatorAddress: Address;
19511
+ accountAddress?: Address;
19512
+ }): Promise<bigint>;
19841
19513
  /**
19842
- * Reverse lookup — find the plain ERC-20 for a given confidential token.
19514
+ * Decrypt confidential balances for multiple tokens in parallel, returning
19515
+ * successes and per-token errors separately. Pre-authorizes all token
19516
+ * addresses in a single wallet signature, then delegates each decrypt to
19517
+ * `sdk.decryption.decryptValues`.
19843
19518
  *
19844
- * @param confidentialTokenAddress - The confidential token address.
19845
- * @returns The lookup result, or `null` if no pair is registered.
19519
+ * Tokens that fail to decrypt land in `errors` rather than aborting the
19520
+ * whole batch — caller decides how to surface them.
19521
+ *
19522
+ * @param tokens - Array of {@link Token} instances bound to the same SDK.
19523
+ * @param owner - Balance owner address.
19524
+ * @returns `{ results, errors }` partitioning the per-token outcomes.
19846
19525
  *
19847
19526
  * @example
19848
19527
  * ```ts
19849
- * const result = await registry.getUnderlyingToken(cUsdcAddress);
19850
- * if (result) {
19851
- * console.log(result.tokenAddress, result.isValid);
19852
- * }
19528
+ * const { results, errors } = await Token.batchBalancesOf(tokens, owner);
19853
19529
  * ```
19854
19530
  */
19855
- getUnderlyingToken(confidentialTokenAddress: Address): Promise<{
19856
- tokenAddress: Address;
19857
- isValid: boolean;
19858
- } | null>;
19859
- /**
19860
- * Fetch all token wrapper pairs from the registry.
19861
- *
19862
- * @returns All registered `TokenWrapperPair` entries.
19863
- */
19864
- getTokenPairs(): Promise<readonly TokenWrapperPair[]>;
19865
- /**
19866
- * Get the total number of token wrapper pairs.
19867
- *
19868
- * @returns The count as a bigint.
19869
- */
19870
- getTokenPairsLength(): Promise<bigint>;
19871
- /**
19872
- * Fetch a range of token wrapper pairs (paginated by index).
19873
- *
19874
- * @param fromIndex - Start index (inclusive).
19875
- * @param toIndex - End index (exclusive).
19876
- * @returns The slice of `TokenWrapperPair` entries.
19877
- */
19878
- getTokenPairsSlice(fromIndex: bigint, toIndex: bigint): Promise<readonly TokenWrapperPair[]>;
19879
- /**
19880
- * Fetch a single token wrapper pair by index.
19881
- *
19882
- * @param index - Zero-based pair index.
19883
- * @returns The `TokenWrapperPair` at that index.
19884
- */
19885
- getTokenPair(index: bigint): Promise<TokenWrapperPair>;
19886
- /**
19887
- * Look up the confidential token address for a given plain ERC-20 token.
19888
- *
19889
- * @param tokenAddress - The plain ERC-20 token address.
19890
- * @returns A tuple `[isValid, confidentialTokenAddress]`. `isValid` is `true` only for a
19891
- * registered, non-revoked wrapper. The address is the zero address when no pair is registered.
19892
- * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
19893
- */
19894
- getConfidentialTokenAddress(tokenAddress: Address): Promise<readonly [boolean, Address]>;
19895
- /**
19896
- * Reverse lookup — find the plain ERC-20 for a given confidential token.
19897
- *
19898
- * @param confidentialTokenAddress - The confidential token address.
19899
- * @returns A tuple `[isValid, tokenAddress]`. `isValid` is `true` only for a registered,
19900
- * non-revoked wrapper. The address is the zero address when no pair is registered.
19901
- * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
19902
- */
19903
- getTokenAddress(confidentialTokenAddress: Address): Promise<readonly [boolean, Address]>;
19904
- /**
19905
- * Check whether a confidential token is registered and valid.
19906
- *
19907
- * @param confidentialTokenAddress - The confidential token address to check.
19908
- * @returns `true` if the token is a known valid wrapper in the registry.
19909
- */
19910
- isConfidentialTokenValid(confidentialTokenAddress: Address): Promise<boolean>;
19911
- }
19912
- //#endregion
19913
- //#region src/query/wrapper-discovery.d.ts
19914
- /** Configuration for {@link wrapperDiscoveryQueryOptions}. */
19915
- interface WrapperDiscoveryQueryConfig {
19916
- /**
19917
- * Address of any confidential token you control.
19918
- * Used to scope the query cache key and to gate whether the query
19919
- * is enabled — it does not affect which wrapper the registry returns.
19920
- */
19921
- tokenAddress?: Address;
19922
- /**
19923
- * The ERC-20 token address to discover the confidential wrapper for.
19924
- * The registry is resolved automatically from chain config.
19925
- */
19926
- erc20Address?: Address;
19927
- /**
19928
- * The resolved registry contract address for the current chain.
19929
- * Included in the query key so that switching chains invalidates
19930
- * stale cached results. Pass `undefined` when the chain ID is not
19931
- * yet known — the query will be disabled.
19932
- */
19933
- registryAddress?: Address;
19934
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
19935
- query?: Record<string, unknown>;
19936
- }
19937
- /** Builds TanStack Query options for discovering the confidential wrapper address for a given ERC-20 token (resolves to `null` when none is registered). */
19938
- declare function wrapperDiscoveryQueryOptions(registry: WrappersRegistry, config: WrapperDiscoveryQueryConfig): QueryFactoryOptions<Address | null, Error, Address | null, ReturnType<typeof zamaQueryKeys.wrapperDiscovery.token>>;
19939
- //#endregion
19940
- //#region src/query/underlying-allowance.d.ts
19941
- /** Configuration for {@link underlyingAllowanceQueryOptions}. */
19942
- interface UnderlyingAllowanceQueryConfig {
19943
- /** Owner whose underlying-token allowance to read; the query stays disabled until provided. */
19944
- owner?: Address;
19945
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
19946
- query?: Record<string, unknown>;
19947
- }
19948
- /** Builds TanStack Query options for reading the ERC-20 allowance the owner has granted a confidential wrapper on its underlying token. */
19949
- declare function underlyingAllowanceQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config: UnderlyingAllowanceQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.underlyingAllowance.scope>>;
19950
- //#endregion
19951
- //#region src/query/pending-unshield.d.ts
19952
- /** Configuration for {@link pendingUnshieldQueryOptions}. */
19953
- interface PendingUnshieldQueryConfig {
19954
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
19955
- query?: Record<string, unknown>;
19956
- }
19957
- /**
19958
- * Query options for reading the unwrap tx hash of an unshield that was
19959
- * interrupted between its two phases (returns `null` if none is pending).
19960
- *
19961
- * Backed by {@link ZamaSDK} storage via `WrappedToken.getPendingUnshield()`.
19962
- * `staleTime: 0` so the value reflects storage on mount; the unshield/unwrap
19963
- * mutations also invalidate this key on success.
19964
- */
19965
- declare function pendingUnshieldQueryOptions(sdk: ZamaSDK, tokenAddress: Address, config?: PendingUnshieldQueryConfig): QueryFactoryOptions<Hex | null, Error, Hex | null, ReturnType<typeof zamaQueryKeys.pendingUnshield.token>>;
19966
- //#endregion
19967
- //#region src/query/confidential-is-operator.d.ts
19968
- /** Configuration for {@link confidentialIsOperatorQueryOptions}. */
19969
- interface ConfidentialIsOperatorQueryConfig {
19970
- /** Token holder whose operator authorization to check; the query stays disabled until provided. */
19971
- holder?: Address;
19972
- /** Spender address to check for operator authorization; the query stays disabled until provided. */
19973
- spender?: Address;
19974
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
19975
- query?: Record<string, unknown>;
19976
- }
19977
- /** Builds TanStack Query options for reading whether a spender is an authorized operator of a holder on a confidential token. */
19978
- declare function confidentialIsOperatorQueryOptions(sdk: ZamaSDK, tokenAddress: Address | undefined, config: ConfidentialIsOperatorQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.confidentialIsOperator.scope>>;
19979
- //#endregion
19980
- //#region src/token/token.d.ts
19981
- /** Options for {@link Token.batchDecryptBalancesAs}. */
19982
- interface BatchDecryptAsOptions {
19983
- /** The address of the account that delegated decryption rights. */
19984
- delegatorAddress: Address;
19985
- /** Pre-fetched encrypted values. When omitted, they are fetched from the chain. */
19986
- encryptedValues?: EncryptedValue[];
19987
- /**
19988
- * The account whose on-chain balance to read. Defaults to the delegator
19989
- * address, which is the common case (the delegator grants permission to
19990
- * decrypt their own balance). Only set this when the account differs
19991
- * from the delegator.
19992
- *
19993
- * Matches the `account` parameter of `confidentialBalanceOf(account)` on-chain.
19994
- */
19995
- accountAddress?: Address;
19996
- /** Maximum number of concurrent decrypt calls. Default: 10. */
19997
- maxConcurrency?: number;
19998
- /** Called when decryption fails for a single token. Return a fallback bigint. */
19999
- onError?: (error: Error, address: Address) => bigint;
20000
- }
20001
- /** Result of {@link Token.batchBalancesOf}. */
20002
- interface BatchBalancesResult {
20003
- /** Successfully decrypted balances, keyed by token address. */
20004
- results: Map<Address, bigint>;
20005
- /** Per-token errors for tokens that failed to decrypt. */
20006
- errors: Map<Address, ZamaError>;
20007
- }
20008
- /**
20009
- * High-level interface for an ERC-7984 confidential token.
20010
- * Hides FHE complexity (encryption, decryption, EIP-712 signing) behind
20011
- * familiar ERC-20-like methods.
20012
- *
20013
- * For ERC-7984 wrappers (shield/unshield), use {@link WrappedToken} instead —
20014
- * it extends `Token` with wrapper-specific operations.
20015
- *
20016
- * Decryption, credentials, caching, and event emission are handled by the
20017
- * owning {@link ZamaSDK} — this class only exposes token-scoped helpers
20018
- * that delegate to `sdk.decryption.decryptValues` and `sdk.permits.grantPermit`.
20019
- */
20020
- declare class Token {
20021
- #private;
20022
- /** The SDK instance this token operates through. */
20023
- readonly sdk: ZamaSDK;
20024
- /** Checksummed address of the confidential token contract. */
20025
- readonly address: Address;
20026
- constructor(sdk: ZamaSDK, address: Address);
20027
- /** Read the token name from the contract. */
20028
- name(): Promise<string>;
20029
- /** Read the token symbol from the contract. */
20030
- symbol(): Promise<string>;
20031
- /** Read the token decimals from the contract. */
20032
- decimals(): Promise<number>;
20033
- /**
20034
- * ERC-165 check for {@link ERC7984_INTERFACE_ID} support.
20035
- *
20036
- * @returns `true` if the contract implements the ERC-7984 confidential token interface.
20037
- */
20038
- isConfidential(): Promise<boolean>;
20039
- /**
20040
- * ERC-165 check for IERC7984ERC20Wrapper support.
20041
- *
20042
- * @returns `true` if the contract implements the ERC-7984 wrapper interface
20043
- * ({@link ERC7984_WRAPPER_INTERFACE_ID}, `0x1f1c62b2`).
20044
- */
20045
- isWrapper(): Promise<boolean>;
20046
- /**
20047
- * Decrypt and return the plaintext balance for the given owner.
20048
- * Acquires FHE credentials via a wallet signature if none are cached.
20049
- *
20050
- * @param owner - Balance owner address.
20051
- * @returns The decrypted plaintext balance as a bigint.
20052
- * @throws if FHE decryption fails. {@link DecryptionFailedError}
20053
- *
20054
- * @example
20055
- * ```ts
20056
- * const balance = await token.balanceOf("0xOwner");
20057
- * ```
20058
- */
20059
- balanceOf(owner: Address): Promise<bigint>;
20060
- /**
20061
- * Return the raw encrypted balance without decrypting.
20062
- *
20063
- * @param owner - Balance owner address.
20064
- * @returns The encrypted balance as a hex string.
20065
- *
20066
- * @example
20067
- * ```ts
20068
- * const encryptedValue = await token.confidentialBalanceOf("0xOwner");
20069
- * ```
20070
- */
20071
- confidentialBalanceOf(owner: Address): Promise<EncryptedValue>;
20072
- /**
20073
- * Decrypt the balance of a delegator using delegated decryption credentials.
20074
- * The connected signer acts as the delegatee who has been granted permission
20075
- * by the delegator to decrypt their balance.
20076
- *
20077
- * Clear values are cached in storage keyed by `(account, token, encryptedValue)`.
20078
- * Because every on-chain balance change produces a new encrypted value,
20079
- * stale cache entries are never served. Cache write failures are silently
20080
- * ignored — they do not affect the returned value.
20081
- *
20082
- * @param delegatorAddress - The address of the account that delegated decryption rights.
20083
- * @param accountAddress - The account whose on-chain balance to read. Defaults
20084
- * to the delegator address.
20085
- * @returns The decrypted plaintext balance as a bigint.
20086
- * @throws if no active delegation exists. {@link DelegationNotFoundError}
20087
- * @throws if the delegation has expired. {@link DelegationExpiredError}
20088
- * @throws if delegated decryption fails. {@link DecryptionFailedError}
20089
- *
20090
- * @example
20091
- * ```ts
20092
- * const balance = await token.decryptBalanceAs({
20093
- * delegatorAddress: "0xDelegator",
20094
- * });
20095
- * ```
20096
- */
20097
- decryptBalanceAs({ delegatorAddress, accountAddress }: {
20098
- delegatorAddress: Address;
20099
- accountAddress?: Address;
20100
- }): Promise<bigint>;
20101
- /**
20102
- * Decrypt confidential balances for multiple tokens in parallel, returning
20103
- * successes and per-token errors separately. Pre-authorizes all token
20104
- * addresses in a single wallet signature, then delegates each decrypt to
20105
- * `sdk.decryption.decryptValues`.
20106
- *
20107
- * Tokens that fail to decrypt land in `errors` rather than aborting the
20108
- * whole batch — caller decides how to surface them.
20109
- *
20110
- * @param tokens - Array of {@link Token} instances bound to the same SDK.
20111
- * @param owner - Balance owner address.
20112
- * @returns `{ results, errors }` partitioning the per-token outcomes.
20113
- *
20114
- * @example
20115
- * ```ts
20116
- * const { results, errors } = await Token.batchBalancesOf(tokens, owner);
20117
- * ```
20118
- */
20119
- static batchBalancesOf(tokens: Token[], owner: Address): Promise<BatchBalancesResult>;
19531
+ static batchBalancesOf(tokens: Token[], owner: Address): Promise<BatchBalancesResult>;
20120
19532
  /**
20121
19533
  * Batch decrypt confidential balances as a delegate across multiple tokens.
20122
19534
  * Mirrors {@link batchBalancesOf} but uses delegated credentials.
@@ -20488,343 +19900,607 @@ declare class WrappedToken extends Token {
20488
19900
  finalizeUnwrap(unwrapRequestId: EncryptedValue): Promise<TransactionResult>;
20489
19901
  }
20490
19902
  //#endregion
20491
- //#region src/query/confidential-balance.d.ts
20492
- /** Configuration for {@link confidentialBalanceQueryOptions}. */
20493
- interface ConfidentialBalanceQueryConfig {
20494
- /** Address of the confidential token to read the balance of. */
20495
- tokenAddress: Address;
20496
- /** Account whose confidential balance to read; the query stays disabled until provided. */
20497
- account?: Address;
20498
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
20499
- query?: Record<string, unknown>;
20500
- }
20501
- /** Query options for a single confidential token balance. Auto-gated on `account`. */
20502
- declare function confidentialBalanceQueryOptions(token: Token, config: ConfidentialBalanceQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.confidentialBalance.owner>>;
20503
- //#endregion
20504
- //#region src/query/confidential-balances.d.ts
20505
- /** Configuration for {@link confidentialBalancesQueryOptions}. */
20506
- interface ConfidentialBalancesQueryConfig {
20507
- /** Account whose confidential balances to read; the query stays disabled until provided. */
20508
- account?: Address;
20509
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
20510
- query?: Record<string, unknown>;
20511
- }
20512
- /** Builds TanStack Query options for reading the confidential balances of several tokens for one account in a single batch. */
20513
- declare function confidentialBalancesQueryOptions(tokens: Token[], config?: ConfidentialBalancesQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<BatchBalancesResult, Error, BatchBalancesResult, ReturnType<typeof zamaQueryKeys.confidentialBalances.tokens>>;
20514
- //#endregion
20515
- //#region src/query/wrappers-registry.d.ts
20516
- /** Base configuration shared by the wrappers-registry query option factories. */
20517
- interface WrappersRegistryQueryConfig {
20518
- /** Registry contract address for the current chain; used as a query key discriminator. */
20519
- registryAddress: Address | undefined;
20520
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
20521
- query?: Record<string, unknown>;
20522
- }
20523
- /** Builds TanStack Query options for reading all token wrapper pairs registered in the wrappers registry. */
20524
- declare function tokenPairsQueryOptions(sdk: ZamaSDK, config: WrappersRegistryQueryConfig): QueryFactoryOptions<readonly TokenWrapperPair[], Error, readonly TokenWrapperPair[], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairs>>;
20525
- /** Configuration for {@link confidentialTokenAddressQueryOptions}. */
20526
- interface ConfidentialTokenAddressQueryConfig extends WrappersRegistryQueryConfig {
20527
- /** Underlying ERC-20 token address whose confidential counterpart to look up. */
20528
- tokenAddress?: Address;
20529
- }
20530
- /** Builds TanStack Query options for reading the confidential token address registered for a given underlying ERC-20 token. */
20531
- declare function confidentialTokenAddressQueryOptions(sdk: ZamaSDK, config: ConfidentialTokenAddressQueryConfig): QueryFactoryOptions<readonly [boolean, Address], Error, readonly [boolean, Address], ReturnType<typeof zamaQueryKeys.wrappersRegistry.confidentialTokenAddress>>;
20532
- /** Configuration for {@link tokenAddressQueryOptions}. */
20533
- interface TokenAddressQueryConfig extends WrappersRegistryQueryConfig {
20534
- /** Confidential token address whose underlying ERC-20 counterpart to look up. */
20535
- confidentialTokenAddress?: Address;
20536
- }
20537
- /** Builds TanStack Query options for reading the underlying ERC-20 token address registered for a given confidential token. */
20538
- declare function tokenAddressQueryOptions(sdk: ZamaSDK, config: TokenAddressQueryConfig): QueryFactoryOptions<readonly [boolean, Address], Error, readonly [boolean, Address], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenAddress>>;
20539
- /** Builds TanStack Query options for reading the total number of token wrapper pairs in the registry. */
20540
- declare function tokenPairsLengthQueryOptions(sdk: ZamaSDK, config: WrappersRegistryQueryConfig): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsLength>>;
20541
- /** Configuration for {@link tokenPairsSliceQueryOptions}. */
20542
- interface TokenPairsSliceQueryConfig extends WrappersRegistryQueryConfig {
20543
- /** Zero-based index of the first pair in the slice (inclusive). */
20544
- fromIndex?: bigint;
20545
- /** Index bounding the end of the slice. */
20546
- toIndex?: bigint;
20547
- }
20548
- /** Builds TanStack Query options for reading a contiguous slice of the registry's token wrapper pairs. */
20549
- declare function tokenPairsSliceQueryOptions(sdk: ZamaSDK, config: TokenPairsSliceQueryConfig): QueryFactoryOptions<readonly TokenWrapperPair[], Error, readonly TokenWrapperPair[], ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsSlice>>;
20550
- /** Configuration for {@link tokenPairQueryOptions}. */
20551
- interface TokenPairQueryConfig extends WrappersRegistryQueryConfig {
20552
- /** Zero-based index of the token wrapper pair to read. */
20553
- index?: bigint;
20554
- }
20555
- /** Builds TanStack Query options for reading a single token wrapper pair by its index in the registry. */
20556
- declare function tokenPairQueryOptions(sdk: ZamaSDK, config: TokenPairQueryConfig): QueryFactoryOptions<TokenWrapperPair, Error, TokenWrapperPair, ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPair>>;
20557
- /** Configuration for {@link isConfidentialTokenValidQueryOptions}. */
20558
- interface IsConfidentialTokenValidQueryConfig extends WrappersRegistryQueryConfig {
20559
- /** Confidential token address to validate against the registry. */
20560
- confidentialTokenAddress?: Address;
20561
- }
20562
- /** Builds TanStack Query options for checking whether a confidential token is registered and valid in the registry. */
20563
- declare function isConfidentialTokenValidQueryOptions(sdk: ZamaSDK, config: IsConfidentialTokenValidQueryConfig): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.wrappersRegistry.isConfidentialTokenValid>>;
20564
- /** Configuration for {@link listPairsQueryOptions}. */
20565
- interface ListPairsQueryConfig {
20566
- /**
20567
- * The registry address for this chain — used as a query key discriminator.
20568
- * The registry instance already knows how to resolve the address for the
20569
- * current chain; this field just keeps the TanStack Query cache isolated
20570
- * per registry contract.
20571
- */
20572
- registryAddress: Address | undefined;
20573
- /** 1-based page number to fetch; defaults to `1`. */
20574
- page?: number;
20575
- /** Number of pairs per page; defaults to `100`. */
20576
- pageSize?: number;
20577
- /** When `true`, resolve each pair's on-chain metadata; defaults to `false`. */
20578
- metadata?: boolean;
20579
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
20580
- query?: Record<string, unknown>;
20581
- }
19903
+ //#region src/wrappers-registry.d.ts
20582
19904
  /**
20583
- * Query options for paginated listing of token wrapper pairs.
19905
+ * Default wrappers registry addresses for known chains.
19906
+ * Only includes chains where a registry is deployed (excludes Hardhat).
20584
19907
  *
20585
- * Accepts a {@link WrappersRegistry} instance rather than a raw provider so that the
20586
- * class-level TTL cache is shared across multiple `queryFn` executions. Pass
20587
- * `sdk.registry` (the ZamaSDK lazy singleton) to ensure a single shared cache.
19908
+ * @deprecated Read `registryAddress` from the chain presets instead (e.g.
19909
+ * `sepolia.registryAddress`). Will be removed in the next major version.
20588
19910
  */
20589
- declare function listPairsQueryOptions(registry: WrappersRegistry, config: ListPairsQueryConfig): QueryFactoryOptions<PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>, Error, PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>, ReturnType<typeof zamaQueryKeys.wrappersRegistry.listPairs>>;
20590
- //#endregion
20591
- //#region src/query/shield.d.ts
20592
- /** Variables for {@link shieldMutationOptions}. */
20593
- interface ShieldParams extends ShieldOptions {
20594
- /** Amount of the public ERC-20 to shield, in the token's base units. */
20595
- amount: bigint;
19911
+ declare const DefaultRegistryAddresses: Record<number, Address>;
19912
+ /** Configuration for {@link WrappersRegistry}. */
19913
+ interface WrappersRegistryConfig {
19914
+ /** Read-only chain provider used for every registry lookup. */
19915
+ provider: GenericProvider;
19916
+ /**
19917
+ * Per-chain registry address overrides, merged on top of
19918
+ * {@link DefaultRegistryAddresses}. Use this to supply a registry
19919
+ * address for custom or local chains (e.g. Hardhat).
19920
+ *
19921
+ * @example
19922
+ * ```ts
19923
+ * new WrappersRegistry({
19924
+ * provider,
19925
+ * registryAddresses: { [31337]: "0xYourHardhatRegistry" },
19926
+ * });
19927
+ * ```
19928
+ */
19929
+ registryAddresses?: Record<number, Address>;
19930
+ /**
19931
+ * How long cached registry results remain valid, in seconds.
19932
+ * Default: `86400` (24 hours).
19933
+ */
19934
+ registryTTL?: number;
20596
19935
  }
20597
- /** Builds TanStack Query mutation options for {@link WrappedToken.shield | shielding} a public ERC-20 into its confidential form. @see {@link ShieldParams} */
20598
- declare function shieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.shield", Address], ShieldParams, TransactionResult>;
20599
- //#endregion
20600
- //#region src/query/transfer.d.ts
20601
- /** Variables for {@link confidentialTransferMutationOptions}. */
20602
- interface ConfidentialTransferParams extends TransferOptions {
20603
- /** Recipient address. */
20604
- to: Address;
20605
- /** Amount of tokens to transfer, in the token's base units. */
20606
- amount: bigint;
20607
- }
20608
- /** Builds TanStack Query mutation options for {@link Token.confidentialTransfer | transferring} confidential tokens. @see {@link ConfidentialTransferParams} */
20609
- declare function confidentialTransferMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransfer", Address], ConfidentialTransferParams, TransactionResult>;
20610
- //#endregion
20611
- //#region src/query/transfer-and-call.d.ts
20612
- /** Variables for {@link confidentialTransferAndCallMutationOptions}. */
20613
- interface ConfidentialTransferAndCallParams extends TransferOptions {
20614
- /** Recipient address. */
20615
- to: Address;
20616
- /** Amount of tokens to transfer, in the token's base units. */
20617
- amount: bigint;
20618
- /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */
20619
- data: Hex;
20620
- }
20621
- /** Builds TanStack Query mutation options for {@link Token.confidentialTransferAndCall | transferring} confidential tokens and invoking the recipient's receiver hook. @see {@link ConfidentialTransferAndCallParams} */
20622
- declare function confidentialTransferAndCallMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferAndCall", Address], ConfidentialTransferAndCallParams, TransactionResult>;
20623
- //#endregion
20624
- //#region src/query/transfer-from.d.ts
20625
- /** Variables for {@link confidentialTransferFromMutationOptions}. */
20626
- interface ConfidentialTransferFromParams {
20627
- /** Address to transfer from. */
20628
- from: Address;
20629
- /** Recipient address. */
20630
- to: Address;
20631
- /** Amount of tokens to transfer, in the token's base units. */
20632
- amount: bigint;
20633
- /** Optional progress callbacks for the multi-step transfer flow. */
20634
- callbacks?: TransferCallbacks;
20635
- }
20636
- /** Builds TanStack Query mutation options for {@link Token.confidentialTransferFrom | transferring} confidential tokens from another account (operator flow). @see {@link ConfidentialTransferFromParams} */
20637
- declare function confidentialTransferFromMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferFrom", Address], ConfidentialTransferFromParams, TransactionResult>;
20638
- //#endregion
20639
- //#region src/query/transfer-from-and-call.d.ts
20640
- /** Variables for {@link confidentialTransferFromAndCallMutationOptions}. */
20641
- interface ConfidentialTransferFromAndCallParams {
20642
- /** Address to transfer from. */
20643
- from: Address;
20644
- /** Recipient address. */
20645
- to: Address;
20646
- /** Amount of tokens to transfer, in the token's base units. */
20647
- amount: bigint;
20648
- /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */
20649
- data: Hex;
20650
- /** Optional progress callbacks for the multi-step transfer flow. */
20651
- callbacks?: TransferCallbacks;
20652
- }
20653
- /** Builds TanStack Query mutation options for {@link Token.confidentialTransferFromAndCall | transferring} confidential tokens from another account and invoking the recipient's receiver hook. @see {@link ConfidentialTransferFromAndCallParams} */
20654
- declare function confidentialTransferFromAndCallMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialTransferFromAndCall", Address], ConfidentialTransferFromAndCallParams, TransactionResult>;
20655
- //#endregion
20656
- //#region src/query/set-operator.d.ts
20657
- /** Variables for {@link confidentialSetOperatorMutationOptions}. */
20658
- interface ConfidentialSetOperatorParams {
20659
- /** Operator address to authorize. */
20660
- operator: Address;
20661
- /** Unix timestamp (seconds) when the operator authorization expires; defaults to one hour from now. */
20662
- until?: number;
20663
- }
20664
- /** Builds TanStack Query mutation options for {@link Token.setOperator | authorizing} an operator on a confidential token. @see {@link ConfidentialSetOperatorParams} */
20665
- declare function confidentialSetOperatorMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.confidentialSetOperator", Address], ConfidentialSetOperatorParams, TransactionResult>;
20666
- //#endregion
20667
- //#region src/query/approve-underlying.d.ts
20668
- /** Variables for {@link approveUnderlyingMutationOptions}. */
20669
- interface ApproveUnderlyingParams {
20670
- /** Amount of the underlying ERC-20 to approve, in its base units; omit for a max approval. */
20671
- amount?: bigint;
20672
- }
20673
- /** Builds TanStack Query mutation options for {@link WrappedToken.approveUnderlying | approving} the wrapper to spend the underlying ERC-20. @see {@link ApproveUnderlyingParams} */
20674
- declare function approveUnderlyingMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.approveUnderlying", Address], ApproveUnderlyingParams, TransactionResult>;
20675
- //#endregion
20676
- //#region src/query/unshield.d.ts
20677
- /** Variables for {@link unshieldMutationOptions}. */
20678
- interface UnshieldParams extends UnshieldOptions {
20679
- /** Amount of tokens to unshield, in the token's base units. */
20680
- amount: bigint;
20681
- }
20682
- /** Builds TanStack Query mutation options for {@link WrappedToken.unshield | unshielding} a confidential token back into its public ERC-20. @see {@link UnshieldParams} */
20683
- declare function unshieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unshield", Address], UnshieldParams, TransactionResult>;
20684
- //#endregion
20685
- //#region src/query/unshield-all.d.ts
20686
- /** Variables for {@link unshieldAllMutationOptions}. */
20687
- interface UnshieldAllParams extends UnshieldCallbacks {}
20688
- /** Builds TanStack Query mutation options for {@link WrappedToken.unshieldAll | unshielding} the entire confidential balance back into the public ERC-20. @see {@link UnshieldAllParams} */
20689
- declare function unshieldAllMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unshieldAll", Address], UnshieldAllParams | void, TransactionResult>;
20690
- //#endregion
20691
- //#region src/query/resume-unshield.d.ts
20692
- /** Variables for {@link resumeUnshieldMutationOptions}. */
20693
- interface ResumeUnshieldParams extends UnshieldCallbacks {
20694
- /** Hash of the earlier unwrap request transaction to resume from. */
20695
- unwrapTxHash: Hex;
20696
- }
20697
- /** Builds TanStack Query mutation options for {@link WrappedToken.resumeUnshield | resuming} an interrupted unshield from its unwrap request transaction. @see {@link ResumeUnshieldParams} */
20698
- declare function resumeUnshieldMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.resumeUnshield", Address], ResumeUnshieldParams, TransactionResult>;
20699
- //#endregion
20700
- //#region src/query/unwrap.d.ts
20701
- /** Variables for {@link unwrapMutationOptions}. */
20702
- interface UnwrapParams {
20703
- /** Amount of tokens to unwrap, in the token's base units. */
20704
- amount: bigint;
19936
+ /** Options for {@link WrappersRegistry.listPairs}. */
19937
+ interface ListPairsOptions {
19938
+ /** Page number (1-indexed). Default: `1`. */
19939
+ page?: number;
19940
+ /** Number of items per page. Default: `100`. */
19941
+ pageSize?: number;
19942
+ /**
19943
+ * When `true`, fetches on-chain metadata (name, symbol, decimals) for both
19944
+ * the ERC-20 and confidential token, plus totalSupply for the ERC-20.
19945
+ * Default: `false`.
19946
+ */
19947
+ metadata?: boolean;
20705
19948
  }
20706
- /** Builds TanStack Query mutation options for {@link WrappedToken.unwrap | unwrapping} a confidential token (request phase of the two-phase unwrap). @see {@link UnwrapParams} */
20707
- declare function unwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unwrap", Address], UnwrapParams, UnwrapResult>;
20708
- //#endregion
20709
- //#region src/query/wrap.d.ts
20710
- /** Variables for {@link wrapMutationOptions}. */
20711
- interface WrapParams extends WrapOptions {
20712
- /** Amount of the public ERC-20 to wrap, in the token's base units. */
20713
- amount: bigint;
19949
+ /**
19950
+ * High-level interface for the on-chain token wrappers registry.
19951
+ *
19952
+ * Uses the configured {@link GenericProvider} to resolve the correct registry
19953
+ * contract address for the current chain and exposes typed read helpers for
19954
+ * every registry query. Results are cached in memory with a configurable TTL
19955
+ * (default 24 hours).
19956
+ *
19957
+ * @example
19958
+ * ```ts
19959
+ * const registry = new WrappersRegistry({ provider });
19960
+ *
19961
+ * // Paginated listing
19962
+ * const page1 = await registry.listPairs({ page: 1, pageSize: 20 });
19963
+ *
19964
+ * // Structured lookups
19965
+ * const result = await registry.getConfidentialToken(erc20Address);
19966
+ * if (result) console.log(result.confidentialTokenAddress);
19967
+ *
19968
+ * // Force refresh
19969
+ * registry.refresh();
19970
+ * ```
19971
+ */
19972
+ declare class WrappersRegistry {
19973
+ #private;
19974
+ /** Read-only chain access used for registry contract reads. */
19975
+ readonly provider: GenericProvider;
19976
+ constructor(config: WrappersRegistryConfig);
19977
+ /**
19978
+ * Synchronous lookup of the registry address for a given chain ID.
19979
+ * Returns `undefined` if no address is configured for that chain.
19980
+ */
19981
+ getAddress(chainId: number): Address | undefined;
19982
+ /**
19983
+ * Force-invalidate the in-memory cache. The next call to any read method
19984
+ * will fetch fresh data from the chain.
19985
+ */
19986
+ refresh(): void;
19987
+ /**
19988
+ * The cache TTL in milliseconds.
19989
+ * Exposed so query option factories can set a matching `staleTime`.
19990
+ */
19991
+ get ttlMs(): number;
19992
+ /**
19993
+ * Resolve the registry contract address for the current chain.
19994
+ *
19995
+ * Priority: `registryAddresses[chainId]` \> built-in default.
19996
+ *
19997
+ * @returns The registry contract address for the connected chain.
19998
+ * @throws if no address is configured for the chain. {@link ConfigurationError}
19999
+ */
20000
+ getRegistryAddress(): Promise<Address>;
20001
+ /**
20002
+ * List token wrapper pairs with page-based pagination.
20003
+ *
20004
+ * Internally maps to `getTokenConfidentialTokenPairsSlice` on-chain.
20005
+ *
20006
+ * @param options - Pagination and enrichment options.
20007
+ * @returns A {@link PaginatedResult} of pairs.
20008
+ *
20009
+ * @example
20010
+ * ```ts
20011
+ * const result = await registry.listPairs({ page: 1, pageSize: 20 });
20012
+ * console.log(`${result.total} pairs, showing page ${result.page}`);
20013
+ *
20014
+ * // With on-chain metadata
20015
+ * const withMeta = await registry.listPairs({ metadata: true, pageSize: 10 });
20016
+ * for (const pair of withMeta.items) {
20017
+ * console.log(pair.underlying.symbol, "→", pair.confidential.symbol);
20018
+ * }
20019
+ * ```
20020
+ */
20021
+ listPairs(options: ListPairsOptions & {
20022
+ metadata: true;
20023
+ }): Promise<PaginatedResult<TokenWrapperPairWithMetadata>>;
20024
+ /** Lists registered underlying/confidential token pairs; pass `{ metadata: true }` to include on-chain token metadata. */
20025
+ listPairs(options?: ListPairsOptions): Promise<PaginatedResult<TokenWrapperPair>>;
20026
+ /**
20027
+ * Look up the confidential token for a given plain ERC-20 address.
20028
+ *
20029
+ * @param tokenAddress - The plain ERC-20 token address.
20030
+ * @returns The lookup result, or `null` if the token has never been registered.
20031
+ * **Note:** revoked tokens (registered then invalidated) return a non-null result
20032
+ * with `isValid: false`. Check `result.isValid` explicitly rather than using
20033
+ * `if (result)` to guard against processing revoked tokens.
20034
+ *
20035
+ * @example
20036
+ * ```ts
20037
+ * const result = await registry.getConfidentialToken(usdcAddress);
20038
+ * if (result?.isValid) {
20039
+ * console.log(result.confidentialTokenAddress);
20040
+ * }
20041
+ * ```
20042
+ */
20043
+ getConfidentialToken(tokenAddress: Address): Promise<{
20044
+ confidentialTokenAddress: Address;
20045
+ isValid: boolean;
20046
+ } | null>;
20047
+ /**
20048
+ * Reverse lookup — find the plain ERC-20 for a given confidential token.
20049
+ *
20050
+ * @param confidentialTokenAddress - The confidential token address.
20051
+ * @returns The lookup result, or `null` if no pair is registered.
20052
+ *
20053
+ * @example
20054
+ * ```ts
20055
+ * const result = await registry.getUnderlyingToken(cUsdcAddress);
20056
+ * if (result) {
20057
+ * console.log(result.tokenAddress, result.isValid);
20058
+ * }
20059
+ * ```
20060
+ */
20061
+ getUnderlyingToken(confidentialTokenAddress: Address): Promise<{
20062
+ tokenAddress: Address;
20063
+ isValid: boolean;
20064
+ } | null>;
20065
+ /**
20066
+ * Fetch all token wrapper pairs from the registry.
20067
+ *
20068
+ * @returns All registered `TokenWrapperPair` entries.
20069
+ */
20070
+ getTokenPairs(): Promise<readonly TokenWrapperPair[]>;
20071
+ /**
20072
+ * Get the total number of token wrapper pairs.
20073
+ *
20074
+ * @returns The count as a bigint.
20075
+ */
20076
+ getTokenPairsLength(): Promise<bigint>;
20077
+ /**
20078
+ * Fetch a range of token wrapper pairs (paginated by index).
20079
+ *
20080
+ * @param fromIndex - Start index (inclusive).
20081
+ * @param toIndex - End index (exclusive).
20082
+ * @returns The slice of `TokenWrapperPair` entries.
20083
+ */
20084
+ getTokenPairsSlice(fromIndex: bigint, toIndex: bigint): Promise<readonly TokenWrapperPair[]>;
20085
+ /**
20086
+ * Fetch a single token wrapper pair by index.
20087
+ *
20088
+ * @param index - Zero-based pair index.
20089
+ * @returns The `TokenWrapperPair` at that index.
20090
+ */
20091
+ getTokenPair(index: bigint): Promise<TokenWrapperPair>;
20092
+ /**
20093
+ * Look up the confidential token address for a given plain ERC-20 token.
20094
+ *
20095
+ * @param tokenAddress - The plain ERC-20 token address.
20096
+ * @returns A tuple `[isValid, confidentialTokenAddress]`. `isValid` is `true` only for a
20097
+ * registered, non-revoked wrapper. The address is the zero address when no pair is registered.
20098
+ * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
20099
+ */
20100
+ getConfidentialTokenAddress(tokenAddress: Address): Promise<readonly [boolean, Address]>;
20101
+ /**
20102
+ * Reverse lookup — find the plain ERC-20 for a given confidential token.
20103
+ *
20104
+ * @param confidentialTokenAddress - The confidential token address.
20105
+ * @returns A tuple `[isValid, tokenAddress]`. `isValid` is `true` only for a registered,
20106
+ * non-revoked wrapper. The address is the zero address when no pair is registered.
20107
+ * A non-zero address with `isValid=false` means the wrapper was registered but later revoked.
20108
+ */
20109
+ getTokenAddress(confidentialTokenAddress: Address): Promise<readonly [boolean, Address]>;
20110
+ /**
20111
+ * Check whether a confidential token is registered and valid.
20112
+ *
20113
+ * @param confidentialTokenAddress - The confidential token address to check.
20114
+ * @returns `true` if the token is a known valid wrapper in the registry.
20115
+ */
20116
+ isConfidentialTokenValid(confidentialTokenAddress: Address): Promise<boolean>;
20714
20117
  }
20715
- /** Builds TanStack Query mutation options for {@link WrappedToken.wrap | wrapping} a public ERC-20 into its confidential form. @see {@link WrapParams} */
20716
- declare function wrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.wrap", Address], WrapParams, TransactionResult>;
20717
- //#endregion
20718
- //#region src/query/unwrap-all.d.ts
20719
- /** Builds TanStack Query mutation options for {@link WrappedToken.unwrapAll | unwrapping} the entire confidential balance. */
20720
- declare function unwrapAllMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.unwrapAll", Address], void, UnwrapResult>;
20721
- //#endregion
20722
- //#region src/query/finalize-unwrap.d.ts
20723
- /** Variables for {@link finalizeUnwrapMutationOptions}. */
20724
- type FinalizeUnwrapParams = {
20725
- /** Identifier from an `UnwrapRequested` event. */
20726
- unwrapRequestId: EncryptedValue;
20727
- };
20728
- /** Builds TanStack Query mutation options for {@link WrappedToken.finalizeUnwrap | finalizing} a previously requested unwrap. @see {@link FinalizeUnwrapParams} */
20729
- declare function finalizeUnwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.finalizeUnwrap", Address], FinalizeUnwrapParams, TransactionResult>;
20730
20118
  //#endregion
20731
- //#region src/query/encrypt.d.ts
20732
- /** Builds TanStack Query mutation options for {@link ZamaSDK.encrypt | encrypting} plaintext inputs into an encrypted payload. */
20733
- declare function encryptMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.encrypt"], EncryptParams, EncryptResult>;
20734
- //#endregion
20735
- //#region src/query/delegated-decrypt.d.ts
20736
- /** Variables for {@link delegatedDecryptValuesMutationOptions}. */
20737
- interface DelegatedDecryptValuesMutationParams {
20738
- /** Encrypted values (with their contract addresses) to decrypt. */
20739
- encryptedInputs: EncryptedInput[];
20740
- /** Address of the account that delegated decryption rights to the connected wallet. */
20741
- delegatorAddress: Address;
20119
+ //#region src/zama-sdk.d.ts
20120
+ /** Instance-level options that are deliberately not part of the shareable config object. */
20121
+ interface ZamaSDKOptions {
20122
+ /**
20123
+ * Encrypts the transport key pair's private half at rest. Headless environments only
20124
+ * (CLI tools, servers, agents); the constructor rejects it in browser contexts. Supply
20125
+ * at least 32 random bytes, or a string of at least 64 characters, from a CSPRNG or
20126
+ * secrets manager. The SDK copies a Uint8Array secret and zeroizes its own copy after
20127
+ * key import; it never touches your buffer, so zeroize yours after construction.
20128
+ * The SDK never persists or exposes this value. Omit for the default:
20129
+ * plaintext at rest, security delegated to the storage backend.
20130
+ */
20131
+ transportKeyPairDerivationSecret?: string | Uint8Array;
20742
20132
  }
20743
- /** Builds TanStack Query mutation options for {@link Decryption.delegatedDecryptValues | decrypting} encrypted values via delegated decryption credentials. @see {@link DelegatedDecryptValuesMutationParams} */
20744
- declare function delegatedDecryptValuesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.delegatedDecryptValues"], DelegatedDecryptValuesMutationParams, Readonly<Record<EncryptedValue, ClearValue>>>;
20745
- //#endregion
20746
- //#region src/query/public-decrypt.d.ts
20747
- /** Builds TanStack Query mutation options for {@link Decryption.decryptPublicValues | publicly decrypting} encrypted values, caching each clear result. */
20748
- declare function decryptPublicValuesMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.decryptPublicValues"], EncryptedValue[], DecryptPublicValuesResult>;
20749
- //#endregion
20750
- //#region src/query/grant-permit.d.ts
20751
- /** Builds TanStack Query mutation options for {@link Permits.grantPermit | granting} decryption permits for the given contract addresses. */
20752
- declare function grantPermitMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.grantPermit"], Address[], void>;
20753
- //#endregion
20754
- //#region src/query/has-permit.d.ts
20755
- /** Configuration for {@link hasPermitQueryOptions}. */
20756
- interface HasPermitQueryConfig {
20757
- /** Contract addresses to check credentials against. */
20758
- contractAddresses: Address[];
20133
+ /**
20134
+ * ZamaSDK — composes a RelayerSDK with contract abstraction.
20135
+ *
20136
+ * Exposes domain namespaces for permits, delegations, decryption, offline
20137
+ * signing, and tokens, plus an unchanged registry, a top-level `encrypt`, and
20138
+ * lifecycle methods. Internal `*Service` classes do the work; the namespace
20139
+ * classes own SDK-level guards (chain alignment, signer requirement, event
20140
+ * emission).
20141
+ */
20142
+ declare class ZamaSDK {
20143
+ #private;
20144
+ /** Read-only chain access used for all contract reads. */
20145
+ readonly provider: GenericProvider;
20146
+ /** Wallet signer used for write operations, or `undefined` when the SDK is read-only. */
20147
+ readonly signer: GenericSigner | undefined;
20148
+ /** Storage for cached permits and transport key pairs. */
20149
+ readonly storage: GenericStorage;
20150
+ /**
20151
+ * A {@link WrappersRegistry} instance auto-configured for the current chain.
20152
+ * Uses built-in defaults from chain configs, and the SDK's `registryTTL` if configured.
20153
+ */
20154
+ readonly registry: WrappersRegistry;
20155
+ /** Permit and keypair management. */
20156
+ readonly permits: Permits;
20157
+ /** On-chain decryption-delegation management. */
20158
+ readonly delegations: Delegations;
20159
+ /** FHE decryption (user, delegated user, public). */
20160
+ readonly decryption: Decryption;
20161
+ /** Offline-signing pipeline: `prepare` builds an unsigned tx the caller signs and broadcasts out-of-process — for HSM, policy-engine, and cross-process custody workflows. */
20162
+ readonly offline: Offline;
20163
+ constructor(config: ZamaConfig, options?: ZamaSDKOptions);
20164
+ /**
20165
+ * The single-chain relayer backend for the **currently active** chain.
20166
+ */
20167
+ get relayer(): RelayerSDK;
20168
+ /**
20169
+ * Create a {@link WrappersRegistry} instance bound to this SDK's provider.
20170
+ * Inherits the registry addresses derived from the SDK's chain configs, so
20171
+ * the result is consistent with {@link ZamaSDK.registry}.
20172
+ *
20173
+ * @param registryAddresses - Optional per-chain overrides for this registry instance.
20174
+ * @returns A {@link WrappersRegistry} instance.
20175
+ *
20176
+ * @example
20177
+ * ```ts
20178
+ * // Addresses resolved from the SDK's chain configs
20179
+ * const registry = sdk.createWrappersRegistry();
20180
+ *
20181
+ * // Hardhat or custom chain — override per chain for this registry instance
20182
+ * const registry = sdk.createWrappersRegistry({ [31337]: "0xYourRegistry" });
20183
+ *
20184
+ * const pairs = await registry.getTokenPairs();
20185
+ * ```
20186
+ */
20187
+ createWrappersRegistry(registryAddresses?: Record<number, Address>): WrappersRegistry;
20188
+ /**
20189
+ * Encrypt one or more plaintext values into FHE ciphertexts.
20190
+ *
20191
+ * @param params - Typed FHE inputs, the target contract address, and the user address.
20192
+ * @returns External encrypted values and the input proof for on-chain submission.
20193
+ * @throws if FHE encryption fails. {@link EncryptionFailedError}
20194
+ *
20195
+ * @example
20196
+ * ```ts
20197
+ * const { encryptedValues, inputProof } = await sdk.encrypt({
20198
+ * values: [{ value: 1000n, type: "euint64" }],
20199
+ * contractAddress: "0xToken",
20200
+ * userAddress: "0xUser",
20201
+ * });
20202
+ * ```
20203
+ */
20204
+ encrypt(params: EncryptParams, options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<EncryptResult>;
20205
+ /**
20206
+ * Create a high-level ERC-20-style interface for an ERC-7984 confidential token.
20207
+ * Supports balance queries, transfers, operator approvals, and decryption.
20208
+ *
20209
+ * For ERC-7984 wrappers (shield/unshield/allowance), use {@link createWrappedToken} instead.
20210
+ *
20211
+ * @param address - The confidential token contract address.
20212
+ * @returns A {@link Token} instance bound to this SDK.
20213
+ *
20214
+ * @example
20215
+ * ```ts
20216
+ * const token = sdk.createToken(cUSDT);
20217
+ * const balance = await token.balanceOf(userAddress);
20218
+ * ```
20219
+ */
20220
+ createToken(address: Address): Token;
20221
+ /**
20222
+ * Create a high-level interface for an ERC-7984 wrapper token.
20223
+ * Extends {@link Token} with shield/unshield/allowance/finalize-unwrap operations.
20224
+ *
20225
+ * @param address - The wrapper token contract address.
20226
+ * @returns A {@link WrappedToken} instance bound to this SDK.
20227
+ *
20228
+ * @example
20229
+ * ```ts
20230
+ * const wrapped = sdk.createWrappedToken(wUSDT);
20231
+ * await wrapped.shield(1_000_000n);
20232
+ * ```
20233
+ */
20234
+ createWrappedToken(address: Address): WrappedToken;
20759
20235
  /**
20760
- * Standard TanStack query options. `hasPermit` intentionally overrides cache
20761
- * timing because permit state is wallet-local, not server state: every fetch
20762
- * should read the SDK credential service directly.
20236
+ * Unsubscribe from signer lifecycle events without terminating the relayer.
20237
+ * Call this when the SDK instance is being replaced but the relayer is shared
20238
+ * (e.g. React provider remount in Strict Mode).
20763
20239
  */
20764
- query?: Record<string, unknown>;
20765
- }
20766
- /** Builds TanStack Query options for reading whether the connected wallet holds a valid decryption permit for the given contracts. */
20767
- declare function hasPermitQueryOptions(sdk: ZamaSDK, config: HasPermitQueryConfig, signerContext?: SignerQueryContext): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.hasPermit.scope>>;
20768
- //#endregion
20769
- //#region src/query/revoke-permits.d.ts
20770
- /** TanStack Query mutation factory for {@link Permits.revokePermits}. */
20771
- declare function revokePermitsMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.revokePermits"], Address[] | void, void>;
20772
- //#endregion
20773
- //#region src/query/clear-credentials.d.ts
20774
- /** TanStack Query mutation factory for {@link Permits.clear}. */
20775
- declare function clearCredentialsMutationOptions(sdk: ZamaSDK): MutationFactoryOptions<readonly ["zama.clearCredentials"], void, void>;
20776
- //#endregion
20777
- //#region src/query/delegate-decryption.d.ts
20778
- /** Variables for {@link delegateDecryptionMutationOptions}. */
20779
- interface DelegateDecryptionParams {
20780
- /** Address to grant delegated decryption rights to. */
20781
- delegateAddress: Address;
20782
- /** When the delegation expires; omit for no expiry. */
20783
- expirationDate?: Date;
20240
+ dispose(): void;
20241
+ /**
20242
+ * Terminate the relayer backend and clean up resources.
20243
+ * Call this when the SDK is no longer needed (e.g. on unmount or shutdown).
20244
+ */
20245
+ terminate(): void;
20246
+ /**
20247
+ * Implements the TC39 Explicit Resource Management protocol.
20248
+ * Calls {@link terminate} when the `using` binding goes out of scope,
20249
+ * unsubscribing signer events and shutting down the relayer.
20250
+ *
20251
+ * @example
20252
+ * ```ts
20253
+ * {
20254
+ * using sdk = new ZamaSDK({ relayer, provider, signer, storage });
20255
+ * await sdk.permits.grantPermit([cUSDT]);
20256
+ * const balance = await sdk.createToken(cUSDT).balanceOf(userAddress);
20257
+ * } // sdk.terminate() called automatically here
20258
+ * ```
20259
+ */
20260
+ [Symbol.dispose](): void;
20784
20261
  }
20785
- /** Builds TanStack Query mutation options for {@link Delegations.delegateDecryption | granting} delegated decryption rights on a contract. @see {@link DelegateDecryptionParams} */
20786
- declare function delegateDecryptionMutationOptions(sdk: ZamaSDK, contractAddress: Address): MutationFactoryOptions<readonly ["zama.delegateDecryption", Address], DelegateDecryptionParams, TransactionResult>;
20787
20262
  //#endregion
20788
- //#region src/query/decrypt-balance-as.d.ts
20789
- /** Variables for {@link decryptBalanceAsMutationOptions}. */
20790
- interface DecryptBalanceAsParams {
20791
- /** Address of the account that delegated decryption rights to the connected wallet. */
20792
- delegatorAddress: Address;
20793
- /** Account whose on-chain balance to read; defaults to the delegator address. */
20794
- accountAddress?: Address;
20263
+ //#region src/query/factory-types.d.ts
20264
+ /**
20265
+ * TanStack Query options object returned by the SDK's `*QueryOptions` factories:
20266
+ * `QueryObserverOptions` with `queryKey` and `queryFn` required and the
20267
+ * cache-internal keys (`queryHash`, `queryKeyHashFn`, `throwOnError`) removed.
20268
+ */
20269
+ type QueryFactoryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey"> & Required<Pick<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey">>, "queryFn" | "queryHash" | "queryKeyHashFn" | "throwOnError"> & {
20270
+ queryFn: Exclude<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>["queryFn"], typeof skipToken | undefined>;
20271
+ };
20272
+ /** TanStack Query mutation options object returned by the SDK's `*MutationOptions` factories. */
20273
+ interface MutationFactoryOptions<TMutationKey extends readonly unknown[], TVariables, TData, TOnMutateResult = unknown> {
20274
+ /** Cache key identifying the mutation. */
20275
+ mutationKey: TMutationKey;
20276
+ /** Runs the mutation for the given variables. */
20277
+ mutationFn: (variables: TVariables) => Promise<TData>;
20278
+ /** Optional callback invoked after the mutation succeeds. */
20279
+ onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => void;
20795
20280
  }
20796
- /** Builds TanStack Query mutation options for {@link Token.decryptBalanceAs | decrypting} a balance via delegated decryption credentials. @see {@link DecryptBalanceAsParams} */
20797
- declare function decryptBalanceAsMutationOptions(token: Token): MutationFactoryOptions<readonly ["zama.decryptBalanceAs", Address], DecryptBalanceAsParams, bigint>;
20798
20281
  //#endregion
20799
- //#region src/query/batch-decrypt-balances-as.d.ts
20800
- /** Variables for {@link batchDecryptBalancesAsMutationOptions}. */
20801
- type BatchDecryptBalancesAsParams = BatchDecryptAsOptions;
20802
- /** Builds TanStack Query mutation options for {@link Token.batchDecryptBalancesAs | decrypting} multiple token balances via delegated decryption credentials. @see {@link BatchDecryptBalancesAsParams} */
20803
- declare function batchDecryptBalancesAsMutationOptions(tokens: Token[]): MutationFactoryOptions<readonly ["zama.batchDecryptBalancesAs", ...Address[]], BatchDecryptBalancesAsParams, Map<Address, bigint>>;
20282
+ //#region src/query/query-keys.d.ts
20283
+ /**
20284
+ * Canonical query-key namespace for `@zama-fhe/sdk/query`.
20285
+ *
20286
+ * @example
20287
+ * ```ts
20288
+ * queryClient.invalidateQueries({
20289
+ * queryKey: zamaQueryKeys.confidentialBalance.token("0xToken"),
20290
+ * });
20291
+ * ```
20292
+ */
20293
+ declare const zamaQueryKeys: {
20294
+ readonly confidentialBalance: {
20295
+ readonly all: readonly ["zama.confidentialBalance"];
20296
+ readonly token: (tokenAddress: Address) => readonly ["zama.confidentialBalance", {
20297
+ readonly tokenAddress: `0x${string}`;
20298
+ }];
20299
+ readonly owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalance", {
20300
+ readonly owner?: `0x${string}` | undefined;
20301
+ readonly walletAddress: `0x${string}`;
20302
+ readonly walletChainId: number;
20303
+ readonly tokenAddress: `0x${string}`;
20304
+ } | {
20305
+ readonly owner?: `0x${string}` | undefined;
20306
+ readonly walletAddress?: undefined;
20307
+ readonly walletChainId?: undefined;
20308
+ readonly tokenAddress: `0x${string}`;
20309
+ }];
20310
+ };
20311
+ readonly confidentialBalances: {
20312
+ readonly all: readonly ["zama.confidentialBalances"];
20313
+ readonly tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) => readonly ["zama.confidentialBalances", {
20314
+ readonly owner?: `0x${string}` | undefined;
20315
+ readonly walletAddress: `0x${string}`;
20316
+ readonly walletChainId: number;
20317
+ readonly tokenAddresses: `0x${string}`[];
20318
+ } | {
20319
+ readonly owner?: `0x${string}` | undefined;
20320
+ readonly walletAddress?: undefined;
20321
+ readonly walletChainId?: undefined;
20322
+ readonly tokenAddresses: `0x${string}`[];
20323
+ }];
20324
+ };
20325
+ readonly tokenMetadata: {
20326
+ readonly all: readonly ["zama.tokenMetadata"];
20327
+ readonly token: (tokenAddress: Address) => readonly ["zama.tokenMetadata", {
20328
+ readonly tokenAddress: `0x${string}`;
20329
+ }];
20330
+ };
20331
+ readonly isConfidential: {
20332
+ readonly all: readonly ["zama.isConfidential"];
20333
+ readonly token: (tokenAddress: Address) => readonly ["zama.isConfidential", {
20334
+ readonly tokenAddress: `0x${string}`;
20335
+ }];
20336
+ };
20337
+ readonly isWrapper: {
20338
+ readonly all: readonly ["zama.isWrapper"];
20339
+ readonly token: (tokenAddress: Address) => readonly ["zama.isWrapper", {
20340
+ readonly tokenAddress: `0x${string}`;
20341
+ }];
20342
+ };
20343
+ readonly wrapperDiscovery: {
20344
+ readonly all: readonly ["zama.wrapperDiscovery"];
20345
+ readonly token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => readonly ["zama.wrapperDiscovery", {
20346
+ readonly registryAddress?: `0x${string}` | undefined;
20347
+ readonly erc20Address?: `0x${string}` | undefined;
20348
+ readonly tokenAddress?: `0x${string}` | undefined;
20349
+ }];
20350
+ };
20351
+ readonly underlyingAllowance: {
20352
+ readonly all: readonly ["zama.underlyingAllowance"];
20353
+ readonly token: (tokenAddress: Address) => readonly ["zama.underlyingAllowance", {
20354
+ readonly tokenAddress: `0x${string}`;
20355
+ }];
20356
+ readonly scope: (tokenAddress: Address, owner?: Address) => readonly ["zama.underlyingAllowance", {
20357
+ readonly owner?: `0x${string}` | undefined;
20358
+ readonly tokenAddress: `0x${string}`;
20359
+ }];
20360
+ };
20361
+ readonly confidentialIsOperator: {
20362
+ readonly all: readonly ["zama.confidentialIsOperator"];
20363
+ readonly token: (tokenAddress?: Address) => readonly ["zama.confidentialIsOperator", {
20364
+ tokenAddress: `0x${string}`;
20365
+ } | {
20366
+ tokenAddress?: undefined;
20367
+ }];
20368
+ readonly scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => readonly ["zama.confidentialIsOperator", {
20369
+ readonly spender?: `0x${string}` | undefined;
20370
+ readonly holder?: `0x${string}` | undefined;
20371
+ readonly tokenAddress?: `0x${string}` | undefined;
20372
+ }];
20373
+ };
20374
+ readonly totalSupply: {
20375
+ readonly all: readonly ["zama.totalSupply"];
20376
+ readonly token: (tokenAddress: Address) => readonly ["zama.totalSupply", {
20377
+ readonly tokenAddress: `0x${string}`;
20378
+ }];
20379
+ };
20380
+ readonly pendingUnshield: {
20381
+ readonly all: readonly ["zama.pendingUnshield"];
20382
+ readonly token: (tokenAddress: Address) => readonly ["zama.pendingUnshield", {
20383
+ readonly tokenAddress: `0x${string}`;
20384
+ }];
20385
+ };
20386
+ readonly hasPermit: {
20387
+ readonly all: readonly ["zama.hasPermit"];
20388
+ readonly scope: (contractAddresses: Address[], walletAccount?: WalletAccount) => readonly ["zama.hasPermit", {
20389
+ readonly contractAddresses: `0x${string}`[];
20390
+ readonly walletAddress: `0x${string}`;
20391
+ readonly walletChainId: number;
20392
+ } | {
20393
+ readonly contractAddresses: `0x${string}`[];
20394
+ readonly walletAddress?: undefined;
20395
+ readonly walletChainId?: undefined;
20396
+ }];
20397
+ };
20398
+ readonly delegationStatus: {
20399
+ readonly all: readonly ["zama.delegationStatus"];
20400
+ readonly contract: (contractAddress?: Address) => readonly ["zama.delegationStatus", {
20401
+ contractAddress: `0x${string}`;
20402
+ } | {
20403
+ contractAddress?: undefined;
20404
+ }];
20405
+ readonly scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => readonly ["zama.delegationStatus", {
20406
+ readonly delegateAddress?: `0x${string}` | undefined;
20407
+ readonly delegatorAddress?: `0x${string}` | undefined;
20408
+ readonly contractAddress?: `0x${string}` | undefined;
20409
+ }];
20410
+ };
20411
+ readonly decryption: {
20412
+ readonly all: readonly ["zama.decryption"];
20413
+ readonly encryptedValue: (encryptedValue: string, contractAddress?: Address) => readonly ["zama.decryption", {
20414
+ readonly contractAddress?: `0x${string}` | undefined;
20415
+ readonly encryptedValue: string;
20416
+ }];
20417
+ readonly encryptedInputs: (encryptedInputs: readonly {
20418
+ encryptedValue: string;
20419
+ contractAddress: Address;
20420
+ }[], walletAccount?: WalletAccount) => readonly ["zama.decryption", {
20421
+ readonly encryptedInputs: {
20422
+ encryptedValue: Hex;
20423
+ contractAddress: `0x${string}`;
20424
+ }[];
20425
+ readonly walletAddress: `0x${string}`;
20426
+ readonly walletChainId: number;
20427
+ } | {
20428
+ readonly encryptedInputs: {
20429
+ encryptedValue: Hex;
20430
+ contractAddress: `0x${string}`;
20431
+ }[];
20432
+ readonly walletAddress?: undefined;
20433
+ readonly walletChainId?: undefined;
20434
+ }];
20435
+ };
20436
+ readonly wrappersRegistry: {
20437
+ readonly all: readonly ["zama.wrappersRegistry"];
20438
+ readonly chainId: () => readonly ["zama.wrappersRegistry", {
20439
+ readonly type: "chainId";
20440
+ }];
20441
+ readonly tokenPairs: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
20442
+ readonly type: "tokenPairs";
20443
+ readonly registryAddress: `0x${string}`;
20444
+ }];
20445
+ readonly confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) => readonly ["zama.wrappersRegistry", {
20446
+ readonly type: "confidentialTokenAddress";
20447
+ readonly registryAddress: `0x${string}`;
20448
+ readonly tokenAddress: `0x${string}`;
20449
+ }];
20450
+ readonly tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
20451
+ readonly type: "tokenAddress";
20452
+ readonly registryAddress: `0x${string}`;
20453
+ readonly confidentialTokenAddress: `0x${string}`;
20454
+ }];
20455
+ readonly tokenPairsLength: (registryAddress: Address) => readonly ["zama.wrappersRegistry", {
20456
+ readonly type: "tokenPairsLength";
20457
+ readonly registryAddress: `0x${string}`;
20458
+ }];
20459
+ readonly tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) => readonly ["zama.wrappersRegistry", {
20460
+ readonly type: "tokenPairsSlice";
20461
+ readonly registryAddress: `0x${string}`;
20462
+ readonly fromIndex: string;
20463
+ readonly toIndex: string;
20464
+ }];
20465
+ readonly tokenPair: (registryAddress: Address, index: string) => readonly ["zama.wrappersRegistry", {
20466
+ readonly type: "tokenPair";
20467
+ readonly registryAddress: `0x${string}`;
20468
+ readonly index: string;
20469
+ }];
20470
+ readonly isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) => readonly ["zama.wrappersRegistry", {
20471
+ readonly type: "isConfidentialTokenValid";
20472
+ readonly registryAddress: `0x${string}`;
20473
+ readonly confidentialTokenAddress: `0x${string}`;
20474
+ }];
20475
+ readonly listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) => readonly ["zama.wrappersRegistry", {
20476
+ readonly type: "listPairs";
20477
+ readonly registryAddress: `0x${string}`;
20478
+ readonly page: number;
20479
+ readonly pageSize: number;
20480
+ readonly metadata: boolean;
20481
+ }];
20482
+ };
20483
+ };
20804
20484
  //#endregion
20805
- //#region src/query/revoke-delegation.d.ts
20806
- /** Variables for {@link revokeDelegationMutationOptions}. */
20807
- interface RevokeDelegationParams {
20808
- /** Address whose delegated decryption rights to revoke. */
20809
- delegateAddress: Address;
20485
+ //#region src/query/signer-query-context.d.ts
20486
+ /** Connected-wallet context threaded into query factories to scope cache keys and gate signer-dependent queries. */
20487
+ interface SignerQueryContext {
20488
+ /** Connected wallet account; queries that need a signer stay disabled until it is set. */
20489
+ walletAccount?: WalletAccount;
20810
20490
  }
20811
- /** Builds TanStack Query mutation options for {@link Delegations.revokeDelegation | revoking} delegated decryption rights on a contract. @see {@link RevokeDelegationParams} */
20812
- declare function revokeDelegationMutationOptions(sdk: ZamaSDK, contractAddress: Address): MutationFactoryOptions<readonly ["zama.revokeDelegation", Address], RevokeDelegationParams, TransactionResult>;
20813
20491
  //#endregion
20814
- //#region src/query/delegation-status.d.ts
20815
- /** Configuration for {@link delegationStatusQueryOptions}. */
20816
- interface DelegationStatusQueryConfig {
20817
- /** Contract the delegation applies to; pass `undefined` to keep the query disabled. */
20818
- contractAddress: Address | undefined;
20819
- /** Address granting the delegated decryption rights; the query stays disabled until provided. */
20820
- delegatorAddress?: Address;
20821
- /** Address receiving the delegated decryption rights; the query stays disabled until provided. */
20822
- delegateAddress?: Address;
20823
- /** Additional TanStack Query options merged into the generated query (e.g. `staleTime`, `enabled`). */
20824
- query?: Record<string, unknown>;
20492
+ //#region src/query/user-decrypt.d.ts
20493
+ /** A single encrypted value to decrypt, paired with the contract that owns it. */
20494
+ interface EncryptedInput {
20495
+ /** Encrypted handle to decrypt. */
20496
+ encryptedValue: EncryptedValue;
20497
+ /** Address of the contract the encrypted value belongs to. */
20498
+ contractAddress: Address;
20825
20499
  }
20826
- /** Builds TanStack Query options for reading the decryption-delegation status between a delegator and a delegate on a contract. */
20827
- declare function delegationStatusQueryOptions(sdk: ZamaSDK, config: DelegationStatusQueryConfig): QueryFactoryOptions<DelegationStatus, Error, DelegationStatus, ReturnType<typeof zamaQueryKeys.delegationStatus.scope>>;
20500
+ /** Decrypted clear values keyed by encrypted handle. */
20501
+ type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;
20502
+ /** Builds TanStack Query options for decrypting a batch of encrypted handles into their clear values. */
20503
+ declare function decryptValuesQueryOptions(sdk: ZamaSDK, encryptedInputs: EncryptedInput[], signerContext?: SignerQueryContext): QueryFactoryOptions<DecryptResult, Error, DecryptResult, ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>>;
20828
20504
  //#endregion
20829
20505
  //#region src/services/decryption-service.d.ts
20830
20506
  /** Options shared by the delegated-decrypt entry points. */
@@ -20854,197 +20530,6 @@ interface BatchDecryptResult {
20854
20530
  items: BatchDecryptItem[];
20855
20531
  }
20856
20532
  //#endregion
20857
- //#region src/namespaces/offline.d.ts
20858
- /**
20859
- * Namespace for the offline-signing pipeline —
20860
- * `prepare → [external sign + self-publish]` — for institutional custody, HSM
20861
- * ceremonies, and policy-engine workflows where signing runs out-of-process and
20862
- * cannot happen synchronously in a single Promise.
20863
- */
20864
- declare class Offline {
20865
- #private;
20866
- /**
20867
- * Build an RLP-encoded unsigned transaction for the given request. The
20868
- * caller signs it externally — via an HSM ceremony, an out-of-process
20869
- * custodian, or any signer holding the key — and broadcasts the signed bytes
20870
- * through its own channel.
20871
- *
20872
- * Signer-optional: works without a configured signer (canonical shape for
20873
- * cross-process custody — the back-end signer service consumes
20874
- * `prepared.unsignedTx` and returns signed bytes).
20875
- *
20876
- * @remarks
20877
- * `request.from` is only a declaration — the SDK does not prove the caller
20878
- * controls it, and an EIP-1559 unsigned tx carries no `from` field at all
20879
- * (the on-chain sender is whichever key signs the bytes). Point `from` at
20880
- * the account the custodian will sign with; custodians enforce key-control
20881
- * at sign time — a signing request for a key the credential can't use fails
20882
- * there — so a mismatched `from` cannot make the custodian sign from an
20883
- * account you don't control. Verifying control of `from` up front is still
20884
- * the application's responsibility.
20885
- */
20886
- prepare<K extends TransactionKind>(request: Extract<PrepareTransactionRequest, {
20887
- kind: K;
20888
- }>, options?: PrepareOptions): Promise<PreparedFor<K>>;
20889
- }
20890
- //#endregion
20891
- //#region src/zama-sdk.d.ts
20892
- /** Instance-level options that are deliberately not part of the shareable config object. */
20893
- interface ZamaSDKOptions {
20894
- /**
20895
- * Encrypts the transport key pair's private half at rest. Headless environments only
20896
- * (CLI tools, servers, agents); the constructor rejects it in browser contexts. Supply
20897
- * at least 32 random bytes, or a string of at least 64 characters, from a CSPRNG or
20898
- * secrets manager. The SDK copies a Uint8Array secret and zeroizes its own copy after
20899
- * key import; it never touches your buffer, so zeroize yours after construction.
20900
- * The SDK never persists or exposes this value. Omit for the default:
20901
- * plaintext at rest, security delegated to the storage backend.
20902
- */
20903
- transportKeyPairDerivationSecret?: string | Uint8Array;
20904
- }
20905
- /**
20906
- * ZamaSDK — composes a RelayerSDK with contract abstraction.
20907
- *
20908
- * Exposes domain namespaces for permits, delegations, decryption, offline
20909
- * signing, and tokens, plus an unchanged registry, a top-level `encrypt`, and
20910
- * lifecycle methods. Internal `*Service` classes do the work; the namespace
20911
- * classes own SDK-level guards (chain alignment, signer requirement, event
20912
- * emission).
20913
- */
20914
- declare class ZamaSDK {
20915
- #private;
20916
- /** Read-only chain access used for all contract reads. */
20917
- readonly provider: GenericProvider;
20918
- /** Wallet signer used for write operations, or `undefined` when the SDK is read-only. */
20919
- readonly signer: GenericSigner | undefined;
20920
- /** Storage for cached permits and transport key pairs. */
20921
- readonly storage: GenericStorage;
20922
- /**
20923
- * A {@link WrappersRegistry} instance auto-configured for the current chain.
20924
- * Uses built-in defaults from chain configs, and the SDK's `registryTTL` if configured.
20925
- */
20926
- readonly registry: WrappersRegistry;
20927
- /** Permit and keypair management. */
20928
- readonly permits: Permits;
20929
- /** On-chain decryption-delegation management. */
20930
- readonly delegations: Delegations;
20931
- /** FHE decryption (user, delegated user, public). */
20932
- readonly decryption: Decryption;
20933
- /** Offline-signing pipeline: `prepare` builds an unsigned tx the caller signs and broadcasts out-of-process — for HSM, policy-engine, and cross-process custody workflows. */
20934
- readonly offline: Offline;
20935
- constructor(config: ZamaConfig, options?: ZamaSDKOptions);
20936
- /**
20937
- * The single-chain relayer backend for the **currently active** chain.
20938
- */
20939
- get relayer(): RelayerSDK;
20940
- /**
20941
- * Create a {@link WrappersRegistry} instance bound to this SDK's provider.
20942
- * Inherits the registry addresses derived from the SDK's chain configs, so
20943
- * the result is consistent with {@link ZamaSDK.registry}.
20944
- *
20945
- * @param registryAddresses - Optional per-chain overrides for this registry instance.
20946
- * @returns A {@link WrappersRegistry} instance.
20947
- *
20948
- * @example
20949
- * ```ts
20950
- * // Addresses resolved from the SDK's chain configs
20951
- * const registry = sdk.createWrappersRegistry();
20952
- *
20953
- * // Hardhat or custom chain — override per chain for this registry instance
20954
- * const registry = sdk.createWrappersRegistry({ [31337]: "0xYourRegistry" });
20955
- *
20956
- * const pairs = await registry.getTokenPairs();
20957
- * ```
20958
- */
20959
- createWrappersRegistry(registryAddresses?: Record<number, Address>): WrappersRegistry;
20960
- /**
20961
- * Encrypt one or more plaintext values into FHE ciphertexts.
20962
- *
20963
- * @param params - Typed FHE inputs, the target contract address, and the user address.
20964
- * @returns External encrypted values and the input proof for on-chain submission.
20965
- * @throws if FHE encryption fails. {@link EncryptionFailedError}
20966
- *
20967
- * @example
20968
- * ```ts
20969
- * const { encryptedValues, inputProof } = await sdk.encrypt({
20970
- * values: [{ value: 1000n, type: "euint64" }],
20971
- * contractAddress: "0xToken",
20972
- * userAddress: "0xUser",
20973
- * });
20974
- * ```
20975
- */
20976
- encrypt(params: EncryptParams, options?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<EncryptResult>;
20977
- /**
20978
- * Create a high-level ERC-20-style interface for an ERC-7984 confidential token.
20979
- * Supports balance queries, transfers, operator approvals, and decryption.
20980
- *
20981
- * For ERC-7984 wrappers (shield/unshield/allowance), use {@link createWrappedToken} instead.
20982
- *
20983
- * @param address - The confidential token contract address.
20984
- * @returns A {@link Token} instance bound to this SDK.
20985
- *
20986
- * @example
20987
- * ```ts
20988
- * const token = sdk.createToken(cUSDT);
20989
- * const balance = await token.balanceOf(userAddress);
20990
- * ```
20991
- */
20992
- createToken(address: Address): Token;
20993
- /**
20994
- * Create a high-level interface for an ERC-7984 wrapper token.
20995
- * Extends {@link Token} with shield/unshield/allowance/finalize-unwrap operations.
20996
- *
20997
- * @param address - The wrapper token contract address.
20998
- * @returns A {@link WrappedToken} instance bound to this SDK.
20999
- *
21000
- * @example
21001
- * ```ts
21002
- * const wrapped = sdk.createWrappedToken(wUSDT);
21003
- * await wrapped.shield(1_000_000n);
21004
- * ```
21005
- */
21006
- createWrappedToken(address: Address): WrappedToken;
21007
- /**
21008
- * Unsubscribe from signer lifecycle events without terminating the relayer.
21009
- * Call this when the SDK instance is being replaced but the relayer is shared
21010
- * (e.g. React provider remount in Strict Mode).
21011
- */
21012
- dispose(): void;
21013
- /**
21014
- * Terminate the relayer backend and clean up resources.
21015
- * Call this when the SDK is no longer needed (e.g. on unmount or shutdown).
21016
- */
21017
- terminate(): void;
21018
- /**
21019
- * Implements the TC39 Explicit Resource Management protocol.
21020
- * Calls {@link terminate} when the `using` binding goes out of scope,
21021
- * unsubscribing signer events and shutting down the relayer.
21022
- *
21023
- * @example
21024
- * ```ts
21025
- * {
21026
- * using sdk = new ZamaSDK({ relayer, provider, signer, storage });
21027
- * await sdk.permits.grantPermit([cUSDT]);
21028
- * const balance = await sdk.createToken(cUSDT).balanceOf(userAddress);
21029
- * } // sdk.terminate() called automatically here
21030
- * ```
21031
- */
21032
- [Symbol.dispose](): void;
21033
- }
21034
- //#endregion
21035
- //#region src/query/user-decrypt.d.ts
21036
- /** A single encrypted value to decrypt, paired with the contract that owns it. */
21037
- interface EncryptedInput {
21038
- /** Encrypted handle to decrypt. */
21039
- encryptedValue: EncryptedValue;
21040
- /** Address of the contract the encrypted value belongs to. */
21041
- contractAddress: Address;
21042
- }
21043
- /** Decrypted clear values keyed by encrypted handle. */
21044
- type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;
21045
- /** Builds TanStack Query options for decrypting a batch of encrypted handles into their clear values. */
21046
- declare function decryptValuesQueryOptions(sdk: ZamaSDK, encryptedInputs: EncryptedInput[], signerContext?: SignerQueryContext): QueryFactoryOptions<DecryptResult, Error, DecryptResult, ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>>;
21047
- //#endregion
21048
20533
  //#region src/namespaces/decryption.d.ts
21049
20534
  /**
21050
20535
  * Public namespace for FHE decryption — the canonical way to decrypt.
@@ -21182,5 +20667,94 @@ declare class Decryption {
21182
20667
  } & DelegatedDecryptOptions): Promise<BatchDecryptResult>;
21183
20668
  }
21184
20669
  //#endregion
21185
- export { ConfidentialTransferParams as $, ZamaErrorCode as $n, invalidateAfterUnshield as $t, FinalizeUnwrapParams as A, BalanceErrorDetails as An, balanceOfContract as Ar, UnderlyingAllowanceQueryConfig as At, unshieldAllMutationOptions as B, DelegationDelegateEqualsContractError as Bn, isOperatorContract as Br, IsConfidentialQueryConfig as Bt, HasPermitQueryConfig as C, WalletAccountNotReadyError as Cn, ERC7984_INTERFACE_ID as Cr, BatchBalancesResult as Ct, DelegatedDecryptValuesMutationParams as D, ConfigurationError as Dn, supportsInterfaceContract as Dr, confidentialIsOperatorQueryOptions as Dt, decryptPublicValuesMutationOptions as E, NotEntitledError as En, isConfidentialWrapperContract as Er, ConfidentialIsOperatorQueryConfig as Et, UnwrapParams as F, DecryptionFailedError as Fn, confidentialTotalSupplyContract as Fr, ListPairsOptions as Ft, ConfidentialSetOperatorParams as G, DelegationNotPropagatedError as Gn, unwrapFromBalanceContract as Gr, tokenMetadataQueryOptions as Gt, unshieldMutationOptions as H, DelegationExpiredError as Hn, setOperatorContract as Hr, isWrapperQueryOptions as Ht, unwrapMutationOptions as I, EncryptionFailedError as In, confidentialTransferContract as Ir, WrappersRegistry as It, confidentialTransferFromAndCallMutationOptions as J, KeyWrappingError as Jn, QueryLike as Jt, confidentialSetOperatorMutationOptions as K, DelegationSelfNotAllowedError as Kn, wrapContract as Kr, QueryClientLike as Kt, ResumeUnshieldParams as L, AclPausedError as Ln, confidentialTransferFromContract as Lr, WrappersRegistryConfig as Lt, unwrapAllMutationOptions as M, InsufficientAllowanceError as Mn, nameContract as Mr, WrapperDiscoveryQueryConfig as Mt, WrapParams as N, InsufficientConfidentialBalanceError as Nn, symbolContract as Nr, wrapperDiscoveryQueryOptions as Nt, delegatedDecryptValuesMutationOptions as O, RelayerRequestFailedError as On, allowanceContract as Or, PendingUnshieldQueryConfig as Ot, wrapMutationOptions as P, InsufficientERC20BalanceError as Pn, confidentialBalanceOfContract as Pr, DefaultRegistryAddresses as Pt, confidentialTransferAndCallMutationOptions as Q, ZamaError as Qn, invalidateAfterTransfer as Qt, resumeUnshieldMutationOptions as R, DelegationContractIsSelfError as Rn, finalizeUnwrapContract as Rr, TotalSupplyQueryConfig as Rt, revokePermitsMutationOptions as S, SignerRequiredError as Sn, ERC1363_INTERFACE_ID as Sr, WrappedToken as St, grantPermitMutationOptions as T, RpcRateLimitError as Tn, isConfidentialTokenContract as Tr, Token as Tt, ApproveUnderlyingParams as U, DelegationExpiryUnchangedError as Un, underlyingContract as Ur, TokenMetadata as Ut, UnshieldParams as V, DelegationExpirationTooSoonError as Vn, rateContract as Vr, isConfidentialQueryOptions as Vt, approveUnderlyingMutationOptions as W, DelegationNotFoundError as Wn, unwrapContract as Wr, TokenMetadataQueryConfig as Wt, confidentialTransferFromMutationOptions as X, TransportKeyPairExpiredError as Xn, invalidateAfterSetOperator as Xt, ConfidentialTransferFromParams as Y, NoCiphertextError as Yn, invalidateAfterApproveUnderlying as Yt, ConfidentialTransferAndCallParams as Z, ChainMismatchError as Zn, invalidateAfterShield as Zt, DecryptBalanceAsParams as _, matchZamaError as _n, delegateForUserDecryptionContract as _r, tokenPairsSliceQueryOptions as _t, ZamaSDK as a, invalidateWalletLifecycleQueries as an, SerializedTransportKeyPair as ar, ListPairsQueryConfig as at, delegateDecryptionMutationOptions as b, SigningRejectedError as bn, revokeDelegationContract as br, ConfidentialBalanceQueryConfig as bt, BatchDecryptItem as c, MutationFactoryOptions as cn, TokenWrapperPair as cr, TokenPairsSliceQueryConfig as ct, DelegationStatusQueryConfig as d, filterQueryOptions as dn, getTokenAddressContract as dr, isConfidentialTokenValidQueryOptions as dt, invalidateAfterUnshieldSettled as en, isRetryable as er, confidentialTransferMutationOptions as et, delegationStatusQueryOptions as f, hashFn as fn, getTokenPairContract as fr, listPairsQueryOptions as ft, batchDecryptBalancesAsMutationOptions as g, ErrorForCode as gn, isConfidentialTokenValidContract as gr, tokenPairsQueryOptions as gt, BatchDecryptBalancesAsParams as h, Permits as hn, getTokenPairsSliceContract as hr, tokenPairsLengthQueryOptions as ht, decryptValuesQueryOptions as i, invalidateWagmiBalanceQueries as in, SerializedPermitEip712 as ir, IsConfidentialTokenValidQueryConfig as it, finalizeUnwrapMutationOptions as j, ERC20ReadFailedError as jn, decimalsContract as jr, underlyingAllowanceQueryOptions as jt, encryptMutationOptions as k, BalanceCheckUnavailableError as kn, approveContract as kr, pendingUnshieldQueryOptions as kt, BatchDecryptResult as l, QueryFactoryOptions as ln, TokenWrapperPairWithMetadata as lr, WrappersRegistryQueryConfig as lt, revokeDelegationMutationOptions as m, DelegationStatus as mn, getTokenPairsLengthContract as mr, tokenPairQueryOptions as mt, DecryptResult as n, invalidateAfterWrap as nn, Permission as nr, shieldMutationOptions as nt, ZamaSDKOptions as o, zamaQueryKeys as on, ChecksummedAddress as or, TokenAddressQueryConfig as ot, RevokeDelegationParams as p, Delegations as pn, getTokenPairsContract as pr, tokenAddressQueryOptions as pt, ConfidentialTransferFromAndCallParams as q, InvalidTransportKeyPairError as qn, createConfig as qr, QueryFilterLike as qt, EncryptedInput as r, invalidateBalanceQueries as rn, SerializedPermit as rr, ConfidentialTokenAddressQueryConfig as rt, Offline as s, SignerQueryContext as sn, PaginatedResult as sr, TokenPairQueryConfig as st, Decryption as t, invalidateAfterUnwrap as tn, retryAfterSeconds as tr, ShieldParams as tt, DelegatedDecryptOptions as u, StrippedQueryOptionKeys as un, getConfidentialTokenAddressContract as ur, confidentialTokenAddressQueryOptions as ut, decryptBalanceAsMutationOptions as v, TransactionRevertedError as vn, getDelegationExpiryContract as vr, ConfidentialBalancesQueryConfig as vt, hasPermitQueryOptions as w, WalletNotConnectedError as wn, ERC7984_WRAPPER_INTERFACE_ID as wr, BatchDecryptAsOptions as wt, clearCredentialsMutationOptions as x, SignerNotConfiguredError as xn, transferAndCallContract as xr, confidentialBalanceQueryOptions as xt, DelegateDecryptionParams as y, SigningFailedError as yn, isHandleDelegatedContract as yr, confidentialBalancesQueryOptions as yt, UnshieldAllParams as z, DelegationCooldownError as zn, inferredTotalSupplyContract as zr, totalSupplyQueryOptions as zt };
21186
- //# sourceMappingURL=index-BNeNpxpl.d.ts.map
20670
+ //#region src/storage/memory-storage.d.ts
20671
+ /** In-memory credential store. Credentials are lost on page reload. */
20672
+ declare class MemoryStorage implements GenericStorage {
20673
+ #private;
20674
+ /**
20675
+ * Retrieve a value by key.
20676
+ * @returns The stored value, or `null` if the key does not exist.
20677
+ */
20678
+ get<T = unknown>(key: string): Promise<T | null>;
20679
+ /** Store a value under the given key, overwriting any existing entry. */
20680
+ set<T = unknown>(key: string, value: T): Promise<void>;
20681
+ /** Remove the entry for the given key (no-op if absent). */
20682
+ delete(key: string): Promise<void>;
20683
+ }
20684
+ /** Default singleton for application-wide use. */
20685
+ declare const memoryStorage: MemoryStorage;
20686
+ //#endregion
20687
+ //#region src/storage/indexeddb-storage.d.ts
20688
+ /**
20689
+ * IndexedDB-backed {@link GenericStorage}.
20690
+ *
20691
+ * Stores keypair and permit objects keyed by a hashed wallet address. The
20692
+ * SDK delegates security to the storage backend — values are persisted
20693
+ * verbatim with no SDK-layer encryption.
20694
+ */
20695
+ declare class IndexedDBStorage implements GenericStorage {
20696
+ #private;
20697
+ constructor(dbName?: string, dbVersion?: number, storeName?: string);
20698
+ /**
20699
+ * Retrieve a value by key.
20700
+ * @returns The stored value, or `null` if the key does not exist.
20701
+ */
20702
+ get<T = unknown>(key: string): Promise<T | null>;
20703
+ /** Store a value under the given key, overwriting any existing entry. */
20704
+ set<T = unknown>(key: string, value: T): Promise<void>;
20705
+ /** Remove the entry for the given key (no-op if absent). */
20706
+ delete(key: string): Promise<void>;
20707
+ /** Remove all stored entries. */
20708
+ clear(): Promise<void>;
20709
+ }
20710
+ /** Default singleton for application-wide use. */
20711
+ declare const indexedDBStorage: IndexedDBStorage;
20712
+ //#endregion
20713
+ //#region src/storage/chrome-session-storage.d.ts
20714
+ /**
20715
+ * {@link GenericStorage} backed by `chrome.storage.session`.
20716
+ *
20717
+ * Use this in MV3 web extensions so the wallet signature survives
20718
+ * service worker restarts and is shared across popup, background,
20719
+ * and content script contexts.
20720
+ *
20721
+ * @example
20722
+ * ```ts
20723
+ * import { ZamaSDK, indexedDBStorage, chromeSessionStorage } from "@zama-fhe/sdk";
20724
+ * import { createConfig } from "@zama-fhe/sdk/viem";
20725
+ *
20726
+ * const config = createConfig({
20727
+ * chains: [mySepolia],
20728
+ * publicClient,
20729
+ * walletClient,
20730
+ * relayers: { [mySepolia.id]: web() },
20731
+ * storage: indexedDBStorage, // encrypted transport key pair — persistent
20732
+ * permitStorage: chromeSessionStorage, // signed permits — ephemeral
20733
+ * });
20734
+ * const sdk = new ZamaSDK(config);
20735
+ * ```
20736
+ */
20737
+ declare class ChromeSessionStorage implements GenericStorage {
20738
+ /**
20739
+ * Retrieve a value by key.
20740
+ * @returns The stored value, or `null` if the key does not exist.
20741
+ */
20742
+ get<T = unknown>(key: string): Promise<T | null>;
20743
+ /** Store a value under the given key, overwriting any existing entry. */
20744
+ set(key: string, value: unknown): Promise<void>;
20745
+ /** Remove the entry for the given key (no-op if absent). */
20746
+ delete(key: string): Promise<void>;
20747
+ }
20748
+ /** Default singleton for application-wide use. */
20749
+ declare const chromeSessionStorage: ChromeSessionStorage;
20750
+ //#endregion
20751
+ //#region src/utils/handles.d.ts
20752
+ /** All-zero encrypted-value sentinel — a 32-byte zero handle representing the cleartext value `0`. */
20753
+ declare const ZERO_ENCRYPTED_VALUE: "0x0000000000000000000000000000000000000000000000000000000000000000";
20754
+ /**
20755
+ * Check whether an encrypted value represents the zero value.
20756
+ */
20757
+ declare function isEncryptedValueZero(encryptedValue: string): boolean;
20758
+ //#endregion
20759
+ export { InsufficientConfidentialBalanceError as $, symbolContract as $t, BatchDecryptAsOptions as A, getConfidentialTokenAddressContract as At, SigningRejectedError as B, revokeDelegationContract as Bt, ZamaSDKOptions as C, SerializedPermit as Ct, WrappersRegistryConfig as D, PaginatedResult as Dt, WrappersRegistry as E, ChecksummedAddress as Et, Permits as F, getTokenPairsSliceContract as Ft, RpcRateLimitError as G, isConfidentialTokenContract as Gt, SignerRequiredError as H, ERC1363_INTERFACE_ID as Ht, ErrorForCode as I, isConfidentialTokenValidContract as It, RelayerRequestFailedError as J, allowanceContract as Jt, NotEntitledError as K, isConfidentialWrapperContract as Kt, matchZamaError as L, delegateForUserDecryptionContract as Lt, Offline as M, getTokenPairContract as Mt, Delegations as N, getTokenPairsContract as Nt, WrappedToken as O, TokenWrapperPair as Ot, DelegationStatus as P, getTokenPairsLengthContract as Pt, InsufficientAllowanceError as Q, nameContract as Qt, TransactionRevertedError as R, getDelegationExpiryContract as Rt, ZamaSDK as S, Permission as St, ListPairsOptions as T, SerializedTransportKeyPair as Tt, WalletAccountNotReadyError as U, ERC7984_INTERFACE_ID as Ut, SignerNotConfiguredError as V, transferAndCallContract as Vt, WalletNotConnectedError as W, ERC7984_WRAPPER_INTERFACE_ID as Wt, BalanceErrorDetails as X, balanceOfContract as Xt, BalanceCheckUnavailableError as Y, approveContract as Yt, ERC20ReadFailedError as Z, decimalsContract as Zt, decryptValuesQueryOptions as _, ChainMismatchError as _t, ChromeSessionStorage as a, inferredTotalSupplyContract as an, DelegationCooldownError as at, MutationFactoryOptions as b, isRetryable as bt, indexedDBStorage as c, setOperatorContract as cn, DelegationExpiredError as ct, Decryption as d, unwrapFromBalanceContract as dn, DelegationNotPropagatedError as dt, confidentialBalanceOfContract as en, InsufficientERC20BalanceError as et, BatchDecryptItem as f, wrapContract as fn, DelegationSelfNotAllowedError as ft, EncryptedInput as g, TransportKeyPairExpiredError as gt, DecryptResult as h, NoCiphertextError as ht, isEncryptedValueZero as i, finalizeUnwrapContract as in, DelegationContractIsSelfError as it, Token as j, getTokenAddressContract as jt, BatchBalancesResult as k, TokenWrapperPairWithMetadata as kt, MemoryStorage as l, underlyingContract as ln, DelegationExpiryUnchangedError as lt, DelegatedDecryptOptions as m, KeyWrappingError as mt, Hex$1 as n, confidentialTransferContract as nn, EncryptionFailedError as nt, chromeSessionStorage as o, isOperatorContract as on, DelegationDelegateEqualsContractError as ot, BatchDecryptResult as p, createConfig as pn, InvalidTransportKeyPairError as pt, ConfigurationError as q, supportsInterfaceContract as qt, ZERO_ENCRYPTED_VALUE as r, confidentialTransferFromContract as rn, AclPausedError as rt, IndexedDBStorage as s, rateContract as sn, DelegationExpirationTooSoonError as st, Address$1 as t, confidentialTotalSupplyContract as tn, DecryptionFailedError as tt, memoryStorage as u, unwrapContract as un, DelegationNotFoundError as ut, SignerQueryContext as v, ZamaError as vt, DefaultRegistryAddresses as w, SerializedPermitEip712 as wt, QueryFactoryOptions as x, retryAfterSeconds as xt, zamaQueryKeys as y, ZamaErrorCode as yt, SigningFailedError as z, isHandleDelegatedContract as zt };
20760
+ //# sourceMappingURL=index-CLhOMZFu.d.ts.map