@miden-sdk/react 0.14.11 → 0.15.0-alpha.5

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/mt/lazy.d.ts CHANGED
@@ -1,10 +1,10 @@
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 { AccountId, Account, AccountHeader, AccountStorageMode, AccountComponent, NoteId, InputNoteRecord, Note, StorageMode, AuthScheme, TransactionScript, AdviceInputs, AccountStorageRequirements, TransactionRequest, WasmWebClient, AccountFile, NoteVisibility, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteScript, NoteAttachment } from '@miden-sdk/miden-sdk/lazy';
5
- export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, Note, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk/lazy';
4
+ import { AccountId, Account, AccountHeader, AccountStorageMode, AccountComponent, NoteId, InputNoteRecord, Note, StorageMode, AuthScheme, TransactionScript, AdviceInputs, AccountStorageRequirements, TransactionRequest, WasmWebClient, AccountFile, NoteVisibility, ConsumableNoteRecord, NoteInput, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteScript, 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
- declare module "@miden-sdk/miden-sdk/lazy" {
7
+ declare module "@miden-sdk/miden-sdk" {
8
8
  interface Account {
9
9
  /** Returns the bech32-encoded account id using the configured network. */
10
10
  bech32id(): string;
@@ -275,7 +275,7 @@ interface CreateWalletOptions {
275
275
  storageMode?: StorageMode;
276
276
  /** Whether code can be updated. Default: true */
277
277
  mutable?: boolean;
278
- /** Auth scheme. Default: `AuthScheme.Falcon` */
278
+ /** Auth scheme. Default: AuthScheme.AuthRpoFalcon512 */
279
279
  authScheme?: AuthScheme;
280
280
  /** Initial seed for deterministic account ID */
281
281
  initSeed?: Uint8Array;
@@ -283,13 +283,15 @@ interface CreateWalletOptions {
283
283
  interface CreateFaucetOptions {
284
284
  /** Token symbol (e.g., "TEST") */
285
285
  tokenSymbol: string;
286
+ /** Human-readable token name. Defaults to `tokenSymbol` when omitted. */
287
+ tokenName?: string;
286
288
  /** Number of decimals. Default: 8 */
287
289
  decimals?: number;
288
290
  /** Maximum supply */
289
291
  maxSupply: bigint | number;
290
292
  /** Storage mode. Default: private */
291
293
  storageMode?: StorageMode;
292
- /** Auth scheme. Default: `AuthScheme.Falcon` */
294
+ /** Auth scheme. Default: AuthScheme.AuthRpoFalcon512 */
293
295
  authScheme?: AuthScheme;
294
296
  }
295
297
  type ImportAccountOptions = {
@@ -402,6 +404,54 @@ interface SwapOptions {
402
404
  /** Note type for payback note. Default: private */
403
405
  paybackNoteType?: NoteVisibility;
404
406
  }
407
+ interface PswapCreateOptions {
408
+ /** Account that creates the PSWAP note */
409
+ accountId: AccountRef;
410
+ /** Faucet ID of the offered asset */
411
+ offeredFaucetId: AccountRef;
412
+ /** Amount being offered */
413
+ offeredAmount: bigint | number;
414
+ /** Faucet ID of the requested asset */
415
+ requestedFaucetId: AccountRef;
416
+ /** Amount being requested */
417
+ requestedAmount: bigint | number;
418
+ /** Visibility of the PSWAP note. Default: private */
419
+ noteType?: NoteVisibility;
420
+ /** Visibility of the payback note. Default: private */
421
+ paybackNoteType?: NoteVisibility;
422
+ }
423
+ interface PswapConsumeOptions {
424
+ /** Consumer account filling the PSWAP note */
425
+ accountId: AccountRef;
426
+ /**
427
+ * PSWAP note to consume. Accepts a hex string ID, `NoteId` object,
428
+ * `InputNoteRecord`, or `Note` — string/NoteId values are looked up from
429
+ * the local store; record/Note values are used directly.
430
+ */
431
+ note: NoteInput;
432
+ /**
433
+ * Amount of the requested asset the consumer is providing from its own
434
+ * vault. Receives a proportional share of the offered asset; partial fills
435
+ * also produce a remainder PSWAP note carrying the unfilled portion.
436
+ */
437
+ fillAmount: bigint | number;
438
+ /**
439
+ * Amount of the requested asset supplied by other (in-flight) notes routed
440
+ * into the same transaction. Defaults to `0`; most callers should leave
441
+ * this unset.
442
+ */
443
+ noteFillAmount?: bigint | number;
444
+ }
445
+ interface PswapCancelOptions {
446
+ /** Creator account reclaiming the offered asset */
447
+ accountId: AccountRef;
448
+ /**
449
+ * PSWAP note to cancel. Accepts a hex string ID, `NoteId` object,
450
+ * `InputNoteRecord`, or `Note` — string/NoteId values are looked up from
451
+ * the local store; record/Note values are used directly.
452
+ */
453
+ note: NoteInput;
454
+ }
405
455
  interface ExecuteTransactionOptions {
406
456
  /** Account ID the transaction applies to */
407
457
  accountId: AccountRef;
@@ -521,7 +571,7 @@ declare const DEFAULTS: {
521
571
  readonly AUTO_SYNC_INTERVAL: 15000;
522
572
  readonly STORAGE_MODE: "private";
523
573
  readonly WALLET_MUTABLE: true;
524
- readonly AUTH_SCHEME: "falcon";
574
+ readonly AUTH_SCHEME: AuthScheme.AuthRpoFalcon512;
525
575
  readonly NOTE_TYPE: "private";
526
576
  readonly FAUCET_DECIMALS: 8;
527
577
  };
@@ -1117,6 +1167,128 @@ interface UseSwapResult {
1117
1167
  */
1118
1168
  declare function useSwap(): UseSwapResult;
1119
1169
 
1170
+ interface UsePswapCreateResult {
1171
+ /** Create a partial-swap (PSWAP) note */
1172
+ pswapCreate: (options: PswapCreateOptions) => Promise<TransactionResult>;
1173
+ /** The transaction result */
1174
+ result: TransactionResult | null;
1175
+ /** Whether the transaction is in progress */
1176
+ isLoading: boolean;
1177
+ /** Current stage of the transaction */
1178
+ stage: TransactionStage;
1179
+ /** Error if transaction failed */
1180
+ error: Error | null;
1181
+ /** Reset the hook state */
1182
+ reset: () => void;
1183
+ }
1184
+ /**
1185
+ * Hook to create a partial-swap (PSWAP) note. The note can be filled by
1186
+ * multiple consumers; partial fills emit a remainder PSWAP note.
1187
+ *
1188
+ * @example
1189
+ * ```tsx
1190
+ * function CreatePswapButton({ accountId }: { accountId: string }) {
1191
+ * const { pswapCreate, isLoading, stage, error } = usePswapCreate();
1192
+ *
1193
+ * const handleCreate = async () => {
1194
+ * const result = await pswapCreate({
1195
+ * accountId,
1196
+ * offeredFaucetId: '0x...',
1197
+ * offeredAmount: 100n,
1198
+ * requestedFaucetId: '0x...',
1199
+ * requestedAmount: 50n,
1200
+ * });
1201
+ * console.log('PSWAP created! TX:', result.transactionId);
1202
+ * };
1203
+ *
1204
+ * return (
1205
+ * <button onClick={handleCreate} disabled={isLoading}>
1206
+ * {isLoading ? stage : 'Create PSWAP'}
1207
+ * </button>
1208
+ * );
1209
+ * }
1210
+ * ```
1211
+ */
1212
+ declare function usePswapCreate(): UsePswapCreateResult;
1213
+
1214
+ interface UsePswapConsumeResult {
1215
+ /** Fill (consume) an existing partial-swap (PSWAP) note */
1216
+ pswapConsume: (options: PswapConsumeOptions) => Promise<TransactionResult>;
1217
+ /** The transaction result */
1218
+ result: TransactionResult | null;
1219
+ /** Whether the transaction is in progress */
1220
+ isLoading: boolean;
1221
+ /** Current stage of the transaction */
1222
+ stage: TransactionStage;
1223
+ /** Error if transaction failed */
1224
+ error: Error | null;
1225
+ /** Reset the hook state */
1226
+ reset: () => void;
1227
+ }
1228
+ /**
1229
+ * Hook to consume (fully or partially fill) an existing PSWAP note. The
1230
+ * consumer supplies `fillAmount` and receives a proportional share of the
1231
+ * offered asset.
1232
+ *
1233
+ * @example
1234
+ * ```tsx
1235
+ * function FillPswapButton({ accountId, note }: Props) {
1236
+ * const { pswapConsume, isLoading, stage } = usePswapConsume();
1237
+ *
1238
+ * const handleFill = async () => {
1239
+ * await pswapConsume({
1240
+ * accountId,
1241
+ * note,
1242
+ * fillAmount: 25n,
1243
+ * });
1244
+ * };
1245
+ *
1246
+ * return (
1247
+ * <button onClick={handleFill} disabled={isLoading}>
1248
+ * {isLoading ? stage : 'Fill PSWAP'}
1249
+ * </button>
1250
+ * );
1251
+ * }
1252
+ * ```
1253
+ */
1254
+ declare function usePswapConsume(): UsePswapConsumeResult;
1255
+
1256
+ interface UsePswapCancelResult {
1257
+ /** Cancel a partial-swap (PSWAP) note as the creator */
1258
+ pswapCancel: (options: PswapCancelOptions) => Promise<TransactionResult>;
1259
+ /** The transaction result */
1260
+ result: TransactionResult | null;
1261
+ /** Whether the transaction is in progress */
1262
+ isLoading: boolean;
1263
+ /** Current stage of the transaction */
1264
+ stage: TransactionStage;
1265
+ /** Error if transaction failed */
1266
+ error: Error | null;
1267
+ /** Reset the hook state */
1268
+ reset: () => void;
1269
+ }
1270
+ /**
1271
+ * Hook to cancel a PSWAP note as the creator and reclaim the offered asset.
1272
+ *
1273
+ * @example
1274
+ * ```tsx
1275
+ * function CancelPswapButton({ accountId, note }: Props) {
1276
+ * const { pswapCancel, isLoading, stage } = usePswapCancel();
1277
+ *
1278
+ * const handleCancel = async () => {
1279
+ * await pswapCancel({ accountId, note });
1280
+ * };
1281
+ *
1282
+ * return (
1283
+ * <button onClick={handleCancel} disabled={isLoading}>
1284
+ * {isLoading ? stage : 'Cancel PSWAP'}
1285
+ * </button>
1286
+ * );
1287
+ * }
1288
+ * ```
1289
+ */
1290
+ declare function usePswapCancel(): UsePswapCancelResult;
1291
+
1120
1292
  interface UseTransactionResult {
1121
1293
  /** Execute a transaction request end-to-end */
1122
1294
  execute: (options: ExecuteTransactionOptions) => Promise<TransactionResult>;
@@ -1407,6 +1579,8 @@ interface UseSyncControlResult {
1407
1579
  */
1408
1580
  declare function useSyncControl(): UseSyncControlResult;
1409
1581
 
1582
+ declare const installAccountBech32: () => void;
1583
+ declare const ensureAccountBech32: (account?: Account | null) => void;
1410
1584
  declare const toBech32AccountId: (accountId: string) => string;
1411
1585
 
1412
1586
  declare const formatAssetAmount: (amount: bigint | number, decimals?: number) => string;
@@ -1431,17 +1605,41 @@ interface NoteAttachmentData {
1431
1605
  kind: "word" | "array";
1432
1606
  }
1433
1607
  /**
1434
- * Decode a note's attachment. Returns null if no attachment.
1608
+ * Decode a note's attachment payload back into the bigint values that
1609
+ * `createNoteAttachment` packed in.
1610
+ *
1611
+ * On the 0.15 protocol surface the full attachment content (the packed words)
1612
+ * lives on the note record (`InputNoteRecord.attachments()`), not on
1613
+ * `NoteMetadata`. This reads the note's first attachment and flattens its
1614
+ * words back into a `bigint[]`, the inverse of `createNoteAttachment`.
1615
+ *
1616
+ * - No attachments → `null`.
1617
+ * - An all-zero payload (regardless of word count) → `null`. This covers the
1618
+ * placeholder produced by `emptyAttachment()` (a single all-zero word) and
1619
+ * matches the pre-0.15 behavior where a `None`-kind attachment decoded to
1620
+ * `null`.
1621
+ * - Otherwise → `{ values, kind }` where `kind` is `"word"` for a single-word
1622
+ * attachment and `"array"` for multi-word content.
1623
+ *
1624
+ * The returned `values` include the trailing-zero padding `createNoteAttachment`
1625
+ * added to reach word boundaries; consumers that need the original unpadded
1626
+ * values should strip trailing zeros.
1435
1627
  */
1436
1628
  declare function readNoteAttachment(note: InputNoteRecord): NoteAttachmentData | null;
1437
1629
  /**
1438
- * Encode values into a NoteAttachment.
1439
- * <= 4 values -> Word (avoids miden-standards 0.13.x Array advice-map bug).
1440
- * > 4 values -> Array.
1441
- *
1442
- * Note: Values are padded to word boundaries (multiples of 4) with trailing 0n.
1443
- * `readNoteAttachment` returns raw values including padding. Consumers should
1444
- * strip trailing zeros if they need the original unpadded values.
1630
+ * Encode bigint values into a `NoteAttachment`.
1631
+ *
1632
+ * - 0 values falls back to `emptyAttachment()` (a single zero-Word
1633
+ * attachment with the `none` scheme). On the 0.15 protocol surface there
1634
+ * is no native "empty" attachment; this preserves the pre-migration
1635
+ * "default attachment when caller has no payload" behavior at the cost
1636
+ * of one trivial word.
1637
+ * - 1..=4 values → padded to 4 elements and wrapped as a single Word via
1638
+ * `NoteAttachment.fromWord(scheme, word)`.
1639
+ * - >4 values → padded to a multiple of 4, chunked into Words, and wrapped
1640
+ * via `NoteAttachment.fromWords(scheme, words)`.
1641
+ *
1642
+ * Values are padded to word boundaries (multiples of 4) with trailing `0n`.
1445
1643
  */
1446
1644
  declare function createNoteAttachment(values: bigint[] | Uint8Array | number[]): NoteAttachment;
1447
1645
 
@@ -1510,4 +1708,4 @@ declare function createMidenStorage(prefix: string): {
1510
1708
  clear(): void;
1511
1709
  };
1512
1710
 
1513
- 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 UseCompileResult, 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, useCompile, 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 };
1711
+ 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 PswapCancelOptions, type PswapConsumeOptions, type PswapCreateOptions, 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 UseCompileResult, 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 UsePswapCancelResult, type UsePswapConsumeResult, type UsePswapCreateResult, 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, ensureAccountBech32, formatAssetAmount, formatNoteSummary, getNoteSummary, installAccountBech32, migrateStorage, normalizeAccountId, parseAssetAmount, readNoteAttachment, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useCompile, useConsume, useCreateFaucet, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, usePswapCancel, usePswapConsume, usePswapCreate, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };