@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
@@ -1,132 +0,0 @@
1
- import { resolveAccountRef } from "../utils.js";
2
-
3
- /**
4
- * Coerce an `orderId` (string | bigint) to a decimal string for the WASM
5
- * `u64` parse on the other side.
6
- *
7
- * A PSWAP `orderId` is `u64`-shaped and routinely exceeds
8
- * `Number.MAX_SAFE_INTEGER` (`2^53 - 1`). JS `number` cannot represent the
9
- * full u64 range without silent precision loss, so it is not accepted — pass
10
- * `orderId` as a `bigint` or `string` instead.
11
- *
12
- * @param {string | bigint} orderId
13
- * @returns {string}
14
- */
15
- function normalizeOrderId(orderId) {
16
- if (typeof orderId === "bigint") return orderId.toString();
17
- if (typeof orderId === "string") return orderId;
18
- throw new TypeError(
19
- `PSWAP orderId must be a string or bigint; got ${typeof orderId}`
20
- );
21
- }
22
-
23
- /**
24
- * PswapResource surfaces partial-swap (PSWAP) lineage tracking and creator-side
25
- * cancellation keyed by a lineage's stable order id.
26
- *
27
- * A PSWAP note can be filled by many consumers; each fill advances the lineage
28
- * to a new remainder note. The client persists that chain locally as it syncs,
29
- * and the reader methods here expose it. {@link PswapResource#cancelByOrder}
30
- * reclaims the unfilled offered asset on the current tip of an active lineage,
31
- * resolving the creator account from the tracked record so the caller only
32
- * needs the order id.
33
- */
34
- export class PswapResource {
35
- #inner;
36
- #getWasm;
37
- #client;
38
-
39
- constructor(inner, getWasm, client) {
40
- this.#inner = inner;
41
- this.#getWasm = getWasm;
42
- this.#client = client;
43
- }
44
-
45
- /**
46
- * Returns every PSWAP lineage tracked by this client.
47
- *
48
- * @returns {Promise<PswapLineageRecord[]>} All tracked lineages.
49
- */
50
- async lineages() {
51
- this.#client.assertNotTerminated();
52
- return await this.#inner.getPswapLineages();
53
- }
54
-
55
- /**
56
- * Returns lineages created by a specific local account.
57
- *
58
- * @param {AccountRef} account - Creator account (hex, bech32, Account, or AccountId).
59
- * @returns {Promise<PswapLineageRecord[]>} Lineages created by the account.
60
- */
61
- async lineagesFor(account) {
62
- this.#client.assertNotTerminated();
63
- const wasm = await this.#getWasm();
64
- const accountId = resolveAccountRef(account, wasm);
65
- return await this.#inner.getPswapLineagesFor(accountId);
66
- }
67
-
68
- /**
69
- * Returns the lineage for one order, or null if not tracked.
70
- *
71
- * @param {string | bigint} orderId - Stable order id. Pass as a `string` or
72
- * `bigint` for the full `u64` range; `number` is rejected because it cannot
73
- * represent ids above `Number.MAX_SAFE_INTEGER` without precision loss.
74
- * @returns {Promise<PswapLineageRecord | null>} The lineage, or null.
75
- */
76
- async lineage(orderId) {
77
- this.#client.assertNotTerminated();
78
- const result = await this.#inner.getPswapLineage(normalizeOrderId(orderId));
79
- return result ?? null;
80
- }
81
-
82
- /**
83
- * Builds and submits a transaction reclaiming the unfilled offered asset on
84
- * the current tip of an Active lineage. The creator account is resolved from
85
- * the tracked lineage, so only the order id is required. Runs through the
86
- * same execute/prove/submit path as the other transaction helpers.
87
- *
88
- * Throws before submitting any transaction when:
89
- * - no lineage is tracked for `orderId`, OR
90
- * - the lineage is in a terminal state (`FullyFilled` or `Reclaimed`,
91
- * guarded by the `buildPswapCancelByOrder` binding).
92
- *
93
- * Concurrency: the lineage-read, build, and submit steps below are not
94
- * atomic against external fills. If another consumer — or this client's own
95
- * in-flight tx — advances the lineage tip between the build and submit, the
96
- * cancel will target an already-consumed note and the kernel will reject
97
- * it with a "note already nullified" error. Treat that as a signal to
98
- * re-read the lineage and retry against the new tip.
99
- *
100
- * @param {PswapCancelByOrderOptions} opts - Order id and optional tx options.
101
- * @returns {Promise<TransactionSubmitResult>} The submitted transaction.
102
- */
103
- async cancelByOrder(opts) {
104
- this.#client.assertNotTerminated();
105
- const orderId = normalizeOrderId(opts.orderId);
106
-
107
- // Fetch the lineage for the creator account (the cancel's submitter).
108
- // The terminal-state guard is authoritative in the `buildPswapCancelByOrder`
109
- // binding below, so it is not repeated here.
110
- const lineage = await this.#inner.getPswapLineage(orderId);
111
- if (!lineage) {
112
- throw new Error(`No PSWAP lineage tracked for order ${orderId}`);
113
- }
114
- const accountId = lineage.creatorAccountId();
115
-
116
- const request = await this.#inner.buildPswapCancelByOrder(orderId);
117
-
118
- const { txId, result } = await this.#client.transactions.submit(
119
- accountId,
120
- request,
121
- { prover: opts.prover }
122
- );
123
-
124
- if (opts.waitForConfirmation) {
125
- await this.#client.transactions.waitFor(txId.toHex(), {
126
- timeout: opts.timeout,
127
- });
128
- }
129
-
130
- return { txId, result };
131
- }
132
- }