@miden-sdk/miden-sdk 0.15.6 → 0.16.0-alpha.1

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 (52) hide show
  1. package/README.md +0 -137
  2. package/dist/mt/{workers/Cargo-mvyTli7g-BwMMSyoq.js → Cargo-DKsyWYgG.js} +699 -1202
  3. package/dist/mt/Cargo-DKsyWYgG.js.map +1 -0
  4. package/dist/mt/api-types.d.ts +38 -250
  5. package/dist/mt/assets/miden_client_web.wasm +0 -0
  6. package/dist/mt/crates/miden_client_web.d.ts +179 -370
  7. package/dist/mt/docs-entry.d.ts +3 -6
  8. package/dist/mt/eager.js +1 -1
  9. package/dist/mt/index.d.ts +0 -3
  10. package/dist/mt/index.js +49 -450
  11. package/dist/mt/index.js.map +1 -1
  12. package/dist/mt/wasm.js +1 -1
  13. package/dist/mt/workerHelpers.js +1 -1
  14. package/dist/mt/{Cargo-mvyTli7g.js → workers/Cargo-DKsyWYgG-DfOhgt23.js} +700 -1201
  15. package/dist/mt/workers/Cargo-DKsyWYgG-DfOhgt23.js.map +1 -0
  16. package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
  17. package/dist/mt/workers/web-client-methods-worker.js +703 -1207
  18. package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
  19. package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
  20. package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
  21. package/dist/mt/workers/workerHelpers.js +1 -1
  22. package/dist/st/{workers/Cargo-Cysp4vto-BIw-TeJn.js → Cargo-LwITdlzJ.js} +694 -1195
  23. package/dist/st/Cargo-LwITdlzJ.js.map +1 -0
  24. package/dist/st/api-types.d.ts +38 -250
  25. package/dist/st/assets/miden_client_web.wasm +0 -0
  26. package/dist/st/crates/miden_client_web.d.ts +179 -370
  27. package/dist/st/docs-entry.d.ts +3 -6
  28. package/dist/st/eager.js +1 -1
  29. package/dist/st/index.d.ts +0 -3
  30. package/dist/st/index.js +49 -450
  31. package/dist/st/index.js.map +1 -1
  32. package/dist/st/wasm.js +1 -1
  33. package/dist/st/{Cargo-Cysp4vto.js → workers/Cargo-LwITdlzJ-Dyl2bCwN.js} +695 -1194
  34. package/dist/st/workers/Cargo-LwITdlzJ-Dyl2bCwN.js.map +1 -0
  35. package/dist/st/workers/assets/miden_client_web.wasm +0 -0
  36. package/dist/st/workers/web-client-methods-worker.js +698 -1200
  37. package/dist/st/workers/web-client-methods-worker.js.map +1 -1
  38. package/dist/st/workers/web-client-methods-worker.module.js +1 -1
  39. package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
  40. package/js/client.js +2 -4
  41. package/js/node/client-factory.js +4 -11
  42. package/js/node/napi-compat.js +1 -0
  43. package/js/node-index.js +11 -10
  44. package/js/resources/compiler.js +23 -12
  45. package/js/resources/transactions.js +20 -289
  46. package/js/standalone.js +3 -61
  47. package/package.json +4 -4
  48. package/dist/mt/Cargo-mvyTli7g.js.map +0 -1
  49. package/dist/mt/workers/Cargo-mvyTli7g-BwMMSyoq.js.map +0 -1
  50. package/dist/st/Cargo-Cysp4vto.js.map +0 -1
  51. package/dist/st/workers/Cargo-Cysp4vto-BIw-TeJn.js.map +0 -1
  52. package/js/resources/pswap.js +0 -132
@@ -26,16 +26,13 @@ import type {
26
26
  NoteExportFormat,
27
27
  StorageSlot,
28
28
  AccountComponent,
29
+ Library,
29
30
  AuthSecretKey,
30
31
  AccountStorageRequirements,
31
32
  TransactionScript,
32
33
  NoteScript,
33
- NoteRecipient,
34
- NoteExecutionHint,
35
- NetworkAccountTarget,
36
34
  AdviceInputs,
37
35
  FeltArray,
38
- PswapLineageRecord,
39
36
  } from "./crates/miden_client_web.js";
40
37
 
41
38
  // Import the full namespace for the MidenArrayConstructors type
@@ -190,8 +187,6 @@ export interface ClientOptions {
190
187
  storeName?: string;
191
188
  /** Sync state on creation (default: false). */
192
189
  autoSync?: boolean;
193
- /** Enable debug mode for transaction execution (default: false). */
194
- debugMode?: boolean;
195
190
  /** External keystore callbacks. */
196
191
  keystore?: {
197
192
  getKey: GetKeyCallback;
@@ -360,48 +355,6 @@ export interface SendResult {
360
355
  result: TransactionResult;
361
356
  }
362
357
 
363
- /**
364
- * Options for {@link TransactionsResource.createNetworkNote} and the standalone
365
- * {@link buildNetworkNote}. Builds a Public, custom-script note carrying a
366
- * `NetworkAccountTarget` attachment so a public network account auto-consumes it.
367
- *
368
- * Provide exactly one of `recipient` or `script`.
369
- */
370
- export interface NetworkNoteOptions extends TransactionOptions {
371
- /** Account that creates, funds, and submits the note (the executing sender). */
372
- account: AccountRef;
373
- /**
374
- * The network account the note targets. Any account reference, or a pre-built
375
- * `NetworkAccountTarget`. Encoded as the note's `NetworkAccountTarget`
376
- * attachment — this is what makes `isNetworkNote()` true.
377
- */
378
- target: AccountRef | NetworkAccountTarget;
379
- /** Execution hint when `target` is an account reference. Defaults to `always`. */
380
- executionHint?: NoteExecutionHint;
381
- /**
382
- * Recipient carrying the note's custom consumption script. Build with
383
- * `new NoteRecipient(serialNum, noteScript, noteStorage)`, or omit and pass
384
- * `script` to have the recipient built for you.
385
- */
386
- recipient?: NoteRecipient;
387
- /** Custom consumption script; the recipient is built with a fresh serial number. */
388
- script?: NoteScript;
389
- /** Note storage / inputs the script reads (used with `script`). */
390
- inputs?: bigint[];
391
- /** Assets locked into the note. Optional — a note may carry no assets. */
392
- assets?: Asset | Asset[];
393
- /** Extra attachment payload appended AFTER the required `NetworkAccountTarget`. */
394
- attachment?: bigint[];
395
- }
396
-
397
- /** Result of {@link TransactionsResource.createNetworkNote}. */
398
- export interface NetworkNoteResult {
399
- txId: TransactionId;
400
- /** The built network note (read its id / attachments). */
401
- note: Note;
402
- result: TransactionResult;
403
- }
404
-
405
358
  /** Result of methods that previously returned bare TransactionId. */
406
359
  export interface TransactionSubmitResult {
407
360
  txId: TransactionId;
@@ -419,21 +372,6 @@ export interface MintOptions extends TransactionOptions {
419
372
  type?: NoteVisibility;
420
373
  }
421
374
 
422
- export interface BridgeOptions extends TransactionOptions {
423
- /** Account that creates and funds the bridge note (the sender / executing account). */
424
- account: AccountRef;
425
- /** Bridge account that consumes the note and burns the bridged asset. */
426
- bridgeAccount: AccountRef;
427
- /** Faucet / token ID of the fungible asset to bridge. */
428
- token: AccountRef;
429
- /** Amount of the asset to bridge. */
430
- amount: number | bigint;
431
- /** AggLayer-assigned network ID of the destination chain. */
432
- destinationNetwork: number;
433
- /** Destination Ethereum address on the destination network (0x-prefixed hex). */
434
- destinationAddress: string;
435
- }
436
-
437
375
  export interface ConsumeOptions extends TransactionOptions {
438
376
  account: AccountRef;
439
377
  notes: NoteInput | NoteInput[];
@@ -444,73 +382,6 @@ export interface ConsumeAllOptions extends TransactionOptions {
444
382
  maxNotes?: number;
445
383
  }
446
384
 
447
- /**
448
- * A single operation inside a transaction batch. The shape mirrors the
449
- * singular options types (`SendOptions`, `MintOptions`, ...) minus the
450
- * `account` field — the executing account is set once at the batch level
451
- * and shared by every operation (V1 single-account constraint).
452
- */
453
- export type BatchOperation =
454
- | {
455
- kind: "send";
456
- to: AccountRef;
457
- token: AccountRef;
458
- amount: number | bigint;
459
- type?: NoteVisibility;
460
- reclaimAfter?: number;
461
- timelockUntil?: number;
462
- }
463
- | {
464
- kind: "mint";
465
- to: AccountRef;
466
- amount: number | bigint;
467
- type?: NoteVisibility;
468
- }
469
- | {
470
- kind: "consume";
471
- notes: NoteInput | NoteInput[];
472
- }
473
- | {
474
- kind: "swap";
475
- offer: Asset;
476
- request: Asset;
477
- type?: NoteVisibility;
478
- paybackType?: NoteVisibility;
479
- }
480
- | {
481
- kind: "execute";
482
- script: TransactionScript;
483
- foreignAccounts?: (
484
- | AccountRef
485
- | { id: AccountRef; storage?: AccountStorageRequirements }
486
- )[];
487
- }
488
- | {
489
- /** Escape hatch for pre-built TransactionRequests. */
490
- kind: "custom";
491
- request: TransactionRequest;
492
- };
493
-
494
- export interface BatchOptions {
495
- /** The account executing every operation in the batch (single-account in V1). */
496
- account: AccountRef;
497
- /** Operations to execute atomically as a batch. Must be non-empty. */
498
- operations: BatchOperation[];
499
- /**
500
- * Wait until the batch's block has been observed in the local sync height.
501
- * Differs from singular `waitForConfirmation`: the V1 batch API returns
502
- * only a block number, so we poll chain height rather than per-tx status.
503
- */
504
- waitForConfirmation?: boolean;
505
- /** Wall-clock polling timeout for `waitForConfirmation` (default 60_000ms). */
506
- timeout?: number;
507
- }
508
-
509
- export interface BatchSubmitResult {
510
- /** The block number the batch was accepted into. */
511
- blockNumber: number;
512
- }
513
-
514
385
  export interface SwapOptions extends TransactionOptions {
515
386
  account: AccountRef;
516
387
  offer: Asset;
@@ -554,18 +425,6 @@ export interface PswapCancelOptions extends TransactionOptions {
554
425
  note: NoteInput;
555
426
  }
556
427
 
557
- export interface PswapCancelByOrderOptions extends TransactionOptions {
558
- /**
559
- * Stable order id of the lineage to cancel, as reported by
560
- * {@link PswapLineageRecord.orderId}. Accepts the decimal string or a
561
- * `bigint`. `number` is rejected: a PSWAP order id is `u64`-shaped and
562
- * routinely exceeds `Number.MAX_SAFE_INTEGER`, which a JS `number` cannot
563
- * represent without silent precision loss. The creator account and current
564
- * tip note are resolved from the tracked lineage.
565
- */
566
- orderId: string | bigint;
567
- }
568
-
569
428
  export interface ExecuteOptions extends TransactionOptions {
570
429
  /** Account executing the custom script. */
571
430
  account: AccountRef;
@@ -611,16 +470,6 @@ export interface PreviewMintOptions {
611
470
  type?: NoteVisibility;
612
471
  }
613
472
 
614
- export interface PreviewBridgeOptions {
615
- operation: "bridge";
616
- account: AccountRef;
617
- bridgeAccount: AccountRef;
618
- token: AccountRef;
619
- amount: number | bigint;
620
- destinationNetwork: number;
621
- destinationAddress: string;
622
- }
623
-
624
473
  export interface PreviewConsumeOptions {
625
474
  operation: "consume";
626
475
  account: AccountRef;
@@ -668,7 +517,6 @@ export interface PreviewCustomOptions {
668
517
  export type PreviewOptions =
669
518
  | PreviewSendOptions
670
519
  | PreviewMintOptions
671
- | PreviewBridgeOptions
672
520
  | PreviewConsumeOptions
673
521
  | PreviewSwapOptions
674
522
  | PreviewPswapCreateOptions
@@ -724,7 +572,7 @@ export type NoteQuery =
724
572
  export interface NoteOptions {
725
573
  from: AccountRef;
726
574
  to: AccountRef;
727
- assets: Asset | Asset[];
575
+ assets: Asset | [Asset, ...Asset[]];
728
576
  type?: NoteVisibility;
729
577
  attachment?: Felt[];
730
578
  }
@@ -868,22 +716,6 @@ export interface TransactionsResource {
868
716
  * @param options - Mint options including the faucet, recipient, and amount.
869
717
  */
870
718
  mint(options: MintOptions): Promise<TransactionSubmitResult>;
871
- /**
872
- * Builds a Public custom-script note carrying a `NetworkAccountTarget`
873
- * attachment, submits it as an own output note, and (optionally) waits for
874
- * confirmation. The submitted note satisfies `Note.isNetworkNote()`, so a
875
- * public network account will auto-consume it.
876
- */
877
- createNetworkNote(options: NetworkNoteOptions): Promise<NetworkNoteResult>;
878
- /**
879
- * Bridge a fungible asset out to another network via the AggLayer. Emits a
880
- * single public B2AGG (Bridge-to-AggLayer) note that the bridge account
881
- * consumes, burning the asset so it can be claimed at the destination
882
- * Ethereum address on the destination network.
883
- *
884
- * @param options - Sender, bridge account, token, amount, and destination.
885
- */
886
- bridge(options: BridgeOptions): Promise<TransactionSubmitResult>;
887
719
  /**
888
720
  * Consume one or more notes for an account.
889
721
  *
@@ -936,8 +768,18 @@ export interface TransactionsResource {
936
768
  execute(options: ExecuteOptions): Promise<TransactionSubmitResult>;
937
769
 
938
770
  /**
939
- * Dry-run a transaction to preview its effects without submitting it to
940
- * the network.
771
+ * Dry-run a transaction to obtain the {@link TransactionSummary} the
772
+ * account is being asked to authorize, without submitting anything to the
773
+ * network.
774
+ *
775
+ * The summary only exists while authorization is pending: it is returned
776
+ * when the account's auth procedure aborts with the unauthorized event
777
+ * (e.g. a multisig below its signing threshold), so it can be signed
778
+ * out-of-band. If the transaction is already fully authorized, execution
779
+ * succeeds without producing a summary and this method rejects with an
780
+ * error whose `code` is `"TRANSACTION_ALREADY_AUTHORIZED"` (on Node.js the
781
+ * code prefixes the error message instead) — submit the transaction with
782
+ * `execute` instead.
941
783
  *
942
784
  * @param options - Preview options discriminated by `operation` field.
943
785
  */
@@ -957,34 +799,6 @@ export interface TransactionsResource {
957
799
  options?: TransactionOptions
958
800
  ): Promise<TransactionSubmitResult>;
959
801
 
960
- /**
961
- * Execute a heterogeneous batch of operations against a single account.
962
- * Each operation is built, proven individually and as a batch, and all
963
- * operations are submitted atomically — either every tx in the batch
964
- * lands or none does.
965
- *
966
- * V1 supports only same-account batches (mirrors the underlying Rust
967
- * `Client::new_transaction_batch()` constraint).
968
- *
969
- * @param options - Batch options including the account and operations.
970
- */
971
- batch(options: BatchOptions): Promise<BatchSubmitResult>;
972
-
973
- /**
974
- * Submit pre-built TransactionRequests as an atomic batch. Plural
975
- * counterpart of {@link submit} — for callers that already have built
976
- * requests in hand and want to skip the high-level operation builders.
977
- *
978
- * @param account - The account executing every transaction in the batch.
979
- * @param requests - Pre-built transaction requests (must be non-empty).
980
- * @param options - Optional batch settings (waitForConfirmation, timeout, prover).
981
- */
982
- submitBatch(
983
- account: AccountRef,
984
- requests: TransactionRequest[],
985
- options?: Omit<BatchOptions, "account" | "operations">
986
- ): Promise<BatchSubmitResult>;
987
-
988
802
  /** Execute a program (view call) and return the resulting stack output. */
989
803
  executeProgram(options: ExecuteProgramOptions): Promise<FeltArray>;
990
804
 
@@ -1005,46 +819,6 @@ export interface TransactionsResource {
1005
819
  waitFor(txId: string | TransactionId, options?: WaitOptions): Promise<void>;
1006
820
  }
1007
821
 
1008
- export interface PswapResource {
1009
- /**
1010
- * Returns every partial-swap (PSWAP) lineage tracked by this client. A
1011
- * lineage records how a PSWAP note has been filled round by round, from the
1012
- * original note through each remainder to the current tip.
1013
- */
1014
- lineages(): Promise<PswapLineageRecord[]>;
1015
- /**
1016
- * Returns the PSWAP lineages created by a specific local account.
1017
- *
1018
- * @param account - Creator account (hex, bech32, `Account`, or `AccountId`).
1019
- */
1020
- lineagesFor(account: AccountRef): Promise<PswapLineageRecord[]>;
1021
- /**
1022
- * Returns the lineage for a single order, or `null` if this client is not
1023
- * tracking it — either because the order was not created by this client, or
1024
- * because tracking did not register when it was created. Registration runs as
1025
- * a transaction observer at create time and does not block the create
1026
- * transaction if it fails.
1027
- *
1028
- * @param orderId - Stable order id (decimal string or bigint). `number` is
1029
- * rejected: a PSWAP order id is `u64`-shaped and routinely exceeds
1030
- * `Number.MAX_SAFE_INTEGER`, which a JS `number` cannot represent without
1031
- * silent precision loss.
1032
- */
1033
- lineage(orderId: string | bigint): Promise<PswapLineageRecord | null>;
1034
- /**
1035
- * Reclaim the unfilled offered asset on the current tip of an active
1036
- * lineage, identified by its stable order id. Builds the cancel transaction,
1037
- * resolves the creator account from the tracked lineage, and submits it
1038
- * through the same prove/submit path as the other transaction helpers.
1039
- * Throws if no lineage is tracked for the order.
1040
- *
1041
- * @param options - Order id and optional transaction options.
1042
- */
1043
- cancelByOrder(
1044
- options: PswapCancelByOrderOptions
1045
- ): Promise<TransactionSubmitResult>;
1046
- }
1047
-
1048
822
  export interface NotesResource {
1049
823
  /**
1050
824
  * List received (input) notes, optionally filtered by status or IDs.
@@ -1113,6 +887,11 @@ export interface NotesResource {
1113
887
  export interface CompileComponentOptions {
1114
888
  /** MASM source code for the component. */
1115
889
  code: string;
890
+ /**
891
+ * Module path used to derive procedure identities. Use the same namespace when
892
+ * linking this component into transaction scripts.
893
+ */
894
+ namespace?: string;
1116
895
  /** Initial storage slots for the component. */
1117
896
  slots?: StorageSlot[];
1118
897
  /**
@@ -1139,18 +918,35 @@ export interface CompileTxScriptLibrary {
1139
918
  linking?: Linking;
1140
919
  }
1141
920
 
921
+ /** Links the exact compiled code installed by an account component. */
922
+ export interface CompileAccountComponentLibrary {
923
+ /** Account component whose installed code should be linked. */
924
+ component: AccountComponent;
925
+ /**
926
+ * `Linking.Dynamic` (default) — procedures are linked via DYNCALL at runtime.
927
+ * `Linking.Static` — procedures are inlined at compile time.
928
+ */
929
+ linking?: Linking;
930
+ }
931
+
932
+ /** A script library supplied inline, pre-built, or from an installed account component. */
933
+ export type CompileScriptLibrary =
934
+ | CompileTxScriptLibrary
935
+ | CompileAccountComponentLibrary
936
+ | Library;
937
+
1142
938
  export interface CompileTxScriptOptions {
1143
939
  /** MASM source code for the transaction script. */
1144
940
  code: string;
1145
941
  /** Component libraries to link. */
1146
- libraries?: CompileTxScriptLibrary[];
942
+ libraries?: CompileScriptLibrary[];
1147
943
  }
1148
944
 
1149
945
  export interface CompileNoteScriptOptions {
1150
946
  /** MASM source code for the note script. */
1151
947
  code: string;
1152
948
  /** Component libraries to link. */
1153
- libraries?: CompileTxScriptLibrary[];
949
+ libraries?: CompileScriptLibrary[];
1154
950
  }
1155
951
 
1156
952
  export declare class CompilerResource {
@@ -1281,7 +1077,6 @@ export declare class MidenClient {
1281
1077
  readonly settings: SettingsResource;
1282
1078
  readonly compile: CompilerResource;
1283
1079
  readonly keystore: KeystoreResource;
1284
- readonly pswap: PswapResource;
1285
1080
 
1286
1081
  /** Syncs the client: fetches private notes from the Note Transport Layer, then syncs on-chain state. Fails fast on either. */
1287
1082
  sync(): Promise<SyncSummary>;
@@ -1355,13 +1150,6 @@ export declare function createP2IDENote(
1355
1150
  options: P2IDEOptions
1356
1151
  ): ReturnType<WasmModule["Note"]["createP2IDENote"]>;
1357
1152
 
1358
- /**
1359
- * Builds (without submitting) a Public custom-script note carrying a
1360
- * `NetworkAccountTarget` attachment. Provide exactly one of `recipient` or
1361
- * `script`.
1362
- */
1363
- export declare function buildNetworkNote(opts: NetworkNoteOptions): Note;
1364
-
1365
1153
  /** Builds a swap tag for note matching. Returns a NoteTag (use `.asU32()` for the numeric value). */
1366
1154
  export declare function buildSwapTag(
1367
1155
  options: BuildSwapTagOptions