From 76c673ac4d8bc6b364a22d2d942ee001a77674e6 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Mon, 27 Apr 2020 14:29:46 +0400 Subject: [PATCH] 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 --- src/logic/safe/transactions/gasNew.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/logic/safe/transactions/gasNew.js b/src/logic/safe/transactions/gasNew.js index 15c33c17..3f34178f 100644 --- a/src/logic/safe/transactions/gasNew.js +++ b/src/logic/safe/transactions/gasNew.js @@ -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, }) },