@miden-sdk/miden-sdk 0.14.0-alpha → 0.14.0
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 +2 -2
- package/dist/{Cargo-D064yzd4.js → Cargo-M1xGvXNQ.js} +1679 -754
- package/dist/Cargo-M1xGvXNQ.js.map +1 -0
- package/dist/api-types.d.ts +461 -53
- package/dist/assets/miden_client_web.wasm +0 -0
- package/dist/crates/miden_client_web.d.ts +351 -107
- package/dist/docs-entry.d.ts +1 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +616 -96
- package/dist/index.js.map +1 -1
- package/dist/wasm.js +1 -1
- package/dist/workers/{Cargo-D064yzd4-D064yzd4.js → Cargo-M1xGvXNQ-M1xGvXNQ.js} +1679 -754
- package/dist/workers/Cargo-M1xGvXNQ-M1xGvXNQ.js.map +1 -0
- package/dist/workers/assets/miden_client_web.wasm +0 -0
- package/dist/workers/web-client-methods-worker.js +2 -2
- package/dist/workers/web-client-methods-worker.js.map +1 -1
- package/package.json +8 -4
- package/dist/Cargo-D064yzd4.js.map +0 -1
- package/dist/workers/Cargo-D064yzd4-D064yzd4.js.map +0 -1
package/dist/api-types.d.ts
CHANGED
|
@@ -13,17 +13,24 @@ import type {
|
|
|
13
13
|
Felt,
|
|
14
14
|
TransactionId,
|
|
15
15
|
TransactionRequest,
|
|
16
|
+
TransactionResult,
|
|
16
17
|
TransactionSummary,
|
|
17
18
|
TransactionRecord,
|
|
18
19
|
InputNoteRecord,
|
|
19
20
|
OutputNoteRecord,
|
|
20
|
-
ConsumableNoteRecord,
|
|
21
21
|
NoteId,
|
|
22
22
|
NoteFile,
|
|
23
23
|
NoteTag,
|
|
24
24
|
Note,
|
|
25
25
|
OutputNote,
|
|
26
26
|
NoteExportFormat,
|
|
27
|
+
StorageSlot,
|
|
28
|
+
AccountComponent,
|
|
29
|
+
AuthSecretKey,
|
|
30
|
+
AccountStorageRequirements,
|
|
31
|
+
TransactionScript,
|
|
32
|
+
AdviceInputs,
|
|
33
|
+
FeltArray,
|
|
27
34
|
} from "./crates/miden_client_web";
|
|
28
35
|
|
|
29
36
|
// Import the full namespace for the MidenArrayConstructors type
|
|
@@ -73,39 +80,87 @@ export declare const AuthScheme: {
|
|
|
73
80
|
*/
|
|
74
81
|
export type AuthSchemeType = (typeof AuthScheme)[keyof typeof AuthScheme];
|
|
75
82
|
|
|
83
|
+
/**
|
|
84
|
+
* User-friendly note visibility constants.
|
|
85
|
+
* Use `NoteVisibility.Public` or `NoteVisibility.Private` instead of raw strings.
|
|
86
|
+
*/
|
|
87
|
+
export declare const NoteVisibility: {
|
|
88
|
+
readonly Public: "public";
|
|
89
|
+
readonly Private: "private";
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** Union of valid NoteVisibility string values. */
|
|
93
|
+
export type NoteVisibility = "public" | "private";
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* User-friendly storage mode constants.
|
|
97
|
+
* Use `StorageMode.Public`, `StorageMode.Private`, or `StorageMode.Network` instead of raw strings.
|
|
98
|
+
*/
|
|
99
|
+
export declare const StorageMode: {
|
|
100
|
+
readonly Public: "public";
|
|
101
|
+
readonly Private: "private";
|
|
102
|
+
readonly Network: "network";
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** Union of valid StorageMode string values. */
|
|
106
|
+
export type StorageMode = "public" | "private" | "network";
|
|
107
|
+
|
|
76
108
|
/**
|
|
77
109
|
* Union of all values in the AccountType const.
|
|
78
110
|
*/
|
|
79
111
|
export type AccountType = (typeof AccountType)[keyof typeof AccountType];
|
|
80
112
|
|
|
81
113
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
114
|
+
* Account type constants with numeric values matching the WASM `AccountType` enum.
|
|
115
|
+
* Includes SDK-friendly aliases (e.g. `MutableWallet`) that map to the same
|
|
116
|
+
* numeric values. These values work with both `accounts.create()` and the
|
|
117
|
+
* low-level `AccountBuilder.accountType()`.
|
|
85
118
|
*/
|
|
86
119
|
export declare const AccountType: {
|
|
87
|
-
|
|
88
|
-
readonly
|
|
89
|
-
readonly
|
|
120
|
+
// WASM-compatible values
|
|
121
|
+
readonly FungibleFaucet: 0;
|
|
122
|
+
readonly NonFungibleFaucet: 1;
|
|
123
|
+
readonly RegularAccountImmutableCode: 2;
|
|
124
|
+
readonly RegularAccountUpdatableCode: 3;
|
|
125
|
+
// SDK-friendly aliases
|
|
126
|
+
readonly MutableWallet: 3;
|
|
127
|
+
readonly ImmutableWallet: 2;
|
|
128
|
+
readonly ImmutableContract: 2;
|
|
129
|
+
readonly MutableContract: 3;
|
|
90
130
|
};
|
|
91
131
|
|
|
92
|
-
/** Union of valid AccountType
|
|
93
|
-
export type AccountTypeValue =
|
|
94
|
-
| "MutableWallet"
|
|
95
|
-
| "ImmutableWallet"
|
|
96
|
-
| "FungibleFaucet";
|
|
132
|
+
/** Union of valid AccountType numeric values. */
|
|
133
|
+
export type AccountTypeValue = 0 | 1 | 2 | 3;
|
|
97
134
|
|
|
98
135
|
// ════════════════════════════════════════════════════════════════
|
|
99
136
|
// Client options
|
|
100
137
|
// ════════════════════════════════════════════════════════════════
|
|
101
138
|
|
|
102
139
|
export interface ClientOptions {
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
140
|
+
/**
|
|
141
|
+
* RPC endpoint. Accepts shorthands or a raw URL:
|
|
142
|
+
* - `"testnet"` — Miden testnet RPC (`https://rpc.testnet.miden.io`)
|
|
143
|
+
* - `"devnet"` — Miden devnet RPC (`https://rpc.devnet.miden.io`)
|
|
144
|
+
* - `"localhost"` / `"local"` — local node (`http://localhost:57291`)
|
|
145
|
+
* - any other string — treated as a raw RPC endpoint URL
|
|
146
|
+
* Defaults to the SDK testnet RPC if omitted.
|
|
147
|
+
*/
|
|
148
|
+
rpcUrl?: "testnet" | "devnet" | "localhost" | "local" | (string & {});
|
|
149
|
+
/**
|
|
150
|
+
* Note transport endpoint. Accepts shorthands or a raw URL:
|
|
151
|
+
* - `"testnet"` — Miden testnet transport (`https://transport.miden.io`)
|
|
152
|
+
* - `"devnet"` — Miden devnet transport (`https://transport.devnet.miden.io`)
|
|
153
|
+
* - any other string — treated as a raw note transport endpoint URL
|
|
154
|
+
*/
|
|
155
|
+
noteTransportUrl?: "testnet" | "devnet" | (string & {});
|
|
156
|
+
/**
|
|
157
|
+
* Prover to use for transactions. Accepts shorthands or a raw URL:
|
|
158
|
+
* - `"local"` — local (in-browser) prover
|
|
159
|
+
* - `"devnet"` — Miden devnet remote prover
|
|
160
|
+
* - `"testnet"` — Miden testnet remote prover
|
|
161
|
+
* - any other string — treated as a raw remote prover URL
|
|
162
|
+
*/
|
|
163
|
+
proverUrl?: "local" | "devnet" | "testnet" | (string & {});
|
|
109
164
|
/** Hashed to 32 bytes via SHA-256. */
|
|
110
165
|
seed?: string | Uint8Array;
|
|
111
166
|
/** Store isolation key. */
|
|
@@ -138,8 +193,6 @@ export interface Asset {
|
|
|
138
193
|
amount: number | bigint;
|
|
139
194
|
}
|
|
140
195
|
|
|
141
|
-
export type NoteVisibility = "public" | "private";
|
|
142
|
-
|
|
143
196
|
/**
|
|
144
197
|
* A note reference: hex note ID string, NoteId object, InputNoteRecord, or Note object.
|
|
145
198
|
*/
|
|
@@ -149,26 +202,43 @@ export type NoteInput = string | NoteId | Note | InputNoteRecord;
|
|
|
149
202
|
// Account types
|
|
150
203
|
// ════════════════════════════════════════════════════════════════
|
|
151
204
|
|
|
152
|
-
/** Create a wallet
|
|
153
|
-
export type CreateAccountOptions =
|
|
205
|
+
/** Create a wallet, faucet, or contract. Discriminated by `type` field. */
|
|
206
|
+
export type CreateAccountOptions =
|
|
207
|
+
| WalletCreateOptions
|
|
208
|
+
| FaucetCreateOptions
|
|
209
|
+
| ContractCreateOptions;
|
|
154
210
|
|
|
155
211
|
export interface WalletCreateOptions {
|
|
156
|
-
/** Account type. Defaults to
|
|
157
|
-
type?:
|
|
158
|
-
storage?:
|
|
212
|
+
/** Account type. Defaults to `AccountType.MutableWallet`. */
|
|
213
|
+
type?: AccountTypeValue;
|
|
214
|
+
storage?: StorageMode;
|
|
159
215
|
auth?: AuthSchemeType;
|
|
160
216
|
seed?: string | Uint8Array;
|
|
161
217
|
}
|
|
162
218
|
|
|
163
219
|
export interface FaucetCreateOptions {
|
|
164
|
-
|
|
220
|
+
/** Use `AccountType.FungibleFaucet` or `AccountType.NonFungibleFaucet`. */
|
|
221
|
+
type: AccountTypeValue;
|
|
165
222
|
symbol: string;
|
|
166
223
|
decimals: number;
|
|
167
224
|
maxSupply: number | bigint;
|
|
168
|
-
storage?:
|
|
225
|
+
storage?: StorageMode;
|
|
169
226
|
auth?: AuthSchemeType;
|
|
170
227
|
}
|
|
171
228
|
|
|
229
|
+
export interface ContractCreateOptions {
|
|
230
|
+
/** Use `AccountType.ImmutableContract` or `AccountType.MutableContract`. */
|
|
231
|
+
type?: AccountTypeValue;
|
|
232
|
+
/** Raw 32-byte seed (Uint8Array). Required. */
|
|
233
|
+
seed: Uint8Array;
|
|
234
|
+
/** Auth secret key. Required. */
|
|
235
|
+
auth: AuthSecretKey;
|
|
236
|
+
/** Pre-compiled AccountComponent instances. Required for contracts. */
|
|
237
|
+
components: AccountComponent[];
|
|
238
|
+
/** Storage mode. Defaults to "public" for contracts. */
|
|
239
|
+
storage?: StorageMode;
|
|
240
|
+
}
|
|
241
|
+
|
|
172
242
|
export interface AccountDetails {
|
|
173
243
|
account: Account;
|
|
174
244
|
vault: AssetVault;
|
|
@@ -180,20 +250,27 @@ export interface AccountDetails {
|
|
|
180
250
|
/**
|
|
181
251
|
* Discriminated union for account import.
|
|
182
252
|
*
|
|
183
|
-
* - `
|
|
253
|
+
* - `AccountRef` (string, AccountId, Account, AccountHeader) — Import a public account by ID (fetches state from the network).
|
|
184
254
|
* - `{ file: AccountFile }` — Import from a previously exported account file (works for both public and private accounts).
|
|
185
255
|
* - `{ seed, type?, auth? }` — Reconstruct a **public** account from its init seed. **Does not work for private accounts** — use the account file workflow instead.
|
|
186
256
|
*/
|
|
187
257
|
export type ImportAccountInput =
|
|
188
|
-
|
|
|
258
|
+
| AccountRef
|
|
189
259
|
| { file: AccountFile }
|
|
190
260
|
| {
|
|
191
261
|
seed: Uint8Array;
|
|
192
|
-
/** Account type. Defaults to
|
|
193
|
-
type?:
|
|
262
|
+
/** Account type. Defaults to `AccountType.MutableWallet`. */
|
|
263
|
+
type?: AccountTypeValue;
|
|
194
264
|
auth?: AuthSchemeType;
|
|
195
265
|
};
|
|
196
266
|
|
|
267
|
+
export interface InsertAccountOptions {
|
|
268
|
+
/** The pre-built account to insert. */
|
|
269
|
+
account: Account;
|
|
270
|
+
/** Whether to overwrite an existing account with the same ID. Defaults to `false`. */
|
|
271
|
+
overwrite?: boolean;
|
|
272
|
+
}
|
|
273
|
+
|
|
197
274
|
/** Options for accounts.export(). Exists for forward-compatible extensibility. */
|
|
198
275
|
export interface ExportAccountOptions {}
|
|
199
276
|
|
|
@@ -213,23 +290,51 @@ export interface TransactionOptions {
|
|
|
213
290
|
prover?: TransactionProver;
|
|
214
291
|
}
|
|
215
292
|
|
|
216
|
-
export interface
|
|
293
|
+
export interface SendOptionsDefault extends TransactionOptions {
|
|
217
294
|
account: AccountRef;
|
|
218
295
|
to: AccountRef;
|
|
219
296
|
token: AccountRef;
|
|
220
297
|
amount: number | bigint;
|
|
221
298
|
type?: NoteVisibility;
|
|
299
|
+
returnNote?: false;
|
|
222
300
|
/** Block height after which the sender can reclaim the note. This is a block number, not wall-clock time. */
|
|
223
301
|
reclaimAfter?: number;
|
|
224
302
|
/** Block height until which the note is timelocked. This is a block number, not wall-clock time. */
|
|
225
303
|
timelockUntil?: number;
|
|
226
304
|
}
|
|
227
305
|
|
|
306
|
+
export interface SendOptionsReturnNote extends TransactionOptions {
|
|
307
|
+
account: AccountRef;
|
|
308
|
+
to: AccountRef;
|
|
309
|
+
token: AccountRef;
|
|
310
|
+
amount: number | bigint;
|
|
311
|
+
type?: NoteVisibility;
|
|
312
|
+
returnNote: true;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** @deprecated Use SendOptionsDefault or SendOptionsReturnNote instead */
|
|
316
|
+
export type SendOptions = SendOptionsDefault | SendOptionsReturnNote;
|
|
317
|
+
|
|
318
|
+
export interface SendResult {
|
|
319
|
+
txId: TransactionId;
|
|
320
|
+
note: Note | null;
|
|
321
|
+
result: TransactionResult;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** Result of methods that previously returned bare TransactionId. */
|
|
325
|
+
export interface TransactionSubmitResult {
|
|
326
|
+
txId: TransactionId;
|
|
327
|
+
result: TransactionResult;
|
|
328
|
+
}
|
|
329
|
+
|
|
228
330
|
export interface MintOptions extends TransactionOptions {
|
|
229
331
|
/** Faucet (executing account). */
|
|
230
332
|
account: AccountRef;
|
|
333
|
+
/** Recipient account. */
|
|
231
334
|
to: AccountRef;
|
|
335
|
+
/** Amount to mint. */
|
|
232
336
|
amount: number | bigint;
|
|
337
|
+
/** Note visibility. Defaults to "public". */
|
|
233
338
|
type?: NoteVisibility;
|
|
234
339
|
}
|
|
235
340
|
|
|
@@ -251,6 +356,32 @@ export interface SwapOptions extends TransactionOptions {
|
|
|
251
356
|
paybackType?: NoteVisibility;
|
|
252
357
|
}
|
|
253
358
|
|
|
359
|
+
export interface ExecuteOptions extends TransactionOptions {
|
|
360
|
+
/** Account executing the custom script. */
|
|
361
|
+
account: AccountRef;
|
|
362
|
+
/** Compiled TransactionScript. */
|
|
363
|
+
script: TransactionScript;
|
|
364
|
+
/** Foreign accounts referenced by the script. */
|
|
365
|
+
foreignAccounts?: (
|
|
366
|
+
| AccountRef
|
|
367
|
+
| { id: AccountRef; storage?: AccountStorageRequirements }
|
|
368
|
+
)[];
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export interface ExecuteProgramOptions {
|
|
372
|
+
/** Account to execute the program against. */
|
|
373
|
+
account: AccountRef;
|
|
374
|
+
/** Compiled TransactionScript to execute. */
|
|
375
|
+
script: TransactionScript;
|
|
376
|
+
/** Advice inputs for the execution. Defaults to empty. */
|
|
377
|
+
adviceInputs?: AdviceInputs;
|
|
378
|
+
/** Foreign accounts referenced by the script. */
|
|
379
|
+
foreignAccounts?: (
|
|
380
|
+
| AccountRef
|
|
381
|
+
| { id: AccountRef; storage?: AccountStorageRequirements }
|
|
382
|
+
)[];
|
|
383
|
+
}
|
|
384
|
+
|
|
254
385
|
export interface PreviewSendOptions {
|
|
255
386
|
operation: "send";
|
|
256
387
|
account: AccountRef;
|
|
@@ -307,6 +438,7 @@ export interface ConsumeAllResult {
|
|
|
307
438
|
txId: TransactionId | null;
|
|
308
439
|
consumed: number;
|
|
309
440
|
remaining: number;
|
|
441
|
+
result?: TransactionResult;
|
|
310
442
|
}
|
|
311
443
|
|
|
312
444
|
/**
|
|
@@ -315,7 +447,7 @@ export interface ConsumeAllResult {
|
|
|
315
447
|
*/
|
|
316
448
|
export type TransactionQuery =
|
|
317
449
|
| { status: "uncommitted" }
|
|
318
|
-
| { ids: string[] }
|
|
450
|
+
| { ids: (string | TransactionId)[] }
|
|
319
451
|
| { expiredBefore: number };
|
|
320
452
|
|
|
321
453
|
// ════════════════════════════════════════════════════════════════
|
|
@@ -332,7 +464,7 @@ export type NoteQuery =
|
|
|
332
464
|
| "processing"
|
|
333
465
|
| "unverified";
|
|
334
466
|
}
|
|
335
|
-
| { ids: string[] };
|
|
467
|
+
| { ids: (string | NoteId)[] };
|
|
336
468
|
|
|
337
469
|
/** Options for standalone note creation utilities. */
|
|
338
470
|
export interface NoteOptions {
|
|
@@ -358,7 +490,7 @@ export interface FetchPrivateNotesOptions {
|
|
|
358
490
|
}
|
|
359
491
|
|
|
360
492
|
export interface SendPrivateOptions {
|
|
361
|
-
|
|
493
|
+
note: NoteInput;
|
|
362
494
|
to: AccountRef;
|
|
363
495
|
}
|
|
364
496
|
|
|
@@ -389,76 +521,341 @@ export interface BuildSwapTagOptions {
|
|
|
389
521
|
// ════════════════════════════════════════════════════════════════
|
|
390
522
|
|
|
391
523
|
export interface AccountsResource {
|
|
524
|
+
/**
|
|
525
|
+
* Create a new wallet, faucet, or contract account. Defaults to a mutable
|
|
526
|
+
* wallet if no options are provided.
|
|
527
|
+
*
|
|
528
|
+
* @param options - Account creation options discriminated by `type` field.
|
|
529
|
+
*/
|
|
392
530
|
create(options?: CreateAccountOptions): Promise<Account>;
|
|
531
|
+
/**
|
|
532
|
+
* Insert a pre-built account into the local store. Useful for external signer
|
|
533
|
+
* integrations that construct accounts via `AccountBuilder` with custom auth commitments.
|
|
534
|
+
*
|
|
535
|
+
* @param options - Insert options.
|
|
536
|
+
*/
|
|
537
|
+
insert(options: InsertAccountOptions): Promise<void>;
|
|
538
|
+
/**
|
|
539
|
+
* Retrieve an account by ID. Returns `null` if not found in the local store.
|
|
540
|
+
*
|
|
541
|
+
* @param accountId - The account to retrieve.
|
|
542
|
+
*/
|
|
393
543
|
get(accountId: AccountRef): Promise<Account | null>;
|
|
544
|
+
/**
|
|
545
|
+
* Retrieve an account locally, or import it from the network if not found.
|
|
546
|
+
*
|
|
547
|
+
* @param accountId - The account to retrieve or import.
|
|
548
|
+
*/
|
|
549
|
+
getOrImport(accountId: AccountRef): Promise<Account>;
|
|
550
|
+
/**
|
|
551
|
+
* List all accounts in the local store.
|
|
552
|
+
*/
|
|
394
553
|
list(): Promise<AccountHeader[]>;
|
|
554
|
+
/**
|
|
555
|
+
* Retrieve detailed account information including vault, storage, code, and keys.
|
|
556
|
+
*
|
|
557
|
+
* @param accountId - The account to retrieve details for.
|
|
558
|
+
*/
|
|
395
559
|
getDetails(accountId: AccountRef): Promise<AccountDetails>;
|
|
560
|
+
/**
|
|
561
|
+
* Get the balance of a specific token for an account.
|
|
562
|
+
*
|
|
563
|
+
* @param accountId - The account to check.
|
|
564
|
+
* @param tokenId - The faucet account that identifies the token.
|
|
565
|
+
*/
|
|
396
566
|
getBalance(accountId: AccountRef, tokenId: AccountRef): Promise<bigint>;
|
|
397
567
|
|
|
568
|
+
/**
|
|
569
|
+
* Import an account from the network by ID, from an exported file, or
|
|
570
|
+
* reconstruct from a seed.
|
|
571
|
+
*
|
|
572
|
+
* @param input - Account reference, file, or seed-based import options.
|
|
573
|
+
*/
|
|
398
574
|
import(input: ImportAccountInput): Promise<Account>;
|
|
575
|
+
/**
|
|
576
|
+
* Export an account to an {@link AccountFile} for backup or transfer.
|
|
577
|
+
*
|
|
578
|
+
* @param accountId - The account to export.
|
|
579
|
+
* @param options - Export options (reserved for future use).
|
|
580
|
+
*/
|
|
399
581
|
export(
|
|
400
582
|
accountId: AccountRef,
|
|
401
583
|
options?: ExportAccountOptions
|
|
402
584
|
): Promise<AccountFile>;
|
|
403
585
|
|
|
586
|
+
/**
|
|
587
|
+
* Associate a Bech32 address with an account.
|
|
588
|
+
*
|
|
589
|
+
* @param accountId - The account to add the address to.
|
|
590
|
+
* @param address - The Bech32 address string.
|
|
591
|
+
*/
|
|
404
592
|
addAddress(accountId: AccountRef, address: string): Promise<void>;
|
|
593
|
+
/**
|
|
594
|
+
* Remove a Bech32 address from an account.
|
|
595
|
+
*
|
|
596
|
+
* @param accountId - The account to remove the address from.
|
|
597
|
+
* @param address - The Bech32 address string to remove.
|
|
598
|
+
*/
|
|
405
599
|
removeAddress(accountId: AccountRef, address: string): Promise<void>;
|
|
406
600
|
}
|
|
407
601
|
|
|
408
602
|
export interface TransactionsResource {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
603
|
+
/**
|
|
604
|
+
* Send tokens to another account by creating a pay-to-ID note. Set
|
|
605
|
+
* `returnNote: true` to get the created note back.
|
|
606
|
+
*
|
|
607
|
+
* @param options - Send options including sender, recipient, token, and amount.
|
|
608
|
+
*/
|
|
609
|
+
send(
|
|
610
|
+
options: SendOptionsDefault
|
|
611
|
+
): Promise<{ txId: TransactionId; note: null; result: TransactionResult }>;
|
|
612
|
+
send(
|
|
613
|
+
options: SendOptionsReturnNote
|
|
614
|
+
): Promise<{ txId: TransactionId; note: Note; result: TransactionResult }>;
|
|
615
|
+
send(options: SendOptions): Promise<SendResult>;
|
|
616
|
+
/**
|
|
617
|
+
* Mint new tokens from a faucet account.
|
|
618
|
+
*
|
|
619
|
+
* @param options - Mint options including the faucet, recipient, and amount.
|
|
620
|
+
*/
|
|
621
|
+
mint(options: MintOptions): Promise<TransactionSubmitResult>;
|
|
622
|
+
/**
|
|
623
|
+
* Consume one or more notes for an account.
|
|
624
|
+
*
|
|
625
|
+
* @param options - Consume options including the account and notes to consume.
|
|
626
|
+
*/
|
|
627
|
+
consume(options: ConsumeOptions): Promise<TransactionSubmitResult>;
|
|
628
|
+
/**
|
|
629
|
+
* Execute an atomic swap between two assets.
|
|
630
|
+
*
|
|
631
|
+
* @param options - Swap options including the account, offered asset, and requested asset.
|
|
632
|
+
*/
|
|
633
|
+
swap(options: SwapOptions): Promise<TransactionSubmitResult>;
|
|
634
|
+
/**
|
|
635
|
+
* Consume all available notes for an account, up to an optional limit.
|
|
636
|
+
* Returns the count of remaining notes for pagination.
|
|
637
|
+
*
|
|
638
|
+
* @param options - Options including the account and optional max notes limit.
|
|
639
|
+
*/
|
|
413
640
|
consumeAll(options: ConsumeAllOptions): Promise<ConsumeAllResult>;
|
|
641
|
+
/**
|
|
642
|
+
* Execute a custom transaction script with optional foreign account references.
|
|
643
|
+
*
|
|
644
|
+
* @param options - Execute options including the account, compiled script, and foreign accounts.
|
|
645
|
+
*/
|
|
646
|
+
execute(options: ExecuteOptions): Promise<TransactionSubmitResult>;
|
|
414
647
|
|
|
648
|
+
/**
|
|
649
|
+
* Dry-run a transaction to preview its effects without submitting it to
|
|
650
|
+
* the network.
|
|
651
|
+
*
|
|
652
|
+
* @param options - Preview options discriminated by `operation` field.
|
|
653
|
+
*/
|
|
415
654
|
preview(options: PreviewOptions): Promise<TransactionSummary>;
|
|
416
655
|
|
|
417
656
|
/**
|
|
418
|
-
* Submit a pre-built TransactionRequest.
|
|
419
|
-
*
|
|
657
|
+
* Submit a pre-built TransactionRequest. Note: WASM requires accountId
|
|
658
|
+
* separately, so `account` is the first argument.
|
|
659
|
+
*
|
|
660
|
+
* @param account - The account executing the transaction.
|
|
661
|
+
* @param request - The pre-built transaction request.
|
|
662
|
+
* @param options - Optional transaction options (prover, confirmation).
|
|
420
663
|
*/
|
|
421
664
|
submit(
|
|
422
665
|
account: AccountRef,
|
|
423
666
|
request: TransactionRequest,
|
|
424
667
|
options?: TransactionOptions
|
|
425
|
-
): Promise<
|
|
668
|
+
): Promise<TransactionSubmitResult>;
|
|
669
|
+
|
|
670
|
+
/** Execute a program (view call) and return the resulting stack output. */
|
|
671
|
+
executeProgram(options: ExecuteProgramOptions): Promise<FeltArray>;
|
|
426
672
|
|
|
673
|
+
/**
|
|
674
|
+
* List transactions, optionally filtered by status, IDs, or expiration.
|
|
675
|
+
*
|
|
676
|
+
* @param query - Optional filter for transaction status, IDs, or expiration.
|
|
677
|
+
*/
|
|
427
678
|
list(query?: TransactionQuery): Promise<TransactionRecord[]>;
|
|
428
679
|
|
|
429
|
-
|
|
680
|
+
/**
|
|
681
|
+
* Poll until a transaction is confirmed on-chain. Throws on rejection
|
|
682
|
+
* or timeout.
|
|
683
|
+
*
|
|
684
|
+
* @param txId - The transaction ID to wait for.
|
|
685
|
+
* @param options - Optional polling timeout, interval, and progress callback.
|
|
686
|
+
*/
|
|
687
|
+
waitFor(txId: string | TransactionId, options?: WaitOptions): Promise<void>;
|
|
430
688
|
}
|
|
431
689
|
|
|
432
690
|
export interface NotesResource {
|
|
691
|
+
/**
|
|
692
|
+
* List received (input) notes, optionally filtered by status or IDs.
|
|
693
|
+
*
|
|
694
|
+
* @param query - Optional filter by note status or note IDs.
|
|
695
|
+
*/
|
|
433
696
|
list(query?: NoteQuery): Promise<InputNoteRecord[]>;
|
|
434
|
-
|
|
697
|
+
/**
|
|
698
|
+
* Retrieve a note by ID. Returns `null` if not found.
|
|
699
|
+
*
|
|
700
|
+
* @param noteId - The note to retrieve.
|
|
701
|
+
*/
|
|
702
|
+
get(noteId: NoteInput): Promise<InputNoteRecord | null>;
|
|
435
703
|
|
|
704
|
+
/**
|
|
705
|
+
* List sent (output) notes, optionally filtered by status or IDs.
|
|
706
|
+
*
|
|
707
|
+
* @param query - Optional filter by note status or note IDs.
|
|
708
|
+
*/
|
|
436
709
|
listSent(query?: NoteQuery): Promise<OutputNoteRecord[]>;
|
|
437
710
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
711
|
+
/**
|
|
712
|
+
* List notes that are available for consumption by a specific account.
|
|
713
|
+
*
|
|
714
|
+
* @param options - Options containing the account to check availability for.
|
|
715
|
+
*/
|
|
716
|
+
listAvailable(options: { account: AccountRef }): Promise<InputNoteRecord[]>;
|
|
441
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Import a note from a {@link NoteFile}.
|
|
720
|
+
*
|
|
721
|
+
* @param noteFile - The note file to import.
|
|
722
|
+
*/
|
|
442
723
|
import(noteFile: NoteFile): Promise<NoteId>;
|
|
443
|
-
|
|
724
|
+
/**
|
|
725
|
+
* Export a note to a {@link NoteFile} for transfer or backup.
|
|
726
|
+
*
|
|
727
|
+
* @param noteId - The note to export.
|
|
728
|
+
* @param options - Optional export format options.
|
|
729
|
+
*/
|
|
730
|
+
export(noteId: NoteInput, options?: ExportNoteOptions): Promise<NoteFile>;
|
|
444
731
|
|
|
732
|
+
/**
|
|
733
|
+
* Fetch private notes from the note transport service.
|
|
734
|
+
*
|
|
735
|
+
* @param options - Optional fetch mode: `"incremental"` (default) or `"all"`.
|
|
736
|
+
*/
|
|
445
737
|
fetchPrivate(options?: FetchPrivateNotesOptions): Promise<void>;
|
|
738
|
+
/**
|
|
739
|
+
* Send a private note to a recipient via the note transport service.
|
|
740
|
+
*
|
|
741
|
+
* @param options - Options including the note and the recipient.
|
|
742
|
+
*/
|
|
446
743
|
sendPrivate(options: SendPrivateOptions): Promise<void>;
|
|
447
744
|
}
|
|
448
745
|
|
|
746
|
+
// ════════════════════════════════════════════════════════════════
|
|
747
|
+
// Compiler types
|
|
748
|
+
// ════════════════════════════════════════════════════════════════
|
|
749
|
+
|
|
750
|
+
export interface CompileComponentOptions {
|
|
751
|
+
/** MASM source code for the component. */
|
|
752
|
+
code: string;
|
|
753
|
+
/** Initial storage slots for the component. */
|
|
754
|
+
slots?: StorageSlot[];
|
|
755
|
+
/**
|
|
756
|
+
* When true, the component accepts all input types for Falcon-signed
|
|
757
|
+
* transactions by automatically adding `exec.auth::auth_tx_rpo_falcon512`
|
|
758
|
+
* to a library context. Default: true.
|
|
759
|
+
*
|
|
760
|
+
* **BREAKING (v0.12):** This flag was added in v0.12 and defaults to `true`.
|
|
761
|
+
* Set to `false` if you compile a component that already includes its own
|
|
762
|
+
* auth transaction kernel invocation or intentionally omits one.
|
|
763
|
+
*/
|
|
764
|
+
supportAllTypes?: boolean;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
export interface CompileTxScriptLibrary {
|
|
768
|
+
/** MASM namespace for the library (e.g. "counter::module"). */
|
|
769
|
+
namespace: string;
|
|
770
|
+
/** MASM source code for the library. */
|
|
771
|
+
code: string;
|
|
772
|
+
/**
|
|
773
|
+
* `"dynamic"` (default) — procedures are linked via DYNCALL at runtime.
|
|
774
|
+
* `"static"` — procedures are inlined at compile time.
|
|
775
|
+
*/
|
|
776
|
+
linking?: "dynamic" | "static";
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
export interface CompileTxScriptOptions {
|
|
780
|
+
/** MASM source code for the transaction script. */
|
|
781
|
+
code: string;
|
|
782
|
+
/** Component libraries to link. */
|
|
783
|
+
libraries?: CompileTxScriptLibrary[];
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export interface CompilerResource {
|
|
787
|
+
/**
|
|
788
|
+
* Compile MASM source into an AccountComponent.
|
|
789
|
+
*
|
|
790
|
+
* @param options - Component source code, storage slots, and auth options.
|
|
791
|
+
*/
|
|
792
|
+
component(options: CompileComponentOptions): Promise<AccountComponent>;
|
|
793
|
+
/**
|
|
794
|
+
* Compile MASM source into a TransactionScript.
|
|
795
|
+
*
|
|
796
|
+
* @param options - Script source code and optional libraries to link.
|
|
797
|
+
*/
|
|
798
|
+
txScript(options: CompileTxScriptOptions): Promise<TransactionScript>;
|
|
799
|
+
}
|
|
800
|
+
|
|
449
801
|
export interface TagsResource {
|
|
802
|
+
/**
|
|
803
|
+
* Add a note tag to listen for during sync.
|
|
804
|
+
*
|
|
805
|
+
* @param tag - The numeric note tag to register.
|
|
806
|
+
*/
|
|
450
807
|
add(tag: number): Promise<void>;
|
|
808
|
+
/**
|
|
809
|
+
* Remove a note tag so it is no longer tracked during sync.
|
|
810
|
+
*
|
|
811
|
+
* @param tag - The numeric note tag to unregister.
|
|
812
|
+
*/
|
|
451
813
|
remove(tag: number): Promise<void>;
|
|
814
|
+
/**
|
|
815
|
+
* List all registered note tags.
|
|
816
|
+
*/
|
|
452
817
|
list(): Promise<number[]>;
|
|
453
818
|
}
|
|
454
819
|
|
|
455
820
|
export interface SettingsResource {
|
|
821
|
+
/**
|
|
822
|
+
* Get a setting value by key. Returns `null` if not found.
|
|
823
|
+
*
|
|
824
|
+
* @param key - The setting key.
|
|
825
|
+
*/
|
|
456
826
|
get<T = unknown>(key: string): Promise<T | null>;
|
|
827
|
+
/**
|
|
828
|
+
* Set a setting value.
|
|
829
|
+
*
|
|
830
|
+
* @param key - The setting key.
|
|
831
|
+
* @param value - The value to store.
|
|
832
|
+
*/
|
|
457
833
|
set(key: string, value: unknown): Promise<void>;
|
|
834
|
+
/**
|
|
835
|
+
* Remove a setting.
|
|
836
|
+
*
|
|
837
|
+
* @param key - The setting key to remove.
|
|
838
|
+
*/
|
|
458
839
|
remove(key: string): Promise<void>;
|
|
840
|
+
/**
|
|
841
|
+
* List all setting keys.
|
|
842
|
+
*/
|
|
459
843
|
listKeys(): Promise<string[]>;
|
|
460
844
|
}
|
|
461
845
|
|
|
846
|
+
export interface KeystoreResource {
|
|
847
|
+
/** Inserts a secret key into the keystore, associating it with the given account ID. */
|
|
848
|
+
insert(accountId: AccountId, secretKey: AuthSecretKey): Promise<void>;
|
|
849
|
+
/** Retrieves a secret key by its public key commitment. Returns null if not found. */
|
|
850
|
+
get(pubKeyCommitment: Word): Promise<AuthSecretKey | null>;
|
|
851
|
+
/** Removes a key from the keystore by its public key commitment. */
|
|
852
|
+
remove(pubKeyCommitment: Word): Promise<void>;
|
|
853
|
+
/** Returns all public key commitments associated with the given account ID. */
|
|
854
|
+
getCommitments(accountId: AccountId): Promise<Word[]>;
|
|
855
|
+
/** Returns the account ID associated with a public key commitment, or null if not found. */
|
|
856
|
+
getAccountId(pubKeyCommitment: Word): Promise<AccountId | null>;
|
|
857
|
+
}
|
|
858
|
+
|
|
462
859
|
// ════════════════════════════════════════════════════════════════
|
|
463
860
|
// MidenClient
|
|
464
861
|
// ════════════════════════════════════════════════════════════════
|
|
@@ -466,8 +863,10 @@ export interface SettingsResource {
|
|
|
466
863
|
export declare class MidenClient {
|
|
467
864
|
/** Creates and initializes a new MidenClient. */
|
|
468
865
|
static create(options?: ClientOptions): Promise<MidenClient>;
|
|
469
|
-
/** Creates a client preconfigured for testnet
|
|
866
|
+
/** Creates a client preconfigured for testnet (rpc, prover, note transport, autoSync). */
|
|
470
867
|
static createTestnet(options?: ClientOptions): Promise<MidenClient>;
|
|
868
|
+
/** Creates a client preconfigured for devnet (rpc, prover, note transport, autoSync). */
|
|
869
|
+
static createDevnet(options?: ClientOptions): Promise<MidenClient>;
|
|
471
870
|
/** Creates a mock client for testing. */
|
|
472
871
|
static createMock(options?: MockOptions): Promise<MidenClient>;
|
|
473
872
|
|
|
@@ -476,6 +875,8 @@ export declare class MidenClient {
|
|
|
476
875
|
readonly notes: NotesResource;
|
|
477
876
|
readonly tags: TagsResource;
|
|
478
877
|
readonly settings: SettingsResource;
|
|
878
|
+
readonly compile: CompilerResource;
|
|
879
|
+
readonly keystore: KeystoreResource;
|
|
479
880
|
|
|
480
881
|
/** Syncs the client state with the Miden node. */
|
|
481
882
|
sync(options?: { timeout?: number }): Promise<SyncSummary>;
|
|
@@ -486,10 +887,8 @@ export declare class MidenClient {
|
|
|
486
887
|
/** Terminates the underlying Web Worker. After this, all method calls throw. */
|
|
487
888
|
terminate(): void;
|
|
488
889
|
|
|
489
|
-
/**
|
|
490
|
-
|
|
491
|
-
/** Imports a previously exported store snapshot. */
|
|
492
|
-
importStore(snapshot: StoreSnapshot): Promise<void>;
|
|
890
|
+
/** Returns the identifier of the underlying store (e.g. IndexedDB database name, file path). */
|
|
891
|
+
storeIdentifier(): string;
|
|
493
892
|
|
|
494
893
|
/** Advances the mock chain by one block. Only available on mock clients. */
|
|
495
894
|
proveBlock(): void;
|
|
@@ -517,5 +916,14 @@ export declare function createP2IDENote(options: P2IDEOptions): OutputNote;
|
|
|
517
916
|
/** Builds a swap tag for note matching. Returns a NoteTag (use `.asU32()` for the numeric value). */
|
|
518
917
|
export declare function buildSwapTag(options: BuildSwapTagOptions): NoteTag;
|
|
519
918
|
|
|
919
|
+
/** Exports the entire contents of an IndexedDB store as a JSON string. */
|
|
920
|
+
export declare function exportStore(storeName: string): Promise<string>;
|
|
921
|
+
|
|
922
|
+
/** Imports store contents from a JSON string, replacing all existing data. */
|
|
923
|
+
export declare function importStore(
|
|
924
|
+
storeName: string,
|
|
925
|
+
storeDump: string
|
|
926
|
+
): Promise<void>;
|
|
927
|
+
|
|
520
928
|
/** Returns the initialized WASM module. Throws if WASM is unavailable. */
|
|
521
929
|
export declare function getWasmOrThrow(): Promise<typeof WasmExports>;
|