From b1d9d5b643418f20dcf0b5749a8add11d6a8233c Mon Sep 17 00:00:00 2001 From: Matthew Walsh Date: Wed, 15 Apr 2026 11:57:36 +0100 Subject: [PATCH] fix(transaction-controller): broaden gas estimation for type-4 transactions with non-self target Broaden isUpgradeWithData condition to support type-4 transactions where to != from (e.g. enforced simulations targeting the delegation manager). Override to=from in the upgrade-only estimation since a bare 7702 authorization upgrade is always a self-transaction. --- packages/transaction-controller/src/utils/gas.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/transaction-controller/src/utils/gas.ts b/packages/transaction-controller/src/utils/gas.ts index 0b34e406c4c..b13a5b4ca13 100644 --- a/packages/transaction-controller/src/utils/gas.ts +++ b/packages/transaction-controller/src/utils/gas.ts @@ -140,15 +140,17 @@ export async function estimateGas({ let estimatedGas = fallback; let simulationFails: TransactionMeta['simulationFails']; - const isUpgradeWithDataToSelf = + const isUpgradeWithData = txParams.type === TransactionEnvelopeType.setCode && Boolean(authorizationList?.length) && Boolean(data) && - data !== '0x' && + data !== '0x'; + + const isUpgradeWithDataToSelf = isUpgradeWithData && from?.toLowerCase() === to?.toLowerCase(); try { - if (isSimulationEnabled && isUpgradeWithDataToSelf) { + if (isSimulationEnabled && isUpgradeWithData) { estimatedGas = await estimateGasUpgradeWithDataToSelf( request, messenger, @@ -570,6 +572,7 @@ async function estimateGasUpgradeWithDataToSelf( params: [ { ...txParams, + to: txParams.from, data: '0x', }, ],