@miden-sdk/miden-sdk 0.15.0-alpha.4 → 0.15.0-alpha.5
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/README.md +139 -9
- package/dist/mt/Cargo-smJQCGjz.js +26146 -0
- package/dist/mt/Cargo-smJQCGjz.js.map +1 -0
- package/dist/{api-types.d.ts → mt/api-types.d.ts} +154 -4
- package/dist/mt/assets/miden_client_web.wasm +0 -0
- package/dist/mt/crates/miden_client_web.d.ts +4791 -0
- package/dist/mt/eager.js +38 -0
- package/dist/mt/eager.js.map +1 -0
- package/dist/{index.d.ts → mt/index.d.ts} +4 -2
- package/dist/mt/index.js +3778 -0
- package/dist/mt/index.js.map +1 -0
- package/dist/{wasm.js → mt/wasm.js} +1 -1
- package/dist/mt/wasm.js.map +1 -0
- package/dist/mt/workerHelpers.js +28 -0
- package/dist/mt/workers/Cargo-smJQCGjz-q4GYXDiD.js +26147 -0
- package/dist/mt/workers/Cargo-smJQCGjz-q4GYXDiD.js.map +1 -0
- package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
- package/dist/mt/workers/web-client-methods-worker.js +26885 -0
- package/dist/mt/workers/web-client-methods-worker.js.map +1 -0
- package/dist/{workers → mt/workers}/web-client-methods-worker.module.js +17 -1
- package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -0
- package/dist/mt/workers/workerHelpers.js +28 -0
- package/dist/{Cargo-CVlXCH_2.js → st/Cargo-CG4XszZo.js} +698 -495
- package/dist/st/Cargo-CG4XszZo.js.map +1 -0
- package/dist/st/api-types.d.ts +1140 -0
- package/dist/{workers → st}/assets/miden_client_web.wasm +0 -0
- package/dist/{crates → st/crates}/miden_client_web.d.ts +342 -196
- package/dist/st/docs-entry.d.ts +38 -0
- package/dist/{eager.js → st/eager.js} +1 -1
- package/dist/st/eager.js.map +1 -0
- package/dist/st/index.d.ts +182 -0
- package/dist/{index.js → st/index.js} +425 -19
- package/dist/st/index.js.map +1 -0
- package/dist/st/wasm.js +23 -0
- package/dist/st/wasm.js.map +1 -0
- package/dist/{workers/Cargo-CVlXCH_2-CWA-5vlh.js → st/workers/Cargo-CG4XszZo-S7EHAZSa.js} +698 -495
- package/dist/st/workers/Cargo-CG4XszZo-S7EHAZSa.js.map +1 -0
- package/dist/{assets → st/workers/assets}/miden_client_web.wasm +0 -0
- package/dist/{workers → st/workers}/web-client-methods-worker.js +715 -496
- package/dist/st/workers/web-client-methods-worker.js.map +1 -0
- package/dist/st/workers/web-client-methods-worker.module.js +575 -0
- package/dist/st/workers/web-client-methods-worker.module.js.map +1 -0
- package/js/client.js +166 -2
- package/js/node/napi-compat.js +15 -0
- package/js/node-index.js +0 -1
- package/js/resources/accounts.js +4 -6
- package/js/resources/transactions.js +134 -0
- package/lazy/package.json +2 -2
- package/mt/lazy/package.json +4 -0
- package/mt/package.json +4 -0
- package/package.json +30 -15
- package/dist/Cargo-CVlXCH_2.js.map +0 -1
- package/dist/eager.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/wasm.js.map +0 -1
- package/dist/workers/Cargo-CVlXCH_2-CWA-5vlh.js.map +0 -1
- package/dist/workers/web-client-methods-worker.js.map +0 -1
- package/dist/workers/web-client-methods-worker.module.js.map +0 -1
- /package/dist/{docs-entry.d.ts → mt/docs-entry.d.ts} +0 -0
package/js/client.js
CHANGED
|
@@ -39,6 +39,80 @@ export class MidenClient {
|
|
|
39
39
|
this.keystore = new KeystoreResource(inner, this);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Escape hatch: runs `fn` with exclusive access to the proxied JS
|
|
44
|
+
* WebClient that backs this MidenClient.
|
|
45
|
+
*
|
|
46
|
+
* The proxy forwards missing properties to the underlying wasm-bindgen
|
|
47
|
+
* `WebClient`, so `fn` can reach lower-level methods like
|
|
48
|
+
* `executeTransaction`, `proveTransaction[WithProver]`,
|
|
49
|
+
* `submitProvenTransaction`, `applyTransaction`,
|
|
50
|
+
* `newSendTransactionRequest`, `newConsumeTransactionRequest`, etc.
|
|
51
|
+
*
|
|
52
|
+
* Intended for advanced consumers that need to split the bundled
|
|
53
|
+
* execute → prove → submit → apply pipeline across contexts — for example,
|
|
54
|
+
* a Chrome MV3 extension that runs `executeTransaction` in its service
|
|
55
|
+
* worker, dispatches the prove step to a `chrome.offscreen` document
|
|
56
|
+
* (where wasm-bindgen-rayon can spawn a real thread pool), then runs
|
|
57
|
+
* `submitProvenTransaction` + `applyTransaction` back in the SW.
|
|
58
|
+
*
|
|
59
|
+
* The callback runs inside `_serializeWasmCall`, so the WASM RefCell is
|
|
60
|
+
* held for the duration of `fn`. Concurrent SDK calls (sync, other
|
|
61
|
+
* transactions, etc.) queue on the same chain and run after `fn`
|
|
62
|
+
* settles. Without this serialization, raw inner-client access would
|
|
63
|
+
* race the proxy's chain and trip wasm-bindgen's "recursive use of an
|
|
64
|
+
* object detected" panic.
|
|
65
|
+
*
|
|
66
|
+
* Re-entrancy: while `fn` is running, the underlying client's
|
|
67
|
+
* `_withInnerLockDepth` counter is bumped so that `_serializeWasmCall`
|
|
68
|
+
* invocations made BY `fn` (or any proxy-dispatched method it calls)
|
|
69
|
+
* run inline rather than enqueuing on the chain. Without this, every
|
|
70
|
+
* `await inner.X(...)` inside `fn` would enqueue behind the outer
|
|
71
|
+
* `_withInnerWebClient` slot which is itself awaiting `fn` —
|
|
72
|
+
* a classic re-entrant-lock deadlock. The depth counter restores the
|
|
73
|
+
* intent of the docstring above: the lock is held for the duration
|
|
74
|
+
* of `fn`, and inner-client calls "borrow" that already-held lock
|
|
75
|
+
* instead of trying to re-acquire it.
|
|
76
|
+
*
|
|
77
|
+
* SAFETY CONTRACT for re-entrancy: callers MUST hold an external
|
|
78
|
+
* mutex preventing concurrent access to this same client instance
|
|
79
|
+
* via other code paths during `fn`. The chain still serializes
|
|
80
|
+
* against external callers — they queue behind the outer slot — but
|
|
81
|
+
* if an external task runs during one of `fn`'s awaits and calls
|
|
82
|
+
* into the SDK, it will see `_withInnerLockDepth > 0` and run
|
|
83
|
+
* inline, racing wasm-bindgen's borrow check. The wallet pattern
|
|
84
|
+
* (own outer mutex around `_withInnerWebClient`) satisfies this.
|
|
85
|
+
*
|
|
86
|
+
* Stability: marked `@internal`. The shape of the proxied client is
|
|
87
|
+
* intentionally not part of the documented public API and may change
|
|
88
|
+
* between SDK versions. If you depend on this method, pin the SDK
|
|
89
|
+
* version and test the lower-level surface carefully on each upgrade.
|
|
90
|
+
* If your use case is common enough to warrant a stable public API,
|
|
91
|
+
* file an issue.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
* @template T
|
|
95
|
+
* @param {(inner: object) => Promise<T>} fn - Async callback receiving
|
|
96
|
+
* the proxied JS WebClient. Must not return references that escape
|
|
97
|
+
* the callback's lifetime (the lock is released on settle).
|
|
98
|
+
* @returns {Promise<T>} The resolved value of `fn`.
|
|
99
|
+
*/
|
|
100
|
+
_withInnerWebClient(fn) {
|
|
101
|
+
this.assertNotTerminated();
|
|
102
|
+
if (typeof fn !== "function") {
|
|
103
|
+
throw new TypeError("_withInnerWebClient: fn must be a function");
|
|
104
|
+
}
|
|
105
|
+
const inner = this.#inner;
|
|
106
|
+
return inner._serializeWasmCall(async () => {
|
|
107
|
+
inner._withInnerLockDepth = (inner._withInnerLockDepth || 0) + 1;
|
|
108
|
+
try {
|
|
109
|
+
return await fn(inner);
|
|
110
|
+
} finally {
|
|
111
|
+
inner._withInnerLockDepth--;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
42
116
|
/**
|
|
43
117
|
* Creates and initializes a new MidenClient.
|
|
44
118
|
*
|
|
@@ -67,6 +141,13 @@ export class MidenClient {
|
|
|
67
141
|
const rpcUrl = resolveRpcUrl(options?.rpcUrl);
|
|
68
142
|
const noteTransportUrl = resolveNoteTransportUrl(options?.noteTransportUrl);
|
|
69
143
|
|
|
144
|
+
// `useWorker: false` opts out of the Web Worker shim that wraps every
|
|
145
|
+
// WASM call. The shim exists to keep the main thread responsive in
|
|
146
|
+
// browser/extension contexts, but it serializes the prover via
|
|
147
|
+
// `TransactionProver.serialize()` — a format that has no encoding for
|
|
148
|
+
// `newCallbackProver(jsFn)` and silently downgrades it to `"local"`.
|
|
149
|
+
// Mobile/Tauri/native-prover consumers must pass `useWorker: false`.
|
|
150
|
+
const useWorker = options?.useWorker;
|
|
70
151
|
let inner;
|
|
71
152
|
if (options?.keystore) {
|
|
72
153
|
inner = await WebClientClass.createClientWithExternalKeystore(
|
|
@@ -77,7 +158,8 @@ export class MidenClient {
|
|
|
77
158
|
options.keystore.getKey,
|
|
78
159
|
options.keystore.insertKey,
|
|
79
160
|
options.keystore.sign,
|
|
80
|
-
options?.debugMode
|
|
161
|
+
options?.debugMode,
|
|
162
|
+
useWorker
|
|
81
163
|
);
|
|
82
164
|
} else {
|
|
83
165
|
inner = await WebClientClass.createClient(
|
|
@@ -85,7 +167,8 @@ export class MidenClient {
|
|
|
85
167
|
noteTransportUrl,
|
|
86
168
|
seed,
|
|
87
169
|
options?.storeName,
|
|
88
|
-
options?.debugMode
|
|
170
|
+
options?.debugMode,
|
|
171
|
+
useWorker
|
|
89
172
|
);
|
|
90
173
|
}
|
|
91
174
|
|
|
@@ -142,6 +225,32 @@ export class MidenClient {
|
|
|
142
225
|
});
|
|
143
226
|
}
|
|
144
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Resolves once the WASM module is initialized and safe to use.
|
|
230
|
+
*
|
|
231
|
+
* Idempotent and shared across callers: the underlying loader memoizes the
|
|
232
|
+
* in-flight promise, so concurrent `ready()` calls await the same
|
|
233
|
+
* initialization and post-init callers resolve immediately from a cached
|
|
234
|
+
* module. Safe to call from `MidenProvider`, tutorial helpers, and any
|
|
235
|
+
* other consumer simultaneously.
|
|
236
|
+
*
|
|
237
|
+
* Useful on the `/lazy` entry (e.g. Next.js / Capacitor), where no
|
|
238
|
+
* top-level await runs at import time. On the default (eager) entry this
|
|
239
|
+
* is redundant — importing the module already awaits WASM — but calling it
|
|
240
|
+
* is still harmless.
|
|
241
|
+
*
|
|
242
|
+
* @returns {Promise<void>} Resolves when WASM is initialized.
|
|
243
|
+
*/
|
|
244
|
+
static async ready() {
|
|
245
|
+
const getWasm = MidenClient._getWasmOrThrow;
|
|
246
|
+
if (!getWasm) {
|
|
247
|
+
throw new Error(
|
|
248
|
+
"MidenClient not initialized. Import from the SDK package entry point."
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
await getWasm();
|
|
252
|
+
}
|
|
253
|
+
|
|
145
254
|
/**
|
|
146
255
|
* Creates a mock client for testing.
|
|
147
256
|
*
|
|
@@ -198,6 +307,61 @@ export class MidenClient {
|
|
|
198
307
|
return await this.#inner.getSyncHeight();
|
|
199
308
|
}
|
|
200
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Resolves once every serialized WASM call that was already on the
|
|
312
|
+
* internal `_serializeWasmCall` chain when `waitForIdle()` was called
|
|
313
|
+
* (execute, submit, prove, apply, sync, or account creation) has
|
|
314
|
+
* settled. Use this from callers that need to perform a non-WASM-side
|
|
315
|
+
* action — e.g. clearing an in-memory auth key on wallet lock — after
|
|
316
|
+
* the kernel finishes, so its auth callback doesn't race with the key
|
|
317
|
+
* being cleared.
|
|
318
|
+
*
|
|
319
|
+
* Does NOT wait for calls enqueued after `waitForIdle()` returns —
|
|
320
|
+
* intentional, so a caller can drain and proceed without being blocked
|
|
321
|
+
* indefinitely by concurrent workload.
|
|
322
|
+
*
|
|
323
|
+
* Caveat for `syncState`: `syncStateWithTimeout` awaits the sync lock
|
|
324
|
+
* (`acquireSyncLock`, which uses Web Locks) BEFORE putting its WASM
|
|
325
|
+
* call onto the chain, so a `syncState` that is queued on the sync
|
|
326
|
+
* lock — but has not yet begun its WASM phase — is not visible to
|
|
327
|
+
* `waitForIdle` and will not be awaited. Other methods (`newWallet`,
|
|
328
|
+
* `executeTransaction`, etc.) route through the chain synchronously
|
|
329
|
+
* on call and are always observed.
|
|
330
|
+
*
|
|
331
|
+
* Safe to call at any time; returns immediately if nothing was in
|
|
332
|
+
* flight.
|
|
333
|
+
*
|
|
334
|
+
* @returns {Promise<void>}
|
|
335
|
+
*/
|
|
336
|
+
async waitForIdle() {
|
|
337
|
+
this.assertNotTerminated();
|
|
338
|
+
await this.#inner.waitForIdle();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Returns the raw JS value that the most recent sign-callback invocation
|
|
343
|
+
* threw, or `null` if the last sign call succeeded (or no call has
|
|
344
|
+
* happened yet).
|
|
345
|
+
*
|
|
346
|
+
* Useful for recovering structured metadata (e.g. a `reason: 'locked'`
|
|
347
|
+
* property) that the kernel-level `auth::request` diagnostic would
|
|
348
|
+
* otherwise erase. Call immediately after catching a failed
|
|
349
|
+
* `transactions.submit` / `transactions.send` / `transactions.consume`.
|
|
350
|
+
*
|
|
351
|
+
* Meaningful only with `useWorker: false`: under the worker shim the
|
|
352
|
+
* sign callback fires against the worker's WASM keystore, while this
|
|
353
|
+
* accessor reads the main-thread instance — which never signed — so it
|
|
354
|
+
* returns `null`. Consumers that need this signal (e.g. external
|
|
355
|
+
* keystores with lock-aware sign callbacks) already require
|
|
356
|
+
* `useWorker: false` for the callback to be reachable at all.
|
|
357
|
+
*
|
|
358
|
+
* @returns {any} The raw thrown value, or `null`.
|
|
359
|
+
*/
|
|
360
|
+
lastAuthError() {
|
|
361
|
+
this.assertNotTerminated();
|
|
362
|
+
return this.#inner.lastAuthError();
|
|
363
|
+
}
|
|
364
|
+
|
|
201
365
|
/**
|
|
202
366
|
* Terminates the underlying Web Worker. After this, all method calls will throw.
|
|
203
367
|
*/
|
package/js/node/napi-compat.js
CHANGED
|
@@ -91,6 +91,21 @@ export function wrapClient(rawClient, storeName) {
|
|
|
91
91
|
if (prop === "onStateChanged") {
|
|
92
92
|
return () => undefined;
|
|
93
93
|
}
|
|
94
|
+
// waitForIdle drains the browser SDK's detached `_serializeWasmCall`
|
|
95
|
+
// chain. The napi binding has no such chain — every call is awaited
|
|
96
|
+
// directly by its caller and serialized inside Rust — so there is
|
|
97
|
+
// nothing in flight by the time a caller could invoke this. Resolve
|
|
98
|
+
// immediately to keep the cross-platform MidenClient surface intact.
|
|
99
|
+
if (prop === "waitForIdle") {
|
|
100
|
+
return () => Promise.resolve();
|
|
101
|
+
}
|
|
102
|
+
// lastAuthError surfaces the raw value a JS sign callback threw.
|
|
103
|
+
// The Node binding signs with FilesystemKeyStore (no JS callback can
|
|
104
|
+
// ever run), so "no sign error" is the semantically correct answer,
|
|
105
|
+
// not a stub.
|
|
106
|
+
if (prop === "lastAuthError") {
|
|
107
|
+
return () => null;
|
|
108
|
+
}
|
|
94
109
|
if (prop === "newWallet") {
|
|
95
110
|
return (mode, mutable, authScheme, seed) => {
|
|
96
111
|
const normSeed =
|
package/js/node-index.js
CHANGED
package/js/resources/accounts.js
CHANGED
|
@@ -34,6 +34,7 @@ export class AccountsResource {
|
|
|
34
34
|
return await this.#inner.newFaucet(
|
|
35
35
|
storageMode,
|
|
36
36
|
type === 1 || type === "NonFungibleFaucet",
|
|
37
|
+
opts.name ?? opts.symbol,
|
|
37
38
|
opts.symbol,
|
|
38
39
|
opts.decimals,
|
|
39
40
|
BigInt(opts.maxSupply),
|
|
@@ -66,11 +67,9 @@ export class AccountsResource {
|
|
|
66
67
|
if (!opts.auth)
|
|
67
68
|
throw new Error("Contract creation requires an 'auth' (AuthSecretKey)");
|
|
68
69
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
? wasm.AccountType.RegularAccountUpdatableCode
|
|
73
|
-
: wasm.AccountType.RegularAccountImmutableCode;
|
|
70
|
+
// The 0.15 protocol has no code-mutability distinction, so the `type`
|
|
71
|
+
// ("ImmutableContract" / "MutableContract") only steers routing here; the
|
|
72
|
+
// account's on-chain visibility is set entirely by `storageMode`.
|
|
74
73
|
const storageMode = resolveStorageMode(opts.storage ?? "public", wasm);
|
|
75
74
|
const authComponent =
|
|
76
75
|
wasm.AccountComponent.createAuthComponentFromSecretKey(opts.auth);
|
|
@@ -85,7 +84,6 @@ export class AccountsResource {
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
let builder = new wasm.AccountBuilder(opts.seed)
|
|
88
|
-
.accountType(accountTypeEnum)
|
|
89
87
|
.storageMode(storageMode)
|
|
90
88
|
.withAuthComponent(authComponent);
|
|
91
89
|
|
|
@@ -177,6 +177,72 @@ export class TransactionsResource {
|
|
|
177
177
|
return { txId, result };
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
/** Create a partial-swap (PSWAP) note. See {@link PswapCreateOptions}. */
|
|
181
|
+
async pswapCreate(opts) {
|
|
182
|
+
this.#client.assertNotTerminated();
|
|
183
|
+
const wasm = await this.#getWasm();
|
|
184
|
+
const { accountId, request } = await this.#buildPswapCreateRequest(
|
|
185
|
+
opts,
|
|
186
|
+
wasm
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
190
|
+
accountId,
|
|
191
|
+
request,
|
|
192
|
+
opts.prover
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
if (opts.waitForConfirmation) {
|
|
196
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return { txId, result };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Consume (fully or partially fill) a PSWAP note. See {@link PswapConsumeOptions}. */
|
|
203
|
+
async pswapConsume(opts) {
|
|
204
|
+
this.#client.assertNotTerminated();
|
|
205
|
+
const wasm = await this.#getWasm();
|
|
206
|
+
const { accountId, request } = await this.#buildPswapConsumeRequest(
|
|
207
|
+
opts,
|
|
208
|
+
wasm
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
212
|
+
accountId,
|
|
213
|
+
request,
|
|
214
|
+
opts.prover
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
if (opts.waitForConfirmation) {
|
|
218
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return { txId, result };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Cancel a PSWAP note as its creator and reclaim the offered asset. See {@link PswapCancelOptions}. */
|
|
225
|
+
async pswapCancel(opts) {
|
|
226
|
+
this.#client.assertNotTerminated();
|
|
227
|
+
const wasm = await this.#getWasm();
|
|
228
|
+
const { accountId, request } = await this.#buildPswapCancelRequest(
|
|
229
|
+
opts,
|
|
230
|
+
wasm
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
234
|
+
accountId,
|
|
235
|
+
request,
|
|
236
|
+
opts.prover
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
if (opts.waitForConfirmation) {
|
|
240
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return { txId, result };
|
|
244
|
+
}
|
|
245
|
+
|
|
180
246
|
async preview(opts) {
|
|
181
247
|
this.#client.assertNotTerminated();
|
|
182
248
|
const wasm = await this.#getWasm();
|
|
@@ -201,6 +267,27 @@ export class TransactionsResource {
|
|
|
201
267
|
({ accountId, request } = await this.#buildSwapRequest(opts, wasm));
|
|
202
268
|
break;
|
|
203
269
|
}
|
|
270
|
+
case "pswapCreate": {
|
|
271
|
+
({ accountId, request } = await this.#buildPswapCreateRequest(
|
|
272
|
+
opts,
|
|
273
|
+
wasm
|
|
274
|
+
));
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
case "pswapConsume": {
|
|
278
|
+
({ accountId, request } = await this.#buildPswapConsumeRequest(
|
|
279
|
+
opts,
|
|
280
|
+
wasm
|
|
281
|
+
));
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
case "pswapCancel": {
|
|
285
|
+
({ accountId, request } = await this.#buildPswapCancelRequest(
|
|
286
|
+
opts,
|
|
287
|
+
wasm
|
|
288
|
+
));
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
204
291
|
case "custom": {
|
|
205
292
|
accountId = resolveAccountRef(opts.account, wasm);
|
|
206
293
|
request = opts.request;
|
|
@@ -487,6 +574,53 @@ export class TransactionsResource {
|
|
|
487
574
|
return { accountId, request };
|
|
488
575
|
}
|
|
489
576
|
|
|
577
|
+
async #buildPswapCreateRequest(opts, wasm) {
|
|
578
|
+
const accountId = resolveAccountRef(opts.account, wasm);
|
|
579
|
+
const offeredFaucetId = resolveAccountRef(opts.offer.token, wasm);
|
|
580
|
+
const requestedFaucetId = resolveAccountRef(opts.request.token, wasm);
|
|
581
|
+
const noteType = resolveNoteType(opts.type, wasm);
|
|
582
|
+
const paybackNoteType = resolveNoteType(
|
|
583
|
+
opts.paybackType ?? opts.type,
|
|
584
|
+
wasm
|
|
585
|
+
);
|
|
586
|
+
|
|
587
|
+
const request = await this.#inner.newPswapCreateTransactionRequest(
|
|
588
|
+
accountId,
|
|
589
|
+
offeredFaucetId,
|
|
590
|
+
BigInt(opts.offer.amount),
|
|
591
|
+
requestedFaucetId,
|
|
592
|
+
BigInt(opts.request.amount),
|
|
593
|
+
noteType,
|
|
594
|
+
paybackNoteType
|
|
595
|
+
);
|
|
596
|
+
return { accountId, request };
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
async #buildPswapConsumeRequest(opts, wasm) {
|
|
600
|
+
const accountId = resolveAccountRef(opts.account, wasm);
|
|
601
|
+
const note = await this.#resolveNoteInput(opts.note);
|
|
602
|
+
const noteFillAmount = opts.noteFillAmount ?? 0n;
|
|
603
|
+
|
|
604
|
+
const request = await this.#inner.newPswapConsumeTransactionRequest(
|
|
605
|
+
note,
|
|
606
|
+
accountId,
|
|
607
|
+
BigInt(opts.fillAmount),
|
|
608
|
+
BigInt(noteFillAmount)
|
|
609
|
+
);
|
|
610
|
+
return { accountId, request };
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
async #buildPswapCancelRequest(opts, wasm) {
|
|
614
|
+
const accountId = resolveAccountRef(opts.account, wasm);
|
|
615
|
+
const note = await this.#resolveNoteInput(opts.note);
|
|
616
|
+
|
|
617
|
+
const request = await this.#inner.newPswapCancelTransactionRequest(
|
|
618
|
+
note,
|
|
619
|
+
accountId
|
|
620
|
+
);
|
|
621
|
+
return { accountId, request };
|
|
622
|
+
}
|
|
623
|
+
|
|
490
624
|
async #resolveNoteInput(input) {
|
|
491
625
|
if (typeof input === "string") {
|
|
492
626
|
const record = await this.#inner.getInputNote(input);
|
package/lazy/package.json
CHANGED
package/mt/package.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miden-sdk/miden-sdk",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.5",
|
|
4
4
|
"description": "Miden Wasm SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,24 +15,36 @@
|
|
|
15
15
|
"Miden"
|
|
16
16
|
],
|
|
17
17
|
"type": "module",
|
|
18
|
-
"main": "./dist/eager.js",
|
|
19
|
-
"browser": "./dist/eager.js",
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
18
|
+
"main": "./dist/st/eager.js",
|
|
19
|
+
"browser": "./dist/st/eager.js",
|
|
20
|
+
"types": "./dist/st/index.d.ts",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"node": {
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
24
|
+
"types": "./dist/st/index.d.ts",
|
|
25
25
|
"default": "./js/node-index.js"
|
|
26
26
|
},
|
|
27
27
|
"import": {
|
|
28
|
-
"types": "./dist/index.d.ts",
|
|
29
|
-
"default": "./dist/eager.js"
|
|
28
|
+
"types": "./dist/st/index.d.ts",
|
|
29
|
+
"default": "./dist/st/eager.js"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"./lazy": {
|
|
33
33
|
"import": {
|
|
34
|
-
"types": "./dist/index.d.ts",
|
|
35
|
-
"default": "./dist/index.js"
|
|
34
|
+
"types": "./dist/st/index.d.ts",
|
|
35
|
+
"default": "./dist/st/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"./mt": {
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/mt/index.d.ts",
|
|
41
|
+
"default": "./dist/mt/eager.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"./mt/lazy": {
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/mt/index.d.ts",
|
|
47
|
+
"default": "./dist/mt/index.js"
|
|
36
48
|
}
|
|
37
49
|
},
|
|
38
50
|
"./package.json": "./package.json"
|
|
@@ -40,6 +52,7 @@
|
|
|
40
52
|
"files": [
|
|
41
53
|
"dist",
|
|
42
54
|
"lazy",
|
|
55
|
+
"mt",
|
|
43
56
|
"js/node-index.js",
|
|
44
57
|
"js/node",
|
|
45
58
|
"js/client.js",
|
|
@@ -56,7 +69,6 @@
|
|
|
56
69
|
"@vitest/coverage-v8": "^3.0.0",
|
|
57
70
|
"@wasm-tool/rollup-plugin-rust": "^3.0.3",
|
|
58
71
|
"binaryen": "^129.0.0",
|
|
59
|
-
"cpr": "^3.0.1",
|
|
60
72
|
"cross-env": "^7.0.3",
|
|
61
73
|
"rimraf": "^6.0.1",
|
|
62
74
|
"rollup": "^4.59.0",
|
|
@@ -71,14 +83,17 @@
|
|
|
71
83
|
"glob": "^11.0.0"
|
|
72
84
|
},
|
|
73
85
|
"optionalDependencies": {
|
|
74
|
-
"@miden-sdk/node-darwin-arm64": "0.15.0-alpha.
|
|
75
|
-
"@miden-sdk/node-darwin-x64": "0.15.0-alpha.
|
|
76
|
-
"@miden-sdk/node-linux-x64-gnu": "0.15.0-alpha.
|
|
86
|
+
"@miden-sdk/node-darwin-arm64": "0.15.0-alpha.5",
|
|
87
|
+
"@miden-sdk/node-darwin-x64": "0.15.0-alpha.5",
|
|
88
|
+
"@miden-sdk/node-linux-x64-gnu": "0.15.0-alpha.5"
|
|
77
89
|
},
|
|
78
90
|
"scripts": {
|
|
79
91
|
"build-rust-client-js": "pnpm --filter web_store run build",
|
|
80
|
-
"build": "rimraf dist && pnpm run build-rust-client-js &&
|
|
81
|
-
"build-
|
|
92
|
+
"build": "rimraf dist && pnpm run build-rust-client-js && pnpm run build-st && pnpm run build-mt && pnpm run build-types && node ./scripts/post-build.js",
|
|
93
|
+
"build-st": "cross-env MIDEN_BUILD_VARIANT=st rollup -c rollup.config.js",
|
|
94
|
+
"build-mt": "cross-env MIDEN_BUILD_VARIANT=mt rollup -c rollup.config.js",
|
|
95
|
+
"build-types": "node ./scripts/build-types.js",
|
|
96
|
+
"build-dev": "pnpm install && cross-env MIDEN_WEB_DEV=true pnpm run build",
|
|
82
97
|
"check:wasm-types": "node ./scripts/check-bindgen-types.js",
|
|
83
98
|
"check:method-classification": "node ./scripts/check-method-classification.js",
|
|
84
99
|
"check:standalone-types": "node ./scripts/check-standalone-types.js",
|