solforge 0.1.6 → 0.2.0

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 (194) hide show
  1. package/.agi/agi.sqlite +0 -0
  2. package/.claude/settings.local.json +9 -0
  3. package/.github/workflows/release-binaries.yml +133 -0
  4. package/.tmp/.787ebcdbf7b8fde8-00000000.hm +0 -0
  5. package/.tmp/.bffe6efebdf8aedc-00000000.hm +0 -0
  6. package/AGENTS.md +271 -0
  7. package/CLAUDE.md +106 -0
  8. package/PROJECT_STRUCTURE.md +124 -0
  9. package/README.md +367 -393
  10. package/SOLANA_KIT_GUIDE.md +251 -0
  11. package/SOLFORGE.md +119 -0
  12. package/biome.json +34 -0
  13. package/bun.lock +743 -0
  14. package/docs/bun-single-file-executable.md +585 -0
  15. package/docs/cli-plan.md +154 -0
  16. package/docs/data-indexing-plan.md +214 -0
  17. package/docs/gui-roadmap.md +202 -0
  18. package/drizzle/0000_friendly_millenium_guard.sql +53 -0
  19. package/drizzle/0001_stale_sentinels.sql +2 -0
  20. package/drizzle/meta/0000_snapshot.json +329 -0
  21. package/drizzle/meta/0001_snapshot.json +345 -0
  22. package/drizzle/meta/_journal.json +20 -0
  23. package/drizzle.config.ts +12 -0
  24. package/index.ts +21 -0
  25. package/mint.sh +47 -0
  26. package/package.json +45 -69
  27. package/postcss.config.js +6 -0
  28. package/rpc-server.ts.backup +519 -0
  29. package/server/index.ts +5 -0
  30. package/server/lib/base58.ts +33 -0
  31. package/server/lib/faucet.ts +110 -0
  32. package/server/lib/spl-token.ts +57 -0
  33. package/server/methods/TEMPLATE.md +117 -0
  34. package/server/methods/account/get-account-info.ts +90 -0
  35. package/server/methods/account/get-balance.ts +27 -0
  36. package/server/methods/account/get-multiple-accounts.ts +83 -0
  37. package/server/methods/account/get-parsed-account-info.ts +21 -0
  38. package/server/methods/account/index.ts +12 -0
  39. package/server/methods/account/parsers/index.ts +52 -0
  40. package/server/methods/account/parsers/loader-upgradeable.ts +66 -0
  41. package/server/methods/account/parsers/spl-token.ts +237 -0
  42. package/server/methods/account/parsers/system.ts +4 -0
  43. package/server/methods/account/request-airdrop.ts +219 -0
  44. package/server/methods/admin/adopt-mint-authority.ts +94 -0
  45. package/server/methods/admin/clone-program-accounts.ts +55 -0
  46. package/server/methods/admin/clone-program.ts +152 -0
  47. package/server/methods/admin/clone-token-accounts.ts +117 -0
  48. package/server/methods/admin/clone-token-mint.ts +82 -0
  49. package/server/methods/admin/create-mint.ts +114 -0
  50. package/server/methods/admin/create-token-account.ts +137 -0
  51. package/server/methods/admin/helpers.ts +70 -0
  52. package/server/methods/admin/index.ts +10 -0
  53. package/server/methods/admin/list-mints.ts +21 -0
  54. package/server/methods/admin/load-program.ts +52 -0
  55. package/server/methods/admin/mint-to.ts +278 -0
  56. package/server/methods/block/get-block-height.ts +5 -0
  57. package/server/methods/block/get-block.ts +35 -0
  58. package/server/methods/block/get-blocks-with-limit.ts +23 -0
  59. package/server/methods/block/get-latest-blockhash.ts +12 -0
  60. package/server/methods/block/get-slot.ts +5 -0
  61. package/server/methods/block/index.ts +6 -0
  62. package/server/methods/block/is-blockhash-valid.ts +23 -0
  63. package/server/methods/epoch/get-cluster-nodes.ts +17 -0
  64. package/server/methods/epoch/get-epoch-info.ts +16 -0
  65. package/server/methods/epoch/get-epoch-schedule.ts +15 -0
  66. package/server/methods/epoch/get-highest-snapshot-slot.ts +9 -0
  67. package/server/methods/epoch/get-leader-schedule.ts +8 -0
  68. package/server/methods/epoch/get-max-retransmit-slot.ts +9 -0
  69. package/server/methods/epoch/get-max-shred-insert-slot.ts +9 -0
  70. package/server/methods/epoch/get-slot-leader.ts +6 -0
  71. package/server/methods/epoch/get-slot-leaders.ts +9 -0
  72. package/server/methods/epoch/get-stake-activation.ts +9 -0
  73. package/server/methods/epoch/get-stake-minimum-delegation.ts +9 -0
  74. package/server/methods/epoch/get-vote-accounts.ts +19 -0
  75. package/server/methods/epoch/index.ts +13 -0
  76. package/server/methods/epoch/minimum-ledger-slot.ts +5 -0
  77. package/server/methods/fee/get-fee-calculator-for-blockhash.ts +12 -0
  78. package/server/methods/fee/get-fee-for-message.ts +8 -0
  79. package/server/methods/fee/get-fee-rate-governor.ts +16 -0
  80. package/server/methods/fee/get-fees.ts +14 -0
  81. package/server/methods/fee/get-recent-prioritization-fees.ts +22 -0
  82. package/server/methods/fee/index.ts +5 -0
  83. package/server/methods/get-address-lookup-table.ts +31 -0
  84. package/server/methods/index.ts +265 -0
  85. package/server/methods/performance/get-recent-performance-samples.ts +25 -0
  86. package/server/methods/performance/get-transaction-count.ts +5 -0
  87. package/server/methods/performance/index.ts +2 -0
  88. package/server/methods/program/get-block-commitment.ts +9 -0
  89. package/server/methods/program/get-block-production.ts +14 -0
  90. package/server/methods/program/get-block-time.ts +21 -0
  91. package/server/methods/program/get-blocks.ts +11 -0
  92. package/server/methods/program/get-first-available-block.ts +9 -0
  93. package/server/methods/program/get-genesis-hash.ts +6 -0
  94. package/server/methods/program/get-identity.ts +6 -0
  95. package/server/methods/program/get-inflation-governor.ts +15 -0
  96. package/server/methods/program/get-inflation-rate.ts +10 -0
  97. package/server/methods/program/get-inflation-reward.ts +12 -0
  98. package/server/methods/program/get-largest-accounts.ts +8 -0
  99. package/server/methods/program/get-parsed-program-accounts.ts +12 -0
  100. package/server/methods/program/get-parsed-token-accounts-by-delegate.ts +12 -0
  101. package/server/methods/program/get-parsed-token-accounts-by-owner.ts +12 -0
  102. package/server/methods/program/get-program-accounts.ts +221 -0
  103. package/server/methods/program/get-supply.ts +13 -0
  104. package/server/methods/program/get-token-account-balance.ts +64 -0
  105. package/server/methods/program/get-token-accounts-by-delegate.ts +81 -0
  106. package/server/methods/program/get-token-accounts-by-owner.ts +390 -0
  107. package/server/methods/program/get-token-largest-accounts.ts +80 -0
  108. package/server/methods/program/get-token-supply.ts +38 -0
  109. package/server/methods/program/index.ts +21 -0
  110. package/server/methods/solforge/index.ts +155 -0
  111. package/server/methods/system/get-health.ts +5 -0
  112. package/server/methods/system/get-minimum-balance-for-rent-exemption.ts +13 -0
  113. package/server/methods/system/get-version.ts +9 -0
  114. package/server/methods/system/index.ts +3 -0
  115. package/server/methods/transaction/get-confirmed-transaction.ts +11 -0
  116. package/server/methods/transaction/get-parsed-transaction.ts +21 -0
  117. package/server/methods/transaction/get-signature-statuses.ts +72 -0
  118. package/server/methods/transaction/get-signatures-for-address.ts +45 -0
  119. package/server/methods/transaction/get-transaction.ts +428 -0
  120. package/server/methods/transaction/index.ts +7 -0
  121. package/server/methods/transaction/send-transaction.ts +232 -0
  122. package/server/methods/transaction/simulate-transaction.ts +56 -0
  123. package/server/rpc-server.ts +474 -0
  124. package/server/types.ts +74 -0
  125. package/server/ws-server.ts +171 -0
  126. package/sf.config.json +38 -0
  127. package/src/cli/bootstrap.ts +67 -0
  128. package/src/cli/commands/airdrop.ts +37 -0
  129. package/src/cli/commands/config.ts +39 -0
  130. package/src/cli/commands/mint.ts +187 -0
  131. package/src/cli/commands/program-clone.ts +124 -0
  132. package/src/cli/commands/program-load.ts +64 -0
  133. package/src/cli/commands/rpc-start.ts +46 -0
  134. package/src/cli/commands/token-adopt-authority.ts +37 -0
  135. package/src/cli/commands/token-clone.ts +113 -0
  136. package/src/cli/commands/token-create.ts +81 -0
  137. package/src/cli/main.ts +130 -0
  138. package/src/cli/run-solforge.ts +98 -0
  139. package/src/cli/setup-utils.ts +54 -0
  140. package/src/cli/setup-wizard.ts +256 -0
  141. package/src/cli/utils/args.ts +15 -0
  142. package/src/config/index.ts +130 -0
  143. package/src/db/index.ts +83 -0
  144. package/src/db/schema/accounts.ts +23 -0
  145. package/src/db/schema/address-signatures.ts +31 -0
  146. package/src/db/schema/index.ts +5 -0
  147. package/src/db/schema/meta-kv.ts +9 -0
  148. package/src/db/schema/transactions.ts +29 -0
  149. package/src/db/schema/tx-accounts.ts +33 -0
  150. package/src/db/tx-store.ts +229 -0
  151. package/src/gui/public/app.css +1 -0
  152. package/src/gui/public/index.html +19 -0
  153. package/src/gui/server.ts +297 -0
  154. package/src/gui/src/api.ts +127 -0
  155. package/src/gui/src/app.tsx +390 -0
  156. package/src/gui/src/components/airdrop-mint-form.tsx +216 -0
  157. package/src/gui/src/components/clone-program-modal.tsx +183 -0
  158. package/src/gui/src/components/clone-token-modal.tsx +211 -0
  159. package/src/gui/src/components/modal.tsx +127 -0
  160. package/src/gui/src/components/programs-panel.tsx +112 -0
  161. package/src/gui/src/components/status-panel.tsx +122 -0
  162. package/src/gui/src/components/tokens-panel.tsx +116 -0
  163. package/src/gui/src/hooks/use-interval.ts +17 -0
  164. package/src/gui/src/index.css +529 -0
  165. package/src/gui/src/main.tsx +17 -0
  166. package/src/migrations-bundled.ts +17 -0
  167. package/src/rpc/start.ts +44 -0
  168. package/tailwind.config.js +27 -0
  169. package/test-client.ts +120 -0
  170. package/tmp/inspect-html.ts +4 -0
  171. package/tmp/response-test.ts +5 -0
  172. package/tmp/test-html.ts +5 -0
  173. package/tmp/test-server.ts +13 -0
  174. package/tsconfig.json +24 -23
  175. package/LICENSE +0 -21
  176. package/scripts/postinstall.cjs +0 -103
  177. package/src/api-server-entry.ts +0 -109
  178. package/src/commands/add-program.ts +0 -337
  179. package/src/commands/init.ts +0 -122
  180. package/src/commands/list.ts +0 -136
  181. package/src/commands/mint.ts +0 -336
  182. package/src/commands/start.ts +0 -878
  183. package/src/commands/status.ts +0 -99
  184. package/src/commands/stop.ts +0 -406
  185. package/src/config/manager.ts +0 -157
  186. package/src/index.ts +0 -188
  187. package/src/services/api-server.ts +0 -532
  188. package/src/services/port-manager.ts +0 -177
  189. package/src/services/process-registry.ts +0 -154
  190. package/src/services/program-cloner.ts +0 -317
  191. package/src/services/token-cloner.ts +0 -809
  192. package/src/services/validator.ts +0 -295
  193. package/src/types/config.ts +0 -110
  194. package/src/utils/shell.ts +0 -110
@@ -1,336 +0,0 @@
1
- import { Command } from "commander";
2
- import chalk from "chalk";
3
- import { existsSync, readFileSync } from "fs";
4
- import { join } from "path";
5
- import { input, select } from "@inquirer/prompts";
6
- import { runCommand } from "../utils/shell";
7
- import { Keypair, PublicKey } from "@solana/web3.js";
8
-
9
- interface TokenConfig {
10
- symbol: string;
11
- mainnetMint: string;
12
- mintAmount: number;
13
- }
14
-
15
- interface ClonedToken {
16
- config: TokenConfig;
17
- mintAuthorityPath: string;
18
- modifiedAccountPath: string;
19
- mintAuthority: {
20
- publicKey: string;
21
- secretKey: number[];
22
- };
23
- }
24
-
25
- export const mintCommand = new Command()
26
- .name("mint")
27
- .description("Interactively mint tokens to any wallet address")
28
- .option("--rpc-url <url>", "RPC URL to use", "http://127.0.0.1:8899")
29
- .option("--symbol <symbol>", "Token symbol to mint")
30
- .option("--wallet <address>", "Wallet address to mint to")
31
- .option("--amount <amount>", "Amount to mint")
32
- .action(async (options) => {
33
- try {
34
- console.log(chalk.blue("đŸĒ™ Interactive Token Minting"));
35
- console.log(chalk.gray("Mint tokens to any wallet address\n"));
36
-
37
- // Check if solforge data exists
38
- const workDir = ".solforge";
39
- if (!existsSync(workDir)) {
40
- console.error(
41
- chalk.red("❌ No solforge data found. Run 'solforge start' first.")
42
- );
43
- process.exit(1);
44
- }
45
-
46
- // Load available tokens
47
- const tokens = await loadAvailableTokens(workDir);
48
-
49
- if (tokens.length === 0) {
50
- console.error(
51
- chalk.red(
52
- "❌ No tokens found. Run 'solforge start' first to clone tokens."
53
- )
54
- );
55
- process.exit(1);
56
- }
57
-
58
- // Display available tokens
59
- console.log(chalk.cyan("📋 Available Tokens:"));
60
- tokens.forEach((token, index) => {
61
- console.log(
62
- chalk.gray(
63
- ` ${index + 1}. ${token.config.symbol} (${
64
- token.config.mainnetMint
65
- })`
66
- )
67
- );
68
- });
69
- console.log();
70
-
71
- // Select token (or use provided symbol)
72
- let selectedToken: ClonedToken;
73
- if (options.symbol) {
74
- const token = tokens.find(
75
- (t) => t.config.symbol.toLowerCase() === options.symbol.toLowerCase()
76
- );
77
- if (!token) {
78
- console.error(
79
- chalk.red(`❌ Token ${options.symbol} not found in cloned tokens`)
80
- );
81
- process.exit(1);
82
- }
83
- selectedToken = token;
84
- console.log(
85
- chalk.gray(`Selected token: ${selectedToken.config.symbol}`)
86
- );
87
- } else {
88
- selectedToken = await select({
89
- message: "Select a token to mint:",
90
- choices: tokens.map((token) => ({
91
- name: `${token.config.symbol} (${token.config.mainnetMint})`,
92
- value: token,
93
- })),
94
- });
95
- }
96
-
97
- // Get recipient address (or use provided wallet)
98
- let recipientAddress: string;
99
- if (options.wallet) {
100
- recipientAddress = options.wallet;
101
- // Validate wallet address
102
- try {
103
- new PublicKey(recipientAddress);
104
- } catch {
105
- console.error(chalk.red("❌ Invalid wallet address"));
106
- process.exit(1);
107
- }
108
- console.log(chalk.gray(`Recipient wallet: ${recipientAddress}`));
109
- } else {
110
- recipientAddress = await input({
111
- message: "Enter recipient wallet address:",
112
- validate: (value: string) => {
113
- if (!value.trim()) {
114
- return "Please enter a valid address";
115
- }
116
- try {
117
- new PublicKey(value.trim());
118
- return true;
119
- } catch {
120
- return "Please enter a valid Solana address";
121
- }
122
- },
123
- });
124
- }
125
-
126
- // Get amount to mint (or use provided amount)
127
- let amount: string;
128
- if (options.amount) {
129
- const num = parseFloat(options.amount);
130
- if (isNaN(num) || num <= 0) {
131
- console.error(chalk.red("❌ Invalid amount"));
132
- process.exit(1);
133
- }
134
- amount = options.amount;
135
- console.log(chalk.gray(`Amount to mint: ${amount}`));
136
- } else {
137
- amount = await input({
138
- message: "Enter amount to mint:",
139
- validate: (value: string) => {
140
- const num = parseFloat(value);
141
- if (isNaN(num) || num <= 0) {
142
- return "Please enter a valid positive number";
143
- }
144
- return true;
145
- },
146
- });
147
- }
148
-
149
- // Confirm minting if interactive
150
- if (!options.symbol || !options.wallet || !options.amount) {
151
- const confirm = await input({
152
- message: `Confirm minting ${amount} ${selectedToken.config.symbol} to ${recipientAddress}? (y/N):`,
153
- default: "N",
154
- });
155
-
156
- if (confirm.toLowerCase() !== "y" && confirm.toLowerCase() !== "yes") {
157
- console.log(chalk.yellow("Minting cancelled."));
158
- process.exit(0);
159
- }
160
- }
161
-
162
- console.log(chalk.blue("🚀 Starting mint..."));
163
-
164
- // Execute mint
165
- await mintTokenToWallet(
166
- selectedToken,
167
- recipientAddress,
168
- parseFloat(amount),
169
- options.rpcUrl
170
- );
171
-
172
- console.log(
173
- chalk.green(
174
- `✅ Successfully minted ${amount} ${selectedToken.config.symbol} to ${recipientAddress}`
175
- )
176
- );
177
- } catch (error) {
178
- console.error(chalk.red(`❌ Mint failed: ${error}`));
179
- process.exit(1);
180
- }
181
- });
182
-
183
- async function loadAvailableTokens(workDir: string): Promise<ClonedToken[]> {
184
- const tokens: ClonedToken[] = [];
185
-
186
- try {
187
- // Load token config from sf.config.json
188
- const configPath = "sf.config.json";
189
- if (!existsSync(configPath)) {
190
- throw new Error("sf.config.json not found in current directory");
191
- }
192
-
193
- const config = JSON.parse(readFileSync(configPath, "utf8"));
194
- const tokenConfigs: TokenConfig[] = config.tokens || [];
195
-
196
- // Load shared mint authority
197
- const sharedMintAuthorityPath = join(workDir, "shared-mint-authority.json");
198
- if (!existsSync(sharedMintAuthorityPath)) {
199
- throw new Error("Shared mint authority not found");
200
- }
201
-
202
- const secretKeyArray = JSON.parse(
203
- readFileSync(sharedMintAuthorityPath, "utf8")
204
- );
205
- const mintAuthorityKeypair = Keypair.fromSecretKey(
206
- new Uint8Array(secretKeyArray)
207
- );
208
- const mintAuthority = {
209
- publicKey: mintAuthorityKeypair.publicKey.toBase58(),
210
- secretKey: Array.from(mintAuthorityKeypair.secretKey),
211
- };
212
-
213
- // Build cloned tokens list
214
- for (const tokenConfig of tokenConfigs) {
215
- const tokenDir = join(
216
- workDir,
217
- `token-${tokenConfig.symbol.toLowerCase()}`
218
- );
219
- const modifiedAccountPath = join(tokenDir, "modified.json");
220
-
221
- if (existsSync(modifiedAccountPath)) {
222
- tokens.push({
223
- config: tokenConfig,
224
- mintAuthorityPath: sharedMintAuthorityPath,
225
- modifiedAccountPath,
226
- mintAuthority,
227
- });
228
- }
229
- }
230
-
231
- return tokens;
232
- } catch (error) {
233
- throw new Error(`Failed to load tokens: ${error}`);
234
- }
235
- }
236
-
237
- export async function mintTokenToWallet(
238
- token: ClonedToken,
239
- walletAddress: string,
240
- amount: number,
241
- rpcUrl: string
242
- ): Promise<void> {
243
- // Check if associated token account already exists (same pattern as token-cloner.ts)
244
- console.log(chalk.gray(`🔍 Checking for existing token account...`));
245
-
246
- const checkAccountsResult = await runCommand(
247
- "spl-token",
248
- ["accounts", "--owner", walletAddress, "--url", rpcUrl, "--output", "json"],
249
- { silent: true }
250
- );
251
-
252
- let tokenAccountAddress = "";
253
-
254
- if (checkAccountsResult.success && checkAccountsResult.stdout) {
255
- try {
256
- const accountsData = JSON.parse(checkAccountsResult.stdout);
257
-
258
- // Look for existing token account for this mint
259
- for (const account of accountsData.accounts || []) {
260
- if (account.mint === token.config.mainnetMint) {
261
- tokenAccountAddress = account.address;
262
- console.log(
263
- chalk.gray(
264
- `â„šī¸ Found existing token account: ${tokenAccountAddress}`
265
- )
266
- );
267
- break;
268
- }
269
- }
270
- } catch (error) {
271
- // No existing accounts found or parsing error, will create new account
272
- }
273
- }
274
-
275
- if (!tokenAccountAddress) {
276
- // Account doesn't exist, create it (same pattern as token-cloner.ts)
277
- console.log(chalk.gray(`🔧 Creating token account...`));
278
-
279
- const createAccountResult = await runCommand(
280
- "spl-token",
281
- [
282
- "create-account",
283
- token.config.mainnetMint,
284
- "--owner",
285
- walletAddress,
286
- "--fee-payer",
287
- token.mintAuthorityPath,
288
- "--url",
289
- rpcUrl,
290
- ],
291
- { silent: false }
292
- );
293
-
294
- if (!createAccountResult.success) {
295
- throw new Error(
296
- `Failed to create token account: ${createAccountResult.stderr}`
297
- );
298
- }
299
-
300
- // Extract token account address from create-account output
301
- const match = createAccountResult.stdout.match(/Creating account (\S+)/);
302
- tokenAccountAddress = match?.[1] || "";
303
-
304
- if (!tokenAccountAddress) {
305
- throw new Error(
306
- "Failed to determine token account address from create-account output"
307
- );
308
- }
309
-
310
- console.log(chalk.gray(`✅ Created token account: ${tokenAccountAddress}`));
311
- }
312
-
313
- // Now mint to the token account (same pattern as token-cloner.ts)
314
- console.log(chalk.gray(`💰 Minting ${amount} tokens...`));
315
-
316
- const result = await runCommand(
317
- "spl-token",
318
- [
319
- "mint",
320
- token.config.mainnetMint,
321
- amount.toString(),
322
- tokenAccountAddress,
323
- "--mint-authority",
324
- token.mintAuthorityPath,
325
- "--fee-payer",
326
- token.mintAuthorityPath,
327
- "--url",
328
- rpcUrl,
329
- ],
330
- { silent: false }
331
- );
332
-
333
- if (!result.success) {
334
- throw new Error(`Failed to mint tokens: ${result.stderr}`);
335
- }
336
- }