@miden-sdk/miden-sdk 0.15.1 → 0.15.3

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 (44) hide show
  1. package/README.md +39 -0
  2. package/dist/mt/{Cargo-D6y7aDQ8.js → Cargo-D2qNRrNR.js} +288 -79
  3. package/dist/mt/Cargo-D2qNRrNR.js.map +1 -0
  4. package/dist/mt/api-types.d.ts +54 -0
  5. package/dist/mt/assets/miden_client_web.wasm +0 -0
  6. package/dist/mt/crates/miden_client_web.d.ts +102 -0
  7. package/dist/mt/docs-entry.d.ts +3 -0
  8. package/dist/mt/eager.js +1 -1
  9. package/dist/mt/index.js +134 -1
  10. package/dist/mt/index.js.map +1 -1
  11. package/dist/mt/wasm.js +1 -1
  12. package/dist/mt/workerHelpers.js +1 -1
  13. package/dist/mt/workers/{Cargo-D6y7aDQ8-BbSVnZEb.js → Cargo-D2qNRrNR-n_GEbq73.js} +288 -79
  14. package/dist/mt/workers/{Cargo-D6y7aDQ8-BbSVnZEb.js.map → Cargo-D2qNRrNR-n_GEbq73.js.map} +1 -1
  15. package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
  16. package/dist/mt/workers/web-client-methods-worker.js +290 -79
  17. package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
  18. package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
  19. package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
  20. package/dist/mt/workers/workerHelpers.js +1 -1
  21. package/dist/st/{Cargo-LzqxI7kL.js → Cargo-BP7-0qVT.js} +285 -78
  22. package/dist/st/Cargo-BP7-0qVT.js.map +1 -0
  23. package/dist/st/api-types.d.ts +54 -0
  24. package/dist/st/assets/miden_client_web.wasm +0 -0
  25. package/dist/st/crates/miden_client_web.d.ts +102 -0
  26. package/dist/st/docs-entry.d.ts +3 -0
  27. package/dist/st/eager.js +1 -1
  28. package/dist/st/index.js +134 -1
  29. package/dist/st/index.js.map +1 -1
  30. package/dist/st/wasm.js +1 -1
  31. package/dist/st/workers/{Cargo-LzqxI7kL-9fqTseKT.js → Cargo-BP7-0qVT-CmfAy6bf.js} +285 -78
  32. package/dist/st/workers/Cargo-BP7-0qVT-CmfAy6bf.js.map +1 -0
  33. package/dist/st/workers/assets/miden_client_web.wasm +0 -0
  34. package/dist/st/workers/web-client-methods-worker.js +287 -78
  35. package/dist/st/workers/web-client-methods-worker.js.map +1 -1
  36. package/dist/st/workers/web-client-methods-worker.module.js +1 -1
  37. package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
  38. package/js/client.js +2 -0
  39. package/js/node-index.js +149 -40
  40. package/js/resources/pswap.js +132 -0
  41. package/package.json +6 -4
  42. package/dist/mt/Cargo-D6y7aDQ8.js.map +0 -1
  43. package/dist/st/Cargo-LzqxI7kL.js.map +0 -1
  44. package/dist/st/workers/Cargo-LzqxI7kL-9fqTseKT.js.map +0 -1
package/README.md CHANGED
@@ -452,6 +452,45 @@ const balance = await client.accounts.getBalance(wallet, dagToken);
452
452
  console.log(`Balance: ${balance}`);
453
453
  ```
454
454
 
455
+ ### Partial-Swap (PSWAP) Orders
456
+
457
+ A partial-swap note offers one asset for another and can be filled by multiple
458
+ counterparties over time — each partial fill pays the creator and leaves a
459
+ remainder note carrying the unfilled balance. The client tracks that chain as a
460
+ **lineage** keyed by a stable `orderId`, advancing it round by round as fills
461
+ are discovered on sync.
462
+
463
+ ```typescript
464
+ // Offer 100 of token A for 25 of token B.
465
+ await client.transactions.pswapCreate({
466
+ account: wallet,
467
+ offer: { token: aToken, amount: 100n },
468
+ request: { token: bToken, amount: 25n }
469
+ });
470
+ await client.sync();
471
+
472
+ // The order is tracked as a lineage keyed by a stable order id.
473
+ const [lineage] = await client.pswap.lineagesFor(wallet);
474
+ const orderId = lineage.orderId();
475
+ console.log(lineage.remainingOffered().toString()); // unfilled offered balance
476
+
477
+ // A counterparty fills part of the order:
478
+ // client.transactions.pswapConsume({ account, note, fillAmount });
479
+ // On the next sync the lineage advances, and `remainingOffered()` shrinks.
480
+
481
+ // Reclaim the unfilled remainder on the current tip, by stable order id.
482
+ // `waitForConfirmation` blocks until the cancel commits AND a sync brings
483
+ // the consumed-note update down; without it, the call resolves at submit
484
+ // time and `pswap.lineage(orderId)` still reads `Active` until the next
485
+ // sync. The lineage only transitions to `Reclaimed` once the chain sees
486
+ // the cancel land.
487
+ await client.pswap.cancelByOrder({ orderId, waitForConfirmation: true });
488
+ ```
489
+
490
+ `client.pswap.lineages()` returns every order this client created;
491
+ `client.pswap.lineage(orderId)` returns one order's lineage, or `null` if it is
492
+ not tracked.
493
+
455
494
  ### Cleanup
456
495
 
457
496
  When you're finished using a MidenClient instance, call `terminate()` to release its Web Worker: