@miden-sdk/react 0.14.0-alpha → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md CHANGED
@@ -133,7 +133,7 @@ const { mutate: consume } = useConsume();
133
133
 
134
134
  await consume({
135
135
  accountId: myAccountId,
136
- noteIds: [noteId1, noteId2], // optional: consume specific notes
136
+ notes: [noteId1, noteId2], // note IDs, InputNoteRecords, or Note objects
137
137
  });
138
138
  ```
139
139
 
@@ -288,7 +288,7 @@ const { client, account, setAccount } = useTurnkeySigner();
288
288
  ```tsx
289
289
  import { MidenFiSignerProvider } from "@miden-sdk/wallet-adapter-react";
290
290
 
291
- <MidenFiSignerProvider network="Testnet">
291
+ <MidenFiSignerProvider network="testnet">
292
292
  <MidenProvider config={{ rpcUrl: "testnet" }}>
293
293
  <App />
294
294
  </MidenProvider>
package/README.md CHANGED
@@ -839,11 +839,11 @@ import { useConsume } from '@miden-sdk/react';
839
839
  function ConsumeNotes() {
840
840
  const { consume, result, isLoading, stage, error, reset } = useConsume();
841
841
 
842
- const handleConsume = async (noteIds: string[]) => {
842
+ const handleConsume = async (notes: string[]) => {
843
843
  try {
844
844
  const { transactionId } = await consume({
845
845
  accountId: '0xmywallet...', // Your wallet ID
846
- noteIds: noteIds, // Array of note IDs to consume
846
+ notes, // Note IDs, InputNoteRecords, or Note objects
847
847
  });
848
848
 
849
849
  console.log('Consumed! TX:', transactionId);
@@ -952,6 +952,47 @@ function CustomTransactionButton({ accountId }: { accountId: string }) {
952
952
  }
953
953
  ```
954
954
 
955
+ #### `useExecuteProgram()`
956
+
957
+ Execute a program (view call) against an account and read the resulting stack
958
+ output. This runs locally and does not submit anything to the network. Useful
959
+ for reading on-chain state like storage maps or computed values.
960
+
961
+ Built-in features:
962
+ - **Auto pre-sync** before executing (disable with `skipSync: true`)
963
+ - **Concurrency guard** prevents double-executions while a call is in-flight
964
+ - **Ergonomic output** converts the raw `FeltArray` to a `bigint[]` array
965
+
966
+ ```tsx
967
+ import { useExecuteProgram } from '@miden-sdk/react';
968
+
969
+ function ReadCountButton({ accountId, script }: { accountId: string; script: TransactionScript }) {
970
+ const { execute, result, isLoading, error } = useExecuteProgram();
971
+
972
+ const handleRead = async () => {
973
+ const { stack } = await execute({
974
+ accountId,
975
+ script,
976
+ // Optional:
977
+ // adviceInputs: myAdviceInputs,
978
+ // foreignAccounts: [otherAccountId],
979
+ // skipSync: true,
980
+ });
981
+ console.log('Stack output:', stack); // bigint[]
982
+ };
983
+
984
+ return (
985
+ <div>
986
+ <button onClick={handleRead} disabled={isLoading}>
987
+ {isLoading ? 'Executing...' : 'Read Count'}
988
+ </button>
989
+ {result && <p>Count: {result.stack[0].toString()}</p>}
990
+ {error && <p>Error: {error.message}</p>}
991
+ </div>
992
+ );
993
+ }
994
+ ```
995
+
955
996
  #### `useSessionAccount(options)`
956
997
 
957
998
  Manage a session wallet lifecycle: create, fund, and consume in a single flow.
@@ -1245,7 +1286,7 @@ import { MidenFiSignerProvider } from '@miden-sdk/wallet-adapter-react';
1245
1286
 
1246
1287
  function App() {
1247
1288
  return (
1248
- <MidenFiSignerProvider network="Testnet">
1289
+ <MidenFiSignerProvider network="testnet">
1249
1290
  <MidenProvider config={{ rpcUrl: 'testnet' }}>
1250
1291
  <YourApp />
1251
1292
  </MidenProvider>
@@ -1272,6 +1313,73 @@ function ConnectButton() {
1272
1313
  }
1273
1314
  ```
1274
1315
 
1316
+ ### Multi-Signer Setup
1317
+
1318
+ For apps that support multiple signer providers (e.g. Para + Turnkey + MidenFi), use `MultiSignerProvider` and `SignerSlot` to let users choose which signer to connect:
1319
+
1320
+ ```tsx
1321
+ import {
1322
+ MidenProvider,
1323
+ MultiSignerProvider,
1324
+ SignerSlot,
1325
+ useMultiSigner,
1326
+ } from '@miden-sdk/react';
1327
+ import { ParaSignerProvider } from '@miden-sdk/use-miden-para-react';
1328
+ import { TurnkeySignerProvider } from '@miden-sdk/miden-turnkey-react';
1329
+ import { MidenFiSignerProvider } from '@miden-sdk/miden-wallet-adapter-react';
1330
+
1331
+ function App() {
1332
+ return (
1333
+ <MultiSignerProvider>
1334
+ <ParaSignerProvider apiKey="your-api-key" environment="BETA">
1335
+ <SignerSlot />
1336
+ </ParaSignerProvider>
1337
+ <TurnkeySignerProvider>
1338
+ <SignerSlot />
1339
+ </TurnkeySignerProvider>
1340
+ <MidenFiSignerProvider network="testnet">
1341
+ <SignerSlot />
1342
+ </MidenFiSignerProvider>
1343
+ <MidenProvider config={{ rpcUrl: 'testnet', prover: 'testnet' }}>
1344
+ <YourApp />
1345
+ </MidenProvider>
1346
+ </MultiSignerProvider>
1347
+ );
1348
+ }
1349
+ ```
1350
+
1351
+ Each `SignerSlot` captures its nearest ancestor signer provider's context and registers it with `MultiSignerProvider`. The `MidenProvider` sees whichever signer is currently active (or `null` for local keystore mode).
1352
+
1353
+ Use `useMultiSigner()` to list available signers and switch between them:
1354
+
1355
+ ```tsx
1356
+ function SignerSelector() {
1357
+ const multiSigner = useMultiSigner();
1358
+
1359
+ return (
1360
+ <div>
1361
+ {multiSigner?.signers.map((s) => (
1362
+ <button key={s.name} onClick={() => multiSigner.connectSigner(s.name)}>
1363
+ {s.name}
1364
+ </button>
1365
+ ))}
1366
+ <button onClick={() => multiSigner?.disconnectSigner()}>
1367
+ Use Local Keystore
1368
+ </button>
1369
+ </div>
1370
+ );
1371
+ }
1372
+ ```
1373
+
1374
+ The `useMultiSigner()` hook returns:
1375
+
1376
+ | Field | Type | Description |
1377
+ |-------|------|-------------|
1378
+ | `signers` | `SignerContextValue[]` | All registered signer providers |
1379
+ | `activeSigner` | `SignerContextValue \| null` | Currently active signer |
1380
+ | `connectSigner(name)` | `(name: string) => Promise<void>` | Switch to a signer by name |
1381
+ | `disconnectSigner()` | `() => Promise<void>` | Disconnect active signer (falls back to local keystore) |
1382
+
1275
1383
  ### Custom Account Components
1276
1384
 
1277
1385
  Signer providers can include custom `AccountComponent` instances in the account via the `customComponents` field on `SignerAccountConfig`. This is useful for attaching application-specific logic compiled from `.masp` packages (e.g. a DEX component or custom smart contract) alongside the default auth and basic wallet components.