@hardkas/cli 0.2.2-alpha.1 → 0.4.0-alpha
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/accounts-keystore-runners-QYSNZMZV.js +155 -0
- package/dist/{artifact-lineage-runner-RJWQ3R3X.js → artifact-lineage-runner-TY4YTE6H.js} +6 -2
- package/dist/bridge-local-runner-E3LICYYX.js +174 -0
- package/dist/{chunk-AQWQW5ZG.js → chunk-K7XPWWIO.js} +45 -1
- package/dist/chunk-KA5CAWI2.js +163 -0
- package/dist/chunk-ZM2NBOAE.js +37 -0
- package/dist/{dag-runners-YQDHD7U6.js → dag-runners-NLBYR7I7.js} +2 -2
- package/dist/deployment-runners-GEICABEH.js +15 -0
- package/dist/dev-doctor-runner-LTSENPQ3.js +145 -0
- package/dist/dev-server-runner-IM5DCDD3.js +45 -0
- package/dist/index.js +2145 -560
- package/dist/kaspa-doctor-runner-F2ISPABM.js +81 -0
- package/dist/kaspa-wallet-runner-ORJ5YFKU.js +179 -0
- package/dist/local-wizard-runner-GCAWGZ6D.js +144 -0
- package/dist/metamask-runner-PRIOW4J3.js +132 -0
- package/dist/replay-verify-runner-Y3RARVD7.js +50 -0
- package/dist/{rpc-doctor-runner-ERWXOXSE.js → rpc-doctor-runner-V7H7AAX4.js} +1 -1
- package/dist/session-runner-LDSGDP47.js +118 -0
- package/dist/{snapshot-restore-runner-QNAADGBX.js → snapshot-restore-runner-KIJNPLDV.js} +1 -1
- package/dist/{snapshot-verify-runner-BWRW3NUW.js → snapshot-verify-runner-PGMADWLN.js} +1 -1
- package/dist/{tx-verify-runner-Z5M2JDRI.js → tx-verify-runner-6EGY5ZN4.js} +11 -2
- package/dist/ui-SUYOHGGP.js +10 -0
- package/package.json +26 -15
- package/dist/accounts-keystore-runners-MCJIAGZ4.js +0 -112
- package/dist/replay-verify-runner-UMYALHNT.js +0 -37
- package/dist/ui-OVK5PX6H.js +0 -8
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleError
|
|
3
|
+
} from "./chunk-K7XPWWIO.js";
|
|
4
|
+
|
|
5
|
+
// src/runners/dev-doctor-runner.ts
|
|
6
|
+
import pc from "picocolors";
|
|
7
|
+
import { loadHardkasConfig } from "@hardkas/config";
|
|
8
|
+
async function runDevDoctor(options) {
|
|
9
|
+
const checks = [];
|
|
10
|
+
let finalStatus = "ready";
|
|
11
|
+
const timeoutMs = options.timeout ? parseInt(options.timeout, 10) : 3e3;
|
|
12
|
+
try {
|
|
13
|
+
const config = await loadHardkasConfig();
|
|
14
|
+
const networkId = config.config.networkId || config.config.defaultNetwork || "simnet";
|
|
15
|
+
const { getL2NetworkProfile, EvmJsonRpcClient, generateAddEthereumChainPayload } = await import("@hardkas/l2");
|
|
16
|
+
const { listHardkasAccounts } = await import("@hardkas/accounts");
|
|
17
|
+
let profile;
|
|
18
|
+
try {
|
|
19
|
+
profile = await getL2NetworkProfile({
|
|
20
|
+
name: options.profile,
|
|
21
|
+
userProfiles: config.config.l2?.networks,
|
|
22
|
+
cliOverrides: {
|
|
23
|
+
rpcUrl: options.rpcUrl || (networkId === "simnet" || networkId === "localnet" ? "http://127.0.0.1:8545" : void 0),
|
|
24
|
+
chainId: networkId === "simnet" || networkId === "localnet" ? 19416 : void 0
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
} catch (e) {
|
|
28
|
+
checks.push({ name: "L2 Profile", status: "error", message: e.message });
|
|
29
|
+
finalStatus = "failed";
|
|
30
|
+
}
|
|
31
|
+
if (profile) {
|
|
32
|
+
const rpcUrl = options.rpcUrl || profile.rpcUrl;
|
|
33
|
+
if (rpcUrl) {
|
|
34
|
+
const client = new EvmJsonRpcClient({ url: rpcUrl, timeoutMs });
|
|
35
|
+
try {
|
|
36
|
+
const block = await client.getBlockNumber();
|
|
37
|
+
checks.push({ name: "Igra RPC Connectivity", status: "success", message: `Reachable (Block #${block})` });
|
|
38
|
+
} catch (e) {
|
|
39
|
+
checks.push({ name: "Igra RPC Connectivity", status: "error", message: `Unreachable: ${e.message}` });
|
|
40
|
+
finalStatus = "failed";
|
|
41
|
+
}
|
|
42
|
+
if (profile.chainId !== void 0) {
|
|
43
|
+
try {
|
|
44
|
+
const chainId = await client.getChainId();
|
|
45
|
+
if (chainId === profile.chainId) {
|
|
46
|
+
checks.push({ name: "Chain ID Verification", status: "success", message: `Matches profile (${chainId})` });
|
|
47
|
+
} else {
|
|
48
|
+
checks.push({ name: "Chain ID Verification", status: "error", message: `Mismatch: profile expects ${profile.chainId}, node reports ${chainId}` });
|
|
49
|
+
finalStatus = "failed";
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const gasPrice = await client.getGasPriceWei();
|
|
56
|
+
checks.push({ name: "Gas Price Check", status: "success", message: `Responds (${gasPrice.toString()} wei)` });
|
|
57
|
+
} catch (e) {
|
|
58
|
+
}
|
|
59
|
+
const accounts = listHardkasAccounts(config.config);
|
|
60
|
+
const evmAccounts = accounts.filter((a) => a.kind === "evm-private-key");
|
|
61
|
+
let targetAccount = options.account ? evmAccounts.find((a) => a.name === options.account) : evmAccounts[0];
|
|
62
|
+
if (targetAccount) {
|
|
63
|
+
checks.push({ name: "Local EVM Account", status: "success", message: `Found "${targetAccount.name}" (${targetAccount.address})` });
|
|
64
|
+
if (targetAccount.address) {
|
|
65
|
+
try {
|
|
66
|
+
const balance = await client.getBalanceWei(targetAccount.address);
|
|
67
|
+
const kasBalance = Number(balance) / 1e18;
|
|
68
|
+
if (kasBalance > 0) {
|
|
69
|
+
checks.push({ name: "Account Balance", status: "success", message: `${kasBalance} iKAS` });
|
|
70
|
+
} else {
|
|
71
|
+
checks.push({ name: "Account Balance", status: "warning", message: "Zero balance (funding required)" });
|
|
72
|
+
if (finalStatus === "ready") finalStatus = "warning";
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
checks.push({ name: "Local EVM Account", status: "warning", message: "No EVM accounts found in config/store" });
|
|
79
|
+
if (finalStatus === "ready") finalStatus = "warning";
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
generateAddEthereumChainPayload(profile);
|
|
83
|
+
checks.push({ name: "MetaMask Readiness", status: "success", message: "Payload generation OK" });
|
|
84
|
+
} catch (e) {
|
|
85
|
+
checks.push({ name: "MetaMask Readiness", status: "error", message: e.message });
|
|
86
|
+
finalStatus = "failed";
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
checks.push({ name: "RPC Configuration", status: "error", message: "No RPC URL found in profile or options" });
|
|
90
|
+
finalStatus = "failed";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (finalStatus === "failed") {
|
|
94
|
+
process.exitCode = 1;
|
|
95
|
+
}
|
|
96
|
+
if (options.json) {
|
|
97
|
+
const result = {
|
|
98
|
+
schema: "hardkas.devDoctor.v1",
|
|
99
|
+
status: finalStatus,
|
|
100
|
+
checks
|
|
101
|
+
};
|
|
102
|
+
console.log(JSON.stringify(result, null, 2));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
console.log(pc.bold("\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"));
|
|
106
|
+
console.log(pc.bold(`HardKAS \u2022 Dev Doctor`));
|
|
107
|
+
console.log(pc.bold("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n"));
|
|
108
|
+
for (const check of checks) {
|
|
109
|
+
const icon = check.status === "success" ? pc.green("\u2713") : check.status === "warning" ? pc.yellow("\u26A0") : pc.red("\u2717");
|
|
110
|
+
console.log(`${icon} ${pc.bold(check.name)}: ${check.message}`);
|
|
111
|
+
}
|
|
112
|
+
console.log(pc.bold("\nStatus: ") + (finalStatus === "ready" ? pc.green("READY") : finalStatus === "warning" ? pc.yellow("WARNING") : pc.red("FAILED")));
|
|
113
|
+
if (finalStatus === "ready") {
|
|
114
|
+
const accName = options.account || "alice_evm";
|
|
115
|
+
console.log(`
|
|
116
|
+
${pc.cyan("Next steps:")}`);
|
|
117
|
+
console.log(` hardkas metamask account ${pc.white(accName)} --show-private-key
|
|
118
|
+
`);
|
|
119
|
+
} else if (finalStatus === "failed") {
|
|
120
|
+
console.log(`
|
|
121
|
+
${pc.red("Fix recommendations:")}`);
|
|
122
|
+
if (checks.some((c) => c.name === "Igra RPC Connectivity" && c.status === "error")) {
|
|
123
|
+
console.log(` - Ensure your local Igra/EVM node is running on ${pc.white("http://127.0.0.1:8545")}`);
|
|
124
|
+
console.log(` - Or use ${pc.cyan("--rpc-url <url>")} to specify a different node.`);
|
|
125
|
+
}
|
|
126
|
+
if (checks.some((c) => c.name === "Chain ID Verification" && c.status === "error")) {
|
|
127
|
+
console.log(` - Your profile expect ${pc.white(profile?.chainId)}, but the node is on another network.`);
|
|
128
|
+
}
|
|
129
|
+
console.log("");
|
|
130
|
+
} else if (finalStatus === "warning") {
|
|
131
|
+
console.log(`
|
|
132
|
+
${pc.yellow("Recommendations:")}`);
|
|
133
|
+
if (checks.some((c) => c.name === "Account Balance" && c.status === "warning")) {
|
|
134
|
+
console.log(` - Fund your account: ${pc.white("hardkas wallet fund <name> --l2")}`);
|
|
135
|
+
}
|
|
136
|
+
console.log("");
|
|
137
|
+
}
|
|
138
|
+
} catch (e) {
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
handleError(e);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
runDevDoctor
|
|
145
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleError
|
|
3
|
+
} from "./chunk-K7XPWWIO.js";
|
|
4
|
+
|
|
5
|
+
// src/runners/dev-server-runner.ts
|
|
6
|
+
import pc from "picocolors";
|
|
7
|
+
async function runDevServer(options) {
|
|
8
|
+
try {
|
|
9
|
+
const { createDevServer } = await import("@hardkas/dev-server");
|
|
10
|
+
const port = parseInt(options.port, 10);
|
|
11
|
+
let host = options.host;
|
|
12
|
+
if (options.unsafeExternal && options.host === "localhost") {
|
|
13
|
+
host = "0.0.0.0";
|
|
14
|
+
}
|
|
15
|
+
if (options.json) {
|
|
16
|
+
console.log(JSON.stringify({
|
|
17
|
+
schema: "hardkas.devServer.v1",
|
|
18
|
+
status: "running",
|
|
19
|
+
url: `http://${host}:${port}`,
|
|
20
|
+
config: { port, host, unsafeExternal: options.unsafeExternal }
|
|
21
|
+
}, null, 2));
|
|
22
|
+
}
|
|
23
|
+
const server = createDevServer({
|
|
24
|
+
port,
|
|
25
|
+
host,
|
|
26
|
+
unsafeExternal: options.unsafeExternal,
|
|
27
|
+
open: options.open
|
|
28
|
+
});
|
|
29
|
+
console.log(pc.bold("\nHardKas Dev Server"));
|
|
30
|
+
console.log(pc.dim("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"));
|
|
31
|
+
server.start();
|
|
32
|
+
console.log(pc.dim("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"));
|
|
33
|
+
console.log(pc.yellow("LOCAL DEV ONLY"));
|
|
34
|
+
console.log(pc.dim("Press Ctrl+C to stop.\n"));
|
|
35
|
+
process.on("SIGINT", () => {
|
|
36
|
+
console.log("\nStopping Dev Server...");
|
|
37
|
+
process.exit(0);
|
|
38
|
+
});
|
|
39
|
+
} catch (e) {
|
|
40
|
+
handleError(e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
runDevServer
|
|
45
|
+
};
|