(Fix) - Gas estimation for transaction creation (#1772)

* Fix gas estimation for transaction creation

* Adds missing logs

Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
This commit is contained in:
Agustin Pane 2021-01-26 18:06:39 -03:00 committed by GitHub
parent 19be231d53
commit a020e8e0dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -131,6 +131,7 @@ const calculateMinimumGasForTransaction = async (
): Promise<number> => {
for (const additionalGas of additionalGasBatches) {
const amountOfGasToTryTx = txGasEstimation + dataGasEstimation + additionalGas
console.info(`Estimating transaction creation with gas amount: ${amountOfGasToTryTx}`)
try {
await getGasEstimationTxResponse({
to: safeAddress,
@ -139,7 +140,8 @@ const calculateMinimumGasForTransaction = async (
gasPrice: 0,
gas: amountOfGasToTryTx,
})
return txGasEstimation + additionalGas
console.info(`Gas estimation successfully finished with gas amount: ${amountOfGasToTryTx}`)
return amountOfGasToTryTx
} catch (error) {
console.log(`Error trying to estimate gas with amount: ${amountOfGasToTryTx}`)
}
@ -165,8 +167,6 @@ export const estimateGasForTransactionCreation = async (
data: estimateData,
})
const txGasEstimation = gasEstimationResponse + 10000
// 21000 - additional gas costs (e.g. base tx costs, transfer costs)
const dataGasEstimation = parseRequiredTxGasResponse(estimateData) + 21000
const additionalGasBatches = [0, 10000, 20000, 40000, 80000, 160000, 320000, 640000, 1280000, 2560000, 5120000]
@ -175,7 +175,7 @@ export const estimateGasForTransactionCreation = async (
additionalGasBatches,
safeAddress,
estimateData,
txGasEstimation,
gasEstimationResponse,
dataGasEstimation,
)
} catch (error) {