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