From 7bcbb76956f85aabab336771d8139e73b1d62867 Mon Sep 17 00:00:00 2001 From: Luke Steyn Date: Tue, 15 Jul 2025 15:42:49 +0800 Subject: [PATCH 1/2] Updated compute unit price logic so that they get included to transaction even when set to zero. --- sdk/src/tx/txHandler.ts | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/sdk/src/tx/txHandler.ts b/sdk/src/tx/txHandler.ts index 09471867e8..9378fda899 100644 --- a/sdk/src/tx/txHandler.ts +++ b/sdk/src/tx/txHandler.ts @@ -42,9 +42,6 @@ import { DEFAULT_CONFIRMATION_OPTS } from '../config'; * When the whileValidTxSender waits for confirmation of a given transaction, it needs the last available blockheight and blockhash used in the signature to do so. For pre-signed transactions, these values aren't attached to the transaction object by default. For a "scrappy" workaround which doesn't break backwards compatibility, the SIGNATURE_BLOCK_AND_EXPIRY property is simply attached to the transaction objects as they are created or signed in this handler despite a mismatch in the typescript types. If the values are attached to the transaction when they reach the whileValidTxSender, it can opt-in to use these values. */ -const DEV_TRY_FORCE_TX_TIMEOUTS = - process.env.DEV_TRY_FORCE_TX_TIMEOUTS === 'true' || false; - export const COMPUTE_UNITS_DEFAULT = 200_000; const BLOCKHASH_FETCH_RETRY_COUNT = 3; @@ -554,13 +551,7 @@ export class TxHandler { const computeUnitsPrice = baseTxParams?.computeUnitsPrice; - if (DEV_TRY_FORCE_TX_TIMEOUTS) { - allIx.push( - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: 0, - }) - ); - } else if (computeUnitsPrice > 0 && !hasSetComputeUnitPriceIx) { + if (typeof computeUnitsPrice === 'number' && computeUnitsPrice != null && !hasSetComputeUnitPriceIx) { allIx.push( ComputeBudgetProgram.setComputeUnitPrice({ microLamports: computeUnitsPrice, @@ -603,13 +594,7 @@ export class TxHandler { ); } - if (DEV_TRY_FORCE_TX_TIMEOUTS) { - tx.add( - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: 0, - }) - ); - } else if (computeUnitsPrice != 0) { + if (typeof computeUnitsPrice === 'number' && computeUnitsPrice != null) { tx.add( ComputeBudgetProgram.setComputeUnitPrice({ microLamports: computeUnitsPrice, From 55437fcef7d4eacac7f42d40cfc2aafb384ed313 Mon Sep 17 00:00:00 2001 From: Luke Steyn Date: Tue, 15 Jul 2025 16:09:28 +0800 Subject: [PATCH 2/2] prettier --- sdk/src/tx/txHandler.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/src/tx/txHandler.ts b/sdk/src/tx/txHandler.ts index 9378fda899..0f974ccea5 100644 --- a/sdk/src/tx/txHandler.ts +++ b/sdk/src/tx/txHandler.ts @@ -551,7 +551,11 @@ export class TxHandler { const computeUnitsPrice = baseTxParams?.computeUnitsPrice; - if (typeof computeUnitsPrice === 'number' && computeUnitsPrice != null && !hasSetComputeUnitPriceIx) { + if ( + typeof computeUnitsPrice === 'number' && + computeUnitsPrice != null && + !hasSetComputeUnitPriceIx + ) { allIx.push( ComputeBudgetProgram.setComputeUnitPrice({ microLamports: computeUnitsPrice,