mirror of
https://github.com/status-im/safe-react.git
synced 2025-02-18 12:36:34 +00:00
(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> => {
|
): Promise<number> => {
|
||||||
for (const additionalGas of additionalGasBatches) {
|
for (const additionalGas of additionalGasBatches) {
|
||||||
const amountOfGasToTryTx = txGasEstimation + dataGasEstimation + additionalGas
|
const amountOfGasToTryTx = txGasEstimation + dataGasEstimation + additionalGas
|
||||||
|
console.info(`Estimating transaction creation with gas amount: ${amountOfGasToTryTx}`)
|
||||||
try {
|
try {
|
||||||
await getGasEstimationTxResponse({
|
await getGasEstimationTxResponse({
|
||||||
to: safeAddress,
|
to: safeAddress,
|
||||||
@ -139,7 +140,8 @@ const calculateMinimumGasForTransaction = async (
|
|||||||
gasPrice: 0,
|
gasPrice: 0,
|
||||||
gas: amountOfGasToTryTx,
|
gas: amountOfGasToTryTx,
|
||||||
})
|
})
|
||||||
return txGasEstimation + additionalGas
|
console.info(`Gas estimation successfully finished with gas amount: ${amountOfGasToTryTx}`)
|
||||||
|
return amountOfGasToTryTx
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`Error trying to estimate gas with amount: ${amountOfGasToTryTx}`)
|
console.log(`Error trying to estimate gas with amount: ${amountOfGasToTryTx}`)
|
||||||
}
|
}
|
||||||
@ -165,8 +167,6 @@ export const estimateGasForTransactionCreation = async (
|
|||||||
data: estimateData,
|
data: estimateData,
|
||||||
})
|
})
|
||||||
|
|
||||||
const txGasEstimation = gasEstimationResponse + 10000
|
|
||||||
|
|
||||||
// 21000 - additional gas costs (e.g. base tx costs, transfer costs)
|
// 21000 - additional gas costs (e.g. base tx costs, transfer costs)
|
||||||
const dataGasEstimation = parseRequiredTxGasResponse(estimateData) + 21000
|
const dataGasEstimation = parseRequiredTxGasResponse(estimateData) + 21000
|
||||||
const additionalGasBatches = [0, 10000, 20000, 40000, 80000, 160000, 320000, 640000, 1280000, 2560000, 5120000]
|
const additionalGasBatches = [0, 10000, 20000, 40000, 80000, 160000, 320000, 640000, 1280000, 2560000, 5120000]
|
||||||
@ -175,7 +175,7 @@ export const estimateGasForTransactionCreation = async (
|
|||||||
additionalGasBatches,
|
additionalGasBatches,
|
||||||
safeAddress,
|
safeAddress,
|
||||||
estimateData,
|
estimateData,
|
||||||
txGasEstimation,
|
gasEstimationResponse,
|
||||||
dataGasEstimation,
|
dataGasEstimation,
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user