@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
|
@@ -102,16 +102,20 @@ export type NoteVisibility = "public" | "private";
|
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* User-friendly storage mode constants.
|
|
105
|
-
* Use `StorageMode.Public
|
|
105
|
+
* Use `StorageMode.Public` or `StorageMode.Private` instead of raw strings.
|
|
106
|
+
*
|
|
107
|
+
* The `"network"` storage mode was removed in the migration to miden-client
|
|
108
|
+
* PR #2214 — the 0.15 protocol surface no longer has a separate
|
|
109
|
+
* network-account flag (network execution is now driven by the calling
|
|
110
|
+
* surface, not the account's storage mode).
|
|
106
111
|
*/
|
|
107
112
|
export declare const StorageMode: {
|
|
108
113
|
readonly Public: "public";
|
|
109
114
|
readonly Private: "private";
|
|
110
|
-
readonly Network: "network";
|
|
111
115
|
};
|
|
112
116
|
|
|
113
117
|
/** Union of valid StorageMode string values. */
|
|
114
|
-
export type StorageMode = "public" | "private"
|
|
118
|
+
export type StorageMode = "public" | "private";
|
|
115
119
|
|
|
116
120
|
/**
|
|
117
121
|
* Library linking mode for script compilation.
|
|
@@ -195,6 +199,21 @@ export interface ClientOptions {
|
|
|
195
199
|
insertKey: InsertKeyCallback;
|
|
196
200
|
sign: SignCallback;
|
|
197
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Enable the Web Worker shim that runs WASM calls off the main thread.
|
|
204
|
+
* Defaults to `true` — leave it that way in browsers/extensions so the UI
|
|
205
|
+
* stays responsive while WASM is busy.
|
|
206
|
+
*
|
|
207
|
+
* Set to `false` when:
|
|
208
|
+
* - You pass a `CallbackProver` via `TransactionProver.newCallbackProver(jsFn)`.
|
|
209
|
+
* The worker boundary serializes the prover with `TransactionProver.serialize()`,
|
|
210
|
+
* which has no encoding for the callback variant and silently downgrades
|
|
211
|
+
* to `"local"` — your callback would never fire.
|
|
212
|
+
* - You're embedding the client in a single-WebView native shell (iOS/Android
|
|
213
|
+
* Capacitor host, Tauri, Electron preload), where the UI thread isn't
|
|
214
|
+
* competing with the WASM thread anyway.
|
|
215
|
+
*/
|
|
216
|
+
useWorker?: boolean;
|
|
198
217
|
}
|
|
199
218
|
|
|
200
219
|
// ════════════════════════════════════════════════════════════════
|
|
@@ -241,6 +260,8 @@ export interface WalletCreateOptions {
|
|
|
241
260
|
export interface FaucetCreateOptions {
|
|
242
261
|
/** Use `AccountType.FungibleFaucet` or `AccountType.NonFungibleFaucet`. */
|
|
243
262
|
type: AccountTypeValue;
|
|
263
|
+
/** Human-readable token name. Defaults to `symbol` when omitted. */
|
|
264
|
+
name?: string;
|
|
244
265
|
symbol: string;
|
|
245
266
|
decimals: number;
|
|
246
267
|
maxSupply: number | bigint;
|
|
@@ -378,6 +399,41 @@ export interface SwapOptions extends TransactionOptions {
|
|
|
378
399
|
paybackType?: NoteVisibility;
|
|
379
400
|
}
|
|
380
401
|
|
|
402
|
+
/**
|
|
403
|
+
* Options for {@link TransactionsResource.pswapCreate}. V1 PSWAP notes carry
|
|
404
|
+
* no attachment, so there is no `attachment` field.
|
|
405
|
+
*/
|
|
406
|
+
export interface PswapCreateOptions extends TransactionOptions {
|
|
407
|
+
/** Account that creates the partial-swap (PSWAP) note. */
|
|
408
|
+
account: AccountRef;
|
|
409
|
+
/** Fungible asset offered by the creator. */
|
|
410
|
+
offer: Asset;
|
|
411
|
+
/** Fungible asset requested in exchange. */
|
|
412
|
+
request: Asset;
|
|
413
|
+
/** Visibility of the PSWAP note itself. */
|
|
414
|
+
type?: NoteVisibility;
|
|
415
|
+
/** Visibility of the payback note fillers emit to the creator. Defaults to `public`. */
|
|
416
|
+
paybackType?: NoteVisibility;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export interface PswapConsumeOptions extends TransactionOptions {
|
|
420
|
+
/** Consumer account filling the PSWAP note. */
|
|
421
|
+
account: AccountRef;
|
|
422
|
+
/** PSWAP note to consume — accepts a note id (hex), `NoteId`, `InputNoteRecord`, or `Note`. */
|
|
423
|
+
note: NoteInput;
|
|
424
|
+
/** Requested-asset amount the consumer supplies from its own vault; a partial amount emits a remainder PSWAP note. */
|
|
425
|
+
fillAmount: number | bigint;
|
|
426
|
+
/** Requested-asset amount supplied by other in-flight notes in the same tx. Defaults to `0`; leave unset normally. */
|
|
427
|
+
noteFillAmount?: number | bigint;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export interface PswapCancelOptions extends TransactionOptions {
|
|
431
|
+
/** Creator account reclaiming the offered asset. */
|
|
432
|
+
account: AccountRef;
|
|
433
|
+
/** PSWAP note to cancel — accepts a note id (hex), `NoteId`, `InputNoteRecord`, or `Note`. */
|
|
434
|
+
note: NoteInput;
|
|
435
|
+
}
|
|
436
|
+
|
|
381
437
|
export interface ExecuteOptions extends TransactionOptions {
|
|
382
438
|
/** Account executing the custom script. */
|
|
383
439
|
account: AccountRef;
|
|
@@ -438,6 +494,29 @@ export interface PreviewSwapOptions {
|
|
|
438
494
|
paybackType?: NoteVisibility;
|
|
439
495
|
}
|
|
440
496
|
|
|
497
|
+
export interface PreviewPswapCreateOptions {
|
|
498
|
+
operation: "pswapCreate";
|
|
499
|
+
account: AccountRef;
|
|
500
|
+
offer: Asset;
|
|
501
|
+
request: Asset;
|
|
502
|
+
type?: NoteVisibility;
|
|
503
|
+
paybackType?: NoteVisibility;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface PreviewPswapConsumeOptions {
|
|
507
|
+
operation: "pswapConsume";
|
|
508
|
+
account: AccountRef;
|
|
509
|
+
note: NoteInput;
|
|
510
|
+
fillAmount: number | bigint;
|
|
511
|
+
noteFillAmount?: number | bigint;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export interface PreviewPswapCancelOptions {
|
|
515
|
+
operation: "pswapCancel";
|
|
516
|
+
account: AccountRef;
|
|
517
|
+
note: NoteInput;
|
|
518
|
+
}
|
|
519
|
+
|
|
441
520
|
export interface PreviewCustomOptions {
|
|
442
521
|
operation: "custom";
|
|
443
522
|
account: AccountRef;
|
|
@@ -449,6 +528,9 @@ export type PreviewOptions =
|
|
|
449
528
|
| PreviewMintOptions
|
|
450
529
|
| PreviewConsumeOptions
|
|
451
530
|
| PreviewSwapOptions
|
|
531
|
+
| PreviewPswapCreateOptions
|
|
532
|
+
| PreviewPswapConsumeOptions
|
|
533
|
+
| PreviewPswapCancelOptions
|
|
452
534
|
| PreviewCustomOptions;
|
|
453
535
|
|
|
454
536
|
/** Status values reported during waitFor polling. */
|
|
@@ -654,6 +736,31 @@ export interface TransactionsResource {
|
|
|
654
736
|
* @param options - Swap options including the account, offered asset, and requested asset.
|
|
655
737
|
*/
|
|
656
738
|
swap(options: SwapOptions): Promise<TransactionSubmitResult>;
|
|
739
|
+
/**
|
|
740
|
+
* Create a partial-swap (PSWAP) note offering one fungible asset for
|
|
741
|
+
* another. Unlike `swap`, the resulting note can be filled by multiple
|
|
742
|
+
* consumers; each fill emits a payback note to the creator and, on a
|
|
743
|
+
* partial fill, a remainder PSWAP note carrying the unfilled amount.
|
|
744
|
+
*
|
|
745
|
+
* @param options - Creator, offered asset, requested asset, and visibility.
|
|
746
|
+
*/
|
|
747
|
+
pswapCreate(options: PswapCreateOptions): Promise<TransactionSubmitResult>;
|
|
748
|
+
/**
|
|
749
|
+
* Consume (fully or partially fill) an existing PSWAP note. The consumer
|
|
750
|
+
* supplies `fillAmount` of the requested asset and receives a proportional
|
|
751
|
+
* share of the offered asset. A full fill (`fillAmount` equal to the
|
|
752
|
+
* note's requested amount) produces only the payback note; a partial fill
|
|
753
|
+
* also produces a remainder PSWAP note.
|
|
754
|
+
*
|
|
755
|
+
* @param options - Consumer account, PSWAP note, and fill amount.
|
|
756
|
+
*/
|
|
757
|
+
pswapConsume(options: PswapConsumeOptions): Promise<TransactionSubmitResult>;
|
|
758
|
+
/**
|
|
759
|
+
* Cancel a PSWAP note as the creator and reclaim the offered asset.
|
|
760
|
+
*
|
|
761
|
+
* @param options - Creator account and PSWAP note to cancel.
|
|
762
|
+
*/
|
|
763
|
+
pswapCancel(options: PswapCancelOptions): Promise<TransactionSubmitResult>;
|
|
657
764
|
/**
|
|
658
765
|
* Consume all available notes for an account, up to an optional limit.
|
|
659
766
|
* Returns the count of remaining notes for pagination.
|
|
@@ -742,8 +849,13 @@ export interface NotesResource {
|
|
|
742
849
|
* Import a note from a {@link NoteFile}.
|
|
743
850
|
*
|
|
744
851
|
* @param noteFile - The note file to import.
|
|
852
|
+
* @returns The imported note's id (hex) when the file carries metadata (a
|
|
853
|
+
* note id or a full note with proof); for a details-only file, which has no
|
|
854
|
+
* note id yet, the note's details commitment (hex) is returned instead.
|
|
855
|
+
* In both cases the value is a hex string, not a `NoteId` object — pass it
|
|
856
|
+
* to {@link NoteId.fromHex} if a `NoteId` instance is required.
|
|
745
857
|
*/
|
|
746
|
-
import(noteFile: NoteFile): Promise<
|
|
858
|
+
import(noteFile: NoteFile): Promise<string>;
|
|
747
859
|
/**
|
|
748
860
|
* Export a note to a {@link NoteFile} for transfer or backup.
|
|
749
861
|
*
|
|
@@ -924,6 +1036,15 @@ export declare class MidenClient {
|
|
|
924
1036
|
static createDevnet(options?: ClientOptions): Promise<MidenClient>;
|
|
925
1037
|
/** Creates a mock client for testing. */
|
|
926
1038
|
static createMock(options?: MockOptions): Promise<MidenClient>;
|
|
1039
|
+
/**
|
|
1040
|
+
* Resolves once the WASM module is initialized and safe to use.
|
|
1041
|
+
*
|
|
1042
|
+
* Idempotent and shared across callers — concurrent invocations await the
|
|
1043
|
+
* same in-flight promise, and post-init callers resolve immediately.
|
|
1044
|
+
* Primarily useful on the `/lazy` entry (Next.js / Capacitor) where no
|
|
1045
|
+
* top-level await runs at import time; harmless on the eager entry.
|
|
1046
|
+
*/
|
|
1047
|
+
static ready(): Promise<void>;
|
|
927
1048
|
|
|
928
1049
|
readonly accounts: AccountsResource;
|
|
929
1050
|
readonly transactions: TransactionsResource;
|
|
@@ -937,6 +1058,35 @@ export declare class MidenClient {
|
|
|
937
1058
|
sync(options?: { timeout?: number }): Promise<SyncSummary>;
|
|
938
1059
|
/** Returns the current sync height. */
|
|
939
1060
|
getSyncHeight(): Promise<number>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Resolves once every serialized WASM call that was already on the
|
|
1063
|
+
* internal call chain when `waitForIdle()` was called (execute, submit,
|
|
1064
|
+
* prove, apply, sync, or account creation) has settled. Use this from
|
|
1065
|
+
* callers that need to perform a non-WASM-side action — e.g. clearing
|
|
1066
|
+
* an in-memory auth key on wallet lock — after the kernel finishes, so
|
|
1067
|
+
* its auth callback doesn't race with the key being cleared. Does NOT
|
|
1068
|
+
* wait for calls enqueued after `waitForIdle()` returns.
|
|
1069
|
+
*
|
|
1070
|
+
* Caveat for `sync`: a `syncState` blocked on its sync lock (Web
|
|
1071
|
+
* Locks) has not yet reached the internal chain, so `waitForIdle`
|
|
1072
|
+
* does not await it. Other serialized methods are always observed.
|
|
1073
|
+
*
|
|
1074
|
+
* Returns immediately if nothing was in flight.
|
|
1075
|
+
*/
|
|
1076
|
+
waitForIdle(): Promise<void>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Returns the raw JS value that the most recent sign-callback invocation
|
|
1079
|
+
* threw, or `null` if the last sign call succeeded (or no call has
|
|
1080
|
+
* happened yet). Useful for recovering structured metadata (e.g. a
|
|
1081
|
+
* `reason: 'locked'` property) that the kernel-level `auth::request`
|
|
1082
|
+
* diagnostic would otherwise erase.
|
|
1083
|
+
*
|
|
1084
|
+
* Meaningful only with `useWorker: false` (the worker shim's keystore
|
|
1085
|
+
* lives in the worker WASM instance, so this reads `null` there). On
|
|
1086
|
+
* the Node.js binding it always returns `null` — signing goes through
|
|
1087
|
+
* the filesystem keystore, never a JS callback.
|
|
1088
|
+
*/
|
|
1089
|
+
lastAuthError(): unknown;
|
|
940
1090
|
/** Returns the client-level default prover. */
|
|
941
1091
|
readonly defaultProver: TransactionProver | null;
|
|
942
1092
|
/** Terminates the underlying Web Worker. After this, all method calls throw. */
|
|
Binary file
|