@miden-sdk/miden-sdk 0.14.5 → 0.15.0-alpha.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/LICENSE +21 -0
- package/README.md +9 -9
- package/dist/{Cargo-M3382VZc.js → Cargo-CVlXCH_2.js} +7129 -6225
- package/dist/Cargo-CVlXCH_2.js.map +1 -0
- package/dist/api-types.d.ts +19 -65
- package/dist/assets/miden_client_web.wasm +0 -0
- package/dist/crates/miden_client_web.d.ts +122 -172
- package/dist/docs-entry.d.ts +5 -2
- package/dist/eager.js +7 -4
- package/dist/eager.js.map +1 -1
- package/dist/index.d.ts +107 -14
- package/dist/index.js +529 -415
- package/dist/index.js.map +1 -1
- package/dist/wasm.js +1 -1
- package/dist/workers/{Cargo-M3382VZc-Dfw4tXwh.js → Cargo-CVlXCH_2-CWA-5vlh.js} +7129 -6225
- package/dist/workers/Cargo-CVlXCH_2-CWA-5vlh.js.map +1 -0
- package/dist/workers/assets/miden_client_web.wasm +0 -0
- package/dist/workers/web-client-methods-worker.js +7153 -6243
- package/dist/workers/web-client-methods-worker.js.map +1 -1
- package/dist/workers/web-client-methods-worker.module.js +23 -19
- package/dist/workers/web-client-methods-worker.module.js.map +1 -1
- package/js/client.js +327 -0
- package/js/node/client-factory.js +117 -0
- package/js/node/loader.js +138 -0
- package/js/node/napi-compat.js +238 -0
- package/js/node-index.js +195 -0
- package/js/resources/accounts.js +224 -0
- package/js/resources/compiler.js +74 -0
- package/js/resources/keystore.js +54 -0
- package/js/resources/notes.js +124 -0
- package/js/resources/settings.js +30 -0
- package/js/resources/tags.js +31 -0
- package/js/resources/transactions.js +533 -0
- package/js/standalone.js +109 -0
- package/js/utils.js +232 -0
- package/lazy/package.json +4 -0
- package/package.json +62 -40
- package/dist/Cargo-M3382VZc.js.map +0 -1
- package/dist/workers/Cargo-M3382VZc-Dfw4tXwh.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import loadWasm from './wasm.js';
|
|
2
|
-
|
|
3
|
-
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, setupLogging } from './Cargo-M3382VZc.js';
|
|
2
|
+
export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, setupLogging } from './Cargo-CVlXCH_2.js';
|
|
4
3
|
|
|
5
4
|
const WorkerAction = Object.freeze({
|
|
6
5
|
INIT: "init",
|
|
@@ -109,6 +108,7 @@ async function acquireSyncLock(dbId, timeoutMs = 0) {
|
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
const onResult = (result) => {
|
|
111
|
+
/* v8 ignore next 1 -- timeoutId only set when timeoutMs>0 AND another sync is in progress; combo rare in tests */
|
|
112
112
|
if (timeoutId) clearTimeout(timeoutId);
|
|
113
113
|
resolve({ acquired: false, coalescedResult: result });
|
|
114
114
|
};
|
|
@@ -154,6 +154,7 @@ async function acquireSyncLock(dbId, timeoutMs = 0) {
|
|
|
154
154
|
|
|
155
155
|
navigator.locks
|
|
156
156
|
.request(lockName, { mode: "exclusive" }, async () => {
|
|
157
|
+
/* v8 ignore next 3 -- race: lock granted after timeout or newer generation */
|
|
157
158
|
if (timedOut || state.syncGeneration !== currentGeneration) {
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
@@ -166,6 +167,9 @@ async function acquireSyncLock(dbId, timeoutMs = 0) {
|
|
|
166
167
|
});
|
|
167
168
|
})
|
|
168
169
|
.catch((err) => {
|
|
170
|
+
/* v8 ignore next 5 -- catch path requires Web Locks rejection combined with
|
|
171
|
+
optional timeout; tested via "rejects when Web Locks request rejects" but
|
|
172
|
+
the timeoutId-set branch needs Web Locks + timeout simultaneously */
|
|
169
173
|
if (timeoutId) clearTimeout(timeoutId);
|
|
170
174
|
if (state.syncGeneration === currentGeneration) {
|
|
171
175
|
state.inProgress = false;
|
|
@@ -346,31 +350,18 @@ function resolveStorageMode(mode, wasm) {
|
|
|
346
350
|
}
|
|
347
351
|
|
|
348
352
|
/**
|
|
349
|
-
* Resolves an auth scheme string to a WASM
|
|
353
|
+
* Resolves an auth scheme string to a WASM AuthScheme enum value.
|
|
350
354
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
* expect the numeric variant from the Rust `AuthScheme` enum. This helper
|
|
355
|
-
* bridges the two so callers never touch wasm-bindgen internals directly.
|
|
356
|
-
*
|
|
357
|
-
* `wasm` is optional: when provided (by internal callers who already have
|
|
358
|
-
* the module loaded), the numeric value is read from the binding itself,
|
|
359
|
-
* keeping the mapping robust if wasm-bindgen ever renumbers the enum. When
|
|
360
|
-
* omitted (public callers who don't have a handle to the WASM module), the
|
|
361
|
-
* hardcoded discriminants below are used — these are pinned to the Rust
|
|
362
|
-
* enum order by a cross-check test in `test/account_component.test.ts`.
|
|
363
|
-
*
|
|
364
|
-
* @param {"falcon" | "ecdsa" | undefined} scheme - Defaults to `"falcon"`.
|
|
365
|
-
* @param {object} [wasm] - Optional WASM module handle.
|
|
366
|
-
* @returns {number} The AuthScheme enum numeric value (1 or 2).
|
|
355
|
+
* @param {string | undefined} scheme - "falcon" or "ecdsa". Defaults to "falcon".
|
|
356
|
+
* @param {object} wasm - The WASM module.
|
|
357
|
+
* @returns {number} The AuthScheme enum value.
|
|
367
358
|
*/
|
|
368
359
|
function resolveAuthScheme(scheme, wasm) {
|
|
369
360
|
if (scheme === "ecdsa") {
|
|
370
|
-
return wasm
|
|
361
|
+
return wasm.AuthScheme.AuthEcdsaK256Keccak;
|
|
371
362
|
}
|
|
372
363
|
if (scheme === "falcon" || scheme == null) {
|
|
373
|
-
return wasm
|
|
364
|
+
return wasm.AuthScheme.AuthRpoFalcon512;
|
|
374
365
|
}
|
|
375
366
|
throw new Error(
|
|
376
367
|
`Unknown auth scheme: "${scheme}". Expected "falcon" or "ecdsa".`
|
|
@@ -554,12 +545,21 @@ class AccountsResource {
|
|
|
554
545
|
const authComponent =
|
|
555
546
|
wasm.AccountComponent.createAuthComponentFromSecretKey(opts.auth);
|
|
556
547
|
|
|
548
|
+
// Schema commitment from `build()` is not a substitute for contract code; require explicit
|
|
549
|
+
// `components` so auth-only contracts are rejected at this layer.
|
|
550
|
+
const components = opts.components ?? [];
|
|
551
|
+
if (components.length === 0) {
|
|
552
|
+
throw new Error(
|
|
553
|
+
"Contract accounts require at least one non-auth procedure: pass at least one entry in `components`."
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
557
|
let builder = new wasm.AccountBuilder(opts.seed)
|
|
558
558
|
.accountType(accountTypeEnum)
|
|
559
559
|
.storageMode(storageMode)
|
|
560
560
|
.withAuthComponent(authComponent);
|
|
561
561
|
|
|
562
|
-
for (const component of
|
|
562
|
+
for (const component of components) {
|
|
563
563
|
builder = builder.withComponent(component);
|
|
564
564
|
}
|
|
565
565
|
|
|
@@ -601,7 +601,9 @@ class AccountsResource {
|
|
|
601
601
|
if (!account) {
|
|
602
602
|
throw new Error(`Account not found: ${id.toString()}`);
|
|
603
603
|
}
|
|
604
|
-
const keys =
|
|
604
|
+
const keys = this.#inner.keystore
|
|
605
|
+
? await this.#inner.keystore.getCommitments(id)
|
|
606
|
+
: await this.#inner.getPublicKeyCommitmentsOfAccount(id);
|
|
605
607
|
return {
|
|
606
608
|
account,
|
|
607
609
|
vault: account.vault(),
|
|
@@ -616,7 +618,7 @@ class AccountsResource {
|
|
|
616
618
|
const wasm = await this.#getWasm();
|
|
617
619
|
const accountId = resolveAccountRef(accountRef, wasm);
|
|
618
620
|
const faucetId = resolveAccountRef(tokenRef, wasm);
|
|
619
|
-
const reader = this.#inner.accountReader(accountId);
|
|
621
|
+
const reader = await this.#inner.accountReader(accountId);
|
|
620
622
|
return await reader.getBalance(faucetId);
|
|
621
623
|
}
|
|
622
624
|
|
|
@@ -1209,13 +1211,8 @@ class TransactionsResource {
|
|
|
1209
1211
|
async #submitOrSubmitWithProver(accountId, request, perCallProver) {
|
|
1210
1212
|
const result = await this.#inner.executeTransaction(accountId, request);
|
|
1211
1213
|
const prover = perCallProver ?? this.#client.defaultProver;
|
|
1212
|
-
// Use proveTransactionWithProver (by-reference) when a prover is
|
|
1213
|
-
// provided, so the JS-side handle is NOT consumed by wasm-bindgen.
|
|
1214
|
-
// Passing the prover by value would transfer ownership and invalidate
|
|
1215
|
-
// the JS object after one call, causing silent fallback to local
|
|
1216
|
-
// proving on reuse.
|
|
1217
1214
|
const proven = prover
|
|
1218
|
-
? await this.#inner.
|
|
1215
|
+
? await this.#inner.proveTransaction(result, prover)
|
|
1219
1216
|
: await this.#inner.proveTransaction(result);
|
|
1220
1217
|
const txId = result.id();
|
|
1221
1218
|
const height = await this.#inner.submitProvenTransaction(proven, result);
|
|
@@ -1426,7 +1423,7 @@ class CompilerResource {
|
|
|
1426
1423
|
async component({ code, slots = [], supportAllTypes = true }) {
|
|
1427
1424
|
this.#client?.assertNotTerminated();
|
|
1428
1425
|
const wasm = await this.#getWasm();
|
|
1429
|
-
const builder = this.#inner.createCodeBuilder();
|
|
1426
|
+
const builder = await this.#inner.createCodeBuilder();
|
|
1430
1427
|
const compiled = builder.compileAccountComponentCode(code);
|
|
1431
1428
|
const component = wasm.AccountComponent.compile(compiled, slots);
|
|
1432
1429
|
return supportAllTypes ? component.withSupportsAllTypes() : component;
|
|
@@ -1442,7 +1439,7 @@ class CompilerResource {
|
|
|
1442
1439
|
this.#client?.assertNotTerminated();
|
|
1443
1440
|
// Ensure WASM is initialized (result unused — only #inner needs it)
|
|
1444
1441
|
await this.#getWasm();
|
|
1445
|
-
const builder = this.#inner.createCodeBuilder();
|
|
1442
|
+
const builder = await this.#inner.createCodeBuilder();
|
|
1446
1443
|
linkLibraries(builder, libraries);
|
|
1447
1444
|
return builder.compileTxScript(code);
|
|
1448
1445
|
}
|
|
@@ -1456,7 +1453,7 @@ class CompilerResource {
|
|
|
1456
1453
|
async noteScript({ code, libraries = [] }) {
|
|
1457
1454
|
this.#client?.assertNotTerminated();
|
|
1458
1455
|
await this.#getWasm();
|
|
1459
|
-
const builder = this.#inner.createCodeBuilder();
|
|
1456
|
+
const builder = await this.#inner.createCodeBuilder();
|
|
1460
1457
|
linkLibraries(builder, libraries);
|
|
1461
1458
|
return builder.compileNoteScript(code);
|
|
1462
1459
|
}
|
|
@@ -1492,32 +1489,47 @@ class KeystoreResource {
|
|
|
1492
1489
|
|
|
1493
1490
|
async insert(accountId, secretKey) {
|
|
1494
1491
|
this.#client.assertNotTerminated();
|
|
1495
|
-
|
|
1496
|
-
|
|
1492
|
+
if (this.#inner.keystore) {
|
|
1493
|
+
return await this.#inner.keystore.insert(accountId, secretKey);
|
|
1494
|
+
}
|
|
1495
|
+
return await this.#inner.addAccountSecretKeyToWebStore(
|
|
1496
|
+
accountId,
|
|
1497
|
+
secretKey
|
|
1498
|
+
);
|
|
1497
1499
|
}
|
|
1498
1500
|
|
|
1499
1501
|
async get(pubKeyCommitment) {
|
|
1500
1502
|
this.#client.assertNotTerminated();
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
+
if (this.#inner.keystore) {
|
|
1504
|
+
return await this.#inner.keystore.get(pubKeyCommitment);
|
|
1505
|
+
}
|
|
1506
|
+
return await this.#inner.getAccountAuthByPubKeyCommitment(pubKeyCommitment);
|
|
1503
1507
|
}
|
|
1504
1508
|
|
|
1505
1509
|
async remove(pubKeyCommitment) {
|
|
1506
1510
|
this.#client.assertNotTerminated();
|
|
1507
|
-
|
|
1508
|
-
|
|
1511
|
+
if (this.#inner.keystore) {
|
|
1512
|
+
return await this.#inner.keystore.remove(pubKeyCommitment);
|
|
1513
|
+
}
|
|
1514
|
+
throw new Error("remove() is not supported on this platform");
|
|
1509
1515
|
}
|
|
1510
1516
|
|
|
1511
1517
|
async getCommitments(accountId) {
|
|
1512
1518
|
this.#client.assertNotTerminated();
|
|
1513
|
-
|
|
1514
|
-
|
|
1519
|
+
if (this.#inner.keystore) {
|
|
1520
|
+
return await this.#inner.keystore.getCommitments(accountId);
|
|
1521
|
+
}
|
|
1522
|
+
return await this.#inner.getPublicKeyCommitmentsOfAccount(accountId);
|
|
1515
1523
|
}
|
|
1516
1524
|
|
|
1517
1525
|
async getAccountId(pubKeyCommitment) {
|
|
1518
1526
|
this.#client.assertNotTerminated();
|
|
1519
|
-
|
|
1520
|
-
|
|
1527
|
+
if (this.#inner.keystore) {
|
|
1528
|
+
return await this.#inner.keystore.getAccountId(pubKeyCommitment);
|
|
1529
|
+
}
|
|
1530
|
+
const account =
|
|
1531
|
+
await this.#inner.getAccountByKeyCommitment(pubKeyCommitment);
|
|
1532
|
+
return account ? account.id() : undefined;
|
|
1521
1533
|
}
|
|
1522
1534
|
}
|
|
1523
1535
|
|
|
@@ -1590,14 +1602,16 @@ class MidenClient {
|
|
|
1590
1602
|
options?.storeName,
|
|
1591
1603
|
options.keystore.getKey,
|
|
1592
1604
|
options.keystore.insertKey,
|
|
1593
|
-
options.keystore.sign
|
|
1605
|
+
options.keystore.sign,
|
|
1606
|
+
options?.debugMode
|
|
1594
1607
|
);
|
|
1595
1608
|
} else {
|
|
1596
1609
|
inner = await WebClientClass.createClient(
|
|
1597
1610
|
rpcUrl,
|
|
1598
1611
|
noteTransportUrl,
|
|
1599
1612
|
seed,
|
|
1600
|
-
options?.storeName
|
|
1613
|
+
options?.storeName,
|
|
1614
|
+
options?.debugMode
|
|
1601
1615
|
);
|
|
1602
1616
|
}
|
|
1603
1617
|
|
|
@@ -1654,32 +1668,6 @@ class MidenClient {
|
|
|
1654
1668
|
});
|
|
1655
1669
|
}
|
|
1656
1670
|
|
|
1657
|
-
/**
|
|
1658
|
-
* Resolves once the WASM module is initialized and safe to use.
|
|
1659
|
-
*
|
|
1660
|
-
* Idempotent and shared across callers: the underlying loader memoizes the
|
|
1661
|
-
* in-flight promise, so concurrent `ready()` calls await the same
|
|
1662
|
-
* initialization and post-init callers resolve immediately from a cached
|
|
1663
|
-
* module. Safe to call from `MidenProvider`, tutorial helpers, and any
|
|
1664
|
-
* other consumer simultaneously.
|
|
1665
|
-
*
|
|
1666
|
-
* Useful on the `/lazy` entry (e.g. Next.js / Capacitor), where no
|
|
1667
|
-
* top-level await runs at import time. On the default (eager) entry this
|
|
1668
|
-
* is redundant — importing the module already awaits WASM — but calling it
|
|
1669
|
-
* is still harmless.
|
|
1670
|
-
*
|
|
1671
|
-
* @returns {Promise<void>} Resolves when WASM is initialized.
|
|
1672
|
-
*/
|
|
1673
|
-
static async ready() {
|
|
1674
|
-
const getWasm = MidenClient._getWasmOrThrow;
|
|
1675
|
-
if (!getWasm) {
|
|
1676
|
-
throw new Error(
|
|
1677
|
-
"MidenClient not initialized. Import from the SDK package entry point."
|
|
1678
|
-
);
|
|
1679
|
-
}
|
|
1680
|
-
await getWasm();
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
1671
|
/**
|
|
1684
1672
|
* Creates a mock client for testing.
|
|
1685
1673
|
*
|
|
@@ -1736,54 +1724,6 @@ class MidenClient {
|
|
|
1736
1724
|
return await this.#inner.getSyncHeight();
|
|
1737
1725
|
}
|
|
1738
1726
|
|
|
1739
|
-
/**
|
|
1740
|
-
* Resolves once every serialized WASM call that was already on the
|
|
1741
|
-
* internal `_serializeWasmCall` chain when `waitForIdle()` was called
|
|
1742
|
-
* (execute, submit, prove, apply, sync, or account creation) has
|
|
1743
|
-
* settled. Use this from callers that need to perform a non-WASM-side
|
|
1744
|
-
* action — e.g. clearing an in-memory auth key on wallet lock — after
|
|
1745
|
-
* the kernel finishes, so its auth callback doesn't race with the key
|
|
1746
|
-
* being cleared.
|
|
1747
|
-
*
|
|
1748
|
-
* Does NOT wait for calls enqueued after `waitForIdle()` returns —
|
|
1749
|
-
* intentional, so a caller can drain and proceed without being blocked
|
|
1750
|
-
* indefinitely by concurrent workload.
|
|
1751
|
-
*
|
|
1752
|
-
* Caveat for `syncState`: `syncStateWithTimeout` awaits the sync lock
|
|
1753
|
-
* (`acquireSyncLock`, which uses Web Locks) BEFORE putting its WASM
|
|
1754
|
-
* call onto the chain, so a `syncState` that is queued on the sync
|
|
1755
|
-
* lock — but has not yet begun its WASM phase — is not visible to
|
|
1756
|
-
* `waitForIdle` and will not be awaited. Other methods (`newWallet`,
|
|
1757
|
-
* `executeTransaction`, etc.) route through the chain synchronously
|
|
1758
|
-
* on call and are always observed.
|
|
1759
|
-
*
|
|
1760
|
-
* Safe to call at any time; returns immediately if nothing was in
|
|
1761
|
-
* flight.
|
|
1762
|
-
*
|
|
1763
|
-
* @returns {Promise<void>}
|
|
1764
|
-
*/
|
|
1765
|
-
async waitForIdle() {
|
|
1766
|
-
this.assertNotTerminated();
|
|
1767
|
-
await this.#inner.waitForIdle();
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
/**
|
|
1771
|
-
* Returns the raw JS value that the most recent sign-callback invocation
|
|
1772
|
-
* threw, or `null` if the last sign call succeeded (or no call has
|
|
1773
|
-
* happened yet).
|
|
1774
|
-
*
|
|
1775
|
-
* Useful for recovering structured metadata (e.g. a `reason: 'locked'`
|
|
1776
|
-
* property) that the kernel-level `auth::request` diagnostic would
|
|
1777
|
-
* otherwise erase. Call immediately after catching a failed
|
|
1778
|
-
* `transactions.submit` / `transactions.send` / `transactions.consume`.
|
|
1779
|
-
*
|
|
1780
|
-
* @returns {any} The raw thrown value, or `null`.
|
|
1781
|
-
*/
|
|
1782
|
-
lastAuthError() {
|
|
1783
|
-
this.assertNotTerminated();
|
|
1784
|
-
return this.#inner.lastAuthError();
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
1727
|
/**
|
|
1788
1728
|
* Terminates the underlying Web Worker. After this, all method calls will throw.
|
|
1789
1729
|
*/
|
|
@@ -1805,9 +1745,9 @@ class MidenClient {
|
|
|
1805
1745
|
*
|
|
1806
1746
|
* @returns {string} The store identifier.
|
|
1807
1747
|
*/
|
|
1808
|
-
storeIdentifier() {
|
|
1748
|
+
async storeIdentifier() {
|
|
1809
1749
|
this.assertNotTerminated();
|
|
1810
|
-
return this.#inner.storeIdentifier();
|
|
1750
|
+
return await this.#inner.storeIdentifier();
|
|
1811
1751
|
}
|
|
1812
1752
|
|
|
1813
1753
|
// ── Mock-only methods ──
|
|
@@ -2021,55 +1961,337 @@ function buildNoteAssets(assets, wasm) {
|
|
|
2021
1961
|
}
|
|
2022
1962
|
|
|
2023
1963
|
/**
|
|
2024
|
-
*
|
|
1964
|
+
* StorageView wraps the raw WASM AccountStorage to provide a developer-friendly
|
|
1965
|
+
* (and AI-agent-friendly) API.
|
|
2025
1966
|
*
|
|
2026
|
-
*
|
|
2027
|
-
*
|
|
2028
|
-
*
|
|
2029
|
-
*
|
|
2030
|
-
* is unchanged so the JS object looks fine, but any subsequent method call
|
|
2031
|
-
* panics inside WASM with the opaque `"null pointer passed to rust"`
|
|
2032
|
-
* error from wasm-bindgen.
|
|
1967
|
+
* Key behavior: `getItem()` returns a `StorageResult` that works intuitively for
|
|
1968
|
+
* both Value and StorageMap slots. The result has `.toBigInt()`, `.toHex()`, and
|
|
1969
|
+
* `.toString()` methods that do the right thing automatically. For StorageMap slots,
|
|
1970
|
+
* `.entries` provides access to all map entries.
|
|
2033
1971
|
*
|
|
2034
|
-
*
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2037
|
-
*
|
|
2038
|
-
* clones — leaving the originals fully usable afterwards.
|
|
1972
|
+
* Numeric ergonomics: `StorageResult` is usable directly in template strings,
|
|
1973
|
+
* JSX, and arithmetic via `toString()` (lossless, BigInt-backed) and `valueOf()`
|
|
1974
|
+
* (returns a JS number for values that fit, throws on overflow — never silently
|
|
1975
|
+
* corrupts). For exact u64 access use `.toBigInt()`.
|
|
2039
1976
|
*
|
|
2040
|
-
* The
|
|
2041
|
-
*
|
|
2042
|
-
* methods) keep working transparently.
|
|
1977
|
+
* The raw WASM AccountStorage is still accessible via `.raw` for advanced use cases
|
|
1978
|
+
* that need the original behavior (e.g., comparing map commitment roots).
|
|
2043
1979
|
*/
|
|
1980
|
+
/** @param {string} hex @param {typeof Word} WordClass @returns {Word | undefined} */
|
|
1981
|
+
function hexToWord(hex, WordClass) {
|
|
1982
|
+
if (!hex || !WordClass) return undefined;
|
|
1983
|
+
try {
|
|
1984
|
+
return WordClass.fromHex(hex);
|
|
1985
|
+
} catch {
|
|
1986
|
+
return undefined;
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
2044
1989
|
|
|
1990
|
+
class StorageView {
|
|
1991
|
+
#storage;
|
|
1992
|
+
#WordClass;
|
|
2045
1993
|
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
1994
|
+
/**
|
|
1995
|
+
* @param {AccountStorage} wasmStorage
|
|
1996
|
+
* @param {typeof Word} WordClass
|
|
1997
|
+
*/
|
|
1998
|
+
constructor(wasmStorage, WordClass) {
|
|
1999
|
+
this.#storage = wasmStorage;
|
|
2000
|
+
this.#WordClass = WordClass;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
/**
|
|
2004
|
+
* The raw WASM AccountStorage, for cases where you need the original
|
|
2005
|
+
* primitive behavior (e.g., reading map commitment roots via raw.getItem()).
|
|
2006
|
+
*/
|
|
2007
|
+
get raw() {
|
|
2008
|
+
return this.#storage;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* Returns the commitment to the full account storage.
|
|
2013
|
+
*/
|
|
2014
|
+
commitment() {
|
|
2015
|
+
return this.#storage.commitment();
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
/**
|
|
2019
|
+
* Returns the names of all storage slots on this account.
|
|
2020
|
+
* @returns {string[]}
|
|
2021
|
+
*/
|
|
2022
|
+
getSlotNames() {
|
|
2023
|
+
return this.#storage.getSlotNames();
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
/**
|
|
2027
|
+
* Returns a StorageResult for the given slot.
|
|
2028
|
+
*
|
|
2029
|
+
* The result has convenience methods that work for both Value and StorageMap slots:
|
|
2030
|
+
* - `.toBigInt()` — first felt as BigInt (full u64 precision)
|
|
2031
|
+
* - `.toHex()` — first felt's Word as hex string
|
|
2032
|
+
* - `.toString()` — renders as the BigInt value (works in JSX: {result})
|
|
2033
|
+
* - `.isMap` — true if this is a StorageMap slot
|
|
2034
|
+
* - `.entries` — all map entries (undefined for Value slots)
|
|
2035
|
+
* - `.word` — the underlying Word value
|
|
2036
|
+
*
|
|
2037
|
+
* The result is also usable directly in arithmetic (`+result`, `result * 2`)
|
|
2038
|
+
* via `valueOf()`, which returns a JS number for values that fit and throws
|
|
2039
|
+
* `RangeError` for values exceeding `Number.MAX_SAFE_INTEGER` — use `.toBigInt()`
|
|
2040
|
+
* for exact access to large u64 values.
|
|
2041
|
+
*
|
|
2042
|
+
* For explicit key-based map reads, use `getMapItem(slotName, key)`.
|
|
2043
|
+
* For the raw commitment hash, use `raw.getItem(slotName)`.
|
|
2044
|
+
*
|
|
2045
|
+
* @param {string} slotName
|
|
2046
|
+
* @returns {StorageResult | undefined}
|
|
2047
|
+
*/
|
|
2048
|
+
getItem(slotName) {
|
|
2049
|
+
// Type detection + value retrieval in one pass.
|
|
2050
|
+
// We call getMapEntries to detect maps, but defer parsing the entries
|
|
2051
|
+
// until .entries is actually accessed (lazy). Only the first entry's
|
|
2052
|
+
// Word is parsed eagerly for the convenience methods (toBigInt, etc.).
|
|
2053
|
+
const rawEntries = this.#storage.getMapEntries(slotName);
|
|
2054
|
+
if (rawEntries !== undefined && rawEntries !== null) {
|
|
2055
|
+
// StorageMap — parse only the first entry eagerly
|
|
2056
|
+
const firstWord =
|
|
2057
|
+
rawEntries.length > 0
|
|
2058
|
+
? hexToWord(rawEntries[0].value, this.#WordClass)
|
|
2059
|
+
: undefined;
|
|
2060
|
+
return new StorageResult(firstWord, true, rawEntries, this.#WordClass);
|
|
2056
2061
|
}
|
|
2057
|
-
|
|
2062
|
+
|
|
2063
|
+
// Value slot — use raw getItem
|
|
2064
|
+
const word = this.#storage.getItem(slotName);
|
|
2065
|
+
if (!word) return undefined;
|
|
2066
|
+
return new StorageResult(word, false, undefined, this.#WordClass);
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
/**
|
|
2070
|
+
* Returns the value for a key in a StorageMap slot.
|
|
2071
|
+
* Delegates directly to the raw WASM method.
|
|
2072
|
+
*
|
|
2073
|
+
* @param {string} slotName
|
|
2074
|
+
* @param {Word} key
|
|
2075
|
+
* @returns {Word | undefined}
|
|
2076
|
+
*/
|
|
2077
|
+
getMapItem(slotName, key) {
|
|
2078
|
+
return this.#storage.getMapItem(slotName, key);
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
/**
|
|
2082
|
+
* Get all key-value pairs from a StorageMap slot.
|
|
2083
|
+
* Returns undefined if the slot isn't a map, or an empty array if the map is empty.
|
|
2084
|
+
*/
|
|
2085
|
+
getMapEntries(slotName) {
|
|
2086
|
+
return this.#storage.getMapEntries(slotName);
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
/**
|
|
2090
|
+
* Returns the commitment root of a storage slot as a Word.
|
|
2091
|
+
*
|
|
2092
|
+
* For Value slots, this is the stored Word itself.
|
|
2093
|
+
* For StorageMap slots, this is the Merkle root hash of the map — useful for:
|
|
2094
|
+
* - Verifying state hasn't changed between transactions
|
|
2095
|
+
* - Merkle inclusion proofs against the account state
|
|
2096
|
+
* - Comparing map state across accounts or sync cycles
|
|
2097
|
+
*
|
|
2098
|
+
* This is the raw protocol-level value. For reading stored data, use `getItem()`.
|
|
2099
|
+
*
|
|
2100
|
+
* @param {string} slotName
|
|
2101
|
+
* @returns {Word | undefined}
|
|
2102
|
+
*/
|
|
2103
|
+
getCommitment(slotName) {
|
|
2104
|
+
return this.#storage.getItem(slotName);
|
|
2105
|
+
}
|
|
2058
2106
|
}
|
|
2059
2107
|
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2108
|
+
/**
|
|
2109
|
+
* Result of reading a storage slot. Works for both Value and StorageMap slots.
|
|
2110
|
+
*
|
|
2111
|
+
* Provides a unified interface so code like `storage.getItem(name).toBigInt()`
|
|
2112
|
+
* works regardless of the underlying slot type.
|
|
2113
|
+
*
|
|
2114
|
+
* For StorageMap slots, the convenience methods (toHex, toBigInt) operate on
|
|
2115
|
+
* the first entry's value. The full map data is available via `.entries`.
|
|
2116
|
+
* Note: Miden storage maps are Merkle-based, so "first" is determined by key hash
|
|
2117
|
+
* order — deterministic for a given map state, but not meaningful as an ordering.
|
|
2118
|
+
*/
|
|
2119
|
+
class StorageResult {
|
|
2120
|
+
#word;
|
|
2121
|
+
#isMap;
|
|
2122
|
+
#rawEntries; // Raw JsStorageMapEntry[] from WASM — parsed lazily
|
|
2123
|
+
#parsedEntries; // Parsed entries with Word objects — created on first .entries access
|
|
2124
|
+
#WordClass;
|
|
2125
|
+
|
|
2126
|
+
/**
|
|
2127
|
+
* @param {Word | undefined} word — the primary Word value (first entry for maps)
|
|
2128
|
+
* @param {boolean} isMap — whether this came from a StorageMap slot
|
|
2129
|
+
* @param {Array | undefined} rawEntries — raw WASM entries (parsed lazily on .entries access)
|
|
2130
|
+
* @param {typeof Word} WordClass — Word constructor for hex parsing
|
|
2131
|
+
*/
|
|
2132
|
+
constructor(word, isMap, rawEntries, WordClass) {
|
|
2133
|
+
this.#word = word;
|
|
2134
|
+
this.#isMap = isMap;
|
|
2135
|
+
this.#rawEntries = rawEntries;
|
|
2136
|
+
this.#WordClass = WordClass;
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
/** True if this slot is a StorageMap. */
|
|
2140
|
+
get isMap() {
|
|
2141
|
+
return this.#isMap;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
/**
|
|
2145
|
+
* All entries from a StorageMap slot (lazily parsed on first access).
|
|
2146
|
+
* Each entry has { key: string (hex), value: string (hex), word: Word | undefined }.
|
|
2147
|
+
* Returns undefined for Value slots.
|
|
2148
|
+
*/
|
|
2149
|
+
get entries() {
|
|
2150
|
+
if (!this.#isMap) return undefined;
|
|
2151
|
+
if (this.#parsedEntries) return this.#parsedEntries;
|
|
2152
|
+
if (!this.#rawEntries) return [];
|
|
2153
|
+
|
|
2154
|
+
// Parse entries lazily — only when the user actually accesses .entries
|
|
2155
|
+
this.#parsedEntries = this.#rawEntries.map((e) => ({
|
|
2156
|
+
key: e.key,
|
|
2157
|
+
value: e.value,
|
|
2158
|
+
word: hexToWord(e.value, this.#WordClass),
|
|
2159
|
+
}));
|
|
2160
|
+
this.#rawEntries = undefined; // Free raw entries
|
|
2161
|
+
return this.#parsedEntries;
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
/**
|
|
2165
|
+
* The underlying Word value.
|
|
2166
|
+
* For Value slots: the stored Word.
|
|
2167
|
+
* For StorageMap slots: the first entry's value as a Word (or undefined if empty).
|
|
2168
|
+
*/
|
|
2169
|
+
get word() {
|
|
2170
|
+
return this.#word;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
/**
|
|
2174
|
+
* Returns all four Felts of the stored Word as an array.
|
|
2175
|
+
* Pass-through to Word.toFelts() — ensures code that expects a Word-like
|
|
2176
|
+
* object (e.g., `result.toFelts()[0].asInt()`) works on StorageResult.
|
|
2177
|
+
* @returns {Felt[]}
|
|
2178
|
+
*/
|
|
2179
|
+
toFelts() {
|
|
2180
|
+
if (!this.#word) return [];
|
|
2181
|
+
return this.#word.toFelts();
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
/**
|
|
2185
|
+
* The first Felt of the stored Word.
|
|
2186
|
+
* Returns the WASM Felt object — use .asInt() to get its BigInt value.
|
|
2187
|
+
* @returns {Felt | undefined}
|
|
2188
|
+
*/
|
|
2189
|
+
felt() {
|
|
2190
|
+
if (!this.#word) return undefined;
|
|
2191
|
+
const felts = this.#word.toFelts();
|
|
2192
|
+
return felts?.[0];
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* First felt as a BigInt. Preserves full u64 precision.
|
|
2197
|
+
* @returns {bigint}
|
|
2198
|
+
*/
|
|
2199
|
+
toBigInt() {
|
|
2200
|
+
if (!this.#word) return 0n;
|
|
2201
|
+
return wordToBigInt(this.#word);
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
/**
|
|
2205
|
+
* The Word's hex representation.
|
|
2206
|
+
* For Value slots: the stored Word hex.
|
|
2207
|
+
* For StorageMap slots: the first entry's value Word hex.
|
|
2208
|
+
* @returns {string}
|
|
2209
|
+
*/
|
|
2210
|
+
toHex() {
|
|
2211
|
+
if (!this.#word) return "0x" + "0".repeat(64);
|
|
2212
|
+
return this.#word.toHex();
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
/**
|
|
2216
|
+
* Renders as the BigInt value (lossless). Makes `{storageResult}` work in JSX
|
|
2217
|
+
* and template literals: `` `value: ${result}` ``.
|
|
2218
|
+
* @returns {string}
|
|
2219
|
+
*/
|
|
2220
|
+
toString() {
|
|
2221
|
+
return this.toBigInt().toString();
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
/**
|
|
2225
|
+
* JSON serialization — returns the value as a string to avoid
|
|
2226
|
+
* precision loss for large u64 felt values.
|
|
2227
|
+
*/
|
|
2228
|
+
toJSON() {
|
|
2229
|
+
return this.toBigInt().toString();
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
/**
|
|
2233
|
+
* Allows `+result`, `result * 2`, etc. to work as expected.
|
|
2234
|
+
*
|
|
2235
|
+
* Returns a JS number for values that fit in `Number.MAX_SAFE_INTEGER`
|
|
2236
|
+
* (2^53 - 1). For larger u64 values, throws `RangeError` rather than
|
|
2237
|
+
* silently losing precision — use `.toBigInt()` to access the exact value.
|
|
2238
|
+
*
|
|
2239
|
+
* @returns {number}
|
|
2240
|
+
* @throws {RangeError} if the underlying felt exceeds Number.MAX_SAFE_INTEGER
|
|
2241
|
+
*/
|
|
2242
|
+
valueOf() {
|
|
2243
|
+
const big = this.toBigInt();
|
|
2244
|
+
if (big > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
2245
|
+
throw new RangeError(
|
|
2246
|
+
`StorageResult value ${big} exceeds Number.MAX_SAFE_INTEGER ` +
|
|
2247
|
+
`(${Number.MAX_SAFE_INTEGER}) — use .toBigInt() to read the exact value.`
|
|
2248
|
+
);
|
|
2249
|
+
}
|
|
2250
|
+
return Number(big);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
/**
|
|
2255
|
+
* Convert a Word's first felt to a BigInt.
|
|
2256
|
+
* Uses BigInt to preserve full u64 precision (felts are u64-backed).
|
|
2257
|
+
* Handles the little-endian byte order of felt serialization.
|
|
2258
|
+
*
|
|
2259
|
+
* @param {Word} word
|
|
2260
|
+
* @returns {bigint}
|
|
2261
|
+
*/
|
|
2262
|
+
function wordToBigInt(word) {
|
|
2263
|
+
try {
|
|
2264
|
+
const hex = word.toHex();
|
|
2265
|
+
// Word.toHex() returns "0x" + 64 hex chars (4 felts × 16 hex chars each).
|
|
2266
|
+
// Each felt is serialized as 8 little-endian bytes, so we take the first 16
|
|
2267
|
+
// hex chars (first felt) and reverse the byte pairs to get the integer value.
|
|
2268
|
+
const feltHex = hex.slice(2, 18);
|
|
2269
|
+
const bytes = feltHex.match(/../g);
|
|
2270
|
+
if (!bytes) return 0n;
|
|
2271
|
+
return BigInt("0x" + bytes.reverse().join(""));
|
|
2272
|
+
} catch {
|
|
2273
|
+
return 0n;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
/**
|
|
2278
|
+
* Install the StorageView wrapper on Account.prototype.storage().
|
|
2279
|
+
* After this, `account.storage()` returns a StorageView instead of raw AccountStorage.
|
|
2280
|
+
*
|
|
2281
|
+
* @param {object} wasmModule — the loaded WASM module containing Account, Word, etc.
|
|
2282
|
+
*/
|
|
2283
|
+
function installStorageView(wasmModule) {
|
|
2284
|
+
const AccountProto = wasmModule.Account?.prototype;
|
|
2285
|
+
if (!AccountProto || !AccountProto.storage) return;
|
|
2286
|
+
|
|
2287
|
+
const originalStorage = AccountProto.storage;
|
|
2288
|
+
const WordClass = wasmModule.Word;
|
|
2289
|
+
|
|
2290
|
+
AccountProto.storage = function () {
|
|
2291
|
+
const raw = originalStorage.call(this);
|
|
2292
|
+
return new StorageView(raw, WordClass);
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2073
2295
|
|
|
2074
2296
|
const AccountType = Object.freeze({
|
|
2075
2297
|
// WASM-compatible numeric values — usable with AccountBuilder directly
|
|
@@ -2105,43 +2327,6 @@ const Linking = Object.freeze({
|
|
|
2105
2327
|
Static: "static",
|
|
2106
2328
|
});
|
|
2107
2329
|
|
|
2108
|
-
// Method classification sets — used by scripts/check-method-classification.js to ensure
|
|
2109
|
-
// every WASM export is explicitly categorised. Update when adding new WASM methods.
|
|
2110
|
-
//
|
|
2111
|
-
// Note on `SYNC_METHODS`: the classifier is "synchronous in JS" — i.e.
|
|
2112
|
-
// `pub fn ...` in Rust, not `pub async fn ...`. Two sub-cases:
|
|
2113
|
-
// 1. Factory methods that return a non-Promise value (`accountReader`
|
|
2114
|
-
// returns `AccountReader`; the transaction-request builders return
|
|
2115
|
-
// `TransactionRequestBuilder`; `createCodeBuilder` returns a builder).
|
|
2116
|
-
// Wrapping these in `_serializeWasmCall` would turn their return
|
|
2117
|
-
// value into `Promise<T>` and break callers that use the result
|
|
2118
|
-
// immediately (e.g. `const reader = client.accountReader(id);
|
|
2119
|
-
// await reader.nonce();`).
|
|
2120
|
-
// 2. Sync methods that still take `&mut self` in Rust (`proveBlock`,
|
|
2121
|
-
// `serializeMockChain`, `setDebugMode`). Safe to opt out because JS
|
|
2122
|
-
// is single-threaded — the event loop cannot interleave another
|
|
2123
|
-
// call during their synchronous execution, so the RefCell borrow
|
|
2124
|
-
// is always released before any other borrow can start.
|
|
2125
|
-
// Do NOT move a sync-in-JS method into `WRITE_METHODS` / `READ_METHODS`
|
|
2126
|
-
// just because it takes `&mut self` or `&self`; wrapping changes its
|
|
2127
|
-
// return shape and breaks every caller.
|
|
2128
|
-
const SYNC_METHODS = new Set([
|
|
2129
|
-
"accountReader",
|
|
2130
|
-
"buildSwapTag",
|
|
2131
|
-
"createCodeBuilder",
|
|
2132
|
-
"lastAuthError",
|
|
2133
|
-
"newConsumeTransactionRequest",
|
|
2134
|
-
"newMintTransactionRequest",
|
|
2135
|
-
"newSendTransactionRequest",
|
|
2136
|
-
"newSwapTransactionRequest",
|
|
2137
|
-
"proveBlock",
|
|
2138
|
-
"serializeMockChain",
|
|
2139
|
-
"serializeMockNoteTransportNode",
|
|
2140
|
-
"setDebugMode",
|
|
2141
|
-
"storeIdentifier",
|
|
2142
|
-
"usesMockChain",
|
|
2143
|
-
]);
|
|
2144
|
-
|
|
2145
2330
|
const MOCK_STORE_NAME = "mock_client_db";
|
|
2146
2331
|
|
|
2147
2332
|
const buildTypedArraysExport = (exportObject) => {
|
|
@@ -2198,6 +2383,9 @@ const ensureWasm = async () => {
|
|
|
2198
2383
|
}
|
|
2199
2384
|
// Set WASM module for standalone utilities
|
|
2200
2385
|
_setWasm(module);
|
|
2386
|
+
// Install StorageView: account.storage() now returns a developer-friendly
|
|
2387
|
+
// wrapper that makes getItem() work correctly for StorageMap slots.
|
|
2388
|
+
installStorageView(module);
|
|
2201
2389
|
}
|
|
2202
2390
|
return module;
|
|
2203
2391
|
});
|
|
@@ -2242,16 +2430,6 @@ const getWasmOrThrow = async () => {
|
|
|
2242
2430
|
/**
|
|
2243
2431
|
* Create a Proxy that forwards missing properties to the underlying WASM
|
|
2244
2432
|
* WebClient.
|
|
2245
|
-
*
|
|
2246
|
-
* Async proxy-fallback methods (every WASM method that borrows the
|
|
2247
|
-
* WebClient's RefCell — reads included, since `&self` and `&mut self` both
|
|
2248
|
-
* trip wasm-bindgen's "recursive use of an object detected" panic if
|
|
2249
|
-
* another borrow is live) are routed through `_serializeWasmCall` so they
|
|
2250
|
-
* queue on the same chain as the explicitly-wrapped methods.
|
|
2251
|
-
*
|
|
2252
|
-
* `SYNC_METHODS` opts out: they are synchronous in JS and wrapping them
|
|
2253
|
-
* would change their return type to `Promise<T>`, which is a breaking
|
|
2254
|
-
* change for consumers that use them as plain getters or builders.
|
|
2255
2433
|
*/
|
|
2256
2434
|
function createClientProxy(instance) {
|
|
2257
2435
|
return new Proxy(instance, {
|
|
@@ -2262,13 +2440,7 @@ function createClientProxy(instance) {
|
|
|
2262
2440
|
if (target.wasmWebClient && prop in target.wasmWebClient) {
|
|
2263
2441
|
const value = target.wasmWebClient[prop];
|
|
2264
2442
|
if (typeof value === "function") {
|
|
2265
|
-
|
|
2266
|
-
return value.bind(target.wasmWebClient);
|
|
2267
|
-
}
|
|
2268
|
-
return (...args) =>
|
|
2269
|
-
target._serializeWasmCall(() =>
|
|
2270
|
-
value.apply(target.wasmWebClient, args)
|
|
2271
|
-
);
|
|
2443
|
+
return value.bind(target.wasmWebClient);
|
|
2272
2444
|
}
|
|
2273
2445
|
return value;
|
|
2274
2446
|
}
|
|
@@ -2499,13 +2671,6 @@ class WebClient {
|
|
|
2499
2671
|
* Serialize a WASM call that requires exclusive (&mut self) access.
|
|
2500
2672
|
* Concurrent calls are queued and executed one at a time.
|
|
2501
2673
|
*
|
|
2502
|
-
* Wraps both the direct (in-thread) path and the worker-dispatched path.
|
|
2503
|
-
* On the worker path this is redundant with the worker's own message queue,
|
|
2504
|
-
* but harmless (the chain resolves immediately on the main thread once the
|
|
2505
|
-
* worker's postMessage returns). On the direct path it is load-bearing —
|
|
2506
|
-
* without it, concurrent main-thread callers would panic with
|
|
2507
|
-
* "recursive use of an object detected" (wasm-bindgen's internal RefCell).
|
|
2508
|
-
*
|
|
2509
2674
|
* @param {() => Promise<any>} fn - The async function to execute.
|
|
2510
2675
|
* @returns {Promise<any>} The result of fn.
|
|
2511
2676
|
*/
|
|
@@ -2515,35 +2680,6 @@ class WebClient {
|
|
|
2515
2680
|
return result;
|
|
2516
2681
|
}
|
|
2517
2682
|
|
|
2518
|
-
/**
|
|
2519
|
-
* Returns a promise that resolves once every serialized WASM call that
|
|
2520
|
-
* was already on `_wasmCallChain` when `waitForIdle()` was called has
|
|
2521
|
-
* settled. Use this from callers that need to perform a non-WASM-side
|
|
2522
|
-
* action (e.g. clear an in-memory auth key) AFTER any in-flight
|
|
2523
|
-
* execute / submit / sync has completed, so the WASM kernel's auth
|
|
2524
|
-
* callback doesn't race with the key being cleared.
|
|
2525
|
-
*
|
|
2526
|
-
* Does NOT wait for calls enqueued after `waitForIdle()` returns —
|
|
2527
|
-
* this is intentional, so a caller can drain and then proceed without
|
|
2528
|
-
* being blocked indefinitely by a concurrent workload.
|
|
2529
|
-
*
|
|
2530
|
-
* Caveat for `syncState`: `syncStateWithTimeout` awaits
|
|
2531
|
-
* `acquireSyncLock` (Web Locks) BEFORE wrapping its WASM call in
|
|
2532
|
-
* `_serializeWasmCall`, so a sync that is queued on the sync lock but
|
|
2533
|
-
* has not yet reached its WASM phase is not on the chain and will not
|
|
2534
|
-
* be awaited. Every other serialized method (`executeTransaction`,
|
|
2535
|
-
* `newWallet`, `submitNewTransaction`, `proveTransaction`,
|
|
2536
|
-
* `applyTransaction`, and the proxy-fallback reads) routes through
|
|
2537
|
-
* the chain synchronously on call and is always observed.
|
|
2538
|
-
*
|
|
2539
|
-
* @returns {Promise<void>}
|
|
2540
|
-
*/
|
|
2541
|
-
async waitForIdle() {
|
|
2542
|
-
// Chain on `_wasmCallChain`; by the time this resolves, any in-flight
|
|
2543
|
-
// serialized call has settled. Catch so the chain state doesn't leak.
|
|
2544
|
-
await this._wasmCallChain.catch(() => {});
|
|
2545
|
-
}
|
|
2546
|
-
|
|
2547
2683
|
// TODO: This will soon conflict with some changes in main.
|
|
2548
2684
|
// More context here:
|
|
2549
2685
|
// https://github.com/0xMiden/miden-client/pull/1645?notification_referrer_id=NT_kwHOA1yg7NoAJVJlcG9zaXRvcnk7NjU5MzQzNzAyO0lzc3VlOzM3OTY4OTU1Nzk¬ifications_query=is%3Aunread#discussion_r2696075480
|
|
@@ -2749,171 +2885,147 @@ class WebClient {
|
|
|
2749
2885
|
}
|
|
2750
2886
|
|
|
2751
2887
|
async submitNewTransaction(accountId, transactionRequest) {
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
transactionRequest
|
|
2759
|
-
);
|
|
2760
|
-
}
|
|
2761
|
-
|
|
2762
|
-
const wasm = await getWasmOrThrow();
|
|
2763
|
-
const serializedTransactionRequest = transactionRequest.serialize();
|
|
2764
|
-
const result = await this.callMethodWithWorker(
|
|
2765
|
-
MethodName.SUBMIT_NEW_TRANSACTION,
|
|
2766
|
-
accountId.toString(),
|
|
2767
|
-
serializedTransactionRequest
|
|
2888
|
+
try {
|
|
2889
|
+
if (!this.worker) {
|
|
2890
|
+
const wasmWebClient = await this.getWasmWebClient();
|
|
2891
|
+
return await wasmWebClient.submitNewTransaction(
|
|
2892
|
+
accountId,
|
|
2893
|
+
transactionRequest
|
|
2768
2894
|
);
|
|
2895
|
+
}
|
|
2769
2896
|
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2897
|
+
const wasm = await getWasmOrThrow();
|
|
2898
|
+
const serializedTransactionRequest = transactionRequest.serialize();
|
|
2899
|
+
const result = await this.callMethodWithWorker(
|
|
2900
|
+
MethodName.SUBMIT_NEW_TRANSACTION,
|
|
2901
|
+
accountId.toString(),
|
|
2902
|
+
serializedTransactionRequest
|
|
2903
|
+
);
|
|
2773
2904
|
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
})
|
|
2905
|
+
const transactionResult = wasm.TransactionResult.deserialize(
|
|
2906
|
+
new Uint8Array(result.serializedTransactionResult)
|
|
2907
|
+
);
|
|
2908
|
+
|
|
2909
|
+
return transactionResult.id();
|
|
2910
|
+
} catch (error) {
|
|
2911
|
+
console.error("INDEX.JS: Error in submitNewTransaction:", error);
|
|
2912
|
+
throw error;
|
|
2913
|
+
}
|
|
2780
2914
|
}
|
|
2781
2915
|
|
|
2782
2916
|
async submitNewTransactionWithProver(accountId, transactionRequest, prover) {
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
prover
|
|
2791
|
-
);
|
|
2792
|
-
}
|
|
2793
|
-
|
|
2794
|
-
const wasm = await getWasmOrThrow();
|
|
2795
|
-
const serializedTransactionRequest = transactionRequest.serialize();
|
|
2796
|
-
const proverPayload = prover.serialize();
|
|
2797
|
-
const result = await this.callMethodWithWorker(
|
|
2798
|
-
MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER,
|
|
2799
|
-
accountId.toString(),
|
|
2800
|
-
serializedTransactionRequest,
|
|
2801
|
-
proverPayload
|
|
2917
|
+
try {
|
|
2918
|
+
if (!this.worker) {
|
|
2919
|
+
const wasmWebClient = await this.getWasmWebClient();
|
|
2920
|
+
return await wasmWebClient.submitNewTransactionWithProver(
|
|
2921
|
+
accountId,
|
|
2922
|
+
transactionRequest,
|
|
2923
|
+
prover
|
|
2802
2924
|
);
|
|
2925
|
+
}
|
|
2803
2926
|
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2927
|
+
const wasm = await getWasmOrThrow();
|
|
2928
|
+
const serializedTransactionRequest = transactionRequest.serialize();
|
|
2929
|
+
const proverPayload = prover.serialize();
|
|
2930
|
+
const result = await this.callMethodWithWorker(
|
|
2931
|
+
MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER,
|
|
2932
|
+
accountId.toString(),
|
|
2933
|
+
serializedTransactionRequest,
|
|
2934
|
+
proverPayload
|
|
2935
|
+
);
|
|
2807
2936
|
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2937
|
+
const transactionResult = wasm.TransactionResult.deserialize(
|
|
2938
|
+
new Uint8Array(result.serializedTransactionResult)
|
|
2939
|
+
);
|
|
2940
|
+
|
|
2941
|
+
return transactionResult.id();
|
|
2942
|
+
} catch (error) {
|
|
2943
|
+
console.error(
|
|
2944
|
+
"INDEX.JS: Error in submitNewTransactionWithProver:",
|
|
2945
|
+
error
|
|
2946
|
+
);
|
|
2947
|
+
throw error;
|
|
2948
|
+
}
|
|
2817
2949
|
}
|
|
2818
2950
|
|
|
2819
2951
|
async executeTransaction(accountId, transactionRequest) {
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
transactionRequest
|
|
2827
|
-
);
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
const wasm = await getWasmOrThrow();
|
|
2831
|
-
const serializedTransactionRequest = transactionRequest.serialize();
|
|
2832
|
-
const serializedResultBytes = await this.callMethodWithWorker(
|
|
2833
|
-
MethodName.EXECUTE_TRANSACTION,
|
|
2834
|
-
accountId.toString(),
|
|
2835
|
-
serializedTransactionRequest
|
|
2836
|
-
);
|
|
2837
|
-
|
|
2838
|
-
return wasm.TransactionResult.deserialize(
|
|
2839
|
-
new Uint8Array(serializedResultBytes)
|
|
2952
|
+
try {
|
|
2953
|
+
if (!this.worker) {
|
|
2954
|
+
const wasmWebClient = await this.getWasmWebClient();
|
|
2955
|
+
return await wasmWebClient.executeTransaction(
|
|
2956
|
+
accountId,
|
|
2957
|
+
transactionRequest
|
|
2840
2958
|
);
|
|
2841
|
-
} catch (error) {
|
|
2842
|
-
console.error("INDEX.JS: Error in executeTransaction:", error);
|
|
2843
|
-
throw error;
|
|
2844
2959
|
}
|
|
2845
|
-
|
|
2960
|
+
|
|
2961
|
+
const wasm = await getWasmOrThrow();
|
|
2962
|
+
const serializedTransactionRequest = transactionRequest.serialize();
|
|
2963
|
+
const serializedResultBytes = await this.callMethodWithWorker(
|
|
2964
|
+
MethodName.EXECUTE_TRANSACTION,
|
|
2965
|
+
accountId.toString(),
|
|
2966
|
+
serializedTransactionRequest
|
|
2967
|
+
);
|
|
2968
|
+
|
|
2969
|
+
return wasm.TransactionResult.deserialize(
|
|
2970
|
+
new Uint8Array(serializedResultBytes)
|
|
2971
|
+
);
|
|
2972
|
+
} catch (error) {
|
|
2973
|
+
console.error("INDEX.JS: Error in executeTransaction:", error);
|
|
2974
|
+
throw error;
|
|
2975
|
+
}
|
|
2846
2976
|
}
|
|
2847
2977
|
|
|
2848
2978
|
async proveTransaction(transactionResult, prover) {
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
? await wasmWebClient.proveTransactionWithProver(
|
|
2855
|
-
transactionResult,
|
|
2856
|
-
prover
|
|
2857
|
-
)
|
|
2858
|
-
: await wasmWebClient.proveTransaction(transactionResult);
|
|
2859
|
-
}
|
|
2860
|
-
|
|
2861
|
-
const wasm = await getWasmOrThrow();
|
|
2862
|
-
const serializedTransactionResult = transactionResult.serialize();
|
|
2863
|
-
const proverPayload = prover ? prover.serialize() : null;
|
|
2979
|
+
try {
|
|
2980
|
+
if (!this.worker) {
|
|
2981
|
+
const wasmWebClient = await this.getWasmWebClient();
|
|
2982
|
+
return await wasmWebClient.proveTransaction(transactionResult, prover);
|
|
2983
|
+
}
|
|
2864
2984
|
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
proverPayload
|
|
2869
|
-
);
|
|
2985
|
+
const wasm = await getWasmOrThrow();
|
|
2986
|
+
const serializedTransactionResult = transactionResult.serialize();
|
|
2987
|
+
const proverPayload = prover ? prover.serialize() : null;
|
|
2870
2988
|
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
throw error;
|
|
2877
|
-
}
|
|
2878
|
-
});
|
|
2879
|
-
}
|
|
2989
|
+
const serializedProvenBytes = await this.callMethodWithWorker(
|
|
2990
|
+
MethodName.PROVE_TRANSACTION,
|
|
2991
|
+
serializedTransactionResult,
|
|
2992
|
+
proverPayload
|
|
2993
|
+
);
|
|
2880
2994
|
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2995
|
+
return wasm.ProvenTransaction.deserialize(
|
|
2996
|
+
new Uint8Array(serializedProvenBytes)
|
|
2997
|
+
);
|
|
2998
|
+
} catch (error) {
|
|
2999
|
+
console.error("INDEX.JS: Error in proveTransaction:", error);
|
|
3000
|
+
throw error;
|
|
3001
|
+
}
|
|
2888
3002
|
}
|
|
2889
3003
|
|
|
2890
3004
|
async applyTransaction(transactionResult, submissionHeight) {
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
transactionResult,
|
|
2897
|
-
submissionHeight
|
|
2898
|
-
);
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2901
|
-
const wasm = await getWasmOrThrow();
|
|
2902
|
-
const serializedTransactionResult = transactionResult.serialize();
|
|
2903
|
-
const serializedUpdateBytes = await this.callMethodWithWorker(
|
|
2904
|
-
MethodName.APPLY_TRANSACTION,
|
|
2905
|
-
serializedTransactionResult,
|
|
3005
|
+
try {
|
|
3006
|
+
if (!this.worker) {
|
|
3007
|
+
const wasmWebClient = await this.getWasmWebClient();
|
|
3008
|
+
return await wasmWebClient.applyTransaction(
|
|
3009
|
+
transactionResult,
|
|
2906
3010
|
submissionHeight
|
|
2907
3011
|
);
|
|
2908
|
-
|
|
2909
|
-
return wasm.TransactionStoreUpdate.deserialize(
|
|
2910
|
-
new Uint8Array(serializedUpdateBytes)
|
|
2911
|
-
);
|
|
2912
|
-
} catch (error) {
|
|
2913
|
-
console.error("INDEX.JS: Error in applyTransaction:", error);
|
|
2914
|
-
throw error;
|
|
2915
3012
|
}
|
|
2916
|
-
|
|
3013
|
+
|
|
3014
|
+
const wasm = await getWasmOrThrow();
|
|
3015
|
+
const serializedTransactionResult = transactionResult.serialize();
|
|
3016
|
+
const serializedUpdateBytes = await this.callMethodWithWorker(
|
|
3017
|
+
MethodName.APPLY_TRANSACTION,
|
|
3018
|
+
serializedTransactionResult,
|
|
3019
|
+
submissionHeight
|
|
3020
|
+
);
|
|
3021
|
+
|
|
3022
|
+
return wasm.TransactionStoreUpdate.deserialize(
|
|
3023
|
+
new Uint8Array(serializedUpdateBytes)
|
|
3024
|
+
);
|
|
3025
|
+
} catch (error) {
|
|
3026
|
+
console.error("INDEX.JS: Error in applyTransaction:", error);
|
|
3027
|
+
throw error;
|
|
3028
|
+
}
|
|
2917
3029
|
}
|
|
2918
3030
|
|
|
2919
3031
|
/**
|
|
@@ -2952,25 +3064,21 @@ class WebClient {
|
|
|
2952
3064
|
return lockHandle.coalescedResult;
|
|
2953
3065
|
}
|
|
2954
3066
|
|
|
2955
|
-
// We acquired the lock - perform the sync
|
|
2956
|
-
// call in _serializeWasmCall so it can't race with any other
|
|
2957
|
-
// mutating method (executeTransaction, submitNewTransaction, etc.)
|
|
2958
|
-
// on the same WebClient. The outer coalescing lock stays in place
|
|
2959
|
-
// so concurrent syncState callers still share one in-flight sync.
|
|
3067
|
+
// We acquired the lock - perform the sync
|
|
2960
3068
|
try {
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
3069
|
+
let result;
|
|
3070
|
+
if (!this.worker) {
|
|
3071
|
+
const wasmWebClient = await this.getWasmWebClient();
|
|
3072
|
+
result = await wasmWebClient.syncStateImpl();
|
|
3073
|
+
} else {
|
|
2966
3074
|
const wasm = await getWasmOrThrow();
|
|
2967
3075
|
const serializedSyncSummaryBytes = await this.callMethodWithWorker(
|
|
2968
3076
|
MethodName.SYNC_STATE
|
|
2969
3077
|
);
|
|
2970
|
-
|
|
3078
|
+
result = wasm.SyncSummary.deserialize(
|
|
2971
3079
|
new Uint8Array(serializedSyncSummaryBytes)
|
|
2972
3080
|
);
|
|
2973
|
-
}
|
|
3081
|
+
}
|
|
2974
3082
|
|
|
2975
3083
|
// Release the lock with the result
|
|
2976
3084
|
releaseSyncLock(dbId, result);
|
|
@@ -3049,9 +3157,9 @@ class MockWebClient extends WebClient {
|
|
|
3049
3157
|
// Wait for the underlying wasmWebClient to be initialized.
|
|
3050
3158
|
const wasmWebClient = await instance.getWasmWebClient();
|
|
3051
3159
|
await wasmWebClient.createMockClient(
|
|
3052
|
-
seed,
|
|
3053
|
-
serializedMockChain,
|
|
3054
|
-
serializedMockNoteTransportNode
|
|
3160
|
+
seed ?? null,
|
|
3161
|
+
serializedMockChain ?? null,
|
|
3162
|
+
serializedMockNoteTransportNode ?? null
|
|
3055
3163
|
);
|
|
3056
3164
|
|
|
3057
3165
|
// Wait for the worker to be ready
|
|
@@ -3096,9 +3204,11 @@ class MockWebClient extends WebClient {
|
|
|
3096
3204
|
if (!this.worker) {
|
|
3097
3205
|
result = await wasmWebClient.syncStateImpl();
|
|
3098
3206
|
} else {
|
|
3099
|
-
let serializedMockChain = wasmWebClient.serializeMockChain()
|
|
3100
|
-
|
|
3101
|
-
|
|
3207
|
+
let serializedMockChain = (await wasmWebClient.serializeMockChain())
|
|
3208
|
+
.buffer;
|
|
3209
|
+
let serializedMockNoteTransportNode = (
|
|
3210
|
+
await wasmWebClient.serializeMockNoteTransportNode()
|
|
3211
|
+
).buffer;
|
|
3102
3212
|
|
|
3103
3213
|
const wasm = await getWasmOrThrow();
|
|
3104
3214
|
|
|
@@ -3134,9 +3244,11 @@ class MockWebClient extends WebClient {
|
|
|
3134
3244
|
const wasmWebClient = await this.getWasmWebClient();
|
|
3135
3245
|
const wasm = await getWasmOrThrow();
|
|
3136
3246
|
const serializedTransactionRequest = transactionRequest.serialize();
|
|
3137
|
-
const serializedMockChain = wasmWebClient.serializeMockChain()
|
|
3138
|
-
|
|
3139
|
-
|
|
3247
|
+
const serializedMockChain = (await wasmWebClient.serializeMockChain())
|
|
3248
|
+
.buffer;
|
|
3249
|
+
const serializedMockNoteTransportNode = (
|
|
3250
|
+
await wasmWebClient.serializeMockNoteTransportNode()
|
|
3251
|
+
).buffer;
|
|
3140
3252
|
|
|
3141
3253
|
const result = await this.callMethodWithWorker(
|
|
3142
3254
|
MethodName.SUBMIT_NEW_TRANSACTION_MOCK,
|
|
@@ -3188,9 +3300,11 @@ class MockWebClient extends WebClient {
|
|
|
3188
3300
|
const wasm = await getWasmOrThrow();
|
|
3189
3301
|
const serializedTransactionRequest = transactionRequest.serialize();
|
|
3190
3302
|
const proverPayload = prover.serialize();
|
|
3191
|
-
const serializedMockChain = wasmWebClient.serializeMockChain()
|
|
3192
|
-
|
|
3193
|
-
|
|
3303
|
+
const serializedMockChain = (await wasmWebClient.serializeMockChain())
|
|
3304
|
+
.buffer;
|
|
3305
|
+
const serializedMockNoteTransportNode = (
|
|
3306
|
+
await wasmWebClient.serializeMockNoteTransportNode()
|
|
3307
|
+
).buffer;
|
|
3194
3308
|
|
|
3195
3309
|
const result = await this.callMethodWithWorker(
|
|
3196
3310
|
MethodName.SUBMIT_NEW_TRANSACTION_WITH_PROVER_MOCK,
|
|
@@ -3254,5 +3368,5 @@ MidenClient._MockWasmWebClient = MockWebClient;
|
|
|
3254
3368
|
MidenClient._getWasmOrThrow = getWasmOrThrow;
|
|
3255
3369
|
_setWebClient(WebClient);
|
|
3256
3370
|
|
|
3257
|
-
export {
|
|
3371
|
+
export { AccountType, AuthScheme, CompilerResource, Linking, MidenArrays, MidenClient, MockWebClient as MockWasmWebClient, MockWebClient, NoteVisibility, StorageMode, StorageResult, StorageView, WebClient as WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, getWasmOrThrow, wordToBigInt };
|
|
3258
3372
|
//# sourceMappingURL=index.js.map
|