create-miden-app 1.0.3 → 1.0.6

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