(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:
parent
19be231d53
commit
a020e8e0dc
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue