create-mn-app 1.0.3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mn-app",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Create Midnight Network applications with zero configuration",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -34,7 +34,8 @@
34
34
  "@midnight-ntwrk/wallet-api": "5.0.0",
35
35
  "@midnight-ntwrk/zswap": "^4.0.0",
36
36
  "ws": "^8.18.3",
37
- "dotenv": "^16.3.1"
37
+ "dotenv": "^16.3.1",
38
+ "chalk": "^5.3.0"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/node": "^24.4.0",
@@ -9,6 +9,7 @@ import {
9
9
  import { nativeToken } from "@midnight-ntwrk/ledger";
10
10
  import { WebSocket } from "ws";
11
11
  import * as Rx from "rxjs";
12
+ import chalk from "chalk";
12
13
  import { MidnightProviders } from "./providers/midnight-providers.js";
13
14
  import { EnvironmentManager } from "./utils/environment.js";
14
15
 
@@ -21,14 +22,19 @@ setNetworkId(NetworkId.TestNet);
21
22
 
22
23
  async function checkBalance() {
23
24
  try {
24
- console.log("\nšŸŒ™ Checking Wallet Balance\n");
25
+ console.log();
26
+ console.log(chalk.blue.bold("━".repeat(60)));
27
+ console.log(chalk.blue.bold("šŸŒ™ Wallet Balance Checker"));
28
+ console.log(chalk.blue.bold("━".repeat(60)));
29
+ console.log();
25
30
 
26
31
  const seed = process.env.WALLET_SEED;
27
32
  if (!seed) {
28
33
  throw new Error("WALLET_SEED not found in .env file");
29
34
  }
30
35
 
31
- console.log("Building wallet...");
36
+ console.log(chalk.gray("Building wallet..."));
37
+ console.log();
32
38
 
33
39
  // Get network configuration
34
40
  const networkConfig = EnvironmentManager.getNetworkConfig();
@@ -56,30 +62,53 @@ async function checkBalance() {
56
62
 
57
63
  const state = await Rx.firstValueFrom(wallet.state());
58
64
 
59
- console.log(`Wallet Address: ${state.address}`);
65
+ console.log(chalk.cyan.bold("šŸ“ Wallet Address:"));
66
+ console.log(chalk.white(` ${state.address}`));
67
+ console.log();
60
68
 
61
69
  const balance = state.balances[nativeToken()] || 0n;
62
70
 
63
71
  if (balance === 0n) {
64
- console.log(`\nšŸ’° Balance: 0 DUST\n`);
65
- console.log("āŒ No funds detected.");
66
- console.log("\nšŸ“ To get funds:");
67
- console.log(" 1. Visit: https://midnight.network/test-faucet");
68
- console.log(" 2. Paste your wallet address");
69
- console.log(" 3. Wait a few minutes for the transaction to process");
70
- console.log(" 4. Run 'npm run check-balance' again to verify");
71
- console.log("\nšŸ’” Note: Faucet transactions can take 2-5 minutes to process.");
72
+ console.log(chalk.yellow.bold("šŸ’° Balance: ") + chalk.red.bold("0 DUST"));
73
+ console.log();
74
+ console.log(chalk.red("āŒ No funds detected."));
75
+ console.log();
76
+ console.log(chalk.magenta.bold("━".repeat(60)));
77
+ console.log(chalk.magenta.bold("šŸ“ How to Get Test Tokens:"));
78
+ console.log(chalk.magenta.bold("━".repeat(60)));
79
+ console.log();
80
+ console.log(chalk.white(" 1. ") + chalk.cyan("Visit: ") + chalk.underline("https://midnight.network/test-faucet"));
81
+ console.log(chalk.white(" 2. ") + chalk.cyan("Paste your wallet address (shown above)"));
82
+ console.log(chalk.white(" 3. ") + chalk.cyan("Request tokens from the faucet"));
83
+ console.log(chalk.white(" 4. ") + chalk.cyan("Wait 2-5 minutes for processing"));
84
+ console.log(chalk.white(" 5. ") + chalk.cyan("Run ") + chalk.yellow.bold("'npm run check-balance'") + chalk.cyan(" again"));
85
+ console.log();
86
+ console.log(chalk.gray("━".repeat(60)));
87
+ console.log(chalk.gray("šŸ’” Tip: Faucet transactions typically take 2-5 minutes to process."));
88
+ console.log(chalk.gray("━".repeat(60)));
72
89
  } else {
73
- console.log(`\nšŸ’° Balance: ${balance} DUST\n`);
74
- console.log("āœ… Wallet is funded!");
75
- console.log("\nšŸš€ You can now deploy your contract:");
76
- console.log(" npm run deploy");
90
+ console.log(chalk.yellow.bold("šŸ’° Balance: ") + chalk.green.bold(`${balance} DUST`));
91
+ console.log();
92
+ console.log(chalk.green.bold("āœ… Wallet is funded and ready!"));
93
+ console.log();
94
+ console.log(chalk.magenta.bold("━".repeat(60)));
95
+ console.log(chalk.magenta.bold("šŸš€ Next Step:"));
96
+ console.log(chalk.magenta.bold("━".repeat(60)));
97
+ console.log();
98
+ console.log(chalk.cyan(" Deploy your contract with:"));
99
+ console.log(chalk.yellow.bold(" npm run deploy"));
100
+ console.log();
101
+ console.log(chalk.gray("━".repeat(60)));
77
102
  }
78
103
 
104
+ console.log();
79
105
  wallet.close();
80
106
  process.exit(0);
81
107
  } catch (error) {
82
- console.error("Error checking balance:", error);
108
+ console.log();
109
+ console.log(chalk.red.bold("āŒ Error checking balance:"));
110
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
111
+ console.log();
83
112
  process.exit(1);
84
113
  }
85
114
  }
@@ -19,6 +19,7 @@ import * as fs from "fs";
19
19
  import * as path from "path";
20
20
  import * as Rx from "rxjs";
21
21
  import { type Wallet } from "@midnight-ntwrk/wallet-api";
22
+ import chalk from "chalk";
22
23
  import { MidnightProviders } from "./providers/midnight-providers.js";
23
24
  import { EnvironmentManager } from "./utils/environment.js";
24
25
 
@@ -47,7 +48,11 @@ const waitForFunds = (wallet: Wallet) =>
47
48
  );
48
49
 
49
50
  async function main() {
50
- console.log("šŸŒ™ {{projectName}} Deployment\n");
51
+ console.log();
52
+ console.log(chalk.blue.bold("━".repeat(60)));
53
+ console.log(chalk.blue.bold("šŸŒ™ {{projectName}} Deployment"));
54
+ console.log(chalk.blue.bold("━".repeat(60)));
55
+ console.log();
51
56
 
52
57
  try {
53
58
  // Validate environment
@@ -79,31 +84,44 @@ async function main() {
79
84
  wallet.start();
80
85
  const state = await Rx.firstValueFrom(wallet.state());
81
86
 
82
- console.log(`Your wallet address is: ${state.address}`);
87
+ console.log(chalk.cyan.bold("šŸ“ Wallet Address:"));
88
+ console.log(chalk.white(` ${state.address}`));
89
+ console.log();
83
90
 
84
91
  let balance = state.balances[nativeToken()] || 0n;
85
92
 
86
93
  if (balance === 0n) {
87
- console.log(`Your wallet balance is: 0 DUST`);
88
- console.log("\nāŒ Wallet needs funding to deploy contracts.\n");
89
- console.log("šŸ“ To get test tokens:");
90
- console.log(" 1. Visit: https://midnight.network/test-faucet");
91
- console.log(" 2. Paste your wallet address (shown above)");
92
- console.log(" 3. Request tokens from the faucet\n");
93
- console.log("ā±ļø Faucet transactions can take 2-5 minutes to process.\n");
94
- console.log("šŸ’” Options while waiting:");
95
- console.log(" • Let this script wait (it will auto-detect when funds arrive)");
96
- console.log(" • OR press Ctrl+C to stop, then check balance with:");
97
- console.log(" npm run check-balance");
98
- console.log(" • Once funded, run: npm run deploy\n");
99
- console.log(`Waiting to receive tokens...`);
94
+ console.log(chalk.yellow.bold("šŸ’° Balance: ") + chalk.red.bold("0 DUST"));
95
+ console.log();
96
+ console.log(chalk.red.bold("āŒ Wallet needs funding to deploy contracts."));
97
+ console.log();
98
+ console.log(chalk.magenta.bold("━".repeat(60)));
99
+ console.log(chalk.magenta.bold("šŸ“ How to Get Test Tokens:"));
100
+ console.log(chalk.magenta.bold("━".repeat(60)));
101
+ console.log();
102
+ console.log(chalk.white(" 1. ") + chalk.cyan("Visit: ") + chalk.underline("https://midnight.network/test-faucet"));
103
+ console.log(chalk.white(" 2. ") + chalk.cyan("Paste your wallet address (shown above)"));
104
+ console.log(chalk.white(" 3. ") + chalk.cyan("Request tokens from the faucet"));
105
+ console.log();
106
+ console.log(chalk.gray("━".repeat(60)));
107
+ console.log(chalk.gray("ā±ļø Faucet transactions can take 2-5 minutes to process."));
108
+ console.log(chalk.gray("━".repeat(60)));
109
+ console.log();
110
+ console.log(chalk.yellow.bold("šŸ’” Options while waiting:"));
111
+ console.log(chalk.white(" • ") + chalk.cyan("Let this script wait (it will auto-detect when funds arrive)"));
112
+ console.log(chalk.white(" • ") + chalk.cyan("OR press ") + chalk.yellow("Ctrl+C") + chalk.cyan(" to stop, then check balance with:"));
113
+ console.log(chalk.yellow.bold(" npm run check-balance"));
114
+ console.log(chalk.white(" • ") + chalk.cyan("Once funded, run: ") + chalk.yellow.bold("npm run deploy"));
115
+ console.log();
116
+ console.log(chalk.blue("ā³ Waiting to receive tokens..."));
100
117
  balance = await waitForFunds(wallet);
101
118
  }
102
119
 
103
- console.log(`Balance: ${balance}`);
120
+ console.log(chalk.yellow.bold("šŸ’° Balance: ") + chalk.green.bold(`${balance} DUST`));
121
+ console.log();
104
122
 
105
123
  // Load compiled contract files
106
- console.log("Loading contract...");
124
+ console.log(chalk.gray("šŸ“¦ Loading contract..."));
107
125
  const contractPath = path.join(process.cwd(), "contracts");
108
126
  const contractModulePath = path.join(
109
127
  contractPath,
@@ -154,7 +172,8 @@ async function main() {
154
172
  });
155
173
 
156
174
  // Deploy contract to blockchain
157
- console.log("Deploying contract (30-60 seconds)...");
175
+ console.log(chalk.blue("šŸš€ Deploying contract (30-60 seconds)..."));
176
+ console.log();
158
177
 
159
178
  const deployed = await deployContract(providers, {
160
179
  contract: contractInstance,
@@ -165,8 +184,14 @@ async function main() {
165
184
  const contractAddress = deployed.deployTxData.public.contractAddress;
166
185
 
167
186
  // Save deployment information
168
- console.log("\nšŸŽ‰ DEPLOYED!");
169
- console.log(`Contract: ${contractAddress}\n`);
187
+ console.log();
188
+ console.log(chalk.green.bold("━".repeat(60)));
189
+ console.log(chalk.green.bold("šŸŽ‰ CONTRACT DEPLOYED SUCCESSFULLY!"));
190
+ console.log(chalk.green.bold("━".repeat(60)));
191
+ console.log();
192
+ console.log(chalk.cyan.bold("šŸ“ Contract Address:"));
193
+ console.log(chalk.white(` ${contractAddress}`));
194
+ console.log();
170
195
 
171
196
  const info = {
172
197
  contractAddress,
@@ -176,12 +201,16 @@ async function main() {
176
201
  };
177
202
 
178
203
  fs.writeFileSync("deployment.json", JSON.stringify(info, null, 2));
179
- console.log("āœ… Saved to deployment.json");
204
+ console.log(chalk.gray("āœ… Saved to deployment.json"));
205
+ console.log();
180
206
 
181
207
  // Close wallet connection
182
208
  await wallet.close();
183
209
  } catch (error) {
184
- console.error("āŒ Failed:", error);
210
+ console.log();
211
+ console.log(chalk.red.bold("āŒ Deployment Failed:"));
212
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
213
+ console.log();
185
214
  process.exit(1);
186
215
  }
187
216
  }