create-miden-app 1.0.6 → 1.0.7
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/package.json +1 -1
- package/template/.claude/commands/review-security.md +67 -0
- package/template/.claude/settings.json +1 -7
- package/template/.claude/settings.local.json +24 -0
- package/template/.claude/skills/frontend-pitfalls/SKILL.md +28 -31
- package/template/.claude/skills/frontend-source-guide/SKILL.md +14 -14
- package/template/.claude/skills/miden-concepts/SKILL.md +4 -2
- package/template/.claude/skills/react-sdk-patterns/SKILL.md +294 -28
- package/template/.claude/skills/signer-integration/SKILL.md +22 -3
- package/template/.claude/skills/testing-patterns/SKILL.md +201 -40
- package/template/.claude/skills/vite-wasm-setup/SKILL.md +20 -14
- package/template/.claude/skills/web-client-usage/SKILL.md +454 -0
- package/template/.env.example +15 -2
- package/template/.mcp.json +9 -0
- package/template/CLAUDE.md +49 -16
- package/template/README.md +85 -19
- package/template/package.json +5 -4
- package/template/public/packages/counter_account.masp +0 -0
- package/template/public/packages/increment_note.masp +0 -0
- package/template/src/__tests__/fixtures/accounts.ts +17 -6
- package/template/src/__tests__/fixtures/index.ts +1 -0
- package/template/src/__tests__/mocks/miden-sdk-react.ts +18 -1
- package/template/src/__tests__/patterns/mutation-hook.test.tsx +2 -2
- package/template/src/__tests__/patterns/provider-setup.test.tsx +2 -0
- package/template/src/components/AppContent.tsx +33 -3
- package/template/{create-miden-app/template/src/components/Counter.tsx → src/components/ConfiguredCounter.tsx} +7 -4
- package/template/src/components/Counter.tsx +12 -41
- package/template/src/components/__tests__/AppContent.test.tsx +192 -4
- package/template/src/components/__tests__/ConfiguredCounter.test.tsx +116 -0
- package/template/src/components/__tests__/Counter.test.tsx +24 -94
- package/template/src/config.ts +26 -6
- package/template/src/hooks/__tests__/useIncrementCounter.test.tsx +257 -0
- package/template/src/hooks/useIncrementCounter.ts +109 -50
- package/template/src/providers.tsx +20 -24
- package/template/vite.config.ts +1 -1
- package/template/vitest.config.ts +1 -2
- package/template/yarn.lock +761 -688
- package/template/create-miden-app/template/.claude/hooks/typecheck.sh +0 -27
- package/template/create-miden-app/template/.claude/settings.json +0 -17
- package/template/create-miden-app/template/.claude/skills/frontend-pitfalls/SKILL.md +0 -189
- package/template/create-miden-app/template/.claude/skills/frontend-source-guide/SKILL.md +0 -163
- package/template/create-miden-app/template/.claude/skills/miden-concepts/SKILL.md +0 -108
- package/template/create-miden-app/template/.claude/skills/react-sdk-patterns/SKILL.md +0 -294
- package/template/create-miden-app/template/.claude/skills/signer-integration/SKILL.md +0 -158
- package/template/create-miden-app/template/.claude/skills/vite-wasm-setup/SKILL.md +0 -128
- package/template/create-miden-app/template/.env.example +0 -5
- package/template/create-miden-app/template/CLAUDE.md +0 -116
- package/template/create-miden-app/template/README.md +0 -61
- package/template/create-miden-app/template/eslint.config.js +0 -23
- package/template/create-miden-app/template/index.html +0 -13
- package/template/create-miden-app/template/package.json +0 -34
- package/template/create-miden-app/template/public/vite.svg +0 -1
- package/template/create-miden-app/template/src/App.tsx +0 -10
- package/template/create-miden-app/template/src/assets/miden.svg +0 -3
- package/template/create-miden-app/template/src/assets/react.svg +0 -1
- package/template/create-miden-app/template/src/components/AppContent.css +0 -45
- package/template/create-miden-app/template/src/components/AppContent.tsx +0 -50
- package/template/create-miden-app/template/src/components/Counter.css +0 -27
- package/template/create-miden-app/template/src/config.ts +0 -21
- package/template/create-miden-app/template/src/hooks/useIncrementCounter.ts +0 -136
- package/template/create-miden-app/template/src/index.css +0 -75
- package/template/create-miden-app/template/src/lib/miden.ts +0 -9
- package/template/create-miden-app/template/src/main.tsx +0 -10
- package/template/create-miden-app/template/src/providers.tsx +0 -31
- package/template/create-miden-app/template/src/vite-env.d.ts +0 -1
- package/template/create-miden-app/template/tsconfig.app.json +0 -32
- package/template/create-miden-app/template/tsconfig.json +0 -7
- package/template/create-miden-app/template/tsconfig.node.json +0 -24
- package/template/create-miden-app/template/vite.config.ts +0 -17
- package/template/create-miden-app/template/yarn.lock +0 -1697
package/package.json
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: opus
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You are a security-focused code reviewer specializing in web3, WASM, and TypeScript/Rust applications.
|
|
6
|
+
|
|
7
|
+
Review the code at: $ARGUMENTS
|
|
8
|
+
|
|
9
|
+
This can be a file, directory, or glob pattern. Read the relevant source files and perform a focused security audit across these dimensions, reporting only actual findings (skip any section with no issues):
|
|
10
|
+
|
|
11
|
+
## 1. Input Validation & Injection
|
|
12
|
+
- Are user-supplied strings (hex IDs, bech32 addresses, amounts) validated before being passed to WASM/Rust?
|
|
13
|
+
- Can malformed input cause panics in Rust that propagate as unhandled exceptions in JS?
|
|
14
|
+
- Are there any paths where unsanitized input reaches sensitive operations (key derivation, transaction building)?
|
|
15
|
+
- Could numeric inputs overflow (e.g., BigInt conversion from plain numbers)?
|
|
16
|
+
|
|
17
|
+
## 2. Key Material & Secrets
|
|
18
|
+
- Is key material ever logged, serialized to JSON, or exposed in error messages?
|
|
19
|
+
- Are private keys properly zeroed after use or held only in WASM memory?
|
|
20
|
+
- Could keystore callbacks leak secrets through exception messages or stack traces?
|
|
21
|
+
- Is seed material handled securely (not stored in localStorage, not logged)?
|
|
22
|
+
|
|
23
|
+
## 3. Transaction Safety
|
|
24
|
+
- Can transaction parameters be manipulated to send to unintended recipients?
|
|
25
|
+
- Are there TOCTOU (time-of-check-time-of-use) issues between building and submitting transactions?
|
|
26
|
+
- Could amount values be manipulated through type coercion (string→number precision loss)?
|
|
27
|
+
- Are note IDs validated to prevent consuming the wrong notes?
|
|
28
|
+
|
|
29
|
+
## 4. WASM Boundary
|
|
30
|
+
- Are there memory safety issues at the JS↔WASM boundary?
|
|
31
|
+
- Could JsValue conversions fail in ways that leave state inconsistent?
|
|
32
|
+
- Are WASM errors properly caught or could they crash the runtime?
|
|
33
|
+
- Is there potential for use-after-free when JS holds references to WASM objects?
|
|
34
|
+
|
|
35
|
+
## 5. State & Storage
|
|
36
|
+
- Is IndexedDB data integrity protected (could concurrent tabs corrupt state)?
|
|
37
|
+
- Are there race conditions in async operations that could lead to double-spends or stale reads?
|
|
38
|
+
- Could store export/import be used to replay old state maliciously?
|
|
39
|
+
- Are database transactions (Dexie) used appropriately for atomic operations?
|
|
40
|
+
|
|
41
|
+
## 6. Network & RPC
|
|
42
|
+
- Are RPC responses validated before being trusted?
|
|
43
|
+
- Could a malicious RPC endpoint feed incorrect block data or note metadata?
|
|
44
|
+
- Is TLS enforced for RPC and prover connections?
|
|
45
|
+
- Are there timing side-channels in how responses are processed?
|
|
46
|
+
|
|
47
|
+
## 7. Supply Chain & Dependencies
|
|
48
|
+
- Are there known vulnerable dependencies?
|
|
49
|
+
- Are lockfile integrity hashes (`package-lock.json` / `yarn.lock` / `pnpm-lock.yaml`) unchanged when WASM-bundled dependencies (e.g. `@miden-sdk/*`) update?
|
|
50
|
+
- Could wasm-bindgen-generated glue code introduce issues?
|
|
51
|
+
|
|
52
|
+
## Output Format
|
|
53
|
+
|
|
54
|
+
For each finding, use severity levels:
|
|
55
|
+
- **[CRITICAL]** - Exploitable vulnerability that could cause loss of funds or key compromise
|
|
56
|
+
- **[HIGH]** - Security issue that should be fixed before production use
|
|
57
|
+
- **[MEDIUM]** - Weakness that could be exploited under specific conditions
|
|
58
|
+
- **[LOW]** - Defense-in-depth improvement
|
|
59
|
+
- **[INFO]** - Observation worth noting but not directly exploitable
|
|
60
|
+
|
|
61
|
+
For each finding include:
|
|
62
|
+
1. File and line number
|
|
63
|
+
2. Description of the vulnerability
|
|
64
|
+
3. Attack scenario (how it could be exploited)
|
|
65
|
+
4. Recommended fix
|
|
66
|
+
|
|
67
|
+
End with a summary: count of findings by severity, and the top 3 highest-priority items to address.
|
|
@@ -15,13 +15,7 @@
|
|
|
15
15
|
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/run-affected-tests.sh",
|
|
16
16
|
"timeout": 120,
|
|
17
17
|
"statusMessage": "Running affected tests..."
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"Stop": [
|
|
23
|
-
{
|
|
24
|
-
"hooks": [
|
|
18
|
+
},
|
|
25
19
|
{
|
|
26
20
|
"type": "command",
|
|
27
21
|
"command": "cd \"$CLAUDE_PROJECT_DIR\" && npx vitest --run && npx tsc -b --noEmit && npx vite build",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"WebFetch(domain:github.com)",
|
|
5
|
+
"WebFetch(domain:api.github.com)",
|
|
6
|
+
"mcp__playwright__browser_navigate",
|
|
7
|
+
"mcp__playwright__browser_console_messages",
|
|
8
|
+
"mcp__playwright__browser_take_screenshot",
|
|
9
|
+
"WebFetch(domain:registry.npmjs.org)",
|
|
10
|
+
"mcp__playwright__browser_wait_for",
|
|
11
|
+
"mcp__playwright__browser_snapshot",
|
|
12
|
+
"mcp__playwright__browser_evaluate",
|
|
13
|
+
"WebFetch(domain:rpc.testnet.miden.io)",
|
|
14
|
+
"WebFetch(domain:testnet.midenscan.com)",
|
|
15
|
+
"WebFetch(domain:transport.miden.io)",
|
|
16
|
+
"mcp__playwright__browser_close",
|
|
17
|
+
"WebFetch(domain:scan-backend-testnet-miden.eu-central-8.gateway.fm)",
|
|
18
|
+
"WebFetch(domain:transport.devnet.miden.io)",
|
|
19
|
+
"WebFetch(domain:tx-prover.testnet.miden.io)",
|
|
20
|
+
"WebFetch(domain:registry.yarnpkg.com)",
|
|
21
|
+
"mcp__playwright__browser_network_requests"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -18,7 +18,7 @@ function App() {
|
|
|
18
18
|
|
|
19
19
|
// CORRECT — use loadingComponent or check isReady
|
|
20
20
|
<MidenProvider
|
|
21
|
-
config={{ rpcUrl: "
|
|
21
|
+
config={{ rpcUrl: "testnet" }}
|
|
22
22
|
loadingComponent={<p>Loading WASM...</p>}
|
|
23
23
|
>
|
|
24
24
|
<App />
|
|
@@ -44,8 +44,9 @@ const handleClick = async () => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// CORRECT — use runExclusive for sequential execution
|
|
47
|
+
const client = useMidenClient();
|
|
47
48
|
const { runExclusive } = useMiden();
|
|
48
|
-
await runExclusive(async (
|
|
49
|
+
await runExclusive(async () => {
|
|
49
50
|
await client.syncState();
|
|
50
51
|
// now safe to do next operation
|
|
51
52
|
});
|
|
@@ -57,22 +58,22 @@ Built-in hooks (useSend, useConsume, etc.) already use runExclusive internally.
|
|
|
57
58
|
|
|
58
59
|
WASM SharedArrayBuffer requires these headers. Without them, WASM init silently fails.
|
|
59
60
|
|
|
61
|
+
The template's source-of-truth pattern is to opt into COOP/COEP via the Vite plugin explicitly:
|
|
62
|
+
|
|
60
63
|
```ts
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// ALSO REQUIRED on production server (nginx, Vercel, Cloudflare)
|
|
70
|
-
// See vite-wasm-setup skill for deployment configs
|
|
64
|
+
// vite.config.ts — template default
|
|
65
|
+
import { midenVitePlugin } from "@miden-sdk/vite-plugin";
|
|
66
|
+
|
|
67
|
+
export default defineConfig({
|
|
68
|
+
plugins: [react(), midenVitePlugin({ crossOriginIsolation: true })],
|
|
69
|
+
});
|
|
71
70
|
```
|
|
72
71
|
|
|
73
|
-
|
|
72
|
+
Do not rely on the plugin's own default — `@miden-sdk/vite-plugin` defaults `crossOriginIsolation` to `false`, and that default has shifted across releases. Pass `true` explicitly on any route that runs Miden client code.
|
|
73
|
+
|
|
74
|
+
COOP/COEP must also be set on the production server — the plugin only covers the Vite dev server. See `vite-wasm-setup` for per-host configs (Nginx, Vercel, Cloudflare).
|
|
74
75
|
|
|
75
|
-
**
|
|
76
|
+
**Gotcha (opt-out path)**: Cross-origin-isolation breaks third-party iframes, external scripts without CORS, and OAuth popups. If a route must host those and cannot use Miden client code, either (a) use `Cross-Origin-Embedder-Policy: credentialless` for weaker isolation that still allows most cross-origin resources, or (b) scope `crossOriginIsolation: false` to that specific route and accept that Miden operations won't work there. Do not disable isolation globally as a convenience.
|
|
76
77
|
|
|
77
78
|
## FP4: BigInt Type Mismatch (HIGH)
|
|
78
79
|
|
|
@@ -117,7 +118,7 @@ Default `autoSyncInterval` is 15000ms (15 seconds). Each sync triggers re-render
|
|
|
117
118
|
|
|
118
119
|
```tsx
|
|
119
120
|
// PROBLEM — form resets every 15 seconds because parent re-renders
|
|
120
|
-
<MidenProvider config={{ rpcUrl: "
|
|
121
|
+
<MidenProvider config={{ rpcUrl: "testnet" }}>
|
|
121
122
|
<SendForm /> {/* re-renders on every sync */}
|
|
122
123
|
</MidenProvider>
|
|
123
124
|
|
|
@@ -125,7 +126,7 @@ Default `autoSyncInterval` is 15000ms (15 seconds). Each sync triggers re-render
|
|
|
125
126
|
const MemoizedForm = React.memo(SendForm);
|
|
126
127
|
|
|
127
128
|
// SOLUTION 2 — disable auto-sync for manual control
|
|
128
|
-
<MidenProvider config={{ rpcUrl: "
|
|
129
|
+
<MidenProvider config={{ rpcUrl: "testnet", autoSyncInterval: 0 }}>
|
|
129
130
|
```
|
|
130
131
|
|
|
131
132
|
## FP7: IndexedDB State Loss (MEDIUM)
|
|
@@ -138,40 +139,36 @@ The client persists accounts, keys, and notes in IndexedDB. Browser "Clear site
|
|
|
138
139
|
|
|
139
140
|
## FP8: Vite Configuration Requirements (MEDIUM)
|
|
140
141
|
|
|
141
|
-
The `@miden-sdk/vite-plugin` package handles all Miden-specific Vite config.
|
|
142
|
-
The minimal setup is:
|
|
142
|
+
The `@miden-sdk/vite-plugin` package handles all Miden-specific Vite config. The template's source-of-truth pattern — which you should copy for any new Miden app — is:
|
|
143
143
|
|
|
144
144
|
```ts
|
|
145
145
|
import { midenVitePlugin } from "@miden-sdk/vite-plugin";
|
|
146
146
|
|
|
147
147
|
export default defineConfig({
|
|
148
|
-
plugins: [react(), midenVitePlugin()],
|
|
148
|
+
plugins: [react(), midenVitePlugin({ crossOriginIsolation: true })],
|
|
149
149
|
});
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
`midenVitePlugin()` handles
|
|
153
|
-
and optionally COOP/COEP headers (via the `crossOriginIsolation` option, defaults to `false`
|
|
154
|
-
to avoid breaking OAuth popups).
|
|
152
|
+
`midenVitePlugin()` handles WASM loading, top-level await, pre-bundling exclusion, and — when `crossOriginIsolation: true` is passed — emits the COOP `same-origin` + COEP `require-corp` headers the SDK requires for `SharedArrayBuffer`.
|
|
155
153
|
|
|
156
|
-
| Option |
|
|
157
|
-
|
|
158
|
-
| `crossOriginIsolation` | `false` |
|
|
154
|
+
| Option | Plugin default | Template default | Purpose |
|
|
155
|
+
|--------|----------------|------------------|---------|
|
|
156
|
+
| `crossOriginIsolation` | `false` | **`true`** | Emit COOP/COEP headers for SharedArrayBuffer |
|
|
159
157
|
|
|
160
|
-
|
|
161
|
-
For production COOP/COEP, set headers at the server level (see vite-wasm-setup skill).
|
|
158
|
+
Always pass `crossOriginIsolation: true` explicitly. The plugin's `false` default is wrong for a Miden app, and relying on it risks silent WASM-init failures if the default shifts in a future release. The opt-out path (routes that host OAuth popups or cross-origin iframes incompatible with isolation) is discussed in FP3. For production, set the same headers at the server level — see `vite-wasm-setup` for host-specific configs.
|
|
162
159
|
|
|
163
160
|
## FP9: React StrictMode Double-Init (LOW)
|
|
164
161
|
|
|
165
|
-
React 19 StrictMode double-invokes effects in development. MidenProvider handles this via `isInitializedRef`, but direct `
|
|
162
|
+
React 19 StrictMode double-invokes effects in development. MidenProvider handles this via `isInitializedRef`, but direct `WasmWebClient.createClient()` calls will initialize twice. (The SDK exports `WasmWebClient` as `WebClient` for convenience.)
|
|
166
163
|
|
|
167
164
|
```tsx
|
|
168
165
|
// WRONG — manual client creation in useEffect
|
|
169
166
|
useEffect(() => {
|
|
170
|
-
const client = await
|
|
167
|
+
const client = await WasmWebClient.createClient(url); // called twice in dev
|
|
171
168
|
}, []);
|
|
172
169
|
|
|
173
170
|
// CORRECT — always use MidenProvider
|
|
174
|
-
<MidenProvider config={{ rpcUrl: "
|
|
171
|
+
<MidenProvider config={{ rpcUrl: "testnet" }}>
|
|
175
172
|
```
|
|
176
173
|
|
|
177
174
|
## Quick Reference
|
|
@@ -185,5 +182,5 @@ useEffect(() => {
|
|
|
185
182
|
| FP5 | Bech32 mismatch | HIGH | Match network in rpcUrl and addresses |
|
|
186
183
|
| FP6 | Auto-sync | MEDIUM | Set autoSyncInterval: 0 if UI stability matters |
|
|
187
184
|
| FP7 | IndexedDB loss | MEDIUM | Warn users; use external signers for production |
|
|
188
|
-
| FP8 | Vite config | MEDIUM |
|
|
185
|
+
| FP8 | Vite config | MEDIUM | Always pass `midenVitePlugin({ crossOriginIsolation: true })` — don't rely on the plugin default |
|
|
189
186
|
| FP9 | StrictMode | LOW | Use MidenProvider, not manual client creation |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: frontend-source-guide
|
|
3
|
-
description: Guide for advanced Miden frontend development using source repo exploration. Covers AI development practices (Plan Mode, verification-driven development, context engineering, sub-agents) and maps the miden-client source repository for discovering advanced patterns. Use when building complex applications beyond basic hook usage, implementing custom signers, working with
|
|
3
|
+
description: Guide for advanced Miden frontend development using source repo exploration. Covers AI development practices (Plan Mode, verification-driven development, context engineering, sub-agents) and maps the miden-client source repository for discovering advanced patterns. Use when building complex applications beyond basic hook usage, implementing custom signers, working with WasmWebClient directly, or troubleshooting SDK internals.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Advanced Miden Frontend Development: Source-Guided Context Engineering
|
|
@@ -13,7 +13,7 @@ For any non-trivial frontend application, start in Plan Mode before writing code
|
|
|
13
13
|
|
|
14
14
|
- Explore React SDK source and examples to understand available patterns
|
|
15
15
|
- Design the component hierarchy, data flow, and which hooks to use
|
|
16
|
-
- Identify which built-in hooks cover your needs vs what requires
|
|
16
|
+
- Identify which built-in hooks cover your needs vs what requires direct WasmWebClient access
|
|
17
17
|
- Map out the user flow: account creation, token operations, note handling
|
|
18
18
|
|
|
19
19
|
Rule of thumb: if the task involves custom transactions, external signers, or patterns not covered by the basic skills, plan first.
|
|
@@ -70,7 +70,7 @@ When stuck at any stage: search the React SDK source for a similar working patte
|
|
|
70
70
|
Clone this repo alongside your project for reference. Claude will explore it when needed for advanced patterns.
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
|
-
# Contains React SDK source,
|
|
73
|
+
# Contains React SDK source, WasmWebClient WASM bindings, and working examples
|
|
74
74
|
git clone --depth 1 https://github.com/0xMiden/miden-client.git ../miden-client
|
|
75
75
|
```
|
|
76
76
|
|
|
@@ -92,10 +92,10 @@ The primary reference for all frontend development.
|
|
|
92
92
|
|
|
93
93
|
The Rust-to-WASM bridge that the React SDK wraps.
|
|
94
94
|
|
|
95
|
-
- Contains the `
|
|
95
|
+
- Contains the `WasmWebClient` struct and all methods available via `useMidenClient()`
|
|
96
96
|
- JavaScript bindings in `js/` directory
|
|
97
97
|
|
|
98
|
-
**Explore when**: A hook doesn't exist for your operation, understanding what
|
|
98
|
+
**Explore when**: A hook doesn't exist for your operation, understanding what WasmWebClient methods are available, debugging WASM-level errors.
|
|
99
99
|
|
|
100
100
|
### `crates/idxdb-store/` — IndexedDB Persistence
|
|
101
101
|
|
|
@@ -117,14 +117,14 @@ The browser storage layer for accounts, keys, notes, and transaction history.
|
|
|
117
117
|
| Token display | `src/utils/amounts.ts` | formatAssetAmount, parseAssetAmount |
|
|
118
118
|
| Account ID formatting | `src/utils/accountBech32.ts` | toBech32AccountId |
|
|
119
119
|
| State management | `src/store/MidenStore.ts` | Zustand selectors, cached state |
|
|
120
|
-
| Direct
|
|
120
|
+
| Direct WasmWebClient usage | `src/context/MidenProvider.tsx` | useMidenClient(), runExclusive |
|
|
121
121
|
| Multi-step workflow | `src/hooks/useWaitForCommit.ts`, `useWaitForNotes.ts` | Polling, timeout patterns |
|
|
122
122
|
|
|
123
123
|
---
|
|
124
124
|
|
|
125
125
|
## Common Advanced Patterns
|
|
126
126
|
|
|
127
|
-
### Custom Hooks Wrapping
|
|
127
|
+
### Custom Hooks Wrapping WasmWebClient
|
|
128
128
|
For operations not covered by built-in hooks, create custom hooks that use useMidenClient() and runExclusive:
|
|
129
129
|
```tsx
|
|
130
130
|
function useBlockHeader(blockNumber: number) {
|
|
@@ -146,16 +146,16 @@ function useBlockHeader(blockNumber: number) {
|
|
|
146
146
|
### Multi-Step Workflows
|
|
147
147
|
Compose hooks for complex flows (mint → wait for commit → sync → consume):
|
|
148
148
|
```tsx
|
|
149
|
-
const {
|
|
150
|
-
const {
|
|
151
|
-
const {
|
|
152
|
-
const {
|
|
149
|
+
const { mint } = useMint();
|
|
150
|
+
const { waitForCommit } = useWaitForCommit();
|
|
151
|
+
const { waitForConsumableNotes } = useWaitForNotes();
|
|
152
|
+
const { consume } = useConsume();
|
|
153
153
|
|
|
154
154
|
const mintAndConsume = async () => {
|
|
155
155
|
const { transactionId } = await mint({ targetAccountId, faucetId, amount });
|
|
156
|
-
await waitForCommit(
|
|
157
|
-
await
|
|
158
|
-
await consume({ accountId: targetAccountId,
|
|
156
|
+
await waitForCommit(transactionId);
|
|
157
|
+
await waitForConsumableNotes({ accountId: targetAccountId });
|
|
158
|
+
await consume({ accountId: targetAccountId, notes: [...] });
|
|
159
159
|
};
|
|
160
160
|
```
|
|
161
161
|
|
|
@@ -40,7 +40,7 @@ Accounts are composed from **components** — reusable Rust modules annotated wi
|
|
|
40
40
|
### Notes
|
|
41
41
|
Notes are **UTXO-like messages** for asynchronous inter-account communication. A note contains:
|
|
42
42
|
- **Script** — Logic that executes when the note is consumed
|
|
43
|
-
- **
|
|
43
|
+
- **Storage** — Data accessible to the script during execution (`NoteStorage`, Vec<Felt>)
|
|
44
44
|
- **Assets** — Fungible/non-fungible tokens attached to the note
|
|
45
45
|
- **Metadata** — Sender, tag, note type (public/private)
|
|
46
46
|
|
|
@@ -84,7 +84,9 @@ A transaction is a **single-account state transition** with 4 phases:
|
|
|
84
84
|
| `BasicWallet` | Standard wallet: `receive_asset()`, `move_asset_to_note()` |
|
|
85
85
|
| `BasicFungibleFaucet` | Mint/burn fungible tokens |
|
|
86
86
|
| `NoAuth` | No authentication (for testing) |
|
|
87
|
-
| `
|
|
87
|
+
| `AuthSingleSig` | Production signature authentication — unified auth component covering both Falcon-512 and ECDSA-K256 key types |
|
|
88
|
+
|
|
89
|
+
**v14 note**: `AuthSingleSig` unifies what were previously per-scheme auth components (one for Falcon-512, one for ECDSA-K256) into a single component that dispatches on the key type ([miden-client#1798](https://github.com/0xMiden/miden-client/pull/1798)). In the same release the underlying Falcon-512 signature scheme adopted Poseidon2 as its hash function, and is now named `Falcon512Poseidon2`. If you see the older per-scheme component names or the old signature-scheme name in examples or docs, the source predates 0.14 and needs updating.
|
|
88
90
|
|
|
89
91
|
## Development Model
|
|
90
92
|
|