SafeTxGas calculation: Add check for openethereum/parity revert messages (#788)

* add check for openethereum/parity revert messages

* fix isEstimationSuccessful check

* fix estimation check if revert msg is from openethereum
This commit is contained in:
Mikhail Mikheev 2020-04-27 14:29:46 +04:00 committed by GitHub
parent f4cca4c416
commit 76c673ac4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -118,8 +118,15 @@ export const estimateSafeTxGas = async (
gasLimit: txGasEstimation + dataGasEstimation + additionalGas,
},
(error, res) => {
// res.data check is for OpenEthereum/Parity revert messages format
const isOpenEthereumRevertMsg = res && typeof res.data === 'string'
const isEstimationSuccessful =
!error &&
((typeof res === 'string' && res !== '0x') || (isOpenEthereumRevertMsg && res.data.slice(9) !== '0x'))
resolve({
success: error || res === '0x' ? false : true,
success: isEstimationSuccessful,
estimation: txGasEstimation + additionalGas,
})
},