@miden-sdk/react 0.14.5 → 0.15.0-alpha.4

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.Falcon,
319
+ AUTH_SCHEME: AuthScheme.AuthRpoFalcon512,
320
320
  NOTE_TYPE: "private",
321
321
  FAUCET_DECIMALS: 8
322
322
  };
@@ -402,10 +402,7 @@ function resolveProverTarget(target, config) {
402
402
  return TransactionProver.newLocalProver();
403
403
  }
404
404
  if (normalized === "devnet" || normalized === "testnet") {
405
- const url = config.proverUrls?.[normalized] ?? DEFAULT_PROVER_URLS[normalized] ?? null;
406
- if (!url) {
407
- throw new Error(`Missing ${normalized} prover URL`);
408
- }
405
+ const url = config.proverUrls?.[normalized] ?? DEFAULT_PROVER_URLS[normalized];
409
406
  return TransactionProver.newRemoteProver(
410
407
  url,
411
408
  normalizeTimeout(config.proverTimeoutMs)
@@ -459,13 +456,7 @@ function isPrivateStorageMode(storageMode) {
459
456
  return storageMode.toString() === "private";
460
457
  }
461
458
  async function initializeSignerAccount(client, config) {
462
- const {
463
- AccountBuilder,
464
- AccountComponent,
465
- AuthScheme: AuthScheme2,
466
- Word: Word2,
467
- resolveAuthScheme: resolveAuthScheme5
468
- } = await import("@miden-sdk/miden-sdk");
459
+ const { AccountBuilder, AccountComponent, AuthScheme: AuthScheme2, Word: Word2 } = await import("@miden-sdk/miden-sdk");
469
460
  await client.syncState();
470
461
  if (config.importAccountId) {
471
462
  const accountId2 = parseAccountId(config.importAccountId);
@@ -486,7 +477,7 @@ async function initializeSignerAccount(client, config) {
486
477
  let builder = new AccountBuilder(seed).withAuthComponent(
487
478
  AccountComponent.createAuthComponentFromCommitment(
488
479
  commitmentWord,
489
- resolveAuthScheme5(AuthScheme2.ECDSA)
480
+ AuthScheme2.AuthEcdsaK256Keccak
490
481
  )
491
482
  ).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
492
483
  if (config.customComponents?.length) {
@@ -559,20 +550,15 @@ function MidenProvider({
559
550
  }),
560
551
  [config]
561
552
  );
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
- ]);
553
+ const defaultProver = useMemo(
554
+ () => resolveTransactionProver(resolvedConfig),
555
+ [
556
+ resolvedConfig.prover,
557
+ resolvedConfig.proverTimeoutMs,
558
+ resolvedConfig.proverUrls?.devnet,
559
+ resolvedConfig.proverUrls?.testnet
560
+ ]
561
+ );
576
562
  const runExclusive = useCallback(
577
563
  async (fn) => clientLockRef.current.runExclusive(fn),
578
564
  []
@@ -1807,10 +1793,7 @@ function useSyncState() {
1807
1793
 
1808
1794
  // src/hooks/useCreateWallet.ts
1809
1795
  import { useCallback as useCallback9, useState as useState7 } from "react";
1810
- import {
1811
- AccountStorageMode,
1812
- resolveAuthScheme
1813
- } from "@miden-sdk/miden-sdk";
1796
+ import { AccountStorageMode } from "@miden-sdk/miden-sdk";
1814
1797
 
1815
1798
  // src/utils/runExclusive.ts
1816
1799
  var runExclusiveDirect = async (fn) => fn();
@@ -1835,9 +1818,7 @@ function useCreateWallet() {
1835
1818
  options.storageMode ?? DEFAULTS.STORAGE_MODE
1836
1819
  );
1837
1820
  const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
1838
- const authScheme = resolveAuthScheme(
1839
- options.authScheme ?? DEFAULTS.AUTH_SCHEME
1840
- );
1821
+ const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
1841
1822
  const newWallet = await runExclusiveSafe(async () => {
1842
1823
  const createdWallet = await client.newWallet(
1843
1824
  storageMode,
@@ -1890,10 +1871,7 @@ function getStorageMode(mode) {
1890
1871
 
1891
1872
  // src/hooks/useCreateFaucet.ts
1892
1873
  import { useCallback as useCallback10, useState as useState8 } from "react";
1893
- import {
1894
- AccountStorageMode as AccountStorageMode2,
1895
- resolveAuthScheme as resolveAuthScheme2
1896
- } from "@miden-sdk/miden-sdk";
1874
+ import { AccountStorageMode as AccountStorageMode2 } from "@miden-sdk/miden-sdk";
1897
1875
  function useCreateFaucet() {
1898
1876
  const { client, isReady, runExclusive } = useMiden();
1899
1877
  const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
@@ -1913,9 +1891,7 @@ function useCreateFaucet() {
1913
1891
  options.storageMode ?? DEFAULTS.STORAGE_MODE
1914
1892
  );
1915
1893
  const decimals = options.decimals ?? DEFAULTS.FAUCET_DECIMALS;
1916
- const authScheme = resolveAuthScheme2(
1917
- options.authScheme ?? DEFAULTS.AUTH_SCHEME
1918
- );
1894
+ const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
1919
1895
  const newFaucet = await runExclusiveSafe(async () => {
1920
1896
  const createdFaucet = await client.newFaucet(
1921
1897
  storageMode,
@@ -1970,7 +1946,7 @@ function getStorageMode2(mode) {
1970
1946
 
1971
1947
  // src/hooks/useImportAccount.ts
1972
1948
  import { useCallback as useCallback11, useState as useState9 } from "react";
1973
- import { AccountFile, resolveAuthScheme as resolveAuthScheme3 } from "@miden-sdk/miden-sdk";
1949
+ import { AccountFile } from "@miden-sdk/miden-sdk";
1974
1950
 
1975
1951
  // src/utils/errors.ts
1976
1952
  var MidenError = class extends Error {
@@ -2103,9 +2079,7 @@ function useImportAccount() {
2103
2079
  }
2104
2080
  case "seed": {
2105
2081
  const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
2106
- const authScheme = resolveAuthScheme3(
2107
- options.authScheme ?? DEFAULTS.AUTH_SCHEME
2108
- );
2082
+ const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
2109
2083
  return await client.importPublicAccountFromSeed(
2110
2084
  options.seed,
2111
2085
  mutable,
@@ -2297,7 +2271,7 @@ function useSend() {
2297
2271
  );
2298
2272
  txRequest = new TransactionRequestBuilder().withOwnOutputNotes(new NoteArray([note])).build();
2299
2273
  } else {
2300
- txRequest = client.newSendTransactionRequest(
2274
+ txRequest = await client.newSendTransactionRequest(
2301
2275
  fromAccountId,
2302
2276
  toAccountId,
2303
2277
  assetIdObj,
@@ -2314,7 +2288,7 @@ function useSend() {
2314
2288
  const proverConfig = useMidenStore.getState().config;
2315
2289
  const provenTransaction = await proveWithFallback(
2316
2290
  (resolvedProver) => runExclusiveSafe(
2317
- () => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
2291
+ () => client.proveTransaction(txResult, resolvedProver)
2318
2292
  ),
2319
2293
  proverConfig
2320
2294
  );
@@ -2466,7 +2440,7 @@ function useMultiSend() {
2466
2440
  const proverConfig = useMidenStore.getState().config;
2467
2441
  const provenTransaction = await proveWithFallback(
2468
2442
  (resolvedProver) => runExclusiveDirect(
2469
- () => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
2443
+ () => client.proveTransaction(txResult, resolvedProver)
2470
2444
  ),
2471
2445
  proverConfig
2472
2446
  );
@@ -2632,7 +2606,7 @@ function useMint() {
2632
2606
  const faucetIdObj = parseAccountId(options.faucetId);
2633
2607
  setStage("proving");
2634
2608
  const txResult = await runExclusiveSafe(async () => {
2635
- const txRequest = client.newMintTransactionRequest(
2609
+ const txRequest = await client.newMintTransactionRequest(
2636
2610
  targetAccountIdObj,
2637
2611
  faucetIdObj,
2638
2612
  noteType,
@@ -2738,12 +2712,6 @@ function useConsume() {
2738
2712
  }
2739
2713
  }
2740
2714
  const notes = resolved;
2741
- if (notes.length === 0) {
2742
- throw new Error("No notes found for provided IDs");
2743
- }
2744
- if (notes.length !== options.notes.length) {
2745
- throw new Error("Some notes could not be found for provided IDs");
2746
- }
2747
2715
  const txRequest = client.newConsumeTransactionRequest(notes);
2748
2716
  const txId = prover ? await client.submitNewTransactionWithProver(
2749
2717
  accountIdObj,
@@ -2810,7 +2778,7 @@ function useSwap() {
2810
2778
  const requestedFaucetIdObj = parseAccountId(options.requestedFaucetId);
2811
2779
  setStage("proving");
2812
2780
  const txResult = await runExclusiveSafe(async () => {
2813
- const txRequest = client.newSwapTransactionRequest(
2781
+ const txRequest = await client.newSwapTransactionRequest(
2814
2782
  accountIdObj,
2815
2783
  offeredFaucetIdObj,
2816
2784
  BigInt(options.offeredAmount),
@@ -2937,7 +2905,7 @@ function useTransaction() {
2937
2905
  const proverConfig = useMidenStore.getState().config;
2938
2906
  const provenTransaction = await proveWithFallback(
2939
2907
  (resolvedProver) => runExclusiveSafe(
2940
- () => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
2908
+ () => client.proveTransaction(txResult, resolvedProver)
2941
2909
  ),
2942
2910
  proverConfig
2943
2911
  );
@@ -3121,10 +3089,7 @@ function useCompile() {
3121
3089
 
3122
3090
  // src/hooks/useSessionAccount.ts
3123
3091
  import { useCallback as useCallback22, useEffect as useEffect9, useRef as useRef8, useState as useState17 } from "react";
3124
- import {
3125
- AccountStorageMode as AccountStorageMode3,
3126
- resolveAuthScheme as resolveAuthScheme4
3127
- } from "@miden-sdk/miden-sdk";
3092
+ import { AccountStorageMode as AccountStorageMode3 } from "@miden-sdk/miden-sdk";
3128
3093
  function useSessionAccount(options) {
3129
3094
  const { client, isReady, sync } = useMiden();
3130
3095
  const setAccounts = useMidenStore((state) => state.setAccounts);
@@ -3138,9 +3103,7 @@ function useSessionAccount(options) {
3138
3103
  const maxWaitMs = options.maxWaitMs ?? 6e4;
3139
3104
  const storageMode = options.walletOptions?.storageMode ?? "public";
3140
3105
  const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
3141
- const authScheme = resolveAuthScheme4(
3142
- options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME
3143
- );
3106
+ const authScheme = options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME;
3144
3107
  const fundRef = useRef8(options.fund);
3145
3108
  fundRef.current = options.fund;
3146
3109
  useEffect9(() => {
@@ -3291,7 +3254,7 @@ function useExportStore() {
3291
3254
  setIsExporting(true);
3292
3255
  setError(null);
3293
3256
  try {
3294
- const storeName = client.storeIdentifier();
3257
+ const storeName = await client.storeIdentifier();
3295
3258
  const snapshot = await runExclusive(() => sdkExportStore(storeName));
3296
3259
  return snapshot;
3297
3260
  } catch (err) {
@@ -3617,9 +3580,11 @@ export {
3617
3580
  concatBytes,
3618
3581
  createMidenStorage,
3619
3582
  createNoteAttachment,
3583
+ ensureAccountBech32,
3620
3584
  formatAssetAmount,
3621
3585
  formatNoteSummary,
3622
3586
  getNoteSummary,
3587
+ installAccountBech32,
3623
3588
  migrateStorage,
3624
3589
  normalizeAccountId,
3625
3590
  parseAssetAmount,
package/package.json CHANGED
@@ -1,59 +1,50 @@
1
1
  {
2
2
  "name": "@miden-sdk/react",
3
- "version": "0.14.5",
3
+ "version": "0.15.0-alpha.4",
4
4
  "description": "React hooks library for Miden Web Client",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
10
+ "import": {
11
+ "types": "./dist/index.d.mts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
13
18
  },
14
- "./lazy": {
15
- "types": "./dist/lazy.d.ts",
16
- "import": "./dist/lazy.mjs",
17
- "require": "./dist/lazy.js"
18
- }
19
+ "./package.json": "./package.json"
19
20
  },
20
21
  "files": [
21
22
  "dist",
22
23
  "README.md",
23
24
  "CLAUDE.md"
24
25
  ],
25
- "scripts": {
26
- "build": "tsup",
27
- "dev": "tsup --watch",
28
- "lint": "eslint src",
29
- "typecheck": "tsc --noEmit",
30
- "test": "VITE_CJS_IGNORE_WARNING=1 vitest run",
31
- "test:unit": "VITE_CJS_IGNORE_WARNING=1 vitest run",
32
- "test:integration": "yarn build && playwright test",
33
- "test:all": "VITE_CJS_IGNORE_WARNING=1 vitest run && playwright test"
34
- },
35
26
  "peerDependencies": {
36
- "@miden-sdk/miden-sdk": "^0.14.5",
27
+ "@miden-sdk/miden-sdk": "^0.15.0-alpha.4",
37
28
  "react": ">=18.0.0"
38
29
  },
39
30
  "dependencies": {
40
31
  "zustand": "^5.0.0"
41
32
  },
42
33
  "devDependencies": {
43
- "@miden-sdk/miden-sdk": "file:../../crates/web-client",
44
34
  "@playwright/test": "^1.55.0",
45
35
  "@testing-library/react": "^14.0.0",
46
36
  "@types/react": "^18.2.0",
47
- "@typescript-eslint/eslint-plugin": "^6.0.0",
48
- "@typescript-eslint/parser": "^6.0.0",
49
- "eslint": "^8.0.0",
50
- "http-server": "^14.1.1",
37
+ "@typescript-eslint/eslint-plugin": "^8.25.0",
38
+ "@typescript-eslint/parser": "^8.25.0",
39
+ "@vitest/coverage-v8": "^3.0.0",
40
+ "eslint": "^9.30.1",
51
41
  "jsdom": "^24.0.0",
52
42
  "react": "^18.2.0",
53
43
  "react-dom": "^18.2.0",
54
44
  "tsup": "^8.0.0",
55
45
  "typescript": "^5.0.0",
56
- "vitest": "^1.0.0"
46
+ "vitest": "^3.0.0",
47
+ "@miden-sdk/miden-sdk": "0.15.0-alpha.4"
57
48
  },
58
49
  "keywords": [
59
50
  "miden",
@@ -67,16 +58,20 @@
67
58
  "license": "MIT",
68
59
  "repository": {
69
60
  "type": "git",
70
- "url": "https://github.com/0xMiden/miden-client"
61
+ "url": "https://github.com/0xMiden/web-sdk"
71
62
  },
72
63
  "bugs": {
73
- "url": "https://github.com/0xMiden/miden-client/issues"
64
+ "url": "https://github.com/0xMiden/web-sdk/issues"
74
65
  },
75
- "resolutions": {
76
- "@isaacs/brace-expansion": ">=5.0.1",
77
- "esbuild": ">=0.25.0",
78
- "minimatch": ">=10.2.1",
79
- "rollup": ">=4.59.0",
80
- "qs": ">=6.15.0"
66
+ "scripts": {
67
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
68
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
69
+ "lint": "eslint src",
70
+ "typecheck": "tsc --noEmit",
71
+ "test": "VITE_CJS_IGNORE_WARNING=1 vitest run",
72
+ "test:unit": "VITE_CJS_IGNORE_WARNING=1 vitest run",
73
+ "test:coverage": "VITE_CJS_IGNORE_WARNING=1 vitest run --coverage",
74
+ "test:integration": "pnpm build && playwright test",
75
+ "test:all": "VITE_CJS_IGNORE_WARNING=1 vitest run && playwright test"
81
76
  }
82
- }
77
+ }