@miden-sdk/create-miden-para-react 0.10.10 → 0.13.1

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/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # @miden-sdk/create-miden-para-react
2
2
 
3
- `npm create @miden-sdk/miden-para-react@latest my-app` scaffolds the latest Vite `react-ts` starter, overwrites it with this repo's `vite.config.ts`, swaps in a Para + Miden-ready `App.tsx`, and adds the deps needed to run it out of the box. The scaffold always runs `create-vite` with `--yes --no-install` and pipes no to the install prompt to prevent upstream installs from overwriting the template before we patch it.
3
+ `npm create @miden-sdk/miden-para-react@latest my-app` scaffolds the latest Vite `react-ts` starter, overwrites it with this repo's `vite.config.ts`, swaps in a Para + Miden-ready `App.tsx`, and adds the deps needed to run it out of the box. The scaffold always runs `create-vite` with `--yes --no-install` and pipes "no" to the install prompt to prevent upstream installs from overwriting the template before we patch it.
4
4
 
5
5
  ## What it does
6
6
  - Runs `npm create vite@latest <target> -- --template react-ts` so you always start from the upstream default.
7
7
  - Replaces `vite.config.ts` with the Para + Miden-friendly config (dedupe/exclude and WASM asset handling).
8
- - Replaces `src/App.tsx` with a ParaProvider + `useParaMiden` starter that reports the account ID and client readiness.
9
- - Adds Para/Miden + connector deps (matching `examples/react`) so Para SDK peers resolve: `@miden-sdk/miden-para`, `@miden-sdk/use-miden-para-react`, `@getpara/react-sdk-lite`, `@getpara/evm-wallet-connectors`, `@demox-labs/miden-sdk`, `@tanstack/react-query`, `@wagmi/core`, `viem`, `wagmi`, plus dev plugins `vite-plugin-node-polyfills`, `vite-plugin-wasm`, and `vite-plugin-top-level-await`.
10
- - Installs dependencies using your detected package manager (`pnpm`, `yarn`, `bun`, or falls back to `npm`); `create-vite` is invoked with `--yes --no-install` and auto-answers no to install prompts to avoid reverting the patched files.
11
- - Writes `.npmrc` with `legacy-peer-deps=true` so `npm install` works despite a known peer mismatch between `@miden-sdk/use-miden-para-react` and `@miden-sdk/miden-para`.
8
+ - Replaces `src/App.tsx` with a `ParaSignerProvider` + `MidenProvider` starter that reports wallet, account ID, and client readiness.
9
+ - Adds Para/Miden deps: `@miden-sdk/miden-para`, `@miden-sdk/react`, `@getpara/react-sdk-lite`, `@getpara/evm-wallet-connectors`, `@miden-sdk/miden-sdk`, plus dev plugins `vite-plugin-node-polyfills`, `vite-plugin-wasm`, and `vite-plugin-top-level-await`.
10
+ - Installs dependencies using your detected package manager (`pnpm`, `yarn`, `bun`, or falls back to `npm`); `create-vite` is invoked with `--yes --no-install` and auto-answers "no" to install prompts to avoid reverting the patched files.
11
+ - Writes `.npmrc` with `legacy-peer-deps=true` for peer dependency resolution.
12
12
  - Adds `src/polyfills.ts` and injects it into `src/main.tsx` to provide `Buffer`/`process` in the browser.
13
13
 
14
14
  ## Usage
@@ -27,8 +27,8 @@ const repoRoot = resolve(__dirname, "..", "..", "..");
27
27
  const localMidenParaPath =
28
28
  process.env.MIDEN_PARA_LOCAL_MIDEN_PARA_PATH ?? repoRoot;
29
29
  const localUseMidenParaReactPath =
30
- process.env.MIDEN_PARA_LOCAL_USE_PARA_REACT_PATH ??
31
- resolve(repoRoot, "packages", "use-miden-para-react");
30
+ process.env.MIDEN_PARA_LOCAL_USE_MIDEN_PARA_REACT_PATH ??
31
+ join(repoRoot, "packages", "use-miden-para-react");
32
32
  const useLocalDeps = process.env.MIDEN_PARA_LOCAL_DEPS === "1";
33
33
 
34
34
  const args = process.argv.slice(2);
@@ -211,22 +211,20 @@ function ensureMidenParaDependencies(targetRoot) {
211
211
  pkg.scripts = pkg.scripts ?? {};
212
212
  const midenParaVersion = useLocalDeps
213
213
  ? `file:${localMidenParaPath}`
214
- : "0.10.10";
214
+ : "0.13.1";
215
215
  const useMidenParaReactVersion = useLocalDeps
216
216
  ? `file:${localUseMidenParaReactPath}`
217
- : "^0.10.10";
218
- // Align with examples/react so Para SDK connector peers are satisfied
217
+ : "^0.13.0";
218
+ // Align with examples/react-signer so Para SDK connector peers are satisfied
219
219
  Object.assign(pkg.dependencies, {
220
220
  ...pkg.dependencies,
221
- "@getpara/react-sdk-lite": "2.0.0-alpha.73",
222
- "@getpara/evm-wallet-connectors": "^2.3.0",
223
- "@tanstack/react-query": "^5.90.12",
224
- "@wagmi/core": "^3.0.0",
225
- "@demox-labs/miden-sdk": "^0.12.5",
221
+ "@getpara/react-sdk-lite": "^2.2.0",
222
+ "@getpara/evm-wallet-connectors": "^2.2.0",
223
+ "@miden-sdk/miden-sdk": "^0.13.0",
226
224
  "@miden-sdk/miden-para": midenParaVersion,
227
225
  "@miden-sdk/use-miden-para-react": useMidenParaReactVersion,
228
- viem: "^2.41.2",
229
- wagmi: "^3.1.0",
226
+ "@miden-sdk/react": "^0.13.1",
227
+ "@tanstack/react-query": "^5.0.0",
230
228
  });
231
229
 
232
230
  Object.assign(pkg.devDependencies, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miden-sdk/create-miden-para-react",
3
- "version": "0.10.10",
3
+ "version": "0.13.1",
4
4
  "description": "Create a Vite react-ts app preconfigured with Miden + Para's Vite setup",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,42 +1,45 @@
1
1
  import './App.css';
2
2
  import '@getpara/react-sdk-lite/styles.css';
3
- import { ParaProvider, useAccount, useModal } from '@getpara/react-sdk-lite';
4
- import { useParaMiden } from '@miden-sdk/use-miden-para-react';
5
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
6
-
7
- const queryClient = new QueryClient();
3
+ import { ParaSignerProvider, useParaSigner } from '@miden-sdk/use-miden-para-react';
4
+ import { MidenProvider, useSigner, useMiden } from '@miden-sdk/react';
8
5
 
9
6
  function App() {
10
7
  return (
11
- <QueryClientProvider client={queryClient}>
12
- <ParaProvider
13
- paraClientConfig={{
14
- apiKey: import.meta.env.VITE_PARA_API_KEY,
15
- }}
16
- config={{ appName: 'Starter for MidenxPara' }}
17
- >
8
+ <ParaSignerProvider
9
+ apiKey={import.meta.env.VITE_PARA_API_KEY}
10
+ environment="BETA"
11
+ appName="Starter for MidenxPara"
12
+ >
13
+ <MidenProvider config={{ rpcUrl: 'testnet' }}>
18
14
  <Content />
19
- </ParaProvider>
20
- </QueryClientProvider>
15
+ </MidenProvider>
16
+ </ParaSignerProvider>
21
17
  );
22
18
  }
23
19
 
24
20
  function Content() {
25
- const { client, accountId, para } = useParaMiden(
26
- 'https://rpc.testnet.miden.io'
27
- );
28
- const { isConnected } = useAccount();
29
- const { openModal } = useModal();
21
+ const signer = useSigner();
22
+ const { wallet } = useParaSigner();
23
+ const { isReady, signerAccountId } = useMiden();
24
+
25
+ const handleConnect = async () => {
26
+ if (signer?.isConnected) {
27
+ await signer.disconnect();
28
+ } else {
29
+ await signer?.connect();
30
+ }
31
+ };
30
32
 
31
33
  return (
32
34
  <div>
33
- <button onClick={() => (isConnected ? para?.logout() : openModal?.())}>
34
- {isConnected ? 'Disconnect Para' : 'Connect with Para'}
35
+ <button onClick={handleConnect}>
36
+ {signer?.isConnected ? 'Disconnect Para' : 'Connect with Para'}
35
37
  </button>
36
- {isConnected && (
38
+ {signer?.isConnected && (
37
39
  <>
38
- <p>Account: {accountId ?? '—'}</p>
39
- <p>Client ready: {client ? 'yes' : 'no'}</p>
40
+ <p>Wallet: {wallet?.address ?? '—'}</p>
41
+ <p>Account: {signerAccountId ?? ''}</p>
42
+ <p>Client ready: {isReady ? 'yes' : 'no'}</p>
40
43
  </>
41
44
  )}
42
45
  </div>
@@ -3,19 +3,37 @@ import react from '@vitejs/plugin-react';
3
3
  import { nodePolyfills } from 'vite-plugin-node-polyfills';
4
4
  import wasm from 'vite-plugin-wasm';
5
5
  import topLevelAwait from 'vite-plugin-top-level-await';
6
- import path from 'path';
7
- import { fileURLToPath } from 'url';
8
6
 
9
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
- const optionalConnectorsPath = path.resolve(
11
- __dirname,
12
- 'src',
13
- 'optional-connectors.ts'
14
- );
7
+ // Optional connector families that are never imported by the starter template.
8
+ // Alias them to an empty module so Vite doesn't try to resolve their deps.
9
+ const optionalPackages = [
10
+ '@getpara/solana-wallet-connectors',
11
+ '@getpara/cosmos-wallet-connectors',
12
+ '@getpara/wagmi-v2-connector',
13
+ 'wagmi',
14
+ '@wagmi/core',
15
+ '@wagmi/connectors',
16
+ ];
17
+
18
+ // Mark any import whose bare specifier starts with an optional package
19
+ // (including subpath imports like "wagmi/connectors") as external so
20
+ // Rollup skips them entirely. These code paths are never reached at runtime.
21
+ function externalizeOptionalPackages() {
22
+ return {
23
+ name: 'externalize-optional-packages',
24
+ enforce: 'pre' as const,
25
+ resolveId(id: string) {
26
+ if (optionalPackages.some((pkg) => id === pkg || id.startsWith(pkg + '/'))) {
27
+ return { id, external: true };
28
+ }
29
+ },
30
+ };
31
+ }
15
32
 
16
33
  // Keep the miden SDK unbundled so its WASM asset path stays valid in dev.
17
34
  export default defineConfig({
18
35
  plugins: [
36
+ externalizeOptionalPackages(),
19
37
  wasm(),
20
38
  topLevelAwait(),
21
39
  react(),
@@ -27,9 +45,8 @@ export default defineConfig({
27
45
  // Keep Miden SDK unbundled and avoid prebundling Para's Stencil component bundles
28
46
  // to prevent multiple runtimes in dev.
29
47
  exclude: [
30
- '@demox-labs/miden-sdk',
31
- '@getpara/solana-wallet-connectors',
32
- '@getpara/cosmos-wallet-connectors',
48
+ '@miden-sdk/miden-sdk',
49
+ ...optionalPackages,
33
50
  ],
34
51
  esbuildOptions: {
35
52
  target: 'esnext',
@@ -37,22 +54,12 @@ export default defineConfig({
37
54
  },
38
55
  build: {
39
56
  target: 'esnext',
40
- rollupOptions: {
41
- external: [
42
- '@getpara/solana-wallet-connectors',
43
- '@getpara/cosmos-wallet-connectors',
44
- ],
45
- },
46
57
  },
47
58
  worker: {
48
59
  format: 'es',
49
60
  },
50
61
  resolve: {
51
- dedupe: ['@getpara/web-sdk', '@getpara/react-sdk-lite'],
52
- alias: {
53
- '@getpara/solana-wallet-connectors': optionalConnectorsPath,
54
- '@getpara/cosmos-wallet-connectors': optionalConnectorsPath,
55
- },
62
+ dedupe: ['@getpara/web-sdk', '@getpara/react-sdk-lite', 'react', 'react-dom'],
56
63
  },
57
64
  // Ensure Vite treats wasm as a static asset with the correct MIME type.
58
65
  assetsInclude: ['**/*.wasm'],