@chainalert/cli 0.0.1
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/alerts-STXD4TE5.js +134 -0
- package/dist/auth-6LTJFNU2.js +124 -0
- package/dist/channels-C5JZON37.js +179 -0
- package/dist/chunk-6FDEYAAT.js +27 -0
- package/dist/chunk-CE4DKHAY.js +28 -0
- package/dist/chunk-IC5RERFB.js +185 -0
- package/dist/chunk-K2BGDX7X.js +38 -0
- package/dist/chunk-WPW7UBVR.js +95 -0
- package/dist/contracts-J7JYPQXP.js +108 -0
- package/dist/detections-QSMNEXXI.js +282 -0
- package/dist/events-FM7VK5VH.js +104 -0
- package/dist/health-7R5HLRCZ.js +40 -0
- package/dist/index.js +159 -0
- package/dist/networks-CF2ARYQO.js +57 -0
- package/dist/org-contracts-DM2BTHTO.js +175 -0
- package/dist/repl-Q43IBAFT.js +1657 -0
- package/dist/rpc-configs-P2QCFCDJ.js +112 -0
- package/dist/state-changes-B6BIS4OJ.js +67 -0
- package/dist/templates-LYY2SV42.js +106 -0
- package/package.json +36 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
spinner
|
|
4
|
+
} from "./chunk-CE4DKHAY.js";
|
|
5
|
+
import {
|
|
6
|
+
addRpcConfig,
|
|
7
|
+
listRpcConfigs,
|
|
8
|
+
testRpcConfig
|
|
9
|
+
} from "./chunk-IC5RERFB.js";
|
|
10
|
+
import "./chunk-K2BGDX7X.js";
|
|
11
|
+
import {
|
|
12
|
+
print,
|
|
13
|
+
printError,
|
|
14
|
+
printJson,
|
|
15
|
+
printSuccess,
|
|
16
|
+
printTable
|
|
17
|
+
} from "./chunk-WPW7UBVR.js";
|
|
18
|
+
|
|
19
|
+
// src/commands/rpc-configs.ts
|
|
20
|
+
async function run(args, flags) {
|
|
21
|
+
const sub = args[0] ?? "list";
|
|
22
|
+
switch (sub) {
|
|
23
|
+
case "list": {
|
|
24
|
+
try {
|
|
25
|
+
spinner.start("Fetching RPC configs...");
|
|
26
|
+
const result = await listRpcConfigs();
|
|
27
|
+
spinner.stop();
|
|
28
|
+
if (flags.json) {
|
|
29
|
+
printJson(result);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!result.data.length) {
|
|
33
|
+
print("No RPC configs found.");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
printTable(
|
|
37
|
+
["ID", "Network", "URL", "Status"],
|
|
38
|
+
result.data.map((r) => [
|
|
39
|
+
String(r.id),
|
|
40
|
+
r.networkSlug ?? r.networkId ?? "",
|
|
41
|
+
r.rpcUrl ?? r.url ?? "",
|
|
42
|
+
r.status ?? r.healthy !== void 0 ? r.healthy ? "Healthy" : "Unhealthy" : ""
|
|
43
|
+
])
|
|
44
|
+
);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
spinner.stop();
|
|
47
|
+
printError(err.message ?? "Failed to fetch RPC configs.");
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case "add": {
|
|
53
|
+
if (!flags.network) {
|
|
54
|
+
printError("--network is required.");
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!flags.url) {
|
|
59
|
+
printError("--url is required.");
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
spinner.start("Adding RPC config...");
|
|
65
|
+
const result = await addRpcConfig({
|
|
66
|
+
networkId: flags.network,
|
|
67
|
+
rpcUrl: flags.url
|
|
68
|
+
});
|
|
69
|
+
spinner.stop();
|
|
70
|
+
if (flags.json) {
|
|
71
|
+
printJson(result);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
printSuccess(`RPC config added: ${result.data.id}`);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
spinner.stop();
|
|
77
|
+
printError(err.message ?? "Failed to add RPC config.");
|
|
78
|
+
process.exitCode = 1;
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "test": {
|
|
83
|
+
const id = args[1];
|
|
84
|
+
if (!id) {
|
|
85
|
+
printError("Usage: chainalert rpc-configs test <id>");
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
spinner.start("Testing RPC config...");
|
|
91
|
+
const result = await testRpcConfig(id);
|
|
92
|
+
spinner.stop();
|
|
93
|
+
if (flags.json) {
|
|
94
|
+
printJson(result);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
printSuccess("RPC config is reachable.");
|
|
98
|
+
} catch (err) {
|
|
99
|
+
spinner.stop();
|
|
100
|
+
printError(err.message ?? "Failed to test RPC config.");
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
default:
|
|
106
|
+
printError(`Unknown subcommand: ${sub}. Use: list, add, test`);
|
|
107
|
+
process.exitCode = 1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
run
|
|
112
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
spinner
|
|
4
|
+
} from "./chunk-CE4DKHAY.js";
|
|
5
|
+
import {
|
|
6
|
+
listStateChanges
|
|
7
|
+
} from "./chunk-IC5RERFB.js";
|
|
8
|
+
import "./chunk-K2BGDX7X.js";
|
|
9
|
+
import {
|
|
10
|
+
dim,
|
|
11
|
+
print,
|
|
12
|
+
printError,
|
|
13
|
+
printJson,
|
|
14
|
+
printTable
|
|
15
|
+
} from "./chunk-WPW7UBVR.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/state-changes.ts
|
|
18
|
+
async function run(args, flags) {
|
|
19
|
+
const sub = args[0] ?? "list";
|
|
20
|
+
switch (sub) {
|
|
21
|
+
case "list": {
|
|
22
|
+
try {
|
|
23
|
+
spinner.start("Fetching state changes...");
|
|
24
|
+
const result = await listStateChanges({
|
|
25
|
+
detectionId: flags.detection,
|
|
26
|
+
page: flags.page ? Number(flags.page) : void 0,
|
|
27
|
+
limit: flags.limit ? Number(flags.limit) : void 0
|
|
28
|
+
});
|
|
29
|
+
spinner.stop();
|
|
30
|
+
if (flags.json) {
|
|
31
|
+
printJson(result);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!result.data.length) {
|
|
35
|
+
print("No state changes found.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
printTable(
|
|
39
|
+
["ID", "Detection", "Slot", "Old Value", "New Value", "Block"],
|
|
40
|
+
result.data.map((s) => [
|
|
41
|
+
String(s.id),
|
|
42
|
+
s.detectionId ?? "",
|
|
43
|
+
s.slot ?? s.slotKey ?? "",
|
|
44
|
+
s.oldValue ?? "",
|
|
45
|
+
s.newValue ?? "",
|
|
46
|
+
s.blockNumber ? String(s.blockNumber) : ""
|
|
47
|
+
])
|
|
48
|
+
);
|
|
49
|
+
if (result.meta) {
|
|
50
|
+
print(dim(`
|
|
51
|
+
Page ${result.meta.page ?? 1} of ${result.meta.totalPages ?? "?"} (${result.meta.total ?? "?"} total)`));
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
spinner.stop();
|
|
55
|
+
printError(err.message ?? "Failed to fetch state changes.");
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
printError(`Unknown subcommand: ${sub}. Use: list`);
|
|
62
|
+
process.exitCode = 1;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
run
|
|
67
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
spinner
|
|
4
|
+
} from "./chunk-CE4DKHAY.js";
|
|
5
|
+
import {
|
|
6
|
+
getTemplate,
|
|
7
|
+
listTemplates
|
|
8
|
+
} from "./chunk-IC5RERFB.js";
|
|
9
|
+
import "./chunk-K2BGDX7X.js";
|
|
10
|
+
import {
|
|
11
|
+
bold,
|
|
12
|
+
dim,
|
|
13
|
+
print,
|
|
14
|
+
printError,
|
|
15
|
+
printJson,
|
|
16
|
+
printKV,
|
|
17
|
+
printTable
|
|
18
|
+
} from "./chunk-WPW7UBVR.js";
|
|
19
|
+
|
|
20
|
+
// src/commands/templates.ts
|
|
21
|
+
async function run(args, flags) {
|
|
22
|
+
const sub = args[0] ?? "list";
|
|
23
|
+
switch (sub) {
|
|
24
|
+
case "list": {
|
|
25
|
+
try {
|
|
26
|
+
spinner.start("Fetching templates...");
|
|
27
|
+
const result = await listTemplates({
|
|
28
|
+
category: flags.category,
|
|
29
|
+
search: flags.search
|
|
30
|
+
});
|
|
31
|
+
spinner.stop();
|
|
32
|
+
if (flags.json) {
|
|
33
|
+
printJson(result);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!result.data.length) {
|
|
37
|
+
print("No templates found.");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
printTable(
|
|
41
|
+
["Slug", "Name", "Category", "Tier", "Severity"],
|
|
42
|
+
result.data.map((t) => [
|
|
43
|
+
t.slug ?? "",
|
|
44
|
+
t.name ?? "",
|
|
45
|
+
t.category ?? "",
|
|
46
|
+
t.tier ?? "",
|
|
47
|
+
t.defaultSeverity ?? t.severity ?? ""
|
|
48
|
+
])
|
|
49
|
+
);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
spinner.stop();
|
|
52
|
+
printError(err.message ?? "Failed to fetch templates.");
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case "get": {
|
|
58
|
+
const slug = args[1];
|
|
59
|
+
if (!slug) {
|
|
60
|
+
printError("Usage: chainalert templates get <slug>");
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
spinner.start("Fetching template...");
|
|
66
|
+
const result = await getTemplate(slug);
|
|
67
|
+
spinner.stop();
|
|
68
|
+
if (flags.json) {
|
|
69
|
+
printJson(result);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const t = result.data;
|
|
73
|
+
printKV([
|
|
74
|
+
["Slug", t.slug ?? ""],
|
|
75
|
+
["Name", t.name ?? ""],
|
|
76
|
+
["Category", t.category ?? ""],
|
|
77
|
+
["Tier", t.tier ?? ""],
|
|
78
|
+
["Severity", t.defaultSeverity ?? t.severity ?? ""],
|
|
79
|
+
["Description", t.description ?? dim("(none)")]
|
|
80
|
+
]);
|
|
81
|
+
if (t.inputs && Array.isArray(t.inputs) && t.inputs.length > 0) {
|
|
82
|
+
print("");
|
|
83
|
+
print(bold("Inputs:"));
|
|
84
|
+
for (const input of t.inputs) {
|
|
85
|
+
const required = input.required ? " (required)" : "";
|
|
86
|
+
print(` ${bold(input.key ?? input.name ?? "")}${required}`);
|
|
87
|
+
if (input.description) print(` ${dim(input.description)}`);
|
|
88
|
+
if (input.type) print(` Type: ${input.type}`);
|
|
89
|
+
if (input.default !== void 0) print(` Default: ${String(input.default)}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {
|
|
93
|
+
spinner.stop();
|
|
94
|
+
printError(err.message ?? "Failed to fetch template.");
|
|
95
|
+
process.exitCode = 1;
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
default:
|
|
100
|
+
printError(`Unknown subcommand: ${sub}. Use: list, get`);
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
run
|
|
106
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chainalert/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "ChainAlert CLI — manage blockchain monitoring from the command line",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/ChainAlert-Dev/chainalert.git",
|
|
10
|
+
"directory": "apps/cli"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/ChainAlert-Dev/chainalert/tree/master/apps/cli",
|
|
13
|
+
"bin": {
|
|
14
|
+
"chainalert": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "tsup --watch",
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"lint": "eslint src/",
|
|
23
|
+
"type-check": "tsc --noEmit",
|
|
24
|
+
"test": "vitest run --passWithNoTests"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"openai": "^4.77.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.10.5",
|
|
31
|
+
"eslint": "^9.17.0",
|
|
32
|
+
"tsup": "^8.3.6",
|
|
33
|
+
"typescript": "^5.7.3",
|
|
34
|
+
"vitest": "^4.0.18"
|
|
35
|
+
}
|
|
36
|
+
}
|