@haven-fi/solauto-sdk 1.0.818 → 1.0.819

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.
@@ -1 +1 @@
1
- {"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAiBlE,wBAAgB,mBAAmB,IAAI,SAAS,CAG/C;AAkHD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB;;;;IAkB/D;AAqHD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,EAAE,kBAAkB,EAAE,EAClC,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,EAC3B,eAAe,CAAC,EAAE,eAAe,GAChC,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAkH/B"}
1
+ {"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAiBlE,wBAAgB,mBAAmB,IAAI,SAAS,CAG/C;AAiGD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB;;;;IAkB/D;AAqHD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,EAAE,kBAAkB,EAAE,EAClC,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,EAC3B,eAAe,CAAC,EAAE,eAAe,GAChC,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA6G/B"}
@@ -44,25 +44,10 @@ function parseJitoErrorMessage(message) {
44
44
  }
45
45
  }
46
46
  async function simulateJitoBundle(umi, txs) {
47
- // Pre-serialize transactions to catch size errors before simulation
48
- const serializedTxs = [];
49
- for (let i = 0; i < txs.length; i++) {
50
- try {
51
- const serialized = txs[i].serialize();
52
- if (serialized.length > 1232) {
53
- throw new Error(`Transaction ${i} is too large: ${serialized.length} bytes (max: 1232)`);
54
- }
55
- serializedTxs.push(Buffer.from(serialized).toString("base64"));
56
- }
57
- catch (e) {
58
- (0, generalUtils_1.consoleLog)(`Failed to serialize transaction ${i}:`, e);
59
- throw new Error(`Failed to serialize transaction ${i}: ${e.message || e}`);
60
- }
61
- }
62
47
  const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
63
48
  const res = await (0, generalUtils_1.customRpcCall)(umi, "simulateBundle", [
64
49
  {
65
- encodedTransactions: serializedTxs,
50
+ encodedTransactions: txs.map((x) => Buffer.from(x.serialize()).toString("base64")),
66
51
  },
67
52
  {
68
53
  encoding: "base64",
@@ -202,9 +187,8 @@ async function sendJitoBundledTransactions(umi, connection, userSigner, otherSig
202
187
  (0, generalUtils_1.consoleLog)("Sending Jito bundle...");
203
188
  (0, generalUtils_1.consoleLog)("Transactions: ", txs.length);
204
189
  (0, generalUtils_1.consoleLog)(txs.map((tx) => tx.getInstructions().map((x) => x.programId.toString())));
205
- (0, generalUtils_1.consoleLog)("Transaction sizes (before tip): ", txs.map((x) => x.getTransactionSize(umi)));
190
+ (0, generalUtils_1.consoleLog)("Transaction sizes: ", txs.map((x) => x.getTransactionSize(umi)));
206
191
  txs[0] = (0, solanaUtils_1.prependTx)(txs[0], [getTipInstruction(userSigner, 250000)]);
207
- (0, generalUtils_1.consoleLog)("Transaction sizes (after tip): ", txs.map((x) => x.getTransactionSize(umi)));
208
192
  const latestBlockhash = (await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await umi.rpc.getLatestBlockhash({ commitment: "confirmed" }))).blockhash;
209
193
  if (abortController?.signal.aborted) {
210
194
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAgB9E,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,SAAS,EACrB,KAAK,CAAC,EAAE,UAAU,GACjB,CAAC,UAAU,EAAE,GAAG,CAAC,CAWnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,kBAAkB,CAOpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAOpB;AAED,wBA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AI,EAC3B,eAAe,CAAC,EAAE,eAAe,GAChC,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAoEjC"}
@@ -114,7 +114,6 @@ function prependTx(tx, txsToAdd) {
114
114
  const [beforeKeccak, afterKeccak] = tx.splitByIndex(keccakIdx + 1);
115
115
  // IMPORTANT: Preserve lookup tables from original transaction
116
116
  const lookupTables = tx.options.addressLookupTables ?? [];
117
- (0, generalUtils_1.consoleLog)(`[prependTx] Keccak branch - preserving ${lookupTables.length} lookup tables`);
118
117
  let finalTx = (0, umi_1.transactionBuilder)()
119
118
  .setAddressLookupTables(lookupTables)
120
119
  .add(beforeKeccak);
@@ -147,12 +146,10 @@ function getActualTxSize(umi, tx) {
147
146
  const web3Tx = (0, umi_web3js_adapters_1.toWeb3JsTransaction)(builtTx);
148
147
  // Actually serialize to get the real size
149
148
  const serialized = web3Tx.serialize();
150
- (0, generalUtils_1.consoleLog)("[getActualTxSize] Serialization successful, size:", serialized.length);
151
149
  return serialized.length;
152
150
  }
153
151
  catch (e) {
154
152
  // Serialization failed - transaction is too large or malformed
155
- (0, generalUtils_1.consoleLog)("[getActualTxSize] Serialization FAILED:", e?.message || e);
156
153
  return undefined;
157
154
  }
158
155
  }
@@ -161,19 +158,13 @@ function getActualTxSize(umi, tx) {
161
158
  * More accurate than getTransactionSize() estimation.
162
159
  */
163
160
  function canSerializeTransaction(umi, tx, buffer = 0) {
164
- (0, generalUtils_1.consoleLog)("[canSerializeTransaction] Checking with buffer:", buffer);
165
161
  const size = getActualTxSize(umi, tx);
166
162
  if (size === undefined) {
167
- (0, generalUtils_1.consoleLog)("[canSerializeTransaction] Failed - size undefined");
168
163
  return false;
169
164
  }
170
- const fits = size + buffer <= MAX_TX_SIZE;
171
- (0, generalUtils_1.consoleLog)(`[canSerializeTransaction] Size: ${size}, buffer: ${buffer}, max: ${MAX_TX_SIZE}, fits: ${fits}`);
172
- return fits;
165
+ return size + buffer <= MAX_TX_SIZE;
173
166
  }
174
167
  function addTxOptimizations(umi, tx, computeUnitPrice, computeUnitLimit) {
175
- (0, generalUtils_1.consoleLog)(`[addTxOptimizations] Called with price=${computeUnitPrice}, limit=${computeUnitLimit}`);
176
- (0, generalUtils_1.consoleLog)(`[addTxOptimizations] Input tx estimated size: ${tx.getTransactionSize(umi)}`);
177
168
  const computePriceIx = computeUnitPrice !== undefined
178
169
  ? setComputeUnitPriceUmiIx(umi.identity, computeUnitPrice)
179
170
  : (0, umi_1.transactionBuilder)();
@@ -183,31 +174,22 @@ function addTxOptimizations(umi, tx, computeUnitPrice, computeUnitLimit) {
183
174
  const allOptimizations = tx.prepend(computePriceIx).prepend(computeLimitIx);
184
175
  const withCuPrice = tx.prepend(computePriceIx);
185
176
  const withCuLimit = tx.prepend(computeLimitIx);
186
- (0, generalUtils_1.consoleLog)("[addTxOptimizations] Checking if all optimizations fit...");
187
177
  // Use actual serialization check instead of estimate
188
178
  if (canSerializeTransaction(umi, allOptimizations)) {
189
- (0, generalUtils_1.consoleLog)("[addTxOptimizations] All optimizations fit, adding both");
190
179
  return prependTx(tx, [computePriceIx, computeLimitIx]);
191
180
  }
192
- (0, generalUtils_1.consoleLog)("[addTxOptimizations] Checking if just CU price fits...");
193
- if (canSerializeTransaction(umi, withCuPrice)) {
194
- (0, generalUtils_1.consoleLog)("[addTxOptimizations] Only CU price fits, adding it");
181
+ else if (canSerializeTransaction(umi, withCuPrice)) {
195
182
  return prependTx(tx, [computePriceIx]);
196
183
  }
197
- (0, generalUtils_1.consoleLog)("[addTxOptimizations] Checking if just CU limit fits...");
198
- if (canSerializeTransaction(umi, withCuLimit)) {
199
- (0, generalUtils_1.consoleLog)("[addTxOptimizations] Only CU limit fits, adding it");
184
+ else if (canSerializeTransaction(umi, withCuLimit)) {
200
185
  return prependTx(tx, [computeLimitIx]);
201
186
  }
202
- (0, generalUtils_1.consoleLog)("[addTxOptimizations] Nothing fits, returning original tx");
203
- return tx;
187
+ else {
188
+ return tx;
189
+ }
204
190
  }
205
191
  function assembleFinalTransaction(umi, transaction, computeUnitPrice, computeUnitLimit) {
206
- (0, generalUtils_1.consoleLog)(`[assembleFinalTransaction] Input tx instructions: ${transaction.getInstructions().length}`);
207
- (0, generalUtils_1.consoleLog)(`[assembleFinalTransaction] Input tx estimated size: ${transaction.getTransactionSize(umi)}`);
208
192
  const tx = addTxOptimizations(umi, transaction, computeUnitPrice, computeUnitLimit);
209
- (0, generalUtils_1.consoleLog)(`[assembleFinalTransaction] After optimizations, instructions: ${tx.getInstructions().length}`);
210
- (0, generalUtils_1.consoleLog)(`[assembleFinalTransaction] After optimizations, estimated size: ${tx.getTransactionSize(umi)}`);
211
193
  const marginfiStartFlSerializer = (0, marginfi_1.getLendingAccountStartFlashloanInstructionDataSerializer)();
212
194
  const marginfiStartFlDiscriminator = marginfiStartFlSerializer
213
195
  .serialize({
@@ -241,46 +223,10 @@ function assembleFinalTransaction(umi, transaction, computeUnitPrice, computeUni
241
223
  }
242
224
  catch { }
243
225
  }
244
- (0, generalUtils_1.consoleLog)(`[assembleFinalTransaction] Final tx estimated size: ${tx.getTransactionSize(umi)}`);
245
226
  return tx;
246
227
  }
247
228
  async function simulateTransaction(umi, connection, transaction) {
248
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Building transaction...");
249
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Estimated size:", transaction.getTransactionSize(umi));
250
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Instructions:", transaction.getInstructions().length);
251
- let builtTx;
252
- try {
253
- builtTx = transaction.build(umi);
254
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Built UMI transaction successfully");
255
- }
256
- catch (e) {
257
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Failed to build UMI transaction:", e);
258
- throw e;
259
- }
260
- let web3Tx;
261
- try {
262
- web3Tx = (0, umi_web3js_adapters_1.toWeb3JsTransaction)(builtTx);
263
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Converted to web3.js transaction");
264
- }
265
- catch (e) {
266
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Failed to convert to web3.js:", e);
267
- throw e;
268
- }
269
- // Try to serialize before simulation to catch the error with better context
270
- try {
271
- const serialized = web3Tx.serialize();
272
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Pre-serialization successful, size:", serialized.length);
273
- }
274
- catch (e) {
275
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Pre-serialization FAILED:", e);
276
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Message accounts:", web3Tx.message.staticAccountKeys.length);
277
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Message instructions:", web3Tx.message.compiledInstructions.length);
278
- if ("addressTableLookups" in web3Tx.message) {
279
- (0, generalUtils_1.consoleLog)("[simulateTransaction] Address table lookups:", web3Tx.message.addressTableLookups?.length ?? 0);
280
- }
281
- throw new Error(`Transaction serialization failed before simulation: ${e.message || e}`);
282
- }
283
- const simulationResult = await connection.simulateTransaction(web3Tx, {
229
+ const simulationResult = await connection.simulateTransaction((0, umi_web3js_adapters_1.toWeb3JsTransaction)(transaction.build(umi)), {
284
230
  sigVerify: false,
285
231
  commitment: "confirmed",
286
232
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.818",
3
+ "version": "1.0.819",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -72,29 +72,12 @@ function parseJitoErrorMessage(message: string) {
72
72
  }
73
73
 
74
74
  async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
75
- // Pre-serialize transactions to catch size errors before simulation
76
- const serializedTxs: string[] = [];
77
- for (let i = 0; i < txs.length; i++) {
78
- try {
79
- const serialized = txs[i].serialize();
80
- if (serialized.length > 1232) {
81
- throw new Error(
82
- `Transaction ${i} is too large: ${serialized.length} bytes (max: 1232)`
83
- );
84
- }
85
- serializedTxs.push(Buffer.from(serialized).toString("base64"));
86
- } catch (e: any) {
87
- consoleLog(`Failed to serialize transaction ${i}:`, e);
88
- throw new Error(
89
- `Failed to serialize transaction ${i}: ${e.message || e}`
90
- );
91
- }
92
- }
93
-
94
75
  const simulationResult = await retryWithExponentialBackoff(async () => {
95
76
  const res = await customRpcCall(umi, "simulateBundle", [
96
77
  {
97
- encodedTransactions: serializedTxs,
78
+ encodedTransactions: txs.map((x) =>
79
+ Buffer.from(x.serialize()).toString("base64")
80
+ ),
98
81
  },
99
82
  {
100
83
  encoding: "base64",
@@ -315,17 +298,12 @@ export async function sendJitoBundledTransactions(
315
298
  txs.map((tx) => tx.getInstructions().map((x) => x.programId.toString()))
316
299
  );
317
300
  consoleLog(
318
- "Transaction sizes (before tip): ",
301
+ "Transaction sizes: ",
319
302
  txs.map((x) => x.getTransactionSize(umi))
320
303
  );
321
304
 
322
305
  txs[0] = prependTx(txs[0], [getTipInstruction(userSigner, 250_000)]);
323
306
 
324
- consoleLog(
325
- "Transaction sizes (after tip): ",
326
- txs.map((x) => x.getTransactionSize(umi))
327
- );
328
-
329
307
  const latestBlockhash = (
330
308
  await retryWithExponentialBackoff(
331
309
  async () => await umi.rpc.getLatestBlockhash({ commitment: "confirmed" })
@@ -222,9 +222,6 @@ export function prependTx(
222
222
  const [beforeKeccak, afterKeccak] = tx.splitByIndex(keccakIdx + 1);
223
223
  // IMPORTANT: Preserve lookup tables from original transaction
224
224
  const lookupTables = tx.options.addressLookupTables ?? [];
225
- consoleLog(
226
- `[prependTx] Keccak branch - preserving ${lookupTables.length} lookup tables`
227
- );
228
225
  let finalTx = transactionBuilder()
229
226
  .setAddressLookupTables(lookupTables)
230
227
  .add(beforeKeccak);
@@ -262,11 +259,9 @@ export function getActualTxSize(
262
259
  const web3Tx = toWeb3JsTransaction(builtTx);
263
260
  // Actually serialize to get the real size
264
261
  const serialized = web3Tx.serialize();
265
- consoleLog("[getActualTxSize] Serialization successful, size:", serialized.length);
266
262
  return serialized.length;
267
- } catch (e: any) {
263
+ } catch (e) {
268
264
  // Serialization failed - transaction is too large or malformed
269
- consoleLog("[getActualTxSize] Serialization FAILED:", e?.message || e);
270
265
  return undefined;
271
266
  }
272
267
  }
@@ -280,17 +275,11 @@ export function canSerializeTransaction(
280
275
  tx: TransactionBuilder,
281
276
  buffer: number = 0
282
277
  ): boolean {
283
- consoleLog("[canSerializeTransaction] Checking with buffer:", buffer);
284
278
  const size = getActualTxSize(umi, tx);
285
279
  if (size === undefined) {
286
- consoleLog("[canSerializeTransaction] Failed - size undefined");
287
280
  return false;
288
281
  }
289
- const fits = size + buffer <= MAX_TX_SIZE;
290
- consoleLog(
291
- `[canSerializeTransaction] Size: ${size}, buffer: ${buffer}, max: ${MAX_TX_SIZE}, fits: ${fits}`
292
- );
293
- return fits;
282
+ return size + buffer <= MAX_TX_SIZE;
294
283
  }
295
284
 
296
285
  export function addTxOptimizations(
@@ -299,13 +288,6 @@ export function addTxOptimizations(
299
288
  computeUnitPrice?: number,
300
289
  computeUnitLimit?: number
301
290
  ) {
302
- consoleLog(
303
- `[addTxOptimizations] Called with price=${computeUnitPrice}, limit=${computeUnitLimit}`
304
- );
305
- consoleLog(
306
- `[addTxOptimizations] Input tx estimated size: ${tx.getTransactionSize(umi)}`
307
- );
308
-
309
291
  const computePriceIx =
310
292
  computeUnitPrice !== undefined
311
293
  ? setComputeUnitPriceUmiIx(umi.identity, computeUnitPrice)
@@ -318,24 +300,16 @@ export function addTxOptimizations(
318
300
  const withCuPrice = tx.prepend(computePriceIx);
319
301
  const withCuLimit = tx.prepend(computeLimitIx);
320
302
 
321
- consoleLog("[addTxOptimizations] Checking if all optimizations fit...");
322
303
  // Use actual serialization check instead of estimate
323
304
  if (canSerializeTransaction(umi, allOptimizations)) {
324
- consoleLog("[addTxOptimizations] All optimizations fit, adding both");
325
305
  return prependTx(tx, [computePriceIx, computeLimitIx]);
326
- }
327
- consoleLog("[addTxOptimizations] Checking if just CU price fits...");
328
- if (canSerializeTransaction(umi, withCuPrice)) {
329
- consoleLog("[addTxOptimizations] Only CU price fits, adding it");
306
+ } else if (canSerializeTransaction(umi, withCuPrice)) {
330
307
  return prependTx(tx, [computePriceIx]);
331
- }
332
- consoleLog("[addTxOptimizations] Checking if just CU limit fits...");
333
- if (canSerializeTransaction(umi, withCuLimit)) {
334
- consoleLog("[addTxOptimizations] Only CU limit fits, adding it");
308
+ } else if (canSerializeTransaction(umi, withCuLimit)) {
335
309
  return prependTx(tx, [computeLimitIx]);
310
+ } else {
311
+ return tx;
336
312
  }
337
- consoleLog("[addTxOptimizations] Nothing fits, returning original tx");
338
- return tx;
339
313
  }
340
314
 
341
315
  export function assembleFinalTransaction(
@@ -344,13 +318,6 @@ export function assembleFinalTransaction(
344
318
  computeUnitPrice?: number,
345
319
  computeUnitLimit?: number
346
320
  ) {
347
- consoleLog(
348
- `[assembleFinalTransaction] Input tx instructions: ${transaction.getInstructions().length}`
349
- );
350
- consoleLog(
351
- `[assembleFinalTransaction] Input tx estimated size: ${transaction.getTransactionSize(umi)}`
352
- );
353
-
354
321
  const tx = addTxOptimizations(
355
322
  umi,
356
323
  transaction,
@@ -358,13 +325,6 @@ export function assembleFinalTransaction(
358
325
  computeUnitLimit
359
326
  );
360
327
 
361
- consoleLog(
362
- `[assembleFinalTransaction] After optimizations, instructions: ${tx.getInstructions().length}`
363
- );
364
- consoleLog(
365
- `[assembleFinalTransaction] After optimizations, estimated size: ${tx.getTransactionSize(umi)}`
366
- );
367
-
368
328
  const marginfiStartFlSerializer =
369
329
  getLendingAccountStartFlashloanInstructionDataSerializer();
370
330
  const marginfiStartFlDiscriminator = marginfiStartFlSerializer
@@ -414,9 +374,6 @@ export function assembleFinalTransaction(
414
374
  } catch {}
415
375
  }
416
376
 
417
- consoleLog(
418
- `[assembleFinalTransaction] Final tx estimated size: ${tx.getTransactionSize(umi)}`
419
- );
420
377
  return tx;
421
378
  }
422
379
 
@@ -425,66 +382,13 @@ async function simulateTransaction(
425
382
  connection: Connection,
426
383
  transaction: TransactionBuilder
427
384
  ): Promise<RpcResponseAndContext<SimulatedTransactionResponse>> {
428
- consoleLog("[simulateTransaction] Building transaction...");
429
- consoleLog(
430
- "[simulateTransaction] Estimated size:",
431
- transaction.getTransactionSize(umi)
432
- );
433
- consoleLog(
434
- "[simulateTransaction] Instructions:",
435
- transaction.getInstructions().length
436
- );
437
-
438
- let builtTx;
439
- try {
440
- builtTx = transaction.build(umi);
441
- consoleLog("[simulateTransaction] Built UMI transaction successfully");
442
- } catch (e: any) {
443
- consoleLog("[simulateTransaction] Failed to build UMI transaction:", e);
444
- throw e;
445
- }
446
-
447
- let web3Tx;
448
- try {
449
- web3Tx = toWeb3JsTransaction(builtTx);
450
- consoleLog("[simulateTransaction] Converted to web3.js transaction");
451
- } catch (e: any) {
452
- consoleLog("[simulateTransaction] Failed to convert to web3.js:", e);
453
- throw e;
454
- }
455
-
456
- // Try to serialize before simulation to catch the error with better context
457
- try {
458
- const serialized = web3Tx.serialize();
459
- consoleLog(
460
- "[simulateTransaction] Pre-serialization successful, size:",
461
- serialized.length
462
- );
463
- } catch (e: any) {
464
- consoleLog("[simulateTransaction] Pre-serialization FAILED:", e);
465
- consoleLog(
466
- "[simulateTransaction] Message accounts:",
467
- web3Tx.message.staticAccountKeys.length
468
- );
469
- consoleLog(
470
- "[simulateTransaction] Message instructions:",
471
- web3Tx.message.compiledInstructions.length
472
- );
473
- if ("addressTableLookups" in web3Tx.message) {
474
- consoleLog(
475
- "[simulateTransaction] Address table lookups:",
476
- (web3Tx.message as any).addressTableLookups?.length ?? 0
477
- );
385
+ const simulationResult = await connection.simulateTransaction(
386
+ toWeb3JsTransaction(transaction.build(umi)),
387
+ {
388
+ sigVerify: false,
389
+ commitment: "confirmed",
478
390
  }
479
- throw new Error(
480
- `Transaction serialization failed before simulation: ${e.message || e}`
481
- );
482
- }
483
-
484
- const simulationResult = await connection.simulateTransaction(web3Tx, {
485
- sigVerify: false,
486
- commitment: "confirmed",
487
- });
391
+ );
488
392
  if (simulationResult.value.err) {
489
393
  simulationResult.value.logs?.forEach((x: any) => {
490
394
  consoleLog(x);