@miden-sdk/miden-sdk 0.14.4 → 0.15.0-alpha.4

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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -9
  3. package/dist/{Cargo-Bwjf7IkR.js → Cargo-CVlXCH_2.js} +7105 -6141
  4. package/dist/Cargo-CVlXCH_2.js.map +1 -0
  5. package/dist/api-types.d.ts +17 -47
  6. package/dist/assets/miden_client_web.wasm +0 -0
  7. package/dist/crates/miden_client_web.d.ts +122 -76
  8. package/dist/docs-entry.d.ts +5 -2
  9. package/dist/eager.js +7 -4
  10. package/dist/eager.js.map +1 -1
  11. package/dist/index.d.ts +107 -7
  12. package/dist/index.js +534 -355
  13. package/dist/index.js.map +1 -1
  14. package/dist/wasm.js +1 -1
  15. package/dist/workers/{Cargo-Bwjf7IkR-Cz54YuXA.js → Cargo-CVlXCH_2-CWA-5vlh.js} +7105 -6141
  16. package/dist/workers/Cargo-CVlXCH_2-CWA-5vlh.js.map +1 -0
  17. package/dist/workers/assets/miden_client_web.wasm +0 -0
  18. package/dist/workers/web-client-methods-worker.js +7129 -6159
  19. package/dist/workers/web-client-methods-worker.js.map +1 -1
  20. package/dist/workers/web-client-methods-worker.module.js +23 -19
  21. package/dist/workers/web-client-methods-worker.module.js.map +1 -1
  22. package/js/client.js +327 -0
  23. package/js/node/client-factory.js +117 -0
  24. package/js/node/loader.js +138 -0
  25. package/js/node/napi-compat.js +238 -0
  26. package/js/node-index.js +195 -0
  27. package/js/resources/accounts.js +224 -0
  28. package/js/resources/compiler.js +74 -0
  29. package/js/resources/keystore.js +54 -0
  30. package/js/resources/notes.js +124 -0
  31. package/js/resources/settings.js +30 -0
  32. package/js/resources/tags.js +31 -0
  33. package/js/resources/transactions.js +533 -0
  34. package/js/standalone.js +109 -0
  35. package/js/utils.js +232 -0
  36. package/lazy/package.json +4 -0
  37. package/package.json +62 -40
  38. package/dist/Cargo-Bwjf7IkR.js.map +0 -1
  39. package/dist/workers/Cargo-Bwjf7IkR-Cz54YuXA.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  // Re-export everything from the WASM module
2
- export * from "./crates/miden_client_web";
2
+ export * from "./crates/miden_client_web.js";
3
3
 
4
4
  // Re-export all simplified API types
5
- export * from "./api-types";
5
+ export * from "./api-types.js";
6
6
 
7
7
  // Import types needed for the @internal class declarations below
8
8
  import type {
9
9
  WebClient as WasmWebClientBase,
10
10
  SyncSummary,
11
- } from "./crates/miden_client_web";
11
+ } from "./crates/miden_client_web.js";
12
12
  import type {
13
13
  GetKeyCallback,
14
14
  InsertKeyCallback,
15
15
  SignCallback,
16
- } from "./api-types";
16
+ } from "./api-types.js";
17
17
 
18
18
  export type LogLevel =
19
19
  | "error"
@@ -33,6 +33,103 @@ export type LogLevel =
33
33
  */
34
34
  export declare function setupLogging(logLevel: LogLevel): void;
35
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
+
36
133
  // ════════════════════════════════════════════════════════════════
37
134
  // Internal exports (not public API — for tests and advanced usage)
38
135
  // ════════════════════════════════════════════════════════════════
@@ -74,7 +171,10 @@ export declare class MockWasmWebClient extends WasmWebClient {
74
171
  logLevel?: LogLevel
75
172
  ): Promise<MockWasmWebClient>;
76
173
 
77
- proveBlock(): void;
78
- serializeMockChain(): Uint8Array;
79
- serializeMockNoteTransportNode(): Uint8Array;
174
+ proveBlock(): Promise<void>;
175
+ serializeMockChain(): Promise<Uint8Array>;
176
+ serializeMockNoteTransportNode(): Promise<Uint8Array>;
80
177
  }
178
+
179
+ /** Alias for MockWasmWebClient — used by test apps that import MockWebClient directly. */
180
+ export { MockWasmWebClient as MockWebClient };