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
@@ -8,14 +8,14 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
8
8
  try {
9
9
  const rec = context.getRecordedTransaction(signature);
10
10
  if (rec) {
11
- const tx = rec.tx as any;
11
+ const tx = rec.tx;
12
12
  if (encoding === "base64") {
13
13
  const raw = Buffer.from(tx.serialize()).toString("base64");
14
14
  // Top-level version is required by some clients
15
- const isV0 =
16
- typeof (tx.message as any)?.version === "number"
17
- ? (tx.message as any).version === 0
18
- : true;
15
+ const isV0 = (() => {
16
+ const m = tx.message as unknown as { version?: number };
17
+ return typeof m?.version === "number" ? m.version === 0 : true;
18
+ })();
19
19
  return context.createSuccessResponse(id, {
20
20
  slot: rec.slot,
21
21
  transaction: [raw, "base64"],
@@ -31,55 +31,86 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
31
31
  : [],
32
32
  innerInstructions: [],
33
33
  logMessages: rec.logs || [],
34
- preTokenBalances: Array.isArray((rec as any).preTokenBalances)
35
- ? (rec as any).preTokenBalances
36
- : [],
37
- postTokenBalances: Array.isArray((rec as any).postTokenBalances)
38
- ? (rec as any).postTokenBalances
39
- : [],
34
+ preTokenBalances: (() => {
35
+ const arr = (rec as unknown as { preTokenBalances?: unknown[] })
36
+ .preTokenBalances;
37
+ return Array.isArray(arr) ? arr : [];
38
+ })(),
39
+ postTokenBalances: (() => {
40
+ const arr = (rec as unknown as { postTokenBalances?: unknown[] })
41
+ .postTokenBalances;
42
+ return Array.isArray(arr) ? arr : [];
43
+ })(),
40
44
  rewards: [],
41
45
  },
42
46
  blockTime: rec.blockTime,
43
47
  });
44
48
  }
45
49
 
46
- const msg: any = tx.message as any;
47
- const rawKeys1: any[] = Array.isArray(msg.staticAccountKeys)
50
+ const msg = tx.message as unknown as {
51
+ staticAccountKeys?: unknown[];
52
+ accountKeys?: unknown[];
53
+ compiledInstructions?: unknown[];
54
+ instructions?: unknown[];
55
+ header?: unknown;
56
+ recentBlockhash?: string;
57
+ version?: number;
58
+ addressTableLookups?: unknown[];
59
+ isAccountSigner?: (i: number) => boolean;
60
+ isAccountWritable?: (i: number) => boolean;
61
+ };
62
+ const rawKeys1: unknown[] = Array.isArray(msg.staticAccountKeys)
48
63
  ? msg.staticAccountKeys
49
64
  : Array.isArray(msg.accountKeys)
50
65
  ? msg.accountKeys
51
66
  : [];
52
- const accountKeys = rawKeys1.map((k: any) => {
67
+ const accountKeys = rawKeys1.map((k) => {
53
68
  try {
54
- return typeof k === "string" ? k : k.toBase58();
69
+ return typeof k === "string"
70
+ ? k
71
+ : (k as { toBase58: () => string }).toBase58();
55
72
  } catch {
56
73
  return String(k);
57
74
  }
58
75
  });
59
- const compiled = Array.isArray(msg.compiledInstructions)
76
+ const compiled: unknown[] = Array.isArray(msg.compiledInstructions)
60
77
  ? msg.compiledInstructions
61
78
  : Array.isArray(msg.instructions)
62
79
  ? msg.instructions
63
80
  : [];
64
- const instructions = compiled.map((ci: any) => {
81
+ const instructions = compiled.map((ci) => {
82
+ const c = ci as {
83
+ programIdIndex: number;
84
+ accountKeyIndexes?: number[];
85
+ accounts?: number[];
86
+ data: Uint8Array | number[];
87
+ };
65
88
  const dataBytes: Uint8Array =
66
- ci.data instanceof Uint8Array ? ci.data : Buffer.from(ci.data);
89
+ c.data instanceof Uint8Array ? c.data : Buffer.from(c.data);
67
90
  return {
68
- programIdIndex: ci.programIdIndex,
69
- accounts: Array.from(ci.accountKeyIndexes || ci.accounts || []),
91
+ programIdIndex: c.programIdIndex,
92
+ accounts: Array.from(c.accountKeyIndexes || c.accounts || []),
70
93
  data: context.encodeBase58(dataBytes),
71
94
  };
72
95
  });
73
- const addressTableLookups = (msg.addressTableLookups || []).map(
74
- (l: any) => ({
96
+ const addressTableLookups = (
97
+ Array.isArray(msg.addressTableLookups) ? msg.addressTableLookups : []
98
+ ).map((l) => {
99
+ const a = l as {
100
+ accountKey?: { toBase58?: () => string } | string;
101
+ writableIndexes?: number[];
102
+ readonlyIndexes?: number[];
103
+ };
104
+ return {
75
105
  accountKey:
76
- typeof l.accountKey?.toBase58 === "function"
77
- ? l.accountKey.toBase58()
78
- : String(l.accountKey),
79
- writableIndexes: Array.from(l.writableIndexes || []),
80
- readonlyIndexes: Array.from(l.readonlyIndexes || []),
81
- }),
82
- );
106
+ typeof (a.accountKey as { toBase58?: unknown })?.toBase58 ===
107
+ "function"
108
+ ? (a.accountKey as { toBase58: () => string }).toBase58()
109
+ : String(a.accountKey),
110
+ writableIndexes: Array.from(a.writableIndexes || []),
111
+ readonlyIndexes: Array.from(a.readonlyIndexes || []),
112
+ };
113
+ });
83
114
  const header = msg.header || {
84
115
  numRequiredSignatures: tx.signatures.length,
85
116
  numReadonlySignedAccounts: 0,
@@ -88,7 +119,7 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
88
119
  const recentBlockhash = msg.recentBlockhash || "";
89
120
 
90
121
  const isV0 = typeof msg.version === "number" ? msg.version === 0 : true;
91
- const result: any = {
122
+ const result = {
92
123
  slot: rec.slot,
93
124
  transaction: {
94
125
  signatures: [signature],
@@ -110,12 +141,16 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
110
141
  postBalances: Array.isArray(rec.postBalances) ? rec.postBalances : [],
111
142
  innerInstructions: [],
112
143
  logMessages: rec.logs || [],
113
- preTokenBalances: Array.isArray((rec as any).preTokenBalances)
114
- ? (rec as any).preTokenBalances
115
- : [],
116
- postTokenBalances: Array.isArray((rec as any).postTokenBalances)
117
- ? (rec as any).postTokenBalances
118
- : [],
144
+ preTokenBalances: (() => {
145
+ const arr = (rec as unknown as { preTokenBalances?: unknown[] })
146
+ .preTokenBalances;
147
+ return Array.isArray(arr) ? arr : [];
148
+ })(),
149
+ postTokenBalances: (() => {
150
+ const arr = (rec as unknown as { postTokenBalances?: unknown[] })
151
+ .postTokenBalances;
152
+ return Array.isArray(arr) ? arr : [];
153
+ })(),
119
154
  rewards: [],
120
155
  },
121
156
  blockTime: rec.blockTime,
@@ -134,12 +169,18 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
134
169
  ? !!msg.isAccountWritable(i)
135
170
  : i < (header?.numRequiredSignatures ?? 0),
136
171
  }));
137
- const parsedInstructions = compiled.map((ci: any) => {
138
- const programId = accountKeys[ci.programIdIndex];
139
- let parsed: any;
172
+ const parsedInstructions = compiled.map((ci) => {
173
+ const c = ci as {
174
+ programIdIndex: number;
175
+ accountKeyIndexes?: number[];
176
+ accounts?: number[];
177
+ data: Uint8Array | number[];
178
+ };
179
+ const programId = accountKeys[c.programIdIndex];
180
+ let parsed: unknown;
140
181
  try {
141
182
  const data: Uint8Array =
142
- ci.data instanceof Uint8Array ? ci.data : Buffer.from(ci.data);
183
+ c.data instanceof Uint8Array ? c.data : Buffer.from(c.data);
143
184
  if (programId === SYSTEM_PROGRAM_ID && data.length >= 12) {
144
185
  const dv = new DataView(
145
186
  data.buffer,
@@ -152,8 +193,9 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
152
193
  (ci.accountKeyIndexes?.length ?? 0) >= 2
153
194
  ) {
154
195
  const lamports = Number(dv.getBigUint64(4, true));
155
- const source = accountKeys[ci.accountKeyIndexes[0]];
156
- const destination = accountKeys[ci.accountKeyIndexes[1]];
196
+ const source = accountKeys[c.accountKeyIndexes?.[0] as number];
197
+ const destination =
198
+ accountKeys[c.accountKeyIndexes?.[1] as number];
157
199
  parsed = {
158
200
  type: "transfer",
159
201
  info: { source, destination, lamports },
@@ -164,16 +206,19 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
164
206
  if (parsed) return { program: "system", programId, parsed };
165
207
  return {
166
208
  programId,
167
- accounts: (ci.accountKeyIndexes || []).map(
209
+ accounts: (c.accountKeyIndexes || []).map(
168
210
  (ix: number) => accountKeys[ix],
169
211
  ),
170
212
  data: context.encodeBase58(
171
- ci.data instanceof Uint8Array ? ci.data : Buffer.from(ci.data),
213
+ c.data instanceof Uint8Array ? c.data : Buffer.from(c.data),
172
214
  ),
173
215
  };
174
216
  });
175
- result.transaction.message.accountKeys = accountKeysParsed;
176
- result.transaction.message.instructions = parsedInstructions;
217
+ (result.transaction.message as { accountKeys: unknown[] }).accountKeys =
218
+ accountKeysParsed;
219
+ (
220
+ result.transaction.message as { instructions: unknown[] }
221
+ ).instructions = parsedInstructions as unknown[];
177
222
  }
178
223
 
179
224
  return context.createSuccessResponse(id, result);
@@ -213,15 +258,27 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
213
258
  // Build jsonParsed similar to in-memory path
214
259
  const raw = Buffer.from(row.rawBase64, "base64");
215
260
  const tx = VersionedTransaction.deserialize(raw);
216
- const msg: any = tx.message as any;
217
- const rawKeys2: any[] = Array.isArray(msg.staticAccountKeys)
261
+ const msg = tx.message as unknown as {
262
+ staticAccountKeys?: unknown[];
263
+ accountKeys?: unknown[];
264
+ compiledInstructions?: unknown[];
265
+ instructions?: unknown[];
266
+ header?: unknown;
267
+ recentBlockhash?: string;
268
+ addressTableLookups?: unknown[];
269
+ isAccountSigner?: (i: number) => boolean;
270
+ isAccountWritable?: (i: number) => boolean;
271
+ };
272
+ const rawKeys2: unknown[] = Array.isArray(msg.staticAccountKeys)
218
273
  ? msg.staticAccountKeys
219
274
  : Array.isArray(msg.accountKeys)
220
275
  ? msg.accountKeys
221
276
  : [];
222
- const accountKeys = rawKeys2.map((k: any) => {
277
+ const accountKeys = rawKeys2.map((k) => {
223
278
  try {
224
- return typeof k === "string" ? k : k.toBase58();
279
+ return typeof k === "string"
280
+ ? k
281
+ : (k as { toBase58: () => string }).toBase58();
225
282
  } catch {
226
283
  return String(k);
227
284
  }
@@ -231,17 +288,23 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
231
288
  numReadonlySignedAccounts: 0,
232
289
  numReadonlyUnsignedAccounts: 0,
233
290
  };
234
- const compiled = Array.isArray(msg.compiledInstructions)
291
+ const compiled: unknown[] = Array.isArray(msg.compiledInstructions)
235
292
  ? msg.compiledInstructions
236
293
  : Array.isArray(msg.instructions)
237
294
  ? msg.instructions
238
295
  : [];
239
- const parsedInstructions = compiled.map((ci: any) => {
240
- const programId = accountKeys[ci.programIdIndex];
241
- let parsed: any;
296
+ const parsedInstructions = compiled.map((ci) => {
297
+ const c = ci as {
298
+ programIdIndex: number;
299
+ accountKeyIndexes?: number[];
300
+ accounts?: number[];
301
+ data: Uint8Array | number[];
302
+ };
303
+ const programId = accountKeys[c.programIdIndex];
304
+ let parsed: unknown;
242
305
  try {
243
306
  const data: Uint8Array =
244
- ci.data instanceof Uint8Array ? ci.data : Buffer.from(ci.data);
307
+ c.data instanceof Uint8Array ? c.data : Buffer.from(c.data);
245
308
  // Minimal system transfer parser
246
309
  if (
247
310
  programId === "11111111111111111111111111111111" &&
@@ -258,8 +321,8 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
258
321
  (ci.accountKeyIndexes?.length ?? 0) >= 2
259
322
  ) {
260
323
  const lamports = Number(dv.getBigUint64(4, true));
261
- const source = accountKeys[ci.accountKeyIndexes[0]];
262
- const destination = accountKeys[ci.accountKeyIndexes[1]];
324
+ const source = accountKeys[c.accountKeyIndexes?.[0]];
325
+ const destination = accountKeys[c.accountKeyIndexes?.[1]];
263
326
  parsed = {
264
327
  type: "transfer",
265
328
  info: { source, destination, lamports },
@@ -270,11 +333,11 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
270
333
  if (parsed) return { program: "system", programId, parsed };
271
334
  return {
272
335
  programId,
273
- accounts: (ci.accountKeyIndexes || []).map(
336
+ accounts: (c.accountKeyIndexes || []).map(
274
337
  (ix: number) => accountKeys[ix],
275
338
  ),
276
339
  data: context.encodeBase58(
277
- ci.data instanceof Uint8Array ? ci.data : Buffer.from(ci.data),
340
+ c.data instanceof Uint8Array ? c.data : Buffer.from(c.data),
278
341
  ),
279
342
  };
280
343
  });
@@ -291,7 +354,7 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
291
354
  : i < (header?.numRequiredSignatures ?? 0),
292
355
  }),
293
356
  );
294
- const result: any = {
357
+ const result = {
295
358
  slot: Number(row.slot),
296
359
  transaction: {
297
360
  signatures: [signature],
@@ -323,15 +386,25 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
323
386
  } else {
324
387
  const raw = Buffer.from(row.rawBase64, "base64");
325
388
  const tx = VersionedTransaction.deserialize(raw);
326
- const msg: any = tx.message as any;
327
- const rawKeys3: any[] = Array.isArray(msg.staticAccountKeys)
389
+ const msg = tx.message as unknown as {
390
+ staticAccountKeys?: unknown[];
391
+ accountKeys?: unknown[];
392
+ compiledInstructions?: unknown[];
393
+ instructions?: unknown[];
394
+ header?: unknown;
395
+ recentBlockhash?: string;
396
+ addressTableLookups?: unknown[];
397
+ };
398
+ const rawKeys3: unknown[] = Array.isArray(msg.staticAccountKeys)
328
399
  ? msg.staticAccountKeys
329
400
  : Array.isArray(msg.accountKeys)
330
401
  ? msg.accountKeys
331
402
  : [];
332
- const accountKeys = rawKeys3.map((k: any) => {
403
+ const accountKeys = rawKeys3.map((k) => {
333
404
  try {
334
- return typeof k === "string" ? k : k.toBase58();
405
+ return typeof k === "string"
406
+ ? k
407
+ : (k as { toBase58: () => string }).toBase58();
335
408
  } catch {
336
409
  return String(k);
337
410
  }
@@ -341,19 +414,27 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
341
414
  numReadonlySignedAccounts: 0,
342
415
  numReadonlyUnsignedAccounts: 0,
343
416
  };
344
- const compiled = Array.isArray(msg.compiledInstructions)
417
+ const compiled: unknown[] = Array.isArray(msg.compiledInstructions)
345
418
  ? msg.compiledInstructions
346
419
  : Array.isArray(msg.instructions)
347
420
  ? msg.instructions
348
421
  : [];
349
- const instructions = compiled.map((ci: any) => ({
350
- programIdIndex: ci.programIdIndex,
351
- accounts: Array.from(ci.accountKeyIndexes || ci.accounts || []),
352
- data: context.encodeBase58(
353
- ci.data instanceof Uint8Array ? ci.data : Buffer.from(ci.data),
354
- ),
355
- }));
356
- const result: any = {
422
+ const instructions = compiled.map((ci) => {
423
+ const c = ci as {
424
+ programIdIndex: number;
425
+ accountKeyIndexes?: number[];
426
+ accounts?: number[];
427
+ data: Uint8Array | number[];
428
+ };
429
+ return {
430
+ programIdIndex: c.programIdIndex,
431
+ accounts: Array.from(c.accountKeyIndexes || c.accounts || []),
432
+ data: context.encodeBase58(
433
+ c.data instanceof Uint8Array ? c.data : Buffer.from(c.data),
434
+ ),
435
+ };
436
+ });
437
+ const result = {
357
438
  slot: Number(row.slot),
358
439
  transaction: {
359
440
  signatures: [signature],
@@ -388,7 +469,16 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
388
469
 
389
470
  // Fallback to LiteSVM history when no local record exists
390
471
  const sigBytes = context.decodeBase58(signature);
391
- const txh = (context.svm as any).getTransaction(sigBytes);
472
+ const getTx = (
473
+ context.svm as unknown as {
474
+ getTransaction?: (
475
+ sig: Uint8Array,
476
+ ) =>
477
+ | { logs: () => string[]; err: () => unknown }
478
+ | { meta: () => { logs: () => string[] }; err: () => unknown };
479
+ }
480
+ ).getTransaction;
481
+ const txh = typeof getTx === "function" ? getTx(sigBytes) : undefined;
392
482
  if (!txh) return context.createSuccessResponse(id, null);
393
483
 
394
484
  const isError = "err" in txh;
@@ -417,12 +507,8 @@ export const getTransaction: RpcMethodHandler = async (id, params, context) => {
417
507
  },
418
508
  blockTime: Math.floor(Date.now() / 1000),
419
509
  });
420
- } catch (error: any) {
421
- return context.createErrorResponse(
422
- id,
423
- -32602,
424
- "Invalid params",
425
- error.message,
426
- );
510
+ } catch (error: unknown) {
511
+ const message = error instanceof Error ? error.message : String(error);
512
+ return context.createErrorResponse(id, -32602, "Invalid params", message);
427
513
  }
428
514
  };
@@ -16,14 +16,17 @@ export const sendTransaction: RpcMethodHandler = (id, params, context) => {
16
16
  const tx = VersionedTransaction.deserialize(txData);
17
17
 
18
18
  // Snapshot pre balances
19
- const msg: any = tx.message as any;
20
- const rawKeys: any[] = Array.isArray(msg.staticAccountKeys)
19
+ const msg = tx.message as unknown as {
20
+ staticAccountKeys?: unknown[];
21
+ accountKeys?: unknown[];
22
+ };
23
+ const rawKeys: unknown[] = Array.isArray(msg.staticAccountKeys)
21
24
  ? msg.staticAccountKeys
22
25
  : Array.isArray(msg.accountKeys)
23
26
  ? msg.accountKeys
24
27
  : [];
25
28
  const staticKeys = rawKeys
26
- .map((k: any) => {
29
+ .map((k) => {
27
30
  try {
28
31
  return typeof k === "string" ? new PublicKey(k) : (k as PublicKey);
29
32
  } catch {
@@ -40,8 +43,11 @@ export const sendTransaction: RpcMethodHandler = (id, params, context) => {
40
43
  });
41
44
 
42
45
  // Collect SPL token accounts from instructions for pre/post token balance snapshots
43
- const msgAny: any = msg;
44
- const compiled = Array.isArray(msgAny.compiledInstructions)
46
+ const msgAny = msg as unknown as {
47
+ compiledInstructions?: unknown[];
48
+ instructions?: unknown[];
49
+ };
50
+ const compiled: unknown[] = Array.isArray(msgAny.compiledInstructions)
45
51
  ? msgAny.compiledInstructions
46
52
  : Array.isArray(msgAny.instructions)
47
53
  ? msgAny.instructions
@@ -67,7 +73,7 @@ export const sendTransaction: RpcMethodHandler = (id, params, context) => {
67
73
  } catch {}
68
74
  }
69
75
  // Pre token balances
70
- const preTokenBalances: any[] = [];
76
+ const preTokenBalances: unknown[] = [];
71
77
  const ataToInfo = new Map<
72
78
  string,
73
79
  {
@@ -127,8 +133,9 @@ export const sendTransaction: RpcMethodHandler = (id, params, context) => {
127
133
  const result = context.svm.sendTransaction(tx);
128
134
 
129
135
  try {
130
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
- const maybeErr = (result as any).err?.();
136
+ const rawErr = (result as { err?: unknown }).err;
137
+ const maybeErr =
138
+ typeof rawErr === "function" ? (rawErr as () => unknown)() : rawErr;
132
139
  if (maybeErr) {
133
140
  return context.createErrorResponse(
134
141
  id,
@@ -152,7 +159,7 @@ export const sendTransaction: RpcMethodHandler = (id, params, context) => {
152
159
  }
153
160
  });
154
161
  // Post token balances
155
- const postTokenBalances: any[] = [];
162
+ const postTokenBalances: unknown[] = [];
156
163
  for (const addr of tokenAccountSet) {
157
164
  try {
158
165
  const pk = new PublicKey(addr);
@@ -204,11 +211,16 @@ export const sendTransaction: RpcMethodHandler = (id, params, context) => {
204
211
  }
205
212
  let logs: string[] = [];
206
213
  try {
207
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
208
- const anyRes: any = result;
209
- if (typeof anyRes?.logs === "function") logs = anyRes.logs();
210
- else if (typeof anyRes?.meta === "function")
211
- logs = anyRes.meta()?.logs?.() ?? [];
214
+ const sr = result as {
215
+ logs?: () => string[];
216
+ meta?: () => { logs?: () => string[] } | undefined;
217
+ };
218
+ if (typeof sr?.logs === "function") logs = sr.logs();
219
+ else if (typeof sr?.meta === "function") {
220
+ const m = sr.meta();
221
+ const lg = m?.logs;
222
+ if (typeof lg === "function") logs = lg();
223
+ }
212
224
  } catch {}
213
225
  context.recordTransaction(signature, tx, {
214
226
  logs,
@@ -221,12 +233,13 @@ export const sendTransaction: RpcMethodHandler = (id, params, context) => {
221
233
  });
222
234
 
223
235
  return context.createSuccessResponse(id, signature);
224
- } catch (error: any) {
236
+ } catch (error: unknown) {
237
+ const message = error instanceof Error ? error.message : String(error);
225
238
  return context.createErrorResponse(
226
239
  id,
227
240
  -32003,
228
241
  "Transaction failed",
229
- error.message,
242
+ message,
230
243
  );
231
244
  }
232
245
  };
@@ -45,12 +45,13 @@ export const simulateTransaction: RpcMethodHandler = (id, params, context) => {
45
45
  : null,
46
46
  },
47
47
  });
48
- } catch (error: any) {
48
+ } catch (error: unknown) {
49
+ const message = error instanceof Error ? error.message : String(error);
49
50
  return context.createErrorResponse(
50
51
  id,
51
52
  -32003,
52
53
  "Simulation failed",
53
- error.message,
54
+ message,
54
55
  );
55
56
  }
56
57
  };