@miden-sdk/miden-sdk 0.15.7 → 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 -152
  2. package/dist/mt/{Cargo-CnGom-_z.js → Cargo-DKsyWYgG.js} +700 -1245
  3. package/dist/mt/Cargo-DKsyWYgG.js.map +1 -0
  4. package/dist/mt/api-types.d.ts +38 -370
  5. package/dist/mt/assets/miden_client_web.wasm +0 -0
  6. package/dist/mt/crates/miden_client_web.d.ts +179 -402
  7. package/dist/mt/docs-entry.d.ts +3 -9
  8. package/dist/mt/eager.js +1 -1
  9. package/dist/mt/index.d.ts +0 -3
  10. package/dist/mt/index.js +53 -701
  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/workers/{Cargo-CnGom-_z-X_3VwTbo.js → Cargo-DKsyWYgG-DfOhgt23.js} +700 -1245
  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 -1251
  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/{Cargo-DR9fiMbE.js → Cargo-LwITdlzJ.js} +695 -1237
  23. package/dist/st/Cargo-LwITdlzJ.js.map +1 -0
  24. package/dist/st/api-types.d.ts +38 -370
  25. package/dist/st/assets/miden_client_web.wasm +0 -0
  26. package/dist/st/crates/miden_client_web.d.ts +179 -402
  27. package/dist/st/docs-entry.d.ts +3 -9
  28. package/dist/st/eager.js +1 -1
  29. package/dist/st/index.d.ts +0 -3
  30. package/dist/st/index.js +53 -701
  31. package/dist/st/index.js.map +1 -1
  32. package/dist/st/wasm.js +1 -1
  33. package/dist/st/workers/{Cargo-DR9fiMbE-C0G0clA_.js → Cargo-LwITdlzJ-Dyl2bCwN.js} +695 -1237
  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 -1243
  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 -11
  44. package/js/resources/compiler.js +23 -12
  45. package/js/resources/transactions.js +24 -540
  46. package/js/standalone.js +3 -61
  47. package/package.json +4 -4
  48. package/dist/mt/Cargo-CnGom-_z.js.map +0 -1
  49. package/dist/mt/workers/Cargo-CnGom-_z-X_3VwTbo.js.map +0 -1
  50. package/dist/st/Cargo-DR9fiMbE.js.map +0 -1
  51. package/dist/st/workers/Cargo-DR9fiMbE-C0G0clA_.js.map +0 -1
  52. package/js/resources/pswap.js +0 -132
package/README.md CHANGED
@@ -423,26 +423,6 @@ console.log(faucet.id().toString());
423
423
  console.log(faucet.isFaucet()); // true
424
424
  ```
425
425
 
426
- ### Read Faucet Metadata
427
-
428
- `BasicFungibleFaucetComponent` extracts the on-chain token metadata from a faucet account. The same
429
- component backs both basic and network-style faucets, so it works for either:
430
-
431
- ```typescript
432
- import { BasicFungibleFaucetComponent } from "@miden-sdk/miden-sdk";
433
-
434
- const faucet = BasicFungibleFaucetComponent.fromAccount(account);
435
-
436
- faucet.symbol().toString(); // "DAG"
437
- faucet.tokenName(); // "DAG Token"
438
- faucet.decimals(); // 8
439
- faucet.maxSupply().toString(); // "10000000"
440
- faucet.tokenSupply().toString(); // amount minted so far, e.g. "0"
441
- faucet.description(); // string | undefined
442
- faucet.logoUri(); // string | undefined
443
- faucet.externalLink(); // string | undefined
444
- ```
445
-
446
426
  ### Send Tokens
447
427
 
448
428
  ```typescript
@@ -472,138 +452,6 @@ const balance = await client.accounts.getBalance(wallet, dagToken);
472
452
  console.log(`Balance: ${balance}`);
473
453
  ```
474
454
 
475
- ### Batch Operations
476
-
477
- Submit multiple operations against a single account as one atomic batch — every transaction in the batch lands together or none does. Each operation builds its own `TransactionRequest` internally; you don't have to assemble or serialize them yourself.
478
-
479
- ```typescript
480
- const { blockNumber } = await client.transactions.batch({
481
- account: wallet,
482
- operations: [
483
- { kind: "send", to: alice, token: dagToken, amount: 50n, type: "public" },
484
- { kind: "send", to: bob, token: dagToken, amount: 30n, type: "public" },
485
- { kind: "consume", notes: pendingNotes },
486
- ],
487
- waitForConfirmation: true,
488
- });
489
- console.log(`Batch landed in block ${blockNumber}`);
490
- ```
491
-
492
- Operations are discriminated by `kind`: `"send"`, `"mint"`, `"consume"`, `"swap"`, `"execute"`, and `"custom"` (escape hatch for a pre-built `TransactionRequest`). The shape of each operation mirrors the singular options object (`SendOptions`, `MintOptions`, …) minus the `account` field, which is set once at the batch level.
493
-
494
- V1 supports only same-account batches — every operation must execute against the `account` passed at the top level. Mixing accounts in one batch is not supported.
495
-
496
- For callers that already hold pre-built `TransactionRequest`s, `submitBatch` skips the high-level builders:
497
-
498
- ```typescript
499
- const { blockNumber } = await client.transactions.submitBatch(wallet, [
500
- request1,
501
- request2,
502
- ]);
503
- ```
504
-
505
- The V1 batch primitive returns only the block number — there are no per-tx ids in the result. `waitForConfirmation` polls local sync height until it reaches `blockNumber` (rather than per-tx polling like singular `send` / `consume`).
506
-
507
- ### Manual Transaction Lifecycle
508
-
509
- `client.transactions.submit(account, request)` runs execute → prove → submit → apply in one call. To drive the stages yourself — benchmarking each step or handling errors per stage — `executeRequest` returns a staged handle you advance one step at a time. Each stage carries its own context, so you never re-thread the result or block number:
510
-
511
- ```typescript
512
- const executed = await client.transactions.executeRequest(wallet, request); // local only
513
- const proven = await executed.prove(); // optional { prover } override
514
- const submitted = await proven.submit(); // network; submitted.blockNumber
515
- await submitted.apply(); // persist + fire observers
516
- ```
517
-
518
- Nothing is persisted until `apply` runs — stopping after `submit()` leaves the local store unaware of the transaction until the next sync. `submitted.waitForConfirmation()` blocks until the transaction commits on-chain.
519
-
520
- To submit a proof produced somewhere that shares nothing with this client (a detached prover), pass it back in with `client.transactions.submitProven(proof, result)`, which returns the same submitted handle.
521
-
522
- ### Partial-Swap (PSWAP) Orders
523
-
524
- A partial-swap note offers one asset for another and can be filled by multiple
525
- counterparties over time — each partial fill pays the creator and leaves a
526
- remainder note carrying the unfilled balance. The client tracks that chain as a
527
- **lineage** keyed by a stable `orderId`, advancing it round by round as fills
528
- are discovered on sync.
529
-
530
- ```typescript
531
- // Offer 100 of token A for 25 of token B.
532
- await client.transactions.pswapCreate({
533
- account: wallet,
534
- offer: { token: aToken, amount: 100n },
535
- request: { token: bToken, amount: 25n }
536
- });
537
- await client.sync();
538
-
539
- // The order is tracked as a lineage keyed by a stable order id.
540
- const [lineage] = await client.pswap.lineagesFor(wallet);
541
- const orderId = lineage.orderId();
542
- console.log(lineage.remainingOffered().toString()); // unfilled offered balance
543
-
544
- // A counterparty fills part of the order:
545
- // client.transactions.pswapConsume({ account, note, fillAmount });
546
- // On the next sync the lineage advances, and `remainingOffered()` shrinks.
547
-
548
- // Reclaim the unfilled remainder on the current tip, by stable order id.
549
- // `waitForConfirmation` blocks until the cancel commits AND a sync brings
550
- // the consumed-note update down; without it, the call resolves at submit
551
- // time and `pswap.lineage(orderId)` still reads `Active` until the next
552
- // sync. The lineage only transitions to `Reclaimed` once the chain sees
553
- // the cancel land.
554
- await client.pswap.cancelByOrder({ orderId, waitForConfirmation: true });
555
- ```
556
-
557
- `client.pswap.lineages()` returns every order this client created;
558
- `client.pswap.lineage(orderId)` returns one order's lineage, or `null` if it is
559
- not tracked.
560
-
561
- ### Bridge out (AggLayer)
562
-
563
- `client.transactions.bridge(...)` bridges a fungible asset out to another network via the AggLayer. It emits a single public B2AGG note that the bridge account consumes, burning the asset so it can be claimed at the destination Ethereum address on the AggLayer-assigned network.
564
-
565
- ```typescript
566
- await client.transactions.bridge({
567
- account: wallet, // sender (executes the transaction)
568
- bridgeAccount: bridge, // consumes the note and burns the asset
569
- token: dagToken, // faucet of the asset being bridged
570
- amount: 100n,
571
- destinationNetwork: 1, // AggLayer-assigned network id
572
- destinationAddress: "0x000000000000000000000000000000000000dEaD"
573
- });
574
- ```
575
-
576
- The 20-byte destination is also available as an `EthAddress` (`EthAddress.fromHex("0x…")`) for the lower-level builders `Note.createB2AggNote(...)` and `client.newB2AggTransactionRequest(...)`.
577
-
578
- ### Network Notes
579
-
580
- A network note is a Public note carrying a `NetworkAccountTarget` attachment; a public network account auto-consumes it once the note lands on-chain — no manual `consume` call needed on the target side.
581
-
582
- ```typescript
583
- const { txId, note } = await client.transactions.createNetworkNote({
584
- account: senderId,
585
- target: networkAccountId,
586
- script: myNoteScript, // or: recipient: myRecipient
587
- waitForConfirmation: true,
588
- });
589
- console.log(note.isNetworkNote()); // true
590
- ```
591
-
592
- Provide exactly one of `script` or `recipient`. Notes are always Public — the attachment, not the tag, is what a network account matches on. The standalone `buildNetworkNote(opts)` builds the same note without submitting.
593
-
594
- To create the receiving account, build a **public** account carrying the network-account auth component — its note-script allowlist tells the node which notes the account may auto-consume:
595
-
596
- ```typescript
597
- const auth = AccountComponent.createNetworkAuth([myNoteScript.root()]);
598
- const { account } = new AccountBuilder(seed)
599
- .storageMode(AccountStorageMode.public())
600
- .withComponent(myComponent)
601
- .withAuthComponent(auth)
602
- .build();
603
- ```
604
-
605
- The allowlist must be non-empty. Transaction scripts are forbidden unless allowlisted via the optional second argument (`TransactionScript.root()`); the component bumps the nonce itself, so the account deploys via a scriptless transaction. Readback: `account.isNetworkAccount()` and `account.networkNoteAllowlist()`.
606
-
607
455
  ### Cleanup
608
456
 
609
457
  When you're finished using a MidenClient instance, call `terminate()` to release its Web Worker: