@miden-sdk/miden-sdk 0.13.2 → 0.14.0-alpha
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 +104 -43
- package/dist/{Cargo-e77f9a02.js → Cargo-D064yzd4.js} +7250 -7428
- package/dist/Cargo-D064yzd4.js.map +1 -0
- package/dist/api-types.d.ts +521 -0
- package/dist/assets/miden_client_web.wasm +0 -0
- package/dist/crates/miden_client_web.d.ts +3658 -3312
- package/dist/docs-entry.d.ts +36 -0
- package/dist/index.d.ts +27 -109
- package/dist/index.js +1302 -106
- package/dist/index.js.map +1 -1
- package/dist/wasm.js +1 -1
- package/dist/wasm.js.map +1 -1
- package/dist/workers/{Cargo-e77f9a02-e77f9a02.js → Cargo-D064yzd4-D064yzd4.js} +7250 -7428
- package/dist/workers/Cargo-D064yzd4-D064yzd4.js.map +1 -0
- package/dist/workers/assets/miden_client_web.wasm +0 -0
- package/dist/workers/web-client-methods-worker.js +43 -45
- package/dist/workers/web-client-methods-worker.js.map +1 -1
- package/package.json +15 -3
- package/dist/Cargo-e77f9a02.js.map +0 -1
- package/dist/workers/Cargo-e77f9a02-e77f9a02.js.map +0 -1
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
// Import types needed for type references in the public API
|
|
2
|
+
import type {
|
|
3
|
+
SyncSummary,
|
|
4
|
+
TransactionProver,
|
|
5
|
+
Account,
|
|
6
|
+
AccountHeader,
|
|
7
|
+
AccountId,
|
|
8
|
+
AccountFile,
|
|
9
|
+
AccountCode,
|
|
10
|
+
AccountStorage,
|
|
11
|
+
AssetVault,
|
|
12
|
+
Word,
|
|
13
|
+
Felt,
|
|
14
|
+
TransactionId,
|
|
15
|
+
TransactionRequest,
|
|
16
|
+
TransactionSummary,
|
|
17
|
+
TransactionRecord,
|
|
18
|
+
InputNoteRecord,
|
|
19
|
+
OutputNoteRecord,
|
|
20
|
+
ConsumableNoteRecord,
|
|
21
|
+
NoteId,
|
|
22
|
+
NoteFile,
|
|
23
|
+
NoteTag,
|
|
24
|
+
Note,
|
|
25
|
+
OutputNote,
|
|
26
|
+
NoteExportFormat,
|
|
27
|
+
} from "./crates/miden_client_web";
|
|
28
|
+
|
|
29
|
+
// Import the full namespace for the MidenArrayConstructors type
|
|
30
|
+
import type * as WasmExports from "./crates/miden_client_web";
|
|
31
|
+
|
|
32
|
+
// ════════════════════════════════════════════════════════════════
|
|
33
|
+
// Callback types for external keystore support
|
|
34
|
+
// ════════════════════════════════════════════════════════════════
|
|
35
|
+
|
|
36
|
+
export type GetKeyCallback = (
|
|
37
|
+
pubKey: Uint8Array
|
|
38
|
+
) => Promise<Uint8Array | null | undefined> | Uint8Array | null | undefined;
|
|
39
|
+
|
|
40
|
+
export type InsertKeyCallback = (
|
|
41
|
+
pubKey: Uint8Array,
|
|
42
|
+
secretKey: Uint8Array
|
|
43
|
+
) => Promise<void> | void;
|
|
44
|
+
|
|
45
|
+
export type SignCallback = (
|
|
46
|
+
pubKey: Uint8Array,
|
|
47
|
+
signingInputs: Uint8Array
|
|
48
|
+
) => Promise<Uint8Array> | Uint8Array;
|
|
49
|
+
|
|
50
|
+
type MidenArrayConstructors = {
|
|
51
|
+
[K in keyof typeof WasmExports as K extends `${string}Array`
|
|
52
|
+
? K
|
|
53
|
+
: never]: (typeof WasmExports)[K];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export declare const MidenArrays: MidenArrayConstructors;
|
|
57
|
+
|
|
58
|
+
// ════════════════════════════════════════════════════════════════
|
|
59
|
+
// Constants
|
|
60
|
+
// ════════════════════════════════════════════════════════════════
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* User-friendly auth scheme constants for MidenClient options.
|
|
64
|
+
* Use `AuthScheme.Falcon` or `AuthScheme.ECDSA` instead of raw strings.
|
|
65
|
+
*/
|
|
66
|
+
export declare const AuthScheme: {
|
|
67
|
+
readonly Falcon: "falcon";
|
|
68
|
+
readonly ECDSA: "ecdsa";
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Union of all values in the AuthScheme const.
|
|
73
|
+
*/
|
|
74
|
+
export type AuthSchemeType = (typeof AuthScheme)[keyof typeof AuthScheme];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Union of all values in the AccountType const.
|
|
78
|
+
*/
|
|
79
|
+
export type AccountType = (typeof AccountType)[keyof typeof AccountType];
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* User-friendly account type constants for the simplified API.
|
|
83
|
+
* Replaces the WASM `AccountType` enum (which has internal names like
|
|
84
|
+
* `RegularAccountUpdatableCode`) with readable string constants.
|
|
85
|
+
*/
|
|
86
|
+
export declare const AccountType: {
|
|
87
|
+
readonly MutableWallet: "MutableWallet";
|
|
88
|
+
readonly ImmutableWallet: "ImmutableWallet";
|
|
89
|
+
readonly FungibleFaucet: "FungibleFaucet";
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** Union of valid AccountType string values. */
|
|
93
|
+
export type AccountTypeValue =
|
|
94
|
+
| "MutableWallet"
|
|
95
|
+
| "ImmutableWallet"
|
|
96
|
+
| "FungibleFaucet";
|
|
97
|
+
|
|
98
|
+
// ════════════════════════════════════════════════════════════════
|
|
99
|
+
// Client options
|
|
100
|
+
// ════════════════════════════════════════════════════════════════
|
|
101
|
+
|
|
102
|
+
export interface ClientOptions {
|
|
103
|
+
/** RPC endpoint URL. Defaults to testnet RPC. */
|
|
104
|
+
rpcUrl?: string;
|
|
105
|
+
/** Note transport URL (optional). */
|
|
106
|
+
noteTransportUrl?: string;
|
|
107
|
+
/** Auto-creates a remote prover from this URL. */
|
|
108
|
+
proverUrl?: string;
|
|
109
|
+
/** Hashed to 32 bytes via SHA-256. */
|
|
110
|
+
seed?: string | Uint8Array;
|
|
111
|
+
/** Store isolation key. */
|
|
112
|
+
storeName?: string;
|
|
113
|
+
/** Sync state on creation (default: false). */
|
|
114
|
+
autoSync?: boolean;
|
|
115
|
+
/** External keystore callbacks. */
|
|
116
|
+
keystore?: {
|
|
117
|
+
getKey: GetKeyCallback;
|
|
118
|
+
insertKey: InsertKeyCallback;
|
|
119
|
+
sign: SignCallback;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ════════════════════════════════════════════════════════════════
|
|
124
|
+
// Shared types
|
|
125
|
+
// ════════════════════════════════════════════════════════════════
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* An account reference: hex string, bech32 string, Account, AccountHeader, or AccountId object.
|
|
129
|
+
* All ID fields throughout the SDK accept any of these forms.
|
|
130
|
+
*/
|
|
131
|
+
export type AccountRef = string | Account | AccountHeader | AccountId;
|
|
132
|
+
|
|
133
|
+
/** Represents an amount of a specific token (identified by its faucet account). */
|
|
134
|
+
export interface Asset {
|
|
135
|
+
/** Token identifier (faucet account ID). */
|
|
136
|
+
token: AccountRef;
|
|
137
|
+
/** Auto-converted to bigint internally. */
|
|
138
|
+
amount: number | bigint;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type NoteVisibility = "public" | "private";
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A note reference: hex note ID string, NoteId object, InputNoteRecord, or Note object.
|
|
145
|
+
*/
|
|
146
|
+
export type NoteInput = string | NoteId | Note | InputNoteRecord;
|
|
147
|
+
|
|
148
|
+
// ════════════════════════════════════════════════════════════════
|
|
149
|
+
// Account types
|
|
150
|
+
// ════════════════════════════════════════════════════════════════
|
|
151
|
+
|
|
152
|
+
/** Create a wallet (default) or faucet. Discriminated by `type` field. */
|
|
153
|
+
export type CreateAccountOptions = WalletCreateOptions | FaucetCreateOptions;
|
|
154
|
+
|
|
155
|
+
export interface WalletCreateOptions {
|
|
156
|
+
/** Account type. Defaults to "MutableWallet". Use AccountType enum. */
|
|
157
|
+
type?: "MutableWallet" | "ImmutableWallet";
|
|
158
|
+
storage?: "private" | "public";
|
|
159
|
+
auth?: AuthSchemeType;
|
|
160
|
+
seed?: string | Uint8Array;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface FaucetCreateOptions {
|
|
164
|
+
type: "FungibleFaucet";
|
|
165
|
+
symbol: string;
|
|
166
|
+
decimals: number;
|
|
167
|
+
maxSupply: number | bigint;
|
|
168
|
+
storage?: "private" | "public";
|
|
169
|
+
auth?: AuthSchemeType;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface AccountDetails {
|
|
173
|
+
account: Account;
|
|
174
|
+
vault: AssetVault;
|
|
175
|
+
storage: AccountStorage;
|
|
176
|
+
code: AccountCode | null;
|
|
177
|
+
keys: Word[];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Discriminated union for account import.
|
|
182
|
+
*
|
|
183
|
+
* - `string` — Import a public account by its hex or bech32 ID (fetches state from the network).
|
|
184
|
+
* - `{ file: AccountFile }` — Import from a previously exported account file (works for both public and private accounts).
|
|
185
|
+
* - `{ seed, type?, auth? }` — Reconstruct a **public** account from its init seed. **Does not work for private accounts** — use the account file workflow instead.
|
|
186
|
+
*/
|
|
187
|
+
export type ImportAccountInput =
|
|
188
|
+
| string
|
|
189
|
+
| { file: AccountFile }
|
|
190
|
+
| {
|
|
191
|
+
seed: Uint8Array;
|
|
192
|
+
/** Account type. Defaults to "MutableWallet". Use AccountType enum. */
|
|
193
|
+
type?: "MutableWallet" | "ImmutableWallet";
|
|
194
|
+
auth?: AuthSchemeType;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/** Options for accounts.export(). Exists for forward-compatible extensibility. */
|
|
198
|
+
export interface ExportAccountOptions {}
|
|
199
|
+
|
|
200
|
+
// ════════════════════════════════════════════════════════════════
|
|
201
|
+
// Transaction types
|
|
202
|
+
// ════════════════════════════════════════════════════════════════
|
|
203
|
+
|
|
204
|
+
export interface TransactionOptions {
|
|
205
|
+
waitForConfirmation?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Wall-clock polling timeout in milliseconds for waitFor() (default: 60_000).
|
|
208
|
+
* This is NOT a block height. For block-height-based parameters, see
|
|
209
|
+
* `reclaimAfter` and `timelockUntil` on SendOptions.
|
|
210
|
+
*/
|
|
211
|
+
timeout?: number;
|
|
212
|
+
/** Override default prover. */
|
|
213
|
+
prover?: TransactionProver;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface SendOptions extends TransactionOptions {
|
|
217
|
+
account: AccountRef;
|
|
218
|
+
to: AccountRef;
|
|
219
|
+
token: AccountRef;
|
|
220
|
+
amount: number | bigint;
|
|
221
|
+
type?: NoteVisibility;
|
|
222
|
+
/** Block height after which the sender can reclaim the note. This is a block number, not wall-clock time. */
|
|
223
|
+
reclaimAfter?: number;
|
|
224
|
+
/** Block height until which the note is timelocked. This is a block number, not wall-clock time. */
|
|
225
|
+
timelockUntil?: number;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface MintOptions extends TransactionOptions {
|
|
229
|
+
/** Faucet (executing account). */
|
|
230
|
+
account: AccountRef;
|
|
231
|
+
to: AccountRef;
|
|
232
|
+
amount: number | bigint;
|
|
233
|
+
type?: NoteVisibility;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface ConsumeOptions extends TransactionOptions {
|
|
237
|
+
account: AccountRef;
|
|
238
|
+
notes: NoteInput | NoteInput[];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface ConsumeAllOptions extends TransactionOptions {
|
|
242
|
+
account: AccountRef;
|
|
243
|
+
maxNotes?: number;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface SwapOptions extends TransactionOptions {
|
|
247
|
+
account: AccountRef;
|
|
248
|
+
offer: Asset;
|
|
249
|
+
request: Asset;
|
|
250
|
+
type?: NoteVisibility;
|
|
251
|
+
paybackType?: NoteVisibility;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface PreviewSendOptions {
|
|
255
|
+
operation: "send";
|
|
256
|
+
account: AccountRef;
|
|
257
|
+
to: AccountRef;
|
|
258
|
+
token: AccountRef;
|
|
259
|
+
amount: number | bigint;
|
|
260
|
+
type?: NoteVisibility;
|
|
261
|
+
reclaimAfter?: number;
|
|
262
|
+
timelockUntil?: number;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface PreviewMintOptions {
|
|
266
|
+
operation: "mint";
|
|
267
|
+
account: AccountRef;
|
|
268
|
+
to: AccountRef;
|
|
269
|
+
amount: number | bigint;
|
|
270
|
+
type?: NoteVisibility;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface PreviewConsumeOptions {
|
|
274
|
+
operation: "consume";
|
|
275
|
+
account: AccountRef;
|
|
276
|
+
notes: NoteInput | NoteInput[];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export interface PreviewSwapOptions {
|
|
280
|
+
operation: "swap";
|
|
281
|
+
account: AccountRef;
|
|
282
|
+
offer: Asset;
|
|
283
|
+
request: Asset;
|
|
284
|
+
type?: NoteVisibility;
|
|
285
|
+
paybackType?: NoteVisibility;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export type PreviewOptions =
|
|
289
|
+
| PreviewSendOptions
|
|
290
|
+
| PreviewMintOptions
|
|
291
|
+
| PreviewConsumeOptions
|
|
292
|
+
| PreviewSwapOptions;
|
|
293
|
+
|
|
294
|
+
/** Status values reported during waitFor polling. */
|
|
295
|
+
export type WaitStatus = "pending" | "submitted" | "committed";
|
|
296
|
+
|
|
297
|
+
export interface WaitOptions {
|
|
298
|
+
/** Wall-clock polling timeout in ms (default: 60_000). Set to 0 to disable timeout and poll indefinitely. */
|
|
299
|
+
timeout?: number;
|
|
300
|
+
/** Polling interval in ms (default: 5_000). */
|
|
301
|
+
interval?: number;
|
|
302
|
+
onProgress?: (status: WaitStatus) => void;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Result of consumeAll — includes count of remaining notes for pagination. */
|
|
306
|
+
export interface ConsumeAllResult {
|
|
307
|
+
txId: TransactionId | null;
|
|
308
|
+
consumed: number;
|
|
309
|
+
remaining: number;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Discriminated union for transaction queries.
|
|
314
|
+
* Mirrors the underlying WASM TransactionFilter enum.
|
|
315
|
+
*/
|
|
316
|
+
export type TransactionQuery =
|
|
317
|
+
| { status: "uncommitted" }
|
|
318
|
+
| { ids: string[] }
|
|
319
|
+
| { expiredBefore: number };
|
|
320
|
+
|
|
321
|
+
// ════════════════════════════════════════════════════════════════
|
|
322
|
+
// Note types
|
|
323
|
+
// ════════════════════════════════════════════════════════════════
|
|
324
|
+
|
|
325
|
+
/** Discriminated union for note queries. */
|
|
326
|
+
export type NoteQuery =
|
|
327
|
+
| {
|
|
328
|
+
status:
|
|
329
|
+
| "consumed"
|
|
330
|
+
| "committed"
|
|
331
|
+
| "expected"
|
|
332
|
+
| "processing"
|
|
333
|
+
| "unverified";
|
|
334
|
+
}
|
|
335
|
+
| { ids: string[] };
|
|
336
|
+
|
|
337
|
+
/** Options for standalone note creation utilities. */
|
|
338
|
+
export interface NoteOptions {
|
|
339
|
+
from: AccountRef;
|
|
340
|
+
to: AccountRef;
|
|
341
|
+
assets: Asset | Asset[];
|
|
342
|
+
type?: NoteVisibility;
|
|
343
|
+
attachment?: Felt[];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface P2IDEOptions extends NoteOptions {
|
|
347
|
+
reclaimAfter?: number;
|
|
348
|
+
timelockUntil?: number;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface ExportNoteOptions {
|
|
352
|
+
/** Export format. Defaults to NoteExportFormat.Full. Use the NoteExportFormat enum. */
|
|
353
|
+
format?: NoteExportFormat;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface FetchPrivateNotesOptions {
|
|
357
|
+
mode?: "incremental" | "all";
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface SendPrivateOptions {
|
|
361
|
+
noteId: string;
|
|
362
|
+
to: AccountRef;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export interface MockOptions {
|
|
366
|
+
seed?: string | Uint8Array;
|
|
367
|
+
serializedMockChain?: Uint8Array;
|
|
368
|
+
serializedNoteTransport?: Uint8Array;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** Versioned store snapshot for backup/restore. */
|
|
372
|
+
export interface StoreSnapshot {
|
|
373
|
+
version: number;
|
|
374
|
+
data: unknown;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// ════════════════════════════════════════════════════════════════
|
|
378
|
+
// Swap tag options
|
|
379
|
+
// ════════════════════════════════════════════════════════════════
|
|
380
|
+
|
|
381
|
+
export interface BuildSwapTagOptions {
|
|
382
|
+
type?: NoteVisibility;
|
|
383
|
+
offer: Asset;
|
|
384
|
+
request: Asset;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// ════════════════════════════════════════════════════════════════
|
|
388
|
+
// Resource interfaces
|
|
389
|
+
// ════════════════════════════════════════════════════════════════
|
|
390
|
+
|
|
391
|
+
export interface AccountsResource {
|
|
392
|
+
create(options?: CreateAccountOptions): Promise<Account>;
|
|
393
|
+
get(accountId: AccountRef): Promise<Account | null>;
|
|
394
|
+
list(): Promise<AccountHeader[]>;
|
|
395
|
+
getDetails(accountId: AccountRef): Promise<AccountDetails>;
|
|
396
|
+
getBalance(accountId: AccountRef, tokenId: AccountRef): Promise<bigint>;
|
|
397
|
+
|
|
398
|
+
import(input: ImportAccountInput): Promise<Account>;
|
|
399
|
+
export(
|
|
400
|
+
accountId: AccountRef,
|
|
401
|
+
options?: ExportAccountOptions
|
|
402
|
+
): Promise<AccountFile>;
|
|
403
|
+
|
|
404
|
+
addAddress(accountId: AccountRef, address: string): Promise<void>;
|
|
405
|
+
removeAddress(accountId: AccountRef, address: string): Promise<void>;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface TransactionsResource {
|
|
409
|
+
send(options: SendOptions): Promise<TransactionId>;
|
|
410
|
+
mint(options: MintOptions): Promise<TransactionId>;
|
|
411
|
+
consume(options: ConsumeOptions): Promise<TransactionId>;
|
|
412
|
+
swap(options: SwapOptions): Promise<TransactionId>;
|
|
413
|
+
consumeAll(options: ConsumeAllOptions): Promise<ConsumeAllResult>;
|
|
414
|
+
|
|
415
|
+
preview(options: PreviewOptions): Promise<TransactionSummary>;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Submit a pre-built TransactionRequest.
|
|
419
|
+
* Note: WASM requires accountId separately, so `account` is the first argument.
|
|
420
|
+
*/
|
|
421
|
+
submit(
|
|
422
|
+
account: AccountRef,
|
|
423
|
+
request: TransactionRequest,
|
|
424
|
+
options?: TransactionOptions
|
|
425
|
+
): Promise<TransactionId>;
|
|
426
|
+
|
|
427
|
+
list(query?: TransactionQuery): Promise<TransactionRecord[]>;
|
|
428
|
+
|
|
429
|
+
waitFor(txId: string, options?: WaitOptions): Promise<void>;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export interface NotesResource {
|
|
433
|
+
list(query?: NoteQuery): Promise<InputNoteRecord[]>;
|
|
434
|
+
get(noteId: string): Promise<InputNoteRecord | null>;
|
|
435
|
+
|
|
436
|
+
listSent(query?: NoteQuery): Promise<OutputNoteRecord[]>;
|
|
437
|
+
|
|
438
|
+
listAvailable(options: {
|
|
439
|
+
account: AccountRef;
|
|
440
|
+
}): Promise<ConsumableNoteRecord[]>;
|
|
441
|
+
|
|
442
|
+
import(noteFile: NoteFile): Promise<NoteId>;
|
|
443
|
+
export(noteId: string, options?: ExportNoteOptions): Promise<NoteFile>;
|
|
444
|
+
|
|
445
|
+
fetchPrivate(options?: FetchPrivateNotesOptions): Promise<void>;
|
|
446
|
+
sendPrivate(options: SendPrivateOptions): Promise<void>;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export interface TagsResource {
|
|
450
|
+
add(tag: number): Promise<void>;
|
|
451
|
+
remove(tag: number): Promise<void>;
|
|
452
|
+
list(): Promise<number[]>;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export interface SettingsResource {
|
|
456
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
457
|
+
set(key: string, value: unknown): Promise<void>;
|
|
458
|
+
remove(key: string): Promise<void>;
|
|
459
|
+
listKeys(): Promise<string[]>;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// ════════════════════════════════════════════════════════════════
|
|
463
|
+
// MidenClient
|
|
464
|
+
// ════════════════════════════════════════════════════════════════
|
|
465
|
+
|
|
466
|
+
export declare class MidenClient {
|
|
467
|
+
/** Creates and initializes a new MidenClient. */
|
|
468
|
+
static create(options?: ClientOptions): Promise<MidenClient>;
|
|
469
|
+
/** Creates a client preconfigured for testnet use. Defaults to autoSync: true. */
|
|
470
|
+
static createTestnet(options?: ClientOptions): Promise<MidenClient>;
|
|
471
|
+
/** Creates a mock client for testing. */
|
|
472
|
+
static createMock(options?: MockOptions): Promise<MidenClient>;
|
|
473
|
+
|
|
474
|
+
readonly accounts: AccountsResource;
|
|
475
|
+
readonly transactions: TransactionsResource;
|
|
476
|
+
readonly notes: NotesResource;
|
|
477
|
+
readonly tags: TagsResource;
|
|
478
|
+
readonly settings: SettingsResource;
|
|
479
|
+
|
|
480
|
+
/** Syncs the client state with the Miden node. */
|
|
481
|
+
sync(options?: { timeout?: number }): Promise<SyncSummary>;
|
|
482
|
+
/** Returns the current sync height. */
|
|
483
|
+
getSyncHeight(): Promise<number>;
|
|
484
|
+
/** Returns the client-level default prover. */
|
|
485
|
+
readonly defaultProver: TransactionProver | null;
|
|
486
|
+
/** Terminates the underlying Web Worker. After this, all method calls throw. */
|
|
487
|
+
terminate(): void;
|
|
488
|
+
|
|
489
|
+
/** Exports the client store as a versioned snapshot. */
|
|
490
|
+
exportStore(): Promise<StoreSnapshot>;
|
|
491
|
+
/** Imports a previously exported store snapshot. */
|
|
492
|
+
importStore(snapshot: StoreSnapshot): Promise<void>;
|
|
493
|
+
|
|
494
|
+
/** Advances the mock chain by one block. Only available on mock clients. */
|
|
495
|
+
proveBlock(): void;
|
|
496
|
+
/** Returns true if this client uses a mock chain. */
|
|
497
|
+
usesMockChain(): boolean;
|
|
498
|
+
/** Serializes the mock chain state for snapshot/restore in tests. */
|
|
499
|
+
serializeMockChain(): Uint8Array;
|
|
500
|
+
/** Serializes the mock note transport node state. */
|
|
501
|
+
serializeMockNoteTransportNode(): Uint8Array;
|
|
502
|
+
|
|
503
|
+
[Symbol.dispose](): void;
|
|
504
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// ════════════════════════════════════════════════════════════════
|
|
508
|
+
// Standalone utilities (tree-shakeable)
|
|
509
|
+
// ════════════════════════════════════════════════════════════════
|
|
510
|
+
|
|
511
|
+
/** Creates a P2ID (Pay-to-ID) note. */
|
|
512
|
+
export declare function createP2IDNote(options: NoteOptions): OutputNote;
|
|
513
|
+
|
|
514
|
+
/** Creates a P2IDE (Pay-to-ID with Expiration) note. */
|
|
515
|
+
export declare function createP2IDENote(options: P2IDEOptions): OutputNote;
|
|
516
|
+
|
|
517
|
+
/** Builds a swap tag for note matching. Returns a NoteTag (use `.asU32()` for the numeric value). */
|
|
518
|
+
export declare function buildSwapTag(options: BuildSwapTagOptions): NoteTag;
|
|
519
|
+
|
|
520
|
+
/** Returns the initialized WASM module. Throws if WASM is unavailable. */
|
|
521
|
+
export declare function getWasmOrThrow(): Promise<typeof WasmExports>;
|
|
Binary file
|