@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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -9
  3. package/dist/{Cargo-M3382VZc.js → Cargo-CVlXCH_2.js} +7129 -6225
  4. package/dist/Cargo-CVlXCH_2.js.map +1 -0
  5. package/dist/api-types.d.ts +19 -65
  6. package/dist/assets/miden_client_web.wasm +0 -0
  7. package/dist/crates/miden_client_web.d.ts +122 -172
  8. package/dist/docs-entry.d.ts +5 -2
  9. package/dist/eager.js +7 -4
  10. package/dist/eager.js.map +1 -1
  11. package/dist/index.d.ts +107 -14
  12. package/dist/index.js +529 -415
  13. package/dist/index.js.map +1 -1
  14. package/dist/wasm.js +1 -1
  15. package/dist/workers/{Cargo-M3382VZc-Dfw4tXwh.js → Cargo-CVlXCH_2-CWA-5vlh.js} +7129 -6225
  16. package/dist/workers/Cargo-CVlXCH_2-CWA-5vlh.js.map +1 -0
  17. package/dist/workers/assets/miden_client_web.wasm +0 -0
  18. package/dist/workers/web-client-methods-worker.js +7153 -6243
  19. package/dist/workers/web-client-methods-worker.js.map +1 -1
  20. package/dist/workers/web-client-methods-worker.module.js +23 -19
  21. package/dist/workers/web-client-methods-worker.module.js.map +1 -1
  22. package/js/client.js +327 -0
  23. package/js/node/client-factory.js +117 -0
  24. package/js/node/loader.js +138 -0
  25. package/js/node/napi-compat.js +238 -0
  26. package/js/node-index.js +195 -0
  27. package/js/resources/accounts.js +224 -0
  28. package/js/resources/compiler.js +74 -0
  29. package/js/resources/keystore.js +54 -0
  30. package/js/resources/notes.js +124 -0
  31. package/js/resources/settings.js +30 -0
  32. package/js/resources/tags.js +31 -0
  33. package/js/resources/transactions.js +533 -0
  34. package/js/standalone.js +109 -0
  35. package/js/utils.js +232 -0
  36. package/lazy/package.json +4 -0
  37. package/package.json +62 -40
  38. package/dist/Cargo-M3382VZc.js.map +0 -1
  39. package/dist/workers/Cargo-M3382VZc-Dfw4tXwh.js.map +0 -1
@@ -121,14 +121,6 @@ export class AccountArray {
121
121
  length(): number;
122
122
  constructor(elements?: Account[] | null);
123
123
  push(element: Account): void;
124
- /**
125
- * Replace the element at `index`. Borrows + clones the input
126
- * (mirrors `push`), so the caller's JS handle remains valid
127
- * after the call. Without this borrow, passing `elem` by
128
- * value would move the underlying Rust value out of the
129
- * caller's JS handle and any subsequent method on it would
130
- * panic with `"null pointer passed to rust"`.
131
- */
132
124
  replaceAt(index: number, elem: Account): void;
133
125
  }
134
126
 
@@ -137,16 +129,17 @@ export class AccountBuilder {
137
129
  [Symbol.dispose](): void;
138
130
  /**
139
131
  * Sets the account type (regular, faucet, etc.).
140
- *
141
- * Accepts either a numeric WASM enum value (0–3) or a string name
142
- * (`"FungibleFaucet"`, `"NonFungibleFaucet"`,
143
- * `"RegularAccountImmutableCode"`, `"RegularAccountUpdatableCode"`).
144
132
  */
145
- accountType(account_type: any): AccountBuilder;
133
+ accountType(account_type: AccountType): AccountBuilder;
146
134
  /**
147
- * Builds the account and returns it together with the derived seed.
135
+ * Builds the account (including merged storage schema commitment metadata) and returns it
136
+ * together with the derived seed.
148
137
  */
149
138
  build(): AccountBuilderResult;
139
+ /**
140
+ * Builds the account without adding the schema commitment component (legacy behavior).
141
+ */
142
+ buildWithoutSchemaCommitment(): AccountBuilderResult;
150
143
  /**
151
144
  * Creates a new account builder from a 32-byte initial seed.
152
145
  */
@@ -453,14 +446,6 @@ export class AccountIdArray {
453
446
  length(): number;
454
447
  constructor(elements?: AccountId[] | null);
455
448
  push(element: AccountId): void;
456
- /**
457
- * Replace the element at `index`. Borrows + clones the input
458
- * (mirrors `push`), so the caller's JS handle remains valid
459
- * after the call. Without this borrow, passing `elem` by
460
- * value would move the underlying Rust value out of the
461
- * caller's JS handle and any subsequent method on it would
462
- * panic with `"null pointer passed to rust"`.
463
- */
464
449
  replaceAt(index: number, elem: AccountId): void;
465
450
  }
466
451
 
@@ -510,7 +495,7 @@ export class AccountProof {
510
495
  *
511
496
  * Each entry contains a `key` and `value` as `Word` objects.
512
497
  */
513
- getStorageMapEntries(slot_name: string): StorageMapEntry[] | undefined;
498
+ getStorageMapEntries(slot_name: string): StorageMapEntryJs[] | undefined;
514
499
  /**
515
500
  * Returns the names of all storage slots that have map details available.
516
501
  *
@@ -540,6 +525,13 @@ export class AccountProof {
540
525
  * Returns the number of storage slots, if available (public accounts only).
541
526
  */
542
527
  numStorageSlots(): number | undefined;
528
+ /**
529
+ * Returns the fungible assets in the account's vault, if vault details were included
530
+ * in the proof response.
531
+ *
532
+ * Returns `undefined` if the account is private or vault data was not requested.
533
+ */
534
+ vaultFungibleAssets(): FungibleAsset[] | undefined;
543
535
  }
544
536
 
545
537
  /**
@@ -669,7 +661,7 @@ export class AccountStorage {
669
661
  * Returns `undefined` if the slot isn't a map or doesn't exist.
670
662
  * Returns `[]` if the map exists but is empty.
671
663
  */
672
- getMapEntries(slot_name: string): JsStorageMapEntry[] | undefined;
664
+ getMapEntries(slot_name: string): StorageMapEntry[] | undefined;
673
665
  /**
674
666
  * Returns the value for a key in the map stored at the given slot, if any.
675
667
  */
@@ -1021,15 +1013,6 @@ export class BlockHeader {
1021
1013
  * Returns the commitment to the block contents.
1022
1014
  */
1023
1015
  commitment(): Word;
1024
- /**
1025
- * Returns the account ID of the fungible faucet whose assets are accepted as the native
1026
- * asset of the blockchain (i.e. the asset used for paying transaction verification fees).
1027
- *
1028
- * This is stored on-chain as part of the block's fee parameters, which means consumers can
1029
- * discover the native faucet by reading any block header rather than hardcoding it per
1030
- * network.
1031
- */
1032
- nativeAssetId(): AccountId;
1033
1016
  /**
1034
1017
  * Returns the note commitment root.
1035
1018
  */
@@ -1311,7 +1294,7 @@ export class Felt {
1311
1294
  */
1312
1295
  asInt(): bigint;
1313
1296
  /**
1314
- * Creates a new field element from a u64 value.
1297
+ * Creates a new field element.
1315
1298
  */
1316
1299
  constructor(value: bigint);
1317
1300
  /**
@@ -1338,14 +1321,6 @@ export class FeltArray {
1338
1321
  length(): number;
1339
1322
  constructor(elements?: Felt[] | null);
1340
1323
  push(element: Felt): void;
1341
- /**
1342
- * Replace the element at `index`. Borrows + clones the input
1343
- * (mirrors `push`), so the caller's JS handle remains valid
1344
- * after the call. Without this borrow, passing `elem` by
1345
- * value would move the underlying Rust value out of the
1346
- * caller's JS handle and any subsequent method on it would
1347
- * panic with `"null pointer passed to rust"`.
1348
- */
1349
1324
  replaceAt(index: number, elem: Felt): void;
1350
1325
  }
1351
1326
 
@@ -1486,14 +1461,6 @@ export class ForeignAccountArray {
1486
1461
  length(): number;
1487
1462
  constructor(elements?: ForeignAccount[] | null);
1488
1463
  push(element: ForeignAccount): void;
1489
- /**
1490
- * Replace the element at `index`. Borrows + clones the input
1491
- * (mirrors `push`), so the caller's JS handle remains valid
1492
- * after the call. Without this borrow, passing `elem` by
1493
- * value would move the underlying Rust value out of the
1494
- * caller's JS handle and any subsequent method on it would
1495
- * panic with `"null pointer passed to rust"`.
1496
- */
1497
1464
  replaceAt(index: number, elem: ForeignAccount): void;
1498
1465
  }
1499
1466
 
@@ -2035,6 +2002,32 @@ export class NetworkId {
2035
2002
  static testnet(): NetworkId;
2036
2003
  }
2037
2004
 
2005
+ /**
2006
+ * Status of a network note in the node.
2007
+ */
2008
+ export class NetworkNoteStatusInfo {
2009
+ private constructor();
2010
+ free(): void;
2011
+ [Symbol.dispose](): void;
2012
+ /**
2013
+ * Returns the number of processing attempts.
2014
+ */
2015
+ readonly attemptCount: number;
2016
+ /**
2017
+ * Returns the block number of the last processing attempt, if any.
2018
+ */
2019
+ readonly lastAttemptBlockNum: number | undefined;
2020
+ /**
2021
+ * Returns the last error message, if any.
2022
+ */
2023
+ readonly lastError: string | undefined;
2024
+ /**
2025
+ * Returns the status as a string: `"Pending"`, `"NullifierInflight"`, `"Discarded"`, or
2026
+ * `"NullifierCommitted"`.
2027
+ */
2028
+ readonly status: string;
2029
+ }
2030
+
2038
2031
  /**
2039
2032
  * The type of a Miden network.
2040
2033
  */
@@ -2144,14 +2137,6 @@ export class NoteAndArgsArray {
2144
2137
  length(): number;
2145
2138
  constructor(elements?: NoteAndArgs[] | null);
2146
2139
  push(element: NoteAndArgs): void;
2147
- /**
2148
- * Replace the element at `index`. Borrows + clones the input
2149
- * (mirrors `push`), so the caller's JS handle remains valid
2150
- * after the call. Without this borrow, passing `elem` by
2151
- * value would move the underlying Rust value out of the
2152
- * caller's JS handle and any subsequent method on it would
2153
- * panic with `"null pointer passed to rust"`.
2154
- */
2155
2140
  replaceAt(index: number, elem: NoteAndArgs): void;
2156
2141
  }
2157
2142
 
@@ -2173,14 +2158,6 @@ export class NoteArray {
2173
2158
  length(): number;
2174
2159
  constructor(elements?: Note[] | null);
2175
2160
  push(element: Note): void;
2176
- /**
2177
- * Replace the element at `index`. Borrows + clones the input
2178
- * (mirrors `push`), so the caller's JS handle remains valid
2179
- * after the call. Without this borrow, passing `elem` by
2180
- * value would move the underlying Rust value out of the
2181
- * caller's JS handle and any subsequent method on it would
2182
- * panic with `"null pointer passed to rust"`.
2183
- */
2184
2161
  replaceAt(index: number, elem: Note): void;
2185
2162
  }
2186
2163
 
@@ -2419,14 +2396,6 @@ export class NoteDetailsAndTagArray {
2419
2396
  length(): number;
2420
2397
  constructor(elements?: NoteDetailsAndTag[] | null);
2421
2398
  push(element: NoteDetailsAndTag): void;
2422
- /**
2423
- * Replace the element at `index`. Borrows + clones the input
2424
- * (mirrors `push`), so the caller's JS handle remains valid
2425
- * after the call. Without this borrow, passing `elem` by
2426
- * value would move the underlying Rust value out of the
2427
- * caller's JS handle and any subsequent method on it would
2428
- * panic with `"null pointer passed to rust"`.
2429
- */
2430
2399
  replaceAt(index: number, elem: NoteDetailsAndTag): void;
2431
2400
  }
2432
2401
 
@@ -2653,14 +2622,6 @@ export class NoteIdAndArgsArray {
2653
2622
  length(): number;
2654
2623
  constructor(elements?: NoteIdAndArgs[] | null);
2655
2624
  push(element: NoteIdAndArgs): void;
2656
- /**
2657
- * Replace the element at `index`. Borrows + clones the input
2658
- * (mirrors `push`), so the caller's JS handle remains valid
2659
- * after the call. Without this borrow, passing `elem` by
2660
- * value would move the underlying Rust value out of the
2661
- * caller's JS handle and any subsequent method on it would
2662
- * panic with `"null pointer passed to rust"`.
2663
- */
2664
2625
  replaceAt(index: number, elem: NoteIdAndArgs): void;
2665
2626
  }
2666
2627
 
@@ -2795,14 +2756,6 @@ export class NoteRecipientArray {
2795
2756
  length(): number;
2796
2757
  constructor(elements?: NoteRecipient[] | null);
2797
2758
  push(element: NoteRecipient): void;
2798
- /**
2799
- * Replace the element at `index`. Borrows + clones the input
2800
- * (mirrors `push`), so the caller's JS handle remains valid
2801
- * after the call. Without this borrow, passing `elem` by
2802
- * value would move the underlying Rust value out of the
2803
- * caller's JS handle and any subsequent method on it would
2804
- * panic with `"null pointer passed to rust"`.
2805
- */
2806
2759
  replaceAt(index: number, elem: NoteRecipient): void;
2807
2760
  }
2808
2761
 
@@ -3024,14 +2977,6 @@ export class OutputNoteArray {
3024
2977
  length(): number;
3025
2978
  constructor(elements?: OutputNote[] | null);
3026
2979
  push(element: OutputNote): void;
3027
- /**
3028
- * Replace the element at `index`. Borrows + clones the input
3029
- * (mirrors `push`), so the caller's JS handle remains valid
3030
- * after the call. Without this borrow, passing `elem` by
3031
- * value would move the underlying Rust value out of the
3032
- * caller's JS handle and any subsequent method on it would
3033
- * panic with `"null pointer passed to rust"`.
3034
- */
3035
2980
  replaceAt(index: number, elem: OutputNote): void;
3036
2981
  }
3037
2982
 
@@ -3320,8 +3265,23 @@ export class RpcClient {
3320
3265
  getAccountProof(account_id: AccountId, storage_requirements?: AccountStorageRequirements | null, block_num?: number | null, known_vault_commitment?: Word | null): Promise<AccountProof>;
3321
3266
  /**
3322
3267
  * Fetches a block header by number. When `block_num` is undefined, returns the latest header.
3268
+ *
3269
+ * @param `block_num` - Optional block number. When `undefined`, returns the latest header.
3270
+ * @param `include_mmr_proof` - When `true`, includes the MMR proof in the response. Defaults
3271
+ * to `false` when `undefined`.
3272
+ */
3273
+ getBlockHeaderByNumber(block_num?: number | null, include_mmr_proof?: boolean | null): Promise<BlockHeader>;
3274
+ /**
3275
+ * Fetches the processing status of a network note by its ID.
3276
+ *
3277
+ * Returns information about the note's current status in the network,
3278
+ * including whether it is pending, processed, discarded, or committed,
3279
+ * along with error details and attempt count.
3280
+ *
3281
+ * @param `note_id` - The ID of the note to query.
3282
+ * @returns Promise that resolves to a `NetworkNoteStatusInfo` object.
3323
3283
  */
3324
- getBlockHeaderByNumber(block_num?: number | null): Promise<BlockHeader>;
3284
+ getNetworkNoteStatus(note_id: NoteId): Promise<NetworkNoteStatusInfo>;
3325
3285
  /**
3326
3286
  * Fetches a note script by its root hash from the connected Miden node.
3327
3287
  *
@@ -3591,10 +3551,27 @@ export class StorageMap {
3591
3551
  constructor();
3592
3552
  }
3593
3553
 
3554
+ export class StorageMapEntry {
3555
+ private constructor();
3556
+ /**
3557
+ ** Return copy of self without private attributes.
3558
+ */
3559
+ toJSON(): Object;
3560
+ /**
3561
+ * Return stringified version of self.
3562
+ */
3563
+ toString(): string;
3564
+ free(): void;
3565
+ [Symbol.dispose](): void;
3566
+ key: string;
3567
+ root: string;
3568
+ value: string;
3569
+ }
3570
+
3594
3571
  /**
3595
3572
  * A key-value entry from a storage map.
3596
3573
  */
3597
- export class StorageMapEntry {
3574
+ export class StorageMapEntryJs {
3598
3575
  private constructor();
3599
3576
  free(): void;
3600
3577
  [Symbol.dispose](): void;
@@ -3698,14 +3675,6 @@ export class StorageSlotArray {
3698
3675
  length(): number;
3699
3676
  constructor(elements?: StorageSlot[] | null);
3700
3677
  push(element: StorageSlot): void;
3701
- /**
3702
- * Replace the element at `index`. Borrows + clones the input
3703
- * (mirrors `push`), so the caller's JS handle remains valid
3704
- * after the call. Without this borrow, passing `elem` by
3705
- * value would move the underlying Rust value out of the
3706
- * caller's JS handle and any subsequent method on it would
3707
- * panic with `"null pointer passed to rust"`.
3708
- */
3709
3678
  replaceAt(index: number, elem: StorageSlot): void;
3710
3679
  }
3711
3680
 
@@ -4153,14 +4122,6 @@ export class TransactionScriptInputPairArray {
4153
4122
  length(): number;
4154
4123
  constructor(elements?: TransactionScriptInputPair[] | null);
4155
4124
  push(element: TransactionScriptInputPair): void;
4156
- /**
4157
- * Replace the element at `index`. Borrows + clones the input
4158
- * (mirrors `push`), so the caller's JS handle remains valid
4159
- * after the call. Without this borrow, passing `elem` by
4160
- * value would move the underlying Rust value out of the
4161
- * caller's JS handle and any subsequent method on it would
4162
- * panic with `"null pointer passed to rust"`.
4163
- */
4164
4125
  replaceAt(index: number, elem: TransactionScriptInputPair): void;
4165
4126
  }
4166
4127
 
@@ -4299,7 +4260,8 @@ export class WebClient {
4299
4260
  * const balance = await reader.getBalance(faucetId);
4300
4261
  * ```
4301
4262
  */
4302
- accountReader(account_id: AccountId): AccountReader;
4263
+ accountReader(account_id: AccountId): Promise<AccountReader>;
4264
+ addAccountSecretKeyToWebStore(account_id: AccountId, secret_key: AuthSecretKey): Promise<void>;
4303
4265
  addTag(tag: string): Promise<void>;
4304
4266
  applyTransaction(transaction_result: TransactionResult, submission_height: number): Promise<TransactionStoreUpdate>;
4305
4267
  static buildSwapTag(note_type: NoteType, offered_asset_faucet_id: AccountId, offered_asset_amount: bigint, requested_asset_faucet_id: AccountId, requested_asset_amount: bigint): NoteTag;
@@ -4313,6 +4275,9 @@ export class WebClient {
4313
4275
  * * `store_name`: Optional name for the web store. If `None`, the store name defaults to
4314
4276
  * `MidenClientDB_{network_id}`, where `network_id` is derived from the `node_url`.
4315
4277
  * Explicitly setting this allows for creating multiple isolated clients.
4278
+ * * `debug_mode`: Optional flag to enable debug mode for transaction execution. When enabled,
4279
+ * the transaction executor records additional information useful for debugging. Defaults to
4280
+ * disabled.
4316
4281
  */
4317
4282
  createClient(node_url?: string | null, node_note_transport_url?: string | null, seed?: Uint8Array | null, store_name?: string | null, debug_mode?: boolean | null): Promise<any>;
4318
4283
  /**
@@ -4328,14 +4293,16 @@ export class WebClient {
4328
4293
  * * `get_key_cb`: Callback to retrieve the secret key bytes for a given public key.
4329
4294
  * * `insert_key_cb`: Callback to persist a secret key.
4330
4295
  * * `sign_cb`: Callback to produce serialized signature bytes for the provided inputs.
4296
+ * * `debug_mode`: Optional flag to enable debug mode for transaction execution. Defaults to
4297
+ * disabled.
4331
4298
  */
4332
4299
  createClientWithExternalKeystore(node_url?: string | null, node_note_transport_url?: string | null, seed?: Uint8Array | null, store_name?: string | null, get_key_cb?: Function | null, insert_key_cb?: Function | null, sign_cb?: Function | null, debug_mode?: boolean | null): Promise<any>;
4333
- createCodeBuilder(): CodeBuilder;
4300
+ createCodeBuilder(): Promise<CodeBuilder>;
4334
4301
  /**
4335
4302
  * Creates a new client with a mock RPC API. Useful for testing purposes and proof-of-concept
4336
4303
  * applications as it uses a mock chain that simulates the behavior of a real node.
4337
4304
  */
4338
- createMockClient(seed?: Uint8Array | null, serialized_mock_chain?: Uint8Array | null, serialized_mock_note_transport_node?: Uint8Array | null): Promise<any>;
4305
+ createMockClient(seed?: Uint8Array | null, serialized_mock_chain?: Uint8Array | null, serialized_mock_note_transport_node?: Uint8Array | null): Promise<string>;
4339
4306
  /**
4340
4307
  * Executes a transaction and returns the `TransactionSummary`.
4341
4308
  *
@@ -4386,6 +4353,18 @@ export class WebClient {
4386
4353
  * This method loads the complete account state including vault, storage, and code.
4387
4354
  */
4388
4355
  getAccount(account_id: AccountId): Promise<Account | undefined>;
4356
+ /**
4357
+ * Retrieves an authentication secret key from the keystore given a public key commitment.
4358
+ *
4359
+ * The public key commitment should correspond to one of the keys tracked by the keystore.
4360
+ * Returns the associated [`AuthSecretKey`] if found, or an error if not found.
4361
+ */
4362
+ getAccountAuthByPubKeyCommitment(pub_key_commitment: Word): Promise<AuthSecretKey>;
4363
+ /**
4364
+ * Retrieves the full account data for the account associated with the given public key
4365
+ * commitment, returning `null` if no account is found.
4366
+ */
4367
+ getAccountByKeyCommitment(pub_key_commitment: Word): Promise<Account | undefined>;
4389
4368
  /**
4390
4369
  * Retrieves the account code for a specific account.
4391
4370
  *
@@ -4411,46 +4390,28 @@ export class WebClient {
4411
4390
  getOutputNote(note_id: string): Promise<OutputNoteRecord>;
4412
4391
  getOutputNotes(filter: NoteFilter): Promise<OutputNoteRecord[]>;
4413
4392
  /**
4414
- * Retrieves the setting value for `key`, or `None` if it hasn’t been set.
4393
+ * Returns all public key commitments associated with the given account ID.
4394
+ *
4395
+ * These commitments can be used with [`getAccountAuthByPubKeyCommitment`]
4396
+ * to retrieve the corresponding secret keys from the keystore.
4397
+ */
4398
+ getPublicKeyCommitmentsOfAccount(account_id: AccountId): Promise<Word[]>;
4399
+ /**
4400
+ * Retrieves the setting value for `key`, or `None` if it hasn't been set.
4415
4401
  */
4416
4402
  getSetting(key: string): Promise<any | undefined>;
4417
4403
  getSyncHeight(): Promise<number>;
4418
4404
  getTransactions(transaction_filter: TransactionFilter): Promise<TransactionRecord[]>;
4419
- importAccountById(account_id: AccountId): Promise<any>;
4420
- importAccountFile(account_file: AccountFile): Promise<any>;
4405
+ importAccountById(account_id: AccountId): Promise<void>;
4406
+ importAccountFile(account_file: AccountFile): Promise<string>;
4421
4407
  importNoteFile(note_file: NoteFile): Promise<NoteId>;
4422
4408
  importPublicAccountFromSeed(init_seed: Uint8Array, mutable: boolean, auth_scheme: AuthScheme): Promise<Account>;
4423
4409
  insertAccountAddress(account_id: AccountId, address: Address): Promise<void>;
4424
- /**
4425
- * Returns the raw JS value that the most recent sign-callback invocation
4426
- * threw, or `null` if the last sign call succeeded (or no call has
4427
- * happened yet).
4428
- *
4429
- * Combined with the serialized-call discipline enforced at the JS
4430
- * `WebClient` wrapper, this lets a caller that caught a failed
4431
- * `executeTransaction` / `submitNewTransaction` recover the original
4432
- * JS error the signing callback threw — preserving any structured
4433
- * metadata (e.g. a `reason: 'locked'` property) that the kernel-level
4434
- * `auth::request` diagnostic would otherwise have erased.
4435
- *
4436
- * # Usage (TS)
4437
- * ```ts
4438
- * try {
4439
- * await client.submitNewTransaction(acc, req);
4440
- * } catch (e) {
4441
- * const authErr = client.lastAuthError();
4442
- * if (authErr && authErr.reason === 'locked') {
4443
- * // wait for unlock, then retry
4444
- * }
4445
- * }
4446
- * ```
4447
- */
4448
- lastAuthError(): any;
4449
4410
  /**
4450
4411
  * Returns all the existing setting keys from the store.
4451
4412
  */
4452
4413
  listSettingKeys(): Promise<string[]>;
4453
- listTags(): Promise<any>;
4414
+ listTags(): Promise<string[]>;
4454
4415
  constructor();
4455
4416
  newAccount(account: Account, overwrite: boolean): Promise<void>;
4456
4417
  /**
@@ -4462,26 +4423,16 @@ export class WebClient {
4462
4423
  newAccountWithSecretKey(account: Account, secret_key: AuthSecretKey): Promise<void>;
4463
4424
  newConsumeTransactionRequest(list_of_notes: Note[]): TransactionRequest;
4464
4425
  newFaucet(storage_mode: AccountStorageMode, non_fungible: boolean, token_symbol: string, decimals: number, max_supply: bigint, auth_scheme: AuthScheme): Promise<Account>;
4465
- newMintTransactionRequest(target_account_id: AccountId, faucet_id: AccountId, note_type: NoteType, amount: bigint): TransactionRequest;
4466
- newSendTransactionRequest(sender_account_id: AccountId, target_account_id: AccountId, faucet_id: AccountId, note_type: NoteType, amount: bigint, recall_height?: number | null, timelock_height?: number | null): TransactionRequest;
4467
- newSwapTransactionRequest(sender_account_id: AccountId, offered_asset_faucet_id: AccountId, offered_asset_amount: bigint, requested_asset_faucet_id: AccountId, requested_asset_amount: bigint, note_type: NoteType, payback_note_type: NoteType): TransactionRequest;
4426
+ newMintTransactionRequest(target_account_id: AccountId, faucet_id: AccountId, note_type: NoteType, amount: bigint): Promise<TransactionRequest>;
4427
+ newSendTransactionRequest(sender_account_id: AccountId, target_account_id: AccountId, faucet_id: AccountId, note_type: NoteType, amount: bigint, recall_height?: number | null, timelock_height?: number | null): Promise<TransactionRequest>;
4428
+ newSwapTransactionRequest(sender_account_id: AccountId, offered_asset_faucet_id: AccountId, offered_asset_amount: bigint, requested_asset_faucet_id: AccountId, requested_asset_amount: bigint, note_type: NoteType, payback_note_type: NoteType): Promise<TransactionRequest>;
4468
4429
  newWallet(storage_mode: AccountStorageMode, mutable: boolean, auth_scheme: AuthScheme, init_seed?: Uint8Array | null): Promise<Account>;
4469
- proveBlock(): void;
4430
+ proveBlock(): Promise<void>;
4470
4431
  /**
4471
- * Generates a transaction proof using the client's default (local) prover.
4472
- */
4473
- proveTransaction(transaction_result: TransactionResult): Promise<ProvenTransaction>;
4474
- /**
4475
- * Generates a transaction proof using the provided prover.
4476
- *
4477
- * Takes the prover by reference so the JS-side handle is NOT consumed
4478
- * by wasm-bindgen. Taking `TransactionProver` by value would transfer
4479
- * ownership on each call, invalidating the JS object's internal WASM
4480
- * handle; after one use, subsequent calls from JS would pass a dangling
4481
- * handle that wasm-bindgen interprets as `None`, silently falling back
4482
- * to the local prover.
4432
+ * Generates a transaction proof using either the provided prover or the client's default
4433
+ * prover if none is supplied.
4483
4434
  */
4484
- proveTransactionWithProver(transaction_result: TransactionResult, prover: TransactionProver): Promise<ProvenTransaction>;
4435
+ proveTransaction(transaction_result: TransactionResult, prover?: TransactionProver | null): Promise<ProvenTransaction>;
4485
4436
  /**
4486
4437
  * Prunes historical account states for the specified account up to the given nonce.
4487
4438
  *
@@ -4505,11 +4456,11 @@ export class WebClient {
4505
4456
  /**
4506
4457
  * Returns the inner serialized mock chain if it exists.
4507
4458
  */
4508
- serializeMockChain(): Uint8Array;
4459
+ serializeMockChain(): Promise<Uint8Array>;
4509
4460
  /**
4510
4461
  * Returns the inner serialized mock note transport node if it exists.
4511
4462
  */
4512
- serializeMockNoteTransportNode(): Uint8Array;
4463
+ serializeMockNoteTransportNode(): Promise<Uint8Array>;
4513
4464
  /**
4514
4465
  * Sets a setting key-value in the store. It can then be retrieved using `get_setting`.
4515
4466
  */
@@ -4517,7 +4468,7 @@ export class WebClient {
4517
4468
  /**
4518
4469
  * Returns the identifier of the underlying store (e.g. `IndexedDB` database name, file path).
4519
4470
  */
4520
- storeIdentifier(): string;
4471
+ storeIdentifier(): Promise<string>;
4521
4472
  /**
4522
4473
  * Executes a transaction specified by the request against the specified account,
4523
4474
  * proves it, submits it to the network, and updates the local database.
@@ -4549,7 +4500,7 @@ export class WebClient {
4549
4500
  * which provides proper coordination for concurrent calls.
4550
4501
  */
4551
4502
  syncStateImpl(): Promise<SyncSummary>;
4552
- usesMockChain(): boolean;
4503
+ usesMockChain(): Promise<boolean>;
4553
4504
  /**
4554
4505
  * Returns a `WebKeystoreApi` handle for managing secret keys.
4555
4506
  *
@@ -4602,11 +4553,10 @@ export class Word {
4602
4553
  static deserialize(bytes: Uint8Array): Word;
4603
4554
  /**
4604
4555
  * Creates a Word from a hex string.
4605
- * Fails if the provided string is not a valid hex representation of a Word.
4606
4556
  */
4607
4557
  static fromHex(hex: string): Word;
4608
4558
  /**
4609
- * Creates a word from four u64 values.
4559
+ * Creates a word from four numeric values.
4610
4560
  */
4611
4561
  constructor(u64_vec: BigUint64Array);
4612
4562
  /**
@@ -4626,7 +4576,7 @@ export class Word {
4626
4576
  */
4627
4577
  toHex(): string;
4628
4578
  /**
4629
- * Returns the word as an array of u64 values.
4579
+ * Returns the word as an array of numeric values.
4630
4580
  */
4631
4581
  toU64s(): BigUint64Array;
4632
4582
  }
@@ -29,7 +29,10 @@ export {
29
29
  TransactionRequest,
30
30
  TransactionSummary,
31
31
  Word,
32
- } from "./crates/miden_client_web";
32
+ } from "./crates/miden_client_web.js";
33
33
 
34
34
  // All simplified API types
35
- export * from "./api-types";
35
+ export * from "./api-types.js";
36
+
37
+ // Storage utilities
38
+ export { StorageView, StorageResult, wordToBigInt } from "./index.js";
package/dist/eager.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { getWasmOrThrow } from './index.js';
2
- export { AccountArray, AccountIdArray, AccountType, AuthScheme, CompilerResource, FeltArray, ForeignAccountArray, Linking, MidenArrays, MidenClient, MockWasmWebClient, NoteAndArgsArray, NoteArray, NoteIdAndArgsArray, NoteRecipientArray, NoteVisibility, OutputNoteArray, StorageMode, StorageSlotArray, TransactionScriptInputPairArray, WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, resolveAuthScheme } from './index.js';
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 { AccountType, AuthScheme, CompilerResource, Linking, MidenArrays, MidenClient, MockWasmWebClient, MockWasmWebClient as MockWebClient, NoteVisibility, StorageMode, StorageResult, StorageView, WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, wordToBigInt } from './index.js';
3
+ 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
4
  import './wasm.js';
5
5
 
6
- // Eager entry point for @miden-sdk/miden-sdk.
6
+ // Eager entry point for @miden-sdk/miden-sdk (browser builds).
7
7
  //
8
8
  // Awaits WASM initialization at module top level, so importing this module
9
9
  // guarantees that any wasm-bindgen constructor (`new RpcClient(...)`,
@@ -11,7 +11,10 @@ import './wasm.js';
11
11
  // is safe to call synchronously on the next line. No explicit
12
12
  // `await MidenClient.ready()` / `isReady` gate is required.
13
13
  //
14
- // This is the default entry (`@miden-sdk/miden-sdk` → `./dist/eager.js`).
14
+ // This is the default entry for browser bundlers (`@miden-sdk/miden-sdk`
15
+ // → `./dist/eager.js`). Node.js consumers resolve the `node` exports
16
+ // condition instead and get the napi binding via `./js/node-index.js`,
17
+ // bypassing this file entirely.
15
18
  //
16
19
  // When NOT to use this entry:
17
20
  // - **Capacitor mobile apps** (Miden Wallet iOS/Android): Capacitor's
package/dist/eager.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"eager.js","sources":["../js/eager.js"],"sourcesContent":["// Eager entry point for @miden-sdk/miden-sdk.\n//\n// Awaits WASM initialization at module top level, so importing this module\n// guarantees that any wasm-bindgen constructor (`new RpcClient(...)`,\n// `AccountId.fromHex(...)`, `TransactionProver.newRemoteProver(...)`, etc.)\n// is safe to call synchronously on the next line. No explicit\n// `await MidenClient.ready()` / `isReady` gate is required.\n//\n// This is the default entry (`@miden-sdk/miden-sdk` → `./dist/eager.js`).\n//\n// When NOT to use this entry:\n// - **Capacitor mobile apps** (Miden Wallet iOS/Android): Capacitor's\n// `capacitor://localhost` scheme handler interacts poorly with top-level\n// await in the main WKWebView. Verified empirically: TLA in a Capacitor\n// host WKWebView hangs module evaluation indefinitely, while the same\n// TLA in the dApp-browser WKWebView (vanilla HTTPS) resolves in <100ms.\n// - **Next.js / SSR**: TLA blocks server-side module evaluation.\n// - **Framework adapters (@miden-sdk/react, etc.)**: they manage readiness\n// via their own state machine (e.g. `isReady`) and should not impose\n// TLA on consumer bundles.\n//\n// For those contexts, import from `@miden-sdk/miden-sdk/lazy` — identical\n// API surface, no top-level await, callers are responsible for awaiting\n// `MidenClient.ready()` (or the equivalent) before touching wasm-bindgen\n// types.\nimport { getWasmOrThrow } from \"./index.js\";\n\nawait getWasmOrThrow();\n\nexport * from \"./index.js\";\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAM,cAAc,EAAE;;;;"}
1
+ {"version":3,"file":"eager.js","sources":["../js/eager.js"],"sourcesContent":["// Eager entry point for @miden-sdk/miden-sdk (browser builds).\n//\n// Awaits WASM initialization at module top level, so importing this module\n// guarantees that any wasm-bindgen constructor (`new RpcClient(...)`,\n// `AccountId.fromHex(...)`, `TransactionProver.newRemoteProver(...)`, etc.)\n// is safe to call synchronously on the next line. No explicit\n// `await MidenClient.ready()` / `isReady` gate is required.\n//\n// This is the default entry for browser bundlers (`@miden-sdk/miden-sdk`\n// → `./dist/eager.js`). Node.js consumers resolve the `node` exports\n// condition instead and get the napi binding via `./js/node-index.js`,\n// bypassing this file entirely.\n//\n// When NOT to use this entry:\n// - **Capacitor mobile apps** (Miden Wallet iOS/Android): Capacitor's\n// `capacitor://localhost` scheme handler interacts poorly with top-level\n// await in the main WKWebView. Verified empirically: TLA in a Capacitor\n// host WKWebView hangs module evaluation indefinitely, while the same\n// TLA in the dApp-browser WKWebView (vanilla HTTPS) resolves in <100ms.\n// - **Next.js / SSR**: TLA blocks server-side module evaluation.\n// - **Framework adapters (@miden-sdk/react, etc.)**: they manage readiness\n// via their own state machine (e.g. `isReady`) and should not impose\n// TLA on consumer bundles.\n//\n// For those contexts, import from `@miden-sdk/miden-sdk/lazy` — identical\n// API surface, no top-level await, callers are responsible for awaiting\n// `MidenClient.ready()` (or the equivalent) before touching wasm-bindgen\n// types.\nimport { getWasmOrThrow } from \"./index.js\";\n\nawait getWasmOrThrow();\n\nexport * from \"./index.js\";\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAM,cAAc,EAAE;;;;"}