create-miden-app 1.0.4 → 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.
Files changed (56) hide show
  1. package/cli.js +6 -6
  2. package/package.json +1 -1
  3. package/template/.claude/commands/review-security.md +67 -0
  4. package/template/.claude/hooks/check-artifacts.sh +45 -0
  5. package/template/.claude/hooks/run-affected-tests.sh +31 -0
  6. package/template/.claude/hooks/typecheck.sh +27 -0
  7. package/template/.claude/settings.json +29 -0
  8. package/template/.claude/settings.local.json +24 -0
  9. package/template/.claude/skills/frontend-pitfalls/SKILL.md +186 -0
  10. package/template/.claude/skills/frontend-source-guide/SKILL.md +163 -0
  11. package/template/.claude/skills/miden-concepts/SKILL.md +110 -0
  12. package/template/.claude/skills/react-sdk-patterns/SKILL.md +562 -0
  13. package/template/.claude/skills/signer-integration/SKILL.md +177 -0
  14. package/template/.claude/skills/testing-patterns/SKILL.md +338 -0
  15. package/template/.claude/skills/vite-wasm-setup/SKILL.md +134 -0
  16. package/template/.claude/skills/web-client-usage/SKILL.md +454 -0
  17. package/template/.env.example +18 -0
  18. package/template/.mcp.json +9 -0
  19. package/template/CLAUDE.md +243 -0
  20. package/template/README.md +119 -14
  21. package/template/index.html +1 -1
  22. package/template/package.json +18 -8
  23. package/template/public/packages/counter_account.masp +0 -0
  24. package/template/public/packages/increment_note.masp +0 -0
  25. package/template/src/App.tsx +6 -59
  26. package/template/src/__tests__/fixtures/accounts.ts +68 -0
  27. package/template/src/__tests__/fixtures/index.ts +22 -0
  28. package/template/src/__tests__/fixtures/notes.ts +33 -0
  29. package/template/src/__tests__/mocks/miden-sdk-react.ts +261 -0
  30. package/template/src/__tests__/patterns/README.md +44 -0
  31. package/template/src/__tests__/patterns/mutation-hook.test.tsx +146 -0
  32. package/template/src/__tests__/patterns/provider-setup.test.tsx +77 -0
  33. package/template/src/__tests__/patterns/query-hook.test.tsx +143 -0
  34. package/template/src/{App.css → components/AppContent.css} +9 -9
  35. package/template/src/components/AppContent.tsx +80 -0
  36. package/template/src/components/ConfiguredCounter.tsx +48 -0
  37. package/template/src/components/Counter.css +27 -0
  38. package/template/src/components/Counter.tsx +16 -0
  39. package/template/src/components/__tests__/AppContent.test.tsx +274 -0
  40. package/template/src/components/__tests__/ConfiguredCounter.test.tsx +116 -0
  41. package/template/src/components/__tests__/Counter.test.tsx +44 -0
  42. package/template/src/config.ts +41 -0
  43. package/template/src/hooks/__tests__/useIncrementCounter.test.tsx +257 -0
  44. package/template/src/hooks/useIncrementCounter.ts +195 -0
  45. package/template/src/index.css +7 -0
  46. package/template/src/lib/miden.ts +9 -0
  47. package/template/src/main.tsx +6 -6
  48. package/template/src/providers.tsx +27 -0
  49. package/template/src/vite-env.d.ts +1 -0
  50. package/template/tsconfig.app.json +8 -4
  51. package/template/tsconfig.node.json +1 -3
  52. package/template/vite.config.ts +5 -17
  53. package/template/vitest.config.ts +25 -0
  54. package/template/vitest.setup.ts +1 -0
  55. package/template/yarn.lock +1687 -815
  56. package/template/src/miden/lib/demo.ts +0 -106
@@ -1,106 +0,0 @@
1
- import {
2
- WebClient,
3
- AccountStorageMode,
4
- NoteType,
5
- ConsumableNoteRecord,
6
- AccountId,
7
- AuthScheme,
8
- } from "@miden-sdk/miden-sdk";
9
-
10
- export async function demo() {
11
- // Initialize client to connect with the Miden Testnet.
12
- // NOTE: The client is our entry point to the Miden network.
13
- // All interactions with the network go through the client.
14
- const nodeEndpoint = "https://rpc.devnet.miden.io:443";
15
-
16
- // Initialize client
17
- const client = await WebClient.createClient(nodeEndpoint);
18
- await client.syncState();
19
-
20
- // Creating Alice's account
21
- const alice = await client.newWallet(AccountStorageMode.public(), true, AuthScheme.AuthRpoFalcon512);
22
- console.log("Alice's account ID:", alice.id().toString());
23
-
24
- // Creating a faucet account
25
- const symbol = "TEST";
26
- const decimals = 8;
27
- const initialSupply = BigInt(10_000_000 * 10 ** decimals);
28
- const faucet = await client.newFaucet(
29
- AccountStorageMode.public(), // Public: account state is visible on-chain
30
- false, // Mutable: account code cannot be upgraded later
31
- symbol, // Symbol of the token
32
- decimals, // Number of decimals
33
- initialSupply, // Initial supply of tokens
34
- AuthScheme.AuthRpoFalcon512 // Authentication scheme
35
- );
36
- console.log("Faucet account ID:", faucet.id().toString());
37
-
38
- // Create transaction request to mint fungible asset to Alice's account
39
- // NOTE: This transaction will create a P2ID note (a Miden note containing the minted asset)
40
- // for Alice's account. Alice will be able to consume these notes to get the fungible asset in her vault
41
- console.log("Minting 1000 tokens to Alice...");
42
- const mintTxRequest = client.newMintTransactionRequest(
43
- alice.id(), // Target account (who receives the tokens)
44
- faucet.id(), // Faucet account (who mints the tokens)
45
- NoteType.Public, // Note visibility (public = on-chain)
46
- BigInt(1000) // Amount to mint (in base units)
47
- );
48
- const mintTxId = await client.submitNewTransaction(
49
- faucet.id(),
50
- mintTxRequest
51
- );
52
-
53
- console.log("Mint transaction submitted successfully, ID:", mintTxId.toHex());
54
-
55
- await client.syncState();
56
-
57
- let consumableNotes: ConsumableNoteRecord[] = [];
58
- while (consumableNotes.length === 0) {
59
- // Find consumable notes
60
- consumableNotes = await client.getConsumableNotes(alice.id());
61
-
62
- console.log("Waiting for note to be consumable...");
63
- await new Promise((resolve) => setTimeout(resolve, 3000));
64
- }
65
-
66
- const notes = consumableNotes.map((note) =>
67
- note.inputNoteRecord().toNote()
68
- );
69
-
70
- // Create transaction request to consume notes
71
- // NOTE: This transaction will consume the notes and add the fungible asset to Alice's vault
72
- const consumeTxRequest = client.newConsumeTransactionRequest(notes);
73
- const consumeTxId = await client.submitNewTransaction(
74
- alice.id(),
75
- consumeTxRequest
76
- );
77
- console.log(
78
- "Consume transaction submitted successfully, ID:",
79
- consumeTxId.toHex()
80
- );
81
-
82
- console.log(
83
- "Alice's TEST token balance:",
84
- Number(alice.vault().getBalance(faucet.id()))
85
- );
86
-
87
- await client.syncState();
88
-
89
- // Send tokens from Alice to Bob
90
- const bobAccountId = "0x599a54603f0cf9000000ed7a11e379";
91
- console.log("Sending 100 tokens to Bob...");
92
-
93
- // Build transaction request to send tokens from Alice to Bob
94
- const sendTxRequest = client.newSendTransactionRequest(
95
- alice.id(), // Sender account
96
- AccountId.fromHex(bobAccountId), // Recipient account
97
- faucet.id(), // Asset ID (faucet that created the tokens)
98
- NoteType.Public, // Note visibility
99
- BigInt(100) // Amount to send
100
- );
101
-
102
- const sendTxId = await client.submitNewTransaction(alice.id(), sendTxRequest);
103
- console.log("Send transaction submitted successfully, ID:", sendTxId.toHex());
104
-
105
- await client.syncState();
106
- }