Skip to content

Commit f47df8f

Browse files
authored
Merge pull request #1447 from ethereum/maxfeeCal
fix max txfee calculation
2 parents 5ca8367 + ba0b8f0 commit f47df8f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apps/remix-ide/src/app/ui/confirmDialog.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var yo = require('yo-yo')
22
var csjs = require('csjs-inject')
33
const copyToClipboard = require('./copy-to-clipboard')
4+
const Web3 = require('web3')
45

56
var css = csjs`
67
.txInfoBox {
@@ -28,7 +29,7 @@ function confirmDialog (tx, network, amount, gasEstimation, newGasPriceCb, initi
2829
var maxFee = el.querySelector('#maxfee').value
2930
var confirmBtn = document.querySelector('#modal-footer-ok')
3031
var maxPriorityFee = el.querySelector('#maxpriorityfee').value
31-
if (parseInt(network.lastBlock.baseFeePerGas, 16) > parseInt(maxFee)) {
32+
if (parseInt(network.lastBlock.baseFeePerGas, 16) > Web3.utils.toWei(maxFee, 'Gwei')) {
3233
el.querySelector('#txfee').innerHTML = 'Transaction is invalid. Max fee should not be less than Base fee'
3334
el.gasPriceStatus = false
3435
confirmBtn.hidden = true
@@ -91,7 +92,7 @@ function confirmDialog (tx, network, amount, gasEstimation, newGasPriceCb, initi
9192
</div>
9293
<div class="align-items-center my-1" title="Represents the maximum amount of fee that you will pay for this transaction. The minimun needs to be set to base fee.">
9394
<div class='d-flex'>
94-
<span class="text-dark mr-2 text-nowrap">Max fee (Not less than base fee - ${parseInt(network.lastBlock.baseFeePerGas, 16)} Gwei):</span>
95+
<span class="text-dark mr-2 text-nowrap">Max fee (Not less than base fee ${Web3.utils.fromWei(Web3.utils.toBN(parseInt(network.lastBlock.baseFeePerGas, 16)), 'Gwei')} Gwei):</span>
9596
<input class="form-control mr-1 text-right" style='height: 1.2rem; width: 6rem;' id='maxfee' oninput=${onMaxFeeChange} />
9697
<span>Gwei</span>
9798
<span class="text-dark ml-2"></span>
@@ -124,7 +125,7 @@ function confirmDialog (tx, network, amount, gasEstimation, newGasPriceCb, initi
124125
onGasPriceChange()
125126
}
126127
if (el.querySelector('#maxfee') && network && network.lastBlock && network.lastBlock.baseFeePerGas) {
127-
el.querySelector('#maxfee').value = parseInt(network.lastBlock.baseFeePerGas, 16)
128+
el.querySelector('#maxfee').value = Web3.utils.fromWei(Web3.utils.toBN(parseInt(network.lastBlock.baseFeePerGas, 16)), 'Gwei')
128129
onMaxFeeChange()
129130
}
130131
if (gasPriceStatus !== undefined) {

0 commit comments

Comments
 (0)