@miden-sdk/miden-sdk 0.15.0-alpha.4 → 0.15.0-alpha.5

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 (59) hide show
  1. package/README.md +139 -9
  2. package/dist/mt/Cargo-smJQCGjz.js +26146 -0
  3. package/dist/mt/Cargo-smJQCGjz.js.map +1 -0
  4. package/dist/{api-types.d.ts → mt/api-types.d.ts} +154 -4
  5. package/dist/mt/assets/miden_client_web.wasm +0 -0
  6. package/dist/mt/crates/miden_client_web.d.ts +4791 -0
  7. package/dist/mt/eager.js +38 -0
  8. package/dist/mt/eager.js.map +1 -0
  9. package/dist/{index.d.ts → mt/index.d.ts} +4 -2
  10. package/dist/mt/index.js +3778 -0
  11. package/dist/mt/index.js.map +1 -0
  12. package/dist/{wasm.js → mt/wasm.js} +1 -1
  13. package/dist/mt/wasm.js.map +1 -0
  14. package/dist/mt/workerHelpers.js +28 -0
  15. package/dist/mt/workers/Cargo-smJQCGjz-q4GYXDiD.js +26147 -0
  16. package/dist/mt/workers/Cargo-smJQCGjz-q4GYXDiD.js.map +1 -0
  17. package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
  18. package/dist/mt/workers/web-client-methods-worker.js +26885 -0
  19. package/dist/mt/workers/web-client-methods-worker.js.map +1 -0
  20. package/dist/{workers → mt/workers}/web-client-methods-worker.module.js +17 -1
  21. package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -0
  22. package/dist/mt/workers/workerHelpers.js +28 -0
  23. package/dist/{Cargo-CVlXCH_2.js → st/Cargo-CG4XszZo.js} +698 -495
  24. package/dist/st/Cargo-CG4XszZo.js.map +1 -0
  25. package/dist/st/api-types.d.ts +1140 -0
  26. package/dist/{workers → st}/assets/miden_client_web.wasm +0 -0
  27. package/dist/{crates → st/crates}/miden_client_web.d.ts +342 -196
  28. package/dist/st/docs-entry.d.ts +38 -0
  29. package/dist/{eager.js → st/eager.js} +1 -1
  30. package/dist/st/eager.js.map +1 -0
  31. package/dist/st/index.d.ts +182 -0
  32. package/dist/{index.js → st/index.js} +425 -19
  33. package/dist/st/index.js.map +1 -0
  34. package/dist/st/wasm.js +23 -0
  35. package/dist/st/wasm.js.map +1 -0
  36. package/dist/{workers/Cargo-CVlXCH_2-CWA-5vlh.js → st/workers/Cargo-CG4XszZo-S7EHAZSa.js} +698 -495
  37. package/dist/st/workers/Cargo-CG4XszZo-S7EHAZSa.js.map +1 -0
  38. package/dist/{assets → st/workers/assets}/miden_client_web.wasm +0 -0
  39. package/dist/{workers → st/workers}/web-client-methods-worker.js +715 -496
  40. package/dist/st/workers/web-client-methods-worker.js.map +1 -0
  41. package/dist/st/workers/web-client-methods-worker.module.js +575 -0
  42. package/dist/st/workers/web-client-methods-worker.module.js.map +1 -0
  43. package/js/client.js +166 -2
  44. package/js/node/napi-compat.js +15 -0
  45. package/js/node-index.js +0 -1
  46. package/js/resources/accounts.js +4 -6
  47. package/js/resources/transactions.js +134 -0
  48. package/lazy/package.json +2 -2
  49. package/mt/lazy/package.json +4 -0
  50. package/mt/package.json +4 -0
  51. package/package.json +30 -15
  52. package/dist/Cargo-CVlXCH_2.js.map +0 -1
  53. package/dist/eager.js.map +0 -1
  54. package/dist/index.js.map +0 -1
  55. package/dist/wasm.js.map +0 -1
  56. package/dist/workers/Cargo-CVlXCH_2-CWA-5vlh.js.map +0 -1
  57. package/dist/workers/web-client-methods-worker.js.map +0 -1
  58. package/dist/workers/web-client-methods-worker.module.js.map +0 -1
  59. /package/dist/{docs-entry.d.ts → mt/docs-entry.d.ts} +0 -0
@@ -0,0 +1,575 @@
1
+ // This is a documented workaround that should avoid issues with Vite projects
2
+ // https://github.com/wasm-tool/rollup-plugin-rust?tab=readme-ov-file#usage-with-vite
3
+ // Also, this effectively disables SSR.
4
+ async function loadWasm() {
5
+ let wasmModule;
6
+ if (!import.meta.env || (import.meta.env && !import.meta.env.SSR)) {
7
+ wasmModule = await import('./Cargo-CG4XszZo-S7EHAZSa.js');
8
+ // The Cargo glue's __wbg_init TLA is stripped by the rollup build to
9
+ // prevent blocking WKWebView module evaluation. Call it explicitly here
10
+ // with the WASM URL that the Cargo glue pre-resolves (relative to its
11
+ // own import.meta.url, which downstream bundlers handle correctly).
12
+ if (wasmModule && typeof wasmModule.__wbg_init === "function") {
13
+ await wasmModule.__wbg_init({
14
+ // eslint-disable-next-line camelcase -- wasm-bindgen init API parameter name
15
+ module_or_path: wasmModule.__wasm_url,
16
+ });
17
+ }
18
+ }
19
+ return wasmModule;
20
+ }
21
+
22
+ const WorkerAction = Object.freeze({
23
+ INIT: "init",
24
+ INIT_MOCK: "initMock",
25
+ INIT_THREAD_POOL: "initThreadPool",
26
+ CALL_METHOD: "callMethod",
27
+ EXECUTE_CALLBACK: "executeCallback",
28
+ });
29
+
30
+ const CallbackType = Object.freeze({
31
+ GET_KEY: "getKey",
32
+ INSERT_KEY: "insertKey",
33
+ SIGN: "sign",
34
+ });
35
+
36
+ const MethodName = Object.freeze({
37
+ CREATE_CLIENT: "createClient",
38
+ APPLY_TRANSACTION: "applyTransaction",
39
+ EXECUTE_TRANSACTION: "executeTransaction",
40
+ PROVE_TRANSACTION: "proveTransaction",
41
+ SUBMIT_NEW_TRANSACTION: "submitNewTransaction",
42
+ SUBMIT_NEW_TRANSACTION_MOCK: "submitNewTransactionMock",
43
+ SUBMIT_NEW_TRANSACTION_WITH_PROVER: "submitNewTransactionWithProver",
44
+ SUBMIT_NEW_TRANSACTION_WITH_PROVER_MOCK: "submitNewTransactionWithProverMock",
45
+ SYNC_STATE: "syncState",
46
+ SYNC_STATE_MOCK: "syncStateMock",
47
+ });
48
+
49
+ let wasmModule = null;
50
+
51
+ const getWasmOrThrow = async () => {
52
+ if (!wasmModule) {
53
+ wasmModule = await loadWasm();
54
+ }
55
+ if (!wasmModule) {
56
+ throw new Error(
57
+ "Miden WASM bindings are unavailable in the worker environment."
58
+ );
59
+ }
60
+ return wasmModule;
61
+ };
62
+
63
+ const serializeUnknown = (value) => {
64
+ if (typeof value === "string") {
65
+ return value;
66
+ }
67
+ try {
68
+ return JSON.stringify(value);
69
+ } catch {
70
+ return String(value);
71
+ }
72
+ };
73
+
74
+ const serializeError = (error) => {
75
+ if (error instanceof Error) {
76
+ return {
77
+ name: error.name,
78
+ message: error.message,
79
+ stack: error.stack,
80
+ cause: error.cause ? serializeError(error.cause) : undefined,
81
+ code: error.code,
82
+ };
83
+ }
84
+
85
+ if (typeof error === "object" && error !== null) {
86
+ return {
87
+ name: error.name ?? "Error",
88
+ message: error.message ?? serializeUnknown(error),
89
+ };
90
+ }
91
+
92
+ return {
93
+ name: "Error",
94
+ message: serializeUnknown(error),
95
+ };
96
+ };
97
+
98
+ /**
99
+ * Worker for executing WebClient methods in a separate thread.
100
+ *
101
+ * This worker offloads computationally heavy tasks from the main thread by handling
102
+ * WebClient operations asynchronously. It imports the WASM module and instantiates a
103
+ * WASM WebClient, then listens for messages from the main thread to perform one of two actions:
104
+ *
105
+ * 1. **Initialization (init):**
106
+ * - The worker receives an "init" message along with user parameters (RPC URL and seed).
107
+ * - It instantiates the WASM WebClient and calls its createClient method.
108
+ * - Once initialization is complete, the worker sends a `{ ready: true }` message back to signal
109
+ * that it is fully initialized.
110
+ *
111
+ * 2. **Method Invocation (callMethod):**
112
+ * - The worker receives a "callMethod" message with a specific method name and arguments.
113
+ * - It uses a mapping (defined in `methodHandlers`) to route the call to the corresponding WASM WebClient method.
114
+ * - Complex data is serialized before being sent and deserialized upon return.
115
+ * - The result (or any error) is then posted back to the main thread.
116
+ *
117
+ * The worker uses a message queue to process incoming messages sequentially, ensuring that only one message
118
+ * is handled at a time.
119
+ *
120
+ * Additionally, the worker immediately sends a `{ loaded: true }` message upon script load. This informs the main
121
+ * thread that the worker script is loaded and ready to receive the "init" message.
122
+ *
123
+ * Supported actions (defined in `WorkerAction`):
124
+ * - "init" : Initialize the WASM WebClient with provided parameters.
125
+ * - "callMethod" : Invoke a designated method on the WASM WebClient.
126
+ *
127
+ * Supported method names are defined in the `MethodName` constant.
128
+ */
129
+
130
+ // Global state variables.
131
+ let wasmWebClient = null;
132
+ let wasmSeed = null; // Seed for the WASM WebClient, if needed.
133
+ let ready = false; // Indicates if the worker is fully initialized.
134
+ let messageQueue = []; // Queue for sequential processing.
135
+ let processing = false; // Flag to ensure one message is processed at a time.
136
+
137
+ // Track pending callback requests
138
+ let pendingCallbacks = new Map();
139
+
140
+ // Timeout for pending callbacks (30 seconds)
141
+ const CALLBACK_TIMEOUT_MS = 30000;
142
+
143
+ // Define proxy functions for callbacks that communicate with main thread
144
+ const callbackProxies = {
145
+ getKey: async (pubKey) => {
146
+ return new Promise((resolve, reject) => {
147
+ const requestId = `${CallbackType.GET_KEY}-${Date.now()}-${Math.random()}`;
148
+ const timeoutId = setTimeout(() => {
149
+ if (pendingCallbacks.has(requestId)) {
150
+ pendingCallbacks.delete(requestId);
151
+ reject(new Error(`Callback ${requestId} timed out`));
152
+ }
153
+ }, CALLBACK_TIMEOUT_MS);
154
+ pendingCallbacks.set(requestId, { resolve, reject, timeoutId });
155
+
156
+ self.postMessage({
157
+ action: WorkerAction.EXECUTE_CALLBACK,
158
+ callbackType: CallbackType.GET_KEY,
159
+ args: [pubKey],
160
+ requestId,
161
+ });
162
+ });
163
+ },
164
+ insertKey: async (pubKey, secretKey) => {
165
+ return new Promise((resolve, reject) => {
166
+ const requestId = `${CallbackType.INSERT_KEY}-${Date.now()}-${Math.random()}`;
167
+ const timeoutId = setTimeout(() => {
168
+ if (pendingCallbacks.has(requestId)) {
169
+ pendingCallbacks.delete(requestId);
170
+ reject(new Error(`Callback ${requestId} timed out`));
171
+ }
172
+ }, CALLBACK_TIMEOUT_MS);
173
+ pendingCallbacks.set(requestId, { resolve, reject, timeoutId });
174
+
175
+ self.postMessage({
176
+ action: WorkerAction.EXECUTE_CALLBACK,
177
+ callbackType: CallbackType.INSERT_KEY,
178
+ args: [pubKey, secretKey],
179
+ requestId,
180
+ });
181
+ });
182
+ },
183
+ sign: async (pubKey, signingInputs) => {
184
+ return new Promise((resolve, reject) => {
185
+ const requestId = `${CallbackType.SIGN}-${Date.now()}-${Math.random()}`;
186
+ const timeoutId = setTimeout(() => {
187
+ if (pendingCallbacks.has(requestId)) {
188
+ pendingCallbacks.delete(requestId);
189
+ reject(new Error(`Callback ${requestId} timed out`));
190
+ }
191
+ }, CALLBACK_TIMEOUT_MS);
192
+ pendingCallbacks.set(requestId, { resolve, reject, timeoutId });
193
+
194
+ self.postMessage({
195
+ action: WorkerAction.EXECUTE_CALLBACK,
196
+ callbackType: CallbackType.SIGN,
197
+ args: [pubKey, signingInputs],
198
+ requestId,
199
+ });
200
+ });
201
+ },
202
+ };
203
+
204
+ // Define a mapping from method names to handler functions.
205
+ const methodHandlers = {
206
+ [MethodName.SYNC_STATE]: async () => {
207
+ // Call the internal WASM method (sync lock is handled at the JS wrapper level)
208
+ const syncSummary = await wasmWebClient.syncStateImpl();
209
+ const serializedSyncSummary = syncSummary.serialize();
210
+ return serializedSyncSummary.buffer;
211
+ },
212
+ [MethodName.APPLY_TRANSACTION]: async (args) => {
213
+ const wasm = await getWasmOrThrow();
214
+ const [serializedTransactionResult, submissionHeight] = args;
215
+ const transactionResultBytes = new Uint8Array(serializedTransactionResult);
216
+ const transactionResult = wasm.TransactionResult.deserialize(
217
+ transactionResultBytes
218
+ );
219
+ const transactionUpdate = await wasmWebClient.applyTransaction(
220
+ transactionResult,
221
+ submissionHeight
222
+ );
223
+ const serializedUpdate = transactionUpdate.serialize();
224
+ return serializedUpdate.buffer;
225
+ },
226
+ [MethodName.EXECUTE_TRANSACTION]: async (args) => {
227
+ const wasm = await getWasmOrThrow();
228
+ const [accountIdHex, serializedTransactionRequest] = args;
229
+ const accountId = wasm.AccountId.fromHex(accountIdHex);
230
+ const transactionRequestBytes = new Uint8Array(
231
+ serializedTransactionRequest
232
+ );
233
+ const transactionRequest = wasm.TransactionRequest.deserialize(
234
+ transactionRequestBytes
235
+ );
236
+ const result = await wasmWebClient.executeTransaction(
237
+ accountId,
238
+ transactionRequest
239
+ );
240
+ const serializedResult = result.serialize();
241
+ return serializedResult.buffer;
242
+ },
243
+ [MethodName.PROVE_TRANSACTION]: async (args) => {
244
+ const wasm = await getWasmOrThrow();
245
+ const [serializedTransactionResult, proverPayload] = args;
246
+ const transactionResultBytes = new Uint8Array(serializedTransactionResult);
247
+ const transactionResult = wasm.TransactionResult.deserialize(
248
+ transactionResultBytes
249
+ );
250
+
251
+ const prover = proverPayload
252
+ ? wasm.TransactionProver.deserialize(proverPayload)
253
+ : undefined;
254
+
255
+ const proven = await wasmWebClient.proveTransaction(
256
+ transactionResult,
257
+ prover
258
+ );
259
+ const serializedProven = proven.serialize();
260
+ return serializedProven.buffer;
261
+ },
262
+ [MethodName.SUBMIT_NEW_TRANSACTION]: async (args) => {
263
+ const wasm = await getWasmOrThrow();
264
+ const [accountIdHex, serializedTransactionRequest] = args;
265
+ const accountId = wasm.AccountId.fromHex(accountIdHex);
266
+ const transactionRequestBytes = new Uint8Array(
267
+ serializedTransactionRequest
268
+ );
269
+ const transactionRequest = wasm.TransactionRequest.deserialize(
270
+ transactionRequestBytes
271
+ );
272
+
273
+ const result = await wasmWebClient.executeTransaction(
274
+ accountId,
275
+ transactionRequest
276
+ );
277
+
278
+ const transactionId = result.id().toHex();
279
+
280
+ const proven = await wasmWebClient.proveTransaction(result);
281
+ const submissionHeight = await wasmWebClient.submitProvenTransaction(
282
+ proven,
283
+ result
284
+ );
285
+ const transactionUpdate = await wasmWebClient.applyTransaction(
286
+ result,
287
+ submissionHeight
288
+ );
289
+
290
+ return {
291
+ transactionId,
292
+ submissionHeight,
293
+ serializedTransactionResult: result.serialize().buffer,
294
+ serializedTransactionUpdate: transactionUpdate.serialize().buffer,
295
+ };
296
+ },
297
+ [MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER]: async (args) => {
298
+ const wasm = await getWasmOrThrow();
299
+ const [accountIdHex, serializedTransactionRequest, proverPayload] = args;
300
+ const accountId = wasm.AccountId.fromHex(accountIdHex);
301
+ const transactionRequestBytes = new Uint8Array(
302
+ serializedTransactionRequest
303
+ );
304
+ const transactionRequest = wasm.TransactionRequest.deserialize(
305
+ transactionRequestBytes
306
+ );
307
+
308
+ // Deserialize the prover from the serialized payload
309
+ const prover = proverPayload
310
+ ? wasm.TransactionProver.deserialize(proverPayload)
311
+ : undefined;
312
+
313
+ const result = await wasmWebClient.executeTransaction(
314
+ accountId,
315
+ transactionRequest
316
+ );
317
+
318
+ const transactionId = result.id().toHex();
319
+
320
+ const proven = await wasmWebClient.proveTransaction(result, prover);
321
+ const submissionHeight = await wasmWebClient.submitProvenTransaction(
322
+ proven,
323
+ result
324
+ );
325
+ const transactionUpdate = await wasmWebClient.applyTransaction(
326
+ result,
327
+ submissionHeight
328
+ );
329
+
330
+ return {
331
+ transactionId,
332
+ submissionHeight,
333
+ serializedTransactionResult: result.serialize().buffer,
334
+ serializedTransactionUpdate: transactionUpdate.serialize().buffer,
335
+ };
336
+ },
337
+ };
338
+
339
+ // Add mock methods to the handler mapping.
340
+ methodHandlers[MethodName.SYNC_STATE_MOCK] = async (args) => {
341
+ let [serializedMockChain, serializedMockNoteTransportNode] = args;
342
+ serializedMockChain = new Uint8Array(serializedMockChain);
343
+ serializedMockNoteTransportNode = serializedMockNoteTransportNode
344
+ ? new Uint8Array(serializedMockNoteTransportNode)
345
+ : null;
346
+ await wasmWebClient.createMockClient(
347
+ wasmSeed,
348
+ serializedMockChain,
349
+ serializedMockNoteTransportNode
350
+ );
351
+
352
+ return await methodHandlers[MethodName.SYNC_STATE]();
353
+ };
354
+
355
+ methodHandlers[MethodName.SUBMIT_NEW_TRANSACTION_MOCK] = async (args) => {
356
+ const wasm = await getWasmOrThrow();
357
+ let serializedMockNoteTransportNode = args.pop();
358
+ let serializedMockChain = args.pop();
359
+ serializedMockChain = new Uint8Array(serializedMockChain);
360
+ serializedMockNoteTransportNode = serializedMockNoteTransportNode
361
+ ? new Uint8Array(serializedMockNoteTransportNode)
362
+ : null;
363
+
364
+ wasmWebClient = new wasm.WebClient();
365
+ await wasmWebClient.createMockClient(
366
+ wasmSeed,
367
+ serializedMockChain,
368
+ serializedMockNoteTransportNode
369
+ );
370
+
371
+ const result = await methodHandlers[MethodName.SUBMIT_NEW_TRANSACTION](args);
372
+
373
+ const updatedMockChain = (await wasmWebClient.serializeMockChain()).buffer;
374
+ const updatedMockNoteTransportNode = (
375
+ await wasmWebClient.serializeMockNoteTransportNode()
376
+ ).buffer;
377
+
378
+ return {
379
+ transactionId: result.transactionId,
380
+ submissionHeight: result.submissionHeight,
381
+ serializedTransactionResult: result.serializedTransactionResult,
382
+ serializedTransactionUpdate: result.serializedTransactionUpdate,
383
+ serializedMockChain: updatedMockChain,
384
+ serializedMockNoteTransportNode: updatedMockNoteTransportNode,
385
+ };
386
+ };
387
+
388
+ methodHandlers[MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER_MOCK] = async (
389
+ args
390
+ ) => {
391
+ const wasm = await getWasmOrThrow();
392
+ let serializedMockNoteTransportNode = args.pop();
393
+ let serializedMockChain = args.pop();
394
+ serializedMockChain = new Uint8Array(serializedMockChain);
395
+ serializedMockNoteTransportNode = serializedMockNoteTransportNode
396
+ ? new Uint8Array(serializedMockNoteTransportNode)
397
+ : null;
398
+
399
+ wasmWebClient = new wasm.WebClient();
400
+ await wasmWebClient.createMockClient(
401
+ wasmSeed,
402
+ serializedMockChain,
403
+ serializedMockNoteTransportNode
404
+ );
405
+
406
+ const result =
407
+ await methodHandlers[MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER](args);
408
+
409
+ const updatedMockChain = (await wasmWebClient.serializeMockChain()).buffer;
410
+ const updatedMockNoteTransportNode = (
411
+ await wasmWebClient.serializeMockNoteTransportNode()
412
+ ).buffer;
413
+
414
+ return {
415
+ transactionId: result.transactionId,
416
+ submissionHeight: result.submissionHeight,
417
+ serializedTransactionResult: result.serializedTransactionResult,
418
+ serializedTransactionUpdate: result.serializedTransactionUpdate,
419
+ serializedMockChain: updatedMockChain,
420
+ serializedMockNoteTransportNode: updatedMockNoteTransportNode,
421
+ };
422
+ };
423
+
424
+ /**
425
+ * Process a single message event.
426
+ */
427
+ async function processMessage(event) {
428
+ const { action, args, methodName, requestId } = event.data;
429
+ try {
430
+ if (action === WorkerAction.INIT) {
431
+ const [
432
+ rpcUrl,
433
+ noteTransportUrl,
434
+ seed,
435
+ storeName,
436
+ hasGetKeyCb,
437
+ hasInsertKeyCb,
438
+ hasSignCb,
439
+ logLevel,
440
+ numThreads,
441
+ ] = args;
442
+ const wasm = await getWasmOrThrow();
443
+
444
+ if (logLevel) {
445
+ wasm.setupLogging(logLevel);
446
+ }
447
+
448
+ // Initialize rayon's thread pool inside THIS worker's WASM instance.
449
+ // The SDK runs every prove call here (NOT on the main thread), so a
450
+ // pool initialized only in main-thread WASM does not parallelize the
451
+ // prove. Without this, par_iter()/par_chunks() in miden-crypto +
452
+ // p3-maybe-rayon return rayon::current_num_threads() == 1 and fall
453
+ // through to sequential code despite the parallel features being on.
454
+ if (
455
+ numThreads &&
456
+ numThreads > 1 &&
457
+ typeof wasm.initThreadPool === "function"
458
+ ) {
459
+ await wasm.initThreadPool(numThreads);
460
+ }
461
+
462
+ wasmWebClient = new wasm.WebClient();
463
+
464
+ // Check if any callbacks are provided
465
+ const useExternalKeystore = hasGetKeyCb || hasInsertKeyCb || hasSignCb;
466
+
467
+ if (useExternalKeystore) {
468
+ // Use callback proxies that communicate with the main thread
469
+ await wasmWebClient.createClientWithExternalKeystore(
470
+ rpcUrl,
471
+ noteTransportUrl,
472
+ seed,
473
+ storeName,
474
+ hasGetKeyCb ? callbackProxies.getKey : undefined,
475
+ hasInsertKeyCb ? callbackProxies.insertKey : undefined,
476
+ hasSignCb ? callbackProxies.sign : undefined
477
+ );
478
+ } else {
479
+ await wasmWebClient.createClient(
480
+ rpcUrl,
481
+ noteTransportUrl,
482
+ seed,
483
+ storeName
484
+ );
485
+ }
486
+
487
+ wasmSeed = seed;
488
+ ready = true;
489
+ self.postMessage({ ready: true });
490
+ return;
491
+ } else if (action === WorkerAction.INIT_MOCK) {
492
+ const [seed, logLevel] = args;
493
+ const wasm = await getWasmOrThrow();
494
+
495
+ if (logLevel) {
496
+ wasm.setupLogging(logLevel);
497
+ }
498
+
499
+ wasmWebClient = new wasm.WebClient();
500
+ await wasmWebClient.createMockClient(seed, undefined, undefined);
501
+
502
+ wasmSeed = seed;
503
+ ready = true;
504
+ self.postMessage({ ready: true });
505
+ return;
506
+ } else if (action === WorkerAction.CALL_METHOD) {
507
+ if (!ready) {
508
+ throw new Error("Worker is not ready. Please initialize first.");
509
+ }
510
+ if (!wasmWebClient) {
511
+ throw new Error("WebClient not initialized in worker.");
512
+ }
513
+ // Look up the handler from the mapping.
514
+ const handler = methodHandlers[methodName];
515
+ if (!handler) {
516
+ throw new Error(`Unsupported method: ${methodName}`);
517
+ }
518
+ const result = await handler(args);
519
+ self.postMessage({ requestId, result, methodName });
520
+ return;
521
+ } else {
522
+ throw new Error(`Unsupported action: ${action}`);
523
+ }
524
+ } catch (error) {
525
+ const serializedError = serializeError(error);
526
+ console.error(
527
+ "WORKER: Error occurred - %s",
528
+ serializedError.message,
529
+ error
530
+ );
531
+ self.postMessage({ requestId, error: serializedError, methodName });
532
+ }
533
+ }
534
+
535
+ /**
536
+ * Process messages one at a time from the messageQueue.
537
+ */
538
+ async function processQueue() {
539
+ if (processing || messageQueue.length === 0) return;
540
+ processing = true;
541
+ const event = messageQueue.shift();
542
+ try {
543
+ await processMessage(event);
544
+ } finally {
545
+ processing = false;
546
+ processQueue(); // Process next message in queue.
547
+ }
548
+ }
549
+
550
+ // Enqueue incoming messages and process them sequentially.
551
+ self.onmessage = (event) => {
552
+ if (
553
+ event.data.callbackRequestId &&
554
+ pendingCallbacks.has(event.data.callbackRequestId)
555
+ ) {
556
+ const { callbackRequestId, callbackResult, callbackError } = event.data;
557
+ const { resolve, reject, timeoutId } =
558
+ pendingCallbacks.get(callbackRequestId);
559
+ clearTimeout(timeoutId);
560
+ pendingCallbacks.delete(callbackRequestId);
561
+ if (!callbackError) {
562
+ resolve(callbackResult);
563
+ } else {
564
+ reject(new Error(callbackError));
565
+ }
566
+ return;
567
+ }
568
+ messageQueue.push(event);
569
+ processQueue();
570
+ };
571
+
572
+ // Immediately signal that the worker script has loaded.
573
+ // This tells the main thread that the file is fully loaded before sending the "init" message.
574
+ self.postMessage({ loaded: true });
575
+ //# sourceMappingURL=web-client-methods-worker.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-client-methods-worker.module.js","sources":["../wasm.js","../../../js/constants.js","../../../js/workers/web-client-methods-worker.js"],"sourcesContent":["// This is a documented workaround that should avoid issues with Vite projects\n// https://github.com/wasm-tool/rollup-plugin-rust?tab=readme-ov-file#usage-with-vite\n// Also, this effectively disables SSR.\nasync function loadWasm() {\n let wasmModule;\n if (!import.meta.env || (import.meta.env && !import.meta.env.SSR)) {\n wasmModule = await import('./Cargo-CG4XszZo.js');\n // The Cargo glue's __wbg_init TLA is stripped by the rollup build to\n // prevent blocking WKWebView module evaluation. Call it explicitly here\n // with the WASM URL that the Cargo glue pre-resolves (relative to its\n // own import.meta.url, which downstream bundlers handle correctly).\n if (wasmModule && typeof wasmModule.__wbg_init === \"function\") {\n await wasmModule.__wbg_init({\n // eslint-disable-next-line camelcase -- wasm-bindgen init API parameter name\n module_or_path: wasmModule.__wasm_url,\n });\n }\n }\n return wasmModule;\n}\n\nexport { loadWasm as default };\n//# sourceMappingURL=wasm.js.map\n","export const WorkerAction = Object.freeze({\n INIT: \"init\",\n INIT_MOCK: \"initMock\",\n INIT_THREAD_POOL: \"initThreadPool\",\n CALL_METHOD: \"callMethod\",\n EXECUTE_CALLBACK: \"executeCallback\",\n});\n\nexport const CallbackType = Object.freeze({\n GET_KEY: \"getKey\",\n INSERT_KEY: \"insertKey\",\n SIGN: \"sign\",\n});\n\nexport const MethodName = Object.freeze({\n CREATE_CLIENT: \"createClient\",\n APPLY_TRANSACTION: \"applyTransaction\",\n EXECUTE_TRANSACTION: \"executeTransaction\",\n PROVE_TRANSACTION: \"proveTransaction\",\n SUBMIT_NEW_TRANSACTION: \"submitNewTransaction\",\n SUBMIT_NEW_TRANSACTION_MOCK: \"submitNewTransactionMock\",\n SUBMIT_NEW_TRANSACTION_WITH_PROVER: \"submitNewTransactionWithProver\",\n SUBMIT_NEW_TRANSACTION_WITH_PROVER_MOCK: \"submitNewTransactionWithProverMock\",\n SYNC_STATE: \"syncState\",\n SYNC_STATE_MOCK: \"syncStateMock\",\n});\n","import loadWasm from \"../../dist/wasm.js\";\nimport { CallbackType, MethodName, WorkerAction } from \"../constants.js\";\n\nlet wasmModule = null;\n\nconst getWasmOrThrow = async () => {\n if (!wasmModule) {\n wasmModule = await loadWasm();\n }\n if (!wasmModule) {\n throw new Error(\n \"Miden WASM bindings are unavailable in the worker environment.\"\n );\n }\n return wasmModule;\n};\n\nconst serializeUnknown = (value) => {\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n};\n\nconst serializeError = (error) => {\n if (error instanceof Error) {\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n cause: error.cause ? serializeError(error.cause) : undefined,\n code: error.code,\n };\n }\n\n if (typeof error === \"object\" && error !== null) {\n return {\n name: error.name ?? \"Error\",\n message: error.message ?? serializeUnknown(error),\n };\n }\n\n return {\n name: \"Error\",\n message: serializeUnknown(error),\n };\n};\n\n/**\n * Worker for executing WebClient methods in a separate thread.\n *\n * This worker offloads computationally heavy tasks from the main thread by handling\n * WebClient operations asynchronously. It imports the WASM module and instantiates a\n * WASM WebClient, then listens for messages from the main thread to perform one of two actions:\n *\n * 1. **Initialization (init):**\n * - The worker receives an \"init\" message along with user parameters (RPC URL and seed).\n * - It instantiates the WASM WebClient and calls its createClient method.\n * - Once initialization is complete, the worker sends a `{ ready: true }` message back to signal\n * that it is fully initialized.\n *\n * 2. **Method Invocation (callMethod):**\n * - The worker receives a \"callMethod\" message with a specific method name and arguments.\n * - It uses a mapping (defined in `methodHandlers`) to route the call to the corresponding WASM WebClient method.\n * - Complex data is serialized before being sent and deserialized upon return.\n * - The result (or any error) is then posted back to the main thread.\n *\n * The worker uses a message queue to process incoming messages sequentially, ensuring that only one message\n * is handled at a time.\n *\n * Additionally, the worker immediately sends a `{ loaded: true }` message upon script load. This informs the main\n * thread that the worker script is loaded and ready to receive the \"init\" message.\n *\n * Supported actions (defined in `WorkerAction`):\n * - \"init\" : Initialize the WASM WebClient with provided parameters.\n * - \"callMethod\" : Invoke a designated method on the WASM WebClient.\n *\n * Supported method names are defined in the `MethodName` constant.\n */\n\n// Global state variables.\nlet wasmWebClient = null;\nlet wasmSeed = null; // Seed for the WASM WebClient, if needed.\nlet ready = false; // Indicates if the worker is fully initialized.\nlet messageQueue = []; // Queue for sequential processing.\nlet processing = false; // Flag to ensure one message is processed at a time.\n\n// Track pending callback requests\nlet pendingCallbacks = new Map();\n\n// Timeout for pending callbacks (30 seconds)\nconst CALLBACK_TIMEOUT_MS = 30000;\n\n// Define proxy functions for callbacks that communicate with main thread\nconst callbackProxies = {\n getKey: async (pubKey) => {\n return new Promise((resolve, reject) => {\n const requestId = `${CallbackType.GET_KEY}-${Date.now()}-${Math.random()}`;\n const timeoutId = setTimeout(() => {\n if (pendingCallbacks.has(requestId)) {\n pendingCallbacks.delete(requestId);\n reject(new Error(`Callback ${requestId} timed out`));\n }\n }, CALLBACK_TIMEOUT_MS);\n pendingCallbacks.set(requestId, { resolve, reject, timeoutId });\n\n self.postMessage({\n action: WorkerAction.EXECUTE_CALLBACK,\n callbackType: CallbackType.GET_KEY,\n args: [pubKey],\n requestId,\n });\n });\n },\n insertKey: async (pubKey, secretKey) => {\n return new Promise((resolve, reject) => {\n const requestId = `${CallbackType.INSERT_KEY}-${Date.now()}-${Math.random()}`;\n const timeoutId = setTimeout(() => {\n if (pendingCallbacks.has(requestId)) {\n pendingCallbacks.delete(requestId);\n reject(new Error(`Callback ${requestId} timed out`));\n }\n }, CALLBACK_TIMEOUT_MS);\n pendingCallbacks.set(requestId, { resolve, reject, timeoutId });\n\n self.postMessage({\n action: WorkerAction.EXECUTE_CALLBACK,\n callbackType: CallbackType.INSERT_KEY,\n args: [pubKey, secretKey],\n requestId,\n });\n });\n },\n sign: async (pubKey, signingInputs) => {\n return new Promise((resolve, reject) => {\n const requestId = `${CallbackType.SIGN}-${Date.now()}-${Math.random()}`;\n const timeoutId = setTimeout(() => {\n if (pendingCallbacks.has(requestId)) {\n pendingCallbacks.delete(requestId);\n reject(new Error(`Callback ${requestId} timed out`));\n }\n }, CALLBACK_TIMEOUT_MS);\n pendingCallbacks.set(requestId, { resolve, reject, timeoutId });\n\n self.postMessage({\n action: WorkerAction.EXECUTE_CALLBACK,\n callbackType: CallbackType.SIGN,\n args: [pubKey, signingInputs],\n requestId,\n });\n });\n },\n};\n\n// Define a mapping from method names to handler functions.\nconst methodHandlers = {\n [MethodName.SYNC_STATE]: async () => {\n // Call the internal WASM method (sync lock is handled at the JS wrapper level)\n const syncSummary = await wasmWebClient.syncStateImpl();\n const serializedSyncSummary = syncSummary.serialize();\n return serializedSyncSummary.buffer;\n },\n [MethodName.APPLY_TRANSACTION]: async (args) => {\n const wasm = await getWasmOrThrow();\n const [serializedTransactionResult, submissionHeight] = args;\n const transactionResultBytes = new Uint8Array(serializedTransactionResult);\n const transactionResult = wasm.TransactionResult.deserialize(\n transactionResultBytes\n );\n const transactionUpdate = await wasmWebClient.applyTransaction(\n transactionResult,\n submissionHeight\n );\n const serializedUpdate = transactionUpdate.serialize();\n return serializedUpdate.buffer;\n },\n [MethodName.EXECUTE_TRANSACTION]: async (args) => {\n const wasm = await getWasmOrThrow();\n const [accountIdHex, serializedTransactionRequest] = args;\n const accountId = wasm.AccountId.fromHex(accountIdHex);\n const transactionRequestBytes = new Uint8Array(\n serializedTransactionRequest\n );\n const transactionRequest = wasm.TransactionRequest.deserialize(\n transactionRequestBytes\n );\n const result = await wasmWebClient.executeTransaction(\n accountId,\n transactionRequest\n );\n const serializedResult = result.serialize();\n return serializedResult.buffer;\n },\n [MethodName.PROVE_TRANSACTION]: async (args) => {\n const wasm = await getWasmOrThrow();\n const [serializedTransactionResult, proverPayload] = args;\n const transactionResultBytes = new Uint8Array(serializedTransactionResult);\n const transactionResult = wasm.TransactionResult.deserialize(\n transactionResultBytes\n );\n\n const prover = proverPayload\n ? wasm.TransactionProver.deserialize(proverPayload)\n : undefined;\n\n const proven = await wasmWebClient.proveTransaction(\n transactionResult,\n prover\n );\n const serializedProven = proven.serialize();\n return serializedProven.buffer;\n },\n [MethodName.SUBMIT_NEW_TRANSACTION]: async (args) => {\n const wasm = await getWasmOrThrow();\n const [accountIdHex, serializedTransactionRequest] = args;\n const accountId = wasm.AccountId.fromHex(accountIdHex);\n const transactionRequestBytes = new Uint8Array(\n serializedTransactionRequest\n );\n const transactionRequest = wasm.TransactionRequest.deserialize(\n transactionRequestBytes\n );\n\n const result = await wasmWebClient.executeTransaction(\n accountId,\n transactionRequest\n );\n\n const transactionId = result.id().toHex();\n\n const proven = await wasmWebClient.proveTransaction(result);\n const submissionHeight = await wasmWebClient.submitProvenTransaction(\n proven,\n result\n );\n const transactionUpdate = await wasmWebClient.applyTransaction(\n result,\n submissionHeight\n );\n\n return {\n transactionId,\n submissionHeight,\n serializedTransactionResult: result.serialize().buffer,\n serializedTransactionUpdate: transactionUpdate.serialize().buffer,\n };\n },\n [MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER]: async (args) => {\n const wasm = await getWasmOrThrow();\n const [accountIdHex, serializedTransactionRequest, proverPayload] = args;\n const accountId = wasm.AccountId.fromHex(accountIdHex);\n const transactionRequestBytes = new Uint8Array(\n serializedTransactionRequest\n );\n const transactionRequest = wasm.TransactionRequest.deserialize(\n transactionRequestBytes\n );\n\n // Deserialize the prover from the serialized payload\n const prover = proverPayload\n ? wasm.TransactionProver.deserialize(proverPayload)\n : undefined;\n\n const result = await wasmWebClient.executeTransaction(\n accountId,\n transactionRequest\n );\n\n const transactionId = result.id().toHex();\n\n const proven = await wasmWebClient.proveTransaction(result, prover);\n const submissionHeight = await wasmWebClient.submitProvenTransaction(\n proven,\n result\n );\n const transactionUpdate = await wasmWebClient.applyTransaction(\n result,\n submissionHeight\n );\n\n return {\n transactionId,\n submissionHeight,\n serializedTransactionResult: result.serialize().buffer,\n serializedTransactionUpdate: transactionUpdate.serialize().buffer,\n };\n },\n};\n\n// Add mock methods to the handler mapping.\nmethodHandlers[MethodName.SYNC_STATE_MOCK] = async (args) => {\n let [serializedMockChain, serializedMockNoteTransportNode] = args;\n serializedMockChain = new Uint8Array(serializedMockChain);\n serializedMockNoteTransportNode = serializedMockNoteTransportNode\n ? new Uint8Array(serializedMockNoteTransportNode)\n : null;\n await wasmWebClient.createMockClient(\n wasmSeed,\n serializedMockChain,\n serializedMockNoteTransportNode\n );\n\n return await methodHandlers[MethodName.SYNC_STATE]();\n};\n\nmethodHandlers[MethodName.SUBMIT_NEW_TRANSACTION_MOCK] = async (args) => {\n const wasm = await getWasmOrThrow();\n let serializedMockNoteTransportNode = args.pop();\n let serializedMockChain = args.pop();\n serializedMockChain = new Uint8Array(serializedMockChain);\n serializedMockNoteTransportNode = serializedMockNoteTransportNode\n ? new Uint8Array(serializedMockNoteTransportNode)\n : null;\n\n wasmWebClient = new wasm.WebClient();\n await wasmWebClient.createMockClient(\n wasmSeed,\n serializedMockChain,\n serializedMockNoteTransportNode\n );\n\n const result = await methodHandlers[MethodName.SUBMIT_NEW_TRANSACTION](args);\n\n const updatedMockChain = (await wasmWebClient.serializeMockChain()).buffer;\n const updatedMockNoteTransportNode = (\n await wasmWebClient.serializeMockNoteTransportNode()\n ).buffer;\n\n return {\n transactionId: result.transactionId,\n submissionHeight: result.submissionHeight,\n serializedTransactionResult: result.serializedTransactionResult,\n serializedTransactionUpdate: result.serializedTransactionUpdate,\n serializedMockChain: updatedMockChain,\n serializedMockNoteTransportNode: updatedMockNoteTransportNode,\n };\n};\n\nmethodHandlers[MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER_MOCK] = async (\n args\n) => {\n const wasm = await getWasmOrThrow();\n let serializedMockNoteTransportNode = args.pop();\n let serializedMockChain = args.pop();\n serializedMockChain = new Uint8Array(serializedMockChain);\n serializedMockNoteTransportNode = serializedMockNoteTransportNode\n ? new Uint8Array(serializedMockNoteTransportNode)\n : null;\n\n wasmWebClient = new wasm.WebClient();\n await wasmWebClient.createMockClient(\n wasmSeed,\n serializedMockChain,\n serializedMockNoteTransportNode\n );\n\n const result =\n await methodHandlers[MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER](args);\n\n const updatedMockChain = (await wasmWebClient.serializeMockChain()).buffer;\n const updatedMockNoteTransportNode = (\n await wasmWebClient.serializeMockNoteTransportNode()\n ).buffer;\n\n return {\n transactionId: result.transactionId,\n submissionHeight: result.submissionHeight,\n serializedTransactionResult: result.serializedTransactionResult,\n serializedTransactionUpdate: result.serializedTransactionUpdate,\n serializedMockChain: updatedMockChain,\n serializedMockNoteTransportNode: updatedMockNoteTransportNode,\n };\n};\n\n/**\n * Process a single message event.\n */\nasync function processMessage(event) {\n const { action, args, methodName, requestId } = event.data;\n try {\n if (action === WorkerAction.INIT) {\n const [\n rpcUrl,\n noteTransportUrl,\n seed,\n storeName,\n hasGetKeyCb,\n hasInsertKeyCb,\n hasSignCb,\n logLevel,\n numThreads,\n ] = args;\n const wasm = await getWasmOrThrow();\n\n if (logLevel) {\n wasm.setupLogging(logLevel);\n }\n\n // Initialize rayon's thread pool inside THIS worker's WASM instance.\n // The SDK runs every prove call here (NOT on the main thread), so a\n // pool initialized only in main-thread WASM does not parallelize the\n // prove. Without this, par_iter()/par_chunks() in miden-crypto +\n // p3-maybe-rayon return rayon::current_num_threads() == 1 and fall\n // through to sequential code despite the parallel features being on.\n if (\n numThreads &&\n numThreads > 1 &&\n typeof wasm.initThreadPool === \"function\"\n ) {\n await wasm.initThreadPool(numThreads);\n }\n\n wasmWebClient = new wasm.WebClient();\n\n // Check if any callbacks are provided\n const useExternalKeystore = hasGetKeyCb || hasInsertKeyCb || hasSignCb;\n\n if (useExternalKeystore) {\n // Use callback proxies that communicate with the main thread\n await wasmWebClient.createClientWithExternalKeystore(\n rpcUrl,\n noteTransportUrl,\n seed,\n storeName,\n hasGetKeyCb ? callbackProxies.getKey : undefined,\n hasInsertKeyCb ? callbackProxies.insertKey : undefined,\n hasSignCb ? callbackProxies.sign : undefined\n );\n } else {\n await wasmWebClient.createClient(\n rpcUrl,\n noteTransportUrl,\n seed,\n storeName\n );\n }\n\n wasmSeed = seed;\n ready = true;\n self.postMessage({ ready: true });\n return;\n } else if (action === WorkerAction.INIT_MOCK) {\n const [seed, logLevel] = args;\n const wasm = await getWasmOrThrow();\n\n if (logLevel) {\n wasm.setupLogging(logLevel);\n }\n\n wasmWebClient = new wasm.WebClient();\n await wasmWebClient.createMockClient(seed, undefined, undefined);\n\n wasmSeed = seed;\n ready = true;\n self.postMessage({ ready: true });\n return;\n } else if (action === WorkerAction.CALL_METHOD) {\n if (!ready) {\n throw new Error(\"Worker is not ready. Please initialize first.\");\n }\n if (!wasmWebClient) {\n throw new Error(\"WebClient not initialized in worker.\");\n }\n // Look up the handler from the mapping.\n const handler = methodHandlers[methodName];\n if (!handler) {\n throw new Error(`Unsupported method: ${methodName}`);\n }\n const result = await handler(args);\n self.postMessage({ requestId, result, methodName });\n return;\n } else {\n throw new Error(`Unsupported action: ${action}`);\n }\n } catch (error) {\n const serializedError = serializeError(error);\n console.error(\n \"WORKER: Error occurred - %s\",\n serializedError.message,\n error\n );\n self.postMessage({ requestId, error: serializedError, methodName });\n }\n}\n\n/**\n * Process messages one at a time from the messageQueue.\n */\nasync function processQueue() {\n if (processing || messageQueue.length === 0) return;\n processing = true;\n const event = messageQueue.shift();\n try {\n await processMessage(event);\n } finally {\n processing = false;\n processQueue(); // Process next message in queue.\n }\n}\n\n// Enqueue incoming messages and process them sequentially.\nself.onmessage = (event) => {\n if (\n event.data.callbackRequestId &&\n pendingCallbacks.has(event.data.callbackRequestId)\n ) {\n const { callbackRequestId, callbackResult, callbackError } = event.data;\n const { resolve, reject, timeoutId } =\n pendingCallbacks.get(callbackRequestId);\n clearTimeout(timeoutId);\n pendingCallbacks.delete(callbackRequestId);\n if (!callbackError) {\n resolve(callbackResult);\n } else {\n reject(new Error(callbackError));\n }\n return;\n }\n messageQueue.push(event);\n processQueue();\n};\n\n// Immediately signal that the worker script has loaded.\n// This tells the main thread that the file is fully loaded before sending the \"init\" message.\nself.postMessage({ loaded: true });\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA,eAAe,QAAQ,GAAG;AAC1B,EAAE,IAAI,UAAU;AAChB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACrE,IAAI,UAAU,GAAG,MAAM,OAAO,8BAAqB,CAAC;AACpD;AACA;AACA;AACA;AACA,IAAI,IAAI,UAAU,IAAI,OAAO,UAAU,CAAC,UAAU,KAAK,UAAU,EAAE;AACnE,MAAM,MAAM,UAAU,CAAC,UAAU,CAAC;AAClC;AACA,QAAQ,cAAc,EAAE,UAAU,CAAC,UAAU;AAC7C,OAAO,CAAC;AACR,IAAI;AACJ,EAAE;AACF,EAAE,OAAO,UAAU;AACnB;;ACnBO,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;AAC1C,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,SAAS,EAAE,UAAU;AACvB,EAAE,gBAAgB,EAAE,gBAAgB;AACpC,EAAE,WAAW,EAAE,YAAY;AAC3B,EAAE,gBAAgB,EAAE,iBAAiB;AACrC,CAAC,CAAC;;AAEK,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;AAC1C,EAAE,OAAO,EAAE,QAAQ;AACnB,EAAE,UAAU,EAAE,WAAW;AACzB,EAAE,IAAI,EAAE,MAAM;AAC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