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.
Files changed (82) hide show
  1. package/README.md +471 -79
  2. package/cli.cjs +106 -78
  3. package/package.json +1 -1
  4. package/scripts/install.sh +1 -1
  5. package/scripts/postinstall.cjs +69 -61
  6. package/server/lib/base58.ts +1 -1
  7. package/server/methods/account/get-account-info.ts +3 -7
  8. package/server/methods/account/get-balance.ts +3 -7
  9. package/server/methods/account/get-multiple-accounts.ts +2 -1
  10. package/server/methods/account/get-parsed-account-info.ts +3 -7
  11. package/server/methods/account/parsers/index.ts +2 -2
  12. package/server/methods/account/parsers/loader-upgradeable.ts +14 -1
  13. package/server/methods/account/parsers/spl-token.ts +29 -10
  14. package/server/methods/account/request-airdrop.ts +44 -31
  15. package/server/methods/block/get-block.ts +3 -7
  16. package/server/methods/block/get-blocks-with-limit.ts +3 -7
  17. package/server/methods/block/is-blockhash-valid.ts +3 -7
  18. package/server/methods/get-address-lookup-table.ts +3 -7
  19. package/server/methods/program/get-program-accounts.ts +9 -9
  20. package/server/methods/program/get-token-account-balance.ts +3 -7
  21. package/server/methods/program/get-token-accounts-by-delegate.ts +4 -3
  22. package/server/methods/program/get-token-accounts-by-owner.ts +61 -35
  23. package/server/methods/program/get-token-largest-accounts.ts +3 -2
  24. package/server/methods/program/get-token-supply.ts +3 -2
  25. package/server/methods/solforge/index.ts +9 -6
  26. package/server/methods/transaction/get-parsed-transaction.ts +3 -7
  27. package/server/methods/transaction/get-signature-statuses.ts +14 -7
  28. package/server/methods/transaction/get-signatures-for-address.ts +3 -7
  29. package/server/methods/transaction/get-transaction.ts +167 -81
  30. package/server/methods/transaction/send-transaction.ts +29 -16
  31. package/server/methods/transaction/simulate-transaction.ts +3 -2
  32. package/server/rpc-server.ts +47 -34
  33. package/server/types.ts +9 -6
  34. package/server/ws-server.ts +15 -8
  35. package/src/api-server-entry.ts +91 -91
  36. package/src/cli/commands/airdrop.ts +2 -2
  37. package/src/cli/commands/config.ts +2 -2
  38. package/src/cli/commands/mint.ts +3 -3
  39. package/src/cli/commands/program-clone.ts +9 -11
  40. package/src/cli/commands/program-load.ts +3 -3
  41. package/src/cli/commands/rpc-start.ts +8 -5
  42. package/src/cli/commands/token-adopt-authority.ts +1 -1
  43. package/src/cli/commands/token-clone.ts +5 -6
  44. package/src/cli/commands/token-create.ts +5 -5
  45. package/src/cli/main.ts +38 -37
  46. package/src/cli/run-solforge.ts +20 -6
  47. package/src/cli/setup-wizard.ts +8 -6
  48. package/src/commands/add-program.ts +324 -328
  49. package/src/commands/init.ts +106 -106
  50. package/src/commands/list.ts +125 -125
  51. package/src/commands/mint.ts +247 -248
  52. package/src/commands/start.ts +837 -833
  53. package/src/commands/status.ts +80 -80
  54. package/src/commands/stop.ts +381 -382
  55. package/src/config/index.ts +33 -17
  56. package/src/config/manager.ts +150 -150
  57. package/src/db/index.ts +2 -2
  58. package/src/db/tx-store.ts +12 -8
  59. package/src/gui/public/app.css +1556 -1
  60. package/src/gui/public/build/main.css +1569 -1
  61. package/src/gui/server.ts +21 -22
  62. package/src/gui/src/api.ts +1 -1
  63. package/src/gui/src/app.tsx +96 -45
  64. package/src/gui/src/components/airdrop-mint-form.tsx +49 -19
  65. package/src/gui/src/components/clone-program-modal.tsx +31 -12
  66. package/src/gui/src/components/clone-token-modal.tsx +32 -13
  67. package/src/gui/src/components/modal.tsx +18 -11
  68. package/src/gui/src/components/programs-panel.tsx +27 -15
  69. package/src/gui/src/components/status-panel.tsx +32 -18
  70. package/src/gui/src/components/tokens-panel.tsx +25 -19
  71. package/src/gui/src/index.css +491 -463
  72. package/src/index.ts +177 -149
  73. package/src/rpc/start.ts +1 -1
  74. package/src/services/api-server.ts +494 -475
  75. package/src/services/port-manager.ts +164 -167
  76. package/src/services/process-registry.ts +144 -145
  77. package/src/services/program-cloner.ts +312 -312
  78. package/src/services/token-cloner.ts +799 -797
  79. package/src/services/validator.ts +288 -290
  80. package/src/types/config.ts +72 -72
  81. package/src/utils/shell.ts +75 -75
  82. package/src/utils/token-loader.ts +78 -78
@@ -1,288 +1,287 @@
1
- import { Command } from "commander";
2
- import chalk from "chalk";
3
- import { existsSync, readFileSync } from "fs";
4
- import { join } from "path";
5
1
  import { input, select } from "@inquirer/prompts";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import chalk from "chalk";
4
+ import { Command } from "commander";
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import type { TokenConfig } from "../types/config.js";
6
7
  import { runCommand } from "../utils/shell";
7
- import { Keypair, PublicKey } from "@solana/web3.js";
8
8
  import {
9
- loadClonedTokens,
10
- findTokenBySymbol,
11
- type ClonedToken,
9
+ type ClonedToken,
10
+ findTokenBySymbol,
11
+ loadClonedTokens,
12
12
  } from "../utils/token-loader.js";
13
- import type { TokenConfig } from "../types/config.js";
14
13
 
15
14
  export const mintCommand = new Command()
16
- .name("mint")
17
- .description("Interactively mint tokens to any wallet address")
18
- .option("--rpc-url <url>", "RPC URL to use", "http://127.0.0.1:8899")
19
- .option("--symbol <symbol>", "Token symbol to mint")
20
- .option("--wallet <address>", "Wallet address to mint to")
21
- .option("--amount <amount>", "Amount to mint")
22
- .action(async (options) => {
23
- try {
24
- console.log(chalk.blue("🪙 Interactive Token Minting"));
25
- console.log(chalk.gray("Mint tokens to any wallet address\n"));
15
+ .name("mint")
16
+ .description("Interactively mint tokens to any wallet address")
17
+ .option("--rpc-url <url>", "RPC URL to use", "http://127.0.0.1:8899")
18
+ .option("--symbol <symbol>", "Token symbol to mint")
19
+ .option("--wallet <address>", "Wallet address to mint to")
20
+ .option("--amount <amount>", "Amount to mint")
21
+ .action(async (options) => {
22
+ try {
23
+ console.log(chalk.blue("🪙 Interactive Token Minting"));
24
+ console.log(chalk.gray("Mint tokens to any wallet address\n"));
26
25
 
27
- // Check if solforge data exists
28
- const workDir = ".solforge";
29
- if (!existsSync(workDir)) {
30
- console.error(
31
- chalk.red("❌ No solforge data found. Run 'solforge start' first.")
32
- );
33
- process.exit(1);
34
- }
26
+ // Check if solforge data exists
27
+ const workDir = ".solforge";
28
+ if (!existsSync(workDir)) {
29
+ console.error(
30
+ chalk.red("❌ No solforge data found. Run 'solforge start' first."),
31
+ );
32
+ process.exit(1);
33
+ }
35
34
 
36
- // Load available tokens
37
- const tokens = await loadAvailableTokens(workDir);
35
+ // Load available tokens
36
+ const tokens = await loadAvailableTokens(workDir);
38
37
 
39
- if (tokens.length === 0) {
40
- console.error(
41
- chalk.red(
42
- "❌ No tokens found. Run 'solforge start' first to clone tokens."
43
- )
44
- );
45
- process.exit(1);
46
- }
38
+ if (tokens.length === 0) {
39
+ console.error(
40
+ chalk.red(
41
+ "❌ No tokens found. Run 'solforge start' first to clone tokens.",
42
+ ),
43
+ );
44
+ process.exit(1);
45
+ }
47
46
 
48
- // Display available tokens
49
- console.log(chalk.cyan("📋 Available Tokens:"));
50
- tokens.forEach((token, index) => {
51
- console.log(
52
- chalk.gray(
53
- ` ${index + 1}. ${token.config.symbol} (${
54
- token.config.mainnetMint
55
- })`
56
- )
57
- );
58
- });
59
- console.log();
47
+ // Display available tokens
48
+ console.log(chalk.cyan("📋 Available Tokens:"));
49
+ tokens.forEach((token, index) => {
50
+ console.log(
51
+ chalk.gray(
52
+ ` ${index + 1}. ${token.config.symbol} (${
53
+ token.config.mainnetMint
54
+ })`,
55
+ ),
56
+ );
57
+ });
58
+ console.log();
60
59
 
61
- // Select token (or use provided symbol)
62
- let selectedToken: ClonedToken;
63
- if (options.symbol) {
64
- const token = findTokenBySymbol(tokens, options.symbol);
65
- if (!token) {
66
- console.error(
67
- chalk.red(`❌ Token ${options.symbol} not found in cloned tokens`)
68
- );
69
- process.exit(1);
70
- }
71
- selectedToken = token;
72
- console.log(
73
- chalk.gray(`Selected token: ${selectedToken.config.symbol}`)
74
- );
75
- } else {
76
- selectedToken = await select({
77
- message: "Select a token to mint:",
78
- choices: tokens.map((token) => ({
79
- name: `${token.config.symbol} (${token.config.mainnetMint})`,
80
- value: token,
81
- })),
82
- });
83
- }
60
+ // Select token (or use provided symbol)
61
+ let selectedToken: ClonedToken;
62
+ if (options.symbol) {
63
+ const token = findTokenBySymbol(tokens, options.symbol);
64
+ if (!token) {
65
+ console.error(
66
+ chalk.red(`❌ Token ${options.symbol} not found in cloned tokens`),
67
+ );
68
+ process.exit(1);
69
+ }
70
+ selectedToken = token;
71
+ console.log(
72
+ chalk.gray(`Selected token: ${selectedToken.config.symbol}`),
73
+ );
74
+ } else {
75
+ selectedToken = await select({
76
+ message: "Select a token to mint:",
77
+ choices: tokens.map((token) => ({
78
+ name: `${token.config.symbol} (${token.config.mainnetMint})`,
79
+ value: token,
80
+ })),
81
+ });
82
+ }
84
83
 
85
- // Get recipient address (or use provided wallet)
86
- let recipientAddress: string;
87
- if (options.wallet) {
88
- recipientAddress = options.wallet;
89
- // Validate wallet address
90
- try {
91
- new PublicKey(recipientAddress);
92
- } catch {
93
- console.error(chalk.red("❌ Invalid wallet address"));
94
- process.exit(1);
95
- }
96
- console.log(chalk.gray(`Recipient wallet: ${recipientAddress}`));
97
- } else {
98
- recipientAddress = await input({
99
- message: "Enter recipient wallet address:",
100
- validate: (value: string) => {
101
- if (!value.trim()) {
102
- return "Please enter a valid address";
103
- }
104
- try {
105
- new PublicKey(value.trim());
106
- return true;
107
- } catch {
108
- return "Please enter a valid Solana address";
109
- }
110
- },
111
- });
112
- }
84
+ // Get recipient address (or use provided wallet)
85
+ let recipientAddress: string;
86
+ if (options.wallet) {
87
+ recipientAddress = options.wallet;
88
+ // Validate wallet address
89
+ try {
90
+ new PublicKey(recipientAddress);
91
+ } catch {
92
+ console.error(chalk.red("❌ Invalid wallet address"));
93
+ process.exit(1);
94
+ }
95
+ console.log(chalk.gray(`Recipient wallet: ${recipientAddress}`));
96
+ } else {
97
+ recipientAddress = await input({
98
+ message: "Enter recipient wallet address:",
99
+ validate: (value: string) => {
100
+ if (!value.trim()) {
101
+ return "Please enter a valid address";
102
+ }
103
+ try {
104
+ new PublicKey(value.trim());
105
+ return true;
106
+ } catch {
107
+ return "Please enter a valid Solana address";
108
+ }
109
+ },
110
+ });
111
+ }
113
112
 
114
- // Get amount to mint (or use provided amount)
115
- let amount: string;
116
- if (options.amount) {
117
- const num = parseFloat(options.amount);
118
- if (isNaN(num) || num <= 0) {
119
- console.error(chalk.red("❌ Invalid amount"));
120
- process.exit(1);
121
- }
122
- amount = options.amount;
123
- console.log(chalk.gray(`Amount to mint: ${amount}`));
124
- } else {
125
- amount = await input({
126
- message: "Enter amount to mint:",
127
- validate: (value: string) => {
128
- const num = parseFloat(value);
129
- if (isNaN(num) || num <= 0) {
130
- return "Please enter a valid positive number";
131
- }
132
- return true;
133
- },
134
- });
135
- }
113
+ // Get amount to mint (or use provided amount)
114
+ let amount: string;
115
+ if (options.amount) {
116
+ const num = parseFloat(options.amount);
117
+ if (Number.isNaN(num) || num <= 0) {
118
+ console.error(chalk.red("❌ Invalid amount"));
119
+ process.exit(1);
120
+ }
121
+ amount = options.amount;
122
+ console.log(chalk.gray(`Amount to mint: ${amount}`));
123
+ } else {
124
+ amount = await input({
125
+ message: "Enter amount to mint:",
126
+ validate: (value: string) => {
127
+ const num = parseFloat(value);
128
+ if (Number.isNaN(num) || num <= 0) {
129
+ return "Please enter a valid positive number";
130
+ }
131
+ return true;
132
+ },
133
+ });
134
+ }
136
135
 
137
- // Confirm minting if interactive
138
- if (!options.symbol || !options.wallet || !options.amount) {
139
- const confirm = await input({
140
- message: `Confirm minting ${amount} ${selectedToken.config.symbol} to ${recipientAddress}? (y/N):`,
141
- default: "N",
142
- });
136
+ // Confirm minting if interactive
137
+ if (!options.symbol || !options.wallet || !options.amount) {
138
+ const confirm = await input({
139
+ message: `Confirm minting ${amount} ${selectedToken.config.symbol} to ${recipientAddress}? (y/N):`,
140
+ default: "N",
141
+ });
143
142
 
144
- if (confirm.toLowerCase() !== "y" && confirm.toLowerCase() !== "yes") {
145
- console.log(chalk.yellow("Minting cancelled."));
146
- process.exit(0);
147
- }
148
- }
143
+ if (confirm.toLowerCase() !== "y" && confirm.toLowerCase() !== "yes") {
144
+ console.log(chalk.yellow("Minting cancelled."));
145
+ process.exit(0);
146
+ }
147
+ }
149
148
 
150
- console.log(chalk.blue("🚀 Starting mint..."));
149
+ console.log(chalk.blue("🚀 Starting mint..."));
151
150
 
152
- // Execute mint
153
- await mintTokenToWallet(
154
- selectedToken,
155
- recipientAddress,
156
- parseFloat(amount),
157
- options.rpcUrl
158
- );
151
+ // Execute mint
152
+ await mintTokenToWallet(
153
+ selectedToken,
154
+ recipientAddress,
155
+ parseFloat(amount),
156
+ options.rpcUrl,
157
+ );
159
158
 
160
- console.log(
161
- chalk.green(
162
- `✅ Successfully minted ${amount} ${selectedToken.config.symbol} to ${recipientAddress}`
163
- )
164
- );
165
- } catch (error) {
166
- console.error(chalk.red(`❌ Mint failed: ${error}`));
167
- process.exit(1);
168
- }
169
- });
159
+ console.log(
160
+ chalk.green(
161
+ `✅ Successfully minted ${amount} ${selectedToken.config.symbol} to ${recipientAddress}`,
162
+ ),
163
+ );
164
+ } catch (error) {
165
+ console.error(chalk.red(`❌ Mint failed: ${error}`));
166
+ process.exit(1);
167
+ }
168
+ });
170
169
 
171
170
  async function loadAvailableTokens(workDir: string): Promise<ClonedToken[]> {
172
- try {
173
- // Load token config from sf.config.json
174
- const configPath = "sf.config.json";
175
- if (!existsSync(configPath)) {
176
- throw new Error("sf.config.json not found in current directory");
177
- }
171
+ try {
172
+ // Load token config from sf.config.json
173
+ const configPath = "sf.config.json";
174
+ if (!existsSync(configPath)) {
175
+ throw new Error("sf.config.json not found in current directory");
176
+ }
178
177
 
179
- const config = JSON.parse(readFileSync(configPath, "utf8"));
180
- const tokenConfigs: TokenConfig[] = config.tokens || [];
178
+ const config = JSON.parse(readFileSync(configPath, "utf8"));
179
+ const tokenConfigs: TokenConfig[] = config.tokens || [];
181
180
 
182
- // Use the shared token loader
183
- return await loadClonedTokens(tokenConfigs, workDir);
184
- } catch (error) {
185
- throw new Error(`Failed to load tokens: ${error}`);
186
- }
181
+ // Use the shared token loader
182
+ return await loadClonedTokens(tokenConfigs, workDir);
183
+ } catch (error) {
184
+ throw new Error(`Failed to load tokens: ${error}`);
185
+ }
187
186
  }
188
187
 
189
188
  export async function mintTokenToWallet(
190
- token: ClonedToken,
191
- walletAddress: string,
192
- amount: number,
193
- rpcUrl: string
189
+ token: ClonedToken,
190
+ walletAddress: string,
191
+ amount: number,
192
+ rpcUrl: string,
194
193
  ): Promise<void> {
195
- // Check if associated token account already exists (same pattern as token-cloner.ts)
196
- console.log(chalk.gray(`🔍 Checking for existing token account...`));
194
+ // Check if associated token account already exists (same pattern as token-cloner.ts)
195
+ console.log(chalk.gray(`🔍 Checking for existing token account...`));
197
196
 
198
- const checkAccountsResult = await runCommand(
199
- "spl-token",
200
- ["accounts", "--owner", walletAddress, "--url", rpcUrl, "--output", "json"],
201
- { silent: true }
202
- );
197
+ const checkAccountsResult = await runCommand(
198
+ "spl-token",
199
+ ["accounts", "--owner", walletAddress, "--url", rpcUrl, "--output", "json"],
200
+ { silent: true },
201
+ );
203
202
 
204
- let tokenAccountAddress = "";
203
+ let tokenAccountAddress = "";
205
204
 
206
- if (checkAccountsResult.success && checkAccountsResult.stdout) {
207
- try {
208
- const accountsData = JSON.parse(checkAccountsResult.stdout);
205
+ if (checkAccountsResult.success && checkAccountsResult.stdout) {
206
+ try {
207
+ const accountsData = JSON.parse(checkAccountsResult.stdout);
209
208
 
210
- // Look for existing token account for this mint
211
- for (const account of accountsData.accounts || []) {
212
- if (account.mint === token.config.mainnetMint) {
213
- tokenAccountAddress = account.address;
214
- console.log(
215
- chalk.gray(
216
- `ℹ️ Found existing token account: ${tokenAccountAddress}`
217
- )
218
- );
219
- break;
220
- }
221
- }
222
- } catch (error) {
223
- // No existing accounts found or parsing error, will create new account
224
- }
225
- }
209
+ // Look for existing token account for this mint
210
+ for (const account of accountsData.accounts || []) {
211
+ if (account.mint === token.config.mainnetMint) {
212
+ tokenAccountAddress = account.address;
213
+ console.log(
214
+ chalk.gray(
215
+ `ℹ️ Found existing token account: ${tokenAccountAddress}`,
216
+ ),
217
+ );
218
+ break;
219
+ }
220
+ }
221
+ } catch (_error) {
222
+ // No existing accounts found or parsing error, will create new account
223
+ }
224
+ }
226
225
 
227
- if (!tokenAccountAddress) {
228
- // Account doesn't exist, create it (same pattern as token-cloner.ts)
229
- console.log(chalk.gray(`🔧 Creating token account...`));
226
+ if (!tokenAccountAddress) {
227
+ // Account doesn't exist, create it (same pattern as token-cloner.ts)
228
+ console.log(chalk.gray(`🔧 Creating token account...`));
230
229
 
231
- const createAccountResult = await runCommand(
232
- "spl-token",
233
- [
234
- "create-account",
235
- token.config.mainnetMint,
236
- "--owner",
237
- walletAddress,
238
- "--fee-payer",
239
- token.mintAuthorityPath,
240
- "--url",
241
- rpcUrl,
242
- ],
243
- { silent: false }
244
- );
230
+ const createAccountResult = await runCommand(
231
+ "spl-token",
232
+ [
233
+ "create-account",
234
+ token.config.mainnetMint,
235
+ "--owner",
236
+ walletAddress,
237
+ "--fee-payer",
238
+ token.mintAuthorityPath,
239
+ "--url",
240
+ rpcUrl,
241
+ ],
242
+ { silent: false },
243
+ );
245
244
 
246
- if (!createAccountResult.success) {
247
- throw new Error(
248
- `Failed to create token account: ${createAccountResult.stderr}`
249
- );
250
- }
245
+ if (!createAccountResult.success) {
246
+ throw new Error(
247
+ `Failed to create token account: ${createAccountResult.stderr}`,
248
+ );
249
+ }
251
250
 
252
- // Extract token account address from create-account output
253
- const match = createAccountResult.stdout.match(/Creating account (\S+)/);
254
- tokenAccountAddress = match?.[1] || "";
251
+ // Extract token account address from create-account output
252
+ const match = createAccountResult.stdout.match(/Creating account (\S+)/);
253
+ tokenAccountAddress = match?.[1] || "";
255
254
 
256
- if (!tokenAccountAddress) {
257
- throw new Error(
258
- "Failed to determine token account address from create-account output"
259
- );
260
- }
255
+ if (!tokenAccountAddress) {
256
+ throw new Error(
257
+ "Failed to determine token account address from create-account output",
258
+ );
259
+ }
261
260
 
262
- console.log(chalk.gray(`✅ Created token account: ${tokenAccountAddress}`));
263
- }
261
+ console.log(chalk.gray(`✅ Created token account: ${tokenAccountAddress}`));
262
+ }
264
263
 
265
- // Now mint to the token account (same pattern as token-cloner.ts)
266
- console.log(chalk.gray(`💰 Minting ${amount} tokens...`));
264
+ // Now mint to the token account (same pattern as token-cloner.ts)
265
+ console.log(chalk.gray(`💰 Minting ${amount} tokens...`));
267
266
 
268
- const result = await runCommand(
269
- "spl-token",
270
- [
271
- "mint",
272
- token.config.mainnetMint,
273
- amount.toString(),
274
- tokenAccountAddress,
275
- "--mint-authority",
276
- token.mintAuthorityPath,
277
- "--fee-payer",
278
- token.mintAuthorityPath,
279
- "--url",
280
- rpcUrl,
281
- ],
282
- { silent: false }
283
- );
267
+ const result = await runCommand(
268
+ "spl-token",
269
+ [
270
+ "mint",
271
+ token.config.mainnetMint,
272
+ amount.toString(),
273
+ tokenAccountAddress,
274
+ "--mint-authority",
275
+ token.mintAuthorityPath,
276
+ "--fee-payer",
277
+ token.mintAuthorityPath,
278
+ "--url",
279
+ rpcUrl,
280
+ ],
281
+ { silent: false },
282
+ );
284
283
 
285
- if (!result.success) {
286
- throw new Error(`Failed to mint tokens: ${result.stderr}`);
287
- }
284
+ if (!result.success) {
285
+ throw new Error(`Failed to mint tokens: ${result.stderr}`);
286
+ }
288
287
  }