@miden-sdk/react 0.14.3 → 0.14.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/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.AuthRpoFalcon512,
319
+ AUTH_SCHEME: AuthScheme.Falcon,
320
320
  NOTE_TYPE: "private",
321
321
  FAUCET_DECIMALS: 8
322
322
  };
@@ -459,7 +459,13 @@ function isPrivateStorageMode(storageMode) {
459
459
  return storageMode.toString() === "private";
460
460
  }
461
461
  async function initializeSignerAccount(client, config) {
462
- const { AccountBuilder, AccountComponent, AuthScheme: AuthScheme2, Word: Word2 } = await import("@miden-sdk/miden-sdk");
462
+ const {
463
+ AccountBuilder,
464
+ AccountComponent,
465
+ AuthScheme: AuthScheme2,
466
+ Word: Word2,
467
+ resolveAuthScheme: resolveAuthScheme5
468
+ } = await import("@miden-sdk/miden-sdk");
463
469
  await client.syncState();
464
470
  if (config.importAccountId) {
465
471
  const accountId2 = parseAccountId(config.importAccountId);
@@ -480,7 +486,7 @@ async function initializeSignerAccount(client, config) {
480
486
  let builder = new AccountBuilder(seed).withAuthComponent(
481
487
  AccountComponent.createAuthComponentFromCommitment(
482
488
  commitmentWord,
483
- AuthScheme2.AuthEcdsaK256Keccak
489
+ resolveAuthScheme5(AuthScheme2.ECDSA)
484
490
  )
485
491
  ).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
486
492
  if (config.customComponents?.length) {
@@ -553,15 +559,20 @@ function MidenProvider({
553
559
  }),
554
560
  [config]
555
561
  );
556
- const defaultProver = useMemo(
557
- () => resolveTransactionProver(resolvedConfig),
558
- [
559
- resolvedConfig.prover,
560
- resolvedConfig.proverTimeoutMs,
561
- resolvedConfig.proverUrls?.devnet,
562
- resolvedConfig.proverUrls?.testnet
563
- ]
564
- );
562
+ const [defaultProver, setDefaultProver] = useState(null);
563
+ useEffect(() => {
564
+ if (!isReady) {
565
+ setDefaultProver(null);
566
+ return;
567
+ }
568
+ setDefaultProver(resolveTransactionProver(resolvedConfig));
569
+ }, [
570
+ isReady,
571
+ resolvedConfig.prover,
572
+ resolvedConfig.proverTimeoutMs,
573
+ resolvedConfig.proverUrls?.devnet,
574
+ resolvedConfig.proverUrls?.testnet
575
+ ]);
565
576
  const runExclusive = useCallback(
566
577
  async (fn) => clientLockRef.current.runExclusive(fn),
567
578
  []
@@ -1796,7 +1807,10 @@ function useSyncState() {
1796
1807
 
1797
1808
  // src/hooks/useCreateWallet.ts
1798
1809
  import { useCallback as useCallback9, useState as useState7 } from "react";
1799
- import { AccountStorageMode } from "@miden-sdk/miden-sdk";
1810
+ import {
1811
+ AccountStorageMode,
1812
+ resolveAuthScheme
1813
+ } from "@miden-sdk/miden-sdk";
1800
1814
 
1801
1815
  // src/utils/runExclusive.ts
1802
1816
  var runExclusiveDirect = async (fn) => fn();
@@ -1821,7 +1835,9 @@ function useCreateWallet() {
1821
1835
  options.storageMode ?? DEFAULTS.STORAGE_MODE
1822
1836
  );
1823
1837
  const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
1824
- const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
1838
+ const authScheme = resolveAuthScheme(
1839
+ options.authScheme ?? DEFAULTS.AUTH_SCHEME
1840
+ );
1825
1841
  const newWallet = await runExclusiveSafe(async () => {
1826
1842
  const createdWallet = await client.newWallet(
1827
1843
  storageMode,
@@ -1874,7 +1890,10 @@ function getStorageMode(mode) {
1874
1890
 
1875
1891
  // src/hooks/useCreateFaucet.ts
1876
1892
  import { useCallback as useCallback10, useState as useState8 } from "react";
1877
- import { AccountStorageMode as AccountStorageMode2 } from "@miden-sdk/miden-sdk";
1893
+ import {
1894
+ AccountStorageMode as AccountStorageMode2,
1895
+ resolveAuthScheme as resolveAuthScheme2
1896
+ } from "@miden-sdk/miden-sdk";
1878
1897
  function useCreateFaucet() {
1879
1898
  const { client, isReady, runExclusive } = useMiden();
1880
1899
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
@@ -1894,7 +1913,9 @@ function useCreateFaucet() {
1894
1913
  options.storageMode ?? DEFAULTS.STORAGE_MODE
1895
1914
  );
1896
1915
  const decimals = options.decimals ?? DEFAULTS.FAUCET_DECIMALS;
1897
- const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
1916
+ const authScheme = resolveAuthScheme2(
1917
+ options.authScheme ?? DEFAULTS.AUTH_SCHEME
1918
+ );
1898
1919
  const newFaucet = await runExclusiveSafe(async () => {
1899
1920
  const createdFaucet = await client.newFaucet(
1900
1921
  storageMode,
@@ -1949,7 +1970,7 @@ function getStorageMode2(mode) {
1949
1970
 
1950
1971
  // src/hooks/useImportAccount.ts
1951
1972
  import { useCallback as useCallback11, useState as useState9 } from "react";
1952
- import { AccountFile } from "@miden-sdk/miden-sdk";
1973
+ import { AccountFile, resolveAuthScheme as resolveAuthScheme3 } from "@miden-sdk/miden-sdk";
1953
1974
 
1954
1975
  // src/utils/errors.ts
1955
1976
  var MidenError = class extends Error {
@@ -2082,7 +2103,9 @@ function useImportAccount() {
2082
2103
  }
2083
2104
  case "seed": {
2084
2105
  const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
2085
- const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
2106
+ const authScheme = resolveAuthScheme3(
2107
+ options.authScheme ?? DEFAULTS.AUTH_SCHEME
2108
+ );
2086
2109
  return await client.importPublicAccountFromSeed(
2087
2110
  options.seed,
2088
2111
  mutable,
@@ -2291,7 +2314,7 @@ function useSend() {
2291
2314
  const proverConfig = useMidenStore.getState().config;
2292
2315
  const provenTransaction = await proveWithFallback(
2293
2316
  (resolvedProver) => runExclusiveSafe(
2294
- () => client.proveTransaction(txResult, resolvedProver)
2317
+ () => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
2295
2318
  ),
2296
2319
  proverConfig
2297
2320
  );
@@ -2443,7 +2466,7 @@ function useMultiSend() {
2443
2466
  const proverConfig = useMidenStore.getState().config;
2444
2467
  const provenTransaction = await proveWithFallback(
2445
2468
  (resolvedProver) => runExclusiveDirect(
2446
- () => client.proveTransaction(txResult, resolvedProver)
2469
+ () => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
2447
2470
  ),
2448
2471
  proverConfig
2449
2472
  );
@@ -2914,7 +2937,7 @@ function useTransaction() {
2914
2937
  const proverConfig = useMidenStore.getState().config;
2915
2938
  const provenTransaction = await proveWithFallback(
2916
2939
  (resolvedProver) => runExclusiveSafe(
2917
- () => client.proveTransaction(txResult, resolvedProver)
2940
+ () => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
2918
2941
  ),
2919
2942
  proverConfig
2920
2943
  );
@@ -3098,7 +3121,10 @@ function useCompile() {
3098
3121
 
3099
3122
  // src/hooks/useSessionAccount.ts
3100
3123
  import { useCallback as useCallback22, useEffect as useEffect9, useRef as useRef8, useState as useState17 } from "react";
3101
- import { AccountStorageMode as AccountStorageMode3 } from "@miden-sdk/miden-sdk";
3124
+ import {
3125
+ AccountStorageMode as AccountStorageMode3,
3126
+ resolveAuthScheme as resolveAuthScheme4
3127
+ } from "@miden-sdk/miden-sdk";
3102
3128
  function useSessionAccount(options) {
3103
3129
  const { client, isReady, sync } = useMiden();
3104
3130
  const setAccounts = useMidenStore((state) => state.setAccounts);
@@ -3112,7 +3138,9 @@ function useSessionAccount(options) {
3112
3138
  const maxWaitMs = options.maxWaitMs ?? 6e4;
3113
3139
  const storageMode = options.walletOptions?.storageMode ?? "public";
3114
3140
  const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
3115
- const authScheme = options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME;
3141
+ const authScheme = resolveAuthScheme4(
3142
+ options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME
3143
+ );
3116
3144
  const fundRef = useRef8(options.fund);
3117
3145
  fundRef.current = options.fund;
3118
3146
  useEffect9(() => {