create-miden-app 1.0.4 → 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.
- package/cli.js +6 -6
- package/package.json +1 -1
- package/template/.claude/hooks/check-artifacts.sh +45 -0
- package/template/.claude/hooks/run-affected-tests.sh +31 -0
- package/template/.claude/hooks/typecheck.sh +27 -0
- package/template/.claude/settings.json +35 -0
- package/template/.claude/skills/frontend-pitfalls/SKILL.md +189 -0
- package/template/.claude/skills/frontend-source-guide/SKILL.md +163 -0
- package/template/.claude/skills/miden-concepts/SKILL.md +108 -0
- package/template/.claude/skills/react-sdk-patterns/SKILL.md +296 -0
- package/template/.claude/skills/signer-integration/SKILL.md +158 -0
- package/template/.claude/skills/testing-patterns/SKILL.md +177 -0
- package/template/.claude/skills/vite-wasm-setup/SKILL.md +128 -0
- package/template/.env.example +5 -0
- package/template/CLAUDE.md +210 -0
- package/template/README.md +53 -14
- package/template/create-miden-app/template/.claude/hooks/typecheck.sh +27 -0
- package/template/create-miden-app/template/.claude/settings.json +17 -0
- package/template/create-miden-app/template/.claude/skills/frontend-pitfalls/SKILL.md +189 -0
- package/template/create-miden-app/template/.claude/skills/frontend-source-guide/SKILL.md +163 -0
- package/template/create-miden-app/template/.claude/skills/miden-concepts/SKILL.md +108 -0
- package/template/create-miden-app/template/.claude/skills/react-sdk-patterns/SKILL.md +294 -0
- package/template/create-miden-app/template/.claude/skills/signer-integration/SKILL.md +158 -0
- package/template/create-miden-app/template/.claude/skills/vite-wasm-setup/SKILL.md +128 -0
- package/template/create-miden-app/template/.env.example +5 -0
- package/template/create-miden-app/template/CLAUDE.md +116 -0
- package/template/create-miden-app/template/README.md +61 -0
- package/template/create-miden-app/template/eslint.config.js +23 -0
- package/template/create-miden-app/template/index.html +13 -0
- package/template/create-miden-app/template/package.json +34 -0
- package/template/create-miden-app/template/public/vite.svg +1 -0
- package/template/create-miden-app/template/src/App.tsx +10 -0
- package/template/create-miden-app/template/src/assets/miden.svg +3 -0
- package/template/create-miden-app/template/src/assets/react.svg +1 -0
- package/template/{src/App.css → create-miden-app/template/src/components/AppContent.css} +9 -9
- package/template/create-miden-app/template/src/components/AppContent.tsx +50 -0
- package/template/create-miden-app/template/src/components/Counter.css +27 -0
- package/template/create-miden-app/template/src/components/Counter.tsx +45 -0
- package/template/create-miden-app/template/src/config.ts +21 -0
- package/template/create-miden-app/template/src/hooks/useIncrementCounter.ts +136 -0
- package/template/create-miden-app/template/src/index.css +75 -0
- package/template/create-miden-app/template/src/lib/miden.ts +9 -0
- package/template/create-miden-app/template/src/main.tsx +10 -0
- package/template/create-miden-app/template/src/providers.tsx +31 -0
- package/template/create-miden-app/template/src/vite-env.d.ts +1 -0
- package/template/create-miden-app/template/tsconfig.app.json +32 -0
- package/template/create-miden-app/template/tsconfig.json +7 -0
- package/template/create-miden-app/template/tsconfig.node.json +24 -0
- package/template/create-miden-app/template/vite.config.ts +17 -0
- package/template/create-miden-app/template/yarn.lock +1697 -0
- package/template/index.html +1 -1
- package/template/package.json +17 -8
- package/template/public/packages/counter_account.masp +0 -0
- package/template/public/packages/increment_note.masp +0 -0
- package/template/src/App.tsx +6 -59
- package/template/src/__tests__/fixtures/accounts.ts +57 -0
- package/template/src/__tests__/fixtures/index.ts +21 -0
- package/template/src/__tests__/fixtures/notes.ts +33 -0
- package/template/src/__tests__/mocks/miden-sdk-react.ts +244 -0
- package/template/src/__tests__/patterns/README.md +44 -0
- package/template/src/__tests__/patterns/mutation-hook.test.tsx +146 -0
- package/template/src/__tests__/patterns/provider-setup.test.tsx +75 -0
- package/template/src/__tests__/patterns/query-hook.test.tsx +143 -0
- package/template/src/components/AppContent.css +45 -0
- package/template/src/components/AppContent.tsx +50 -0
- package/template/src/components/Counter.css +27 -0
- package/template/src/components/Counter.tsx +45 -0
- package/template/src/components/__tests__/AppContent.test.tsx +86 -0
- package/template/src/components/__tests__/Counter.test.tsx +114 -0
- package/template/src/config.ts +21 -0
- package/template/src/hooks/useIncrementCounter.ts +136 -0
- package/template/src/index.css +7 -0
- package/template/src/lib/miden.ts +9 -0
- package/template/src/main.tsx +6 -6
- package/template/src/providers.tsx +31 -0
- package/template/src/vite-env.d.ts +1 -0
- package/template/tsconfig.app.json +8 -4
- package/template/tsconfig.node.json +1 -3
- package/template/vite.config.ts +5 -17
- package/template/vitest.config.ts +26 -0
- package/template/vitest.setup.ts +1 -0
- package/template/yarn.lock +1580 -781
- 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
|
-
}
|