@miden-sdk/miden-sdk 0.15.3 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/dist/mt/{Cargo-D2qNRrNR.js → Cargo-DjVnfWKi.js} +424 -88
- package/dist/mt/Cargo-DjVnfWKi.js.map +1 -0
- package/dist/mt/api-types.d.ts +130 -0
- package/dist/mt/assets/miden_client_web.wasm +0 -0
- package/dist/mt/crates/miden_client_web.d.ts +93 -3
- package/dist/mt/docs-entry.d.ts +2 -0
- package/dist/mt/eager.js +1 -1
- package/dist/mt/index.d.ts +3 -0
- package/dist/mt/index.js +211 -13
- package/dist/mt/index.js.map +1 -1
- package/dist/mt/wasm.js +1 -1
- package/dist/mt/workerHelpers.js +1 -1
- package/dist/mt/workers/{Cargo-D2qNRrNR-n_GEbq73.js → Cargo-DjVnfWKi-DvLbB_Zb.js} +424 -88
- package/dist/mt/workers/Cargo-DjVnfWKi-DvLbB_Zb.js.map +1 -0
- package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
- package/dist/mt/workers/web-client-methods-worker.js +425 -88
- package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
- package/dist/mt/workers/workerHelpers.js +1 -1
- package/dist/st/{Cargo-BP7-0qVT.js → Cargo-Cwpuvlbc.js} +433 -98
- package/dist/st/Cargo-Cwpuvlbc.js.map +1 -0
- package/dist/st/api-types.d.ts +130 -0
- package/dist/st/assets/miden_client_web.wasm +0 -0
- package/dist/st/crates/miden_client_web.d.ts +93 -3
- package/dist/st/docs-entry.d.ts +2 -0
- package/dist/st/eager.js +1 -1
- package/dist/st/index.d.ts +3 -0
- package/dist/st/index.js +211 -13
- package/dist/st/index.js.map +1 -1
- package/dist/st/wasm.js +1 -1
- package/dist/st/workers/{Cargo-BP7-0qVT-CmfAy6bf.js → Cargo-Cwpuvlbc-B0V_MEMU.js} +433 -98
- package/dist/st/workers/Cargo-Cwpuvlbc-B0V_MEMU.js.map +1 -0
- package/dist/st/workers/assets/miden_client_web.wasm +0 -0
- package/dist/st/workers/web-client-methods-worker.js +434 -98
- package/dist/st/workers/web-client-methods-worker.js.map +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
- package/js/node-index.js +1 -0
- package/js/resources/transactions.js +198 -12
- package/package.json +4 -4
- package/dist/mt/Cargo-D2qNRrNR.js.map +0 -1
- package/dist/mt/workers/Cargo-D2qNRrNR-n_GEbq73.js.map +0 -1
- package/dist/st/Cargo-BP7-0qVT.js.map +0 -1
- package/dist/st/workers/Cargo-BP7-0qVT-CmfAy6bf.js.map +0 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
async function loadWasm() {
|
|
5
5
|
let wasmModule;
|
|
6
6
|
if (!import.meta.env || (import.meta.env && !import.meta.env.SSR)) {
|
|
7
|
-
wasmModule = await import('./Cargo-
|
|
7
|
+
wasmModule = await import('./Cargo-Cwpuvlbc-B0V_MEMU.js');
|
|
8
8
|
// The Cargo glue's __wbg_init TLA is stripped by the rollup build to
|
|
9
9
|
// prevent blocking WKWebView module evaluation. Call it explicitly here
|
|
10
10
|
// with the WASM URL that the Cargo glue pre-resolves (relative to its
|
|
@@ -1 +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-BP7-0qVT.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 SYNC_CHAIN: \"syncChain\",\n SYNC_CHAIN_MOCK: \"syncChainMock\",\n SYNC_NOTE_TRANSPORT: \"syncNoteTransport\",\n SYNC_NOTE_TRANSPORT_MOCK: \"syncNoteTransportMock\",\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.SYNC_NOTE_TRANSPORT]: async () => {\n await wasmWebClient.syncNoteTransportImpl();\n },\n [MethodName.SYNC_CHAIN]: async () => {\n const syncSummary = await wasmWebClient.syncChainImpl();\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.SYNC_CHAIN_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_CHAIN]();\n};\n\nmethodHandlers[MethodName.SYNC_NOTE_TRANSPORT_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_NOTE_TRANSPORT]();\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, numThreads] = args;\n const wasm = await getWasmOrThrow();\n\n if (logLevel) {\n wasm.setupLogging(logLevel);\n }\n\n // Initialize rayon's pool inside THIS worker's WASM instance — same\n // rationale as the INIT path above: all proving executes here, and a\n // pool initialized in any other instance does not parallelize it.\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 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,CA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-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-Cwpuvlbc.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 SYNC_CHAIN: \"syncChain\",\n SYNC_CHAIN_MOCK: \"syncChainMock\",\n SYNC_NOTE_TRANSPORT: \"syncNoteTransport\",\n SYNC_NOTE_TRANSPORT_MOCK: \"syncNoteTransportMock\",\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.SYNC_NOTE_TRANSPORT]: async () => {\n await wasmWebClient.syncNoteTransportImpl();\n },\n [MethodName.SYNC_CHAIN]: async () => {\n const syncSummary = await wasmWebClient.syncChainImpl();\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.SYNC_CHAIN_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_CHAIN]();\n};\n\nmethodHandlers[MethodName.SYNC_NOTE_TRANSPORT_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_NOTE_TRANSPORT]();\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, numThreads] = args;\n const wasm = await getWasmOrThrow();\n\n if (logLevel) {\n wasm.setupLogging(logLevel);\n }\n\n // Initialize rayon's pool inside THIS worker's WASM instance — same\n // rationale as the INIT path above: all proving executes here, and a\n // pool initialized in any other instance does not parallelize it.\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 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,GAA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,cAAc,CAAC;AAC7B,IAAI,CAAC,MAAM;AACX,MAAM,MAAM,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;AACtC,IAAI;AACJ,IAAI;AACJ,EAAE;AACF,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;AAC1B,EAAE,YAAY,EAAE;AAChB,CAAC;;AAED;AACA;AACA,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC"}
|
package/js/node-index.js
CHANGED
|
@@ -184,6 +184,7 @@ export const ConsumableNoteRecord = /* @__PURE__ */ _reexport(
|
|
|
184
184
|
"ConsumableNoteRecord"
|
|
185
185
|
);
|
|
186
186
|
export const Endpoint = /* @__PURE__ */ _reexport("Endpoint");
|
|
187
|
+
export const EthAddress = /* @__PURE__ */ _reexport("EthAddress");
|
|
187
188
|
export const ExecutedTransaction = /* @__PURE__ */ _reexport(
|
|
188
189
|
"ExecutedTransaction"
|
|
189
190
|
);
|
|
@@ -97,6 +97,24 @@ export class TransactionsResource {
|
|
|
97
97
|
return { txId, result };
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
async bridge(opts) {
|
|
101
|
+
this.#client.assertNotTerminated();
|
|
102
|
+
const wasm = await this.#getWasm();
|
|
103
|
+
const { accountId, request } = await this.#buildB2AggRequest(opts, wasm);
|
|
104
|
+
|
|
105
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
106
|
+
accountId,
|
|
107
|
+
request,
|
|
108
|
+
opts.prover
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
if (opts.waitForConfirmation) {
|
|
112
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return { txId, result };
|
|
116
|
+
}
|
|
117
|
+
|
|
100
118
|
async consume(opts) {
|
|
101
119
|
this.#client.assertNotTerminated();
|
|
102
120
|
const wasm = await this.#getWasm();
|
|
@@ -259,6 +277,10 @@ export class TransactionsResource {
|
|
|
259
277
|
({ accountId, request } = await this.#buildMintRequest(opts, wasm));
|
|
260
278
|
break;
|
|
261
279
|
}
|
|
280
|
+
case "bridge": {
|
|
281
|
+
({ accountId, request } = await this.#buildB2AggRequest(opts, wasm));
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
262
284
|
case "consume": {
|
|
263
285
|
({ accountId, request } = await this.#buildConsumeRequest(opts, wasm));
|
|
264
286
|
break;
|
|
@@ -303,6 +325,163 @@ export class TransactionsResource {
|
|
|
303
325
|
async execute(opts) {
|
|
304
326
|
this.#client.assertNotTerminated();
|
|
305
327
|
const wasm = await this.#getWasm();
|
|
328
|
+
const { accountId, request } = this.#buildExecuteRequest(opts, wasm);
|
|
329
|
+
|
|
330
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
331
|
+
accountId,
|
|
332
|
+
request,
|
|
333
|
+
opts.prover
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
if (opts.waitForConfirmation) {
|
|
337
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return { txId, result };
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Submit a heterogeneous batch of operations against a single account. All
|
|
345
|
+
* operations are executed, proven individually and as a batch, and submitted
|
|
346
|
+
* atomically — either every tx in the batch lands or none does.
|
|
347
|
+
*
|
|
348
|
+
* @param {BatchOptions} opts - Batch options including the account, operations array, and confirmation settings.
|
|
349
|
+
* @returns {Promise<BatchSubmitResult>} The block number the batch was accepted into.
|
|
350
|
+
*/
|
|
351
|
+
async batch(opts) {
|
|
352
|
+
this.#client.assertNotTerminated();
|
|
353
|
+
const wasm = await this.#getWasm();
|
|
354
|
+
|
|
355
|
+
if (!opts || !opts.account) {
|
|
356
|
+
throw new Error("batch: `account` is required");
|
|
357
|
+
}
|
|
358
|
+
if (!Array.isArray(opts.operations) || opts.operations.length === 0) {
|
|
359
|
+
throw new Error("batch: `operations` must be a non-empty array");
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Build each TransactionRequest. Per-op builders all use the batch-level
|
|
363
|
+
// `account` — V1 only supports same-account batches, mirroring the Rust
|
|
364
|
+
// constraint. We forward `opts.account` into each per-op options object so
|
|
365
|
+
// the existing builders' `resolveAccountRef` produces fresh AccountIds
|
|
366
|
+
// when needed.
|
|
367
|
+
const requests = [];
|
|
368
|
+
for (let i = 0; i < opts.operations.length; i++) {
|
|
369
|
+
const op = opts.operations[i];
|
|
370
|
+
let built;
|
|
371
|
+
switch (op?.kind) {
|
|
372
|
+
case "send":
|
|
373
|
+
built = await this.#buildSendRequest(
|
|
374
|
+
{ ...op, account: opts.account },
|
|
375
|
+
wasm
|
|
376
|
+
);
|
|
377
|
+
break;
|
|
378
|
+
case "mint":
|
|
379
|
+
built = await this.#buildMintRequest(
|
|
380
|
+
{ ...op, account: opts.account },
|
|
381
|
+
wasm
|
|
382
|
+
);
|
|
383
|
+
break;
|
|
384
|
+
case "consume":
|
|
385
|
+
built = await this.#buildConsumeRequest(
|
|
386
|
+
{ ...op, account: opts.account },
|
|
387
|
+
wasm
|
|
388
|
+
);
|
|
389
|
+
break;
|
|
390
|
+
case "swap":
|
|
391
|
+
built = await this.#buildSwapRequest(
|
|
392
|
+
{ ...op, account: opts.account },
|
|
393
|
+
wasm
|
|
394
|
+
);
|
|
395
|
+
break;
|
|
396
|
+
case "execute":
|
|
397
|
+
built = this.#buildExecuteRequest(
|
|
398
|
+
{ ...op, account: opts.account },
|
|
399
|
+
wasm
|
|
400
|
+
);
|
|
401
|
+
break;
|
|
402
|
+
case "custom":
|
|
403
|
+
if (!op.request) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
`batch: operation[${i}] of kind "custom" is missing \`request\``
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
built = { request: op.request };
|
|
409
|
+
break;
|
|
410
|
+
default:
|
|
411
|
+
throw new Error(
|
|
412
|
+
`batch: operation[${i}] has unknown kind "${op?.kind}"`
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
requests.push(built.request);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return this.submitBatch(opts.account, requests, opts);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Submit pre-built TransactionRequests as an atomic batch. Lower-level
|
|
423
|
+
* counterpart of `batch()` — for callers that already have built requests in
|
|
424
|
+
* hand. Equivalent to `submit()` but plural.
|
|
425
|
+
*
|
|
426
|
+
* @param {AccountRef} account - The account executing the batch.
|
|
427
|
+
* @param {TransactionRequest[]} requests - Pre-built transaction requests.
|
|
428
|
+
* @param {object} [options] - Optional settings (waitForConfirmation, timeout).
|
|
429
|
+
* The batch is proved with the client's configured prover; the V1 batch API
|
|
430
|
+
* has no per-call prover override.
|
|
431
|
+
* @returns {Promise<BatchSubmitResult>} The block number the batch was accepted into.
|
|
432
|
+
*/
|
|
433
|
+
async submitBatch(account, requests, options) {
|
|
434
|
+
this.#client.assertNotTerminated();
|
|
435
|
+
const wasm = await this.#getWasm();
|
|
436
|
+
|
|
437
|
+
if (!Array.isArray(requests) || requests.length === 0) {
|
|
438
|
+
throw new Error("submitBatch: `requests` must be a non-empty array");
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const accountId = resolveAccountRef(account, wasm);
|
|
442
|
+
const blockNumber = await this.#inner.submitNewTransactionBatch(
|
|
443
|
+
accountId,
|
|
444
|
+
requests.map((r) => r.serialize())
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
if (options?.waitForConfirmation) {
|
|
448
|
+
await this.#waitForBlock(blockNumber, options);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return { blockNumber };
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Polls until the local sync height reaches `blockNumber` or the timeout
|
|
456
|
+
* expires. The Rust V1 batch API returns only a block number — there are no
|
|
457
|
+
* per-tx ids to poll on, so we wait on the chain height instead.
|
|
458
|
+
*
|
|
459
|
+
* @param {number} blockNumber - The block height to wait for.
|
|
460
|
+
* @param {object} [opts] - Polling options (timeout, interval).
|
|
461
|
+
*/
|
|
462
|
+
async #waitForBlock(blockNumber, opts) {
|
|
463
|
+
const timeout = opts?.timeout ?? 60_000;
|
|
464
|
+
const interval = opts?.interval ?? 5_000;
|
|
465
|
+
const start = Date.now();
|
|
466
|
+
|
|
467
|
+
while (true) {
|
|
468
|
+
if (timeout > 0 && Date.now() - start >= timeout) {
|
|
469
|
+
throw new Error(
|
|
470
|
+
`Batch confirmation timed out after ${timeout}ms (waiting for block ${blockNumber})`
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
try {
|
|
474
|
+
await this.#inner.syncStateWithTimeout(0);
|
|
475
|
+
} catch {
|
|
476
|
+
// sync may fail transiently; continue polling
|
|
477
|
+
}
|
|
478
|
+
const height = await this.#inner.getSyncHeight();
|
|
479
|
+
if (height >= blockNumber) return;
|
|
480
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
#buildExecuteRequest(opts, wasm) {
|
|
306
485
|
const accountId = resolveAccountRef(opts.account, wasm);
|
|
307
486
|
|
|
308
487
|
let builder = new wasm.TransactionRequestBuilder().withCustomScript(
|
|
@@ -330,18 +509,7 @@ export class TransactionsResource {
|
|
|
330
509
|
);
|
|
331
510
|
}
|
|
332
511
|
|
|
333
|
-
|
|
334
|
-
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
335
|
-
accountId,
|
|
336
|
-
request,
|
|
337
|
-
opts.prover
|
|
338
|
-
);
|
|
339
|
-
|
|
340
|
-
if (opts.waitForConfirmation) {
|
|
341
|
-
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return { txId, result };
|
|
512
|
+
return { accountId, request: builder.build() };
|
|
345
513
|
}
|
|
346
514
|
|
|
347
515
|
async executeProgram(opts) {
|
|
@@ -514,6 +682,24 @@ export class TransactionsResource {
|
|
|
514
682
|
return { accountId, request };
|
|
515
683
|
}
|
|
516
684
|
|
|
685
|
+
async #buildB2AggRequest(opts, wasm) {
|
|
686
|
+
const accountId = resolveAccountRef(opts.account, wasm);
|
|
687
|
+
const bridgeAccountId = resolveAccountRef(opts.bridgeAccount, wasm);
|
|
688
|
+
const faucetId = resolveAccountRef(opts.token, wasm);
|
|
689
|
+
const amount = BigInt(opts.amount);
|
|
690
|
+
const destinationAddress = wasm.EthAddress.fromHex(opts.destinationAddress);
|
|
691
|
+
|
|
692
|
+
const request = await this.#inner.newB2AggTransactionRequest(
|
|
693
|
+
accountId,
|
|
694
|
+
bridgeAccountId,
|
|
695
|
+
faucetId,
|
|
696
|
+
amount,
|
|
697
|
+
opts.destinationNetwork,
|
|
698
|
+
destinationAddress
|
|
699
|
+
);
|
|
700
|
+
return { accountId, request };
|
|
701
|
+
}
|
|
702
|
+
|
|
517
703
|
async #buildConsumeRequest(opts, wasm) {
|
|
518
704
|
const accountId = resolveAccountRef(opts.account, wasm);
|
|
519
705
|
const noteInputs = Array.isArray(opts.notes) ? opts.notes : [opts.notes];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miden-sdk/miden-sdk",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
4
4
|
"description": "Miden Wasm SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"glob": "^11.0.0"
|
|
84
84
|
},
|
|
85
85
|
"optionalDependencies": {
|
|
86
|
-
"@miden-sdk/node-darwin-arm64": "0.15.
|
|
87
|
-
"@miden-sdk/node-darwin-x64": "0.15.
|
|
88
|
-
"@miden-sdk/node-linux-x64-gnu": "0.15.
|
|
86
|
+
"@miden-sdk/node-darwin-arm64": "0.15.4",
|
|
87
|
+
"@miden-sdk/node-darwin-x64": "0.15.4",
|
|
88
|
+
"@miden-sdk/node-linux-x64-gnu": "0.15.4"
|
|
89
89
|
},
|
|
90
90
|
"scripts": {
|
|
91
91
|
"build-rust-client-js": "pnpm --filter web_store run build",
|