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
|
@@ -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(
|
|
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(
|
|
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(
|
|
65
|
-
console.log(
|
|
66
|
-
console.log("
|
|
67
|
-
console.log(
|
|
68
|
-
console.log("
|
|
69
|
-
console.log("
|
|
70
|
-
console.log("
|
|
71
|
-
console.log(
|
|
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(
|
|
74
|
-
console.log(
|
|
75
|
-
console.log("
|
|
76
|
-
console.log(
|
|
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.
|
|
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(
|
|
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(
|
|
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(
|
|
88
|
-
console.log(
|
|
89
|
-
console.log("
|
|
90
|
-
console.log(
|
|
91
|
-
console.log("
|
|
92
|
-
console.log("
|
|
93
|
-
console.log("
|
|
94
|
-
console.log(
|
|
95
|
-
console.log("
|
|
96
|
-
console.log("
|
|
97
|
-
console.log("
|
|
98
|
-
console.log(
|
|
99
|
-
console.log(
|
|
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(
|
|
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(
|
|
169
|
-
console.log(
|
|
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.
|
|
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
|
}
|