chainlesschain 0.51.0 → 0.81.0
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 +1 -1
- package/src/assets/web-panel/.build-hash +1 -1
- package/src/assets/web-panel/assets/{AppLayout-Rvi759IS.js → AppLayout-6SPt_8Y_.js} +1 -1
- package/src/assets/web-panel/assets/{Dashboard-DBhFxXYQ.js → Dashboard-Br7kCwKJ.js} +2 -2
- package/src/assets/web-panel/assets/Dashboard-CKeMmCoT.css +1 -0
- package/src/assets/web-panel/assets/{index-uL0cZ8N_.js → index-tN-8TosE.js} +2 -2
- package/src/assets/web-panel/index.html +2 -2
- package/src/commands/a2a.js +380 -0
- package/src/commands/agent-network.js +785 -0
- package/src/commands/automation.js +654 -0
- package/src/commands/bi.js +348 -0
- package/src/commands/crosschain.js +218 -0
- package/src/commands/dao.js +565 -0
- package/src/commands/did-v2.js +620 -0
- package/src/commands/dlp.js +341 -0
- package/src/commands/economy.js +578 -0
- package/src/commands/evolution.js +391 -0
- package/src/commands/evomap.js +394 -0
- package/src/commands/federation.js +283 -0
- package/src/commands/hmemory.js +442 -0
- package/src/commands/inference.js +318 -0
- package/src/commands/lowcode.js +356 -0
- package/src/commands/marketplace.js +256 -0
- package/src/commands/perf.js +433 -0
- package/src/commands/pipeline.js +449 -0
- package/src/commands/plugin-ecosystem.js +517 -0
- package/src/commands/privacy.js +321 -0
- package/src/commands/reputation.js +261 -0
- package/src/commands/sandbox.js +401 -0
- package/src/commands/siem.js +246 -0
- package/src/commands/sla.js +259 -0
- package/src/commands/social.js +311 -0
- package/src/commands/sso.js +798 -0
- package/src/commands/stress.js +230 -0
- package/src/commands/terraform.js +245 -0
- package/src/commands/workflow.js +320 -0
- package/src/commands/zkp.js +562 -1
- package/src/index.js +21 -0
- package/src/lib/a2a-protocol.js +451 -0
- package/src/lib/agent-economy.js +479 -0
- package/src/lib/agent-network.js +1121 -0
- package/src/lib/app-builder.js +239 -0
- package/src/lib/automation-engine.js +948 -0
- package/src/lib/bi-engine.js +338 -0
- package/src/lib/cross-chain.js +345 -0
- package/src/lib/dao-governance.js +569 -0
- package/src/lib/did-v2-manager.js +1127 -0
- package/src/lib/dlp-engine.js +389 -0
- package/src/lib/evolution-system.js +453 -0
- package/src/lib/evomap-federation.js +177 -0
- package/src/lib/evomap-governance.js +276 -0
- package/src/lib/federation-hardening.js +259 -0
- package/src/lib/hierarchical-memory.js +481 -0
- package/src/lib/inference-network.js +330 -0
- package/src/lib/perf-tuning.js +734 -0
- package/src/lib/pipeline-orchestrator.js +928 -0
- package/src/lib/plugin-ecosystem.js +1109 -0
- package/src/lib/privacy-computing.js +427 -0
- package/src/lib/reputation-optimizer.js +299 -0
- package/src/lib/sandbox-v2.js +306 -0
- package/src/lib/siem-exporter.js +333 -0
- package/src/lib/skill-marketplace.js +325 -0
- package/src/lib/sla-manager.js +275 -0
- package/src/lib/social-graph-analytics.js +707 -0
- package/src/lib/sso-manager.js +841 -0
- package/src/lib/stress-tester.js +330 -0
- package/src/lib/terraform-manager.js +363 -0
- package/src/lib/workflow-engine.js +454 -1
- package/src/lib/zkp-engine.js +523 -20
- package/src/assets/web-panel/assets/Dashboard-BS-tzGNj.css +0 -1
package/src/commands/dao.js
CHANGED
|
@@ -17,6 +17,26 @@ import {
|
|
|
17
17
|
depositToTreasury,
|
|
18
18
|
getStats,
|
|
19
19
|
configure,
|
|
20
|
+
// Phase 92 canonical surface
|
|
21
|
+
PROPOSAL_STATUS,
|
|
22
|
+
VOTE_TYPE,
|
|
23
|
+
DELEGATION_STATUS,
|
|
24
|
+
TREASURY_TX_TYPE,
|
|
25
|
+
createProposalV2,
|
|
26
|
+
activateProposal,
|
|
27
|
+
castVote,
|
|
28
|
+
delegateVotingPower,
|
|
29
|
+
revokeDelegation,
|
|
30
|
+
getActiveDelegations,
|
|
31
|
+
queueProposal,
|
|
32
|
+
executeProposalV2,
|
|
33
|
+
cancelProposal,
|
|
34
|
+
allocateFundsV2,
|
|
35
|
+
getTreasuryState,
|
|
36
|
+
getGovernanceStatsV2,
|
|
37
|
+
configureV2,
|
|
38
|
+
getConfigV2,
|
|
39
|
+
depositToTreasuryV2,
|
|
20
40
|
} from "../lib/dao-governance.js";
|
|
21
41
|
|
|
22
42
|
export function registerDaoCommand(program) {
|
|
@@ -309,4 +329,549 @@ export function registerDaoCommand(program) {
|
|
|
309
329
|
process.exit(1);
|
|
310
330
|
}
|
|
311
331
|
});
|
|
332
|
+
|
|
333
|
+
// ══════════════════════════════════════════════════════════
|
|
334
|
+
// Phase 92 (DAO 2.0) canonical subcommands
|
|
335
|
+
// ══════════════════════════════════════════════════════════
|
|
336
|
+
|
|
337
|
+
// dao statuses
|
|
338
|
+
dao
|
|
339
|
+
.command("statuses")
|
|
340
|
+
.description("List Phase 92 enum references")
|
|
341
|
+
.option("--json", "Output as JSON")
|
|
342
|
+
.action((options) => {
|
|
343
|
+
const payload = {
|
|
344
|
+
proposalStatus: { ...PROPOSAL_STATUS },
|
|
345
|
+
voteType: { ...VOTE_TYPE },
|
|
346
|
+
delegationStatus: { ...DELEGATION_STATUS },
|
|
347
|
+
treasuryTxType: { ...TREASURY_TX_TYPE },
|
|
348
|
+
};
|
|
349
|
+
if (options.json) {
|
|
350
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
351
|
+
} else {
|
|
352
|
+
for (const [group, enums] of Object.entries(payload)) {
|
|
353
|
+
logger.log(chalk.bold(`${group}:`));
|
|
354
|
+
for (const [key, val] of Object.entries(enums)) {
|
|
355
|
+
logger.log(` ${chalk.cyan(key)} → ${val}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// dao propose-v2
|
|
362
|
+
dao
|
|
363
|
+
.command("propose-v2 <title>")
|
|
364
|
+
.description("Create a Phase 92 proposal in DRAFT status")
|
|
365
|
+
.option("-d, --description <text>", "Proposal description")
|
|
366
|
+
.option("-p, --proposer-did <did>", "Proposer DID")
|
|
367
|
+
.option("-t, --type <type>", "Proposal type", "standard")
|
|
368
|
+
.option("--actions <json>", "Actions as JSON array", "[]")
|
|
369
|
+
.option("--voting-duration <ms>", "Voting duration in ms")
|
|
370
|
+
.option("--json", "Output as JSON")
|
|
371
|
+
.action(async (title, options) => {
|
|
372
|
+
try {
|
|
373
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
374
|
+
if (!ctx.db) {
|
|
375
|
+
logger.error("Database not available");
|
|
376
|
+
process.exit(1);
|
|
377
|
+
}
|
|
378
|
+
const db = ctx.db.getDatabase();
|
|
379
|
+
ensureDAOv2Tables(db);
|
|
380
|
+
|
|
381
|
+
const proposal = createProposalV2(db, {
|
|
382
|
+
title,
|
|
383
|
+
description: options.description,
|
|
384
|
+
proposerDid: options.proposerDid || "did:cli:user",
|
|
385
|
+
type: options.type,
|
|
386
|
+
actions: JSON.parse(options.actions),
|
|
387
|
+
votingDurationMs: options.votingDuration
|
|
388
|
+
? parseInt(options.votingDuration)
|
|
389
|
+
: undefined,
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
if (options.json) {
|
|
393
|
+
console.log(JSON.stringify(proposal, null, 2));
|
|
394
|
+
} else {
|
|
395
|
+
logger.success("Proposal created (DRAFT)");
|
|
396
|
+
logger.log(` ${chalk.bold("ID:")} ${chalk.cyan(proposal.id)}`);
|
|
397
|
+
logger.log(` ${chalk.bold("Status:")} ${proposal.status}`);
|
|
398
|
+
logger.log(` ${chalk.bold("Type:")} ${proposal.type}`);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
await shutdown();
|
|
402
|
+
} catch (err) {
|
|
403
|
+
logger.error(`Failed: ${err.message}`);
|
|
404
|
+
process.exit(1);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
// dao activate
|
|
409
|
+
dao
|
|
410
|
+
.command("activate <proposal-id>")
|
|
411
|
+
.description("Move proposal DRAFT → ACTIVE and open voting window")
|
|
412
|
+
.action(async (proposalId) => {
|
|
413
|
+
try {
|
|
414
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
415
|
+
if (!ctx.db) {
|
|
416
|
+
logger.error("Database not available");
|
|
417
|
+
process.exit(1);
|
|
418
|
+
}
|
|
419
|
+
const db = ctx.db.getDatabase();
|
|
420
|
+
ensureDAOv2Tables(db);
|
|
421
|
+
|
|
422
|
+
const p = activateProposal(db, proposalId);
|
|
423
|
+
logger.success(`Proposal ${chalk.cyan(proposalId)} → ACTIVE`);
|
|
424
|
+
logger.log(` ${chalk.bold("Voting ends:")} ${p.votingEnd}`);
|
|
425
|
+
|
|
426
|
+
await shutdown();
|
|
427
|
+
} catch (err) {
|
|
428
|
+
logger.error(`Failed: ${err.message}`);
|
|
429
|
+
process.exit(1);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
// dao cast-vote
|
|
434
|
+
dao
|
|
435
|
+
.command("cast-vote <proposal-id>")
|
|
436
|
+
.description(
|
|
437
|
+
"Cast a quadratic vote (cost = voteCount²). voteType: for|against|abstain",
|
|
438
|
+
)
|
|
439
|
+
.requiredOption("-v, --voter <did>", "Voter DID")
|
|
440
|
+
.requiredOption("-t, --type <type>", "Vote type: for|against|abstain")
|
|
441
|
+
.option("-c, --count <n>", "Vote count", "1")
|
|
442
|
+
.option("-b, --balance <n>", "Voter token balance (validates cost)")
|
|
443
|
+
.action(async (proposalId, options) => {
|
|
444
|
+
try {
|
|
445
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
446
|
+
if (!ctx.db) {
|
|
447
|
+
logger.error("Database not available");
|
|
448
|
+
process.exit(1);
|
|
449
|
+
}
|
|
450
|
+
const db = ctx.db.getDatabase();
|
|
451
|
+
ensureDAOv2Tables(db);
|
|
452
|
+
|
|
453
|
+
const record = castVote(db, {
|
|
454
|
+
proposalId,
|
|
455
|
+
voterDid: options.voter,
|
|
456
|
+
voteType: options.type,
|
|
457
|
+
voteCount: parseInt(options.count),
|
|
458
|
+
balance: options.balance ? parseFloat(options.balance) : undefined,
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
logger.success("Vote cast");
|
|
462
|
+
logger.log(` ${chalk.bold("Type:")} ${record.voteType}`);
|
|
463
|
+
logger.log(` ${chalk.bold("Count:")} ${record.voteCount}`);
|
|
464
|
+
logger.log(` ${chalk.bold("Quad. cost:")} ${record.quadraticCost}`);
|
|
465
|
+
|
|
466
|
+
await shutdown();
|
|
467
|
+
} catch (err) {
|
|
468
|
+
logger.error(`Failed: ${err.message}`);
|
|
469
|
+
process.exit(1);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
// dao delegate-v2
|
|
474
|
+
dao
|
|
475
|
+
.command("delegate-v2 <from-did> <to-did>")
|
|
476
|
+
.description("Delegate voting power with cycle + depth safety")
|
|
477
|
+
.option("-w, --weight <n>", "Delegation weight", "1")
|
|
478
|
+
.option("--expires-at <iso>", "ISO timestamp when delegation expires")
|
|
479
|
+
.action(async (fromDid, toDid, options) => {
|
|
480
|
+
try {
|
|
481
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
482
|
+
if (!ctx.db) {
|
|
483
|
+
logger.error("Database not available");
|
|
484
|
+
process.exit(1);
|
|
485
|
+
}
|
|
486
|
+
const db = ctx.db.getDatabase();
|
|
487
|
+
ensureDAOv2Tables(db);
|
|
488
|
+
|
|
489
|
+
const d = delegateVotingPower(db, {
|
|
490
|
+
fromDid,
|
|
491
|
+
toDid,
|
|
492
|
+
weight: parseFloat(options.weight),
|
|
493
|
+
expiresAt: options.expiresAt || null,
|
|
494
|
+
});
|
|
495
|
+
logger.success(`Delegated ${fromDid} → ${toDid}`);
|
|
496
|
+
logger.log(` ${chalk.bold("ID:")} ${chalk.cyan(d.id)}`);
|
|
497
|
+
logger.log(` ${chalk.bold("Status:")} ${d.status}`);
|
|
498
|
+
if (d.expiresAt) {
|
|
499
|
+
logger.log(` ${chalk.bold("Expires:")} ${d.expiresAt}`);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
await shutdown();
|
|
503
|
+
} catch (err) {
|
|
504
|
+
logger.error(`Failed: ${err.message}`);
|
|
505
|
+
process.exit(1);
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
// dao revoke-delegation
|
|
510
|
+
dao
|
|
511
|
+
.command("revoke-delegation <from-did>")
|
|
512
|
+
.description("Revoke an active delegation")
|
|
513
|
+
.action(async (fromDid) => {
|
|
514
|
+
try {
|
|
515
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
516
|
+
if (!ctx.db) {
|
|
517
|
+
logger.error("Database not available");
|
|
518
|
+
process.exit(1);
|
|
519
|
+
}
|
|
520
|
+
const db = ctx.db.getDatabase();
|
|
521
|
+
ensureDAOv2Tables(db);
|
|
522
|
+
|
|
523
|
+
const r = revokeDelegation(db, fromDid);
|
|
524
|
+
logger.success(`Delegation revoked: ${chalk.cyan(r.id)}`);
|
|
525
|
+
|
|
526
|
+
await shutdown();
|
|
527
|
+
} catch (err) {
|
|
528
|
+
logger.error(`Failed: ${err.message}`);
|
|
529
|
+
process.exit(1);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
// dao active-delegations
|
|
534
|
+
dao
|
|
535
|
+
.command("active-delegations")
|
|
536
|
+
.description("List ACTIVE delegations (auto-expires past expiresAt)")
|
|
537
|
+
.option("--json", "Output as JSON")
|
|
538
|
+
.action(async (options) => {
|
|
539
|
+
try {
|
|
540
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
541
|
+
if (!ctx.db) {
|
|
542
|
+
logger.error("Database not available");
|
|
543
|
+
process.exit(1);
|
|
544
|
+
}
|
|
545
|
+
const db = ctx.db.getDatabase();
|
|
546
|
+
ensureDAOv2Tables(db);
|
|
547
|
+
|
|
548
|
+
const list = getActiveDelegations();
|
|
549
|
+
if (options.json) {
|
|
550
|
+
console.log(JSON.stringify(list, null, 2));
|
|
551
|
+
} else if (list.length === 0) {
|
|
552
|
+
logger.log("No active delegations");
|
|
553
|
+
} else {
|
|
554
|
+
for (const d of list) {
|
|
555
|
+
logger.log(
|
|
556
|
+
` ${chalk.cyan(d.id.slice(0, 12))} ${d.fromDid} → ${d.toDid} (w=${d.weight})`,
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
await shutdown();
|
|
562
|
+
} catch (err) {
|
|
563
|
+
logger.error(`Failed: ${err.message}`);
|
|
564
|
+
process.exit(1);
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// dao queue
|
|
569
|
+
dao
|
|
570
|
+
.command("queue <proposal-id>")
|
|
571
|
+
.description("Queue proposal (ACTIVE → QUEUE) if majority + quorum met")
|
|
572
|
+
.action(async (proposalId) => {
|
|
573
|
+
try {
|
|
574
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
575
|
+
if (!ctx.db) {
|
|
576
|
+
logger.error("Database not available");
|
|
577
|
+
process.exit(1);
|
|
578
|
+
}
|
|
579
|
+
const db = ctx.db.getDatabase();
|
|
580
|
+
ensureDAOv2Tables(db);
|
|
581
|
+
|
|
582
|
+
const p = queueProposal(db, proposalId);
|
|
583
|
+
logger.success(`Proposal → QUEUE`);
|
|
584
|
+
logger.log(` ${chalk.bold("Timelock ends:")} ${p.queueEnd}`);
|
|
585
|
+
|
|
586
|
+
await shutdown();
|
|
587
|
+
} catch (err) {
|
|
588
|
+
logger.error(`Failed: ${err.message}`);
|
|
589
|
+
process.exit(1);
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
// dao execute-v2
|
|
594
|
+
dao
|
|
595
|
+
.command("execute-v2 <proposal-id>")
|
|
596
|
+
.description("Execute proposal (QUEUE → EXECUTE) after timelock")
|
|
597
|
+
.action(async (proposalId) => {
|
|
598
|
+
try {
|
|
599
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
600
|
+
if (!ctx.db) {
|
|
601
|
+
logger.error("Database not available");
|
|
602
|
+
process.exit(1);
|
|
603
|
+
}
|
|
604
|
+
const db = ctx.db.getDatabase();
|
|
605
|
+
ensureDAOv2Tables(db);
|
|
606
|
+
|
|
607
|
+
const p = executeProposalV2(db, proposalId);
|
|
608
|
+
logger.success(`Proposal ${chalk.cyan(proposalId)} → EXECUTE`);
|
|
609
|
+
logger.log(` ${chalk.bold("Executed at:")} ${p.executedAt}`);
|
|
610
|
+
|
|
611
|
+
await shutdown();
|
|
612
|
+
} catch (err) {
|
|
613
|
+
logger.error(`Failed: ${err.message}`);
|
|
614
|
+
process.exit(1);
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
// dao cancel
|
|
619
|
+
dao
|
|
620
|
+
.command("cancel <proposal-id>")
|
|
621
|
+
.description("Cancel a proposal (non-executed)")
|
|
622
|
+
.action(async (proposalId) => {
|
|
623
|
+
try {
|
|
624
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
625
|
+
if (!ctx.db) {
|
|
626
|
+
logger.error("Database not available");
|
|
627
|
+
process.exit(1);
|
|
628
|
+
}
|
|
629
|
+
const db = ctx.db.getDatabase();
|
|
630
|
+
ensureDAOv2Tables(db);
|
|
631
|
+
|
|
632
|
+
const p = cancelProposal(db, proposalId);
|
|
633
|
+
logger.success(`Proposal → ${p.status}`);
|
|
634
|
+
|
|
635
|
+
await shutdown();
|
|
636
|
+
} catch (err) {
|
|
637
|
+
logger.error(`Failed: ${err.message}`);
|
|
638
|
+
process.exit(1);
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
// dao allocate-v2
|
|
643
|
+
dao
|
|
644
|
+
.command("allocate-v2 <proposal-id>")
|
|
645
|
+
.description(
|
|
646
|
+
"Allocate treasury funds to a recipient (proposal must be EXECUTED)",
|
|
647
|
+
)
|
|
648
|
+
.requiredOption("-r, --recipient <did>", "Recipient DID or address")
|
|
649
|
+
.requiredOption("-a, --amount <n>", "Allocation amount")
|
|
650
|
+
.option("--asset <symbol>", "Asset symbol", "native")
|
|
651
|
+
.option("-m, --memo <text>", "Memo / description")
|
|
652
|
+
.option("--json", "Output as JSON")
|
|
653
|
+
.action(async (proposalId, options) => {
|
|
654
|
+
try {
|
|
655
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
656
|
+
if (!ctx.db) {
|
|
657
|
+
logger.error("Database not available");
|
|
658
|
+
process.exit(1);
|
|
659
|
+
}
|
|
660
|
+
const db = ctx.db.getDatabase();
|
|
661
|
+
ensureDAOv2Tables(db);
|
|
662
|
+
|
|
663
|
+
const tx = allocateFundsV2(db, {
|
|
664
|
+
proposalId,
|
|
665
|
+
recipient: options.recipient,
|
|
666
|
+
amount: parseFloat(options.amount),
|
|
667
|
+
asset: options.asset,
|
|
668
|
+
memo: options.memo,
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
if (options.json) {
|
|
672
|
+
console.log(JSON.stringify(tx, null, 2));
|
|
673
|
+
} else {
|
|
674
|
+
logger.success("Allocation recorded");
|
|
675
|
+
logger.log(` ${chalk.bold("ID:")} ${chalk.cyan(tx.id)}`);
|
|
676
|
+
logger.log(
|
|
677
|
+
` ${chalk.bold("Amount:")} ${tx.amount} ${tx.asset}`,
|
|
678
|
+
);
|
|
679
|
+
logger.log(` ${chalk.bold("Balance after:")} ${tx.balanceAfter}`);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
await shutdown();
|
|
683
|
+
} catch (err) {
|
|
684
|
+
logger.error(`Failed: ${err.message}`);
|
|
685
|
+
process.exit(1);
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
// dao deposit-v2
|
|
690
|
+
dao
|
|
691
|
+
.command("deposit-v2")
|
|
692
|
+
.description("Deposit funds into the DAO treasury")
|
|
693
|
+
.requiredOption("-a, --amount <n>", "Deposit amount")
|
|
694
|
+
.option("--asset <symbol>", "Asset symbol", "native")
|
|
695
|
+
.option("--depositor-did <did>", "Depositor DID")
|
|
696
|
+
.option("-m, --memo <text>", "Memo")
|
|
697
|
+
.action(async (options) => {
|
|
698
|
+
try {
|
|
699
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
700
|
+
if (!ctx.db) {
|
|
701
|
+
logger.error("Database not available");
|
|
702
|
+
process.exit(1);
|
|
703
|
+
}
|
|
704
|
+
const db = ctx.db.getDatabase();
|
|
705
|
+
ensureDAOv2Tables(db);
|
|
706
|
+
|
|
707
|
+
const tx = depositToTreasuryV2(db, {
|
|
708
|
+
amount: parseFloat(options.amount),
|
|
709
|
+
asset: options.asset,
|
|
710
|
+
depositorDid: options.depositorDid,
|
|
711
|
+
memo: options.memo,
|
|
712
|
+
});
|
|
713
|
+
logger.success("Deposit recorded");
|
|
714
|
+
logger.log(` ${chalk.bold("Balance:")} ${tx.balanceAfter}`);
|
|
715
|
+
|
|
716
|
+
await shutdown();
|
|
717
|
+
} catch (err) {
|
|
718
|
+
logger.error(`Failed: ${err.message}`);
|
|
719
|
+
process.exit(1);
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
// dao treasury-state
|
|
724
|
+
dao
|
|
725
|
+
.command("treasury-state")
|
|
726
|
+
.description("Show Phase 92 treasury state (balance + recent txs)")
|
|
727
|
+
.option("--json", "Output as JSON")
|
|
728
|
+
.action(async (options) => {
|
|
729
|
+
try {
|
|
730
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
731
|
+
if (!ctx.db) {
|
|
732
|
+
logger.error("Database not available");
|
|
733
|
+
process.exit(1);
|
|
734
|
+
}
|
|
735
|
+
const db = ctx.db.getDatabase();
|
|
736
|
+
ensureDAOv2Tables(db);
|
|
737
|
+
|
|
738
|
+
const s = getTreasuryState();
|
|
739
|
+
if (options.json) {
|
|
740
|
+
console.log(JSON.stringify(s, null, 2));
|
|
741
|
+
} else {
|
|
742
|
+
logger.log(` ${chalk.bold("Balance:")} ${s.balance}`);
|
|
743
|
+
logger.log(` ${chalk.bold("Total allocated:")} ${s.totalAllocated}`);
|
|
744
|
+
logger.log(
|
|
745
|
+
` ${chalk.bold("Transactions:")} ${s.transactions.length}`,
|
|
746
|
+
);
|
|
747
|
+
for (const t of s.recentTxs.slice(0, 5)) {
|
|
748
|
+
logger.log(
|
|
749
|
+
` ${chalk.cyan(t.id.slice(0, 12))} ${t.txType} ${t.amount} (bal=${t.balanceAfter})`,
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
await shutdown();
|
|
755
|
+
} catch (err) {
|
|
756
|
+
logger.error(`Failed: ${err.message}`);
|
|
757
|
+
process.exit(1);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
// dao stats-v2
|
|
762
|
+
dao
|
|
763
|
+
.command("stats-v2")
|
|
764
|
+
.description(
|
|
765
|
+
"Phase 92 governance stats with participation + delegation coverage",
|
|
766
|
+
)
|
|
767
|
+
.option("-m, --members <n>", "Total member count (for rate calc)", "0")
|
|
768
|
+
.option("--json", "Output as JSON")
|
|
769
|
+
.action(async (options) => {
|
|
770
|
+
try {
|
|
771
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
772
|
+
if (!ctx.db) {
|
|
773
|
+
logger.error("Database not available");
|
|
774
|
+
process.exit(1);
|
|
775
|
+
}
|
|
776
|
+
const db = ctx.db.getDatabase();
|
|
777
|
+
ensureDAOv2Tables(db);
|
|
778
|
+
|
|
779
|
+
const s = getGovernanceStatsV2(parseInt(options.members));
|
|
780
|
+
if (options.json) {
|
|
781
|
+
console.log(JSON.stringify(s, null, 2));
|
|
782
|
+
} else {
|
|
783
|
+
logger.log(
|
|
784
|
+
` ${chalk.bold("Total proposals:")} ${s.totalProposals}`,
|
|
785
|
+
);
|
|
786
|
+
logger.log(
|
|
787
|
+
` ${chalk.bold("Unique voters:")} ${s.uniqueVoters}`,
|
|
788
|
+
);
|
|
789
|
+
logger.log(
|
|
790
|
+
` ${chalk.bold("Participation:")} ${(s.participationRate * 100).toFixed(2)}%`,
|
|
791
|
+
);
|
|
792
|
+
logger.log(
|
|
793
|
+
` ${chalk.bold("Active delegations:")} ${s.activeDelegations}`,
|
|
794
|
+
);
|
|
795
|
+
logger.log(
|
|
796
|
+
` ${chalk.bold("Delegation coverage:")} ${(s.delegationCoverage * 100).toFixed(2)}%`,
|
|
797
|
+
);
|
|
798
|
+
logger.log(
|
|
799
|
+
` ${chalk.bold("Treasury balance:")} ${s.treasuryBalance}`,
|
|
800
|
+
);
|
|
801
|
+
logger.log(chalk.bold(" By status:"));
|
|
802
|
+
for (const [k, v] of Object.entries(s.byStatus)) {
|
|
803
|
+
if (v > 0) logger.log(` ${k}: ${v}`);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
await shutdown();
|
|
808
|
+
} catch (err) {
|
|
809
|
+
logger.error(`Failed: ${err.message}`);
|
|
810
|
+
process.exit(1);
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
// dao configure-v2
|
|
815
|
+
dao
|
|
816
|
+
.command("configure-v2")
|
|
817
|
+
.description("Update Phase 92 governance config")
|
|
818
|
+
.option("--voting-duration <ms>", "Voting duration ms")
|
|
819
|
+
.option("--quorum-percentage <n>", "Quorum % (0-100)")
|
|
820
|
+
.option("--timelock-ms <ms>", "Timelock ms")
|
|
821
|
+
.option(
|
|
822
|
+
"--quadratic-enabled <bool>",
|
|
823
|
+
"Enable quadratic voting (true|false)",
|
|
824
|
+
)
|
|
825
|
+
.option("--max-delegation-depth <n>", "Max delegation chain depth")
|
|
826
|
+
.option("--proposal-threshold <n>", "Minimum tokens to propose")
|
|
827
|
+
.option("--max-single-allocation <n>", "Max single allocation")
|
|
828
|
+
.option("--json", "Output as JSON")
|
|
829
|
+
.action(async (options) => {
|
|
830
|
+
try {
|
|
831
|
+
const updates = {};
|
|
832
|
+
if (options.votingDuration)
|
|
833
|
+
updates.votingDurationMs = parseInt(options.votingDuration);
|
|
834
|
+
if (options.quorumPercentage)
|
|
835
|
+
updates.quorumPercentage = parseFloat(options.quorumPercentage);
|
|
836
|
+
if (options.timelockMs)
|
|
837
|
+
updates.timelockMs = parseInt(options.timelockMs);
|
|
838
|
+
if (options.quadraticEnabled !== undefined)
|
|
839
|
+
updates.quadraticEnabled = options.quadraticEnabled === "true";
|
|
840
|
+
if (options.maxDelegationDepth)
|
|
841
|
+
updates.maxDelegationDepth = parseInt(options.maxDelegationDepth);
|
|
842
|
+
if (options.proposalThreshold)
|
|
843
|
+
updates.proposalThreshold = parseFloat(options.proposalThreshold);
|
|
844
|
+
if (options.maxSingleAllocation)
|
|
845
|
+
updates.maxSingleAllocation = parseFloat(options.maxSingleAllocation);
|
|
846
|
+
|
|
847
|
+
const cfg = configureV2(updates);
|
|
848
|
+
if (options.json) {
|
|
849
|
+
console.log(JSON.stringify(cfg, null, 2));
|
|
850
|
+
} else {
|
|
851
|
+
logger.success("Phase 92 config updated");
|
|
852
|
+
for (const [k, v] of Object.entries(cfg)) {
|
|
853
|
+
logger.log(` ${chalk.bold(k + ":")} ${v}`);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
} catch (err) {
|
|
857
|
+
logger.error(`Failed: ${err.message}`);
|
|
858
|
+
process.exit(1);
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// dao config-v2 (read-only)
|
|
863
|
+
dao
|
|
864
|
+
.command("config-v2")
|
|
865
|
+
.description("Show Phase 92 governance config")
|
|
866
|
+
.option("--json", "Output as JSON")
|
|
867
|
+
.action((options) => {
|
|
868
|
+
const cfg = getConfigV2();
|
|
869
|
+
if (options.json) {
|
|
870
|
+
console.log(JSON.stringify(cfg, null, 2));
|
|
871
|
+
} else {
|
|
872
|
+
for (const [k, v] of Object.entries(cfg)) {
|
|
873
|
+
logger.log(` ${chalk.bold(k + ":")} ${v}`);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
});
|
|
312
877
|
}
|