@zama-fhe/sdk 3.3.0 → 3.3.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +0 -2
  2. package/dist/cjs/base-signer.cjs +1 -1
  3. package/dist/cjs/base-signer.cjs.map +1 -1
  4. package/dist/cjs/chains.cjs +1 -1
  5. package/dist/cjs/chains.cjs.map +1 -1
  6. package/dist/cjs/cleartext/index.cjs +1 -1
  7. package/dist/cjs/cleartext.cjs +2 -0
  8. package/dist/cjs/cleartext.cjs.map +1 -0
  9. package/dist/cjs/ethers/index.cjs.map +1 -1
  10. package/dist/cjs/fhevm-relayer.cjs +2 -0
  11. package/dist/cjs/fhevm-relayer.cjs.map +1 -0
  12. package/dist/cjs/index.cjs +1 -1
  13. package/dist/cjs/index.cjs.map +1 -1
  14. package/dist/cjs/node/index.cjs +2 -0
  15. package/dist/cjs/node/index.cjs.map +1 -0
  16. package/dist/cjs/query/index.cjs +1 -1
  17. package/dist/cjs/query/index.cjs.map +1 -1
  18. package/dist/cjs/relayer.cjs +1 -1
  19. package/dist/cjs/relayer.cjs.map +1 -1
  20. package/dist/cjs/token.cjs +1 -1
  21. package/dist/cjs/token.cjs.map +1 -1
  22. package/dist/cjs/viem/index.cjs +1 -1
  23. package/dist/cjs/viem/index.cjs.map +1 -1
  24. package/dist/cjs/web/index.cjs +1 -590
  25. package/dist/cjs/web/index.cjs.map +1 -1
  26. package/dist/cjs/wrappers-registry.cjs.map +1 -1
  27. package/dist/esm/base-signer-CI-FYai2.js +2 -0
  28. package/dist/esm/base-signer-CI-FYai2.js.map +1 -0
  29. package/dist/esm/{base-signer-C3Wc5oi9.d.ts → base-signer-Q2EJECrc.d.ts} +2 -2
  30. package/dist/esm/chains/index.d.ts +2 -3
  31. package/dist/esm/chains/index.js +1 -1
  32. package/dist/esm/chains-CLv9HEJ_.js +2 -0
  33. package/dist/esm/chains-CLv9HEJ_.js.map +1 -0
  34. package/dist/esm/cleartext/index.d.ts +3 -2
  35. package/dist/esm/cleartext/index.js +1 -1
  36. package/dist/esm/cleartext-BfXTVQu-.js +2 -0
  37. package/dist/esm/cleartext-BfXTVQu-.js.map +1 -0
  38. package/dist/esm/cleartext-U6sPs_Kd.d.ts +19 -0
  39. package/dist/esm/ethers/index.d.ts +4 -5
  40. package/dist/esm/ethers/index.js +1 -1
  41. package/dist/esm/ethers/index.js.map +1 -1
  42. package/dist/esm/fhevm-relayer-B-lEKfPQ.js +2 -0
  43. package/dist/esm/fhevm-relayer-B-lEKfPQ.js.map +1 -0
  44. package/dist/esm/index-BnIp_-Ak.d.ts +328 -0
  45. package/dist/esm/{index-CYBH0nyo.d.ts → index-D66eC3G7.d.ts} +60 -13
  46. package/dist/esm/index.d.ts +8 -11
  47. package/dist/esm/index.js +1 -1
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/node/index.d.ts +5 -194
  50. package/dist/esm/node/index.js +1 -1
  51. package/dist/esm/node/index.js.map +1 -1
  52. package/dist/esm/query/index.d.ts +3 -380
  53. package/dist/esm/query/index.js +1 -1
  54. package/dist/esm/query/index.js.map +1 -1
  55. package/dist/esm/relayer-BYq9bLh8.js +2 -0
  56. package/dist/esm/relayer-BYq9bLh8.js.map +1 -0
  57. package/dist/esm/token-CmHTAAWW.js +2 -0
  58. package/dist/esm/token-CmHTAAWW.js.map +1 -0
  59. package/dist/esm/{types-piBsdTIP.d.ts → types-Bov8XY36.d.ts} +3 -3
  60. package/dist/esm/{types-OHIaPwCy.d.ts → types-BpvL50qX.d.ts} +3 -3
  61. package/dist/esm/types-C-WTLcHZ.d.ts +988 -0
  62. package/dist/esm/viem/index.d.ts +4 -5
  63. package/dist/esm/viem/index.js +1 -1
  64. package/dist/esm/viem/index.js.map +1 -1
  65. package/dist/esm/web/index.d.ts +6 -9
  66. package/dist/esm/web/index.js +1 -590
  67. package/dist/esm/web/index.js.map +1 -1
  68. package/dist/esm/{wrappers-registry-C1oK8Bi6.js → wrappers-registry-xZWzyAi4.js} +2 -2
  69. package/dist/esm/wrappers-registry-xZWzyAi4.js.map +1 -0
  70. package/dist/esm/{index-C1Mtc8Rw.d.ts → zama-sdk-q4_qt64Q.d.ts} +1471 -1102
  71. package/package.json +6 -2
  72. package/dist/cjs/assertions.cjs +0 -2
  73. package/dist/cjs/assertions.cjs.map +0 -1
  74. package/dist/cjs/encryption.cjs +0 -2
  75. package/dist/cjs/encryption.cjs.map +0 -1
  76. package/dist/cjs/relayer-cleartext.cjs +0 -2
  77. package/dist/cjs/relayer-cleartext.cjs.map +0 -1
  78. package/dist/cjs/relayer-sdk.worker.js +0 -589
  79. package/dist/cjs/timeout.cjs +0 -2
  80. package/dist/cjs/timeout.cjs.map +0 -1
  81. package/dist/cjs/validation.cjs +0 -2
  82. package/dist/cjs/validation.cjs.map +0 -1
  83. package/dist/esm/assertions-zYseN5Xz.js +0 -2
  84. package/dist/esm/assertions-zYseN5Xz.js.map +0 -1
  85. package/dist/esm/base-signer-DjytqPkd.js +0 -2
  86. package/dist/esm/base-signer-DjytqPkd.js.map +0 -1
  87. package/dist/esm/chains-CXcO1DBP.js +0 -2
  88. package/dist/esm/chains-CXcO1DBP.js.map +0 -1
  89. package/dist/esm/cleartext-DAkOTlrE.d.ts +0 -19
  90. package/dist/esm/cleartext-rTWFctyd.js +0 -2
  91. package/dist/esm/cleartext-rTWFctyd.js.map +0 -1
  92. package/dist/esm/encryption-x4Z_Icqk.js +0 -2
  93. package/dist/esm/encryption-x4Z_Icqk.js.map +0 -1
  94. package/dist/esm/hex-A72GrTf9.js +0 -2
  95. package/dist/esm/hex-A72GrTf9.js.map +0 -1
  96. package/dist/esm/indexeddb-storage-Mi-fCWN3.js +0 -2
  97. package/dist/esm/indexeddb-storage-Mi-fCWN3.js.map +0 -1
  98. package/dist/esm/memory-storage-fp9RY5BQ.js +0 -2
  99. package/dist/esm/memory-storage-fp9RY5BQ.js.map +0 -1
  100. package/dist/esm/node/relayer-sdk.node-worker.d.ts +0 -1
  101. package/dist/esm/node/relayer-sdk.node-worker.js +0 -2
  102. package/dist/esm/node/relayer-sdk.node-worker.js.map +0 -1
  103. package/dist/esm/relayer-cleartext-Bp6jtxDd.js +0 -2
  104. package/dist/esm/relayer-cleartext-Bp6jtxDd.js.map +0 -1
  105. package/dist/esm/relayer-cleartext-CSeMlmGO.d.ts +0 -844
  106. package/dist/esm/relayer-eavK5bfZ.js +0 -2
  107. package/dist/esm/relayer-eavK5bfZ.js.map +0 -1
  108. package/dist/esm/relayer-sdk.worker.js +0 -589
  109. package/dist/esm/timeout-CNVfiaJD.js +0 -2
  110. package/dist/esm/timeout-CNVfiaJD.js.map +0 -1
  111. package/dist/esm/token-Bt33g0zQ.js +0 -2
  112. package/dist/esm/token-Bt33g0zQ.js.map +0 -1
  113. package/dist/esm/types-BgczXqW2.d.ts +0 -49
  114. package/dist/esm/types-Gn5MeDsr.d.ts +0 -669
  115. package/dist/esm/validation-DLszOweh.js +0 -2
  116. package/dist/esm/validation-DLszOweh.js.map +0 -1
  117. package/dist/esm/worker.base-client-BVnT4yJa.js +0 -2
  118. package/dist/esm/worker.base-client-BVnT4yJa.js.map +0 -1
  119. package/dist/esm/wrappers-registry-C1oK8Bi6.js.map +0 -1
@@ -1,844 +0,0 @@
1
- import { n as FheChain } from "./types-BgczXqW2.js";
2
- import { PrivateKeyAccount } from "viem/accounts";
3
- import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, Hex } from "viem";
4
- import { z } from "zod/mini";
5
- import * as SDK from "@zama-fhe/relayer-sdk/bundle";
6
- import { Bytes32Hex, ClearValueType, InputProofBytesType, KmsDelegatedUserDecryptEIP712Type, KmsUserDecryptEIP712Type, PublicDecryptResults, ZKProofLike } from "@zama-fhe/relayer-sdk/bundle";
7
-
8
- //#region src/utils/error.d.ts
9
- /**
10
- * A plain, structured-clone-safe snapshot of an error and its cause chain.
11
- *
12
- * The worker boundary (`postMessage`) strips prototypes, `code`/`status`, and —
13
- * critically — the `cause` chain, leaving only the message. Decryption errors
14
- * are classified on the **main thread** ({@link wrapDecryptError}), so the worker
15
- * only needs to faithfully hand the error across the boundary, not understand it.
16
- * `serializeError` is that mechanical, taxonomy-agnostic envelope: it copies the
17
- * scalar signal fields the classifier keys on and flattens the nested cause chain
18
- * into a single `cause` link. {@link deserializeError} rebuilds an `Error` whose
19
- * `.cause` chain mirrors the original, so the existing chain-walking detectors
20
- * work on it unchanged.
21
- */
22
- interface SerializedError {
23
- name: string;
24
- message: string;
25
- /** e.g. JSON-RPC -32005, "RELAYER_FETCH_ERROR", ethers "CALL_EXCEPTION". */
26
- code?: string | number;
27
- /** viem-style HTTP status. */
28
- status?: number;
29
- /** relayer / node-fetch-style HTTP status. */
30
- statusCode?: number;
31
- /** Server-driven retry delay in **seconds** (numeric prop or parsed `Retry-After`). */
32
- retryAfter?: number;
33
- /**
34
- * ethers surfaces an HTTP status only as a string on `info.responseStatus`
35
- * (e.g. `"429 Too Many Requests"`), not as a numeric `status`. It lives on a
36
- * nested `info` object the flattening would otherwise skip, so it is lifted
37
- * onto the envelope and rebuilt onto `error.info.responseStatus`, letting the
38
- * ethers rate-limit detector classify a worker-origin 429 exactly as it would
39
- * the same error on the main thread.
40
- */
41
- responseStatus?: string;
42
- cause?: SerializedError;
43
- }
44
- //#endregion
45
- //#region src/worker/worker.types.d.ts
46
- /**
47
- * Minimal four-level logger the SDK logs through.
48
- *
49
- * Supplied optionally by the consumer via `createConfig({ logger })` and
50
- * threaded SDK-wide; `console`, pino, winston, and OpenTelemetry's `DiagLogger`
51
- * satisfy it directly, so no adapter is needed. Levels: `error` (unexpected
52
- * internal failures only — never failures already surfaced via a rejection),
53
- * `warn` (recoverable/degraded conditions), `info` (reserved for coarse
54
- * lifecycle milestones; not currently emitted), `debug` (verbose diagnostics).
55
- */
56
- interface GenericLogger {
57
- info: (message: string, data?: Record<string, unknown>) => void;
58
- debug: (message: string, data?: Record<string, unknown>) => void;
59
- warn: (message: string, data?: Record<string, unknown>) => void;
60
- error: (message: string, data?: Record<string, unknown>) => void;
61
- }
62
- type WorkerEnv = "web" | "node";
63
- type WorkerRequestType = "INIT" | "UPDATE_CSRF" | "ENCRYPT" | "USER_DECRYPT" | "PUBLIC_DECRYPT" | "GENERATE_KEYPAIR" | "CREATE_EIP712" | "CREATE_DELEGATED_EIP712" | "DELEGATED_USER_DECRYPT" | "REQUEST_ZK_PROOF_VERIFICATION" | "GET_PUBLIC_KEY" | "GET_PUBLIC_PARAMS";
64
- interface BaseRequest {
65
- id: string;
66
- type: WorkerRequestType;
67
- }
68
- interface InitWebPayload {
69
- env: "web";
70
- cdnUrl: string;
71
- chains: FheChain[];
72
- csrfToken: string;
73
- /** Expected SHA-384 hex digest for integrity verification. */
74
- integrity?: string;
75
- /** Number of WASM threads for parallel FHE operations. */
76
- thread?: number;
77
- }
78
- interface InitNodePayload {
79
- env: "node";
80
- chains: FheChain[];
81
- }
82
- type InitPayload = InitWebPayload | InitNodePayload;
83
- interface InitRequest extends BaseRequest {
84
- type: "INIT";
85
- payload: InitPayload;
86
- }
87
- interface UpdateCsrfRequest extends BaseRequest {
88
- type: "UPDATE_CSRF";
89
- payload: {
90
- csrfToken: string;
91
- };
92
- }
93
- interface EncryptRequest extends BaseRequest {
94
- type: "ENCRYPT";
95
- payload: {
96
- chainId: number;
97
- values: EncryptInput[];
98
- contractAddress: Address;
99
- userAddress: Address;
100
- };
101
- }
102
- interface UserDecryptRequest extends BaseRequest {
103
- type: "USER_DECRYPT";
104
- payload: {
105
- chainId: number;
106
- encryptedValues: EncryptedValue[];
107
- contractAddress: Address;
108
- signedContractAddresses: Address[];
109
- privateKey: Hex;
110
- publicKey: Hex;
111
- signature: Hex;
112
- signerAddress: Address;
113
- startTimestamp: number;
114
- durationDays: number;
115
- };
116
- }
117
- interface PublicDecryptRequest extends BaseRequest {
118
- type: "PUBLIC_DECRYPT";
119
- payload: {
120
- chainId: number;
121
- encryptedValues: EncryptedValue[];
122
- };
123
- }
124
- interface GenerateKeypairRequest extends BaseRequest {
125
- type: "GENERATE_KEYPAIR";
126
- payload: {
127
- chainId: number;
128
- };
129
- }
130
- interface CreateEIP712Request extends BaseRequest {
131
- type: "CREATE_EIP712";
132
- payload: {
133
- chainId: number;
134
- publicKey: Hex;
135
- contractAddresses: Address[];
136
- startTimestamp: number;
137
- durationDays: number;
138
- };
139
- }
140
- interface CreateDelegatedEIP712Request extends BaseRequest {
141
- type: "CREATE_DELEGATED_EIP712";
142
- payload: {
143
- chainId: number;
144
- publicKey: Hex;
145
- contractAddresses: Address[];
146
- delegatorAddress: Address;
147
- startTimestamp: number;
148
- durationDays: number;
149
- };
150
- }
151
- interface DelegatedUserDecryptRequest extends BaseRequest {
152
- type: "DELEGATED_USER_DECRYPT";
153
- payload: {
154
- chainId: number;
155
- encryptedValues: EncryptedValue[];
156
- contractAddress: Address;
157
- signedContractAddresses: Address[];
158
- privateKey: Hex;
159
- publicKey: Hex;
160
- signature: Hex;
161
- delegatorAddress: Address;
162
- delegateAddress: Address;
163
- startTimestamp: number;
164
- durationDays: number;
165
- };
166
- }
167
- interface RequestZKProofVerificationRequest extends BaseRequest {
168
- type: "REQUEST_ZK_PROOF_VERIFICATION";
169
- payload: {
170
- chainId: number;
171
- zkProof: ZKProofLike;
172
- };
173
- }
174
- interface GetPublicKeyRequest extends BaseRequest {
175
- type: "GET_PUBLIC_KEY";
176
- payload: {
177
- chainId: number;
178
- };
179
- }
180
- interface GetPublicParamsRequest extends BaseRequest {
181
- type: "GET_PUBLIC_PARAMS";
182
- payload: {
183
- chainId: number;
184
- bits: number;
185
- };
186
- }
187
- type WorkerRequest = InitRequest | UpdateCsrfRequest | EncryptRequest | UserDecryptRequest | PublicDecryptRequest | GenerateKeypairRequest | CreateEIP712Request | CreateDelegatedEIP712Request | DelegatedUserDecryptRequest | RequestZKProofVerificationRequest | GetPublicKeyRequest | GetPublicParamsRequest;
188
- type EncryptPayload = EncryptRequest["payload"];
189
- type UserDecryptPayload = UserDecryptRequest["payload"];
190
- type PublicDecryptPayload = PublicDecryptRequest["payload"];
191
- type DelegatedUserDecryptPayload = DelegatedUserDecryptRequest["payload"];
192
- type CreateEIP712Payload = CreateEIP712Request["payload"];
193
- type CreateDelegatedEIP712Payload = CreateDelegatedEIP712Request["payload"];
194
- interface BaseResponse {
195
- id: string;
196
- type: WorkerRequestType;
197
- }
198
- interface SuccessResponse<T> extends BaseResponse {
199
- success: true;
200
- data: T;
201
- }
202
- /**
203
- * A failed worker response. The error and its cause chain are serialized into a
204
- * structured-clone-safe {@link SerializedError} (structured clone strips
205
- * prototypes/codes/causes across the boundary); the main thread rebuilds it
206
- * ({@link deserializeError}) and classifies it once in `wrapDecryptError`.
207
- */
208
- type ErrorResponse = BaseResponse & {
209
- success: false;
210
- error: string;
211
- serialized?: SerializedError;
212
- };
213
- type WorkerResponse<T> = SuccessResponse<T> | ErrorResponse;
214
- type EncryptResponseData = InputProofBytesType;
215
- interface UserDecryptResponseData {
216
- clearValues: Record<EncryptedValue, ClearValue>;
217
- }
218
- interface PublicDecryptResponseData {
219
- clearValues: Readonly<Record<EncryptedValue, ClearValue>>;
220
- abiEncodedClearValues: Hex;
221
- decryptionProof: Hex;
222
- }
223
- interface GenerateKeypairResponseData {
224
- publicKey: Hex;
225
- privateKey: Hex;
226
- }
227
- type CreateEIP712ResponseData = KmsUserDecryptEIP712Type;
228
- type CreateDelegatedEIP712ResponseData = KmsDelegatedUserDecryptEIP712Type;
229
- interface DelegatedUserDecryptResponseData {
230
- clearValues: Record<EncryptedValue, ClearValue>;
231
- }
232
- type RequestZKProofVerificationResponseData = InputProofBytesType;
233
- interface GetPublicKeyResponseData {
234
- result: {
235
- publicKeyId: string;
236
- publicKey: Uint8Array;
237
- } | null;
238
- }
239
- interface GetPublicParamsResponseData {
240
- result: {
241
- publicParams: Uint8Array;
242
- publicParamsId: string;
243
- } | null;
244
- }
245
- //#endregion
246
- //#region src/types/contract.d.ts
247
- /** ABI type accepted by contract call builders. Supports both typed and untyped ABIs. */
248
- type ContractAbi = Abi | readonly unknown[];
249
- /** Extract read-only function names (`pure` | `view`) from a contract ABI. */
250
- type ReadFunctionName<TAbi extends ContractAbi = ContractAbi> = ContractFunctionName<TAbi, "pure" | "view">;
251
- /** Extract write function names (`nonpayable` | `payable`) from a contract ABI. */
252
- type WriteFunctionName<TAbi extends ContractAbi = ContractAbi> = ContractFunctionName<TAbi, "nonpayable" | "payable">;
253
- /** Infer the argument tuple for a read-only contract function. */
254
- type ReadContractArgs<TAbi extends ContractAbi = ContractAbi, TFunctionName extends ReadFunctionName<TAbi> = ReadFunctionName<TAbi>> = ContractFunctionArgs<TAbi, "pure" | "view", TFunctionName>;
255
- /** Infer the argument tuple for a write contract function. */
256
- type WriteContractArgs<TAbi extends ContractAbi = ContractAbi, TFunctionName extends WriteFunctionName<TAbi> = WriteFunctionName<TAbi>> = ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName>;
257
- /** Infer the return type for a read-only contract function. */
258
- type ReadContractReturnType<TAbi extends ContractAbi = ContractAbi, TFunctionName extends ReadFunctionName<TAbi> = ReadFunctionName<TAbi>, TArgs extends ReadContractArgs<TAbi, TFunctionName> = ReadContractArgs<TAbi, TFunctionName>> = ContractFunctionReturnType<TAbi, "pure" | "view", TFunctionName, TArgs>;
259
- /**
260
- * Typed read-contract configuration.
261
- * Matches the shape returned by read contract builders in `src/contracts/`.
262
- */
263
- interface ReadContractConfig<TAbi extends ContractAbi = ContractAbi, TFunctionName extends ReadFunctionName<TAbi> = ReadFunctionName<TAbi>, TArgs extends ReadContractArgs<TAbi, TFunctionName> = ReadContractArgs<TAbi, TFunctionName>> {
264
- /** Target contract address. */
265
- readonly address: Address;
266
- /** ABI fragment for the function being called. */
267
- readonly abi: TAbi;
268
- /** Solidity function name. */
269
- readonly functionName: TFunctionName;
270
- /** Contract call arguments inferred from the ABI and function name. */
271
- readonly args: TArgs;
272
- }
273
- /**
274
- * Typed write-contract configuration.
275
- * Matches the shape returned by write contract builders in `src/contracts/`.
276
- */
277
- interface WriteContractConfig<TAbi extends ContractAbi = ContractAbi, TFunctionName extends WriteFunctionName<TAbi> = WriteFunctionName<TAbi>, TArgs extends WriteContractArgs<TAbi, TFunctionName> = WriteContractArgs<TAbi, TFunctionName>> {
278
- /** Target contract address. */
279
- readonly address: Address;
280
- /** ABI fragment for the function being called. */
281
- readonly abi: TAbi;
282
- /** Solidity function name. */
283
- readonly functionName: TFunctionName;
284
- /** Contract call arguments inferred from the ABI and function name. */
285
- readonly args: TArgs;
286
- /** Native value to send with the transaction (for payable functions). */
287
- readonly value?: bigint;
288
- /** Gas limit override. */
289
- readonly gas?: bigint;
290
- }
291
- //#endregion
292
- //#region src/types/transaction.d.ts
293
- /** Framework-agnostic log shape compatible with any Ethereum provider. */
294
- interface RawLog {
295
- /** Indexed event topics (topic[0] is the event signature hash). */
296
- readonly topics: readonly Hex[];
297
- /** ABI-encoded non-indexed event data. */
298
- readonly data: Hex;
299
- }
300
- /** Framework-agnostic transaction receipt (only the fields the SDK needs). */
301
- interface TransactionReceipt {
302
- /** Event logs emitted during the transaction. */
303
- readonly logs: readonly RawLog[];
304
- }
305
- /** Result of a write operation: the tx hash and its mined receipt. */
306
- interface TransactionResult {
307
- /** The transaction hash. */
308
- txHash: Hex;
309
- /** The mined transaction receipt. */
310
- receipt: TransactionReceipt;
311
- }
312
- //#endregion
313
- //#region src/types/signer.d.ts
314
- /** Snapshot of the connected wallet account at a point in time. */
315
- interface WalletAccount {
316
- address: Address;
317
- chainId: number;
318
- }
319
- /** A wallet account transition emitted by signer adapters. */
320
- interface WalletAccountChange {
321
- previous?: WalletAccount;
322
- next?: WalletAccount;
323
- }
324
- /** Listener for wallet account transitions. */
325
- type WalletAccountListener = (change: WalletAccountChange) => void;
326
- /**
327
- * Synchronous observable store for wallet account readiness.
328
- *
329
- * Direct subscriptions observe raw signer adapter transitions. For SDK-
330
- * coordinated cleanup and React query invalidation, subscribe through
331
- * `ZamaSDK.onWalletAccountChange` so credential/cache cleanup runs first.
332
- */
333
- interface WalletAccountStore {
334
- /** Synchronous, non-prompting snapshot of the currently connected wallet account. */
335
- getSnapshot(): WalletAccount | undefined;
336
- /**
337
- * Whether the store has received at least one snapshot. Adapters whose
338
- * initial account is only available asynchronously start unready; callers
339
- * can distinguish "still loading" from "wallet not connected".
340
- */
341
- isReady(): boolean;
342
- /**
343
- * Subscribe to wallet account transitions (connect, disconnect, account
344
- * change, chain change). Returns an unsubscribe function.
345
- *
346
- * If a wallet account is already known when `subscribe` is called, the
347
- * listener MUST be invoked synchronously with
348
- * `{ previous: undefined, next: <current> }`. The SDK relies on this to
349
- * warm credentials for already-connected signers; custom stores that skip
350
- * this initial emit will silently break credential pre-warming.
351
- */
352
- subscribe(onWalletAccountChange: WalletAccountListener): () => void;
353
- }
354
- /**
355
- * Framework-agnostic signer interface — wallet authority only.
356
- *
357
- * Public chain reads have moved to {@link GenericProvider}. A signer is only
358
- * required for operations that involve a user-controlled wallet
359
- * (`requireWalletAccount`, `signTypedData`, `writeContract`).
360
- */
361
- interface GenericSigner {
362
- /** Observable wallet account readiness state. */
363
- readonly walletAccount: WalletAccountStore;
364
- /**
365
- * Return the currently connected wallet account or throw
366
- * {@link WalletNotConnectedError}. Must not initiate wallet connection.
367
- */
368
- requireWalletAccount(operation: string): WalletAccount;
369
- /**
370
- * Optional non-prompting account discovery hook for adapters whose initial
371
- * account snapshot is only available asynchronously.
372
- */
373
- refreshWalletAccount?(): Promise<WalletAccount | undefined>;
374
- /** Sign EIP-712 typed data (used for decrypt authorization). */
375
- signTypedData(typedData: EIP712TypedData): Promise<Hex>;
376
- /** Send a write transaction and return the tx hash. */
377
- writeContract<const TAbi extends ContractAbi, TFunctionName extends WriteFunctionName<TAbi>, const TArgs extends WriteContractArgs<TAbi, TFunctionName>>(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex>;
378
- /** Release adapter-owned wallet watchers or provider event listeners. */
379
- dispose?(): void;
380
- }
381
- //#endregion
382
- //#region src/types/provider.d.ts
383
- /**
384
- * Framework-agnostic read-only provider interface.
385
- *
386
- * Represents the minimal set of capabilities needed to perform public chain
387
- * reads: querying state via `eth_call`, checking chain identity, awaiting
388
- * transaction receipts, and fetching block timestamps.
389
- *
390
- * Any caller with only an RPC endpoint (server indexer, SSR, dApp pre-connect)
391
- * can drive the SDK via a {@link GenericProvider} implementation, without
392
- * instantiating a wallet-shaped object. Use {@link ViemProvider},
393
- * {@link EthersProvider}, or {@link WagmiProvider}; or implement the
394
- * interface directly.
395
- */
396
- interface GenericProvider {
397
- /** Return the chain ID of the connected network. */
398
- getChainId(): Promise<number>;
399
- /** Execute a read-only call and return the decoded result. */
400
- readContract<const TAbi extends ContractAbi, TFunctionName extends ReadFunctionName<TAbi>, const TArgs extends ReadContractArgs<TAbi, TFunctionName>>(config: ReadContractConfig<TAbi, TFunctionName, TArgs>): Promise<ReadContractReturnType<TAbi, TFunctionName, TArgs>>;
401
- /** Wait for a transaction to be mined and return its receipt. */
402
- waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt>;
403
- /** Return the latest block timestamp in seconds. */
404
- getBlockTimestamp(): Promise<bigint>;
405
- }
406
- //#endregion
407
- //#region src/types/storage.d.ts
408
- /**
409
- * Pluggable key-value store for persisting FHE credentials.
410
- *
411
- * The SDK stores objects directly (not JSON strings). Implementations must
412
- * preserve value types through round-trips — e.g. `IndexedDBStorage` uses
413
- * structured clone, `MemoryStorage` stores values as-is.
414
- */
415
- interface GenericStorage {
416
- /** Retrieve a value by key. Returns `null` if the key does not exist. */
417
- get<T = unknown>(key: string): Promise<T | null>;
418
- /** Store a value under the given key, overwriting any existing entry. */
419
- set<T = unknown>(key: string, value: T): Promise<void>;
420
- /** Remove the entry for the given key (no-op if absent). */
421
- delete(key: string): Promise<void>;
422
- }
423
- //#endregion
424
- //#region src/types/callbacks.d.ts
425
- /** Progress callbacks for multi-step unshield operations. */
426
- interface UnshieldCallbacks {
427
- /** Fired after the unwrap transaction is submitted. */
428
- onUnwrapSubmitted?: (txHash: Hex) => void;
429
- /** Fired when the finalization step begins (receipt parsed, about to finalize). */
430
- onFinalizing?: () => void;
431
- /** Fired after the finalize transaction is submitted. */
432
- onFinalizeSubmitted?: (txHash: Hex) => void;
433
- }
434
- /** Progress callbacks for multi-step shield operations. */
435
- interface ShieldCallbacks {
436
- /** Fired after the ERC-20 approval transaction is submitted (skipped when `approvalStrategy: "skip"`). */
437
- onApprovalSubmitted?: (txHash: Hex) => void;
438
- /** Fired after the shield (wrap) transaction is submitted. */
439
- onShieldSubmitted?: (txHash: Hex) => void;
440
- }
441
- /** Progress callbacks for multi-step confidential transfer operations. */
442
- interface TransferCallbacks {
443
- /** Fired after FHE encryption of the transfer amount completes. */
444
- onEncryptComplete?: () => void;
445
- /** Fired after the transfer transaction is submitted. */
446
- onTransferSubmitted?: (txHash: Hex) => void;
447
- }
448
- //#endregion
449
- //#region src/types/token.d.ts
450
- /** Options for {@link ConfidentialToken.confidentialTransfer}. */
451
- interface TransferOptions extends TransferCallbacks {
452
- /** Skip confidential balance validation (e.g. for smart wallets). Default: `false`. */
453
- skipBalanceCheck?: boolean;
454
- }
455
- /**
456
- * User-facing approval strategy.
457
- *
458
- * - `"exact"` (default): approve exactly `amount`.
459
- * - `"max"`: approve unlimited.
460
- * - `"skip"`: assume a pre-existing approval; skip the approve step.
461
- */
462
- type ApprovalStrategy = "max" | "exact" | "skip";
463
- /**
464
- * The resolved shielding execution path — what actually ran on-chain.
465
- * Reported on {@link ShieldSubmittedEvent}; on a failure, the path is
466
- * encoded in {@link TransactionErrorEvent.operation} as
467
- * `"shield:transferAndCall"` or `"shield:approveAndWrap"`. Decided
468
- * automatically by ERC-165 introspection on the underlying ERC-20.
469
- *
470
- * - `"transferAndCall"`: single tx via ERC-1363 (no approval).
471
- * - `"approveAndWrap"`: legacy two-tx path (`approve` then `wrap`).
472
- */
473
- type ShieldPath = "transferAndCall" | "approveAndWrap";
474
- /** Options for {@link WrappedToken.shield}. */
475
- interface ShieldOptions extends ShieldCallbacks {
476
- /** See {@link ApprovalStrategy}. Default: `"exact"`. Ignored when the underlying supports ERC-1363 (single-tx path requires no approval). */
477
- approvalStrategy?: ApprovalStrategy;
478
- /** Recipient address for the shielded tokens. Defaults to the connected wallet. */
479
- to?: Address;
480
- }
481
- /** Options for {@link WrappedToken.unshield}. */
482
- interface UnshieldOptions extends UnshieldCallbacks {
483
- /** Skip confidential balance validation (e.g. for smart wallets). Default: `false`. */
484
- skipBalanceCheck?: boolean;
485
- }
486
- //#endregion
487
- //#region src/worker/worker.base-client.d.ts
488
- /**
489
- * Timeout / recovery knobs shared by every worker client (node + web), so the
490
- * base class can read them generically off `config`.
491
- */
492
- interface WorkerClientTimeoutConfig {
493
- /** Per-operation timeout in **seconds**. Defaults to 30. */
494
- operationTimeout?: number;
495
- /** WASM-init timeout in **seconds**. Defaults to 60. */
496
- initTimeout?: number;
497
- /**
498
- * Recycle (terminate + lazily re-init) the worker after an operation timeout,
499
- * so a hung thread can't keep serving requests. Defaults to `true`.
500
- */
501
- recycleWorkerOnTimeout?: boolean;
502
- /** Diagnostic label surfaced on {@link WorkerTimeoutError} (e.g. `node-worker-2`). */
503
- workerLabel?: string;
504
- }
505
- /**
506
- * Abstract base class for worker clients (browser Web Worker and Node.js worker_threads).
507
- * Encapsulates all shared logic: pending request tracking, timeouts, init dedup, domain methods.
508
- * Subclasses implement the abstract hooks for platform-specific worker creation and messaging.
509
- */
510
- declare abstract class BaseWorkerClient<TWorker, TConfig extends WorkerClientTimeoutConfig> {
511
- #private;
512
- protected readonly config: TConfig;
513
- protected readonly logger: GenericLogger;
514
- constructor(config: TConfig, logger: GenericLogger);
515
- /** Create the platform-specific worker instance. */
516
- protected abstract createWorker(): TWorker;
517
- /** Wire message/error/messageerror events on the worker. */
518
- protected abstract wireEvents(worker: TWorker): void;
519
- /** Post a message to the worker. */
520
- protected abstract postMessage(worker: TWorker, request: WorkerRequest): void;
521
- /** Terminate the platform-specific worker. */
522
- protected abstract terminateWorker(worker: TWorker): void;
523
- /** Generate a unique request ID. */
524
- protected abstract generateRequestId(): string;
525
- /** Return the init request type and payload. */
526
- protected abstract getInitPayload(): {
527
- type: WorkerRequestType;
528
- payload: WorkerRequest["payload"];
529
- };
530
- /** Subclasses set "web" or "node" — stamps the env discriminant on INIT payloads. */
531
- protected abstract readonly env: WorkerEnv;
532
- /** Optional hook called after worker init succeeds (e.g. for node worker.unref()). */
533
- protected onWorkerReady?(_worker: TWorker): void;
534
- initWorker(): Promise<TWorker>;
535
- terminate(): void;
536
- protected handleResponse(response: WorkerResponse<unknown>): void;
537
- protected handleWorkerError(message: string): void;
538
- protected handleWorkerMessageError(): void;
539
- protected sendRequestTo<T>(worker: TWorker, type: WorkerRequestType, payload: WorkerRequest["payload"], timeoutMs?: number): Promise<T>;
540
- protected sendRequest<T>(type: WorkerRequestType, payload: WorkerRequest["payload"], timeoutMs?: number): Promise<T>;
541
- generateKeypair(params: GenerateKeypairRequest["payload"]): Promise<GenerateKeypairResponseData>;
542
- createEIP712(params: CreateEIP712Payload): Promise<CreateEIP712ResponseData>;
543
- encrypt(params: EncryptPayload): Promise<EncryptResponseData>;
544
- userDecrypt(params: UserDecryptPayload): Promise<UserDecryptResponseData>;
545
- publicDecrypt(params: PublicDecryptPayload): Promise<PublicDecryptResponseData>;
546
- createDelegatedUserDecryptEIP712(params: CreateDelegatedEIP712Payload): Promise<CreateDelegatedEIP712ResponseData>;
547
- delegatedUserDecrypt(params: DelegatedUserDecryptPayload): Promise<DelegatedUserDecryptResponseData>;
548
- requestZKProofVerification(params: RequestZKProofVerificationRequest["payload"]): Promise<RequestZKProofVerificationResponseData>;
549
- getPublicKey(params: GetPublicKeyRequest["payload"]): Promise<GetPublicKeyResponseData>;
550
- getPublicParams(params: GetPublicParamsRequest["payload"]): Promise<GetPublicParamsResponseData>;
551
- }
552
- //#endregion
553
- //#region src/worker/worker.client.d.ts
554
- /** Configuration for the worker client */
555
- interface WorkerClientConfig extends WorkerClientTimeoutConfig {
556
- cdnUrl: string;
557
- chains: FheChain[];
558
- csrfToken: string;
559
- /** Expected SHA-384 hex digest of the CDN bundle for integrity verification. */
560
- integrity?: string;
561
- /** SDK-wide logger for tracing worker request lifecycle. */
562
- logger: GenericLogger;
563
- /** Number of WASM threads for parallel FHE operations (passed to `initSDK({ thread })`). */
564
- thread?: number;
565
- }
566
- /**
567
- * Client for communicating with the RelayerSDK Web Worker.
568
- * Provides a promise-based API for FHE operations.
569
- */
570
- declare class RelayerWorkerClient extends BaseWorkerClient<Worker, WorkerClientConfig> {
571
- protected readonly env: WorkerEnv;
572
- constructor(config: WorkerClientConfig);
573
- protected createWorker(): Worker;
574
- protected wireEvents(worker: Worker): void;
575
- protected postMessage(worker: Worker, request: WorkerRequest): void;
576
- protected terminateWorker(worker: Worker): void;
577
- protected generateRequestId(): string;
578
- protected getInitPayload(): {
579
- type: WorkerRequestType;
580
- payload: WorkerRequest["payload"];
581
- };
582
- /**
583
- * Update the CSRF token in the worker.
584
- * Call this before making authenticated requests to ensure the token is fresh.
585
- */
586
- updateCsrf(csrfToken: string): Promise<void>;
587
- }
588
- //#endregion
589
- //#region src/relayer/relayer-sdk.types.d.ts
590
- /** Network configuration for the Relayer SDK */
591
- type NetworkType = "hardhat" | "sepolia" | "mainnet";
592
- /** Security options for RelayerWeb. */
593
- interface RelayerWebSecurityConfig {
594
- /** Resolve the current CSRF token. Called before each authenticated network request. */
595
- getCsrfToken?: () => string;
596
- /** Verify SHA-384 integrity of the CDN bundle. Defaults to `true`. Set to `false` only in test environments with mocked SDK scripts. */
597
- integrityCheck?: boolean;
598
- }
599
- /** Configuration for RelayerWeb (browser backend) initialization. */
600
- interface RelayerWebConfig {
601
- /** FHE chain configuration. */
602
- chain: FheChain;
603
- /** Worker client — handles WASM operations off the main thread. */
604
- worker: RelayerWorkerClient;
605
- /** Security options (CSRF, CDN integrity). */
606
- security?: RelayerWebSecurityConfig;
607
- /** SDK-wide logger for observing worker lifecycle and request timing. */
608
- logger: GenericLogger;
609
- /**
610
- * Number of WASM threads for parallel FHE operations inside the Web Worker.
611
- * Uses `wasm-bindgen-rayon` under the hood via `SharedArrayBuffer`.
612
- *
613
- * **Requirements:** The page must be served with COOP/COEP headers:
614
- * - `Cross-Origin-Opener-Policy: same-origin`
615
- * - `Cross-Origin-Embedder-Policy: require-corp`
616
- *
617
- * 4–8 threads is the practical sweet spot; beyond that, diminishing returns
618
- * and higher memory usage on low-end devices.
619
- *
620
- * When omitted, the relayer SDK uses its default (single-threaded).
621
- */
622
- threads?: number;
623
- /**
624
- * Persistent storage for caching FHE public key and params across sessions.
625
- *
626
- * Defaults to `new IndexedDBStorage("FheArtifactCache", 1, "artifacts")`.
627
- * Pass a custom `IndexedDBStorage` instance to configure the database name,
628
- * version, or store name. FHE public params can be several MB — avoid
629
- * `localStorage`-backed storage which caps at ~5 MB.
630
- *
631
- * **Not to be confused with `ZamaProvider.storage`** which stores credentials.
632
- */
633
- fheArtifactStorage?: GenericStorage;
634
- /** Cache TTL in seconds for FHE public material. Default: 86 400 (24 h). Set to 0 to revalidate on every operation. Ignored when storage is not set. */
635
- fheArtifactCacheTTL?: number;
636
- }
637
- /** Canonical SDK type for an encrypted value — a `bytes32` ciphertext reference. Alias for {@link Bytes32Hex}. */
638
- type EncryptedValue = Bytes32Hex;
639
- /** Result from encryption — contract-ready hex encrypted values and input proof. */
640
- type EncryptResult = {
641
- encryptedValues: EncryptedValue[];
642
- inputProof: Hex;
643
- };
644
- /** Canonical SDK type for a decrypted clear-text value (`bigint | boolean | string`). */
645
- type ClearValue = ClearValueType;
646
- /** A single value to encrypt with its FHE type. */
647
- type EncryptInput = {
648
- value: boolean | bigint;
649
- type: "ebool";
650
- } | {
651
- value: bigint;
652
- type: Exclude<SDK.FheTypeName, "ebool" | "eaddress">;
653
- } | {
654
- value: Address;
655
- type: "eaddress";
656
- };
657
- /** Parameters for encryption */
658
- interface EncryptParams {
659
- /** Typed inputs for encryption. Each value must specify its FHE type. */
660
- values: EncryptInput[];
661
- contractAddress: Address;
662
- userAddress: Address;
663
- }
664
- /** Parameters for user decryption */
665
- interface UserDecryptParams {
666
- encryptedValues: EncryptedValue[];
667
- contractAddress: Address;
668
- signedContractAddresses: Address[];
669
- privateKey: Hex;
670
- publicKey: Hex;
671
- signature: Hex;
672
- signerAddress: Address;
673
- startTimestamp: number;
674
- durationDays: number;
675
- }
676
- /** Result from public decryption. Alias for {@link PublicDecryptResults}. */
677
- type PublicDecryptResult = PublicDecryptResults;
678
- /**
679
- * EIP712 typed data structure for user or delegated user decrypt requests.
680
- * Union of the relayer-sdk's two user-decrypt EIP712 shapes.
681
- */
682
- type EIP712TypedData = KmsUserDecryptEIP712Type | KmsDelegatedUserDecryptEIP712Type;
683
- /** FHE encryption key — the network's TFHE public key used to encrypt inputs for confidential contracts. */
684
- interface FheEncryptionKey {
685
- publicKeyId: string;
686
- publicKey: Uint8Array;
687
- }
688
- /**
689
- * TFHE public parameters
690
- */
691
- type PublicParamsData = SDK.PublicParams<Uint8Array>[keyof SDK.PublicParams<Uint8Array>];
692
- /** Parameters for delegated user decryption */
693
- interface DelegatedUserDecryptParams {
694
- encryptedValues: EncryptedValue[];
695
- contractAddress: Address;
696
- signedContractAddresses: Address[];
697
- privateKey: Hex;
698
- publicKey: Hex;
699
- signature: Hex;
700
- delegatorAddress: Address;
701
- delegateAddress: Address;
702
- startTimestamp: number;
703
- durationDays: number;
704
- }
705
- /** SDK status */
706
- type RelayerSDKStatus = "idle" | "initializing" | "ready" | "error";
707
- //#endregion
708
- //#region src/schemas/primitives.d.ts
709
- declare const checksummedTag: unique symbol;
710
- /** An EVM address that has been put through `getAddress` (EIP-55 checksum form). */
711
- type ChecksummedAddress = Address & {
712
- readonly [checksummedTag]: true;
713
- };
714
- //#endregion
715
- //#region src/credentials/schemas.d.ts
716
- declare const StoredTransportKeyPairSchema: z.ZodMiniObject<{
717
- publicKey: z.ZodMiniCustom<`0x${string}`, `0x${string}`>;
718
- privateKey: z.ZodMiniCustom<`0x${string}`, `0x${string}`>;
719
- createdAt: z.ZodMiniNumberFormat;
720
- expiresAt: z.ZodMiniNumberFormat;
721
- }, z.core.$strip>;
722
- declare const PermissionSchema: z.ZodMiniObject<{
723
- keypairPublicKey: z.ZodMiniCustom<`0x${string}`, `0x${string}`>;
724
- signerAddress: z.ZodMiniPipe<z.ZodMiniCustom<`0x${string}`, `0x${string}`>, z.ZodMiniTransform<ChecksummedAddress, `0x${string}`>>;
725
- delegatorAddress: z.ZodMiniPipe<z.ZodMiniCustom<`0x${string}`, `0x${string}`>, z.ZodMiniTransform<ChecksummedAddress, `0x${string}`>>;
726
- chainId: z.ZodMiniNumberFormat;
727
- signedContractAddresses: z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniCustom<`0x${string}`, `0x${string}`>, z.ZodMiniTransform<ChecksummedAddress, `0x${string}`>>>;
728
- signature: z.ZodMiniCustom<`0x${string}`, `0x${string}`>;
729
- startTimestamp: z.ZodMiniNumberFormat;
730
- durationDays: z.ZodMiniNumberFormat;
731
- }, z.core.$strip>;
732
- //#endregion
733
- //#region src/credentials/types.d.ts
734
- /** In-memory transport key pair (ML-KEM public + private key, plaintext private half). */
735
- interface TransportKeyPair {
736
- publicKey: Hex;
737
- privateKey: Hex;
738
- }
739
- /** Persisted transport key pair entry with a bounded lifetime. */
740
- type StoredTransportKeyPair = z.infer<typeof StoredTransportKeyPairSchema>;
741
- /**
742
- * A signed EIP-712 permit binding a signer (and optional delegator) to a set of
743
- * contract addresses for a bounded time window.
744
- */
745
- type Permission = z.infer<typeof PermissionSchema>;
746
- /** Resolved transport key pair entry with permits for a decrypt operation. */
747
- interface StoredTransportKeyPairWithPermits {
748
- readonly keypair: StoredTransportKeyPair;
749
- readonly permits: readonly Permission[];
750
- }
751
- //#endregion
752
- //#region src/relayer/relayer-sdk.d.ts
753
- /**
754
- * Core FHE cryptographic operations — the 10 methods that perform
755
- * encryption, decryption, key generation, and proof verification.
756
- */
757
- interface FheOperations {
758
- /** Generate a transport key pair (ML-KEM public + private key) used for user-decryption. */
759
- generateTransportKeyPair(): Promise<TransportKeyPair>;
760
- /**
761
- * Create EIP-712 typed data for signing an FHE decrypt credential.
762
- *
763
- * Low-level credential builder. Prefer the high-level
764
- * `sdk.decryption.decryptValues` ({@link Decryption.decryptValues}), which
765
- * assembles and caches this credential for you.
766
- */
767
- createEIP712(publicKey: Hex, contractAddresses: Address[], startTimestamp: number, durationDays?: number): Promise<EIP712TypedData>;
768
- /** Encrypt plaintext values into FHE ciphertexts. */
769
- encrypt(params: EncryptParams): Promise<EncryptResult>;
770
- /**
771
- * Decrypt FHE encrypted values using the user's own credentials.
772
- *
773
- * Low-level: the caller assembles the credential bundle (transport key pair,
774
- * EIP-712 permit) in {@link UserDecryptParams}. Prefer the high-level
775
- * `sdk.decryption.decryptValues` ({@link Decryption.decryptValues}), which
776
- * manages credentials, caching, and error wrapping.
777
- */
778
- userDecrypt(params: UserDecryptParams): Promise<Readonly<Record<EncryptedValue, ClearValue>>>;
779
- /**
780
- * Decrypt encrypted values using the network public key (no credential needed).
781
- *
782
- * Low-level. Prefer the high-level `sdk.decryption.decryptPublicValues`
783
- * ({@link Decryption.decryptPublicValues}).
784
- */
785
- publicDecrypt(encryptedValues: EncryptedValue[]): Promise<PublicDecryptResult>;
786
- /**
787
- * Create EIP-712 typed data for a delegated user decrypt credential.
788
- *
789
- * Low-level credential builder. Prefer the high-level
790
- * `sdk.decryption.delegatedDecryptValues` ({@link Decryption.delegatedDecryptValues}),
791
- * which assembles and caches this credential for you.
792
- */
793
- createDelegatedUserDecryptEIP712(publicKey: Hex, contractAddresses: Address[], delegatorAddress: Address, startTimestamp: number, durationDays?: number): Promise<KmsDelegatedUserDecryptEIP712Type>;
794
- /**
795
- * Decrypt FHE encrypted values using delegated user credentials.
796
- *
797
- * Low-level: the caller assembles the delegated credential bundle in
798
- * {@link DelegatedUserDecryptParams}. Prefer the high-level
799
- * `sdk.decryption.delegatedDecryptValues` ({@link Decryption.delegatedDecryptValues}).
800
- */
801
- delegatedUserDecrypt(params: DelegatedUserDecryptParams): Promise<Readonly<Record<EncryptedValue, ClearValue>>>;
802
- /** Submit a ZK proof for on-chain verification. */
803
- requestZKProofVerification(zkProof: ZKProofLike): Promise<InputProofBytesType>;
804
- /** Fetch the network's FHE encryption key. Returns `null` if not available. */
805
- fetchFheEncryptionKeyBytes(): Promise<FheEncryptionKey | null>;
806
- /** Fetch FHE public parameters for a given bit size. Returns `null` if not available. */
807
- getPublicParams(bits: number): Promise<PublicParamsData | null>;
808
- }
809
- /**
810
- * Interface for FHE relayer operations.
811
- * Extends `FheOperations` with lifecycle and chain-specific methods.
812
- * Implemented by `RelayerWeb` (browser, via Web Worker + WASM) and `RelayerNode` (Node.js, direct).
813
- */
814
- interface RelayerSDK extends FheOperations {
815
- /** Return the ACL contract address for the current chain. */
816
- getAclAddress(): Promise<Address>;
817
- /** Terminate the relayer backend and release resources. */
818
- terminate(): void;
819
- }
820
- //#endregion
821
- //#region src/relayer/cleartext/relayer-cleartext.d.ts
822
- declare class RelayerCleartext implements RelayerSDK, Disposable {
823
- #private;
824
- readonly kmsSigner: PrivateKeyAccount;
825
- readonly inputSigner: PrivateKeyAccount;
826
- constructor(config: FheChain);
827
- generateTransportKeyPair(): Promise<TransportKeyPair>;
828
- createEIP712(publicKey: Hex, contractAddresses: Address[], startTimestamp: number, durationDays?: number): Promise<EIP712TypedData>;
829
- encrypt(params: EncryptParams): Promise<EncryptResult>;
830
- userDecrypt(params: UserDecryptParams): Promise<Readonly<Record<EncryptedValue, ClearValue>>>;
831
- publicDecrypt(encryptedValues: EncryptedValue[]): Promise<PublicDecryptResult>;
832
- createDelegatedUserDecryptEIP712(publicKey: Hex, contractAddresses: Address[], delegatorAddress: Address, startTimestamp: number, durationDays?: number): Promise<KmsDelegatedUserDecryptEIP712Type>;
833
- delegatedUserDecrypt(params: DelegatedUserDecryptParams): Promise<Readonly<Record<EncryptedValue, ClearValue>>>;
834
- requestZKProofVerification(_zkProof: ZKProofLike): Promise<InputProofBytesType>;
835
- fetchFheEncryptionKeyBytes(): Promise<FheEncryptionKey | null>;
836
- getPublicParams(_bits: number): Promise<PublicParamsData | null>;
837
- getAclAddress(): Promise<Address>;
838
- terminate(): void;
839
- /** Calls {@link terminate} (no-op in cleartext mode). */
840
- [Symbol.dispose](): void;
841
- }
842
- //#endregion
843
- export { CreateDelegatedEIP712Request as $, ShieldCallbacks as A, WorkerEnv as At, RawLog as B, BaseWorkerClient as C, RequestZKProofVerificationRequest as Ct, ShieldPath as D, UserDecryptPayload as Dt, ShieldOptions as E, UpdateCsrfRequest as Et, GenericSigner as F, ReadContractConfig as G, TransactionResult as H, WalletAccount as I, WriteContractArgs as J, ReadContractReturnType as K, WalletAccountChange as L, UnshieldCallbacks as M, WorkerRequestType as Mt, GenericStorage as N, WorkerResponse as Nt, TransferOptions as O, UserDecryptRequest as Ot, GenericProvider as P, SerializedError as Pt, CreateDelegatedEIP712Payload as Q, WalletAccountListener as R, RelayerWorkerClient as S, PublicDecryptResponseData as St, ApprovalStrategy as T, SuccessResponse as Tt, ContractAbi as U, TransactionReceipt as V, ReadContractArgs as W, WriteFunctionName as X, WriteContractConfig as Y, BaseRequest as Z, PublicParamsData as _, GetPublicParamsResponseData as _t, StoredTransportKeyPairWithPermits as a, DelegatedUserDecryptRequest as at, RelayerWebSecurityConfig as b, PublicDecryptPayload as bt, DelegatedUserDecryptParams as c, EncryptRequest as ct, EncryptParams as d, GenerateKeypairRequest as dt, CreateDelegatedEIP712ResponseData as et, EncryptResult as f, GenerateKeypairResponseData as ft, PublicDecryptResult as g, GetPublicParamsRequest as gt, NetworkType as h, GetPublicKeyResponseData as ht, StoredTransportKeyPair as i, DelegatedUserDecryptPayload as it, TransferCallbacks as j, WorkerRequest as jt, UnshieldOptions as k, UserDecryptResponseData as kt, EIP712TypedData as l, EncryptResponseData as lt, FheEncryptionKey as m, GetPublicKeyRequest as mt, RelayerSDK as n, CreateEIP712Request as nt, TransportKeyPair as o, DelegatedUserDecryptResponseData as ot, EncryptedValue as p, GenericLogger as pt, ReadFunctionName as q, Permission as r, CreateEIP712ResponseData as rt, ClearValue as s, EncryptPayload as st, RelayerCleartext as t, CreateEIP712Payload as tt, EncryptInput as u, ErrorResponse as ut, RelayerSDKStatus as v, InitPayload as vt, WorkerClientTimeoutConfig as w, RequestZKProofVerificationResponseData as wt, UserDecryptParams as x, PublicDecryptRequest as xt, RelayerWebConfig as y, InitRequest as yt, WalletAccountStore as z };
844
- //# sourceMappingURL=relayer-cleartext-CSeMlmGO.d.ts.map