solforge 0.2.0 → 0.2.2

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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/docs/API.md +379 -0
  3. package/docs/CONFIGURATION.md +407 -0
  4. package/package.json +67 -45
  5. package/src/api-server-entry.ts +109 -0
  6. package/src/commands/add-program.ts +337 -0
  7. package/src/commands/init.ts +122 -0
  8. package/src/commands/list.ts +136 -0
  9. package/src/commands/mint.ts +288 -0
  10. package/src/commands/start.ts +877 -0
  11. package/src/commands/status.ts +99 -0
  12. package/src/commands/stop.ts +406 -0
  13. package/src/config/manager.ts +157 -0
  14. package/src/gui/public/build/main.css +1 -0
  15. package/src/gui/public/build/main.js +303 -0
  16. package/src/gui/public/build/main.js.txt +231 -0
  17. package/src/index.ts +188 -0
  18. package/src/services/api-server.ts +485 -0
  19. package/src/services/port-manager.ts +177 -0
  20. package/src/services/process-registry.ts +154 -0
  21. package/src/services/program-cloner.ts +317 -0
  22. package/src/services/token-cloner.ts +809 -0
  23. package/src/services/validator.ts +295 -0
  24. package/src/types/config.ts +110 -0
  25. package/src/utils/shell.ts +110 -0
  26. package/src/utils/token-loader.ts +115 -0
  27. package/.agi/agi.sqlite +0 -0
  28. package/.claude/settings.local.json +0 -9
  29. package/.github/workflows/release-binaries.yml +0 -133
  30. package/.tmp/.787ebcdbf7b8fde8-00000000.hm +0 -0
  31. package/.tmp/.bffe6efebdf8aedc-00000000.hm +0 -0
  32. package/AGENTS.md +0 -271
  33. package/CLAUDE.md +0 -106
  34. package/PROJECT_STRUCTURE.md +0 -124
  35. package/SOLANA_KIT_GUIDE.md +0 -251
  36. package/SOLFORGE.md +0 -119
  37. package/biome.json +0 -34
  38. package/bun.lock +0 -743
  39. package/drizzle/0000_friendly_millenium_guard.sql +0 -53
  40. package/drizzle/0001_stale_sentinels.sql +0 -2
  41. package/drizzle/meta/0000_snapshot.json +0 -329
  42. package/drizzle/meta/0001_snapshot.json +0 -345
  43. package/drizzle/meta/_journal.json +0 -20
  44. package/drizzle.config.ts +0 -12
  45. package/index.ts +0 -21
  46. package/mint.sh +0 -47
  47. package/postcss.config.js +0 -6
  48. package/rpc-server.ts.backup +0 -519
  49. package/sf.config.json +0 -38
  50. package/tailwind.config.js +0 -27
  51. package/test-client.ts +0 -120
  52. package/tmp/inspect-html.ts +0 -4
  53. package/tmp/response-test.ts +0 -5
  54. package/tmp/test-html.ts +0 -5
  55. package/tmp/test-server.ts +0 -13
  56. package/tsconfig.json +0 -29
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 nitishxyz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/docs/API.md ADDED
@@ -0,0 +1,379 @@
1
+ # SolForge API Documentation
2
+
3
+ SolForge includes a REST API server that runs alongside your local validator, providing programmatic access to validator operations and token management.
4
+
5
+ ## Getting Started
6
+
7
+ The API server starts automatically when you run `solforge start` and is available at:
8
+
9
+ ```
10
+ http://127.0.0.1:3000/api
11
+ ```
12
+
13
+ For network access from other devices, use the `--network` flag:
14
+
15
+ ```bash
16
+ solforge start --network
17
+ ```
18
+
19
+ This makes the API server accessible at:
20
+
21
+ ```
22
+ http://0.0.0.0:3000/api
23
+ ```
24
+
25
+ The API server will:
26
+
27
+ - Start in the background when you run `solforge start`
28
+ - Stop automatically when you run `solforge stop`
29
+ - Use port 3000 by default (configurable)
30
+ - Bind to localhost by default (use `--network` for network access)
31
+
32
+ You can also run the API server standalone (without a validator):
33
+
34
+ ```bash
35
+ solforge api-server --port 8080 --host 0.0.0.0
36
+ ```
37
+
38
+ ## Base URL
39
+
40
+ All API endpoints are prefixed with `/api`:
41
+
42
+ ```
43
+ Base URL: http://127.0.0.1:3000/api
44
+ ```
45
+
46
+ ## Authentication
47
+
48
+ Currently, no authentication is required. The API server is intended for local development use only.
49
+
50
+ ## Endpoints
51
+
52
+ ### Health Check
53
+
54
+ Check if the API server is running.
55
+
56
+ ```http
57
+ GET /api/health
58
+ ```
59
+
60
+ **Response:**
61
+
62
+ ```json
63
+ {
64
+ "status": "ok",
65
+ "timestamp": "2024-01-15T10:30:00.000Z"
66
+ }
67
+ ```
68
+
69
+ ### Validator Information
70
+
71
+ Get information about the running validator.
72
+
73
+ ```http
74
+ GET /api/validator/info
75
+ ```
76
+
77
+ **Response:**
78
+
79
+ ```json
80
+ {
81
+ "version": {
82
+ "solana-core": "1.17.0"
83
+ },
84
+ "blockHeight": 12345,
85
+ "slotLeader": "11111111111111111111111111111111",
86
+ "rpcUrl": "http://127.0.0.1:8899",
87
+ "faucetUrl": "http://127.0.0.1:9900"
88
+ }
89
+ ```
90
+
91
+ ### List Tokens
92
+
93
+ Get all cloned tokens available on the validator.
94
+
95
+ ```http
96
+ GET /api/tokens
97
+ ```
98
+
99
+ **Response:**
100
+
101
+ ```json
102
+ {
103
+ "tokens": [
104
+ {
105
+ "symbol": "USDC",
106
+ "mainnetMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
107
+ "mintAuthority": "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
108
+ "recipients": [
109
+ {
110
+ "wallet": "YourWalletPublicKeyHere",
111
+ "amount": 1000000000
112
+ }
113
+ ],
114
+ "cloneMetadata": true
115
+ }
116
+ ],
117
+ "count": 1
118
+ }
119
+ ```
120
+
121
+ ### List Programs
122
+
123
+ Get all cloned programs available on the validator.
124
+
125
+ ```http
126
+ GET /api/programs
127
+ ```
128
+
129
+ **Response:**
130
+
131
+ ```json
132
+ {
133
+ "programs": [
134
+ {
135
+ "name": "Token Metadata",
136
+ "programId": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
137
+ "filePath": "/path/to/program.so"
138
+ }
139
+ ],
140
+ "count": 1
141
+ }
142
+ ```
143
+
144
+ ### Mint Tokens
145
+
146
+ Mint tokens to a specific wallet address.
147
+
148
+ ```http
149
+ POST /api/tokens/:mintAddress/mint
150
+ ```
151
+
152
+ **Parameters:**
153
+
154
+ - `mintAddress` (path parameter) - Token mint address (e.g., "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
155
+
156
+ **Request Body:**
157
+
158
+ ```json
159
+ {
160
+ "walletAddress": "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
161
+ "amount": 1000
162
+ }
163
+ ```
164
+
165
+ **Response:**
166
+
167
+ ```json
168
+ {
169
+ "success": true,
170
+ "symbol": "USDC",
171
+ "amount": 1000,
172
+ "walletAddress": "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
173
+ "mintAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
174
+ }
175
+ ```
176
+
177
+ **Error Response:**
178
+
179
+ ```json
180
+ {
181
+ "error": "Token with mint address EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v not found in cloned tokens"
182
+ }
183
+ ```
184
+
185
+ ### Get Wallet Balances
186
+
187
+ Get SOL and token balances for a specific wallet.
188
+
189
+ ```http
190
+ GET /api/wallet/:address/balances
191
+ ```
192
+
193
+ **Parameters:**
194
+
195
+ - `address` (path parameter) - Wallet public key
196
+
197
+ **Response:**
198
+
199
+ ```json
200
+ {
201
+ "walletAddress": "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
202
+ "solBalance": {
203
+ "lamports": 1000000000,
204
+ "sol": 1.0
205
+ },
206
+ "tokenBalances": [
207
+ {
208
+ "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
209
+ "symbol": "USDC",
210
+ "balance": "1000000000",
211
+ "decimals": 6,
212
+ "uiAmount": 1000
213
+ }
214
+ ],
215
+ "timestamp": "2024-01-15T10:30:00.000Z"
216
+ }
217
+ ```
218
+
219
+ ### Airdrop SOL
220
+
221
+ Airdrop SOL to a wallet address.
222
+
223
+ ```http
224
+ POST /api/airdrop
225
+ ```
226
+
227
+ **Request Body:**
228
+
229
+ ```json
230
+ {
231
+ "walletAddress": "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
232
+ "amount": 1
233
+ }
234
+ ```
235
+
236
+ **Response:**
237
+
238
+ ```json
239
+ {
240
+ "success": true,
241
+ "amount": 1,
242
+ "walletAddress": "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
243
+ "signature": "5j7s8K9mN2pQ3rT4uV5wX6yZ7a8B9c0D1e2F3g4H5i6J7k8L9m0N1o2P3q4R5s6T7u8V9w0X1y2Z3a4B5c6D7e8F"
244
+ }
245
+ ```
246
+
247
+ ### Get Recent Transactions
248
+
249
+ Get recent transactions from the validator.
250
+
251
+ ```http
252
+ GET /api/transactions/recent?limit=10
253
+ ```
254
+
255
+ **Query Parameters:**
256
+
257
+ - `limit` (optional) - Number of transactions to return (max 100, default 10)
258
+
259
+ **Response:**
260
+
261
+ ```json
262
+ {
263
+ "transactions": [
264
+ {
265
+ "signature": "5j7s8K9mN2pQ3rT4uV5wX6yZ7a8B9c0D1e2F3g4H5i6J7k8L9m0N1o2P3q4R5s6T7u8V9w0X1y2Z3a4B5c6D7e8F",
266
+ "slot": 12345,
267
+ "blockTime": 1642234567,
268
+ "confirmationStatus": "finalized"
269
+ }
270
+ ],
271
+ "count": 1
272
+ }
273
+ ```
274
+
275
+ ## Error Handling
276
+
277
+ All endpoints return appropriate HTTP status codes:
278
+
279
+ - `200` - Success
280
+ - `400` - Bad Request (invalid parameters)
281
+ - `404` - Not Found (endpoint doesn't exist)
282
+ - `500` - Internal Server Error
283
+
284
+ Error responses include details:
285
+
286
+ ```json
287
+ {
288
+ "error": "Error message",
289
+ "details": "Additional error details"
290
+ }
291
+ ```
292
+
293
+ ## Examples
294
+
295
+ ### Using curl
296
+
297
+ **Mint tokens:**
298
+
299
+ ```bash
300
+ curl -X POST http://127.0.0.1:3000/api/tokens/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/mint \
301
+ -H "Content-Type: application/json" \
302
+ -d '{
303
+ "walletAddress": "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
304
+ "amount": 1000
305
+ }'
306
+ ```
307
+
308
+ **Get wallet balances:**
309
+
310
+ ```bash
311
+ curl http://127.0.0.1:3000/api/wallet/HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ/balances
312
+ ```
313
+
314
+ **Airdrop SOL:**
315
+
316
+ ```bash
317
+ curl -X POST http://127.0.0.1:3000/api/airdrop \
318
+ -H "Content-Type: application/json" \
319
+ -d '{
320
+ "walletAddress": "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
321
+ "amount": 1
322
+ }'
323
+ ```
324
+
325
+ ### Using JavaScript/TypeScript
326
+
327
+ ```typescript
328
+ const API_BASE = "http://127.0.0.1:3000/api";
329
+
330
+ // Mint tokens
331
+ async function mintTokens(
332
+ symbol: string,
333
+ walletAddress: string,
334
+ amount: number
335
+ ) {
336
+ const response = await fetch(`${API_BASE}/tokens/${symbol}/mint`, {
337
+ method: "POST",
338
+ headers: {
339
+ "Content-Type": "application/json",
340
+ },
341
+ body: JSON.stringify({
342
+ walletAddress,
343
+ amount,
344
+ }),
345
+ });
346
+
347
+ return response.json();
348
+ }
349
+
350
+ // Get wallet balances
351
+ async function getWalletBalances(address: string) {
352
+ const response = await fetch(`${API_BASE}/wallet/${address}/balances`);
353
+ return response.json();
354
+ }
355
+
356
+ // Usage
357
+ const result = await mintTokens(
358
+ "USDC",
359
+ "HpHke1uSs4VzA8m76Uy2aDfnhDg2Dw2vJMQvpBVU5mTJ",
360
+ 1000
361
+ );
362
+ console.log(result);
363
+ ```
364
+
365
+ ## Configuration
366
+
367
+ The API server port can be configured by setting the `API_PORT` environment variable or by modifying the start command configuration.
368
+
369
+ ## CORS
370
+
371
+ CORS is enabled for all origins to facilitate local web development. In production, you should configure appropriate CORS settings.
372
+
373
+ ## Rate Limiting
374
+
375
+ Currently, no rate limiting is implemented. The API is intended for local development use only.
376
+
377
+ ## WebSocket Support
378
+
379
+ WebSocket support is not currently implemented but may be added in future versions for real-time updates.