@miden-sdk/miden-sdk 0.14.0-alpha.2 → 0.14.0

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import loadWasm from './wasm.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, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, 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, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, OutputNotesArray, Package, PartialNote, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, Word, createAuthFalcon512RpoMultisig, initSync, setupLogging } from './Cargo-DlfmzoDc.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, 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, 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-M1xGvXNQ.js';
3
3
 
4
4
  const WorkerAction = Object.freeze({
5
5
  INIT: "init",
@@ -364,22 +364,89 @@ function resolveAuthScheme(scheme, wasm) {
364
364
  }
365
365
 
366
366
  /**
367
- * Resolves a simplified AccountType string to a boolean `mutable` flag
367
+ * Resolves an AccountType value to a boolean `mutable` flag
368
368
  * for the underlying WASM `newWallet()` / `importPublicAccountFromSeed()` calls.
369
369
  *
370
- * @param {string | undefined} accountType - "MutableWallet", "ImmutableWallet", or undefined.
371
- * Defaults to mutable wallet when undefined.
370
+ * Accepts the numeric WASM enum values (2 = immutable, 3 = mutable) or the
371
+ * legacy string aliases ("MutableWallet", "ImmutableWallet"). Defaults to
372
+ * mutable when undefined.
373
+ *
374
+ * @param {number | string | undefined} accountType
372
375
  * @returns {boolean} Whether the account code is mutable.
373
376
  */
374
377
  function resolveAccountMutability(accountType) {
375
- if (accountType == null || accountType === "MutableWallet") {
378
+ if (
379
+ accountType == null ||
380
+ accountType === "MutableWallet" ||
381
+ accountType === 3
382
+ ) {
376
383
  return true;
377
384
  }
378
- if (accountType === "ImmutableWallet") {
385
+ if (accountType === "ImmutableWallet" || accountType === 2) {
379
386
  return false;
380
387
  }
381
388
  throw new Error(
382
- `Unknown wallet account type: "${accountType}". Expected "MutableWallet" or "ImmutableWallet".`
389
+ `Unknown wallet account type: "${accountType}". Expected AccountType.MutableWallet (3) or AccountType.ImmutableWallet (2).`
390
+ );
391
+ }
392
+
393
+ /**
394
+ * Resolves a NoteInput (string | NoteId | InputNoteRecord | Note) to a hex string.
395
+ *
396
+ * - Strings are passed through unchanged.
397
+ * - NoteId WASM objects are converted via `.toString()`.
398
+ * - InputNoteRecord and Note objects (with an `.id()` method) are resolved via `.id().toString()`.
399
+ *
400
+ * @param {string | object} input - The note reference to resolve.
401
+ * @returns {string} The hex note ID string.
402
+ */
403
+ function resolveNoteIdHex(input) {
404
+ if (input == null) {
405
+ throw new Error("Note ID cannot be null or undefined");
406
+ }
407
+ if (typeof input === "string") {
408
+ return input;
409
+ }
410
+ // NoteId WASM object — has toString() but not id() (unlike InputNoteRecord/Note).
411
+ // Check for constructor.fromHex to distinguish from plain objects (which also inherit toString).
412
+ if (
413
+ typeof input.toString === "function" &&
414
+ typeof input.id !== "function" &&
415
+ input.constructor?.fromHex !== undefined
416
+ ) {
417
+ return input.toString();
418
+ }
419
+ // InputNoteRecord, Note, or other object with id() returning NoteId
420
+ if (typeof input.id === "function") {
421
+ return input.id().toString();
422
+ }
423
+ throw new TypeError(
424
+ `Cannot resolve note ID: expected string, NoteId, InputNoteRecord, or Note, got ${typeof input}`
425
+ );
426
+ }
427
+
428
+ /**
429
+ * Resolves a TransactionId reference (string | TransactionId) to a hex string.
430
+ *
431
+ * - Strings are passed through unchanged.
432
+ * - TransactionId WASM objects are converted via `.toHex()`.
433
+ *
434
+ * @param {string | object} input - The transaction ID reference to resolve.
435
+ * @returns {string} The hex transaction ID string.
436
+ */
437
+ function resolveTransactionIdHex(input) {
438
+ if (input == null) {
439
+ throw new Error("Transaction ID cannot be null or undefined");
440
+ }
441
+ if (typeof input === "string") {
442
+ return input;
443
+ }
444
+ // TransactionId WASM object — toHex() returns hex
445
+ if (typeof input.toHex === "function") {
446
+ return input.toHex();
447
+ }
448
+ throw new TypeError(
449
+ `Cannot resolve transaction ID: expected string or TransactionId, got ${typeof input}`
383
450
  );
384
451
  }
385
452
 
@@ -419,25 +486,84 @@ class AccountsResource {
419
486
  this.#client.assertNotTerminated();
420
487
  const wasm = await this.#getWasm();
421
488
 
422
- if (opts?.type === "FungibleFaucet") {
489
+ const type = opts?.type;
490
+
491
+ if (
492
+ type === 0 ||
493
+ type === 1 ||
494
+ type === "FungibleFaucet" ||
495
+ type === "NonFungibleFaucet"
496
+ ) {
423
497
  const storageMode = resolveStorageMode(opts.storage ?? "public", wasm);
424
498
  const authScheme = resolveAuthScheme(opts.auth, wasm);
425
499
  return await this.#inner.newFaucet(
426
500
  storageMode,
427
- false,
501
+ type === 1 || type === "NonFungibleFaucet",
428
502
  opts.symbol,
429
503
  opts.decimals,
430
504
  BigInt(opts.maxSupply),
431
505
  authScheme
432
506
  );
507
+ } else if (
508
+ type === "ImmutableContract" ||
509
+ type === "MutableContract" ||
510
+ opts?.components // Contracts are distinguished from wallets by having components
511
+ ) {
512
+ return await this.#createContract(opts, wasm);
513
+ } else {
514
+ // Default: wallet (mutable or immutable based on type)
515
+ const mutable = resolveAccountMutability(opts?.type);
516
+ const storageMode = resolveStorageMode(opts?.storage ?? "private", wasm);
517
+ const authScheme = resolveAuthScheme(opts?.auth, wasm);
518
+ const seed = opts?.seed ? await hashSeed(opts.seed) : undefined;
519
+ return await this.#inner.newWallet(
520
+ storageMode,
521
+ mutable,
522
+ authScheme,
523
+ seed
524
+ );
433
525
  }
526
+ }
527
+
528
+ async #createContract(opts, wasm) {
529
+ if (!opts.seed)
530
+ throw new Error("Contract creation requires a 'seed' (Uint8Array)");
531
+ if (!opts.auth)
532
+ throw new Error("Contract creation requires an 'auth' (AuthSecretKey)");
533
+
534
+ // Default to immutable when type is omitted (safer for contracts)
535
+ const mutable = opts.type === "MutableContract" || opts.type === 3;
536
+ const accountTypeEnum = mutable
537
+ ? wasm.AccountType.RegularAccountUpdatableCode
538
+ : wasm.AccountType.RegularAccountImmutableCode;
539
+ const storageMode = resolveStorageMode(opts.storage ?? "public", wasm);
540
+ const authComponent =
541
+ wasm.AccountComponent.createAuthComponentFromSecretKey(opts.auth);
542
+
543
+ let builder = new wasm.AccountBuilder(opts.seed)
544
+ .accountType(accountTypeEnum)
545
+ .storageMode(storageMode)
546
+ .withAuthComponent(authComponent);
547
+
548
+ for (const component of opts.components ?? []) {
549
+ builder = builder.withComponent(component);
550
+ }
551
+
552
+ const built = builder.build();
553
+ const account = built.account;
554
+
555
+ await this.#inner.newAccountWithSecretKey(account, opts.auth);
556
+ return account;
557
+ }
558
+
559
+ async insert({ account, overwrite = false }) {
560
+ this.#client.assertNotTerminated();
561
+ await this.#inner.newAccount(account, overwrite);
562
+ }
434
563
 
435
- // Default: wallet (mutable or immutable based on type)
436
- const mutable = resolveAccountMutability(opts?.type);
437
- const storageMode = resolveStorageMode(opts?.storage ?? "private", wasm);
438
- const authScheme = resolveAuthScheme(opts?.auth, wasm);
439
- const seed = opts?.seed ? await hashSeed(opts.seed) : undefined;
440
- return await this.#inner.newWallet(storageMode, mutable, authScheme, seed);
564
+ async getOrImport(ref) {
565
+ this.#client.assertNotTerminated();
566
+ return (await this.get(ref)) ?? (await this.import(ref));
441
567
  }
442
568
 
443
569
  async get(ref) {
@@ -461,7 +587,7 @@ class AccountsResource {
461
587
  if (!account) {
462
588
  throw new Error(`Account not found: ${id.toString()}`);
463
589
  }
464
- const keys = await this.#inner.getPublicKeyCommitmentsOfAccount(id);
590
+ const keys = await this.#inner.keystore.getCommitments(id);
465
591
  return {
466
592
  account,
467
593
  vault: account.vault(),
@@ -484,8 +610,10 @@ class AccountsResource {
484
610
  this.#client.assertNotTerminated();
485
611
  const wasm = await this.#getWasm();
486
612
 
487
- if (typeof input === "string") {
488
- // Import by ID (hex or bech32 string)
613
+ // Early exit for string, Account, and AccountHeader types before property
614
+ // checks, preventing misrouting if a WASM object ever gains a .file or .seed
615
+ // property. Bare AccountId (no .id() method) falls through to the fallback.
616
+ if (typeof input === "string" || typeof input.id === "function") {
489
617
  const id = resolveAccountRef(input, wasm);
490
618
  await this.#inner.importAccountById(id);
491
619
  return await this.#inner.getAccount(id);
@@ -519,9 +647,10 @@ class AccountsResource {
519
647
  );
520
648
  }
521
649
 
522
- throw new Error(
523
- "Invalid import input: expected a string, { file }, or { seed }"
524
- );
650
+ // Fallback: treat as AccountRef (string, AccountId, Account, AccountHeader)
651
+ const id = resolveAccountRef(input, wasm);
652
+ await this.#inner.importAccountById(id);
653
+ return await this.#inner.getAccount(id);
525
654
  }
526
655
 
527
656
  async export(ref) {
@@ -562,9 +691,53 @@ class TransactionsResource {
562
691
  async send(opts) {
563
692
  this.#client.assertNotTerminated();
564
693
  const wasm = await this.#getWasm();
565
- const { accountId, request } = await this.#buildSendRequest(opts, wasm);
566
694
 
567
- const txId = await this.#submitOrSubmitWithProver(
695
+ if (opts.returnNote === true) {
696
+ // returnNote path — build the P2ID note in JS so we can return the Note
697
+ // object to the caller (e.g. for out-of-band delivery to the recipient).
698
+ if (opts.reclaimAfter != null || opts.timelockUntil != null) {
699
+ throw new Error(
700
+ "reclaimAfter and timelockUntil are not supported when returnNote is true"
701
+ );
702
+ }
703
+
704
+ const senderId = resolveAccountRef(opts.account, wasm);
705
+ const receiverId = resolveAccountRef(opts.to, wasm);
706
+ const faucetId = resolveAccountRef(opts.token, wasm);
707
+ const noteType = resolveNoteType(opts.type, wasm);
708
+
709
+ const note = wasm.Note.createP2IDNote(
710
+ senderId,
711
+ receiverId,
712
+ new wasm.NoteAssets([
713
+ new wasm.FungibleAsset(faucetId, BigInt(opts.amount)),
714
+ ]),
715
+ noteType,
716
+ new wasm.NoteAttachment()
717
+ );
718
+
719
+ const request = new wasm.TransactionRequestBuilder()
720
+ .withOwnOutputNotes(
721
+ new wasm.OutputNoteArray([wasm.OutputNote.full(note)])
722
+ )
723
+ .build();
724
+
725
+ const { txId, result } = await this.#submitOrSubmitWithProver(
726
+ senderId,
727
+ request,
728
+ opts.prover
729
+ );
730
+
731
+ if (opts.waitForConfirmation) {
732
+ await this.waitFor(txId.toHex(), { timeout: opts.timeout });
733
+ }
734
+
735
+ return { txId, note, result };
736
+ }
737
+
738
+ // Default path — note built in WASM with optional reclaim/timelock
739
+ const { accountId, request } = await this.#buildSendRequest(opts, wasm);
740
+ const { txId, result } = await this.#submitOrSubmitWithProver(
568
741
  accountId,
569
742
  request,
570
743
  opts.prover
@@ -574,7 +747,7 @@ class TransactionsResource {
574
747
  await this.waitFor(txId.toHex(), { timeout: opts.timeout });
575
748
  }
576
749
 
577
- return txId;
750
+ return { txId, note: null, result };
578
751
  }
579
752
 
580
753
  async mint(opts) {
@@ -582,7 +755,7 @@ class TransactionsResource {
582
755
  const wasm = await this.#getWasm();
583
756
  const { accountId, request } = await this.#buildMintRequest(opts, wasm);
584
757
 
585
- const txId = await this.#submitOrSubmitWithProver(
758
+ const { txId, result } = await this.#submitOrSubmitWithProver(
586
759
  accountId,
587
760
  request,
588
761
  opts.prover
@@ -592,7 +765,7 @@ class TransactionsResource {
592
765
  await this.waitFor(txId.toHex(), { timeout: opts.timeout });
593
766
  }
594
767
 
595
- return txId;
768
+ return { txId, result };
596
769
  }
597
770
 
598
771
  async consume(opts) {
@@ -600,7 +773,7 @@ class TransactionsResource {
600
773
  const wasm = await this.#getWasm();
601
774
  const { accountId, request } = await this.#buildConsumeRequest(opts, wasm);
602
775
 
603
- const txId = await this.#submitOrSubmitWithProver(
776
+ const { txId, result } = await this.#submitOrSubmitWithProver(
604
777
  accountId,
605
778
  request,
606
779
  opts.prover
@@ -610,7 +783,7 @@ class TransactionsResource {
610
783
  await this.waitFor(txId.toHex(), { timeout: opts.timeout });
611
784
  }
612
785
 
613
- return txId;
786
+ return { txId, result };
614
787
  }
615
788
 
616
789
  async consumeAll(opts) {
@@ -639,7 +812,7 @@ class TransactionsResource {
639
812
 
640
813
  const request = await this.#inner.newConsumeTransactionRequest(notes);
641
814
 
642
- const txId = await this.#submitOrSubmitWithProver(
815
+ const { txId, result } = await this.#submitOrSubmitWithProver(
643
816
  wasm.AccountId.fromHex(accountIdHex),
644
817
  request,
645
818
  opts.prover
@@ -653,6 +826,7 @@ class TransactionsResource {
653
826
  txId,
654
827
  consumed: toConsume.length,
655
828
  remaining: total - toConsume.length,
829
+ result,
656
830
  };
657
831
  }
658
832
 
@@ -661,7 +835,7 @@ class TransactionsResource {
661
835
  const wasm = await this.#getWasm();
662
836
  const { accountId, request } = await this.#buildSwapRequest(opts, wasm);
663
837
 
664
- const txId = await this.#submitOrSubmitWithProver(
838
+ const { txId, result } = await this.#submitOrSubmitWithProver(
665
839
  accountId,
666
840
  request,
667
841
  opts.prover
@@ -671,7 +845,7 @@ class TransactionsResource {
671
845
  await this.waitFor(txId.toHex(), { timeout: opts.timeout });
672
846
  }
673
847
 
674
- return txId;
848
+ return { txId, result };
675
849
  }
676
850
 
677
851
  async preview(opts) {
@@ -705,6 +879,81 @@ class TransactionsResource {
705
879
  return await this.#inner.executeForSummary(accountId, request);
706
880
  }
707
881
 
882
+ async execute(opts) {
883
+ this.#client.assertNotTerminated();
884
+ const wasm = await this.#getWasm();
885
+ const accountId = resolveAccountRef(opts.account, wasm);
886
+
887
+ let builder = new wasm.TransactionRequestBuilder().withCustomScript(
888
+ opts.script
889
+ );
890
+
891
+ if (opts.foreignAccounts?.length) {
892
+ const accounts = opts.foreignAccounts.map((fa) => {
893
+ // Distinguish { id: AccountRef, storage? } wrapper objects from WASM types
894
+ // (Account/AccountHeader expose .id() as a method, wrappers have .id as a property)
895
+ const isWrapper =
896
+ fa !== null &&
897
+ typeof fa === "object" &&
898
+ "id" in fa &&
899
+ typeof fa.id !== "function";
900
+ const id = resolveAccountRef(isWrapper ? fa.id : fa, wasm);
901
+ const storage =
902
+ isWrapper && fa.storage
903
+ ? fa.storage
904
+ : new wasm.AccountStorageRequirements();
905
+ return wasm.ForeignAccount.public(id, storage);
906
+ });
907
+ builder = builder.withForeignAccounts(
908
+ new wasm.ForeignAccountArray(accounts)
909
+ );
910
+ }
911
+
912
+ const request = builder.build();
913
+ const { txId, result } = await this.#submitOrSubmitWithProver(
914
+ accountId,
915
+ request,
916
+ opts.prover
917
+ );
918
+
919
+ if (opts.waitForConfirmation) {
920
+ await this.waitFor(txId.toHex(), { timeout: opts.timeout });
921
+ }
922
+
923
+ return { txId, result };
924
+ }
925
+
926
+ async executeProgram(opts) {
927
+ this.#client.assertNotTerminated();
928
+ const wasm = await this.#getWasm();
929
+ const accountId = resolveAccountRef(opts.account, wasm);
930
+
931
+ let foreignAccountsArray = new wasm.ForeignAccountArray();
932
+ if (opts.foreignAccounts?.length) {
933
+ const accounts = opts.foreignAccounts.map((fa) => {
934
+ const isWrapper =
935
+ fa !== null &&
936
+ typeof fa === "object" &&
937
+ "id" in fa &&
938
+ typeof fa.id !== "function";
939
+ const id = resolveAccountRef(isWrapper ? fa.id : fa, wasm);
940
+ const storage =
941
+ isWrapper && fa.storage
942
+ ? fa.storage
943
+ : new wasm.AccountStorageRequirements();
944
+ return wasm.ForeignAccount.public(id, storage);
945
+ });
946
+ foreignAccountsArray = new wasm.ForeignAccountArray(accounts);
947
+ }
948
+
949
+ return await this.#inner.executeProgram(
950
+ accountId,
951
+ opts.script,
952
+ opts.adviceInputs ?? new wasm.AdviceInputs(),
953
+ foreignAccountsArray
954
+ );
955
+ }
956
+
708
957
  async submit(account, request, opts) {
709
958
  this.#client.assertNotTerminated();
710
959
  const wasm = await this.#getWasm();
@@ -726,7 +975,9 @@ class TransactionsResource {
726
975
  } else if (query.status === "uncommitted") {
727
976
  filter = wasm.TransactionFilter.uncommitted();
728
977
  } else if (query.ids) {
729
- const txIds = query.ids.map((id) => wasm.TransactionId.fromHex(id));
978
+ const txIds = query.ids.map((id) =>
979
+ wasm.TransactionId.fromHex(resolveTransactionIdHex(id))
980
+ );
730
981
  filter = wasm.TransactionFilter.ids(txIds);
731
982
  } else if (query.expiredBefore !== undefined) {
732
983
  filter = wasm.TransactionFilter.expiredBefore(query.expiredBefore);
@@ -740,7 +991,7 @@ class TransactionsResource {
740
991
  /**
741
992
  * Polls for transaction confirmation.
742
993
  *
743
- * @param {string} txId - Transaction ID hex string.
994
+ * @param {string | TransactionId} txId - Transaction ID hex string or TransactionId object.
744
995
  * @param {WaitOptions} [opts] - Polling options.
745
996
  * @param {number} [opts.timeout=60000] - Wall-clock polling timeout in
746
997
  * milliseconds. This is NOT a block height — it controls how long the
@@ -752,6 +1003,7 @@ class TransactionsResource {
752
1003
  */
753
1004
  async waitFor(txId, opts) {
754
1005
  this.#client.assertNotTerminated();
1006
+ const hex = resolveTransactionIdHex(txId);
755
1007
  const timeout = opts?.timeout ?? 60_000;
756
1008
  const interval = opts?.interval ?? 5_000;
757
1009
  const start = Date.now();
@@ -774,7 +1026,7 @@ class TransactionsResource {
774
1026
 
775
1027
  // Recreate filter each iteration — WASM consumes it by value
776
1028
  const filter = wasm.TransactionFilter.ids([
777
- wasm.TransactionId.fromHex(txId),
1029
+ wasm.TransactionId.fromHex(hex),
778
1030
  ]);
779
1031
  const txs = await this.#inner.getTransactions(filter);
780
1032
 
@@ -788,7 +1040,7 @@ class TransactionsResource {
788
1040
  return;
789
1041
  }
790
1042
  if (status.isDiscarded()) {
791
- throw new Error(`Transaction rejected: ${txId}`);
1043
+ throw new Error(`Transaction rejected: ${hex}`);
792
1044
  }
793
1045
  }
794
1046
 
@@ -841,6 +1093,37 @@ class TransactionsResource {
841
1093
  async #buildConsumeRequest(opts, wasm) {
842
1094
  const accountId = resolveAccountRef(opts.account, wasm);
843
1095
  const noteInputs = Array.isArray(opts.notes) ? opts.notes : [opts.notes];
1096
+
1097
+ const isDirectNote = (input) =>
1098
+ input !== null &&
1099
+ typeof input === "object" &&
1100
+ typeof input.id === "function" &&
1101
+ typeof input.toNote !== "function";
1102
+
1103
+ const hasDirectNotes = noteInputs.some(isDirectNote);
1104
+
1105
+ if (hasDirectNotes) {
1106
+ // At least one raw Note object — use NoteAndArgs builder path
1107
+ // (the only WASM path that accepts unauthenticated notes not in the store).
1108
+ const resolvedNotes = await Promise.all(
1109
+ noteInputs.map(async (input) => {
1110
+ if (isDirectNote(input)) return input;
1111
+ if (input && typeof input.toNote === "function")
1112
+ return input.toNote();
1113
+ return await this.#resolveNoteInput(input);
1114
+ })
1115
+ );
1116
+
1117
+ const noteAndArgsArr = resolvedNotes.map(
1118
+ (note) => new wasm.NoteAndArgs(note, null)
1119
+ );
1120
+ const request = new wasm.TransactionRequestBuilder()
1121
+ .withInputNotes(new wasm.NoteAndArgsArray(noteAndArgsArr))
1122
+ .build();
1123
+ return { accountId, request };
1124
+ }
1125
+
1126
+ // Standard path: all inputs are IDs or records — look up from store.
844
1127
  const notes = await Promise.all(
845
1128
  noteInputs.map((input) => this.#resolveNoteInput(input))
846
1129
  );
@@ -882,8 +1165,15 @@ class TransactionsResource {
882
1165
  if (input && typeof input.toNote === "function") {
883
1166
  return input.toNote();
884
1167
  }
885
- // NoteId — look up the note by its hex ID
886
- if (input && input.constructor?.name === "NoteId") {
1168
+ // NoteId — has toString() but not toNote() or id() (unlike InputNoteRecord/Note).
1169
+ // Check for constructor.fromHex to distinguish from plain objects.
1170
+ if (
1171
+ input &&
1172
+ typeof input.toString === "function" &&
1173
+ typeof input.toNote !== "function" &&
1174
+ typeof input.id !== "function" &&
1175
+ input.constructor?.fromHex !== undefined
1176
+ ) {
887
1177
  const hex = input.toString();
888
1178
  const record = await this.#inner.getInputNote(hex);
889
1179
  if (!record) {
@@ -896,15 +1186,15 @@ class TransactionsResource {
896
1186
  }
897
1187
 
898
1188
  async #submitOrSubmitWithProver(accountId, request, perCallProver) {
1189
+ const result = await this.#inner.executeTransaction(accountId, request);
899
1190
  const prover = perCallProver ?? this.#client.defaultProver;
900
- if (prover) {
901
- return await this.#inner.submitNewTransactionWithProver(
902
- accountId,
903
- request,
904
- prover
905
- );
906
- }
907
- return await this.#inner.submitNewTransaction(accountId, request);
1191
+ const proven = prover
1192
+ ? await this.#inner.proveTransaction(result, prover)
1193
+ : await this.#inner.proveTransaction(result);
1194
+ const txId = result.id();
1195
+ const height = await this.#inner.submitProvenTransaction(proven, result);
1196
+ await this.#inner.applyTransaction(result, height);
1197
+ return { txId, result };
908
1198
  }
909
1199
  }
910
1200
 
@@ -928,7 +1218,7 @@ class NotesResource {
928
1218
 
929
1219
  async get(noteId) {
930
1220
  this.#client.assertNotTerminated();
931
- const result = await this.#inner.getInputNote(noteId);
1221
+ const result = await this.#inner.getInputNote(resolveNoteIdHex(noteId));
932
1222
  return result ?? null;
933
1223
  }
934
1224
 
@@ -943,7 +1233,8 @@ class NotesResource {
943
1233
  this.#client.assertNotTerminated();
944
1234
  const wasm = await this.#getWasm();
945
1235
  const accountId = resolveAccountRef(opts.account, wasm);
946
- return await this.#inner.getConsumableNotes(accountId);
1236
+ const consumable = await this.#inner.getConsumableNotes(accountId);
1237
+ return consumable.map((c) => c.inputNoteRecord());
947
1238
  }
948
1239
 
949
1240
  async import(noteFile) {
@@ -955,7 +1246,7 @@ class NotesResource {
955
1246
  this.#client.assertNotTerminated();
956
1247
  const wasm = await this.#getWasm();
957
1248
  const format = opts?.format ?? wasm.NoteExportFormat.Full;
958
- return await this.#inner.exportNoteFile(noteId, format);
1249
+ return await this.#inner.exportNoteFile(resolveNoteIdHex(noteId), format);
959
1250
  }
960
1251
 
961
1252
  async fetchPrivate(opts) {
@@ -970,11 +1261,27 @@ class NotesResource {
970
1261
  async sendPrivate(opts) {
971
1262
  this.#client.assertNotTerminated();
972
1263
  const wasm = await this.#getWasm();
973
- const noteRecord = await this.#inner.getInputNote(opts.noteId);
974
- if (!noteRecord) {
975
- throw new Error(`Note not found: ${opts.noteId}`);
1264
+
1265
+ let note;
1266
+ const input = opts.note;
1267
+ // Check if input is a Note object (has .id() and .assets() but not .toNote())
1268
+ if (
1269
+ input &&
1270
+ typeof input === "object" &&
1271
+ typeof input.id === "function" &&
1272
+ typeof input.assets === "function" &&
1273
+ typeof input.toNote !== "function"
1274
+ ) {
1275
+ note = input;
1276
+ } else {
1277
+ const noteHex = resolveNoteIdHex(input);
1278
+ const noteRecord = await this.#inner.getInputNote(noteHex);
1279
+ if (!noteRecord) {
1280
+ throw new Error(`Note not found: ${noteHex}`);
1281
+ }
1282
+ note = noteRecord.toNote();
976
1283
  }
977
- const note = noteRecord.toNote();
1284
+
978
1285
  const address = resolveAddress(opts.to, wasm);
979
1286
  await this.#inner.sendPrivateNote(note, address);
980
1287
  }
@@ -986,7 +1293,9 @@ function buildNoteFilter(query, wasm) {
986
1293
  }
987
1294
 
988
1295
  if (query.ids) {
989
- const noteIds = query.ids.map((id) => wasm.NoteId.fromHex(id));
1296
+ const noteIds = query.ids.map((id) =>
1297
+ wasm.NoteId.fromHex(resolveNoteIdHex(id))
1298
+ );
990
1299
  return new wasm.NoteFilter(wasm.NoteFilterTypes.List, noteIds);
991
1300
  }
992
1301
 
@@ -1071,6 +1380,102 @@ class SettingsResource {
1071
1380
  }
1072
1381
  }
1073
1382
 
1383
+ class CompilerResource {
1384
+ #inner;
1385
+ #getWasm;
1386
+ #client;
1387
+
1388
+ constructor(inner, getWasm, client) {
1389
+ this.#inner = inner;
1390
+ this.#getWasm = getWasm;
1391
+ this.#client = client;
1392
+ }
1393
+
1394
+ /**
1395
+ * Compiles MASM code + slots into an AccountComponent ready for accounts.create().
1396
+ *
1397
+ * @param {{ code: string, slots: StorageSlot[], supportAllTypes?: boolean }} opts
1398
+ * @returns {Promise<AccountComponent>}
1399
+ */
1400
+ async component({ code, slots = [], supportAllTypes = true }) {
1401
+ this.#client.assertNotTerminated();
1402
+ const wasm = await this.#getWasm();
1403
+ const builder = this.#inner.createCodeBuilder();
1404
+ const compiled = builder.compileAccountComponentCode(code);
1405
+ const component = wasm.AccountComponent.compile(compiled, slots);
1406
+ return supportAllTypes ? component.withSupportsAllTypes() : component;
1407
+ }
1408
+
1409
+ /**
1410
+ * Compiles a transaction script, optionally linking named libraries inline.
1411
+ *
1412
+ * @param {{ code: string, libraries?: Array<{ namespace: string, code: string, linking?: "dynamic" | "static" }> }} opts
1413
+ * @returns {Promise<TransactionScript>}
1414
+ */
1415
+ async txScript({ code, libraries = [] }) {
1416
+ this.#client.assertNotTerminated();
1417
+ // Ensure WASM is initialized (result unused — only #inner needs it)
1418
+ await this.#getWasm();
1419
+ const builder = this.#inner.createCodeBuilder();
1420
+ for (const lib of libraries) {
1421
+ if (lib && typeof lib.namespace === "string") {
1422
+ // Inline { namespace, code, linking? } — build and link automatically
1423
+ const built = builder.buildLibrary(lib.namespace, lib.code);
1424
+ if (lib.linking === "static") {
1425
+ builder.linkStaticLibrary(built);
1426
+ } else {
1427
+ // Default: "dynamic" — matches existing tutorial behavior
1428
+ builder.linkDynamicLibrary(built);
1429
+ }
1430
+ } else {
1431
+ // Pre-built library object — link dynamically
1432
+ builder.linkDynamicLibrary(lib);
1433
+ }
1434
+ }
1435
+ return builder.compileTxScript(code);
1436
+ }
1437
+ }
1438
+
1439
+ class KeystoreResource {
1440
+ #inner;
1441
+ #client;
1442
+
1443
+ constructor(inner, client) {
1444
+ this.#inner = inner;
1445
+ this.#client = client;
1446
+ }
1447
+
1448
+ async insert(accountId, secretKey) {
1449
+ this.#client.assertNotTerminated();
1450
+ const ks = this.#inner.keystore;
1451
+ return await ks.insert(accountId, secretKey);
1452
+ }
1453
+
1454
+ async get(pubKeyCommitment) {
1455
+ this.#client.assertNotTerminated();
1456
+ const ks = this.#inner.keystore;
1457
+ return await ks.get(pubKeyCommitment);
1458
+ }
1459
+
1460
+ async remove(pubKeyCommitment) {
1461
+ this.#client.assertNotTerminated();
1462
+ const ks = this.#inner.keystore;
1463
+ return await ks.remove(pubKeyCommitment);
1464
+ }
1465
+
1466
+ async getCommitments(accountId) {
1467
+ this.#client.assertNotTerminated();
1468
+ const ks = this.#inner.keystore;
1469
+ return await ks.getCommitments(accountId);
1470
+ }
1471
+
1472
+ async getAccountId(pubKeyCommitment) {
1473
+ this.#client.assertNotTerminated();
1474
+ const ks = this.#inner.keystore;
1475
+ return await ks.getAccountId(pubKeyCommitment);
1476
+ }
1477
+ }
1478
+
1074
1479
  /**
1075
1480
  * MidenClient wraps the existing proxy-wrapped WebClient with a resource-based API.
1076
1481
  *
@@ -1099,15 +1504,24 @@ class MidenClient {
1099
1504
  this.notes = new NotesResource(inner, getWasm, this);
1100
1505
  this.tags = new TagsResource(inner, getWasm, this);
1101
1506
  this.settings = new SettingsResource(inner, getWasm, this);
1507
+ this.compile = new CompilerResource(inner, getWasm, this);
1508
+ this.keystore = new KeystoreResource(inner, this);
1102
1509
  }
1103
1510
 
1104
1511
  /**
1105
1512
  * Creates and initializes a new MidenClient.
1106
1513
  *
1514
+ * If no `rpcUrl` is provided, defaults to testnet with full configuration
1515
+ * (RPC, prover, note transport, autoSync).
1516
+ *
1107
1517
  * @param {ClientOptions} [options] - Client configuration options.
1108
1518
  * @returns {Promise<MidenClient>} A fully initialized client.
1109
1519
  */
1110
1520
  static async create(options) {
1521
+ if (!options?.rpcUrl) {
1522
+ return MidenClient.createTestnet(options);
1523
+ }
1524
+
1111
1525
  const getWasm = MidenClient._getWasmOrThrow;
1112
1526
  const WebClientClass = MidenClient._WasmWebClient;
1113
1527
 
@@ -1119,11 +1533,14 @@ class MidenClient {
1119
1533
 
1120
1534
  const seed = options?.seed ? await hashSeed(options.seed) : undefined;
1121
1535
 
1536
+ const rpcUrl = resolveRpcUrl(options?.rpcUrl);
1537
+ const noteTransportUrl = resolveNoteTransportUrl(options?.noteTransportUrl);
1538
+
1122
1539
  let inner;
1123
1540
  if (options?.keystore) {
1124
1541
  inner = await WebClientClass.createClientWithExternalKeystore(
1125
- options?.rpcUrl,
1126
- options?.noteTransportUrl,
1542
+ rpcUrl,
1543
+ noteTransportUrl,
1127
1544
  seed,
1128
1545
  options?.storeName,
1129
1546
  options.keystore.getKey,
@@ -1132,8 +1549,8 @@ class MidenClient {
1132
1549
  );
1133
1550
  } else {
1134
1551
  inner = await WebClientClass.createClient(
1135
- options?.rpcUrl,
1136
- options?.noteTransportUrl,
1552
+ rpcUrl,
1553
+ noteTransportUrl,
1137
1554
  seed,
1138
1555
  options?.storeName
1139
1556
  );
@@ -1142,10 +1559,7 @@ class MidenClient {
1142
1559
  let defaultProver = null;
1143
1560
  if (options?.proverUrl) {
1144
1561
  const wasm = await getWasm();
1145
- defaultProver = wasm.TransactionProver.newRemoteProver(
1146
- options.proverUrl,
1147
- undefined
1148
- );
1562
+ defaultProver = resolveProver(options.proverUrl, wasm);
1149
1563
  }
1150
1564
 
1151
1565
  const client = new MidenClient(inner, getWasm, defaultProver);
@@ -1159,15 +1573,39 @@ class MidenClient {
1159
1573
 
1160
1574
  /**
1161
1575
  * Creates a client preconfigured for testnet use.
1162
- * Defaults to autoSync: true.
1163
1576
  *
1164
- * @param {object} [options] - Options (autoSync can be overridden).
1577
+ * Defaults: rpcUrl "testnet", proverUrl "testnet", noteTransportUrl "testnet", autoSync true.
1578
+ * All defaults can be overridden via options.
1579
+ *
1580
+ * @param {ClientOptions} [options] - Options to override defaults.
1165
1581
  * @returns {Promise<MidenClient>} A fully initialized testnet client.
1166
1582
  */
1167
1583
  static async createTestnet(options) {
1168
1584
  return MidenClient.create({
1585
+ rpcUrl: "testnet",
1586
+ proverUrl: "testnet",
1587
+ noteTransportUrl: "testnet",
1588
+ autoSync: true,
1589
+ ...options,
1590
+ });
1591
+ }
1592
+
1593
+ /**
1594
+ * Creates a client preconfigured for devnet use.
1595
+ *
1596
+ * Defaults: rpcUrl "devnet", proverUrl "devnet", noteTransportUrl "devnet", autoSync true.
1597
+ * All defaults can be overridden via options.
1598
+ *
1599
+ * @param {ClientOptions} [options] - Options to override defaults.
1600
+ * @returns {Promise<MidenClient>} A fully initialized devnet client.
1601
+ */
1602
+ static async createDevnet(options) {
1603
+ return MidenClient.create({
1604
+ rpcUrl: "devnet",
1605
+ proverUrl: "devnet",
1606
+ noteTransportUrl: "devnet",
1607
+ autoSync: true,
1169
1608
  ...options,
1170
- autoSync: options?.autoSync ?? true,
1171
1609
  });
1172
1610
  }
1173
1611
 
@@ -1244,30 +1682,13 @@ class MidenClient {
1244
1682
  }
1245
1683
 
1246
1684
  /**
1247
- * Exports the client store as a versioned snapshot.
1685
+ * Returns the identifier of the underlying store (e.g. IndexedDB database name, file path).
1248
1686
  *
1249
- * @returns {Promise<StoreSnapshot>} The store snapshot.
1687
+ * @returns {string} The store identifier.
1250
1688
  */
1251
- async exportStore() {
1689
+ storeIdentifier() {
1252
1690
  this.assertNotTerminated();
1253
- const data = await this.#inner.exportStore();
1254
- return { version: 1, data };
1255
- }
1256
-
1257
- /**
1258
- * Imports a previously exported store snapshot.
1259
- *
1260
- * @param {StoreSnapshot} snapshot - The store snapshot to import.
1261
- */
1262
- async importStore(snapshot) {
1263
- this.assertNotTerminated();
1264
- if (!snapshot || snapshot.version !== 1) {
1265
- throw new Error(
1266
- `Unsupported store snapshot version: ${snapshot?.version}. Expected version 1.`
1267
- );
1268
- }
1269
- // Second arg is the store password (empty string = no encryption)
1270
- await this.#inner.forceImportStore(snapshot.data, "");
1691
+ return this.#inner.storeIdentifier();
1271
1692
  }
1272
1693
 
1273
1694
  // ── Mock-only methods ──
@@ -1314,6 +1735,64 @@ class MidenClient {
1314
1735
  }
1315
1736
  }
1316
1737
 
1738
+ const RPC_URLS = {
1739
+ testnet: "https://rpc.testnet.miden.io",
1740
+ devnet: "https://rpc.devnet.miden.io",
1741
+ localhost: "http://localhost:57291",
1742
+ local: "http://localhost:57291",
1743
+ };
1744
+
1745
+ /**
1746
+ * Resolves an rpcUrl shorthand or raw URL into a concrete endpoint string.
1747
+ *
1748
+ * @param {string | undefined} rpcUrl - "testnet", "devnet", "localhost", "local", or a raw URL.
1749
+ * @returns {string | undefined} A fully qualified URL, or undefined to use the SDK default.
1750
+ */
1751
+ function resolveRpcUrl(rpcUrl) {
1752
+ if (!rpcUrl) return undefined;
1753
+ return RPC_URLS[rpcUrl.trim().toLowerCase()] ?? rpcUrl;
1754
+ }
1755
+
1756
+ const PROVER_URLS = {
1757
+ devnet: "https://tx-prover.devnet.miden.io",
1758
+ testnet: "https://tx-prover.testnet.miden.io",
1759
+ };
1760
+
1761
+ const NOTE_TRANSPORT_URLS = {
1762
+ testnet: "https://transport.miden.io",
1763
+ devnet: "https://transport.devnet.miden.io",
1764
+ };
1765
+
1766
+ /**
1767
+ * Resolves a noteTransportUrl shorthand or raw URL into a concrete endpoint string.
1768
+ *
1769
+ * @param {string | undefined} noteTransportUrl - "testnet", "devnet", or a raw URL.
1770
+ * @returns {string | undefined} A fully qualified URL, or undefined if omitted.
1771
+ */
1772
+ function resolveNoteTransportUrl(noteTransportUrl) {
1773
+ if (!noteTransportUrl) return undefined;
1774
+ return (
1775
+ NOTE_TRANSPORT_URLS[noteTransportUrl.trim().toLowerCase()] ??
1776
+ noteTransportUrl
1777
+ );
1778
+ }
1779
+
1780
+ /**
1781
+ * Resolves a proverUrl shorthand or raw URL into a TransactionProver.
1782
+ *
1783
+ * @param {string} proverUrl - "local", "devnet", "testnet", or a raw URL.
1784
+ * @param {object} wasm - Loaded WASM module.
1785
+ * @returns {object} A TransactionProver instance.
1786
+ */
1787
+ function resolveProver(proverUrl, wasm) {
1788
+ const normalized = proverUrl.trim().toLowerCase();
1789
+ if (normalized === "local") {
1790
+ return wasm.TransactionProver.newLocalProver();
1791
+ }
1792
+ const remoteUrl = PROVER_URLS[normalized] ?? proverUrl;
1793
+ return wasm.TransactionProver.newRemoteProver(remoteUrl, undefined);
1794
+ }
1795
+
1317
1796
  // Module-level WASM reference, set by index.js after initialization
1318
1797
  let _wasm = null;
1319
1798
  let _WebClient = null;
@@ -1339,7 +1818,7 @@ function getWasm() {
1339
1818
  * Creates a P2ID (Pay-to-ID) note.
1340
1819
  *
1341
1820
  * @param {NoteOptions} opts - Note creation options.
1342
- * @returns {OutputNote} The created output note.
1821
+ * @returns {Note} The created note.
1343
1822
  */
1344
1823
  function createP2IDNote(opts) {
1345
1824
  const wasm = getWasm();
@@ -1351,21 +1830,20 @@ function createP2IDNote(opts) {
1351
1830
  ? new wasm.NoteAttachment(opts.attachment)
1352
1831
  : new wasm.NoteAttachment([]);
1353
1832
 
1354
- const note = wasm.Note.createP2IDNote(
1833
+ return wasm.Note.createP2IDNote(
1355
1834
  sender,
1356
1835
  target,
1357
1836
  noteAssets,
1358
1837
  noteType,
1359
1838
  attachment
1360
1839
  );
1361
- return wasm.OutputNote.full(note);
1362
1840
  }
1363
1841
 
1364
1842
  /**
1365
1843
  * Creates a P2IDE (Pay-to-ID with Expiration) note.
1366
1844
  *
1367
1845
  * @param {P2IDEOptions} opts - Note creation options with timelock/reclaim.
1368
- * @returns {OutputNote} The created output note.
1846
+ * @returns {Note} The created note.
1369
1847
  */
1370
1848
  function createP2IDENote(opts) {
1371
1849
  const wasm = getWasm();
@@ -1377,7 +1855,7 @@ function createP2IDENote(opts) {
1377
1855
  ? new wasm.NoteAttachment(opts.attachment)
1378
1856
  : new wasm.NoteAttachment([]);
1379
1857
 
1380
- const note = wasm.Note.createP2IDENote(
1858
+ return wasm.Note.createP2IDENote(
1381
1859
  sender,
1382
1860
  target,
1383
1861
  noteAssets,
@@ -1386,7 +1864,6 @@ function createP2IDENote(opts) {
1386
1864
  noteType,
1387
1865
  attachment
1388
1866
  );
1389
- return wasm.OutputNote.full(note);
1390
1867
  }
1391
1868
 
1392
1869
  /**
@@ -1425,9 +1902,16 @@ function buildNoteAssets(assets, wasm) {
1425
1902
  }
1426
1903
 
1427
1904
  const AccountType = Object.freeze({
1428
- MutableWallet: "MutableWallet",
1429
- ImmutableWallet: "ImmutableWallet",
1430
- FungibleFaucet: "FungibleFaucet",
1905
+ // WASM-compatible numeric values — usable with AccountBuilder directly
1906
+ FungibleFaucet: 0,
1907
+ NonFungibleFaucet: 1,
1908
+ RegularAccountImmutableCode: 2,
1909
+ RegularAccountUpdatableCode: 3,
1910
+ // SDK-friendly aliases (same numeric values as their WASM equivalents)
1911
+ MutableWallet: 3,
1912
+ ImmutableWallet: 2,
1913
+ ImmutableContract: 2,
1914
+ MutableContract: 3,
1431
1915
  });
1432
1916
 
1433
1917
  const AuthScheme = Object.freeze({
@@ -1435,6 +1919,19 @@ const AuthScheme = Object.freeze({
1435
1919
  ECDSA: "ecdsa",
1436
1920
  });
1437
1921
 
1922
+ const NoteVisibility = Object.freeze({
1923
+ Public: "public",
1924
+ Private: "private",
1925
+ });
1926
+
1927
+ const StorageMode = Object.freeze({
1928
+ Public: "public",
1929
+ Private: "private",
1930
+ Network: "network",
1931
+ });
1932
+
1933
+ const MOCK_STORE_NAME = "mock_client_db";
1934
+
1438
1935
  const buildTypedArraysExport = (exportObject) => {
1439
1936
  return Object.entries(exportObject).reduce(
1440
1937
  (exports$1, [exportName, _export]) => {
@@ -1908,6 +2405,20 @@ class WebClient {
1908
2405
  });
1909
2406
  }
1910
2407
 
2408
+ async newAccount(account, overwrite) {
2409
+ return this._serializeWasmCall(async () => {
2410
+ const wasmWebClient = await this.getWasmWebClient();
2411
+ return await wasmWebClient.newAccount(account, overwrite);
2412
+ });
2413
+ }
2414
+
2415
+ async newAccountWithSecretKey(account, secretKey) {
2416
+ return this._serializeWasmCall(async () => {
2417
+ const wasmWebClient = await this.getWasmWebClient();
2418
+ return await wasmWebClient.newAccountWithSecretKey(account, secretKey);
2419
+ });
2420
+ }
2421
+
1911
2422
  async submitNewTransaction(accountId, transactionRequest) {
1912
2423
  try {
1913
2424
  if (!this.worker) {
@@ -2136,7 +2647,16 @@ class WebClient {
2136
2647
 
2137
2648
  class MockWebClient extends WebClient {
2138
2649
  constructor(seed, logLevel) {
2139
- super(null, null, seed, "mock", undefined, undefined, undefined, logLevel);
2650
+ super(
2651
+ null,
2652
+ null,
2653
+ seed,
2654
+ MOCK_STORE_NAME,
2655
+ undefined,
2656
+ undefined,
2657
+ undefined,
2658
+ logLevel
2659
+ );
2140
2660
  }
2141
2661
 
2142
2662
  initializeWorker() {
@@ -2377,5 +2897,5 @@ MidenClient._MockWasmWebClient = MockWebClient;
2377
2897
  MidenClient._getWasmOrThrow = getWasmOrThrow;
2378
2898
  _setWebClient(WebClient);
2379
2899
 
2380
- export { AccountType, AuthScheme, MidenArrays, MidenClient, MockWebClient as MockWasmWebClient, WebClient as WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, getWasmOrThrow };
2900
+ export { AccountType, AuthScheme, MidenArrays, MidenClient, MockWebClient as MockWasmWebClient, NoteVisibility, StorageMode, WebClient as WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, getWasmOrThrow };
2381
2901
  //# sourceMappingURL=index.js.map