From 89bda8cbd40231f03e5635af42efc9a669773c3f Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 6 Aug 2021 18:02:07 +0530 Subject: [PATCH 1/3] fix max txfee calculation --- apps/remix-ide/src/app/ui/confirmDialog.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/ui/confirmDialog.js b/apps/remix-ide/src/app/ui/confirmDialog.js index d4b41838f1..a747134af4 100644 --- a/apps/remix-ide/src/app/ui/confirmDialog.js +++ b/apps/remix-ide/src/app/ui/confirmDialog.js @@ -1,6 +1,7 @@ var yo = require('yo-yo') var csjs = require('csjs-inject') const copyToClipboard = require('./copy-to-clipboard') +const Web3 = require('web3') var css = csjs` .txInfoBox { @@ -28,7 +29,7 @@ function confirmDialog (tx, network, amount, gasEstimation, newGasPriceCb, initi var maxFee = el.querySelector('#maxfee').value var confirmBtn = document.querySelector('#modal-footer-ok') var maxPriorityFee = el.querySelector('#maxpriorityfee').value - if (parseInt(network.lastBlock.baseFeePerGas, 16) > parseInt(maxFee)) { + if (Web3.utils.fromWei(Web3.utils.toBN(parseInt(network.lastBlock.baseFeePerGas, 16)), 'Gwei') > parseInt(maxFee)) { el.querySelector('#txfee').innerHTML = 'Transaction is invalid. Max fee should not be less than Base fee' el.gasPriceStatus = false confirmBtn.hidden = true @@ -91,7 +92,7 @@ function confirmDialog (tx, network, amount, gasEstimation, newGasPriceCb, initi
- Max fee (Not less than base fee - ${parseInt(network.lastBlock.baseFeePerGas, 16)} Gwei): + Max fee (Not less than base fee - ${Web3.utils.fromWei(Web3.utils.toBN(parseInt(network.lastBlock.baseFeePerGas, 16)), 'Gwei')} Gwei): Gwei @@ -124,7 +125,7 @@ function confirmDialog (tx, network, amount, gasEstimation, newGasPriceCb, initi onGasPriceChange() } if (el.querySelector('#maxfee') && network && network.lastBlock && network.lastBlock.baseFeePerGas) { - el.querySelector('#maxfee').value = parseInt(network.lastBlock.baseFeePerGas, 16) + el.querySelector('#maxfee').value = Web3.utils.fromWei(Web3.utils.toBN(parseInt(network.lastBlock.baseFeePerGas, 16)), 'Gwei') onMaxFeeChange() } if (gasPriceStatus !== undefined) { From 0d0254781b20516ae9f57e3f009606c25dad938a Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 6 Aug 2021 18:18:58 +0530 Subject: [PATCH 2/3] improve comparison --- apps/remix-ide/src/app/ui/confirmDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/ui/confirmDialog.js b/apps/remix-ide/src/app/ui/confirmDialog.js index a747134af4..515d5db59b 100644 --- a/apps/remix-ide/src/app/ui/confirmDialog.js +++ b/apps/remix-ide/src/app/ui/confirmDialog.js @@ -29,7 +29,7 @@ function confirmDialog (tx, network, amount, gasEstimation, newGasPriceCb, initi var maxFee = el.querySelector('#maxfee').value var confirmBtn = document.querySelector('#modal-footer-ok') var maxPriorityFee = el.querySelector('#maxpriorityfee').value - if (Web3.utils.fromWei(Web3.utils.toBN(parseInt(network.lastBlock.baseFeePerGas, 16)), 'Gwei') > parseInt(maxFee)) { + if (parseInt(network.lastBlock.baseFeePerGas, 16) > Web3.utils.toWei(maxFee, 'Gwei')) { el.querySelector('#txfee').innerHTML = 'Transaction is invalid. Max fee should not be less than Base fee' el.gasPriceStatus = false confirmBtn.hidden = true From 19a7f5bdea30cdb771756171d04464b7ff03f746 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 6 Aug 2021 18:30:57 +0530 Subject: [PATCH 3/3] suggested change --- apps/remix-ide/src/app/ui/confirmDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/ui/confirmDialog.js b/apps/remix-ide/src/app/ui/confirmDialog.js index 515d5db59b..8db7cf9f05 100644 --- a/apps/remix-ide/src/app/ui/confirmDialog.js +++ b/apps/remix-ide/src/app/ui/confirmDialog.js @@ -92,7 +92,7 @@ function confirmDialog (tx, network, amount, gasEstimation, newGasPriceCb, initi
- Max fee (Not less than base fee - ${Web3.utils.fromWei(Web3.utils.toBN(parseInt(network.lastBlock.baseFeePerGas, 16)), 'Gwei')} Gwei): + Max fee (Not less than base fee ${Web3.utils.fromWei(Web3.utils.toBN(parseInt(network.lastBlock.baseFeePerGas, 16)), 'Gwei')} Gwei): Gwei