midnight-mcp 0.1.13 → 0.1.15

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
@@ -126,15 +126,17 @@ Add `"GITHUB_TOKEN": "ghp_..."` for higher GitHub API rate limits (60 → 5000 r
126
126
 
127
127
  ## Indexed Repositories
128
128
 
129
- The API indexes **22+ Midnight repositories**:
130
-
131
- | Category | Repositories |
132
- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
133
- | Core | `compact`, `midnight-js`, `midnight-wallet`, `midnight-docs` |
134
- | Examples | `example-counter`, `example-bboard`, `example-dex`, `create-mn-app` |
135
- | Infrastructure | `midnight-indexer`, `midnight-node-docker`, `midnight-dapp-connector-api` |
136
- | Partner Libraries | `OpenZeppelin/compact-contracts`, `OpenZeppelin/midnight-apps` |
137
- | Official Partners | `bricktowers/midnight-seabattle`, `bricktowers/midnight-identity`, `bricktowers/midnight-rwa`, `MeshJS/midnight-starter-template`, `midnames/core` |
129
+ The API indexes **39 Midnight repositories**:
130
+
131
+ | Category | Repositories |
132
+ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
133
+ | Core | `compact`, `midnight-js`, `midnight-wallet`, `midnight-docs`, `midnight-node`, `midnight-indexer`, `midnight-ledger`, `midnight-zk` |
134
+ | Examples | `example-counter`, `example-bboard`, `example-dex`, `create-mn-app` |
135
+ | Infrastructure | `midnight-node-docker`, `midnight-dapp-connector-api`, `compact-tree-sitter`, `setup-compact-action` |
136
+ | Partner Libraries | `OpenZeppelin/compact-contracts`, `OpenZeppelin/midnight-apps` (LunarSwap) |
137
+ | Official Partners | `bricktowers/midnight-seabattle`, `bricktowers/midnight-identity`, `bricktowers/midnight-rwa`, `MeshJS/midnight-starter-template`, `midnames/core` |
138
+ | Core Partner | `PaimaStudios/midnight-game-2`, `PaimaStudios/midnight-wasm-prover`, `PaimaStudios/midnight-batcher`, `PaimaStudios/midnight-impact-rps-example` |
139
+ | Hackathon Winners | Sea Battle: `ErickRomeroDev/naval-battle-game_v2`, `eddex/midnight-sea-battle-hackathon` • Mini DApp: `statera-protocol`, `nel349/midnight-bank`, `Imdavyking/zkbadge` |
138
140
 
139
141
  ---
140
142
 
@@ -15,9 +15,13 @@ export const EMBEDDED_DOCS = {
15
15
 
16
16
  A curated syntax reference for Compact - Midnight's smart contract language.
17
17
 
18
+ > **Version Note**: This reference is for Compact 0.16+ (current). Some older examples may use deprecated syntax like \`Cell<T>\` wrappers - see "Common Pitfalls" section below.
19
+
18
20
  ## Basic Structure
19
21
 
20
22
  \`\`\`compact
23
+ pragma language_version >= 0.14.0;
24
+
21
25
  include "std";
22
26
 
23
27
  ledger {
@@ -145,11 +149,124 @@ export circuit revealSecret(): Field {
145
149
  }
146
150
  \`\`\`
147
151
 
152
+ ### Disclosure in Conditionals (IMPORTANT)
153
+ When using witness values in if/else conditions, you MUST explicitly disclose the comparison result:
154
+
155
+ \`\`\`compact
156
+ // ❌ WRONG - compiler error: "potential witness-value disclosure must be declared"
157
+ witness getSecret(): Field { return 42; }
158
+ export circuit checkValue(guess: Field): Boolean {
159
+ const secret = getSecret();
160
+ if (guess == secret) { // ERROR: implicit disclosure
161
+ return true;
162
+ }
163
+ return false;
164
+ }
165
+
166
+ // ✅ CORRECT - wrap comparison in disclose()
167
+ export circuit checkValue(guess: Field): Boolean {
168
+ const secret = getSecret();
169
+ if (disclose(guess == secret)) { // Explicitly acknowledge disclosure
170
+ return true;
171
+ }
172
+ return false;
173
+ }
174
+
175
+ // ✅ Multiple comparisons
176
+ export circuit giveHint(guess: Field): Hint {
177
+ const secret = getSecret();
178
+ if (disclose(guess == secret)) {
179
+ return Hint.correct;
180
+ } else if (disclose(guess > secret)) {
181
+ return Hint.too_high;
182
+ } else {
183
+ return Hint.too_low;
184
+ }
185
+ }
186
+ \`\`\`
187
+
188
+ **Why?** When you branch on a comparison involving private (witness) values, the boolean result becomes observable on-chain. Compact requires explicit acknowledgment via \`disclose()\` to prevent accidental privacy leaks.
189
+
148
190
  ### Assertions
149
191
  \`\`\`compact
150
192
  assert(condition); // Basic assertion
151
193
  assert(condition, "Error message"); // With message
152
194
  \`\`\`
195
+
196
+ ## Common Pitfalls & Solutions
197
+
198
+ ### 1. Cell<T> Wrapper (Deprecated)
199
+ \`\`\`compact
200
+ // ❌ OLD SYNTAX (pre-0.15) - causes "unbound identifier Cell"
201
+ export ledger myValue: Cell<Field>;
202
+ myValue.write(42);
203
+ const x = myValue.read();
204
+
205
+ // ✅ CURRENT SYNTAX (0.16+) - direct declaration
206
+ export ledger myValue: Field;
207
+ myValue = 42;
208
+ const x = myValue;
209
+ \`\`\`
210
+
211
+ ### 2. Opaque String Assignment
212
+ \`\`\`compact
213
+ // ❌ WRONG - cannot assign string literals to Opaque
214
+ export ledger message: Opaque<"string">;
215
+ export circuit setMessage(): Void {
216
+ message = "hello"; // ERROR!
217
+ }
218
+
219
+ // ✅ CORRECT - use enum for fixed values
220
+ export enum Status { pending, approved, rejected }
221
+ export ledger status: Status;
222
+ export circuit setStatus(): Void {
223
+ status = Status.approved; // Works!
224
+ }
225
+
226
+ // ✅ Or receive Opaque from parameter/witness
227
+ export circuit setMessage(msg: Opaque<"string">): Void {
228
+ message = msg; // msg comes from TypeScript
229
+ }
230
+ \`\`\`
231
+
232
+ ### 3. Counter vs Field
233
+ \`\`\`compact
234
+ // Counter has special methods
235
+ export ledger count: Counter;
236
+ count.increment(1);
237
+ count.decrement(1);
238
+ const val = count.value();
239
+
240
+ // Field uses direct assignment
241
+ export ledger amount: Field;
242
+ amount = amount + 1;
243
+ const val = amount;
244
+ \`\`\`
245
+
246
+ ### 4. Map Initialization
247
+ \`\`\`compact
248
+ // Maps don't need initialization
249
+ export ledger balances: Map<Bytes<32>, Field>;
250
+
251
+ // Access with .member()
252
+ const balance = balances.member(address);
253
+ balances.insert(address, 100);
254
+ \`\`\`
255
+
256
+ ### 5. Boolean Returns with Witnesses
257
+ \`\`\`compact
258
+ // ❌ WRONG - returns private boolean without disclosure
259
+ export circuit isOwner(): Boolean {
260
+ const caller = getCaller(); // witness
261
+ return caller == owner; // ERROR: undisclosed
262
+ }
263
+
264
+ // ✅ CORRECT - disclose the result
265
+ export circuit isOwner(): Boolean {
266
+ const caller = getCaller();
267
+ return disclose(caller == owner);
268
+ }
269
+ \`\`\`
153
270
  `,
154
271
  "midnight://docs/sdk-api": `# Midnight TypeScript SDK Quick Reference
155
272
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midnight-mcp",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Model Context Protocol Server for Midnight Blockchain Development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",