@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.
Files changed (59) hide show
  1. package/README.md +139 -9
  2. package/dist/mt/Cargo-smJQCGjz.js +26146 -0
  3. package/dist/mt/Cargo-smJQCGjz.js.map +1 -0
  4. package/dist/{api-types.d.ts → mt/api-types.d.ts} +154 -4
  5. package/dist/mt/assets/miden_client_web.wasm +0 -0
  6. package/dist/mt/crates/miden_client_web.d.ts +4791 -0
  7. package/dist/mt/eager.js +38 -0
  8. package/dist/mt/eager.js.map +1 -0
  9. package/dist/{index.d.ts → mt/index.d.ts} +4 -2
  10. package/dist/mt/index.js +3778 -0
  11. package/dist/mt/index.js.map +1 -0
  12. package/dist/{wasm.js → mt/wasm.js} +1 -1
  13. package/dist/mt/wasm.js.map +1 -0
  14. package/dist/mt/workerHelpers.js +28 -0
  15. package/dist/mt/workers/Cargo-smJQCGjz-q4GYXDiD.js +26147 -0
  16. package/dist/mt/workers/Cargo-smJQCGjz-q4GYXDiD.js.map +1 -0
  17. package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
  18. package/dist/mt/workers/web-client-methods-worker.js +26885 -0
  19. package/dist/mt/workers/web-client-methods-worker.js.map +1 -0
  20. package/dist/{workers → mt/workers}/web-client-methods-worker.module.js +17 -1
  21. package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -0
  22. package/dist/mt/workers/workerHelpers.js +28 -0
  23. package/dist/{Cargo-CVlXCH_2.js → st/Cargo-CG4XszZo.js} +698 -495
  24. package/dist/st/Cargo-CG4XszZo.js.map +1 -0
  25. package/dist/st/api-types.d.ts +1140 -0
  26. package/dist/{workers → st}/assets/miden_client_web.wasm +0 -0
  27. package/dist/{crates → st/crates}/miden_client_web.d.ts +342 -196
  28. package/dist/st/docs-entry.d.ts +38 -0
  29. package/dist/{eager.js → st/eager.js} +1 -1
  30. package/dist/st/eager.js.map +1 -0
  31. package/dist/st/index.d.ts +182 -0
  32. package/dist/{index.js → st/index.js} +425 -19
  33. package/dist/st/index.js.map +1 -0
  34. package/dist/st/wasm.js +23 -0
  35. package/dist/st/wasm.js.map +1 -0
  36. package/dist/{workers/Cargo-CVlXCH_2-CWA-5vlh.js → st/workers/Cargo-CG4XszZo-S7EHAZSa.js} +698 -495
  37. package/dist/st/workers/Cargo-CG4XszZo-S7EHAZSa.js.map +1 -0
  38. package/dist/{assets → st/workers/assets}/miden_client_web.wasm +0 -0
  39. package/dist/{workers → st/workers}/web-client-methods-worker.js +715 -496
  40. package/dist/st/workers/web-client-methods-worker.js.map +1 -0
  41. package/dist/st/workers/web-client-methods-worker.module.js +575 -0
  42. package/dist/st/workers/web-client-methods-worker.module.js.map +1 -0
  43. package/js/client.js +166 -2
  44. package/js/node/napi-compat.js +15 -0
  45. package/js/node-index.js +0 -1
  46. package/js/resources/accounts.js +4 -6
  47. package/js/resources/transactions.js +134 -0
  48. package/lazy/package.json +2 -2
  49. package/mt/lazy/package.json +4 -0
  50. package/mt/package.json +4 -0
  51. package/package.json +30 -15
  52. package/dist/Cargo-CVlXCH_2.js.map +0 -1
  53. package/dist/eager.js.map +0 -1
  54. package/dist/index.js.map +0 -1
  55. package/dist/wasm.js.map +0 -1
  56. package/dist/workers/Cargo-CVlXCH_2-CWA-5vlh.js.map +0 -1
  57. package/dist/workers/web-client-methods-worker.js.map +0 -1
  58. package/dist/workers/web-client-methods-worker.module.js.map +0 -1
  59. /package/dist/{docs-entry.d.ts → mt/docs-entry.d.ts} +0 -0
@@ -0,0 +1,38 @@
1
+ /**
2
+ * TypeDoc entry point — curated subset of the public API.
3
+ * Only types listed here (or transitively referenced) appear in generated docs.
4
+ * Runtime consumers should import from index.d.ts, not this file.
5
+ */
6
+
7
+ // Curated WASM re-exports: only types referenced in the public API
8
+ export {
9
+ Account,
10
+ AccountCode,
11
+ AccountFile,
12
+ AccountHeader,
13
+ AccountId,
14
+ AccountStorage,
15
+ AssetVault,
16
+ Felt,
17
+ InputNoteRecord,
18
+ Note,
19
+ NoteExportFormat,
20
+ NoteFile,
21
+ NoteId,
22
+ NoteTag,
23
+ RawOutputNote,
24
+ OutputNoteRecord,
25
+ SyncSummary,
26
+ TransactionId,
27
+ TransactionProver,
28
+ TransactionRecord,
29
+ TransactionRequest,
30
+ TransactionSummary,
31
+ Word,
32
+ } from "./crates/miden_client_web.js";
33
+
34
+ // All simplified API types
35
+ export * from "./api-types.js";
36
+
37
+ // Storage utilities
38
+ export { StorageView, StorageResult, wordToBigInt } from "./index.js";
@@ -1,6 +1,6 @@
1
1
  import { getWasmOrThrow } from './index.js';
2
2
  export { AccountType, AuthScheme, CompilerResource, Linking, MidenArrays, MidenClient, MockWasmWebClient, MockWasmWebClient as MockWebClient, NoteVisibility, StorageMode, StorageResult, StorageView, WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, wordToBigInt } from './index.js';
3
- export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, setupLogging } from './Cargo-CVlXCH_2.js';
3
+ export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, sequentialSumBench, setupLogging } from './Cargo-CG4XszZo.js';
4
4
  import './wasm.js';
5
5
 
6
6
  // Eager entry point for @miden-sdk/miden-sdk (browser builds).
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eager.js","sources":["../../js/eager.js"],"sourcesContent":["// Eager entry point for @miden-sdk/miden-sdk (browser builds).\n//\n// Awaits WASM initialization at module top level, so importing this module\n// guarantees that any wasm-bindgen constructor (`new RpcClient(...)`,\n// `AccountId.fromHex(...)`, `TransactionProver.newRemoteProver(...)`, etc.)\n// is safe to call synchronously on the next line. No explicit\n// `await MidenClient.ready()` / `isReady` gate is required.\n//\n// This is the default entry for browser bundlers (`@miden-sdk/miden-sdk`\n// → `./dist/eager.js`). Node.js consumers resolve the `node` exports\n// condition instead and get the napi binding via `./js/node-index.js`,\n// bypassing this file entirely.\n//\n// When NOT to use this entry:\n// - **Capacitor mobile apps** (Miden Wallet iOS/Android): Capacitor's\n// `capacitor://localhost` scheme handler interacts poorly with top-level\n// await in the main WKWebView. Verified empirically: TLA in a Capacitor\n// host WKWebView hangs module evaluation indefinitely, while the same\n// TLA in the dApp-browser WKWebView (vanilla HTTPS) resolves in <100ms.\n// - **Next.js / SSR**: TLA blocks server-side module evaluation.\n// - **Framework adapters (@miden-sdk/react, etc.)**: they manage readiness\n// via their own state machine (e.g. `isReady`) and should not impose\n// TLA on consumer bundles.\n//\n// For those contexts, import from `@miden-sdk/miden-sdk/lazy` — identical\n// API surface, no top-level await, callers are responsible for awaiting\n// `MidenClient.ready()` (or the equivalent) before touching wasm-bindgen\n// types.\nimport { getWasmOrThrow } from \"./index.js\";\n\nawait getWasmOrThrow();\n\nexport * from \"./index.js\";\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAM,cAAc,EAAE;;;;"}
@@ -0,0 +1,182 @@
1
+ // Re-export everything from the WASM module
2
+ export * from "./crates/miden_client_web.js";
3
+
4
+ // Re-export all simplified API types
5
+ export * from "./api-types.js";
6
+
7
+ // Import types needed for the @internal class declarations below
8
+ import type {
9
+ WebClient as WasmWebClientBase,
10
+ SyncSummary,
11
+ } from "./crates/miden_client_web.js";
12
+ import type {
13
+ GetKeyCallback,
14
+ InsertKeyCallback,
15
+ SignCallback,
16
+ } from "./api-types.js";
17
+
18
+ export type LogLevel =
19
+ | "error"
20
+ | "warn"
21
+ | "info"
22
+ | "debug"
23
+ | "trace"
24
+ | "off"
25
+ | "none";
26
+
27
+ /**
28
+ * Initializes the tracing subscriber that routes Rust log output to the
29
+ * browser console. Call once per thread (main thread / Web Worker).
30
+ * Subsequent calls on the same thread are harmless no-ops.
31
+ *
32
+ * @param logLevel - The maximum log level to display.
33
+ */
34
+ export declare function setupLogging(logLevel: LogLevel): void;
35
+
36
+ // ════════════════════════════════════════════════════════════════
37
+ // StorageView — wraps WASM AccountStorage with smart getItem()
38
+ // ════════════════════════════════════════════════════════════════
39
+
40
+ import type { AccountStorage, Word, Felt } from "./crates/miden_client_web.js";
41
+
42
+ /**
43
+ * Result of reading a storage slot via `StorageView.getItem()`.
44
+ * Works for both Value and StorageMap slots.
45
+ */
46
+ export declare class StorageResult {
47
+ /** True if this slot is a StorageMap. */
48
+ get isMap(): boolean;
49
+
50
+ /**
51
+ * All entries from a StorageMap slot.
52
+ * Each entry has `key` (hex), `value` (hex), and `word` (parsed Word or undefined).
53
+ * Returns undefined for Value slots.
54
+ */
55
+ get entries():
56
+ | Array<{ key: string; value: string; word: Word | undefined }>
57
+ | undefined;
58
+
59
+ /** The underlying Word value. */
60
+ get word(): Word | undefined;
61
+
62
+ /** Returns all four Felts of the stored Word. Pass-through to Word.toFelts(). */
63
+ toFelts(): Felt[];
64
+
65
+ /** The first Felt of the stored Word. */
66
+ felt(): Felt | undefined;
67
+
68
+ /** First felt as a BigInt. Preserves full u64 precision. */
69
+ toBigInt(): bigint;
70
+
71
+ /** The Word's hex representation. */
72
+ toHex(): string;
73
+
74
+ /** Renders as the BigInt value (lossless). Makes `{result}` work in JSX. */
75
+ toString(): string;
76
+
77
+ /** Returns the value as a string for JSON precision safety. */
78
+ toJSON(): string;
79
+
80
+ /**
81
+ * Allows arithmetic: `+result`, `result * 2`.
82
+ * Returns a JS number for values fitting in Number.MAX_SAFE_INTEGER.
83
+ * Throws RangeError for larger values — use `.toBigInt()` for exact access.
84
+ */
85
+ valueOf(): number;
86
+ }
87
+
88
+ /**
89
+ * Wraps WASM AccountStorage with a developer-friendly API.
90
+ *
91
+ * `getItem()` returns a `StorageResult` that works intuitively for both
92
+ * Value and StorageMap slots. The raw WASM AccountStorage is accessible
93
+ * via `.raw`.
94
+ *
95
+ * Installed on `Account.prototype.storage()` at WASM load time.
96
+ */
97
+ export declare class StorageView {
98
+ /** The raw WASM AccountStorage. */
99
+ get raw(): AccountStorage;
100
+
101
+ /** Returns the commitment to the full account storage. */
102
+ commitment(): Word;
103
+
104
+ /** Returns the names of all storage slots. */
105
+ getSlotNames(): string[];
106
+
107
+ /**
108
+ * Smart read: returns a `StorageResult` for the given slot.
109
+ * For Value slots: wraps the stored Word.
110
+ * For StorageMap slots: wraps the first entry's value, with all entries in `.entries`.
111
+ */
112
+ getItem(slotName: string): StorageResult | undefined;
113
+
114
+ /** Returns the value for a key in a StorageMap slot. */
115
+ getMapItem(slotName: string, key: Word): Word | undefined;
116
+
117
+ /** Get all key-value pairs from a StorageMap slot. */
118
+ getMapEntries(
119
+ slotName: string
120
+ ): Array<{ key: string; value: string }> | undefined;
121
+
122
+ /**
123
+ * Returns the commitment root of a storage slot.
124
+ * For Value slots: the stored Word. For StorageMap slots: the Merkle root hash.
125
+ * Useful for proofs, state comparison, and syncing.
126
+ */
127
+ getCommitment(slotName: string): Word | undefined;
128
+ }
129
+
130
+ /** Convert a Word's first felt to a BigInt (full u64 precision). */
131
+ export declare function wordToBigInt(word: Word): bigint;
132
+
133
+ // ════════════════════════════════════════════════════════════════
134
+ // Internal exports (not public API — for tests and advanced usage)
135
+ // ════════════════════════════════════════════════════════════════
136
+
137
+ /** @internal Low-level WebClient wrapper. Use MidenClient instead. */
138
+ export declare class WasmWebClient extends WasmWebClientBase {
139
+ static createClient(
140
+ rpcUrl?: string,
141
+ noteTransportUrl?: string,
142
+ seed?: Uint8Array,
143
+ storeName?: string,
144
+ logLevel?: LogLevel,
145
+ useWorker?: boolean
146
+ ): Promise<WasmWebClient>;
147
+
148
+ static createClientWithExternalKeystore(
149
+ rpcUrl?: string,
150
+ noteTransportUrl?: string,
151
+ seed?: Uint8Array,
152
+ storeName?: string,
153
+ getKeyCb?: GetKeyCallback,
154
+ insertKeyCb?: InsertKeyCallback,
155
+ signCb?: SignCallback,
156
+ logLevel?: LogLevel,
157
+ useWorker?: boolean
158
+ ): Promise<WasmWebClient>;
159
+
160
+ syncState(): Promise<SyncSummary>;
161
+ syncStateWithTimeout(timeoutMs: number): Promise<SyncSummary>;
162
+ setSignCb(signCb: SignCallback | null | undefined): void;
163
+ onStateChanged(callback: (event: any) => void): (() => void) | undefined;
164
+ terminate(): void;
165
+ }
166
+
167
+ /** @internal Low-level MockWebClient wrapper. Use MidenClient.createMock() instead. */
168
+ export declare class MockWasmWebClient extends WasmWebClient {
169
+ static createClient(
170
+ serializedMockChain?: Uint8Array,
171
+ serializedMockNoteTransportNode?: Uint8Array,
172
+ seed?: Uint8Array,
173
+ logLevel?: LogLevel
174
+ ): Promise<MockWasmWebClient>;
175
+
176
+ proveBlock(): Promise<void>;
177
+ serializeMockChain(): Promise<Uint8Array>;
178
+ serializeMockNoteTransportNode(): Promise<Uint8Array>;
179
+ }
180
+
181
+ /** Alias for MockWasmWebClient — used by test apps that import MockWebClient directly. */
182
+ export { MockWasmWebClient as MockWebClient };