@miden-sdk/miden-sdk 0.13.0-next.2 → 0.13.0-next.3

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/dist/index.d.ts CHANGED
@@ -1,133 +1,141 @@
1
- import { WebClient as WasmWebClient } from "./crates/miden_client_web";
2
-
3
- export {
4
- Account,
5
- AccountBuilder,
6
- AccountComponent,
7
- AccountDelta,
8
- AccountFile,
9
- AccountHeader,
10
- AccountId,
11
- AccountInterface,
12
- AccountStorageDelta,
13
- AccountStorageMode,
14
- AccountStorageRequirements,
15
- AccountType,
16
- AccountVaultDelta,
17
- Address,
18
- AddressInterface,
19
- AdviceMap,
20
- AuthRpoFalcon512MultisigConfig,
21
- Assembler,
22
- AssemblerUtils,
23
- AuthSecretKey,
24
- BasicFungibleFaucetComponent,
25
- ConsumableNoteRecord,
26
- Endpoint,
27
- Felt,
28
- FeltArray,
29
- ForeignAccount,
30
- FungibleAsset,
31
- FungibleAssetDelta,
32
- InputNoteRecord,
33
- InputNoteState,
34
- Library,
35
- MidenArrays,
36
- NetworkId,
37
- Note,
38
- NoteAndArgs,
39
- NoteAndArgsArray,
40
- NoteAssets,
41
- NoteConsumability,
42
- NoteDetails,
43
- NoteExecutionHint,
44
- NoteExecutionMode,
45
- NoteFile,
46
- NoteFilter,
47
- NoteFilterTypes,
48
- NoteId,
49
- NoteIdAndArgs,
50
- NoteIdAndArgsArray,
51
- NoteInputs,
52
- NoteMetadata,
53
- NoteRecipient,
54
- NoteScript,
55
- NoteTag,
56
- NoteType,
57
- OutputNote,
58
- OutputNotesArray,
59
- Package,
60
- ProcedureThreshold,
61
- PublicKey,
62
- Rpo256,
63
- RpcClient,
64
- SecretKey,
65
- ProvenTransaction,
66
- SerializedAccountHeader,
67
- Signature,
68
- SigningInputs,
69
- SigningInputsType,
70
- SlotAndKeys,
71
- SlotAndKeysArray,
72
- StorageMap,
73
- StorageSlot,
74
- TestUtils,
75
- TokenSymbol,
76
- TransactionFilter,
77
- TransactionId,
78
- TransactionKernel,
1
+ // Re-export everything from the WASM module
2
+ export * from "./crates/miden_client_web";
3
+
4
+ // Import types we need for augmentation
5
+ import type {
6
+ WebClient as WasmWebClient,
7
+ SyncSummary,
79
8
  TransactionProver,
80
- TransactionRecord,
81
- TransactionRequest,
82
- TransactionResult,
83
- TransactionStoreUpdate,
84
- TransactionRequestBuilder,
85
- TransactionScript,
86
- TransactionScriptInputPair,
87
- TransactionScriptInputPairArray,
88
- TransactionSummary,
89
- Word,
90
- createAuthRpoFalcon512Multisig,
91
9
  } from "./crates/miden_client_web";
92
10
 
93
- // Extend WASM WebClient but override methods that use workers
94
- export declare class WebClient extends WasmWebClient {
11
+ // Import the full namespace for the MidenArrayConstructors type
12
+ import type * as WasmExports from "./crates/miden_client_web";
13
+
14
+ // Export the WASM WebClient type alias for users who need to reference it explicitly
15
+ export type { WebClient as WasmWebClient } from "./crates/miden_client_web";
16
+
17
+ // Callback types for external keystore support
18
+ export type GetKeyCallback = (
19
+ pubKey: Uint8Array
20
+ ) => Promise<Uint8Array | null | undefined> | Uint8Array | null | undefined;
21
+
22
+ export type InsertKeyCallback = (
23
+ pubKey: Uint8Array,
24
+ secretKey: Uint8Array
25
+ ) => Promise<void> | void;
26
+
27
+ export type SignCallback = (
28
+ pubKey: Uint8Array,
29
+ signingInputs: Uint8Array
30
+ ) => Promise<Uint8Array> | Uint8Array;
31
+
32
+ type MidenArrayConstructors = {
33
+ [K in keyof typeof WasmExports as K extends `${string}Array`
34
+ ? K
35
+ : never]: (typeof WasmExports)[K];
36
+ };
37
+
38
+ export declare const MidenArrays: MidenArrayConstructors;
39
+
40
+ // Module augmentation to add JavaScript wrapper methods to WebClient
41
+ declare module "./crates/miden_client_web" {
42
+ interface WebClient {
43
+ /**
44
+ * Factory method to create and initialize a new wrapped WebClient.
45
+ *
46
+ * @param rpcUrl - The RPC URL (optional).
47
+ * @param noteTransportUrl - The note transport URL (optional).
48
+ * @param seed - The seed for the account (optional).
49
+ * @param network - Optional name for the store. Setting this allows multiple clients to be used in the same browser.
50
+ * @returns A promise that resolves to a fully initialized WebClient.
51
+ */
52
+ createClient(
53
+ rpcUrl?: string,
54
+ noteTransportUrl?: string,
55
+ seed?: Uint8Array,
56
+ network?: string
57
+ ): Promise<WebClient>;
58
+
59
+ /**
60
+ * Factory method to create and initialize a new wrapped WebClient with a remote keystore.
61
+ *
62
+ * @param rpcUrl - The RPC URL (optional).
63
+ * @param noteTransportUrl - The note transport URL (optional).
64
+ * @param seed - The seed for the account (optional).
65
+ * @param storeName - Optional name for the store. Setting this allows multiple clients to be used in the same browser.
66
+ * @param getKeyCb - Callback used to retrieve secret keys for a given public key.
67
+ * @param insertKeyCb - Callback used to persist secret keys in the external store.
68
+ * @param signCb - Callback used to create signatures for the provided inputs.
69
+ * @returns A promise that resolves to a fully initialized WebClient.
70
+ */
71
+ createClientWithExternalKeystore(
72
+ rpcUrl?: string,
73
+ noteTransportUrl?: string,
74
+ seed?: Uint8Array,
75
+ storeName?: string,
76
+ getKeyCb?: GetKeyCallback,
77
+ insertKeyCb?: InsertKeyCallback,
78
+ signCb?: SignCallback
79
+ ): Promise<WebClient>;
80
+
81
+ /** Returns the default transaction prover configured on the client. */
82
+ defaultTransactionProver(): TransactionProver;
83
+
84
+ /**
85
+ * Syncs the client state with the Miden node.
86
+ *
87
+ * This method coordinates concurrent calls using the Web Locks API:
88
+ * - If a sync is already in progress, callers wait and receive the same result
89
+ * - Cross-tab coordination ensures only one sync runs at a time per database
90
+ *
91
+ * @returns A promise that resolves to a SyncSummary with the sync results.
92
+ */
93
+ syncState(): Promise<SyncSummary>;
94
+
95
+ /**
96
+ * Syncs the client state with the Miden node with an optional timeout.
97
+ *
98
+ * This method coordinates concurrent calls using the Web Locks API:
99
+ * - If a sync is already in progress, callers wait and receive the same result
100
+ * - Cross-tab coordination ensures only one sync runs at a time per database
101
+ * - If a timeout is specified and exceeded, the method throws an error
102
+ *
103
+ * @param timeoutMs - Optional timeout in milliseconds. If 0 or not provided, waits indefinitely.
104
+ * @returns A promise that resolves to a SyncSummary with the sync results.
105
+ */
106
+ syncStateWithTimeout(timeoutMs?: number): Promise<SyncSummary>;
107
+
108
+ /**
109
+ * Terminates the underlying worker.
110
+ */
111
+ terminate(): void;
112
+ }
113
+ }
114
+
115
+ // MockWebClient class that extends the augmented WebClient
116
+ export declare class MockWebClient extends WasmWebClient {
95
117
  /**
96
- * Factory method to create and initialize a new wrapped WebClient.
118
+ * Factory method to create and initialize a new wrapped MockWebClient.
97
119
  *
98
- * @param rpcUrl - The RPC URL (optional).
99
- * @param noteTransportUrl - The note transport URL (optional).
100
- * @param seed - The seed for the account (optional).
101
- * @returns A promise that resolves to a fully initialized WebClient.
120
+ * @param serializedMockChain - Serialized mock chain (optional).
121
+ * @param serializedMockNoteTransportNode - Serialized mock note transport node (optional).
122
+ * @param seed - Seed for account initialization (optional).
123
+ * @returns A promise that resolves to a fully initialized MockWebClient.
102
124
  */
103
125
  static createClient(
104
- rpcUrl?: string,
105
- noteTransportUrl?: string,
106
- seed?: string
107
- ): Promise<WebClient & WasmWebClient>;
108
-
109
- static createClientWithExternalKeystore(
110
- rpcUrl?: string,
111
- noteTransportUrl?: string,
112
- seed?: string,
113
- getKeyCb?: (
114
- pubKey: Uint8Array
115
- ) => Promise<Uint8Array | null | undefined> | Uint8Array | null | undefined,
116
- insertKeyCb?: (
117
- pubKey: Uint8Array,
118
- secretKey: Uint8Array
119
- ) => Promise<void> | void,
120
- signCb?: (
121
- pubKey: Uint8Array,
122
- signingInputs: Uint8Array
123
- ) => Promise<Uint8Array> | Uint8Array
124
- ): Promise<WebClient & WasmWebClient>;
125
-
126
- /** Returns the default transaction prover configured on the client. */
127
- defaultTransactionProver(): TransactionProver;
126
+ serializedMockChain?: ArrayBuffer | Uint8Array,
127
+ serializedMockNoteTransportNode?: ArrayBuffer | Uint8Array,
128
+ seed?: Uint8Array
129
+ ): Promise<MockWebClient>;
130
+
131
+ /** Syncs the mock state and returns the resulting summary. */
132
+ syncState(): Promise<SyncSummary>;
128
133
 
129
134
  /**
130
- * Terminates the underlying worker.
135
+ * Syncs the client state with the Miden node with an optional timeout.
136
+ *
137
+ * @param timeoutMs - Optional timeout in milliseconds. If 0 or not provided, waits indefinitely.
138
+ * @returns A promise that resolves to a SyncSummary with the sync results.
131
139
  */
132
- terminate(): void;
140
+ syncStateWithTimeout(timeoutMs?: number): Promise<SyncSummary>;
133
141
  }