solforge 0.2.4 → 0.2.6
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/README.md +471 -79
- package/cli.cjs +106 -78
- package/package.json +1 -1
- package/scripts/install.sh +1 -1
- package/scripts/postinstall.cjs +69 -61
- package/server/lib/base58.ts +1 -1
- package/server/methods/account/get-account-info.ts +3 -7
- package/server/methods/account/get-balance.ts +3 -7
- package/server/methods/account/get-multiple-accounts.ts +2 -1
- package/server/methods/account/get-parsed-account-info.ts +3 -7
- package/server/methods/account/parsers/index.ts +2 -2
- package/server/methods/account/parsers/loader-upgradeable.ts +14 -1
- package/server/methods/account/parsers/spl-token.ts +29 -10
- package/server/methods/account/request-airdrop.ts +44 -31
- package/server/methods/block/get-block.ts +3 -7
- package/server/methods/block/get-blocks-with-limit.ts +3 -7
- package/server/methods/block/is-blockhash-valid.ts +3 -7
- package/server/methods/get-address-lookup-table.ts +3 -7
- package/server/methods/program/get-program-accounts.ts +9 -9
- package/server/methods/program/get-token-account-balance.ts +3 -7
- package/server/methods/program/get-token-accounts-by-delegate.ts +4 -3
- package/server/methods/program/get-token-accounts-by-owner.ts +61 -35
- package/server/methods/program/get-token-largest-accounts.ts +3 -2
- package/server/methods/program/get-token-supply.ts +3 -2
- package/server/methods/solforge/index.ts +9 -6
- package/server/methods/transaction/get-parsed-transaction.ts +3 -7
- package/server/methods/transaction/get-signature-statuses.ts +14 -7
- package/server/methods/transaction/get-signatures-for-address.ts +3 -7
- package/server/methods/transaction/get-transaction.ts +167 -81
- package/server/methods/transaction/send-transaction.ts +29 -16
- package/server/methods/transaction/simulate-transaction.ts +3 -2
- package/server/rpc-server.ts +47 -34
- package/server/types.ts +9 -6
- package/server/ws-server.ts +15 -8
- package/src/api-server-entry.ts +91 -91
- package/src/cli/commands/airdrop.ts +2 -2
- package/src/cli/commands/config.ts +2 -2
- package/src/cli/commands/mint.ts +3 -3
- package/src/cli/commands/program-clone.ts +9 -11
- package/src/cli/commands/program-load.ts +3 -3
- package/src/cli/commands/rpc-start.ts +8 -5
- package/src/cli/commands/token-adopt-authority.ts +1 -1
- package/src/cli/commands/token-clone.ts +5 -6
- package/src/cli/commands/token-create.ts +5 -5
- package/src/cli/main.ts +38 -37
- package/src/cli/run-solforge.ts +20 -6
- package/src/cli/setup-wizard.ts +8 -6
- package/src/commands/add-program.ts +324 -328
- package/src/commands/init.ts +106 -106
- package/src/commands/list.ts +125 -125
- package/src/commands/mint.ts +247 -248
- package/src/commands/start.ts +837 -833
- package/src/commands/status.ts +80 -80
- package/src/commands/stop.ts +381 -382
- package/src/config/index.ts +33 -17
- package/src/config/manager.ts +150 -150
- package/src/db/index.ts +2 -2
- package/src/db/tx-store.ts +12 -8
- package/src/gui/public/app.css +1556 -1
- package/src/gui/public/build/main.css +1569 -1
- package/src/gui/server.ts +21 -22
- package/src/gui/src/api.ts +1 -1
- package/src/gui/src/app.tsx +96 -45
- package/src/gui/src/components/airdrop-mint-form.tsx +49 -19
- package/src/gui/src/components/clone-program-modal.tsx +31 -12
- package/src/gui/src/components/clone-token-modal.tsx +32 -13
- package/src/gui/src/components/modal.tsx +18 -11
- package/src/gui/src/components/programs-panel.tsx +27 -15
- package/src/gui/src/components/status-panel.tsx +32 -18
- package/src/gui/src/components/tokens-panel.tsx +25 -19
- package/src/gui/src/index.css +491 -463
- package/src/index.ts +177 -149
- package/src/rpc/start.ts +1 -1
- package/src/services/api-server.ts +494 -475
- package/src/services/port-manager.ts +164 -167
- package/src/services/process-registry.ts +144 -145
- package/src/services/program-cloner.ts +312 -312
- package/src/services/token-cloner.ts +799 -797
- package/src/services/validator.ts +288 -290
- package/src/types/config.ts +72 -72
- package/src/utils/shell.ts +75 -75
- package/src/utils/token-loader.ts +78 -78
package/src/index.ts
CHANGED
|
@@ -2,187 +2,215 @@
|
|
|
2
2
|
|
|
3
3
|
// Suppress bigint-buffer warning
|
|
4
4
|
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
5
|
-
process.stderr.write =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
process.stderr.write = ((
|
|
6
|
+
chunk: unknown,
|
|
7
|
+
encoding?: unknown,
|
|
8
|
+
callback?: unknown,
|
|
9
|
+
) => {
|
|
10
|
+
if (
|
|
11
|
+
typeof chunk === "string" &&
|
|
12
|
+
chunk.includes("bigint: Failed to load bindings")
|
|
13
|
+
) {
|
|
14
|
+
return true; // Suppress this specific warning
|
|
15
|
+
}
|
|
16
|
+
const writer = originalStderrWrite as unknown as (
|
|
17
|
+
chunk: string | Uint8Array,
|
|
18
|
+
encoding?: BufferEncoding,
|
|
19
|
+
callback?: ((err?: Error) => void) | undefined,
|
|
20
|
+
) => boolean;
|
|
21
|
+
return writer(
|
|
22
|
+
chunk as string | Uint8Array,
|
|
23
|
+
encoding as BufferEncoding | undefined,
|
|
24
|
+
callback as ((err?: Error) => void) | undefined,
|
|
25
|
+
);
|
|
26
|
+
}) as typeof process.stderr.write;
|
|
11
27
|
|
|
12
|
-
import { Command } from "commander";
|
|
13
28
|
import chalk from "chalk";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
29
|
+
import { Command } from "commander";
|
|
30
|
+
import { existsSync } from "node:fs";
|
|
31
|
+
import { resolve } from "node:path";
|
|
32
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
33
|
+
import { addProgramCommand } from "./commands/add-program.js";
|
|
16
34
|
import { initCommand } from "./commands/init.js";
|
|
17
|
-
import { statusCommand } from "./commands/status.js";
|
|
18
|
-
import { startCommand } from "./commands/start.js";
|
|
19
|
-
import { mintCommand } from "./commands/mint.js";
|
|
20
35
|
import { listCommand } from "./commands/list.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
36
|
+
import { mintCommand } from "./commands/mint.js";
|
|
37
|
+
import { startCommand } from "./commands/start.js";
|
|
38
|
+
import { statusCommand } from "./commands/status.js";
|
|
39
|
+
import { killCommand, stopCommand } from "./commands/stop.js";
|
|
24
40
|
|
|
25
41
|
const program = new Command();
|
|
26
42
|
|
|
27
43
|
program
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
.name("solforge")
|
|
45
|
+
.description("Solana localnet orchestration tool")
|
|
46
|
+
.version(packageJson.version);
|
|
31
47
|
|
|
32
48
|
// Check for sf.config.json in current directory
|
|
33
49
|
function findConfig(): string | null {
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
const configPath = resolve(process.cwd(), "sf.config.json");
|
|
51
|
+
return existsSync(configPath) ? configPath : null;
|
|
36
52
|
}
|
|
37
53
|
|
|
38
54
|
program
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
.command("init")
|
|
56
|
+
.description("Initialize a new sf.config.json in current directory")
|
|
57
|
+
.action(async () => {
|
|
58
|
+
console.log(chalk.blue("🚀 Initializing SolForge configuration..."));
|
|
59
|
+
await initCommand();
|
|
60
|
+
});
|
|
45
61
|
|
|
46
62
|
program
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
.command("start")
|
|
64
|
+
.description("Start localnet with current sf.config.json")
|
|
65
|
+
.option("--debug", "Enable debug logging to see commands and detailed output")
|
|
66
|
+
.option(
|
|
67
|
+
"--network",
|
|
68
|
+
"Make API server accessible over network (binds to 0.0.0.0 instead of 127.0.0.1)",
|
|
69
|
+
)
|
|
70
|
+
.action(async (options) => {
|
|
71
|
+
const configPath = findConfig();
|
|
72
|
+
if (!configPath) {
|
|
73
|
+
console.error(
|
|
74
|
+
chalk.red("❌ No sf.config.json found in current directory"),
|
|
75
|
+
);
|
|
76
|
+
console.log(chalk.yellow("💡 Run `solforge init` to create one"));
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
await startCommand(options.debug || false, options.network || false);
|
|
81
|
+
});
|
|
63
82
|
|
|
64
83
|
program
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
.command("list")
|
|
85
|
+
.description("List all running validators")
|
|
86
|
+
.action(async () => {
|
|
87
|
+
await listCommand();
|
|
88
|
+
});
|
|
70
89
|
|
|
71
90
|
program
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
.command("stop")
|
|
92
|
+
.description("Stop running validator(s)")
|
|
93
|
+
.argument("[validator-id]", "ID of validator to stop")
|
|
94
|
+
.option("--all", "Stop all running validators")
|
|
95
|
+
.option("--kill", "Force kill the validator (SIGKILL instead of SIGTERM)")
|
|
96
|
+
.action(async (validatorId, options) => {
|
|
97
|
+
await stopCommand(validatorId, options);
|
|
98
|
+
});
|
|
80
99
|
|
|
81
100
|
program
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
101
|
+
.command("kill")
|
|
102
|
+
.description("Force kill running validator(s)")
|
|
103
|
+
.argument("[validator-id]", "ID of validator to kill")
|
|
104
|
+
.option("--all", "Kill all running validators")
|
|
105
|
+
.action(async (validatorId, options) => {
|
|
106
|
+
await killCommand(validatorId, options);
|
|
107
|
+
});
|
|
89
108
|
|
|
90
109
|
program
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
110
|
+
.command("api-server")
|
|
111
|
+
.description("Start API server standalone")
|
|
112
|
+
.option("-p, --port <port>", "Port for API server", "3000")
|
|
113
|
+
.option(
|
|
114
|
+
"--host <host>",
|
|
115
|
+
"Host to bind to (default: 127.0.0.1, use 0.0.0.0 for network access)",
|
|
116
|
+
)
|
|
117
|
+
.option("--rpc-url <url>", "Validator RPC URL", "http://127.0.0.1:8899")
|
|
118
|
+
.option("--faucet-url <url>", "Validator faucet URL", "http://127.0.0.1:9900")
|
|
119
|
+
.option("--work-dir <dir>", "Work directory", "./.solforge")
|
|
120
|
+
.action(async (options) => {
|
|
121
|
+
const configPath = findConfig();
|
|
122
|
+
if (!configPath) {
|
|
123
|
+
console.error(
|
|
124
|
+
chalk.red("❌ No sf.config.json found in current directory"),
|
|
125
|
+
);
|
|
126
|
+
console.log(chalk.yellow("💡 Run `solforge init` to create one"));
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Import API server components
|
|
131
|
+
const { APIServer } = await import("./services/api-server.js");
|
|
132
|
+
const { configManager } = await import("./config/manager.js");
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
await configManager.load(configPath);
|
|
136
|
+
const config = configManager.getConfig();
|
|
137
|
+
|
|
138
|
+
const apiServer = new APIServer({
|
|
139
|
+
port: parseInt(options.port, 10),
|
|
140
|
+
host: options.host,
|
|
141
|
+
validatorRpcUrl: options.rpcUrl,
|
|
142
|
+
validatorFaucetUrl: options.faucetUrl,
|
|
143
|
+
config,
|
|
144
|
+
workDir: options.workDir,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const result = await apiServer.start();
|
|
148
|
+
if (result.success) {
|
|
149
|
+
console.log(chalk.green("✅ API Server started successfully!"));
|
|
150
|
+
|
|
151
|
+
// Keep the process alive
|
|
152
|
+
process.on("SIGTERM", async () => {
|
|
153
|
+
console.log(
|
|
154
|
+
chalk.yellow("📡 API Server received SIGTERM, shutting down..."),
|
|
155
|
+
);
|
|
156
|
+
await apiServer.stop();
|
|
157
|
+
process.exit(0);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
process.on("SIGINT", async () => {
|
|
161
|
+
console.log(
|
|
162
|
+
chalk.yellow("📡 API Server received SIGINT, shutting down..."),
|
|
163
|
+
);
|
|
164
|
+
await apiServer.stop();
|
|
165
|
+
process.exit(0);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Keep process alive
|
|
169
|
+
setInterval(() => {}, 1000);
|
|
170
|
+
} else {
|
|
171
|
+
console.error(
|
|
172
|
+
chalk.red(`❌ Failed to start API server: ${result.error}`),
|
|
173
|
+
);
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error(
|
|
178
|
+
chalk.red(
|
|
179
|
+
`❌ API Server error: ${
|
|
180
|
+
error instanceof Error ? error.message : String(error)
|
|
181
|
+
}`,
|
|
182
|
+
),
|
|
183
|
+
);
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
159
187
|
|
|
160
188
|
program
|
|
161
|
-
|
|
162
|
-
|
|
189
|
+
.command("add-program")
|
|
190
|
+
.description("Add a program to sf.config.json")
|
|
163
191
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
192
|
+
.option("--program-id <address>", "Mainnet program ID to clone and deploy")
|
|
193
|
+
.option("--name <name>", "Friendly name for the program")
|
|
194
|
+
.option("--no-interactive", "Run in non-interactive mode")
|
|
195
|
+
.action(async (options) => {
|
|
196
|
+
await addProgramCommand(options);
|
|
197
|
+
});
|
|
170
198
|
|
|
171
199
|
program
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
200
|
+
.command("status")
|
|
201
|
+
.description("Show localnet status")
|
|
202
|
+
.action(async () => {
|
|
203
|
+
await statusCommand();
|
|
204
|
+
});
|
|
177
205
|
|
|
178
206
|
program.addCommand(mintCommand);
|
|
179
207
|
|
|
180
208
|
program
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
209
|
+
.command("reset")
|
|
210
|
+
.description("Reset localnet ledger")
|
|
211
|
+
.action(async () => {
|
|
212
|
+
console.log(chalk.blue("🔄 Resetting localnet..."));
|
|
213
|
+
// TODO: Implement reset
|
|
214
|
+
});
|
|
187
215
|
|
|
188
216
|
program.parse();
|
package/src/rpc/start.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function startRpcServers(opts: RpcStartOptions = {}) {
|
|
|
27
27
|
if (opts.dbPath) process.env.SOLFORGE_DB_PATH = opts.dbPath;
|
|
28
28
|
|
|
29
29
|
const { httpServer, rpcServer } = createLiteSVMRpcServer(rpcPort, host);
|
|
30
|
-
const { wsServer } = createLiteSVMWebSocketServer(rpcServer, wsPort);
|
|
30
|
+
const { wsServer } = createLiteSVMWebSocketServer(rpcServer, wsPort, host);
|
|
31
31
|
const guiServer = guiEnabled
|
|
32
32
|
? startGuiServer({ port: guiPort, host, rpcPort, rpcServer })
|
|
33
33
|
: null;
|