create-miden-app 1.0.2 → 1.0.4
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/package.json +2 -1
- package/template/src/miden/lib/demo.ts +23 -19
- package/template/vite.config.ts +9 -1
- package/template/yarn.lock +451 -683
package/package.json
CHANGED
package/template/package.json
CHANGED
|
@@ -4,18 +4,21 @@ import {
|
|
|
4
4
|
NoteType,
|
|
5
5
|
ConsumableNoteRecord,
|
|
6
6
|
AccountId,
|
|
7
|
-
|
|
7
|
+
AuthScheme,
|
|
8
|
+
} from "@miden-sdk/miden-sdk";
|
|
8
9
|
|
|
9
10
|
export async function demo() {
|
|
10
11
|
// Initialize client to connect with the Miden Testnet.
|
|
11
12
|
// NOTE: The client is our entry point to the Miden network.
|
|
12
13
|
// All interactions with the network go through the client.
|
|
13
|
-
const nodeEndpoint = "https://rpc.
|
|
14
|
+
const nodeEndpoint = "https://rpc.devnet.miden.io:443";
|
|
15
|
+
|
|
16
|
+
// Initialize client
|
|
14
17
|
const client = await WebClient.createClient(nodeEndpoint);
|
|
15
18
|
await client.syncState();
|
|
16
19
|
|
|
17
20
|
// Creating Alice's account
|
|
18
|
-
const alice = await client.newWallet(AccountStorageMode.public(), true);
|
|
21
|
+
const alice = await client.newWallet(AccountStorageMode.public(), true, AuthScheme.AuthRpoFalcon512);
|
|
19
22
|
console.log("Alice's account ID:", alice.id().toString());
|
|
20
23
|
|
|
21
24
|
// Creating a faucet account
|
|
@@ -27,7 +30,8 @@ export async function demo() {
|
|
|
27
30
|
false, // Mutable: account code cannot be upgraded later
|
|
28
31
|
symbol, // Symbol of the token
|
|
29
32
|
decimals, // Number of decimals
|
|
30
|
-
initialSupply // Initial supply of tokens
|
|
33
|
+
initialSupply, // Initial supply of tokens
|
|
34
|
+
AuthScheme.AuthRpoFalcon512 // Authentication scheme
|
|
31
35
|
);
|
|
32
36
|
console.log("Faucet account ID:", faucet.id().toString());
|
|
33
37
|
|
|
@@ -41,14 +45,13 @@ export async function demo() {
|
|
|
41
45
|
NoteType.Public, // Note visibility (public = on-chain)
|
|
42
46
|
BigInt(1000) // Amount to mint (in base units)
|
|
43
47
|
);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.log(
|
|
48
|
-
"Mint transaction submitted successfully, ID:",
|
|
49
|
-
mintTx.executedTransaction().id().toHex()
|
|
48
|
+
const mintTxId = await client.submitNewTransaction(
|
|
49
|
+
faucet.id(),
|
|
50
|
+
mintTxRequest
|
|
50
51
|
);
|
|
51
52
|
|
|
53
|
+
console.log("Mint transaction submitted successfully, ID:", mintTxId.toHex());
|
|
54
|
+
|
|
52
55
|
await client.syncState();
|
|
53
56
|
|
|
54
57
|
let consumableNotes: ConsumableNoteRecord[] = [];
|
|
@@ -60,18 +63,20 @@ export async function demo() {
|
|
|
60
63
|
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
const
|
|
64
|
-
note.inputNoteRecord().
|
|
66
|
+
const notes = consumableNotes.map((note) =>
|
|
67
|
+
note.inputNoteRecord().toNote()
|
|
65
68
|
);
|
|
66
69
|
|
|
67
70
|
// Create transaction request to consume notes
|
|
68
71
|
// NOTE: This transaction will consume the notes and add the fungible asset to Alice's vault
|
|
69
|
-
const consumeTxRequest = client.newConsumeTransactionRequest(
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
+
const consumeTxRequest = client.newConsumeTransactionRequest(notes);
|
|
73
|
+
const consumeTxId = await client.submitNewTransaction(
|
|
74
|
+
alice.id(),
|
|
75
|
+
consumeTxRequest
|
|
76
|
+
);
|
|
72
77
|
console.log(
|
|
73
78
|
"Consume transaction submitted successfully, ID:",
|
|
74
|
-
|
|
79
|
+
consumeTxId.toHex()
|
|
75
80
|
);
|
|
76
81
|
|
|
77
82
|
console.log(
|
|
@@ -94,9 +99,8 @@ export async function demo() {
|
|
|
94
99
|
BigInt(100) // Amount to send
|
|
95
100
|
);
|
|
96
101
|
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
console.log("Send transaction submitted successfully!");
|
|
102
|
+
const sendTxId = await client.submitNewTransaction(alice.id(), sendTxRequest);
|
|
103
|
+
console.log("Send transaction submitted successfully, ID:", sendTxId.toHex());
|
|
100
104
|
|
|
101
105
|
await client.syncState();
|
|
102
106
|
}
|
package/template/vite.config.ts
CHANGED
|
@@ -2,12 +2,20 @@ import { defineConfig } from "vite";
|
|
|
2
2
|
import react from "@vitejs/plugin-react";
|
|
3
3
|
import wasm from "vite-plugin-wasm";
|
|
4
4
|
import topLevelAwait from "vite-plugin-top-level-await";
|
|
5
|
+
import path from "path";
|
|
5
6
|
|
|
6
7
|
// https://vite.dev/config/
|
|
7
8
|
export default defineConfig({
|
|
8
9
|
plugins: [react(), wasm(), topLevelAwait()],
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
// Help resolve dexie when imported from linked packages
|
|
13
|
+
dexie: path.resolve(__dirname, "node_modules/dexie"),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
9
16
|
optimizeDeps: {
|
|
10
|
-
exclude: ["@
|
|
17
|
+
exclude: ["@miden-sdk/miden-sdk"],
|
|
18
|
+
include: ["dexie"],
|
|
11
19
|
},
|
|
12
20
|
server: {
|
|
13
21
|
headers: {
|