create-mn-app 0.4.0 → 0.4.2
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 +12 -11
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/installers/wallet-generator.d.ts +4 -0
- package/dist/installers/wallet-generator.d.ts.map +1 -0
- package/dist/installers/wallet-generator.js +78 -0
- package/dist/installers/wallet-generator.js.map +1 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +65 -0
- package/dist/test.js.map +1 -0
- package/dist/utils/templates.d.ts.map +1 -1
- package/dist/utils/templates.js +67 -22
- package/dist/utils/templates.js.map +1 -1
- package/package.json +1 -1
- package/templates/hello-world/README.md.template +18 -3
- package/templates/hello-world/_gitignore +3 -0
- package/templates/hello-world/package.json.template +1 -1
- package/templates/hello-world/scripts/e2e-check.ts.template +11 -45
- package/templates/hello-world/src/check-balance.ts.template +10 -55
- package/templates/hello-world/src/cli.ts.template +12 -50
- package/templates/hello-world/src/deploy.ts.template +12 -55
- package/templates/hello-world/src/network.ts +2 -2
- package/templates/hello-world/src/wallet-state.ts +95 -0
- package/templates/hello-world/src/wallet.ts +189 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Scaffold a Midnight Network DApp project. One command bootstraps a contract, a l
|
|
|
13
13
|
| ---------------- | -------- | ------------------------------------------------------ |
|
|
14
14
|
| Node.js | 22+ | |
|
|
15
15
|
| Docker | Compose v2 | Runs the local devnet and proof server |
|
|
16
|
-
| Compact compiler | 0.31.0 | Required for
|
|
16
|
+
| Compact compiler | 0.31.0 | Required for the remote examples (`battleship`, `bboard`, `leaderboard`); the CLI offers to install it for you |
|
|
17
17
|
|
|
18
18
|
## Quick Start
|
|
19
19
|
|
|
@@ -46,8 +46,8 @@ The bundled `hello-world` template runs against three networks. Local devnet is
|
|
|
46
46
|
| Network | Source | When to use |
|
|
47
47
|
| ------------ | ----------------------------------------------------------------- | -------------------------------------------------------- |
|
|
48
48
|
| `undeployed` | Local devnet from `docker-compose.yml` | Default. Iterate fast, no funding, no extension needed. |
|
|
49
|
-
| `preview` | Public preview testnet ([faucet](https://
|
|
50
|
-
| `preprod` | Public preprod testnet ([faucet](https://
|
|
49
|
+
| `preview` | Public preview testnet ([faucet](https://midnight-tmnight-preview.nethermind.dev/)) | Test against shared infra before a release. |
|
|
50
|
+
| `preprod` | Public preprod testnet ([faucet](https://midnight-tmnight-preprod.nethermind.dev/)) | Validate against the network closest to mainnet. |
|
|
51
51
|
|
|
52
52
|
Switch network on a single command:
|
|
53
53
|
|
|
@@ -73,7 +73,7 @@ Pick a template interactively, or pass `--template`:
|
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
75
|
npx create-mn-app@latest my-app # interactive picker
|
|
76
|
-
npx create-mn-app@latest my-app --template
|
|
76
|
+
npx create-mn-app@latest my-app --template bboard # skip the prompts
|
|
77
77
|
npx create-mn-app@latest my-app --list # show every template
|
|
78
78
|
```
|
|
79
79
|
|
|
@@ -84,13 +84,14 @@ npx create-mn-app@latest my-app --list # show every template
|
|
|
84
84
|
| Template | What it is |
|
|
85
85
|
| ----------------------- | ----------------------------------------------------------------------- |
|
|
86
86
|
| `hello-world` (default) | Bundled. Local devnet + message-storage contract. The fastest path to a working deploy. |
|
|
87
|
+
| `battleship` | State-machine game contract with private board state, verified end-to-end via local-devnet tests. Cloned from [`example-battleship`](https://github.com/midnightntwrk/example-battleship). |
|
|
87
88
|
|
|
88
89
|
### Full DApp
|
|
89
90
|
|
|
90
|
-
| Template
|
|
91
|
-
|
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
91
|
+
| Template | What it is |
|
|
92
|
+
| ------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `bboard` (default) | Multi-user bulletin board demonstrating privacy patterns. The go-to DApp example. Cloned from [`example-bboard`](https://github.com/midnightntwrk/example-bboard). |
|
|
94
|
+
| `leaderboard` | Privacy-preserving arcade leaderboard with a React + Lace browser DApp and in-browser ZK proving. Cloned from [`midnight-leaderboard`](https://github.com/midnightntwrk/midnight-leaderboard). |
|
|
94
95
|
|
|
95
96
|
The DApp templates clone an upstream example and configure it for the pinned compiler. They follow the upstream project's setup flow — see the cloned repo's README after scaffolding.
|
|
96
97
|
|
|
@@ -104,7 +105,7 @@ npx create-mn-app@latest [project-directory] [options]
|
|
|
104
105
|
|
|
105
106
|
| Option | Description |
|
|
106
107
|
| ----------------------------------------------- | ------------------------------------------------- |
|
|
107
|
-
| `-t, --template <name>` | `hello-world`, `
|
|
108
|
+
| `-t, --template <name>` | `hello-world`, `battleship`, `bboard`, `leaderboard` |
|
|
108
109
|
| `--list` | List all templates and exit |
|
|
109
110
|
| `--from <owner/repo>` | Scaffold from any GitHub repository |
|
|
110
111
|
| `-y, --yes` | Accept defaults; non-interactive |
|
|
@@ -126,8 +127,8 @@ Issues and pull requests welcome at [github.com/midnightntwrk/create-mn-app](htt
|
|
|
126
127
|
|
|
127
128
|
- [Midnight Docs](https://docs.midnight.network)
|
|
128
129
|
- [Discord](https://discord.com/invite/midnightnetwork)
|
|
129
|
-
- [Preview Faucet](https://
|
|
130
|
-
- [Preprod Faucet](https://
|
|
130
|
+
- [Preview Faucet](https://midnight-tmnight-preview.nethermind.dev/)
|
|
131
|
+
- [Preprod Faucet](https://midnight-tmnight-preprod.nethermind.dev/)
|
|
131
132
|
|
|
132
133
|
## License
|
|
133
134
|
|
package/dist/cli.js
CHANGED
|
@@ -69,7 +69,7 @@ program
|
|
|
69
69
|
.description("Create a new Midnight Network application")
|
|
70
70
|
.version(pkg.version)
|
|
71
71
|
.argument("[project-directory]", "Directory name for your project")
|
|
72
|
-
.option("-t, --template <name>", "Template to use (hello-world,
|
|
72
|
+
.option("-t, --template <name>", "Template to use (hello-world, battleship, bboard, leaderboard, dex, midnight-kitties)")
|
|
73
73
|
.option("--use-npm", "Use npm explicitly")
|
|
74
74
|
.option("--use-yarn", "Use yarn explicitly")
|
|
75
75
|
.option("--use-pnpm", "Use pnpm explicitly")
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,yCAAyC;AACzC,sCAAsC;AACtC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,yCAAoC;AACpC,kDAA0B;AAC1B,sEAA6C;AAC7C,6CAAyC;AACzC,yDAAqD;AACrD,iDAAkD;AAClD,2CAA6B;AAC7B,uCAAyB;AAEzB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAClE,CAAC;AAEF,oBAAoB;AACpB,IAAA,yBAAc,EAAC,EAAE,GAAG,EAAE,mBAAmB,EAAE,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC;IACvE,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,eAAe,CAAC;KACrB,WAAW,CAAC,2CAA2C,CAAC;KACxD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;KACpB,QAAQ,CAAC,qBAAqB,EAAE,iCAAiC,CAAC;KAClE,MAAM,CACL,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,yCAAyC;AACzC,sCAAsC;AACtC,kEAAkE;AACl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,CAAC,CAAC,CAAC;gBACvC,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-generator.d.ts","sourceRoot":"","sources":["../../src/installers/wallet-generator.ts"],"names":[],"mappings":"AAmBA,qBAAa,eAAe;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAwDrD"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is part of create-mn-app.
|
|
3
|
+
// Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// You may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.WalletGenerator = void 0;
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
22
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
23
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
24
|
+
class WalletGenerator {
|
|
25
|
+
async generate(projectPath) {
|
|
26
|
+
// Generate 32 random bytes and convert to hex string
|
|
27
|
+
const bytes = crypto_1.default.randomBytes(32);
|
|
28
|
+
const walletSeed = bytes.toString("hex");
|
|
29
|
+
// Create .env file
|
|
30
|
+
const envPath = path_1.default.join(projectPath, ".env");
|
|
31
|
+
const envContent = `# Midnight Network Configuration
|
|
32
|
+
# Generated on ${new Date().toISOString()}
|
|
33
|
+
|
|
34
|
+
# Network Configuration
|
|
35
|
+
MIDNIGHT_NETWORK=preprod
|
|
36
|
+
PROOF_SERVER_URL=http://127.0.0.1:6300
|
|
37
|
+
|
|
38
|
+
# Wallet Configuration (KEEP PRIVATE!)
|
|
39
|
+
WALLET_SEED=${walletSeed}
|
|
40
|
+
|
|
41
|
+
# Contract Configuration
|
|
42
|
+
CONTRACT_NAME=hello-world
|
|
43
|
+
|
|
44
|
+
# Development Settings
|
|
45
|
+
DEBUG_LEVEL=info
|
|
46
|
+
AUTO_START_PROOF_SERVER=true
|
|
47
|
+
|
|
48
|
+
# Security Warning:
|
|
49
|
+
# Keep your wallet seed private and secure!
|
|
50
|
+
# Never commit this file to version control.
|
|
51
|
+
# Add .env to your .gitignore file.
|
|
52
|
+
`;
|
|
53
|
+
await fs_extra_1.default.writeFile(envPath, envContent);
|
|
54
|
+
// Also create .env.example for reference
|
|
55
|
+
const envExamplePath = path_1.default.join(projectPath, ".env.example");
|
|
56
|
+
const envExampleContent = `# Midnight Network Configuration
|
|
57
|
+
# Copy this file to .env and fill in your values
|
|
58
|
+
|
|
59
|
+
# Network Configuration
|
|
60
|
+
MIDNIGHT_NETWORK=preprod
|
|
61
|
+
PROOF_SERVER_URL=http://127.0.0.1:6300
|
|
62
|
+
|
|
63
|
+
# Wallet Configuration (KEEP PRIVATE!)
|
|
64
|
+
WALLET_SEED=your_64_character_wallet_seed_here
|
|
65
|
+
|
|
66
|
+
# Contract Configuration
|
|
67
|
+
CONTRACT_NAME=hello-world
|
|
68
|
+
|
|
69
|
+
# Development Settings
|
|
70
|
+
DEBUG_LEVEL=info
|
|
71
|
+
AUTO_START_PROOF_SERVER=true
|
|
72
|
+
`;
|
|
73
|
+
await fs_extra_1.default.writeFile(envExamplePath, envExampleContent);
|
|
74
|
+
return walletSeed;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.WalletGenerator = WalletGenerator;
|
|
78
|
+
//# sourceMappingURL=wallet-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-generator.js","sourceRoot":"","sources":["../../src/installers/wallet-generator.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,yCAAyC;AACzC,sCAAsC;AACtC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;AAEjC,gDAAwB;AACxB,wDAA0B;AAC1B,oDAA4B;AAE5B,MAAa,eAAe;IAC1B,KAAK,CAAC,QAAQ,CAAC,WAAmB;QAChC,qDAAqD;QACrD,MAAM,KAAK,GAAG,gBAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACrC,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEzC,mBAAmB;QACnB,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG;iBACN,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;;;;;;;cAO3B,UAAU;;;;;;;;;;;;;CAavB,CAAC;QAEE,MAAM,kBAAE,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAExC,yCAAyC;QACzC,MAAM,cAAc,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAC9D,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;CAgB7B,CAAC;QAEE,MAAM,kBAAE,CAAC,SAAS,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;QAEtD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAzDD,0CAyDC"}
|
package/dist/test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":""}
|
package/dist/test.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is part of create-mn-app.
|
|
3
|
+
// Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// You may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
22
|
+
const create_app_1 = require("./create-app");
|
|
23
|
+
async function testCreateApp() {
|
|
24
|
+
console.log("🧪 Testing create-mn-app...\n");
|
|
25
|
+
const testDir = path_1.default.join(process.cwd(), "test-app");
|
|
26
|
+
// Clean up any existing test
|
|
27
|
+
if (fs_extra_1.default.existsSync(testDir)) {
|
|
28
|
+
await fs_extra_1.default.remove(testDir);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
await (0, create_app_1.createApp)("test-app", {
|
|
32
|
+
template: "hello-world",
|
|
33
|
+
useNpm: true,
|
|
34
|
+
skipInstall: false,
|
|
35
|
+
skipGit: true,
|
|
36
|
+
verbose: true,
|
|
37
|
+
});
|
|
38
|
+
console.log("\n✅ Test completed successfully!");
|
|
39
|
+
// Verify structure
|
|
40
|
+
const requiredFiles = [
|
|
41
|
+
"package.json",
|
|
42
|
+
"tsconfig.json",
|
|
43
|
+
".gitignore",
|
|
44
|
+
"README.md",
|
|
45
|
+
"docker-compose.yml",
|
|
46
|
+
"contracts/hello-world.compact",
|
|
47
|
+
"src/deploy.ts",
|
|
48
|
+
"src/cli.ts",
|
|
49
|
+
"src/check-balance.ts",
|
|
50
|
+
];
|
|
51
|
+
for (const file of requiredFiles) {
|
|
52
|
+
const filePath = path_1.default.join(testDir, file);
|
|
53
|
+
if (!fs_extra_1.default.existsSync(filePath)) {
|
|
54
|
+
throw new Error(`Missing file: ${file}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
console.log("✅ All required files present");
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error("❌ Test failed:", error);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
testCreateApp();
|
|
65
|
+
//# sourceMappingURL=test.js.map
|
package/dist/test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,yCAAyC;AACzC,sCAAsC;AACtC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;AAEjC,wDA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CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,aAAa,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/utils/templates.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAClC;AAiBD,eAAO,MAAM,SAAS,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/utils/templates.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MA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,aAAa,IAAI,IAAI,CA4CpC"}
|
package/dist/utils/templates.js
CHANGED
|
@@ -51,19 +51,20 @@ exports.templates = [
|
|
|
51
51
|
category: "contract",
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
|
-
name: "
|
|
55
|
-
display: "
|
|
56
|
-
description: "
|
|
54
|
+
name: "battleship",
|
|
55
|
+
display: "Battleship",
|
|
56
|
+
description: "State-machine game contract with private board state, verified via local devnet tests",
|
|
57
57
|
available: true,
|
|
58
58
|
type: "remote",
|
|
59
|
-
category: "
|
|
60
|
-
repo: "midnightntwrk/example-
|
|
59
|
+
category: "contract",
|
|
60
|
+
repo: "midnightntwrk/example-battleship",
|
|
61
61
|
nodeVersion: 22,
|
|
62
62
|
requiresCompactCompiler: true,
|
|
63
63
|
compactVersion: "0.31.0",
|
|
64
64
|
projectStructure: [
|
|
65
|
-
"contract/
|
|
66
|
-
"
|
|
65
|
+
"contract/ smart contract (compact) + witnesses",
|
|
66
|
+
"src/ midnight-js integration and test suite",
|
|
67
|
+
"scripts/ local devnet helpers",
|
|
67
68
|
],
|
|
68
69
|
setupSteps: [
|
|
69
70
|
{
|
|
@@ -71,26 +72,23 @@ exports.templates = [
|
|
|
71
72
|
commands: [
|
|
72
73
|
"cd {{projectName}}",
|
|
73
74
|
"{{installCmd}}",
|
|
74
|
-
"
|
|
75
|
-
"cd ../counter-cli && {{runCmd}} build",
|
|
75
|
+
"{{runCmd}} compile",
|
|
76
76
|
],
|
|
77
77
|
note: "downloads ~500MB zk parameters on first run",
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
|
-
title: "
|
|
81
|
-
commands: [
|
|
82
|
-
|
|
83
|
-
],
|
|
84
|
-
note: "runs in background",
|
|
80
|
+
title: "Start Local Devnet",
|
|
81
|
+
commands: ["{{runCmd}} env:up"],
|
|
82
|
+
note: "starts node, indexer, and proof server via Docker (requires Docker running)",
|
|
85
83
|
},
|
|
86
84
|
{
|
|
87
|
-
title: "Run
|
|
88
|
-
commands: ["
|
|
85
|
+
title: "Run Tests",
|
|
86
|
+
commands: ["{{runCmd}} test:local"],
|
|
87
|
+
note: "deploys the contract and plays a full game programmatically\ntakes a few minutes on first run",
|
|
89
88
|
},
|
|
90
89
|
{
|
|
91
|
-
title: "
|
|
92
|
-
commands: [],
|
|
93
|
-
note: "create wallet and fund from faucet\nPreprod faucet: https://faucet.preprod.midnight.network/\nfunding takes 2-3 minutes\nsee README.md for detailed guide",
|
|
90
|
+
title: "Stop Local Devnet",
|
|
91
|
+
commands: ["{{runCmd}} env:down"],
|
|
94
92
|
},
|
|
95
93
|
],
|
|
96
94
|
},
|
|
@@ -144,7 +142,54 @@ exports.templates = [
|
|
|
144
142
|
{
|
|
145
143
|
title: "Important",
|
|
146
144
|
commands: [],
|
|
147
|
-
note: "create wallet and fund from faucet\nPreprod faucet: https://
|
|
145
|
+
note: "create wallet and fund from faucet\nPreprod faucet: https://midnight-tmnight-preprod.nethermind.dev/\nfunding takes 2-3 minutes\nsee README.md for detailed guide",
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "leaderboard",
|
|
151
|
+
display: "Arcade Leaderboard",
|
|
152
|
+
description: "Privacy-preserving leaderboard with a React + Lace browser DApp and in-browser ZK proving",
|
|
153
|
+
available: true,
|
|
154
|
+
type: "remote",
|
|
155
|
+
category: "dapp",
|
|
156
|
+
repo: "midnightntwrk/midnight-leaderboard",
|
|
157
|
+
nodeVersion: 22,
|
|
158
|
+
requiresCompactCompiler: true,
|
|
159
|
+
compactVersion: "0.31.0",
|
|
160
|
+
projectStructure: [
|
|
161
|
+
"contract/ smart contract (compact) + witnesses",
|
|
162
|
+
"api/ shared business logic",
|
|
163
|
+
"leaderboard-ui/ react + vite frontend",
|
|
164
|
+
"proof-server/ production proof server (railway)",
|
|
165
|
+
],
|
|
166
|
+
setupSteps: [
|
|
167
|
+
{
|
|
168
|
+
title: "Build",
|
|
169
|
+
commands: [
|
|
170
|
+
"cd {{projectName}}",
|
|
171
|
+
"{{installCmd}}",
|
|
172
|
+
"{{runCmd}} compile",
|
|
173
|
+
"{{runCmd}} build",
|
|
174
|
+
],
|
|
175
|
+
note: "npm workspaces (contract, api, leaderboard-ui)\ndownloads ~500MB zk parameters on first run",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
title: "Proof Server",
|
|
179
|
+
commands: [
|
|
180
|
+
"docker run -d -p 6300:6300 midnightntwrk/proof-server:8.0.3 -- midnight-proof-server --network preprod",
|
|
181
|
+
],
|
|
182
|
+
note: "runs in background",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
title: "Run Web UI",
|
|
186
|
+
commands: ["cd leaderboard-ui && {{runCmd}} dev"],
|
|
187
|
+
note: "open http://localhost:3000 in Chrome with the Lace wallet extension",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
title: "Important",
|
|
191
|
+
commands: [],
|
|
192
|
+
note: "create wallet and fund from faucet\nPreprod faucet: https://midnight-tmnight-preprod.nethermind.dev/\nfunding takes 2-3 minutes\nsee README.md for detailed guide",
|
|
148
193
|
},
|
|
149
194
|
],
|
|
150
195
|
},
|
|
@@ -161,12 +206,12 @@ exports.templates = [
|
|
|
161
206
|
{
|
|
162
207
|
name: "midnight-kitties",
|
|
163
208
|
display: "Midnight Kitties",
|
|
164
|
-
description: "Full stack DApp using NFT
|
|
209
|
+
description: "Full stack CryptoKitties NFT DApp (breeding + marketplace) using an external NFT module — pending upgrade to the current Midnight stack",
|
|
165
210
|
available: false,
|
|
166
211
|
comingSoon: true,
|
|
167
212
|
type: "remote",
|
|
168
213
|
category: "dapp",
|
|
169
|
-
repo: "midnightntwrk/
|
|
214
|
+
repo: "midnightntwrk/example-kitties",
|
|
170
215
|
},
|
|
171
216
|
];
|
|
172
217
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/utils/templates.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,yCAAyC;AACzC,sCAAsC;AACtC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/utils/templates.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,yCAAyC;AACzC,sCAAsC;AACtC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;AAqOjC,sDAEC;AAKD,0CAEC;AAKD,kCAEC;AAKD,0CAGC;AAKD,sCAEC;AAKD,wDAEC;AAKD,gDAEC;AAKD,sCA4CC;AAjUD,kDAA0B;AA+B1B,MAAM,YAAY,GAA2C;IAC3D,QAAQ,EAAE;QACR,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,2BAA2B;KACzC;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,2CAA2C;KACzD;IACD,SAAS,EAAE;QACT,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,mCAAmC;KACjD;CACF,CAAC;AAEW,QAAA,SAAS,GAAe;IACnC;QACE,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,aAAa;QACtB,WAAW,EAAE,wDAAwD;QACrE,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,UAAU;KACrB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,YAAY;QACrB,WAAW,EACT,uFAAuF;QACzF,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,kCAAkC;QACxC,WAAW,EAAE,EAA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I,SAAS,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAClC,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,eAAK,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CACnE,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAClC,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,GAAG,CAAC,KAAK,CAAC;gBACd,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC;gBAClB,eAAK,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC;gBACxB,GAAG;gBACH,eAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAChC,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -53,8 +53,8 @@ This DApp supports three networks:
|
|
|
53
53
|
| Network | When to use | Default? |
|
|
54
54
|
|---|---|---|
|
|
55
55
|
| `undeployed` | Local devnet bundled in `docker-compose.yml`. Genesis seed is hardcoded; no funding needed. | yes |
|
|
56
|
-
| `preview` | Public preview testnet. Faucet at `https://
|
|
57
|
-
| `preprod` | Public preprod testnet. Faucet at `https://
|
|
56
|
+
| `preview` | Public preview testnet. Faucet at `https://midnight-tmnight-preview.nethermind.dev`. | |
|
|
57
|
+
| `preprod` | Public preprod testnet. Faucet at `https://midnight-tmnight-preprod.nethermind.dev`. | |
|
|
58
58
|
|
|
59
59
|
The active network is **sticky**: whichever network you last interacted
|
|
60
60
|
with stays active until you switch. Any command run with `--network <name>`
|
|
@@ -128,6 +128,19 @@ npm run network undeployed # or: npm run setup -- --network undeployed
|
|
|
128
128
|
Your preview/preprod wallet seeds and deploy addresses stay in
|
|
129
129
|
`.midnight-state.json`. Switch back later, and they're still there.
|
|
130
130
|
|
|
131
|
+
### Wallet sync cache
|
|
132
|
+
|
|
133
|
+
After each `deploy`, `cli`, or `check-balance` run, the scripts serialize the
|
|
134
|
+
wallet's synced state to `.midnight-wallet-state/<network>/` (gitignored).
|
|
135
|
+
The next run on the same network restores from that snapshot and only catches
|
|
136
|
+
up to the latest block instead of replaying from genesis — meaningful on
|
|
137
|
+
`preview` / `preprod` where a from-seed sync takes minutes.
|
|
138
|
+
|
|
139
|
+
If the cache is stale or corrupt (e.g. after an SDK upgrade with an
|
|
140
|
+
incompatible state format) the wallet falls back to a fresh from-seed sync
|
|
141
|
+
with a one-line warning. `npm run clean` removes the cache along with other
|
|
142
|
+
generated state.
|
|
143
|
+
|
|
131
144
|
## Available scripts
|
|
132
145
|
|
|
133
146
|
| Script | Description |
|
|
@@ -138,7 +151,7 @@ Your preview/preprod wallet seeds and deploy addresses stay in
|
|
|
138
151
|
| `npm run cli` | Interactive CLI to call circuits on the deployed contract. |
|
|
139
152
|
| `npm run check-balance` | Print the genesis-seed wallet's NIGHT and DUST balances. |
|
|
140
153
|
| `npm run test:e2e` | Smoke + read-back check against the deployed contract. |
|
|
141
|
-
| `npm run clean` | Remove `contracts/managed
|
|
154
|
+
| `npm run clean` | Remove `contracts/managed/`, `.midnight-state.json`, and `.midnight-wallet-state/`. |
|
|
142
155
|
| `npm run proof-server:start` / `:stop` | Compose lifecycle for just the proof-server service. |
|
|
143
156
|
|
|
144
157
|
## Project structure
|
|
@@ -151,12 +164,14 @@ Your preview/preprod wallet seeds and deploy addresses stay in
|
|
|
151
164
|
│ └── e2e-check.ts # smoke + read-back
|
|
152
165
|
├── src/
|
|
153
166
|
│ ├── network.ts # network selection + state file management
|
|
167
|
+
│ ├── wallet.ts # wallet construction + sync-state cache
|
|
154
168
|
│ ├── setup.ts # orchestrator for `npm run setup`
|
|
155
169
|
│ ├── deploy.ts # deploy the contract
|
|
156
170
|
│ ├── cli.ts # interact with deployed contract
|
|
157
171
|
│ └── check-balance.ts # NIGHT / DUST balance
|
|
158
172
|
├── docker-compose.yml # node + indexer + proof-server
|
|
159
173
|
├── .midnight-state.json # written by deploy (gitignored)
|
|
174
|
+
├── .midnight-wallet-state/ # serialized sync state per network (gitignored)
|
|
160
175
|
├── package.json
|
|
161
176
|
└── tsconfig.json
|
|
162
177
|
```
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"network": "npx tsx src/network.ts",
|
|
16
16
|
"proof-server:start": "docker compose up -d",
|
|
17
17
|
"proof-server:stop": "docker compose down",
|
|
18
|
-
"clean": "rm -rf contracts/managed .midnight-state.json",
|
|
18
|
+
"clean": "rm -rf contracts/managed .midnight-state.json .midnight-wallet-state",
|
|
19
19
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
20
|
"test:e2e": "tsx scripts/e2e-check.ts"
|
|
21
21
|
},
|