solforge 0.2.0 → 0.2.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.
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 +56 -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
@@ -1,251 +0,0 @@
1
- # Solana Kit Guide for LiteSVM RPC Server
2
-
3
- ## Overview
4
- Solana Kit (formerly Web3.js v2) is a complete rewrite of the Web3.js library, designed to be more composable, customizable, and efficient. This guide covers how to use Kit with our LiteSVM RPC server implementation.
5
-
6
- ## Key Differences from Web3.js
7
-
8
- ### 1. No Connection Class
9
- - **Web3.js**: Uses a `Connection` class as a central entry point
10
- - **Kit**: Uses functional approach with `createSolanaRpc` and `createSolanaRpcSubscriptions`
11
-
12
- ### 2. Tree-Shakeable Design
13
- - All functions are importable individually
14
- - Only bundle what you use
15
- - No classes, only functions and Proxy objects
16
-
17
- ### 3. Native TypeScript & Modern JS
18
- - Uses native `bigint` for large values
19
- - Native Ed25519 key support via `CryptoKeyPair`
20
- - Strong TypeScript types throughout
21
-
22
- ## Core Concepts
23
-
24
- ### RPC Creation
25
- ```typescript
26
- import { createSolanaRpc, createSolanaRpcSubscriptions } from '@solana/kit';
27
-
28
- // Create RPC proxy for standard requests
29
- const rpc = createSolanaRpc('http://localhost:8899');
30
-
31
- // Create RPC subscriptions for WebSocket events
32
- const rpcSubscriptions = createSolanaRpcSubscriptions('ws://localhost:8900');
33
- ```
34
-
35
- ### Addresses
36
- ```typescript
37
- import { address, Address } from '@solana/kit';
38
-
39
- // Create an address (replaces PublicKey)
40
- const wallet = address('11111111111111111111111111111111');
41
- ```
42
-
43
- ### Signers
44
- Kit uses signer objects instead of Keypair arrays:
45
- ```typescript
46
- import {
47
- generateKeyPairSigner,
48
- createNoopSigner,
49
- TransactionSigner
50
- } from '@solana/kit';
51
-
52
- // Generate a new signer
53
- const signer = await generateKeyPairSigner();
54
-
55
- // Create a noop signer (for addresses that won't actually sign)
56
- const noopSigner = createNoopSigner(address('1234...'));
57
- ```
58
-
59
- ## RPC Methods Mapping
60
-
61
- ### Account Operations
62
- ```typescript
63
- // Get account info
64
- const { value: account } = await rpc.getAccountInfo(wallet).send();
65
-
66
- // Get balance
67
- const { value: balance } = await rpc.getBalance(wallet).send();
68
-
69
- // Helper functions
70
- import { fetchEncodedAccount, assertAccountExists } from '@solana/kit';
71
- const account = await fetchEncodedAccount(rpc, wallet);
72
- assertAccountExists(account);
73
- ```
74
-
75
- ### Transaction Operations
76
- ```typescript
77
- // Get latest blockhash
78
- const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
79
-
80
- // Send transaction
81
- const signature = await rpc.sendTransaction(signedTransaction).send();
82
-
83
- // Simulate transaction
84
- const { value: simulation } = await rpc.simulateTransaction(transaction).send();
85
- ```
86
-
87
- ## Building Transactions
88
-
89
- ### Transaction Message Pipeline
90
- ```typescript
91
- import {
92
- createTransactionMessage,
93
- setTransactionMessageFeePayerSigner,
94
- setTransactionMessageLifetimeUsingBlockhash,
95
- appendTransactionMessageInstructions,
96
- pipe
97
- } from '@solana/kit';
98
-
99
- const transactionMessage = pipe(
100
- createTransactionMessage({ version: 0 }),
101
- tx => setTransactionMessageFeePayerSigner(payer, tx),
102
- tx => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
103
- tx => appendTransactionMessageInstructions(instructions, tx)
104
- );
105
- ```
106
-
107
- ### Compiling and Signing
108
- ```typescript
109
- import {
110
- compileTransaction,
111
- signTransactionMessageWithSigners,
112
- getSignatureFromTransaction
113
- } from '@solana/kit';
114
-
115
- // Compile the message
116
- const transaction = compileTransaction(transactionMessage);
117
-
118
- // Sign with attached signers
119
- const signedTransaction = await signTransactionMessageWithSigners(transactionMessage);
120
-
121
- // Get signature
122
- const signature = getSignatureFromTransaction(signedTransaction);
123
- ```
124
-
125
- ## Program Instructions
126
-
127
- ### System Program
128
- ```typescript
129
- import { getTransferSolInstruction } from '@solana-program/system';
130
-
131
- const instruction = getTransferSolInstruction({
132
- source: payerSigner,
133
- destination: recipientAddress,
134
- amount: 1_000_000_000n // 1 SOL in lamports
135
- });
136
- ```
137
-
138
- ### Token Program
139
- ```typescript
140
- import { getInitializeMintInstruction } from '@solana-program/token';
141
-
142
- const instruction = getInitializeMintInstruction({
143
- mint: mintSigner.address,
144
- decimals: 9,
145
- mintAuthority: authorityAddress,
146
- freezeAuthority: null
147
- });
148
- ```
149
-
150
- ## Codecs for Data Encoding/Decoding
151
-
152
- ```typescript
153
- import {
154
- Codec,
155
- getStructCodec,
156
- getU8Codec,
157
- getU64Codec,
158
- getAddressCodec,
159
- getUtf8Codec,
160
- addCodecSizePrefix,
161
- getU32Codec
162
- } from '@solana/kit';
163
-
164
- // Define a codec for custom account data
165
- type MyAccount = {
166
- version: number;
167
- owner: Address;
168
- balance: bigint;
169
- name: string;
170
- };
171
-
172
- const myAccountCodec: Codec<MyAccount> = getStructCodec([
173
- ['version', getU8Codec()],
174
- ['owner', getAddressCodec()],
175
- ['balance', getU64Codec()],
176
- ['name', addCodecSizePrefix(getUtf8Codec(), getU32Codec())]
177
- ]);
178
-
179
- // Encode
180
- const bytes = myAccountCodec.encode(accountData);
181
-
182
- // Decode
183
- const decoded = myAccountCodec.decode(bytes);
184
- ```
185
-
186
- ## RPC Method Requirements for LiteSVM
187
-
188
- For our LiteSVM RPC server to work with Kit, we need to implement these RPC methods:
189
-
190
- ### Core Methods
191
- - `getAccountInfo` - Get account data
192
- - `getBalance` - Get account balance
193
- - `getLatestBlockhash` - Get recent blockhash
194
- - `sendTransaction` - Submit transaction
195
- - `simulateTransaction` - Simulate without executing
196
- - `requestAirdrop` - Request test SOL
197
-
198
- ### Additional Methods for Full Compatibility
199
- - `getSignatureStatuses` - Check transaction status
200
- - `getSlot` - Get current slot
201
- - `getBlockHeight` - Get block height
202
- - `getTransaction` - Get transaction by signature
203
- - `getMultipleAccounts` - Batch account fetching
204
- - `getMinimumBalanceForRentExemption` - Rent calculation
205
-
206
- ### For WebSocket Subscriptions
207
- - `accountNotifications` - Account change events
208
- - `signatureNotifications` - Transaction confirmation events
209
- - `slotNotifications` - Slot change events
210
-
211
- ## Error Handling
212
-
213
- Kit uses structured errors:
214
- ```typescript
215
- import { isSolanaError, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_FOUND } from '@solana/kit';
216
-
217
- try {
218
- const result = await rpc.getTransaction(signature).send();
219
- } catch (error) {
220
- if (isSolanaError(error, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_FOUND)) {
221
- console.log('Transaction not found');
222
- }
223
- }
224
- ```
225
-
226
- ## Testing with LiteSVM
227
-
228
- When using Kit with our LiteSVM RPC server:
229
-
230
- ```typescript
231
- // Connect to local LiteSVM RPC
232
- const rpc = createSolanaRpc('http://localhost:8899');
233
-
234
- // Use LiteSVM-specific features
235
- const { value: airdropSig } = await rpc.requestAirdrop(wallet, 1_000_000_000n).send();
236
-
237
- // All standard Kit operations work normally
238
- const { value: balance } = await rpc.getBalance(wallet).send();
239
- ```
240
-
241
- ## Migration from Web3.js
242
-
243
- Use the `@solana/compat` package for incremental migration:
244
- ```typescript
245
- import { fromLegacyPublicKey, fromLegacyKeypair } from '@solana/compat';
246
- import { PublicKey, Keypair } from '@solana/web3.js';
247
-
248
- // Convert legacy types
249
- const address = fromLegacyPublicKey(new PublicKey('...'));
250
- const cryptoKeypair = await fromLegacyKeypair(Keypair.generate());
251
- ```
package/SOLFORGE.md DELETED
@@ -1,119 +0,0 @@
1
- # SolForge - Lightweight Solana RPC Server
2
-
3
- ## Vision
4
-
5
- SolForge is a high-performance, lightweight drop-in replacement for `solana-test-validator` built on LiteSVM. Our goal is to provide developers with a fast, resource-efficient local Solana development environment that "just works."
6
-
7
- ## What We're Building
8
-
9
- ### Core Objectives
10
-
11
- 1. **Drop-in Replacement**: Full compatibility with existing Solana RPC clients and tools
12
- 2. **Blazing Fast**: Sub-second startup, minimal memory footprint (~50MB vs 500MB+)
13
- 3. **Developer First**: Zero configuration, intuitive architecture, easy to extend
14
- 4. **Production Ready**: Reliable, well-tested, suitable for CI/CD pipelines
15
-
16
- ### Key Features
17
-
18
- - ✅ Broad Solana JSON‑RPC coverage (HTTP + PubSub for signatures)
19
- - ⚡ In‑memory execution via LiteSVM; sub‑second startup
20
- - 💧 Faucet-backed airdrops (real transfers, no rate limits)
21
- - 🗃️ Ephemeral SQLite index (Bun + Drizzle) for rich history during a run
22
- - 🔧 Modular architecture; one method per file
23
- - 🧪 Developer‑first defaults; logs and ergonomics for local workflows
24
- - 🎯 Bun‑native
25
-
26
- ## Architecture
27
-
28
- ```
29
- SolForge
30
- ├── Core Server (LiteSVM wrapper)
31
- ├── RPC Method Handlers (modular)
32
- ├── State Management (LiteSVM + ephemeral DB index)
33
- └── Extensions (plugins, custom programs)
34
- ```
35
-
36
- ### Design Principles
37
-
38
- 1. **Modularity Over Monoliths**: Small, focused modules that do one thing well
39
- 2. **Performance First**: Optimize for speed and resource usage
40
- 3. **Developer Experience**: Clear code, good documentation, helpful errors
41
- 4. **Extensibility**: Easy to add new RPC methods and custom behavior
42
- 5. **Compatibility**: Maintain strict Solana RPC API compatibility
43
-
44
- ## Roadmap
45
-
46
- ### Phase 1: Core RPC Methods ✅
47
- - Basic account operations
48
- - Transaction submission and simulation
49
- - Block and slot information
50
- - System queries
51
-
52
- ### Phase 2: Extended RPC Methods (Current)
53
- - Token operations
54
- - Program deployment
55
- - Stake operations
56
- - Vote operations
57
- - Advanced queries
58
-
59
- ### Phase 3: WebSocket Support ✅ (signatures)
60
- - Signature subscriptions implemented; other subs stubbed
61
-
62
- ### Phase 4: Advanced Features
63
- - Snapshot/restore functionality
64
- - Time travel debugging
65
- - Custom program loader
66
- - Performance profiling tools
67
- - Multi-tenant support
68
-
69
- ### Phase 5: Production Features
70
- - Clustering support
71
- - Persistent storage option
72
- - Metrics and monitoring
73
- - Admin API
74
- - Plugin system
75
-
76
- ## Use Cases
77
-
78
- ### Primary
79
- - Local development environment
80
- - Unit and integration testing
81
- - CI/CD pipeline testing
82
- - Educational purposes
83
-
84
- ### Secondary
85
- - Performance benchmarking
86
- - Protocol experimentation
87
- - Custom program development
88
- - Lightweight staging environments
89
-
90
- ## Success Metrics
91
-
92
- - **Startup Time**: < 1 second
93
- - **Memory Usage**: < 50MB idle, < 200MB under load
94
- - **RPC Compatibility**: 100% core methods, 80%+ extended methods
95
- - **Developer Adoption**: Primary choice for local Solana development
96
- - **Test Speed**: 10x faster than solana-test-validator
97
-
98
- ## Non-Goals
99
-
100
- - Not a production validator; not for mainnet/testnet
101
- - Not for consensus participation
102
- - Not for long‑term ledger persistence (DB is ephemeral by default)
103
-
104
- ## Technical Stack
105
-
106
- - **Runtime**: Bun (exclusively)
107
- - **Core**: LiteSVM
108
- - **Language**: TypeScript
109
- - **Architecture**: Modular, event-driven
110
- - **Testing**: Bun test framework
111
- - **Package Management**: Bun
112
-
113
- ## Contributing
114
-
115
- We welcome contributions that align with our vision of a fast, lightweight, developer-friendly Solana RPC server. See AGENTS.md for development guidelines.
116
-
117
- ## Why "SolForge"?
118
-
119
- Like a forge shapes raw metal into useful tools, SolForge shapes the Solana runtime into a powerful development tool - hot, fast, and ready to create.
package/biome.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
3
- "vcs": {
4
- "enabled": false,
5
- "clientKind": "git",
6
- "useIgnoreFile": false
7
- },
8
- "files": {
9
- "ignoreUnknown": false
10
- },
11
- "formatter": {
12
- "enabled": true,
13
- "indentStyle": "tab"
14
- },
15
- "linter": {
16
- "enabled": true,
17
- "rules": {
18
- "recommended": true
19
- }
20
- },
21
- "javascript": {
22
- "formatter": {
23
- "quoteStyle": "double"
24
- }
25
- },
26
- "assist": {
27
- "enabled": true,
28
- "actions": {
29
- "source": {
30
- "organizeImports": "on"
31
- }
32
- }
33
- }
34
- }