Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Fix issue gas estimation (#1628)
Browse files Browse the repository at this point in the history
* Fix issue gas estimation

* Remove gasPrice for estimation, use all the other props

* Add comments change var

* relax linter rule for unused rest params

* Remove lint ignore since now the rule is more relaxed

Co-authored-by: Velenir <velenir@gmail.com>
  • Loading branch information
anxolin and Velenir authored Nov 18, 2020
1 parent b0fc11e commit c14dc99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'react/prop-types': [1, { skipUndeclared: true }],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
},
overrides: [
{
Expand Down
17 changes: 7 additions & 10 deletions src/api/wallet/composeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,13 @@ export const composeProvider = <T extends Provider>(
if (!txConfig) return false

if (!txConfig.gas) {
const gasLimit = await web3.eth
.estimateGas({
from: txConfig.from,
gas: txConfig.gas,
value: txConfig.value,
})
.catch((error) => {
console.error('[composeProvider] Error estimating gas, probably failing transaction', txConfig)
throw error
})
// Remove gasPrice from the estimation props, since they broke after last hardfork
// https://github.com/gnosis/dex-react/pull/1618
const { gasPrice, ...txConfigEstimation } = txConfig
const gasLimit = await web3.eth.estimateGas(txConfigEstimation).catch((error) => {
console.error('[composeProvider] Error estimating gas, probably failing transaction', txConfig)
throw error
})
logDebug('[composeProvider] No gas Limit. Using estimation ' + gasLimit)
txConfig.gas = numberToHex(gasLimit)
} else {
Expand Down

0 comments on commit c14dc99

Please sign in to comment.