coherence-cli 0.7.1 → 0.8.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.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Treasury commands: treasury, treasury deposits, treasury deposit
3
+ */
4
+
5
+ import { get, post } from "../api.mjs";
6
+
7
+ export async function showTreasury() {
8
+ const data = await get("/api/treasury");
9
+ if (!data) {
10
+ console.log("Could not fetch treasury.");
11
+ return;
12
+ }
13
+
14
+ console.log();
15
+ console.log(`\x1b[1m TREASURY\x1b[0m`);
16
+ console.log(` ${"─".repeat(50)}`);
17
+ if (data.total != null) console.log(` Total: ${data.total}`);
18
+ if (data.balance != null) console.log(` Balance: ${data.balance}`);
19
+ if (data.deposits_count != null) console.log(` Deposits: ${data.deposits_count}`);
20
+ if (data.last_updated) console.log(` Updated: ${data.last_updated}`);
21
+ // Fallback: print all keys
22
+ const shown = new Set(["total", "balance", "deposits_count", "last_updated"]);
23
+ for (const [key, val] of Object.entries(data)) {
24
+ if (!shown.has(key) && val != null) {
25
+ console.log(` ${key}: ${JSON.stringify(val)}`);
26
+ }
27
+ }
28
+ console.log();
29
+ }
30
+
31
+ export async function showDeposits(args) {
32
+ const contributor = args[0];
33
+ if (!contributor) {
34
+ console.log("Usage: cc treasury deposits <contributor-id>");
35
+ return;
36
+ }
37
+ const data = await get(`/api/treasury/deposits/${encodeURIComponent(contributor)}`);
38
+ const deposits = Array.isArray(data) ? data : data?.deposits;
39
+ if (!deposits || !Array.isArray(deposits)) {
40
+ console.log(`No deposits found for '${contributor}'.`);
41
+ return;
42
+ }
43
+
44
+ console.log();
45
+ console.log(`\x1b[1m DEPOSITS\x1b[0m for ${contributor} (${deposits.length})`);
46
+ console.log(` ${"─".repeat(60)}`);
47
+ for (const d of deposits) {
48
+ const amount = d.amount != null ? `${d.amount}` : "?";
49
+ const asset = d.asset || d.asset_type || "";
50
+ const date = d.created_at ? d.created_at.slice(0, 10) : "";
51
+ console.log(` ${amount.padEnd(12)} ${asset.padEnd(15)} ${date}`);
52
+ }
53
+ console.log();
54
+ }
55
+
56
+ export async function makeDeposit(args) {
57
+ const amount = parseFloat(args[0]);
58
+ const asset = args[1];
59
+ if (isNaN(amount) || !asset) {
60
+ console.log("Usage: cc treasury deposit <amount> <asset>");
61
+ return;
62
+ }
63
+ const result = await post("/api/treasury/deposit", { amount, asset });
64
+ if (result) {
65
+ console.log(`\x1b[32m✓\x1b[0m Deposited ${amount} ${asset}`);
66
+ } else {
67
+ console.log("Deposit failed.");
68
+ }
69
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coherence-cli",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Coherence Network CLI \u2014 trace ideas from inception to payout, with fair attribution, coherence scoring, and 37 identity providers. No signup needed.",
5
5
  "type": "module",
6
6
  "bin": {