@miden-sdk/react 0.15.4 → 0.15.6

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/CLAUDE.md CHANGED
@@ -165,6 +165,22 @@ await bridge({
165
165
  });
166
166
  ```
167
167
 
168
+ ### Create a Network Note
169
+ ```tsx
170
+ const { createNetworkNote } = useCreateNetworkNote();
171
+
172
+ // Builds a Public custom-script note carrying a NetworkAccountTarget
173
+ // attachment; the targeted network account auto-consumes it on-chain.
174
+ // Provide exactly one of `script` or `recipient`.
175
+ const { txId, note } = await createNetworkNote({
176
+ accountId: senderAccountId,
177
+ target: networkAccountId,
178
+ script: myNoteScript, // or: recipient: myRecipient
179
+ });
180
+
181
+ note.isNetworkNote(); // true
182
+ ```
183
+
168
184
  ### Create Faucet
169
185
  ```tsx
170
186
  const { createFaucet } = useCreateFaucet();
@@ -427,6 +443,7 @@ Query hooks return `{ ...data, isLoading, error, refetch }`. Mutation hooks retu
427
443
  | `useMultiSend()` | `multiSend({ from, recipients })` | `TransactionResult` |
428
444
  | `useMint()` | `mint({ faucetId, to, amount })` | `TransactionResult` |
429
445
  | `useBridge()` | `bridge({ from, bridgeAccount, assetId, amount, destinationNetwork, destinationAddress })` | `TransactionResult` (emits an AggLayer B2AGG bridge-out note) |
446
+ | `useCreateNetworkNote()` | `createNetworkNote({ accountId, target, script \| recipient, ... })` | `NetworkNoteResult` (`{ txId, note }`; note satisfies `note.isNetworkNote()`) |
430
447
  | `useConsume()` | `consume({ accountId, notes })` | `TransactionResult` |
431
448
  | `useSwap()` | `swap({ ... })` | `TransactionResult` |
432
449
  | `usePswapCreate()` | `pswapCreate({ accountId, offeredFaucetId, offeredAmount, requestedFaucetId, requestedAmount, ... })` | `TransactionResult` (creates partial-swap note) |
package/README.md CHANGED
@@ -13,6 +13,7 @@ React hooks library for the Miden Web Client. Provides a simple, ergonomic inter
13
13
  - **Temporal Note Tracking** - `useNoteStream()` tracks when notes first appear, with built-in filtering, handled-note exclusion, and phase snapshots
14
14
  - **Session Wallets** - `useSessionAccount()` manages the create-fund-consume lifecycle for temporary wallets
15
15
  - **AggLayer Bridge-Out** - `useBridge()` emits a B2AGG note to bridge a fungible asset out to another network via the AggLayer
16
+ - **Network Notes** - `useCreateNetworkNote()` creates custom-script network notes
16
17
  - **Concurrency Safety** - Transaction hooks prevent double-sends with built-in concurrency guards
17
18
  - **Auto Pre-Sync** - Transaction hooks sync before executing by default (opt out with `skipSync`)
18
19
  - **WASM Error Wrapping** - Cryptic WASM errors are intercepted and replaced with actionable messages
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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, NoteInput, PswapLineageRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteScript, NoteAttachment } from '@miden-sdk/miden-sdk';
4
+ import { AccountId, Account, AccountHeader, AccountStorageMode, AccountComponent, NoteId, InputNoteRecord, Note, StorageMode, AuthScheme, NoteExecutionHint, NoteRecipient, NoteScript, TransactionScript, AdviceInputs, AccountStorageRequirements, TransactionRequest, WasmWebClient, AccountFile, NoteVisibility, ConsumableNoteRecord, NoteInput, PswapLineageRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteAttachment } from '@miden-sdk/miden-sdk';
5
5
  export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, Note, NoteType, PswapLineageRecord, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
6
6
 
7
7
  declare module "@miden-sdk/miden-sdk" {
@@ -392,6 +392,30 @@ interface MintOptions {
392
392
  /** Note type. Default: private */
393
393
  noteType?: NoteVisibility;
394
394
  }
395
+ interface CreateNetworkNoteOptions {
396
+ /** Account that creates, funds, and submits the note (executing sender). */
397
+ accountId: AccountRef;
398
+ /** The network account the note targets. */
399
+ target: AccountRef;
400
+ /** Execution hint. Defaults to `always`. */
401
+ executionHint?: NoteExecutionHint;
402
+ /** Recipient carrying the custom script (advanced; else pass `script`). */
403
+ recipient?: NoteRecipient;
404
+ /** Custom consumption script; the recipient is built for you. */
405
+ script?: NoteScript;
406
+ /** Note storage / inputs the script reads (used with `script`). */
407
+ inputs?: bigint[];
408
+ /** Single asset to lock into the note. Optional — omit for a zero-asset note. */
409
+ assetId?: AccountRef;
410
+ /** Amount for `assetId`. */
411
+ amount?: bigint | number;
412
+ /** Extra attachment payload appended after the NetworkAccountTarget. */
413
+ attachment?: bigint[] | Uint8Array | number[];
414
+ }
415
+ interface NetworkNoteResult {
416
+ txId: string;
417
+ note: Note;
418
+ }
395
419
  interface BridgeOptions {
396
420
  /** Account that creates and funds the bridge note (the sender) */
397
421
  from: AccountRef;
@@ -1492,6 +1516,22 @@ interface UsePswapCancelByOrderResult {
1492
1516
  */
1493
1517
  declare function usePswapCancelByOrder(): UsePswapCancelByOrderResult;
1494
1518
 
1519
+ interface UseCreateNetworkNoteResult {
1520
+ /** Build + submit a Public custom-script network note. */
1521
+ createNetworkNote: (options: CreateNetworkNoteOptions) => Promise<NetworkNoteResult>;
1522
+ result: NetworkNoteResult | null;
1523
+ isLoading: boolean;
1524
+ stage: TransactionStage;
1525
+ error: Error | null;
1526
+ reset: () => void;
1527
+ }
1528
+ /**
1529
+ * Hook that builds a Public custom-script note carrying a `NetworkAccountTarget`
1530
+ * attachment and submits it as an own output note, so a public network account
1531
+ * auto-consumes it. Provide exactly one of `recipient` or `script`.
1532
+ */
1533
+ declare function useCreateNetworkNote(): UseCreateNetworkNoteResult;
1534
+
1495
1535
  interface UseTransactionResult {
1496
1536
  /** Execute a transaction request end-to-end */
1497
1537
  execute: (options: ExecuteTransactionOptions) => Promise<TransactionResult>;
@@ -1911,4 +1951,4 @@ declare function createMidenStorage(prefix: string): {
1911
1951
  clear(): void;
1912
1952
  };
1913
1953
 
1914
- export { type AccountRef, type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type BridgeOptions, 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 PswapCancelByOrderOptions, type PswapCancelOptions, type PswapConsumeOptions, type PswapCreateOptions, type PswapLineageResult, type PswapLineagesResult, 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 UseBridgeResult, 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 UsePswapCancelByOrderResult, type UsePswapCancelResult, type UsePswapConsumeResult, type UsePswapCreateResult, type UsePswapLineageResult, type UsePswapLineagesForResult, type UsePswapLineagesResult, 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, useBridge, useCompile, useConsume, useCreateFaucet, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, usePswapCancel, usePswapCancelByOrder, usePswapConsume, usePswapCreate, usePswapLineage, usePswapLineages, usePswapLineagesFor, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
1954
+ export { type AccountRef, type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type BridgeOptions, type ConsumeOptions, type CreateFaucetOptions, type CreateNetworkNoteOptions, 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 NetworkNoteResult, type NoteAsset, type NoteAttachmentData, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverTarget, type ProverUrls, type PswapCancelByOrderOptions, type PswapCancelOptions, type PswapConsumeOptions, type PswapCreateOptions, type PswapLineageResult, type PswapLineagesResult, 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 UseBridgeResult, type UseCompileResult, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateNetworkNoteResult, type UseCreateWalletResult, type UseExecuteProgramResult, type UseExportNoteResult, type UseExportStoreResult, type UseImportAccountResult, type UseImportNoteResult, type UseImportStoreResult, type UseMintResult, type UseMultiSendResult, type UseNoteStreamOptions, type UseNoteStreamReturn, type UsePswapCancelByOrderResult, type UsePswapCancelResult, type UsePswapConsumeResult, type UsePswapCreateResult, type UsePswapLineageResult, type UsePswapLineagesForResult, type UsePswapLineagesResult, 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, useBridge, useCompile, useConsume, useCreateFaucet, useCreateNetworkNote, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, usePswapCancel, usePswapCancelByOrder, usePswapConsume, usePswapCreate, usePswapLineage, usePswapLineages, usePswapLineagesFor, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
package/dist/index.mjs CHANGED
@@ -3305,11 +3305,124 @@ function usePswapCancelByOrder() {
3305
3305
  };
3306
3306
  }
3307
3307
 
3308
+ // src/hooks/useCreateNetworkNote.ts
3309
+ import { useCallback as useCallback27, useState as useState23 } from "react";
3310
+ import {
3311
+ Felt,
3312
+ FeltArray,
3313
+ FungibleAsset as FungibleAsset3,
3314
+ Note as Note3,
3315
+ NoteArray as NoteArray3,
3316
+ NoteAssets as NoteAssets3,
3317
+ NoteMetadata,
3318
+ NoteStorage,
3319
+ NoteRecipient,
3320
+ NoteTag,
3321
+ NoteType as NoteType4,
3322
+ NetworkAccountTarget,
3323
+ TransactionRequestBuilder as TransactionRequestBuilder3
3324
+ } from "@miden-sdk/miden-sdk";
3325
+ function useCreateNetworkNote() {
3326
+ const { client, isReady, sync, runExclusive, prover } = useMiden();
3327
+ const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3328
+ const [result, setResult] = useState23(null);
3329
+ const [isLoading, setIsLoading] = useState23(false);
3330
+ const [stage, setStage] = useState23("idle");
3331
+ const [error, setError] = useState23(null);
3332
+ const createNetworkNote = useCallback27(
3333
+ async (options) => {
3334
+ if (!client || !isReady) {
3335
+ throw new Error("Miden client is not ready");
3336
+ }
3337
+ if (options.recipient && options.script) {
3338
+ throw new Error(
3339
+ "createNetworkNote requires exactly one of `recipient` or `script`, not both."
3340
+ );
3341
+ }
3342
+ if (!options.recipient && !options.script) {
3343
+ throw new Error(
3344
+ "createNetworkNote requires either `recipient` or `script`."
3345
+ );
3346
+ }
3347
+ setIsLoading(true);
3348
+ setStage("executing");
3349
+ setError(null);
3350
+ try {
3351
+ const built = await runExclusiveSafe(async () => {
3352
+ const senderId = parseAccountId(options.accountId);
3353
+ const targetId = parseAccountId(options.target);
3354
+ const target = new NetworkAccountTarget(
3355
+ targetId,
3356
+ options.executionHint
3357
+ );
3358
+ const noteAssets = options.assetId != null ? new NoteAssets3([
3359
+ new FungibleAsset3(
3360
+ parseAccountId(options.assetId),
3361
+ BigInt(options.amount ?? 0)
3362
+ )
3363
+ ]) : new NoteAssets3();
3364
+ const metadata = new NoteMetadata(
3365
+ senderId,
3366
+ NoteType4.Public,
3367
+ NoteTag.withAccountTarget(target.targetId())
3368
+ );
3369
+ const recipient = options.recipient ?? NoteRecipient.fromScript(
3370
+ options.script,
3371
+ new NoteStorage(
3372
+ new FeltArray(
3373
+ (options.inputs ?? []).map((value) => new Felt(value))
3374
+ )
3375
+ )
3376
+ );
3377
+ const attachments = [target.toAttachment()];
3378
+ if (options.attachment) {
3379
+ attachments.push(createNoteAttachment(options.attachment));
3380
+ }
3381
+ const note = Note3.withAttachments(
3382
+ noteAssets,
3383
+ metadata,
3384
+ recipient,
3385
+ attachments
3386
+ );
3387
+ const ownOutputs = new NoteArray3();
3388
+ ownOutputs.push(note);
3389
+ const txRequest = new TransactionRequestBuilder3().withOwnOutputNotes(ownOutputs).build();
3390
+ const txId = prover ? await client.submitNewTransactionWithProver(
3391
+ senderId,
3392
+ txRequest,
3393
+ prover
3394
+ ) : await client.submitNewTransaction(senderId, txRequest);
3395
+ return { txId: txId.toHex(), note };
3396
+ });
3397
+ setStage("complete");
3398
+ setResult(built);
3399
+ await sync();
3400
+ return built;
3401
+ } catch (err) {
3402
+ const e = err instanceof Error ? err : new Error(String(err));
3403
+ setError(e);
3404
+ setStage("idle");
3405
+ throw e;
3406
+ } finally {
3407
+ setIsLoading(false);
3408
+ }
3409
+ },
3410
+ [client, isReady, prover, runExclusive, sync]
3411
+ );
3412
+ const reset = useCallback27(() => {
3413
+ setResult(null);
3414
+ setIsLoading(false);
3415
+ setStage("idle");
3416
+ setError(null);
3417
+ }, []);
3418
+ return { createNetworkNote, result, isLoading, stage, error, reset };
3419
+ }
3420
+
3308
3421
  // src/hooks/useTransaction.ts
3309
- import { useCallback as useCallback27, useRef as useRef9, useState as useState23 } from "react";
3422
+ import { useCallback as useCallback28, useRef as useRef9, useState as useState24 } from "react";
3310
3423
 
3311
3424
  // src/utils/transactions.ts
3312
- import { NoteType as NoteType4, TransactionFilter as TransactionFilter4 } from "@miden-sdk/miden-sdk";
3425
+ import { NoteType as NoteType5, TransactionFilter as TransactionFilter4 } from "@miden-sdk/miden-sdk";
3313
3426
  async function waitForTransactionCommit2(client, runExclusiveSafe, txId, maxWaitMs = 1e4, delayMs = 1e3) {
3314
3427
  let waited = 0;
3315
3428
  while (waited < maxWaitMs) {
@@ -3337,7 +3450,7 @@ function extractFullNotes(txResult) {
3337
3450
  const notes = executedTx?.outputNotes?.().notes?.() ?? [];
3338
3451
  const result = [];
3339
3452
  for (const note of notes) {
3340
- if (note.noteType?.() === NoteType4.Private) {
3453
+ if (note.noteType?.() === NoteType5.Private) {
3341
3454
  const full = note.intoFull?.();
3342
3455
  if (full) result.push(full);
3343
3456
  }
@@ -3353,11 +3466,11 @@ function useTransaction() {
3353
3466
  const { client, isReady, sync, runExclusive } = useMiden();
3354
3467
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3355
3468
  const isBusyRef = useRef9(false);
3356
- const [result, setResult] = useState23(null);
3357
- const [isLoading, setIsLoading] = useState23(false);
3358
- const [stage, setStage] = useState23("idle");
3359
- const [error, setError] = useState23(null);
3360
- const execute = useCallback27(
3469
+ const [result, setResult] = useState24(null);
3470
+ const [isLoading, setIsLoading] = useState24(false);
3471
+ const [stage, setStage] = useState24("idle");
3472
+ const [error, setError] = useState24(null);
3473
+ const execute = useCallback28(
3361
3474
  async (options) => {
3362
3475
  if (!client || !isReady) {
3363
3476
  throw new Error("Miden client is not ready");
@@ -3424,7 +3537,7 @@ function useTransaction() {
3424
3537
  },
3425
3538
  [client, isReady, runExclusive, sync]
3426
3539
  );
3427
- const reset = useCallback27(() => {
3540
+ const reset = useCallback28(() => {
3428
3541
  setResult(null);
3429
3542
  setIsLoading(false);
3430
3543
  setStage("idle");
@@ -3447,7 +3560,7 @@ async function resolveRequest(request, client) {
3447
3560
  }
3448
3561
 
3449
3562
  // src/hooks/useExecuteProgram.ts
3450
- import { useCallback as useCallback28, useRef as useRef10, useState as useState24 } from "react";
3563
+ import { useCallback as useCallback29, useRef as useRef10, useState as useState25 } from "react";
3451
3564
  import {
3452
3565
  AdviceInputs,
3453
3566
  ForeignAccount,
@@ -3461,10 +3574,10 @@ function useExecuteProgram() {
3461
3574
  const { client, isReady, sync, runExclusive } = useMiden();
3462
3575
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
3463
3576
  const isBusyRef = useRef10(false);
3464
- const [result, setResult] = useState24(null);
3465
- const [isLoading, setIsLoading] = useState24(false);
3466
- const [error, setError] = useState24(null);
3467
- const execute = useCallback28(
3577
+ const [result, setResult] = useState25(null);
3578
+ const [isLoading, setIsLoading] = useState25(false);
3579
+ const [error, setError] = useState25(null);
3580
+ const execute = useCallback29(
3468
3581
  async (options) => {
3469
3582
  if (!client || !isReady) {
3470
3583
  throw new Error("Miden client is not ready");
@@ -3523,7 +3636,7 @@ function useExecuteProgram() {
3523
3636
  },
3524
3637
  [client, isReady, runExclusive, sync]
3525
3638
  );
3526
- const reset = useCallback28(() => {
3639
+ const reset = useCallback29(() => {
3527
3640
  setResult(null);
3528
3641
  setIsLoading(false);
3529
3642
  setError(null);
@@ -3538,7 +3651,7 @@ function useExecuteProgram() {
3538
3651
  }
3539
3652
 
3540
3653
  // src/hooks/useCompile.ts
3541
- import { useCallback as useCallback29, useMemo as useMemo9 } from "react";
3654
+ import { useCallback as useCallback30, useMemo as useMemo9 } from "react";
3542
3655
  import { CompilerResource, getWasmOrThrow } from "@miden-sdk/miden-sdk";
3543
3656
  function useCompile() {
3544
3657
  const { client, isReady } = useMiden();
@@ -3546,21 +3659,21 @@ function useCompile() {
3546
3659
  () => client && isReady ? new CompilerResource(client, getWasmOrThrow) : null,
3547
3660
  [client, isReady]
3548
3661
  );
3549
- const requireResource = useCallback29(() => {
3662
+ const requireResource = useCallback30(() => {
3550
3663
  if (!resource) {
3551
3664
  throw new Error("Miden client is not ready");
3552
3665
  }
3553
3666
  return resource;
3554
3667
  }, [resource]);
3555
- const component = useCallback29(
3668
+ const component = useCallback30(
3556
3669
  async (options) => requireResource().component(options),
3557
3670
  [requireResource]
3558
3671
  );
3559
- const txScript = useCallback29(
3672
+ const txScript = useCallback30(
3560
3673
  async (options) => requireResource().txScript(options),
3561
3674
  [requireResource]
3562
3675
  );
3563
- const noteScript = useCallback29(
3676
+ const noteScript = useCallback30(
3564
3677
  async (options) => requireResource().noteScript(options),
3565
3678
  [requireResource]
3566
3679
  );
@@ -3568,14 +3681,14 @@ function useCompile() {
3568
3681
  }
3569
3682
 
3570
3683
  // src/hooks/useSessionAccount.ts
3571
- import { useCallback as useCallback30, useEffect as useEffect12, useRef as useRef11, useState as useState25 } from "react";
3684
+ import { useCallback as useCallback31, useEffect as useEffect12, useRef as useRef11, useState as useState26 } from "react";
3572
3685
  import { AccountStorageMode as AccountStorageMode3 } from "@miden-sdk/miden-sdk";
3573
3686
  function useSessionAccount(options) {
3574
3687
  const { client, isReady, sync } = useMiden();
3575
3688
  const setAccounts = useMidenStore((state) => state.setAccounts);
3576
- const [sessionAccountId, setSessionAccountId] = useState25(null);
3577
- const [step, setStep] = useState25("idle");
3578
- const [error, setError] = useState25(null);
3689
+ const [sessionAccountId, setSessionAccountId] = useState26(null);
3690
+ const [step, setStep] = useState26("idle");
3691
+ const [error, setError] = useState26(null);
3579
3692
  const cancelledRef = useRef11(false);
3580
3693
  const isBusyRef = useRef11(false);
3581
3694
  const storagePrefix = options.storagePrefix ?? "miden-session";
@@ -3602,7 +3715,7 @@ function useSessionAccount(options) {
3602
3715
  localStorage.removeItem(`${storagePrefix}:ready`);
3603
3716
  }
3604
3717
  }, [storagePrefix]);
3605
- const initialize = useCallback30(async () => {
3718
+ const initialize = useCallback31(async () => {
3606
3719
  if (!client || !isReady) {
3607
3720
  throw new Error("Miden client is not ready");
3608
3721
  }
@@ -3666,7 +3779,7 @@ function useSessionAccount(options) {
3666
3779
  maxWaitMs,
3667
3780
  setAccounts
3668
3781
  ]);
3669
- const reset = useCallback30(() => {
3782
+ const reset = useCallback31(() => {
3670
3783
  cancelledRef.current = true;
3671
3784
  isBusyRef.current = false;
3672
3785
  setSessionAccountId(null);
@@ -3715,13 +3828,13 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
3715
3828
  }
3716
3829
 
3717
3830
  // src/hooks/useExportStore.ts
3718
- import { useCallback as useCallback31, useState as useState26 } from "react";
3831
+ import { useCallback as useCallback32, useState as useState27 } from "react";
3719
3832
  import { exportStore as sdkExportStore } from "@miden-sdk/miden-sdk";
3720
3833
  function useExportStore() {
3721
3834
  const { client, isReady, runExclusive } = useMiden();
3722
- const [isExporting, setIsExporting] = useState26(false);
3723
- const [error, setError] = useState26(null);
3724
- const exportStore = useCallback31(async () => {
3835
+ const [isExporting, setIsExporting] = useState27(false);
3836
+ const [error, setError] = useState27(null);
3837
+ const exportStore = useCallback32(async () => {
3725
3838
  if (!client || !isReady) {
3726
3839
  throw new Error("Miden client is not ready");
3727
3840
  }
@@ -3739,7 +3852,7 @@ function useExportStore() {
3739
3852
  setIsExporting(false);
3740
3853
  }
3741
3854
  }, [client, isReady, runExclusive]);
3742
- const reset = useCallback31(() => {
3855
+ const reset = useCallback32(() => {
3743
3856
  setIsExporting(false);
3744
3857
  setError(null);
3745
3858
  }, []);
@@ -3752,13 +3865,13 @@ function useExportStore() {
3752
3865
  }
3753
3866
 
3754
3867
  // src/hooks/useImportStore.ts
3755
- import { useCallback as useCallback32, useState as useState27 } from "react";
3868
+ import { useCallback as useCallback33, useState as useState28 } from "react";
3756
3869
  import { importStore as sdkImportStore } from "@miden-sdk/miden-sdk";
3757
3870
  function useImportStore() {
3758
3871
  const { client, isReady, runExclusive, sync } = useMiden();
3759
- const [isImporting, setIsImporting] = useState27(false);
3760
- const [error, setError] = useState27(null);
3761
- const importStore = useCallback32(
3872
+ const [isImporting, setIsImporting] = useState28(false);
3873
+ const [error, setError] = useState28(null);
3874
+ const importStore = useCallback33(
3762
3875
  async (storeDump, storeName, options) => {
3763
3876
  if (!client || !isReady) {
3764
3877
  throw new Error("Miden client is not ready");
@@ -3780,7 +3893,7 @@ function useImportStore() {
3780
3893
  },
3781
3894
  [client, isReady, runExclusive, sync]
3782
3895
  );
3783
- const reset = useCallback32(() => {
3896
+ const reset = useCallback33(() => {
3784
3897
  setIsImporting(false);
3785
3898
  setError(null);
3786
3899
  }, []);
@@ -3793,13 +3906,13 @@ function useImportStore() {
3793
3906
  }
3794
3907
 
3795
3908
  // src/hooks/useImportNote.ts
3796
- import { useCallback as useCallback33, useState as useState28 } from "react";
3909
+ import { useCallback as useCallback34, useState as useState29 } from "react";
3797
3910
  import { NoteFile } from "@miden-sdk/miden-sdk";
3798
3911
  function useImportNote() {
3799
3912
  const { client, isReady, runExclusive, sync } = useMiden();
3800
- const [isImporting, setIsImporting] = useState28(false);
3801
- const [error, setError] = useState28(null);
3802
- const importNote = useCallback33(
3913
+ const [isImporting, setIsImporting] = useState29(false);
3914
+ const [error, setError] = useState29(null);
3915
+ const importNote = useCallback34(
3803
3916
  async (noteBytes) => {
3804
3917
  if (!client || !isReady) {
3805
3918
  throw new Error("Miden client is not ready");
@@ -3823,7 +3936,7 @@ function useImportNote() {
3823
3936
  },
3824
3937
  [client, isReady, runExclusive, sync]
3825
3938
  );
3826
- const reset = useCallback33(() => {
3939
+ const reset = useCallback34(() => {
3827
3940
  setIsImporting(false);
3828
3941
  setError(null);
3829
3942
  }, []);
@@ -3836,13 +3949,13 @@ function useImportNote() {
3836
3949
  }
3837
3950
 
3838
3951
  // src/hooks/useExportNote.ts
3839
- import { useCallback as useCallback34, useState as useState29 } from "react";
3952
+ import { useCallback as useCallback35, useState as useState30 } from "react";
3840
3953
  import { NoteExportFormat } from "@miden-sdk/miden-sdk";
3841
3954
  function useExportNote() {
3842
3955
  const { client, isReady, runExclusive } = useMiden();
3843
- const [isExporting, setIsExporting] = useState29(false);
3844
- const [error, setError] = useState29(null);
3845
- const exportNote = useCallback34(
3956
+ const [isExporting, setIsExporting] = useState30(false);
3957
+ const [error, setError] = useState30(null);
3958
+ const exportNote = useCallback35(
3846
3959
  async (noteId) => {
3847
3960
  if (!client || !isReady) {
3848
3961
  throw new Error("Miden client is not ready");
@@ -3864,7 +3977,7 @@ function useExportNote() {
3864
3977
  },
3865
3978
  [client, isReady, runExclusive]
3866
3979
  );
3867
- const reset = useCallback34(() => {
3980
+ const reset = useCallback35(() => {
3868
3981
  setIsExporting(false);
3869
3982
  setError(null);
3870
3983
  }, []);
@@ -3877,12 +3990,12 @@ function useExportNote() {
3877
3990
  }
3878
3991
 
3879
3992
  // src/hooks/useSyncControl.ts
3880
- import { useCallback as useCallback35 } from "react";
3993
+ import { useCallback as useCallback36 } from "react";
3881
3994
  function useSyncControl() {
3882
3995
  const isPaused = useMidenStore((state) => state.syncPaused);
3883
3996
  const setSyncPaused = useMidenStore((state) => state.setSyncPaused);
3884
- const pauseSync = useCallback35(() => setSyncPaused(true), [setSyncPaused]);
3885
- const resumeSync = useCallback35(() => setSyncPaused(false), [setSyncPaused]);
3997
+ const pauseSync = useCallback36(() => setSyncPaused(true), [setSyncPaused]);
3998
+ const resumeSync = useCallback36(() => setSyncPaused(false), [setSyncPaused]);
3886
3999
  return {
3887
4000
  pauseSync,
3888
4001
  resumeSync,
@@ -4071,6 +4184,7 @@ export {
4071
4184
  useCompile,
4072
4185
  useConsume,
4073
4186
  useCreateFaucet,
4187
+ useCreateNetworkNote,
4074
4188
  useCreateWallet,
4075
4189
  useExecuteProgram,
4076
4190
  useExportNote,
package/dist/lazy.d.ts CHANGED
@@ -1,7 +1,7 @@
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, NoteInput, PswapLineageRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteScript, NoteAttachment } from '@miden-sdk/miden-sdk';
4
+ import { AccountId, Account, AccountHeader, AccountStorageMode, AccountComponent, NoteId, InputNoteRecord, Note, StorageMode, AuthScheme, NoteExecutionHint, NoteRecipient, NoteScript, TransactionScript, AdviceInputs, AccountStorageRequirements, TransactionRequest, WasmWebClient, AccountFile, NoteVisibility, ConsumableNoteRecord, NoteInput, PswapLineageRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteAttachment } from '@miden-sdk/miden-sdk';
5
5
  export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, Note, NoteType, PswapLineageRecord, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
6
6
 
7
7
  declare module "@miden-sdk/miden-sdk" {
@@ -392,6 +392,30 @@ interface MintOptions {
392
392
  /** Note type. Default: private */
393
393
  noteType?: NoteVisibility;
394
394
  }
395
+ interface CreateNetworkNoteOptions {
396
+ /** Account that creates, funds, and submits the note (executing sender). */
397
+ accountId: AccountRef;
398
+ /** The network account the note targets. */
399
+ target: AccountRef;
400
+ /** Execution hint. Defaults to `always`. */
401
+ executionHint?: NoteExecutionHint;
402
+ /** Recipient carrying the custom script (advanced; else pass `script`). */
403
+ recipient?: NoteRecipient;
404
+ /** Custom consumption script; the recipient is built for you. */
405
+ script?: NoteScript;
406
+ /** Note storage / inputs the script reads (used with `script`). */
407
+ inputs?: bigint[];
408
+ /** Single asset to lock into the note. Optional — omit for a zero-asset note. */
409
+ assetId?: AccountRef;
410
+ /** Amount for `assetId`. */
411
+ amount?: bigint | number;
412
+ /** Extra attachment payload appended after the NetworkAccountTarget. */
413
+ attachment?: bigint[] | Uint8Array | number[];
414
+ }
415
+ interface NetworkNoteResult {
416
+ txId: string;
417
+ note: Note;
418
+ }
395
419
  interface BridgeOptions {
396
420
  /** Account that creates and funds the bridge note (the sender) */
397
421
  from: AccountRef;
@@ -1492,6 +1516,22 @@ interface UsePswapCancelByOrderResult {
1492
1516
  */
1493
1517
  declare function usePswapCancelByOrder(): UsePswapCancelByOrderResult;
1494
1518
 
1519
+ interface UseCreateNetworkNoteResult {
1520
+ /** Build + submit a Public custom-script network note. */
1521
+ createNetworkNote: (options: CreateNetworkNoteOptions) => Promise<NetworkNoteResult>;
1522
+ result: NetworkNoteResult | null;
1523
+ isLoading: boolean;
1524
+ stage: TransactionStage;
1525
+ error: Error | null;
1526
+ reset: () => void;
1527
+ }
1528
+ /**
1529
+ * Hook that builds a Public custom-script note carrying a `NetworkAccountTarget`
1530
+ * attachment and submits it as an own output note, so a public network account
1531
+ * auto-consumes it. Provide exactly one of `recipient` or `script`.
1532
+ */
1533
+ declare function useCreateNetworkNote(): UseCreateNetworkNoteResult;
1534
+
1495
1535
  interface UseTransactionResult {
1496
1536
  /** Execute a transaction request end-to-end */
1497
1537
  execute: (options: ExecuteTransactionOptions) => Promise<TransactionResult>;
@@ -1911,4 +1951,4 @@ declare function createMidenStorage(prefix: string): {
1911
1951
  clear(): void;
1912
1952
  };
1913
1953
 
1914
- export { type AccountRef, type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type BridgeOptions, 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 PswapCancelByOrderOptions, type PswapCancelOptions, type PswapConsumeOptions, type PswapCreateOptions, type PswapLineageResult, type PswapLineagesResult, 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 UseBridgeResult, 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 UsePswapCancelByOrderResult, type UsePswapCancelResult, type UsePswapConsumeResult, type UsePswapCreateResult, type UsePswapLineageResult, type UsePswapLineagesForResult, type UsePswapLineagesResult, 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, useBridge, useCompile, useConsume, useCreateFaucet, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, usePswapCancel, usePswapCancelByOrder, usePswapConsume, usePswapCreate, usePswapLineage, usePswapLineages, usePswapLineagesFor, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
1954
+ export { type AccountRef, type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type BridgeOptions, type ConsumeOptions, type CreateFaucetOptions, type CreateNetworkNoteOptions, 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 NetworkNoteResult, type NoteAsset, type NoteAttachmentData, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverTarget, type ProverUrls, type PswapCancelByOrderOptions, type PswapCancelOptions, type PswapConsumeOptions, type PswapCreateOptions, type PswapLineageResult, type PswapLineagesResult, 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 UseBridgeResult, type UseCompileResult, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateNetworkNoteResult, type UseCreateWalletResult, type UseExecuteProgramResult, type UseExportNoteResult, type UseExportStoreResult, type UseImportAccountResult, type UseImportNoteResult, type UseImportStoreResult, type UseMintResult, type UseMultiSendResult, type UseNoteStreamOptions, type UseNoteStreamReturn, type UsePswapCancelByOrderResult, type UsePswapCancelResult, type UsePswapConsumeResult, type UsePswapCreateResult, type UsePswapLineageResult, type UsePswapLineagesForResult, type UsePswapLineagesResult, 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, useBridge, useCompile, useConsume, useCreateFaucet, useCreateNetworkNote, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, usePswapCancel, usePswapCancelByOrder, usePswapConsume, usePswapCreate, usePswapLineage, usePswapLineages, usePswapLineagesFor, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };