@ilalv3/cli 0.2.2 → 0.2.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/dist/commands/demo.js +63 -17
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/commands/demo.js
CHANGED
|
@@ -148,6 +148,15 @@ export async function demoCheck(opts) {
|
|
|
148
148
|
log.line();
|
|
149
149
|
let score = 0;
|
|
150
150
|
let total = 0;
|
|
151
|
+
let networkReady = false;
|
|
152
|
+
let configReady = true;
|
|
153
|
+
let codeReady = true;
|
|
154
|
+
let economicsReady = false;
|
|
155
|
+
let issuerPathReady = false;
|
|
156
|
+
let credentialReady = false;
|
|
157
|
+
let policyReady = false;
|
|
158
|
+
let walletBalancesReady = false;
|
|
159
|
+
const walletBalanceChecks = [];
|
|
151
160
|
const pass = (condition) => {
|
|
152
161
|
total++;
|
|
153
162
|
if (condition)
|
|
@@ -158,6 +167,7 @@ export async function demoCheck(opts) {
|
|
|
158
167
|
try {
|
|
159
168
|
const block = await client.getBlockNumber();
|
|
160
169
|
ok("latest block", block.toString());
|
|
170
|
+
networkReady = true;
|
|
161
171
|
pass(true);
|
|
162
172
|
}
|
|
163
173
|
catch (e) {
|
|
@@ -190,18 +200,25 @@ export async function demoCheck(opts) {
|
|
|
190
200
|
: value;
|
|
191
201
|
ok(label, display);
|
|
192
202
|
}
|
|
193
|
-
else
|
|
203
|
+
else {
|
|
194
204
|
bad(label, fmt.badge("missing", "red"));
|
|
205
|
+
configReady = false;
|
|
206
|
+
}
|
|
195
207
|
pass(valid);
|
|
196
208
|
}
|
|
197
209
|
log.line();
|
|
198
210
|
log.section("Contract Code", "must exist on-chain");
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
211
|
+
const codeChecks = [
|
|
212
|
+
await hasCode(client, "CNFIssuer", cfg.issuer),
|
|
213
|
+
await hasCode(client, "ComplianceHook", cfg.hook),
|
|
214
|
+
await hasCode(client, "PolicyRegistry", cfg.registry),
|
|
215
|
+
await hasCode(client, "ILALRouter", cfg.router),
|
|
216
|
+
await hasCode(client, "currency0", cfg.tokenA),
|
|
217
|
+
await hasCode(client, "currency1", cfg.tokenB),
|
|
218
|
+
];
|
|
219
|
+
for (const check of codeChecks)
|
|
220
|
+
pass(check);
|
|
221
|
+
codeReady = codeChecks.every(Boolean);
|
|
205
222
|
log.line();
|
|
206
223
|
if (cfg.router && isAddress(cfg.router)) {
|
|
207
224
|
log.section("Verified Flow Economics");
|
|
@@ -213,10 +230,12 @@ export async function demoCheck(opts) {
|
|
|
213
230
|
ok("LP fee", cfg.fee === "8388608" ? `${fmt.badge("dynamic", "green")} verified 0.05%` : "pool fee tier");
|
|
214
231
|
ok("ILAL fee", protocolFeePips > 0 ? `${fmt.badge("protocol", "cyan")} ${pipsToPercent(protocolFeePips)}` : fmt.badge("off", "yellow"));
|
|
215
232
|
ok("treasury", fmt.addr(treasury));
|
|
233
|
+
economicsReady = true;
|
|
216
234
|
pass(true);
|
|
217
235
|
}
|
|
218
236
|
catch {
|
|
219
237
|
warn("protocol fee", fmt.badge("legacy router", "yellow"));
|
|
238
|
+
economicsReady = true;
|
|
220
239
|
pass(true);
|
|
221
240
|
}
|
|
222
241
|
log.line();
|
|
@@ -237,6 +256,7 @@ export async function demoCheck(opts) {
|
|
|
237
256
|
ok("issuance path", fmt.badge("ZK", "green"));
|
|
238
257
|
else
|
|
239
258
|
warn("issuance path", fmt.badge("not ready", "yellow"));
|
|
259
|
+
issuerPathReady = hasEASPath || hasZKPath;
|
|
240
260
|
if (root === 0n)
|
|
241
261
|
warn("merkleRoot", fmt.badge("not set", "yellow"));
|
|
242
262
|
else
|
|
@@ -245,7 +265,7 @@ export async function demoCheck(opts) {
|
|
|
245
265
|
warn("zkVerifier", fmt.badge("not set", "yellow"));
|
|
246
266
|
else
|
|
247
267
|
ok("zkVerifier", fmt.addr(verifier));
|
|
248
|
-
pass(
|
|
268
|
+
pass(issuerPathReady);
|
|
249
269
|
}
|
|
250
270
|
catch (e) {
|
|
251
271
|
bad("issuer reads", e instanceof Error ? e.message.split("\n")[0] : String(e));
|
|
@@ -261,6 +281,7 @@ export async function demoCheck(opts) {
|
|
|
261
281
|
ok("credential", `${fmt.badge("valid", "green")} token #${tokenId}`);
|
|
262
282
|
else
|
|
263
283
|
warn("credential", tokenId === 0n ? fmt.badge("missing", "yellow") : fmt.badge("invalid", "yellow"));
|
|
284
|
+
credentialReady = valid;
|
|
264
285
|
pass(valid);
|
|
265
286
|
}
|
|
266
287
|
catch (e) {
|
|
@@ -285,6 +306,7 @@ export async function demoCheck(opts) {
|
|
|
285
306
|
const issuerMatches = policy.cnfIssuer.toLowerCase() === (cfg.issuer ?? "").toLowerCase();
|
|
286
307
|
const ready = policy.enabled && issuerMatches;
|
|
287
308
|
(ready ? ok : warn)("policy", `${policy.enabled ? fmt.badge("enabled", "green") : fmt.badge("disabled", "yellow")} issuer ${fmt.addr(policy.cnfIssuer)}`);
|
|
309
|
+
policyReady = ready;
|
|
288
310
|
pass(ready);
|
|
289
311
|
}
|
|
290
312
|
catch (e) {
|
|
@@ -308,37 +330,61 @@ export async function demoCheck(opts) {
|
|
|
308
330
|
const balanceText = `${formatUnits(balance, decimals)} ${symbol}`;
|
|
309
331
|
const allowanceText = allowance > 0n ? fmt.badge("approved", "green") : fmt.badge("needs approval", "yellow");
|
|
310
332
|
(balance > 0n ? ok : warn)(label, `${balanceText} ${allowanceText}`);
|
|
333
|
+
walletBalanceChecks.push(balance > 0n);
|
|
311
334
|
pass(balance > 0n);
|
|
312
335
|
}
|
|
313
336
|
catch (e) {
|
|
314
337
|
bad(label, e instanceof Error ? e.message.split("\n")[0] : String(e));
|
|
338
|
+
walletBalanceChecks.push(false);
|
|
315
339
|
pass(false);
|
|
316
340
|
}
|
|
317
341
|
}
|
|
342
|
+
walletBalancesReady = walletBalanceChecks.length === 2 && walletBalanceChecks.every(Boolean);
|
|
318
343
|
log.line();
|
|
319
344
|
}
|
|
345
|
+
const infrastructureChecks = [networkReady, configReady, codeReady, economicsReady, issuerPathReady, policyReady];
|
|
346
|
+
const infrastructureReady = infrastructureChecks.every(Boolean);
|
|
347
|
+
const walletSelected = !!wallet && isAddress(wallet);
|
|
348
|
+
const walletReady = walletSelected && credentialReady && walletBalancesReady;
|
|
349
|
+
const realTxReady = infrastructureReady && walletReady;
|
|
320
350
|
const readiness = total === 0 ? 0 : Math.round((score / total) * 100);
|
|
351
|
+
const infraScore = Math.round((infrastructureChecks.filter(Boolean).length / infrastructureChecks.length) * 100);
|
|
352
|
+
const walletScore = walletSelected
|
|
353
|
+
? Math.round(([credentialReady, walletBalancesReady].filter(Boolean).length / 2) * 100)
|
|
354
|
+
: 0;
|
|
321
355
|
log.section("Readiness");
|
|
322
|
-
const tone =
|
|
323
|
-
log.progress("
|
|
356
|
+
const tone = realTxReady ? "green" : infrastructureReady ? "yellow" : readiness >= 60 ? "yellow" : "red";
|
|
357
|
+
log.progress("overall", readiness, tone);
|
|
358
|
+
log.progress("infrastructure", infraScore, infrastructureReady ? "green" : "yellow");
|
|
359
|
+
log.progress("wallet", walletScore, walletReady ? "green" : "yellow");
|
|
324
360
|
log.metrics([
|
|
325
|
-
{ label: "
|
|
326
|
-
{ label: "
|
|
361
|
+
{ label: "infra", value: infrastructureReady ? "ready" : "incomplete", tone: infrastructureReady ? "green" : "yellow" },
|
|
362
|
+
{ label: "wallet", value: walletReady ? "ready" : "not ready", tone: walletReady ? "green" : "yellow" },
|
|
363
|
+
{ label: "tx", value: realTxReady ? "ready" : "blocked", tone: realTxReady ? "green" : "yellow" },
|
|
364
|
+
]);
|
|
365
|
+
log.metrics([
|
|
366
|
+
{ label: "credential", value: credentialReady ? "valid" : "missing", tone: credentialReady ? "green" : "yellow" },
|
|
367
|
+
{ label: "balances", value: walletBalancesReady ? "funded" : "missing", tone: walletBalancesReady ? "green" : "yellow" },
|
|
368
|
+
{ label: "policy", value: policyReady ? "enabled" : "missing", tone: policyReady ? "green" : "yellow" },
|
|
327
369
|
{ label: "deal", value: cfg.fee === "8388608" ? "better" : "standard", tone: cfg.fee === "8388608" ? "green" : "gray" },
|
|
328
370
|
]);
|
|
329
|
-
if (
|
|
371
|
+
if (realTxReady) {
|
|
330
372
|
log.callout("Live demo ready", "credential, policy, hook, router, pool, and balances are aligned", "green");
|
|
331
373
|
}
|
|
374
|
+
else if (infrastructureReady) {
|
|
375
|
+
log.callout("Demo infrastructure ready", "wallet is not ready yet: mint CNF and fund demo tokens before real tx", "yellow");
|
|
376
|
+
}
|
|
332
377
|
else {
|
|
333
378
|
log.callout("Live demo not ready", "fill the missing config/state first", tone);
|
|
334
379
|
}
|
|
335
380
|
log.line();
|
|
336
|
-
log.section("Live Path",
|
|
337
|
-
flowStep("credential", wallet ? `${fmt.addr(wallet)} holds a valid CNF` : "wallet not selected",
|
|
381
|
+
log.section("Live Path", realTxReady ? "what the judge is about to see" : "target flow");
|
|
382
|
+
flowStep("credential", credentialReady && wallet ? `${fmt.addr(wallet)} holds a valid CNF` : wallet ? `${fmt.addr(wallet)} has no valid CNF` : "wallet not selected", credentialReady ? "green" : "yellow");
|
|
338
383
|
flowStep("session", `local EIP-712 binds user + router + pool + action`, "green");
|
|
339
384
|
flowStep("hook", `${cfg.hook ? fmt.addr(cfg.hook) : fmt.badge("missing", "red")} gates swap/liquidity`, cfg.hook ? "green" : "red");
|
|
340
|
-
flowStep("pool", cfg.poolId ? `${fmt.hash(cfg.poolId)} policy enabled` : fmt.badge("
|
|
341
|
-
flowStep("
|
|
385
|
+
flowStep("pool", policyReady && cfg.poolId ? `${fmt.hash(cfg.poolId)} policy enabled` : fmt.badge("policy not ready", "yellow"), policyReady ? "green" : "yellow");
|
|
386
|
+
flowStep("balances", walletBalancesReady ? fmt.badge("funded", "green") : fmt.badge("missing demo tokens", "yellow"), walletBalancesReady ? "green" : "yellow");
|
|
387
|
+
flowStep("result", realTxReady ? fmt.badge("ready for real tx", "green") : fmt.badge("wallet not ready for real tx", "yellow"), realTxReady ? "green" : "yellow");
|
|
342
388
|
log.line();
|
|
343
389
|
log.section("Next Commands");
|
|
344
390
|
if (!cfg.router || !cfg.tokenA || !cfg.tokenB || !cfg.poolId) {
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ const program = new Command();
|
|
|
19
19
|
program
|
|
20
20
|
.name("ilal")
|
|
21
21
|
.description("ILAL Protocol CLI — Uniswap v4 compliance hook toolkit")
|
|
22
|
-
.version("0.2.
|
|
22
|
+
.version("0.2.3")
|
|
23
23
|
.addHelpText("before", `\n ${fmt.bold(fmt.cyan("◆"))} ${fmt.bold("ILAL Protocol")} ${fmt.gray("Uniswap v4 Compliance Hook")}\n`);
|
|
24
24
|
// ─── init ─────────────────────────────────────────────────────────────────────
|
|
25
25
|
program
|