@miden-sdk/react 0.14.4 → 0.14.8
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 +66 -47
- package/LICENSE +21 -0
- package/README.md +67 -12
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +63 -26
- package/dist/lazy.d.ts +3 -3
- package/dist/lazy.mjs +63 -26
- package/dist/{lazy.d.mts → mt/lazy.d.ts} +3 -3
- package/dist/{index.js → mt/lazy.mjs} +466 -464
- package/dist/{index.d.mts → mt.d.ts} +3 -3
- package/dist/{lazy.js → mt.mjs} +466 -464
- package/lazy/package.json +5 -0
- package/mt/lazy/package.json +5 -0
- package/mt/package.json +5 -0
- package/package.json +36 -33
package/dist/index.mjs
CHANGED
|
@@ -316,7 +316,7 @@ var DEFAULTS = {
|
|
|
316
316
|
AUTO_SYNC_INTERVAL: 15e3,
|
|
317
317
|
STORAGE_MODE: "private",
|
|
318
318
|
WALLET_MUTABLE: true,
|
|
319
|
-
AUTH_SCHEME: AuthScheme.
|
|
319
|
+
AUTH_SCHEME: AuthScheme.Falcon,
|
|
320
320
|
NOTE_TYPE: "private",
|
|
321
321
|
FAUCET_DECIMALS: 8
|
|
322
322
|
};
|
|
@@ -425,6 +425,7 @@ function createRemoteProver(config, fallbackTimeout) {
|
|
|
425
425
|
}
|
|
426
426
|
return TransactionProver.newRemoteProver(
|
|
427
427
|
url,
|
|
428
|
+
/* v8 ignore next 1 — timeoutMs is always provided in tests; ?? fallbackTimeout path unreachable */
|
|
428
429
|
normalizeTimeout(timeoutMs ?? fallbackTimeout)
|
|
429
430
|
);
|
|
430
431
|
}
|
|
@@ -459,7 +460,13 @@ function isPrivateStorageMode(storageMode) {
|
|
|
459
460
|
return storageMode.toString() === "private";
|
|
460
461
|
}
|
|
461
462
|
async function initializeSignerAccount(client, config) {
|
|
462
|
-
const {
|
|
463
|
+
const {
|
|
464
|
+
AccountBuilder,
|
|
465
|
+
AccountComponent,
|
|
466
|
+
AuthScheme: AuthScheme2,
|
|
467
|
+
Word: Word2,
|
|
468
|
+
resolveAuthScheme: resolveAuthScheme5
|
|
469
|
+
} = await import("@miden-sdk/miden-sdk");
|
|
463
470
|
await client.syncState();
|
|
464
471
|
if (config.importAccountId) {
|
|
465
472
|
const accountId2 = parseAccountId(config.importAccountId);
|
|
@@ -480,7 +487,7 @@ async function initializeSignerAccount(client, config) {
|
|
|
480
487
|
let builder = new AccountBuilder(seed).withAuthComponent(
|
|
481
488
|
AccountComponent.createAuthComponentFromCommitment(
|
|
482
489
|
commitmentWord,
|
|
483
|
-
AuthScheme2.
|
|
490
|
+
resolveAuthScheme5(AuthScheme2.ECDSA)
|
|
484
491
|
)
|
|
485
492
|
).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
|
|
486
493
|
if (config.customComponents?.length) {
|
|
@@ -564,10 +571,12 @@ function MidenProvider({
|
|
|
564
571
|
isReady,
|
|
565
572
|
resolvedConfig.prover,
|
|
566
573
|
resolvedConfig.proverTimeoutMs,
|
|
574
|
+
/* v8 ignore next 2 — optional chain on proverUrls; tests don't pass proverUrls config */
|
|
567
575
|
resolvedConfig.proverUrls?.devnet,
|
|
568
576
|
resolvedConfig.proverUrls?.testnet
|
|
569
577
|
]);
|
|
570
578
|
const runExclusive = useCallback(
|
|
579
|
+
/* v8 ignore next 3 — runExclusive callback body; only called by advanced consumers, not directly in tests */
|
|
571
580
|
async (fn) => clientLockRef.current.runExclusive(fn),
|
|
572
581
|
[]
|
|
573
582
|
);
|
|
@@ -602,6 +611,8 @@ function MidenProvider({
|
|
|
602
611
|
signCbRef.current = signerContext?.signCb ?? null;
|
|
603
612
|
}, [signerContext?.signCb]);
|
|
604
613
|
const wrappedSignCb = useCallback(
|
|
614
|
+
/* v8 ignore next 11 — wrappedSignCb body is only called during external signer operations;
|
|
615
|
+
* tests don't exercise the full signing flow through MidenProvider directly. */
|
|
605
616
|
async (pubKey, signingInputs) => {
|
|
606
617
|
const cb = signCbRef.current;
|
|
607
618
|
if (!cb) {
|
|
@@ -849,7 +860,10 @@ function MultiSignerProvider({ children }) {
|
|
|
849
860
|
() => ({ register, unregister }),
|
|
850
861
|
[register, unregister]
|
|
851
862
|
);
|
|
852
|
-
const activeSigner = activeSignerName ?
|
|
863
|
+
const activeSigner = activeSignerName ? (
|
|
864
|
+
/* v8 ignore next 1 — ?? null fallback; find() returns undefined only when the signer was unregistered between renders */
|
|
865
|
+
signersSnapshot.find((s) => s.name === activeSignerName) ?? null
|
|
866
|
+
) : null;
|
|
853
867
|
const stableSignCb = useCallback2(
|
|
854
868
|
async (pubKey, signingInputs) => {
|
|
855
869
|
const name = activeSignerName;
|
|
@@ -1301,6 +1315,7 @@ function getNoteType(type) {
|
|
|
1301
1315
|
return NoteType.Private;
|
|
1302
1316
|
case "public":
|
|
1303
1317
|
return NoteType.Public;
|
|
1318
|
+
/* v8 ignore next 2 — TypeScript type ensures only "private"|"public"; default is unreachable */
|
|
1304
1319
|
default:
|
|
1305
1320
|
return NoteType.Private;
|
|
1306
1321
|
}
|
|
@@ -1776,6 +1791,7 @@ function buildFilter(filter, ids, idsHex) {
|
|
|
1776
1791
|
}
|
|
1777
1792
|
return {
|
|
1778
1793
|
filter: TransactionFilter2.all(),
|
|
1794
|
+
/* v8 ignore next 1 — idsHex is always non-null when ids is non-empty; ?? [] is a safety net */
|
|
1779
1795
|
localFilterHexes: idsHex ?? []
|
|
1780
1796
|
};
|
|
1781
1797
|
}
|
|
@@ -1801,7 +1817,10 @@ function useSyncState() {
|
|
|
1801
1817
|
|
|
1802
1818
|
// src/hooks/useCreateWallet.ts
|
|
1803
1819
|
import { useCallback as useCallback9, useState as useState7 } from "react";
|
|
1804
|
-
import {
|
|
1820
|
+
import {
|
|
1821
|
+
AccountStorageMode,
|
|
1822
|
+
resolveAuthScheme
|
|
1823
|
+
} from "@miden-sdk/miden-sdk";
|
|
1805
1824
|
|
|
1806
1825
|
// src/utils/runExclusive.ts
|
|
1807
1826
|
var runExclusiveDirect = async (fn) => fn();
|
|
@@ -1826,7 +1845,9 @@ function useCreateWallet() {
|
|
|
1826
1845
|
options.storageMode ?? DEFAULTS.STORAGE_MODE
|
|
1827
1846
|
);
|
|
1828
1847
|
const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
1829
|
-
const authScheme =
|
|
1848
|
+
const authScheme = resolveAuthScheme(
|
|
1849
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
1850
|
+
);
|
|
1830
1851
|
const newWallet = await runExclusiveSafe(async () => {
|
|
1831
1852
|
const createdWallet = await client.newWallet(
|
|
1832
1853
|
storageMode,
|
|
@@ -1879,7 +1900,10 @@ function getStorageMode(mode) {
|
|
|
1879
1900
|
|
|
1880
1901
|
// src/hooks/useCreateFaucet.ts
|
|
1881
1902
|
import { useCallback as useCallback10, useState as useState8 } from "react";
|
|
1882
|
-
import {
|
|
1903
|
+
import {
|
|
1904
|
+
AccountStorageMode as AccountStorageMode2,
|
|
1905
|
+
resolveAuthScheme as resolveAuthScheme2
|
|
1906
|
+
} from "@miden-sdk/miden-sdk";
|
|
1883
1907
|
function useCreateFaucet() {
|
|
1884
1908
|
const { client, isReady, runExclusive } = useMiden();
|
|
1885
1909
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -1899,7 +1923,9 @@ function useCreateFaucet() {
|
|
|
1899
1923
|
options.storageMode ?? DEFAULTS.STORAGE_MODE
|
|
1900
1924
|
);
|
|
1901
1925
|
const decimals = options.decimals ?? DEFAULTS.FAUCET_DECIMALS;
|
|
1902
|
-
const authScheme =
|
|
1926
|
+
const authScheme = resolveAuthScheme2(
|
|
1927
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
1928
|
+
);
|
|
1903
1929
|
const newFaucet = await runExclusiveSafe(async () => {
|
|
1904
1930
|
const createdFaucet = await client.newFaucet(
|
|
1905
1931
|
storageMode,
|
|
@@ -1954,7 +1980,7 @@ function getStorageMode2(mode) {
|
|
|
1954
1980
|
|
|
1955
1981
|
// src/hooks/useImportAccount.ts
|
|
1956
1982
|
import { useCallback as useCallback11, useState as useState9 } from "react";
|
|
1957
|
-
import { AccountFile } from "@miden-sdk/miden-sdk";
|
|
1983
|
+
import { AccountFile, resolveAuthScheme as resolveAuthScheme3 } from "@miden-sdk/miden-sdk";
|
|
1958
1984
|
|
|
1959
1985
|
// src/utils/errors.ts
|
|
1960
1986
|
var MidenError = class extends Error {
|
|
@@ -2087,7 +2113,9 @@ function useImportAccount() {
|
|
|
2087
2113
|
}
|
|
2088
2114
|
case "seed": {
|
|
2089
2115
|
const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
2090
|
-
const authScheme =
|
|
2116
|
+
const authScheme = resolveAuthScheme3(
|
|
2117
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
2118
|
+
);
|
|
2091
2119
|
return await client.importPublicAccountFromSeed(
|
|
2092
2120
|
options.seed,
|
|
2093
2121
|
mutable,
|
|
@@ -2253,7 +2281,7 @@ function useSend() {
|
|
|
2253
2281
|
txRequest,
|
|
2254
2282
|
prover
|
|
2255
2283
|
) : await client.submitNewTransaction(execFromId, txRequest);
|
|
2256
|
-
return { txId: txId.
|
|
2284
|
+
return { txId: txId.toHex(), note: p2idNote };
|
|
2257
2285
|
});
|
|
2258
2286
|
setStage("complete");
|
|
2259
2287
|
setResult(returnResult);
|
|
@@ -2305,7 +2333,6 @@ function useSend() {
|
|
|
2305
2333
|
() => client.submitProvenTransaction(provenTransaction, txResult)
|
|
2306
2334
|
);
|
|
2307
2335
|
const txIdHex = txResult.id().toHex();
|
|
2308
|
-
const txIdString = txResult.id().toString();
|
|
2309
2336
|
let fullNote = null;
|
|
2310
2337
|
if (noteType === NoteType2.Private) {
|
|
2311
2338
|
fullNote = extractFullNote(txResult);
|
|
@@ -2329,7 +2356,7 @@ function useSend() {
|
|
|
2329
2356
|
);
|
|
2330
2357
|
}
|
|
2331
2358
|
const sendResult = {
|
|
2332
|
-
txId:
|
|
2359
|
+
txId: txIdHex,
|
|
2333
2360
|
note: null
|
|
2334
2361
|
};
|
|
2335
2362
|
setStage("complete");
|
|
@@ -2441,7 +2468,11 @@ function useMultiSend() {
|
|
|
2441
2468
|
};
|
|
2442
2469
|
}
|
|
2443
2470
|
);
|
|
2444
|
-
const
|
|
2471
|
+
const ownOutputs = new NoteArray2();
|
|
2472
|
+
for (const o of outputs) {
|
|
2473
|
+
ownOutputs.push(o.note);
|
|
2474
|
+
}
|
|
2475
|
+
const txRequest = new TransactionRequestBuilder2().withOwnOutputNotes(ownOutputs).build();
|
|
2445
2476
|
const txSenderId = parseAccountId(options.from);
|
|
2446
2477
|
const txResult = await client.executeTransaction(txSenderId, txRequest);
|
|
2447
2478
|
setStage("proving");
|
|
@@ -2458,7 +2489,6 @@ function useMultiSend() {
|
|
|
2458
2489
|
txResult
|
|
2459
2490
|
);
|
|
2460
2491
|
const txIdHex = txResult.id().toHex();
|
|
2461
|
-
const txIdString = txResult.id().toString();
|
|
2462
2492
|
await client.applyTransaction(txResult, submissionHeight);
|
|
2463
2493
|
const hasPrivate = outputs.some((o) => o.noteType === NoteType3.Private);
|
|
2464
2494
|
if (hasPrivate) {
|
|
@@ -2476,7 +2506,7 @@ function useMultiSend() {
|
|
|
2476
2506
|
}
|
|
2477
2507
|
}
|
|
2478
2508
|
}
|
|
2479
|
-
const txSummary = { transactionId:
|
|
2509
|
+
const txSummary = { transactionId: txIdHex };
|
|
2480
2510
|
setStage("complete");
|
|
2481
2511
|
setResult(txSummary);
|
|
2482
2512
|
await sync();
|
|
@@ -2625,7 +2655,7 @@ function useMint() {
|
|
|
2625
2655
|
txRequest,
|
|
2626
2656
|
prover
|
|
2627
2657
|
) : await client.submitNewTransaction(faucetIdObj, txRequest);
|
|
2628
|
-
return { transactionId: txId.
|
|
2658
|
+
return { transactionId: txId.toHex() };
|
|
2629
2659
|
});
|
|
2630
2660
|
setStage("complete");
|
|
2631
2661
|
setResult(txResult);
|
|
@@ -2701,16 +2731,17 @@ function useConsume() {
|
|
|
2701
2731
|
}
|
|
2702
2732
|
}
|
|
2703
2733
|
if (lookupIds.length > 0) {
|
|
2734
|
+
const lookupIdStrings = lookupIds.map((id) => id.toString());
|
|
2704
2735
|
const filter = new NoteFilter3(NoteFilterTypes2.List, lookupIds);
|
|
2705
2736
|
const noteRecords = await client.getInputNotes(filter);
|
|
2706
|
-
if (noteRecords.length !==
|
|
2737
|
+
if (noteRecords.length !== lookupIdStrings.length) {
|
|
2707
2738
|
throw new Error("Some notes could not be found for provided IDs");
|
|
2708
2739
|
}
|
|
2709
2740
|
const recordById = new Map(
|
|
2710
2741
|
noteRecords.map((r) => [r.id().toString(), r])
|
|
2711
2742
|
);
|
|
2712
2743
|
for (let j = 0; j < lookupIndices.length; j++) {
|
|
2713
|
-
const record = recordById.get(
|
|
2744
|
+
const record = recordById.get(lookupIdStrings[j]);
|
|
2714
2745
|
if (!record) {
|
|
2715
2746
|
throw new Error(
|
|
2716
2747
|
"Some notes could not be found for provided IDs"
|
|
@@ -2732,7 +2763,7 @@ function useConsume() {
|
|
|
2732
2763
|
txRequest,
|
|
2733
2764
|
prover
|
|
2734
2765
|
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
2735
|
-
return { transactionId: txId.
|
|
2766
|
+
return { transactionId: txId.toHex() };
|
|
2736
2767
|
});
|
|
2737
2768
|
setStage("complete");
|
|
2738
2769
|
setResult(txResult);
|
|
@@ -2806,7 +2837,7 @@ function useSwap() {
|
|
|
2806
2837
|
txRequest,
|
|
2807
2838
|
prover
|
|
2808
2839
|
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
2809
|
-
return { transactionId: txId.
|
|
2840
|
+
return { transactionId: txId.toHex() };
|
|
2810
2841
|
});
|
|
2811
2842
|
setStage("complete");
|
|
2812
2843
|
setResult(txResult);
|
|
@@ -2941,7 +2972,7 @@ function useTransaction() {
|
|
|
2941
2972
|
);
|
|
2942
2973
|
}
|
|
2943
2974
|
}
|
|
2944
|
-
const txSummary = { transactionId: txId.
|
|
2975
|
+
const txSummary = { transactionId: txId.toHex() };
|
|
2945
2976
|
setStage("complete");
|
|
2946
2977
|
setResult(txSummary);
|
|
2947
2978
|
await sync();
|
|
@@ -3103,7 +3134,10 @@ function useCompile() {
|
|
|
3103
3134
|
|
|
3104
3135
|
// src/hooks/useSessionAccount.ts
|
|
3105
3136
|
import { useCallback as useCallback22, useEffect as useEffect9, useRef as useRef8, useState as useState17 } from "react";
|
|
3106
|
-
import {
|
|
3137
|
+
import {
|
|
3138
|
+
AccountStorageMode as AccountStorageMode3,
|
|
3139
|
+
resolveAuthScheme as resolveAuthScheme4
|
|
3140
|
+
} from "@miden-sdk/miden-sdk";
|
|
3107
3141
|
function useSessionAccount(options) {
|
|
3108
3142
|
const { client, isReady, sync } = useMiden();
|
|
3109
3143
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
@@ -3117,7 +3151,9 @@ function useSessionAccount(options) {
|
|
|
3117
3151
|
const maxWaitMs = options.maxWaitMs ?? 6e4;
|
|
3118
3152
|
const storageMode = options.walletOptions?.storageMode ?? "public";
|
|
3119
3153
|
const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
3120
|
-
const authScheme =
|
|
3154
|
+
const authScheme = resolveAuthScheme4(
|
|
3155
|
+
options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
3156
|
+
);
|
|
3121
3157
|
const fundRef = useRef8(options.fund);
|
|
3122
3158
|
fundRef.current = options.fund;
|
|
3123
3159
|
useEffect9(() => {
|
|
@@ -3168,13 +3204,14 @@ function useSessionAccount(options) {
|
|
|
3168
3204
|
setSessionAccountId(walletId);
|
|
3169
3205
|
localStorage.setItem(`${storagePrefix}:accountId`, walletId);
|
|
3170
3206
|
}
|
|
3207
|
+
const resolvedWalletId = walletId;
|
|
3171
3208
|
setStep("funding");
|
|
3172
|
-
await fundRef.current(
|
|
3209
|
+
await fundRef.current(resolvedWalletId);
|
|
3173
3210
|
if (cancelledRef.current) return;
|
|
3174
3211
|
setStep("consuming");
|
|
3175
3212
|
await waitAndConsume(
|
|
3176
3213
|
client,
|
|
3177
|
-
|
|
3214
|
+
resolvedWalletId,
|
|
3178
3215
|
pollIntervalMs,
|
|
3179
3216
|
maxWaitMs,
|
|
3180
3217
|
cancelledRef
|
package/dist/lazy.d.ts
CHANGED
|
@@ -259,7 +259,7 @@ interface CreateWalletOptions {
|
|
|
259
259
|
storageMode?: StorageMode;
|
|
260
260
|
/** Whether code can be updated. Default: true */
|
|
261
261
|
mutable?: boolean;
|
|
262
|
-
/** Auth scheme. Default: AuthScheme.
|
|
262
|
+
/** Auth scheme. Default: `AuthScheme.Falcon` */
|
|
263
263
|
authScheme?: AuthScheme;
|
|
264
264
|
/** Initial seed for deterministic account ID */
|
|
265
265
|
initSeed?: Uint8Array;
|
|
@@ -273,7 +273,7 @@ interface CreateFaucetOptions {
|
|
|
273
273
|
maxSupply: bigint | number;
|
|
274
274
|
/** Storage mode. Default: private */
|
|
275
275
|
storageMode?: StorageMode;
|
|
276
|
-
/** Auth scheme. Default: AuthScheme.
|
|
276
|
+
/** Auth scheme. Default: `AuthScheme.Falcon` */
|
|
277
277
|
authScheme?: AuthScheme;
|
|
278
278
|
}
|
|
279
279
|
type ImportAccountOptions = {
|
|
@@ -505,7 +505,7 @@ declare const DEFAULTS: {
|
|
|
505
505
|
readonly AUTO_SYNC_INTERVAL: 15000;
|
|
506
506
|
readonly STORAGE_MODE: "private";
|
|
507
507
|
readonly WALLET_MUTABLE: true;
|
|
508
|
-
readonly AUTH_SCHEME:
|
|
508
|
+
readonly AUTH_SCHEME: "falcon";
|
|
509
509
|
readonly NOTE_TYPE: "private";
|
|
510
510
|
readonly FAUCET_DECIMALS: 8;
|
|
511
511
|
};
|
package/dist/lazy.mjs
CHANGED
|
@@ -316,7 +316,7 @@ var DEFAULTS = {
|
|
|
316
316
|
AUTO_SYNC_INTERVAL: 15e3,
|
|
317
317
|
STORAGE_MODE: "private",
|
|
318
318
|
WALLET_MUTABLE: true,
|
|
319
|
-
AUTH_SCHEME: AuthScheme.
|
|
319
|
+
AUTH_SCHEME: AuthScheme.Falcon,
|
|
320
320
|
NOTE_TYPE: "private",
|
|
321
321
|
FAUCET_DECIMALS: 8
|
|
322
322
|
};
|
|
@@ -425,6 +425,7 @@ function createRemoteProver(config, fallbackTimeout) {
|
|
|
425
425
|
}
|
|
426
426
|
return TransactionProver.newRemoteProver(
|
|
427
427
|
url,
|
|
428
|
+
/* v8 ignore next 1 — timeoutMs is always provided in tests; ?? fallbackTimeout path unreachable */
|
|
428
429
|
normalizeTimeout(timeoutMs ?? fallbackTimeout)
|
|
429
430
|
);
|
|
430
431
|
}
|
|
@@ -459,7 +460,13 @@ function isPrivateStorageMode(storageMode) {
|
|
|
459
460
|
return storageMode.toString() === "private";
|
|
460
461
|
}
|
|
461
462
|
async function initializeSignerAccount(client, config) {
|
|
462
|
-
const {
|
|
463
|
+
const {
|
|
464
|
+
AccountBuilder,
|
|
465
|
+
AccountComponent,
|
|
466
|
+
AuthScheme: AuthScheme2,
|
|
467
|
+
Word: Word2,
|
|
468
|
+
resolveAuthScheme: resolveAuthScheme5
|
|
469
|
+
} = await import("@miden-sdk/miden-sdk/lazy");
|
|
463
470
|
await client.syncState();
|
|
464
471
|
if (config.importAccountId) {
|
|
465
472
|
const accountId2 = parseAccountId(config.importAccountId);
|
|
@@ -480,7 +487,7 @@ async function initializeSignerAccount(client, config) {
|
|
|
480
487
|
let builder = new AccountBuilder(seed).withAuthComponent(
|
|
481
488
|
AccountComponent.createAuthComponentFromCommitment(
|
|
482
489
|
commitmentWord,
|
|
483
|
-
AuthScheme2.
|
|
490
|
+
resolveAuthScheme5(AuthScheme2.ECDSA)
|
|
484
491
|
)
|
|
485
492
|
).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
|
|
486
493
|
if (config.customComponents?.length) {
|
|
@@ -564,10 +571,12 @@ function MidenProvider({
|
|
|
564
571
|
isReady,
|
|
565
572
|
resolvedConfig.prover,
|
|
566
573
|
resolvedConfig.proverTimeoutMs,
|
|
574
|
+
/* v8 ignore next 2 — optional chain on proverUrls; tests don't pass proverUrls config */
|
|
567
575
|
resolvedConfig.proverUrls?.devnet,
|
|
568
576
|
resolvedConfig.proverUrls?.testnet
|
|
569
577
|
]);
|
|
570
578
|
const runExclusive = useCallback(
|
|
579
|
+
/* v8 ignore next 3 — runExclusive callback body; only called by advanced consumers, not directly in tests */
|
|
571
580
|
async (fn) => clientLockRef.current.runExclusive(fn),
|
|
572
581
|
[]
|
|
573
582
|
);
|
|
@@ -602,6 +611,8 @@ function MidenProvider({
|
|
|
602
611
|
signCbRef.current = signerContext?.signCb ?? null;
|
|
603
612
|
}, [signerContext?.signCb]);
|
|
604
613
|
const wrappedSignCb = useCallback(
|
|
614
|
+
/* v8 ignore next 11 — wrappedSignCb body is only called during external signer operations;
|
|
615
|
+
* tests don't exercise the full signing flow through MidenProvider directly. */
|
|
605
616
|
async (pubKey, signingInputs) => {
|
|
606
617
|
const cb = signCbRef.current;
|
|
607
618
|
if (!cb) {
|
|
@@ -849,7 +860,10 @@ function MultiSignerProvider({ children }) {
|
|
|
849
860
|
() => ({ register, unregister }),
|
|
850
861
|
[register, unregister]
|
|
851
862
|
);
|
|
852
|
-
const activeSigner = activeSignerName ?
|
|
863
|
+
const activeSigner = activeSignerName ? (
|
|
864
|
+
/* v8 ignore next 1 — ?? null fallback; find() returns undefined only when the signer was unregistered between renders */
|
|
865
|
+
signersSnapshot.find((s) => s.name === activeSignerName) ?? null
|
|
866
|
+
) : null;
|
|
853
867
|
const stableSignCb = useCallback2(
|
|
854
868
|
async (pubKey, signingInputs) => {
|
|
855
869
|
const name = activeSignerName;
|
|
@@ -1301,6 +1315,7 @@ function getNoteType(type) {
|
|
|
1301
1315
|
return NoteType.Private;
|
|
1302
1316
|
case "public":
|
|
1303
1317
|
return NoteType.Public;
|
|
1318
|
+
/* v8 ignore next 2 — TypeScript type ensures only "private"|"public"; default is unreachable */
|
|
1304
1319
|
default:
|
|
1305
1320
|
return NoteType.Private;
|
|
1306
1321
|
}
|
|
@@ -1776,6 +1791,7 @@ function buildFilter(filter, ids, idsHex) {
|
|
|
1776
1791
|
}
|
|
1777
1792
|
return {
|
|
1778
1793
|
filter: TransactionFilter2.all(),
|
|
1794
|
+
/* v8 ignore next 1 — idsHex is always non-null when ids is non-empty; ?? [] is a safety net */
|
|
1779
1795
|
localFilterHexes: idsHex ?? []
|
|
1780
1796
|
};
|
|
1781
1797
|
}
|
|
@@ -1801,7 +1817,10 @@ function useSyncState() {
|
|
|
1801
1817
|
|
|
1802
1818
|
// src/hooks/useCreateWallet.ts
|
|
1803
1819
|
import { useCallback as useCallback9, useState as useState7 } from "react";
|
|
1804
|
-
import {
|
|
1820
|
+
import {
|
|
1821
|
+
AccountStorageMode,
|
|
1822
|
+
resolveAuthScheme
|
|
1823
|
+
} from "@miden-sdk/miden-sdk/lazy";
|
|
1805
1824
|
|
|
1806
1825
|
// src/utils/runExclusive.ts
|
|
1807
1826
|
var runExclusiveDirect = async (fn) => fn();
|
|
@@ -1826,7 +1845,9 @@ function useCreateWallet() {
|
|
|
1826
1845
|
options.storageMode ?? DEFAULTS.STORAGE_MODE
|
|
1827
1846
|
);
|
|
1828
1847
|
const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
1829
|
-
const authScheme =
|
|
1848
|
+
const authScheme = resolveAuthScheme(
|
|
1849
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
1850
|
+
);
|
|
1830
1851
|
const newWallet = await runExclusiveSafe(async () => {
|
|
1831
1852
|
const createdWallet = await client.newWallet(
|
|
1832
1853
|
storageMode,
|
|
@@ -1879,7 +1900,10 @@ function getStorageMode(mode) {
|
|
|
1879
1900
|
|
|
1880
1901
|
// src/hooks/useCreateFaucet.ts
|
|
1881
1902
|
import { useCallback as useCallback10, useState as useState8 } from "react";
|
|
1882
|
-
import {
|
|
1903
|
+
import {
|
|
1904
|
+
AccountStorageMode as AccountStorageMode2,
|
|
1905
|
+
resolveAuthScheme as resolveAuthScheme2
|
|
1906
|
+
} from "@miden-sdk/miden-sdk/lazy";
|
|
1883
1907
|
function useCreateFaucet() {
|
|
1884
1908
|
const { client, isReady, runExclusive } = useMiden();
|
|
1885
1909
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -1899,7 +1923,9 @@ function useCreateFaucet() {
|
|
|
1899
1923
|
options.storageMode ?? DEFAULTS.STORAGE_MODE
|
|
1900
1924
|
);
|
|
1901
1925
|
const decimals = options.decimals ?? DEFAULTS.FAUCET_DECIMALS;
|
|
1902
|
-
const authScheme =
|
|
1926
|
+
const authScheme = resolveAuthScheme2(
|
|
1927
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
1928
|
+
);
|
|
1903
1929
|
const newFaucet = await runExclusiveSafe(async () => {
|
|
1904
1930
|
const createdFaucet = await client.newFaucet(
|
|
1905
1931
|
storageMode,
|
|
@@ -1954,7 +1980,7 @@ function getStorageMode2(mode) {
|
|
|
1954
1980
|
|
|
1955
1981
|
// src/hooks/useImportAccount.ts
|
|
1956
1982
|
import { useCallback as useCallback11, useState as useState9 } from "react";
|
|
1957
|
-
import { AccountFile } from "@miden-sdk/miden-sdk/lazy";
|
|
1983
|
+
import { AccountFile, resolveAuthScheme as resolveAuthScheme3 } from "@miden-sdk/miden-sdk/lazy";
|
|
1958
1984
|
|
|
1959
1985
|
// src/utils/errors.ts
|
|
1960
1986
|
var MidenError = class extends Error {
|
|
@@ -2087,7 +2113,9 @@ function useImportAccount() {
|
|
|
2087
2113
|
}
|
|
2088
2114
|
case "seed": {
|
|
2089
2115
|
const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
2090
|
-
const authScheme =
|
|
2116
|
+
const authScheme = resolveAuthScheme3(
|
|
2117
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
2118
|
+
);
|
|
2091
2119
|
return await client.importPublicAccountFromSeed(
|
|
2092
2120
|
options.seed,
|
|
2093
2121
|
mutable,
|
|
@@ -2253,7 +2281,7 @@ function useSend() {
|
|
|
2253
2281
|
txRequest,
|
|
2254
2282
|
prover
|
|
2255
2283
|
) : await client.submitNewTransaction(execFromId, txRequest);
|
|
2256
|
-
return { txId: txId.
|
|
2284
|
+
return { txId: txId.toHex(), note: p2idNote };
|
|
2257
2285
|
});
|
|
2258
2286
|
setStage("complete");
|
|
2259
2287
|
setResult(returnResult);
|
|
@@ -2305,7 +2333,6 @@ function useSend() {
|
|
|
2305
2333
|
() => client.submitProvenTransaction(provenTransaction, txResult)
|
|
2306
2334
|
);
|
|
2307
2335
|
const txIdHex = txResult.id().toHex();
|
|
2308
|
-
const txIdString = txResult.id().toString();
|
|
2309
2336
|
let fullNote = null;
|
|
2310
2337
|
if (noteType === NoteType2.Private) {
|
|
2311
2338
|
fullNote = extractFullNote(txResult);
|
|
@@ -2329,7 +2356,7 @@ function useSend() {
|
|
|
2329
2356
|
);
|
|
2330
2357
|
}
|
|
2331
2358
|
const sendResult = {
|
|
2332
|
-
txId:
|
|
2359
|
+
txId: txIdHex,
|
|
2333
2360
|
note: null
|
|
2334
2361
|
};
|
|
2335
2362
|
setStage("complete");
|
|
@@ -2441,7 +2468,11 @@ function useMultiSend() {
|
|
|
2441
2468
|
};
|
|
2442
2469
|
}
|
|
2443
2470
|
);
|
|
2444
|
-
const
|
|
2471
|
+
const ownOutputs = new NoteArray2();
|
|
2472
|
+
for (const o of outputs) {
|
|
2473
|
+
ownOutputs.push(o.note);
|
|
2474
|
+
}
|
|
2475
|
+
const txRequest = new TransactionRequestBuilder2().withOwnOutputNotes(ownOutputs).build();
|
|
2445
2476
|
const txSenderId = parseAccountId(options.from);
|
|
2446
2477
|
const txResult = await client.executeTransaction(txSenderId, txRequest);
|
|
2447
2478
|
setStage("proving");
|
|
@@ -2458,7 +2489,6 @@ function useMultiSend() {
|
|
|
2458
2489
|
txResult
|
|
2459
2490
|
);
|
|
2460
2491
|
const txIdHex = txResult.id().toHex();
|
|
2461
|
-
const txIdString = txResult.id().toString();
|
|
2462
2492
|
await client.applyTransaction(txResult, submissionHeight);
|
|
2463
2493
|
const hasPrivate = outputs.some((o) => o.noteType === NoteType3.Private);
|
|
2464
2494
|
if (hasPrivate) {
|
|
@@ -2476,7 +2506,7 @@ function useMultiSend() {
|
|
|
2476
2506
|
}
|
|
2477
2507
|
}
|
|
2478
2508
|
}
|
|
2479
|
-
const txSummary = { transactionId:
|
|
2509
|
+
const txSummary = { transactionId: txIdHex };
|
|
2480
2510
|
setStage("complete");
|
|
2481
2511
|
setResult(txSummary);
|
|
2482
2512
|
await sync();
|
|
@@ -2625,7 +2655,7 @@ function useMint() {
|
|
|
2625
2655
|
txRequest,
|
|
2626
2656
|
prover
|
|
2627
2657
|
) : await client.submitNewTransaction(faucetIdObj, txRequest);
|
|
2628
|
-
return { transactionId: txId.
|
|
2658
|
+
return { transactionId: txId.toHex() };
|
|
2629
2659
|
});
|
|
2630
2660
|
setStage("complete");
|
|
2631
2661
|
setResult(txResult);
|
|
@@ -2701,16 +2731,17 @@ function useConsume() {
|
|
|
2701
2731
|
}
|
|
2702
2732
|
}
|
|
2703
2733
|
if (lookupIds.length > 0) {
|
|
2734
|
+
const lookupIdStrings = lookupIds.map((id) => id.toString());
|
|
2704
2735
|
const filter = new NoteFilter3(NoteFilterTypes2.List, lookupIds);
|
|
2705
2736
|
const noteRecords = await client.getInputNotes(filter);
|
|
2706
|
-
if (noteRecords.length !==
|
|
2737
|
+
if (noteRecords.length !== lookupIdStrings.length) {
|
|
2707
2738
|
throw new Error("Some notes could not be found for provided IDs");
|
|
2708
2739
|
}
|
|
2709
2740
|
const recordById = new Map(
|
|
2710
2741
|
noteRecords.map((r) => [r.id().toString(), r])
|
|
2711
2742
|
);
|
|
2712
2743
|
for (let j = 0; j < lookupIndices.length; j++) {
|
|
2713
|
-
const record = recordById.get(
|
|
2744
|
+
const record = recordById.get(lookupIdStrings[j]);
|
|
2714
2745
|
if (!record) {
|
|
2715
2746
|
throw new Error(
|
|
2716
2747
|
"Some notes could not be found for provided IDs"
|
|
@@ -2732,7 +2763,7 @@ function useConsume() {
|
|
|
2732
2763
|
txRequest,
|
|
2733
2764
|
prover
|
|
2734
2765
|
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
2735
|
-
return { transactionId: txId.
|
|
2766
|
+
return { transactionId: txId.toHex() };
|
|
2736
2767
|
});
|
|
2737
2768
|
setStage("complete");
|
|
2738
2769
|
setResult(txResult);
|
|
@@ -2806,7 +2837,7 @@ function useSwap() {
|
|
|
2806
2837
|
txRequest,
|
|
2807
2838
|
prover
|
|
2808
2839
|
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
2809
|
-
return { transactionId: txId.
|
|
2840
|
+
return { transactionId: txId.toHex() };
|
|
2810
2841
|
});
|
|
2811
2842
|
setStage("complete");
|
|
2812
2843
|
setResult(txResult);
|
|
@@ -2941,7 +2972,7 @@ function useTransaction() {
|
|
|
2941
2972
|
);
|
|
2942
2973
|
}
|
|
2943
2974
|
}
|
|
2944
|
-
const txSummary = { transactionId: txId.
|
|
2975
|
+
const txSummary = { transactionId: txId.toHex() };
|
|
2945
2976
|
setStage("complete");
|
|
2946
2977
|
setResult(txSummary);
|
|
2947
2978
|
await sync();
|
|
@@ -3103,7 +3134,10 @@ function useCompile() {
|
|
|
3103
3134
|
|
|
3104
3135
|
// src/hooks/useSessionAccount.ts
|
|
3105
3136
|
import { useCallback as useCallback22, useEffect as useEffect9, useRef as useRef8, useState as useState17 } from "react";
|
|
3106
|
-
import {
|
|
3137
|
+
import {
|
|
3138
|
+
AccountStorageMode as AccountStorageMode3,
|
|
3139
|
+
resolveAuthScheme as resolveAuthScheme4
|
|
3140
|
+
} from "@miden-sdk/miden-sdk/lazy";
|
|
3107
3141
|
function useSessionAccount(options) {
|
|
3108
3142
|
const { client, isReady, sync } = useMiden();
|
|
3109
3143
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
@@ -3117,7 +3151,9 @@ function useSessionAccount(options) {
|
|
|
3117
3151
|
const maxWaitMs = options.maxWaitMs ?? 6e4;
|
|
3118
3152
|
const storageMode = options.walletOptions?.storageMode ?? "public";
|
|
3119
3153
|
const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
3120
|
-
const authScheme =
|
|
3154
|
+
const authScheme = resolveAuthScheme4(
|
|
3155
|
+
options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
3156
|
+
);
|
|
3121
3157
|
const fundRef = useRef8(options.fund);
|
|
3122
3158
|
fundRef.current = options.fund;
|
|
3123
3159
|
useEffect9(() => {
|
|
@@ -3168,13 +3204,14 @@ function useSessionAccount(options) {
|
|
|
3168
3204
|
setSessionAccountId(walletId);
|
|
3169
3205
|
localStorage.setItem(`${storagePrefix}:accountId`, walletId);
|
|
3170
3206
|
}
|
|
3207
|
+
const resolvedWalletId = walletId;
|
|
3171
3208
|
setStep("funding");
|
|
3172
|
-
await fundRef.current(
|
|
3209
|
+
await fundRef.current(resolvedWalletId);
|
|
3173
3210
|
if (cancelledRef.current) return;
|
|
3174
3211
|
setStep("consuming");
|
|
3175
3212
|
await waitAndConsume(
|
|
3176
3213
|
client,
|
|
3177
|
-
|
|
3214
|
+
resolvedWalletId,
|
|
3178
3215
|
pollIntervalMs,
|
|
3179
3216
|
maxWaitMs,
|
|
3180
3217
|
cancelledRef
|
|
@@ -259,7 +259,7 @@ interface CreateWalletOptions {
|
|
|
259
259
|
storageMode?: StorageMode;
|
|
260
260
|
/** Whether code can be updated. Default: true */
|
|
261
261
|
mutable?: boolean;
|
|
262
|
-
/** Auth scheme. Default: AuthScheme.
|
|
262
|
+
/** Auth scheme. Default: `AuthScheme.Falcon` */
|
|
263
263
|
authScheme?: AuthScheme;
|
|
264
264
|
/** Initial seed for deterministic account ID */
|
|
265
265
|
initSeed?: Uint8Array;
|
|
@@ -273,7 +273,7 @@ interface CreateFaucetOptions {
|
|
|
273
273
|
maxSupply: bigint | number;
|
|
274
274
|
/** Storage mode. Default: private */
|
|
275
275
|
storageMode?: StorageMode;
|
|
276
|
-
/** Auth scheme. Default: AuthScheme.
|
|
276
|
+
/** Auth scheme. Default: `AuthScheme.Falcon` */
|
|
277
277
|
authScheme?: AuthScheme;
|
|
278
278
|
}
|
|
279
279
|
type ImportAccountOptions = {
|
|
@@ -505,7 +505,7 @@ declare const DEFAULTS: {
|
|
|
505
505
|
readonly AUTO_SYNC_INTERVAL: 15000;
|
|
506
506
|
readonly STORAGE_MODE: "private";
|
|
507
507
|
readonly WALLET_MUTABLE: true;
|
|
508
|
-
readonly AUTH_SCHEME:
|
|
508
|
+
readonly AUTH_SCHEME: "falcon";
|
|
509
509
|
readonly NOTE_TYPE: "private";
|
|
510
510
|
readonly FAUCET_DECIMALS: 8;
|
|
511
511
|
};
|