From 1ea2627154fded7b7f49f4f1db44ba23a77914c3 Mon Sep 17 00:00:00 2001 From: Borislav Itskov Date: Wed, 6 Nov 2024 18:15:41 +0200 Subject: [PATCH] fix: make estimateEOA not required when doing estimations --- src/libs/estimate/estimateEOA.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/estimate/estimateEOA.ts b/src/libs/estimate/estimateEOA.ts index 626b19f0f..a0388ceed 100644 --- a/src/libs/estimate/estimateEOA.ts +++ b/src/libs/estimate/estimateEOA.ts @@ -98,7 +98,11 @@ export async function estimateEOA( stateToOverride: getEOAEstimationStateOverride(account.addr) } ) - .catch(catchEstimationFailure) + .catch((e) => { + console.log('error calling estimateEoa:') + console.log(e) + return [[0n, [], {}]] + }) : deploylessEstimator .call('getL1GasEstimation', [encodedCallData, FEE_COLLECTOR, optimisticOracle], { from: blockFrom, @@ -120,8 +124,12 @@ export async function estimateEOA( let gasUsed = 0n if (!network.rpcNoStateOverride) { const [gasUsedEstimateGas, [[gasUsedEstimationSol, feeTokenOutcomes, l1GasEstimation]]] = result - feePaymentOptions[0].availableAmount = feeTokenOutcomes[0][1] - feePaymentOptions[0].addedNative = l1GasEstimation.fee + if (feeTokenOutcomes.length && feeTokenOutcomes[0].length) { + feePaymentOptions[0].availableAmount = feeTokenOutcomes[0][1] + } + if (l1GasEstimation && l1GasEstimation.fee) { + feePaymentOptions[0].addedNative = l1GasEstimation.fee + } // if it's a simple transfer, trust estimateGas as it should be 21K // if it's a contract call, trust whichever is higher