solforge 0.2.3 â 0.2.5
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/LICENSE +2 -2
- package/README.md +323 -364
- package/cli.cjs +126 -69
- package/package.json +1 -1
- package/scripts/install.sh +112 -0
- package/scripts/postinstall.cjs +66 -58
- package/server/methods/program/get-token-accounts-by-owner.ts +7 -2
- package/server/ws-server.ts +4 -1
- package/src/api-server-entry.ts +91 -91
- package/src/cli/commands/rpc-start.ts +4 -1
- package/src/cli/main.ts +39 -14
- package/src/cli/run-solforge.ts +20 -6
- package/src/commands/add-program.ts +324 -328
- package/src/commands/init.ts +106 -106
- package/src/commands/list.ts +125 -125
- package/src/commands/mint.ts +246 -246
- package/src/commands/start.ts +834 -831
- package/src/commands/status.ts +80 -80
- package/src/commands/stop.ts +381 -382
- package/src/config/manager.ts +149 -149
- package/src/gui/public/app.css +1556 -1
- package/src/gui/public/build/main.css +1569 -1
- package/src/gui/server.ts +20 -21
- package/src/gui/src/app.tsx +56 -37
- package/src/gui/src/components/airdrop-mint-form.tsx +17 -11
- package/src/gui/src/components/clone-program-modal.tsx +6 -6
- package/src/gui/src/components/clone-token-modal.tsx +7 -7
- package/src/gui/src/components/modal.tsx +13 -11
- package/src/gui/src/components/programs-panel.tsx +27 -15
- package/src/gui/src/components/status-panel.tsx +31 -17
- package/src/gui/src/components/tokens-panel.tsx +25 -19
- package/src/gui/src/index.css +491 -463
- package/src/index.ts +161 -146
- package/src/rpc/start.ts +1 -1
- package/src/services/api-server.ts +470 -473
- package/src/services/port-manager.ts +167 -167
- package/src/services/process-registry.ts +143 -143
- package/src/services/program-cloner.ts +312 -312
- package/src/services/token-cloner.ts +799 -797
- package/src/services/validator.ts +288 -288
- package/src/types/config.ts +71 -71
- package/src/utils/shell.ts +75 -75
- package/src/utils/token-loader.ts +77 -77
package/src/commands/mint.ts
CHANGED
|
@@ -1,288 +1,288 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { input, select } from "@inquirer/prompts";
|
|
2
|
+
import { Keypair, PublicKey } from "@solana/web3.js";
|
|
2
3
|
import chalk from "chalk";
|
|
4
|
+
import { Command } from "commander";
|
|
3
5
|
import { existsSync, readFileSync } from "fs";
|
|
4
6
|
import { join } from "path";
|
|
5
|
-
import {
|
|
7
|
+
import type { TokenConfig } from "../types/config.js";
|
|
6
8
|
import { runCommand } from "../utils/shell";
|
|
7
|
-
import { Keypair, PublicKey } from "@solana/web3.js";
|
|
8
9
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
type ClonedToken,
|
|
11
|
+
findTokenBySymbol,
|
|
12
|
+
loadClonedTokens,
|
|
12
13
|
} from "../utils/token-loader.js";
|
|
13
|
-
import type { TokenConfig } from "../types/config.js";
|
|
14
14
|
|
|
15
15
|
export const mintCommand = new Command()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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"));
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// Load available tokens
|
|
37
|
+
const tokens = await loadAvailableTokens(workDir);
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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();
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
+
}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
}
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
+
}
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
+
});
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
if (confirm.toLowerCase() !== "y" && confirm.toLowerCase() !== "yes") {
|
|
145
|
+
console.log(chalk.yellow("Minting cancelled."));
|
|
146
|
+
process.exit(0);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
console.log(chalk.blue("đ Starting mint..."));
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
152
|
+
// Execute mint
|
|
153
|
+
await mintTokenToWallet(
|
|
154
|
+
selectedToken,
|
|
155
|
+
recipientAddress,
|
|
156
|
+
parseFloat(amount),
|
|
157
|
+
options.rpcUrl,
|
|
158
|
+
);
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
+
});
|
|
170
170
|
|
|
171
171
|
async function loadAvailableTokens(workDir: string): Promise<ClonedToken[]> {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
+
}
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
const config = JSON.parse(readFileSync(configPath, "utf8"));
|
|
180
|
+
const tokenConfigs: TokenConfig[] = config.tokens || [];
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
+
}
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
export async function mintTokenToWallet(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
token: ClonedToken,
|
|
191
|
+
walletAddress: string,
|
|
192
|
+
amount: number,
|
|
193
|
+
rpcUrl: string,
|
|
194
194
|
): Promise<void> {
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
// Check if associated token account already exists (same pattern as token-cloner.ts)
|
|
196
|
+
console.log(chalk.gray(`đ Checking for existing token account...`));
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
const checkAccountsResult = await runCommand(
|
|
199
|
+
"spl-token",
|
|
200
|
+
["accounts", "--owner", walletAddress, "--url", rpcUrl, "--output", "json"],
|
|
201
|
+
{ silent: true },
|
|
202
|
+
);
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
let tokenAccountAddress = "";
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
if (checkAccountsResult.success && checkAccountsResult.stdout) {
|
|
207
|
+
try {
|
|
208
|
+
const accountsData = JSON.parse(checkAccountsResult.stdout);
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
+
}
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
if (!tokenAccountAddress) {
|
|
228
|
+
// Account doesn't exist, create it (same pattern as token-cloner.ts)
|
|
229
|
+
console.log(chalk.gray(`đ§ Creating token account...`));
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
+
);
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
246
|
+
if (!createAccountResult.success) {
|
|
247
|
+
throw new Error(
|
|
248
|
+
`Failed to create token account: ${createAccountResult.stderr}`,
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
// Extract token account address from create-account output
|
|
253
|
+
const match = createAccountResult.stdout.match(/Creating account (\S+)/);
|
|
254
|
+
tokenAccountAddress = match?.[1] || "";
|
|
255
255
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
if (!tokenAccountAddress) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
"Failed to determine token account address from create-account output",
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
console.log(chalk.gray(`â
Created token account: ${tokenAccountAddress}`));
|
|
263
|
+
}
|
|
264
264
|
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
// Now mint to the token account (same pattern as token-cloner.ts)
|
|
266
|
+
console.log(chalk.gray(`đ° Minting ${amount} tokens...`));
|
|
267
267
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
+
);
|
|
284
284
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
if (!result.success) {
|
|
286
|
+
throw new Error(`Failed to mint tokens: ${result.stderr}`);
|
|
287
|
+
}
|
|
288
288
|
}
|