@miden-sdk/react 0.14.0-alpha → 0.14.1

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.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ReactNode } from 'react';
4
- import { AccountStorageMode, AccountComponent, Account, AccountHeader, AuthScheme, AccountId, TransactionRequest, WasmWebClient, AccountFile, InputNoteRecord, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, NoteAttachment } from '@miden-sdk/miden-sdk';
5
- export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
4
+ import { AccountId, Account, AccountHeader, AccountStorageMode, AccountComponent, NoteId, InputNoteRecord, Note, StorageMode, AuthScheme, TransactionScript, AdviceInputs, AccountStorageRequirements, TransactionRequest, WasmWebClient, AccountFile, NoteVisibility, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, NoteAttachment } from '@miden-sdk/miden-sdk';
5
+ export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, Note, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
6
6
 
7
7
  declare module "@miden-sdk/miden-sdk" {
8
8
  interface Account {
@@ -11,6 +11,9 @@ declare module "@miden-sdk/miden-sdk" {
11
11
  }
12
12
  }
13
13
 
14
+ /** Account reference — any account ID form accepted by the React SDK hooks. */
15
+ type AccountRef = string | AccountId | Account | AccountHeader;
16
+
14
17
  /**
15
18
  * Sign callback for WebClient.createClientWithExternalKeystore.
16
19
  * Called when a transaction needs to be signed.
@@ -20,6 +23,22 @@ declare module "@miden-sdk/miden-sdk" {
20
23
  * @returns Promise resolving to the signature bytes
21
24
  */
22
25
  type SignCallback = (pubKey: Uint8Array, signingInputs: Uint8Array) => Promise<Uint8Array>;
26
+ /**
27
+ * Get-key callback for WebClient.createClientWithExternalKeystore.
28
+ * Called to retrieve a secret key by its public key commitment.
29
+ *
30
+ * @param pubKey - Public key commitment bytes
31
+ * @returns Promise resolving to the secret key bytes
32
+ */
33
+ type GetKeyCallback = (pubKey: Uint8Array) => Promise<Uint8Array>;
34
+ /**
35
+ * Insert-key callback for WebClient.createClientWithExternalKeystore.
36
+ * Called when the SDK needs to persist a newly-generated key pair.
37
+ *
38
+ * @param pubKey - Public key commitment bytes
39
+ * @param secretKey - Secret key bytes to store
40
+ */
41
+ type InsertKeyCallback = (pubKey: Uint8Array, secretKey: Uint8Array) => void;
23
42
  /**
24
43
  * Account type for signer accounts.
25
44
  * Matches the AccountType enum from the SDK.
@@ -40,6 +59,12 @@ interface SignerAccountConfig {
40
59
  accountSeed?: Uint8Array;
41
60
  /** Optional custom account components to include in the account (e.g. from a compiled .masp package) */
42
61
  customComponents?: AccountComponent[];
62
+ /**
63
+ * Optional existing account ID to import instead of building from scratch.
64
+ * When provided, skips AccountBuilder and imports the account by ID from the chain.
65
+ * Useful for wallets that create accounts externally (e.g., via a vault).
66
+ */
67
+ importAccountId?: string;
43
68
  }
44
69
  /**
45
70
  * Context value provided by signer providers (Para, Turnkey, MidenFi, etc.).
@@ -49,6 +74,10 @@ interface SignerAccountConfig {
49
74
  interface SignerContextValue {
50
75
  /** Sign callback for external keystore */
51
76
  signCb: SignCallback;
77
+ /** Optional get-key callback for external keystore (retrieves secret key by public key) */
78
+ getKeyCb?: GetKeyCallback;
79
+ /** Optional insert-key callback for external keystore (persists newly-generated key pair) */
80
+ insertKeyCb?: InsertKeyCallback;
52
81
  /** Account config for initialization (only valid when connected) */
53
82
  accountConfig: SignerAccountConfig;
54
83
  /** Store name suffix for IndexedDB isolation (e.g., "para_walletId") */
@@ -87,10 +116,21 @@ declare const SignerContext: react.Context<SignerContextValue | null>;
87
116
  declare function useSigner(): SignerContextValue | null;
88
117
 
89
118
  type RpcUrlConfig = string | "devnet" | "testnet" | "localhost" | "local";
90
- type ProverConfig = "local" | "devnet" | "testnet" | string | {
119
+ /** Single prover target a well-known name, custom URL, or object with URL + timeout. */
120
+ type ProverTarget = "local" | "localhost" | "devnet" | "testnet" | string | {
91
121
  url: string;
92
122
  timeoutMs?: number | bigint;
93
123
  };
124
+ type ProverConfig = ProverTarget | {
125
+ /** Primary prover to try first */
126
+ primary: ProverTarget;
127
+ /** Fallback prover if primary fails (e.g. "local") */
128
+ fallback?: ProverTarget;
129
+ /** Return true to skip the fallback (e.g. on mobile where local proving is too slow) */
130
+ disableFallback?: () => boolean;
131
+ /** Called when the primary prover fails and the fallback is used */
132
+ onFallback?: () => void;
133
+ };
94
134
  type ProverUrls = {
95
135
  devnet?: string;
96
136
  testnet?: string;
@@ -162,7 +202,7 @@ interface AssetBalance {
162
202
  }
163
203
  interface NotesFilter {
164
204
  status?: "all" | "consumed" | "committed" | "expected" | "processing";
165
- accountId?: string;
205
+ accountId?: AccountRef;
166
206
  /** Only notes from this sender (any format, normalized internally) */
167
207
  sender?: string;
168
208
  /** Exclude these note IDs */
@@ -216,7 +256,7 @@ interface NoteSummary {
216
256
  }
217
257
  interface CreateWalletOptions {
218
258
  /** Storage mode. Default: private */
219
- storageMode?: "private" | "public" | "network";
259
+ storageMode?: StorageMode;
220
260
  /** Whether code can be updated. Default: true */
221
261
  mutable?: boolean;
222
262
  /** Auth scheme. Default: AuthScheme.AuthRpoFalcon512 */
@@ -230,9 +270,9 @@ interface CreateFaucetOptions {
230
270
  /** Number of decimals. Default: 8 */
231
271
  decimals?: number;
232
272
  /** Maximum supply */
233
- maxSupply: bigint;
273
+ maxSupply: bigint | number;
234
274
  /** Storage mode. Default: private */
235
- storageMode?: "private" | "public" | "network";
275
+ storageMode?: StorageMode;
236
276
  /** Auth scheme. Default: AuthScheme.AuthRpoFalcon512 */
237
277
  authScheme?: AuthScheme;
238
278
  }
@@ -241,7 +281,7 @@ type ImportAccountOptions = {
241
281
  file: AccountFile | Uint8Array | ArrayBuffer;
242
282
  } | {
243
283
  type: "id";
244
- accountId: string | AccountId;
284
+ accountId: AccountRef;
245
285
  } | {
246
286
  type: "seed";
247
287
  seed: Uint8Array;
@@ -250,15 +290,15 @@ type ImportAccountOptions = {
250
290
  };
251
291
  interface SendOptions {
252
292
  /** Sender account ID */
253
- from: string;
293
+ from: AccountRef;
254
294
  /** Recipient account ID */
255
- to: string;
295
+ to: AccountRef;
256
296
  /** Asset ID to send (token id) */
257
- assetId: string;
297
+ assetId: AccountRef;
258
298
  /** Amount to send (ignored when sendAll is true) */
259
- amount?: bigint;
299
+ amount?: bigint | number;
260
300
  /** Note type. Default: private */
261
- noteType?: "private" | "public";
301
+ noteType?: NoteVisibility;
262
302
  /** Block height after which sender can reclaim note */
263
303
  recallHeight?: number;
264
304
  /** Block height after which recipient can consume note */
@@ -269,12 +309,18 @@ interface SendOptions {
269
309
  skipSync?: boolean;
270
310
  /** Send the full balance of this asset. When true, amount is ignored. */
271
311
  sendAll?: boolean;
312
+ /** true = build note in JS and return the Note object (e.g. for out-of-band delivery). Default: false */
313
+ returnNote?: boolean;
314
+ }
315
+ interface SendResult {
316
+ txId: string;
317
+ note: Note | null;
272
318
  }
273
319
  interface MultiSendRecipient {
274
320
  /** Recipient account ID */
275
- to: string;
321
+ to: AccountRef;
276
322
  /** Amount to send */
277
- amount: bigint;
323
+ amount: bigint | number;
278
324
  /** Per-recipient note type override */
279
325
  noteType?: "private" | "public";
280
326
  /** Per-recipient attachment */
@@ -282,45 +328,16 @@ interface MultiSendRecipient {
282
328
  }
283
329
  interface MultiSendOptions {
284
330
  /** Sender account ID */
285
- from: string;
331
+ from: AccountRef;
286
332
  /** Asset ID to send (token id) */
287
- assetId: string;
333
+ assetId: AccountRef;
288
334
  /** Recipient list */
289
335
  recipients: MultiSendRecipient[];
290
336
  /** Default note type for all recipients. Default: private */
291
- noteType?: "private" | "public";
337
+ noteType?: NoteVisibility;
292
338
  /** Skip auto-sync before send. Default: false */
293
339
  skipSync?: boolean;
294
340
  }
295
- interface InternalTransferOptions {
296
- /** Sender account ID */
297
- from: string;
298
- /** Recipient account ID */
299
- to: string;
300
- /** Asset ID to send (token id) */
301
- assetId: string;
302
- /** Amount to transfer */
303
- amount: bigint;
304
- /** Note type. Default: private */
305
- noteType?: "private" | "public";
306
- }
307
- interface InternalTransferChainOptions {
308
- /** Initial sender account ID */
309
- from: string;
310
- /** Ordered list of recipient account IDs */
311
- recipients: string[];
312
- /** Asset ID to send (token id) */
313
- assetId: string;
314
- /** Amount to transfer per hop */
315
- amount: bigint;
316
- /** Note type. Default: private */
317
- noteType?: "private" | "public";
318
- }
319
- interface InternalTransferResult {
320
- createTransactionId: string;
321
- consumeTransactionId: string;
322
- noteId: string;
323
- }
324
341
  interface WaitForCommitOptions {
325
342
  /** Timeout in milliseconds. Default: 10000 */
326
343
  timeoutMs?: number;
@@ -329,7 +346,7 @@ interface WaitForCommitOptions {
329
346
  }
330
347
  interface WaitForNotesOptions {
331
348
  /** Account ID to check for consumable notes */
332
- accountId: string;
349
+ accountId: AccountRef;
333
350
  /** Minimum number of notes to wait for. Default: 1 */
334
351
  minCount?: number;
335
352
  /** Timeout in milliseconds. Default: 10000 */
@@ -339,47 +356,72 @@ interface WaitForNotesOptions {
339
356
  }
340
357
  interface MintOptions {
341
358
  /** Target account to receive minted tokens */
342
- targetAccountId: string;
359
+ targetAccountId: AccountRef;
343
360
  /** Faucet account to mint from */
344
- faucetId: string;
361
+ faucetId: AccountRef;
345
362
  /** Amount to mint */
346
- amount: bigint;
363
+ amount: bigint | number;
347
364
  /** Note type. Default: private */
348
- noteType?: "private" | "public";
365
+ noteType?: NoteVisibility;
349
366
  }
350
367
  interface ConsumeOptions {
351
368
  /** Account ID that will consume the notes */
352
369
  accountId: string;
353
- /** List of note IDs to consume */
354
- noteIds: string[];
370
+ /** Notes to consume — accepts note IDs (hex strings), NoteId objects, InputNoteRecord, or Note objects */
371
+ notes: (string | NoteId | InputNoteRecord | Note)[];
355
372
  }
356
373
  interface SwapOptions {
357
374
  /** Account initiating the swap */
358
- accountId: string;
375
+ accountId: AccountRef;
359
376
  /** Faucet ID of the offered asset */
360
- offeredFaucetId: string;
377
+ offeredFaucetId: AccountRef;
361
378
  /** Amount being offered */
362
- offeredAmount: bigint;
379
+ offeredAmount: bigint | number;
363
380
  /** Faucet ID of the requested asset */
364
- requestedFaucetId: string;
381
+ requestedFaucetId: AccountRef;
365
382
  /** Amount being requested */
366
- requestedAmount: bigint;
383
+ requestedAmount: bigint | number;
367
384
  /** Note type for swap note. Default: private */
368
- noteType?: "private" | "public";
385
+ noteType?: NoteVisibility;
369
386
  /** Note type for payback note. Default: private */
370
- paybackNoteType?: "private" | "public";
387
+ paybackNoteType?: NoteVisibility;
371
388
  }
372
389
  interface ExecuteTransactionOptions {
373
390
  /** Account ID the transaction applies to */
374
- accountId: string | AccountId;
391
+ accountId: AccountRef;
375
392
  /** Transaction request or builder */
376
393
  request: TransactionRequest | ((client: WasmWebClient) => TransactionRequest | Promise<TransactionRequest>);
377
394
  /** Skip auto-sync before transaction. Default: false */
378
395
  skipSync?: boolean;
396
+ /**
397
+ * When set, private output notes from this transaction are delivered to the
398
+ * given target account after the transaction is committed. Accepts any
399
+ * AccountRef form (hex string, bech32, AccountId, Account, AccountHeader).
400
+ */
401
+ privateNoteTarget?: AccountRef;
379
402
  }
380
403
  interface TransactionResult {
381
404
  transactionId: string;
382
405
  }
406
+ interface ExecuteProgramOptions {
407
+ /** Account to execute the program against */
408
+ accountId: string | AccountId;
409
+ /** Compiled TransactionScript */
410
+ script: TransactionScript;
411
+ /** Advice inputs (defaults to empty) */
412
+ adviceInputs?: AdviceInputs;
413
+ /** Foreign accounts referenced by the script */
414
+ foreignAccounts?: (string | AccountId | {
415
+ id: string | AccountId;
416
+ storage?: AccountStorageRequirements;
417
+ })[];
418
+ /** Skip auto-sync before execution. Default: false */
419
+ skipSync?: boolean;
420
+ }
421
+ interface ExecuteProgramResult {
422
+ /** The 16-element stack output as bigint array */
423
+ stack: bigint[];
424
+ }
383
425
  interface StreamedNote {
384
426
  /** Note ID (hex string) */
385
427
  id: string;
@@ -481,6 +523,8 @@ interface MidenContextValue {
481
523
  prover: ReturnType<typeof resolveTransactionProver>;
482
524
  /** Account ID from signer (only set when using external signer) */
483
525
  signerAccountId: string | null;
526
+ /** Whether the external signer is connected (null = no signer provider) */
527
+ signerConnected: boolean | null;
484
528
  }
485
529
  interface MidenProviderProps {
486
530
  children: ReactNode;
@@ -494,6 +538,37 @@ declare function MidenProvider({ children, config, loadingComponent, errorCompon
494
538
  declare function useMiden(): MidenContextValue;
495
539
  declare function useMidenClient(): WasmWebClient;
496
540
 
541
+ interface MultiSignerContextValue {
542
+ /** All registered signer providers */
543
+ signers: SignerContextValue[];
544
+ /** The currently active signer (null if none selected) */
545
+ activeSigner: SignerContextValue | null;
546
+ /** Switch to a signer by name and call its connect() */
547
+ connectSigner: (name: string) => Promise<void>;
548
+ /** Disconnect the active signer and revert to local keystore mode */
549
+ disconnectSigner: () => Promise<void>;
550
+ }
551
+ declare function MultiSignerProvider({ children }: {
552
+ children: ReactNode;
553
+ }): react_jsx_runtime.JSX.Element;
554
+ /**
555
+ * Render-less component that registers the nearest ancestor's SignerContext value
556
+ * into the MultiSignerProvider registry.
557
+ *
558
+ * Place one `<SignerSlot />` inside each signer provider:
559
+ * ```tsx
560
+ * <ParaSignerProvider>
561
+ * <SignerSlot />
562
+ * </ParaSignerProvider>
563
+ * ```
564
+ */
565
+ declare function SignerSlot(): null;
566
+ /**
567
+ * Access the multi-signer context for listing signers, connecting, and disconnecting.
568
+ * Returns null when used outside a `MultiSignerProvider`.
569
+ */
570
+ declare function useMultiSigner(): MultiSignerContextValue | null;
571
+
497
572
  /**
498
573
  * Hook to list all accounts in the client.
499
574
  *
@@ -547,7 +622,7 @@ declare function useAccounts(): AccountsResult;
547
622
  * }
548
623
  * ```
549
624
  */
550
- declare function useAccount(accountId: string | AccountId | undefined): AccountResult;
625
+ declare function useAccount(accountId: AccountRef | undefined): AccountResult;
551
626
 
552
627
  /**
553
628
  * Hook to list notes.
@@ -790,9 +865,9 @@ declare function useImportAccount(): UseImportAccountResult;
790
865
 
791
866
  interface UseSendResult {
792
867
  /** Send tokens from one account to another */
793
- send: (options: SendOptions) => Promise<TransactionResult>;
868
+ send: (options: SendOptions) => Promise<SendResult>;
794
869
  /** The transaction result */
795
- result: TransactionResult | null;
870
+ result: SendResult | null;
796
871
  /** Whether the transaction is in progress */
797
872
  isLoading: boolean;
798
873
  /** Current stage of the transaction */
@@ -878,50 +953,6 @@ interface UseMultiSendResult {
878
953
  */
879
954
  declare function useMultiSend(): UseMultiSendResult;
880
955
 
881
- interface UseInternalTransferResult {
882
- /** Create a P2ID note and immediately consume it with another account */
883
- transfer: (options: InternalTransferOptions) => Promise<InternalTransferResult>;
884
- /** Perform a chain of P2ID transfers across multiple accounts */
885
- transferChain: (options: InternalTransferChainOptions) => Promise<InternalTransferResult[]>;
886
- /** The last transfer result(s) */
887
- result: InternalTransferResult | InternalTransferResult[] | null;
888
- /** Whether the transfer is in progress */
889
- isLoading: boolean;
890
- /** Current stage of the transfer */
891
- stage: TransactionStage;
892
- /** Error if transfer failed */
893
- error: Error | null;
894
- /** Reset the hook state */
895
- reset: () => void;
896
- }
897
- /**
898
- * Hook to create a P2ID note and immediately consume it.
899
- *
900
- * @example
901
- * ```tsx
902
- * function InternalTransferButton() {
903
- * const { transfer, isLoading, stage } = useInternalTransfer();
904
- *
905
- * const handleTransfer = async () => {
906
- * await transfer({
907
- * from: "mtst1...",
908
- * to: "0x...",
909
- * assetId: "0x...",
910
- * amount: 50n,
911
- * noteType: "public",
912
- * });
913
- * };
914
- *
915
- * return (
916
- * <button onClick={handleTransfer} disabled={isLoading}>
917
- * {isLoading ? stage : "Transfer"}
918
- * </button>
919
- * );
920
- * }
921
- * ```
922
- */
923
- declare function useInternalTransfer(): UseInternalTransferResult;
924
-
925
956
  interface UseWaitForCommitResult {
926
957
  /** Wait for a transaction to be committed on-chain */
927
958
  waitForCommit: (txId: string | TransactionId, options?: WaitForCommitOptions) => Promise<void>;
@@ -998,14 +1029,14 @@ interface UseConsumeResult {
998
1029
  *
999
1030
  * @example
1000
1031
  * ```tsx
1001
- * function ConsumeNotesButton({ accountId, noteIds }: Props) {
1032
+ * function ConsumeNotesButton({ accountId, notes }: Props) {
1002
1033
  * const { consume, isLoading, stage, error } = useConsume();
1003
1034
  *
1004
1035
  * const handleConsume = async () => {
1005
1036
  * try {
1006
1037
  * const result = await consume({
1007
1038
  * accountId,
1008
- * noteIds,
1039
+ * notes,
1009
1040
  * });
1010
1041
  * console.log('Consumed! TX:', result.transactionId);
1011
1042
  * } catch (err) {
@@ -1087,6 +1118,10 @@ interface UseTransactionResult {
1087
1118
  /**
1088
1119
  * Hook to execute arbitrary transaction requests.
1089
1120
  *
1121
+ * Always uses the 4-step pipeline (execute → prove → submit → apply)
1122
+ * with prover fallback support. When `privateNoteTarget` is set,
1123
+ * additionally waits for commit and delivers private output notes.
1124
+ *
1090
1125
  * @example
1091
1126
  * ```tsx
1092
1127
  * function CustomTransactionButton({ accountId }: { accountId: string }) {
@@ -1105,6 +1140,7 @@ interface UseTransactionResult {
1105
1140
  * NoteType.Private,
1106
1141
  * NoteType.Private
1107
1142
  * ),
1143
+ * privateNoteTarget: "0xrecipient...",
1108
1144
  * });
1109
1145
  * };
1110
1146
  *
@@ -1118,6 +1154,20 @@ interface UseTransactionResult {
1118
1154
  */
1119
1155
  declare function useTransaction(): UseTransactionResult;
1120
1156
 
1157
+ interface UseExecuteProgramResult {
1158
+ /** Execute a program (view call) and return the stack output */
1159
+ execute: (options: ExecuteProgramOptions) => Promise<ExecuteProgramResult>;
1160
+ /** The most recent result */
1161
+ result: ExecuteProgramResult | null;
1162
+ /** Whether execution is in progress */
1163
+ isLoading: boolean;
1164
+ /** Error if execution failed */
1165
+ error: Error | null;
1166
+ /** Reset the hook state */
1167
+ reset: () => void;
1168
+ }
1169
+ declare function useExecuteProgram(): UseExecuteProgramResult;
1170
+
1121
1171
  /**
1122
1172
  * Hook to manage a session wallet lifecycle: create -> fund -> consume.
1123
1173
  *
@@ -1149,9 +1199,174 @@ declare function useTransaction(): UseTransactionResult;
1149
1199
  */
1150
1200
  declare function useSessionAccount(options: UseSessionAccountOptions): UseSessionAccountReturn;
1151
1201
 
1202
+ interface UseExportStoreResult {
1203
+ /** Export the IndexedDB store as a JSON string */
1204
+ exportStore: () => Promise<string>;
1205
+ /** Whether the export is in progress */
1206
+ isExporting: boolean;
1207
+ /** Error if export failed */
1208
+ error: Error | null;
1209
+ /** Reset the hook state */
1210
+ reset: () => void;
1211
+ }
1212
+ /**
1213
+ * Hook to export the IndexedDB store for backup/restore.
1214
+ *
1215
+ * @example
1216
+ * ```tsx
1217
+ * function BackupButton() {
1218
+ * const { exportStore, isExporting, error } = useExportStore();
1219
+ *
1220
+ * const handleBackup = async () => {
1221
+ * const snapshot = await exportStore();
1222
+ * // Save snapshot to file, encrypted storage, etc.
1223
+ * };
1224
+ *
1225
+ * return (
1226
+ * <button onClick={handleBackup} disabled={isExporting}>
1227
+ * {isExporting ? 'Exporting...' : 'Backup Wallet'}
1228
+ * </button>
1229
+ * );
1230
+ * }
1231
+ * ```
1232
+ */
1233
+ declare function useExportStore(): UseExportStoreResult;
1234
+
1235
+ interface ImportStoreOptions {
1236
+ /** Skip auto-sync after import. Default: false */
1237
+ skipSync?: boolean;
1238
+ }
1239
+ interface UseImportStoreResult {
1240
+ /** Import a previously exported store dump */
1241
+ importStore: (storeDump: string, storeName: string, options?: ImportStoreOptions) => Promise<void>;
1242
+ /** Whether the import is in progress */
1243
+ isImporting: boolean;
1244
+ /** Error if import failed */
1245
+ error: Error | null;
1246
+ /** Reset the hook state */
1247
+ reset: () => void;
1248
+ }
1249
+ /**
1250
+ * Hook to import a previously exported IndexedDB store for restore.
1251
+ *
1252
+ * @example
1253
+ * ```tsx
1254
+ * function RestoreButton({ snapshot }: { snapshot: string }) {
1255
+ * const { importStore, isImporting, error } = useImportStore();
1256
+ *
1257
+ * const handleRestore = async () => {
1258
+ * await importStore(snapshot, 'RestoredStore');
1259
+ * // Store has been restored — sync or reload
1260
+ * };
1261
+ *
1262
+ * return (
1263
+ * <button onClick={handleRestore} disabled={isImporting}>
1264
+ * {isImporting ? 'Restoring...' : 'Restore Wallet'}
1265
+ * </button>
1266
+ * );
1267
+ * }
1268
+ * ```
1269
+ */
1270
+ declare function useImportStore(): UseImportStoreResult;
1271
+
1272
+ interface UseImportNoteResult {
1273
+ /** Import a note from serialized bytes (e.g. from QR code or dApp request) */
1274
+ importNote: (noteBytes: Uint8Array) => Promise<string>;
1275
+ /** Whether the import is in progress */
1276
+ isImporting: boolean;
1277
+ /** Error if import failed */
1278
+ error: Error | null;
1279
+ /** Reset the hook state */
1280
+ reset: () => void;
1281
+ }
1282
+ /**
1283
+ * Hook to import a note from serialized NoteFile bytes.
1284
+ *
1285
+ * @example
1286
+ * ```tsx
1287
+ * function ImportNoteButton({ noteBytes }: { noteBytes: Uint8Array }) {
1288
+ * const { importNote, isImporting, error } = useImportNote();
1289
+ *
1290
+ * const handleImport = async () => {
1291
+ * const noteId = await importNote(noteBytes);
1292
+ * console.log('Imported note:', noteId);
1293
+ * };
1294
+ *
1295
+ * return (
1296
+ * <button onClick={handleImport} disabled={isImporting}>
1297
+ * {isImporting ? 'Importing...' : 'Import Note'}
1298
+ * </button>
1299
+ * );
1300
+ * }
1301
+ * ```
1302
+ */
1303
+ declare function useImportNote(): UseImportNoteResult;
1304
+
1305
+ interface UseExportNoteResult {
1306
+ /** Export a note as serialized bytes */
1307
+ exportNote: (noteId: string) => Promise<Uint8Array>;
1308
+ /** Whether the export is in progress */
1309
+ isExporting: boolean;
1310
+ /** Error if export failed */
1311
+ error: Error | null;
1312
+ /** Reset the hook state */
1313
+ reset: () => void;
1314
+ }
1315
+ /**
1316
+ * Hook to export a note as serialized NoteFile bytes.
1317
+ *
1318
+ * @example
1319
+ * ```tsx
1320
+ * function ExportNoteButton({ noteId }: { noteId: string }) {
1321
+ * const { exportNote, isExporting, error } = useExportNote();
1322
+ *
1323
+ * const handleExport = async () => {
1324
+ * const bytes = await exportNote(noteId);
1325
+ * // Share bytes via QR code, file download, etc.
1326
+ * };
1327
+ *
1328
+ * return (
1329
+ * <button onClick={handleExport} disabled={isExporting}>
1330
+ * {isExporting ? 'Exporting...' : 'Export Note'}
1331
+ * </button>
1332
+ * );
1333
+ * }
1334
+ * ```
1335
+ */
1336
+ declare function useExportNote(): UseExportNoteResult;
1337
+
1338
+ interface UseSyncControlResult {
1339
+ /** Pause auto-sync. Manual sync via useSyncState().sync() still works. */
1340
+ pauseSync: () => void;
1341
+ /** Resume auto-sync. */
1342
+ resumeSync: () => void;
1343
+ /** Whether auto-sync is currently paused. */
1344
+ isPaused: boolean;
1345
+ }
1346
+ /**
1347
+ * Hook to pause and resume the automatic background sync.
1348
+ *
1349
+ * Useful during long-running operations (e.g. transaction proving) where
1350
+ * sync would compete for the WASM lock, or when the app is in the background.
1351
+ *
1352
+ * @example
1353
+ * ```tsx
1354
+ * function SyncToggle() {
1355
+ * const { pauseSync, resumeSync, isPaused } = useSyncControl();
1356
+ *
1357
+ * return (
1358
+ * <button onClick={isPaused ? resumeSync : pauseSync}>
1359
+ * {isPaused ? 'Resume Sync' : 'Pause Sync'}
1360
+ * </button>
1361
+ * );
1362
+ * }
1363
+ * ```
1364
+ */
1365
+ declare function useSyncControl(): UseSyncControlResult;
1366
+
1152
1367
  declare const toBech32AccountId: (accountId: string) => string;
1153
1368
 
1154
- declare const formatAssetAmount: (amount: bigint, decimals?: number) => string;
1369
+ declare const formatAssetAmount: (amount: bigint | number, decimals?: number) => string;
1155
1370
  declare const parseAssetAmount: (input: string, decimals?: number) => bigint;
1156
1371
 
1157
1372
  declare const getNoteSummary: (note: ConsumableNoteRecord | InputNoteRecord, getAssetMetadata?: (assetId: string) => AssetMetadata | undefined) => NoteSummary | null;
@@ -1252,4 +1467,4 @@ declare function createMidenStorage(prefix: string): {
1252
1467
  clear(): void;
1253
1468
  };
1254
1469
 
1255
- export { type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type ConsumeOptions, type CreateFaucetOptions, type CreateWalletOptions, DEFAULTS, type ExecuteTransactionOptions, type ImportAccountOptions, type InternalTransferChainOptions, type InternalTransferOptions, type InternalTransferResult, type MidenConfig, MidenError, type MidenErrorCode, MidenProvider, type MidenState, type MigrateStorageOptions, type MintOptions, type MultiSendOptions, type MultiSendRecipient, type MutationResult, type NoteAsset, type NoteAttachmentData, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverUrls, type QueryResult, type RpcUrlConfig, type SendOptions, type SessionAccountStep, type SignCallback, type SignerAccountConfig, type SignerAccountType, SignerContext, type SignerContextValue, type StreamedNote, type SwapOptions, type SyncState, type TransactionHistoryOptions, type TransactionHistoryResult, type TransactionResult, type TransactionStage, type TransactionStatus, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateWalletResult, type UseImportAccountResult, type UseInternalTransferResult, type UseMintResult, type UseMultiSendResult, type UseNoteStreamOptions, type UseNoteStreamReturn, type UseSendResult, type UseSessionAccountOptions, type UseSessionAccountReturn, type UseSwapResult, type UseSyncStateResult, type UseTransactionHistoryResult, type UseTransactionResult, type UseWaitForCommitResult, type UseWaitForNotesResult, type WaitForCommitOptions, type WaitForNotesOptions, type WalletAdapterLike, accountIdsEqual, bigIntToBytes, bytesToBigInt, clearMidenStorage, concatBytes, createMidenStorage, createNoteAttachment, formatAssetAmount, formatNoteSummary, getNoteSummary, migrateStorage, normalizeAccountId, parseAssetAmount, readNoteAttachment, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useConsume, useCreateFaucet, useCreateWallet, useImportAccount, useInternalTransfer, useMiden, useMidenClient, useMint, useMultiSend, useNoteStream, useNotes, useSend, useSessionAccount, useSigner, useSwap, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
1470
+ export { type AccountRef, type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type ConsumeOptions, type CreateFaucetOptions, type CreateWalletOptions, DEFAULTS, type ExecuteProgramOptions, type ExecuteProgramResult, type ExecuteTransactionOptions, type ImportAccountOptions, type ImportStoreOptions, type MidenConfig, MidenError, type MidenErrorCode, MidenProvider, type MidenState, type MigrateStorageOptions, type MintOptions, type MultiSendOptions, type MultiSendRecipient, type MultiSignerContextValue, MultiSignerProvider, type MutationResult, type NoteAsset, type NoteAttachmentData, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverTarget, type ProverUrls, type QueryResult, type RpcUrlConfig, type SendOptions, type SendResult, type SessionAccountStep, type SignCallback, type SignerAccountConfig, type SignerAccountType, SignerContext, type SignerContextValue, SignerSlot, type StreamedNote, type SwapOptions, type SyncState, type TransactionHistoryOptions, type TransactionHistoryResult, type TransactionResult, type TransactionStage, type TransactionStatus, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateWalletResult, type UseExecuteProgramResult, type UseExportNoteResult, type UseExportStoreResult, type UseImportAccountResult, type UseImportNoteResult, type UseImportStoreResult, type UseMintResult, type UseMultiSendResult, type UseNoteStreamOptions, type UseNoteStreamReturn, type UseSendResult, type UseSessionAccountOptions, type UseSessionAccountReturn, type UseSwapResult, type UseSyncControlResult, type UseSyncStateResult, type UseTransactionHistoryResult, type UseTransactionResult, type UseWaitForCommitResult, type UseWaitForNotesResult, type WaitForCommitOptions, type WaitForNotesOptions, type WalletAdapterLike, accountIdsEqual, bigIntToBytes, bytesToBigInt, clearMidenStorage, concatBytes, createMidenStorage, createNoteAttachment, formatAssetAmount, formatNoteSummary, getNoteSummary, migrateStorage, normalizeAccountId, parseAssetAmount, readNoteAttachment, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useConsume, useCreateFaucet, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };