solforge 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
  - 🌐 **Port management** - Automatic port allocation and conflict resolution
14
14
  - 📝 **Configuration-driven** - JSON-based configuration for reproducible environments
15
15
  - 🎨 **Beautiful CLI** - Colorful, intuitive command-line interface
16
+ - 🌐 **REST API** - Background API server for programmatic access to validator operations
16
17
 
17
18
  ## 🚀 Quick Start
18
19
 
@@ -26,7 +27,7 @@
26
27
 
27
28
  ```bash
28
29
  # Clone the repository
29
- git clone <repository-url>
30
+ git clone https://github.com/nitishxyz/solforge.git
30
31
  cd solforge
31
32
 
32
33
  # Install dependencies
@@ -43,16 +44,19 @@ bun run install:binary
43
44
  ### Basic Usage
44
45
 
45
46
  1. **Initialize a new project**:
47
+
46
48
  ```bash
47
49
  solforge init
48
50
  ```
49
51
 
50
52
  2. **Start your localnet**:
53
+
51
54
  ```bash
52
55
  solforge start
53
56
  ```
54
57
 
55
58
  3. **Check status**:
59
+
56
60
  ```bash
57
61
  solforge status
58
62
  solforge list
@@ -63,15 +67,40 @@ bun run install:binary
63
67
  solforge stop --all
64
68
  ```
65
69
 
70
+ ### API Server
71
+
72
+ SolForge automatically starts a REST API server alongside your validator, providing programmatic access to validator operations:
73
+
74
+ ```bash
75
+ # API server starts automatically with the validator
76
+ solforge start
77
+
78
+ # API available at http://127.0.0.1:3000/api
79
+ curl http://127.0.0.1:3000/api/health
80
+
81
+ # Mint tokens via API
82
+ curl -X POST http://127.0.0.1:3000/api/tokens/USDC/mint \
83
+ -H "Content-Type: application/json" \
84
+ -d '{"walletAddress": "YOUR_WALLET_ADDRESS", "amount": 1000}'
85
+
86
+ # Get wallet balances
87
+ curl http://127.0.0.1:3000/api/wallet/YOUR_WALLET_ADDRESS/balances
88
+ ```
89
+
90
+ For complete API documentation, see [API Documentation](docs/API.md).
91
+
66
92
  ## 📖 Documentation
67
93
 
68
94
  ### 📚 Additional Documentation
95
+
96
+ - [API Documentation](docs/API.md) - REST API endpoints and usage examples
69
97
  - [Configuration Guide](docs/CONFIGURATION.md) - Detailed configuration options and examples
70
98
  - [Troubleshooting Guide](#-troubleshooting) - Common issues and solutions
71
99
 
72
100
  ### Commands
73
101
 
74
102
  #### `solforge init`
103
+
75
104
  Initialize a new `sf.config.json` configuration file in the current directory.
76
105
 
77
106
  ```bash
@@ -79,12 +108,14 @@ solforge init
79
108
  ```
80
109
 
81
110
  This command will prompt you for:
111
+
82
112
  - Project name
83
113
  - Description
84
114
  - RPC port (default: 8899)
85
115
  - Whether to include USDC token
86
116
 
87
117
  #### `solforge start [options]`
118
+
88
119
  Start a localnet validator with the current configuration.
89
120
 
90
121
  ```bash
@@ -93,9 +124,11 @@ solforge start --debug # Start with debug logging
93
124
  ```
94
125
 
95
126
  **Options:**
127
+
96
128
  - `--debug` - Enable debug logging to see detailed command output
97
129
 
98
130
  #### `solforge list`
131
+
99
132
  List all running validators with detailed information.
100
133
 
101
134
  ```bash
@@ -103,6 +136,7 @@ solforge list
103
136
  ```
104
137
 
105
138
  Shows:
139
+
106
140
  - Validator ID and name
107
141
  - Process ID (PID)
108
142
  - RPC and Faucet ports
@@ -111,6 +145,7 @@ Shows:
111
145
  - Connection URLs
112
146
 
113
147
  #### `solforge stop [validator-id] [options]`
148
+
114
149
  Stop running validators.
115
150
 
116
151
  ```bash
@@ -121,10 +156,12 @@ solforge stop --kill # Force kill (SIGKILL)
121
156
  ```
122
157
 
123
158
  **Options:**
159
+
124
160
  - `--all` - Stop all running validators
125
161
  - `--kill` - Force kill the validator (SIGKILL instead of SIGTERM)
126
162
 
127
163
  #### `solforge kill [validator-id] [options]`
164
+
128
165
  Force kill running validators with interactive selection.
129
166
 
130
167
  ```bash
@@ -135,12 +172,14 @@ solforge kill --all # Kill all validators
135
172
 
136
173
  **Interactive Mode:**
137
174
  When run without arguments, `solforge kill` will:
175
+
138
176
  - Display a table of all running validators
139
177
  - Allow you to select which validator to kill using arrow keys
140
178
  - Provide options to kill individual validators, all validators, or cancel
141
179
  - No need to copy/paste validator IDs from `solforge list`
142
180
 
143
181
  #### `solforge status`
182
+
144
183
  Show overall localnet status and configuration summary.
145
184
 
146
185
  ```bash
@@ -148,6 +187,7 @@ solforge status
148
187
  ```
149
188
 
150
189
  #### `solforge add-program [options]`
190
+
151
191
  Add a program to your configuration.
152
192
 
153
193
  ```bash
@@ -157,22 +197,39 @@ solforge add-program --program-id <address> --name <name>
157
197
  ```
158
198
 
159
199
  **Options:**
200
+
160
201
  - `--program-id <address>` - Mainnet program ID to clone and deploy
161
202
  - `--name <name>` - Friendly name for the program
162
203
  - `--no-interactive` - Run in non-interactive mode
163
204
 
164
- #### `solforge transfer [options]`
165
- Interactively transfer tokens from mint authority to any address.
205
+ #### `solforge mint [options]`
206
+
207
+ Interactively mint tokens to any wallet address.
166
208
 
167
209
  ```bash
168
- solforge transfer # Use default RPC
169
- solforge transfer --rpc-url http://localhost:8899 # Custom RPC
210
+ solforge mint # Interactive mode
211
+ solforge mint --symbol USDC --wallet <address> --amount 1000 # CLI mode
212
+ solforge mint --rpc-url http://localhost:8899 # Custom RPC
170
213
  ```
171
214
 
172
215
  **Options:**
216
+
173
217
  - `--rpc-url <url>` - RPC URL to use (default: "http://127.0.0.1:8899")
218
+ - `--symbol <symbol>` - Token symbol to mint
219
+ - `--wallet <address>` - Wallet address to mint to
220
+ - `--amount <amount>` - Amount to mint
221
+
222
+ **Interactive Mode:**
223
+ When run without arguments, `solforge mint` will:
224
+
225
+ - Display available cloned tokens
226
+ - Allow you to select which token to mint
227
+ - Prompt for recipient wallet address
228
+ - Prompt for amount to mint
229
+ - Handle SPL token account creation automatically
174
230
 
175
231
  #### `solforge reset`
232
+
176
233
  Reset localnet ledger (coming soon).
177
234
 
178
235
  ```bash
@@ -232,8 +289,9 @@ Here's the complete schema:
232
289
  For detailed configuration options and examples, see the [Configuration Guide](docs/CONFIGURATION.md).
233
290
 
234
291
  **Quick Reference:**
292
+
235
293
  - `name` - Project name
236
- - `description` - Project description
294
+ - `description` - Project description
237
295
  - `tokens[]` - Tokens to clone from mainnet
238
296
  - `programs[]` - Programs to clone from mainnet
239
297
  - `localnet` - Validator settings (ports, logging, etc.)
@@ -241,6 +299,7 @@ For detailed configuration options and examples, see the [Configuration Guide](d
241
299
  ## 🎯 Use Cases
242
300
 
243
301
  ### DeFi Development
302
+
244
303
  Clone popular DeFi tokens and programs to test your application:
245
304
 
246
305
  ```json
@@ -253,7 +312,7 @@ Clone popular DeFi tokens and programs to test your application:
253
312
  "mintAmount": 10000000
254
313
  },
255
314
  {
256
- "symbol": "USDT",
315
+ "symbol": "USDT",
257
316
  "mainnetMint": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
258
317
  "mintAmount": 10000000
259
318
  }
@@ -268,6 +327,7 @@ Clone popular DeFi tokens and programs to test your application:
268
327
  ```
269
328
 
270
329
  ### NFT Development
330
+
271
331
  Set up an environment for NFT projects:
272
332
 
273
333
  ```json
@@ -287,6 +347,7 @@ Set up an environment for NFT projects:
287
347
  ```
288
348
 
289
349
  ### Multi-Environment Testing
350
+
290
351
  Run multiple validators for different test scenarios:
291
352
 
292
353
  ```bash
@@ -294,7 +355,7 @@ Run multiple validators for different test scenarios:
294
355
  cd defi-project
295
356
  solforge start
296
357
 
297
- # Terminal 2 - NFT environment
358
+ # Terminal 2 - NFT environment
298
359
  cd nft-project
299
360
  solforge start
300
361
 
@@ -365,6 +426,7 @@ bun run install:binary # Install binary to ~/.local/bin
365
426
  ### Common Issues
366
427
 
367
428
  **Port already in use**
429
+
368
430
  ```bash
369
431
  # Check what's using the port
370
432
  lsof -i :8899
@@ -379,6 +441,7 @@ lsof -i :8899
379
441
  ```
380
442
 
381
443
  **Validator won't start**
444
+
382
445
  ```bash
383
446
  # Check Solana CLI is installed
384
447
  solana --version
@@ -391,11 +454,13 @@ solforge start --debug
391
454
  ```
392
455
 
393
456
  **Token cloning fails**
457
+
394
458
  - Ensure RPC URL in config is accessible
395
459
  - Check mainnet mint address is correct
396
460
  - Verify network connectivity
397
461
 
398
462
  **Program deployment fails**
463
+
399
464
  - Ensure program ID exists on specified cluster
400
465
  - Check if program has dependencies that need to be deployed first
401
466
  - Verify sufficient SOL for deployment
@@ -409,6 +474,7 @@ solforge start --debug
409
474
  ```
410
475
 
411
476
  This shows:
477
+
412
478
  - Exact solana-test-validator commands
413
479
  - Program deployment steps
414
480
  - Token cloning operations
@@ -417,6 +483,7 @@ This shows:
417
483
  ### Logs and Data
418
484
 
419
485
  SolForge stores data in:
486
+
420
487
  - `~/.solforge/` - Process registry and metadata
421
488
  - `.solforge/` - Local working directory for current project
422
489
 
@@ -426,9 +493,7 @@ MIT License - see [LICENSE](LICENSE) file for details.
426
493
 
427
494
  ## 🤝 Support
428
495
 
429
- - 🐛 **Issues**: [GitHub Issues](https://github.com/your-repo/solforge/issues)
430
- - 💬 **Discussions**: [GitHub Discussions](https://github.com/your-repo/solforge/discussions)
431
- - 📧 **Email**: your-email@example.com
496
+ - 🐛 **Issues**: [GitHub Issues](https://github.com/nitishxyz/solforge/issues)
432
497
 
433
498
  ## 🙏 Acknowledgments
434
499
 
@@ -438,4 +503,4 @@ MIT License - see [LICENSE](LICENSE) file for details.
438
503
 
439
504
  ---
440
505
 
441
- **Happy building on Solana! 🚀**
506
+ **Happy building on Solana! 🚀**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solforge",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Solana localnet orchestration tool for cloning mainnet programs and tokens",
5
5
  "module": "index.ts",
6
6
  "type": "module",
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { APIServer } from "./services/api-server.js";
4
+ import { configManager } from "./config/manager.js";
5
+ import chalk from "chalk";
6
+
7
+ async function main() {
8
+ try {
9
+ // Parse command line arguments
10
+ const args = process.argv.slice(2);
11
+ const portIndex = args.indexOf("--port");
12
+ const configIndex = args.indexOf("--config");
13
+ const rpcIndex = args.indexOf("--rpc-url");
14
+ const faucetIndex = args.indexOf("--faucet-url");
15
+ const workDirIndex = args.indexOf("--work-dir");
16
+
17
+ if (
18
+ portIndex === -1 ||
19
+ configIndex === -1 ||
20
+ rpcIndex === -1 ||
21
+ faucetIndex === -1 ||
22
+ workDirIndex === -1 ||
23
+ !args[portIndex + 1] ||
24
+ !args[configIndex + 1] ||
25
+ !args[rpcIndex + 1] ||
26
+ !args[faucetIndex + 1] ||
27
+ !args[workDirIndex + 1]
28
+ ) {
29
+ console.error(
30
+ "Usage: api-server-entry --port <port> --config <config-path> --rpc-url <url> --faucet-url <url> --work-dir <dir>"
31
+ );
32
+ process.exit(1);
33
+ }
34
+
35
+ const port = parseInt(args[portIndex + 1]!);
36
+ const configPath = args[configIndex + 1]!;
37
+ const rpcUrl = args[rpcIndex + 1]!;
38
+ const faucetUrl = args[faucetIndex + 1]!;
39
+ const workDir = args[workDirIndex + 1]!;
40
+
41
+ // Load configuration
42
+ await configManager.load(configPath);
43
+ const config = configManager.getConfig();
44
+
45
+ // Create and start API server
46
+ const apiServer = new APIServer({
47
+ port,
48
+ validatorRpcUrl: rpcUrl,
49
+ validatorFaucetUrl: faucetUrl,
50
+ config,
51
+ workDir,
52
+ });
53
+
54
+ const result = await apiServer.start();
55
+
56
+ if (result.success) {
57
+ console.log(chalk.green(`🚀 API Server started on port ${port}`));
58
+
59
+ // Keep the process alive
60
+ process.on("SIGTERM", async () => {
61
+ console.log(
62
+ chalk.yellow("📡 API Server received SIGTERM, shutting down...")
63
+ );
64
+ await apiServer.stop();
65
+ process.exit(0);
66
+ });
67
+
68
+ process.on("SIGINT", async () => {
69
+ console.log(
70
+ chalk.yellow("📡 API Server received SIGINT, shutting down...")
71
+ );
72
+ await apiServer.stop();
73
+ process.exit(0);
74
+ });
75
+
76
+ // Keep process alive
77
+ setInterval(() => {}, 1000);
78
+ } else {
79
+ console.error(
80
+ chalk.red(`❌ Failed to start API server: ${result.error}`)
81
+ );
82
+ process.exit(1);
83
+ }
84
+ } catch (error) {
85
+ console.error(
86
+ chalk.red(
87
+ `❌ API Server error: ${
88
+ error instanceof Error ? error.message : String(error)
89
+ }`
90
+ )
91
+ );
92
+ process.exit(1);
93
+ }
94
+ }
95
+
96
+ main().catch((error) => {
97
+ console.error(
98
+ chalk.red(
99
+ `❌ Fatal error: ${
100
+ error instanceof Error ? error.message : String(error)
101
+ }`
102
+ )
103
+ );
104
+ process.exit(1);
105
+ });