Merge pull request #419 from poanetwork/vb-rsk-gas-price-margin

Add 10% margin for gas price in case of RSK chains
This commit is contained in:
Victor Baranov 2020-10-27 15:17:01 +03:00 committed by GitHub
commit 7862f8b8bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -1961,8 +1961,12 @@ module.exports = class MetamaskController extends EventEmitter {
const gasPrice = recentBlock && recentBlock.minimumGasPrice && recentBlock.minimumGasPrice.toString()
if (gasPrice !== '0x' && gasPrice !== '0x0' && gasPrice !== '') {
return gasPrice
const gasPriceInt = parseInt(gasPrice, 16)
// https://forum.poa.network/t/gasprice-lower-than-minimumgasprice-in-rsk/4034
const gasPriceMargin = '0x' + parseInt(gasPriceInt * 1.1).toString(16)
if (!isNaN(gasPriceInt)) {
return gasPriceMargin
} else {
return '0x' + GWEI_BN.toString(16)
}

View File

@ -190,7 +190,7 @@ describe('MetaMaskController', function () {
metamaskController.recentBlocksController = recentBlocksController1
const gasPrice = await metamaskController.getGasPrice()
assert.equal(gasPrice, '0x387ee40', 'takes the min gas price from the latest block')
assert.equal(gasPrice, '0x3e252e0', 'takes the min gas price from the latest block')
metamaskController.recentBlocksController = realRecentBlocksController
})