Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/transaction-controller/src/utils/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -570,6 +572,7 @@ async function estimateGasUpgradeWithDataToSelf(
params: [
{
...txParams,
to: txParams.from,
data: '0x',
},
],
Expand Down
Loading