create-mn-app 1.0.2 ā 1.0.3
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/README.md
CHANGED
|
@@ -87,6 +87,10 @@ Builds your TypeScript source code to JavaScript in the `dist/` directory
|
|
|
87
87
|
|
|
88
88
|
Deploys your compiled contract to the Midnight testnet
|
|
89
89
|
|
|
90
|
+
### `npm run check-balance`
|
|
91
|
+
|
|
92
|
+
Checks your wallet balance. Useful for verifying if test tokens from the faucet have arrived before deploying.
|
|
93
|
+
|
|
90
94
|
## Project Structure
|
|
91
95
|
|
|
92
96
|
```
|
|
@@ -176,6 +180,24 @@ PROOF_SERVER_URL=http://localhost:6300
|
|
|
176
180
|
|
|
177
181
|
## Troubleshooting
|
|
178
182
|
|
|
183
|
+
### Waiting for faucet funds
|
|
184
|
+
|
|
185
|
+
If your deployment is waiting for funds from the testnet faucet:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Option 1: Let the script wait (it will auto-detect funds)
|
|
189
|
+
# Just leave it running after requesting from the faucet
|
|
190
|
+
|
|
191
|
+
# Option 2: Stop and check manually
|
|
192
|
+
# Press Ctrl+C to stop, then:
|
|
193
|
+
npm run check-balance
|
|
194
|
+
|
|
195
|
+
# Once funded, deploy:
|
|
196
|
+
npm run deploy
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
š” **Note**: Faucet transactions typically take 2-5 minutes to process.
|
|
200
|
+
|
|
179
201
|
### Port 6300 already in use
|
|
180
202
|
|
|
181
203
|
If you see "Bind for 0.0.0.0:6300 failed: port is already allocated":
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"build": "tsc",
|
|
14
14
|
"deploy": "node dist/deploy.js",
|
|
15
15
|
"cli": "node dist/cli.js",
|
|
16
|
+
"check-balance": "npm run build && node dist/check-balance.js",
|
|
16
17
|
"reset": "rm -rf contracts/managed deployment.json dist && npm run compile",
|
|
17
18
|
"validate": "tsc --noEmit && npm run compile",
|
|
18
19
|
"clean": "rm -rf dist contracts/managed deployment.json",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { WalletBuilder } from "@midnight-ntwrk/wallet";
|
|
3
|
+
import {
|
|
4
|
+
NetworkId,
|
|
5
|
+
setNetworkId,
|
|
6
|
+
getZswapNetworkId,
|
|
7
|
+
getLedgerNetworkId,
|
|
8
|
+
} from "@midnight-ntwrk/midnight-js-network-id";
|
|
9
|
+
import { nativeToken } from "@midnight-ntwrk/ledger";
|
|
10
|
+
import { WebSocket } from "ws";
|
|
11
|
+
import * as Rx from "rxjs";
|
|
12
|
+
import { MidnightProviders } from "./providers/midnight-providers.js";
|
|
13
|
+
import { EnvironmentManager } from "./utils/environment.js";
|
|
14
|
+
|
|
15
|
+
// Fix WebSocket for Node.js environment
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
globalThis.WebSocket = WebSocket;
|
|
18
|
+
|
|
19
|
+
// Configure for Midnight Testnet
|
|
20
|
+
setNetworkId(NetworkId.TestNet);
|
|
21
|
+
|
|
22
|
+
async function checkBalance() {
|
|
23
|
+
try {
|
|
24
|
+
console.log("\nš Checking Wallet Balance\n");
|
|
25
|
+
|
|
26
|
+
const seed = process.env.WALLET_SEED;
|
|
27
|
+
if (!seed) {
|
|
28
|
+
throw new Error("WALLET_SEED not found in .env file");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log("Building wallet...");
|
|
32
|
+
|
|
33
|
+
// Get network configuration
|
|
34
|
+
const networkConfig = EnvironmentManager.getNetworkConfig();
|
|
35
|
+
|
|
36
|
+
// Create providers
|
|
37
|
+
const providers = MidnightProviders.create({
|
|
38
|
+
indexerUrl: networkConfig.indexerUrl,
|
|
39
|
+
indexerWsUrl: networkConfig.indexerWsUrl,
|
|
40
|
+
prooServerUrl: networkConfig.proofServerUrl,
|
|
41
|
+
walletSeed: seed,
|
|
42
|
+
zkConfigPath: networkConfig.zkConfigPath,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Build wallet
|
|
46
|
+
const wallet = await WalletBuilder.buildFromSeed(
|
|
47
|
+
getLedgerNetworkId(),
|
|
48
|
+
seed,
|
|
49
|
+
providers.privateStateProvider,
|
|
50
|
+
providers.zkConfigProvider,
|
|
51
|
+
providers.publicDataProvider,
|
|
52
|
+
{ coinPublicKey: providers.coinPublicKey }
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
wallet.start();
|
|
56
|
+
|
|
57
|
+
const state = await Rx.firstValueFrom(wallet.state());
|
|
58
|
+
|
|
59
|
+
console.log(`Wallet Address: ${state.address}`);
|
|
60
|
+
|
|
61
|
+
const balance = state.balances[nativeToken()] || 0n;
|
|
62
|
+
|
|
63
|
+
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
|
+
} 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");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
wallet.close();
|
|
80
|
+
process.exit(0);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error("Error checking balance:", error);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
checkBalance();
|
|
@@ -84,10 +84,18 @@ async function main() {
|
|
|
84
84
|
let balance = state.balances[nativeToken()] || 0n;
|
|
85
85
|
|
|
86
86
|
if (balance === 0n) {
|
|
87
|
-
console.log(`Your wallet balance is: 0`);
|
|
88
|
-
console.log(
|
|
89
|
-
|
|
90
|
-
);
|
|
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");
|
|
91
99
|
console.log(`Waiting to receive tokens...`);
|
|
92
100
|
balance = await waitForFunds(wallet);
|
|
93
101
|
}
|