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:
commit
7862f8b8bf
|
@ -1961,8 +1961,12 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
|
|
||||||
const gasPrice = recentBlock && recentBlock.minimumGasPrice && recentBlock.minimumGasPrice.toString()
|
const gasPrice = recentBlock && recentBlock.minimumGasPrice && recentBlock.minimumGasPrice.toString()
|
||||||
|
|
||||||
if (gasPrice !== '0x' && gasPrice !== '0x0' && gasPrice !== '') {
|
const gasPriceInt = parseInt(gasPrice, 16)
|
||||||
return gasPrice
|
// 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 {
|
} else {
|
||||||
return '0x' + GWEI_BN.toString(16)
|
return '0x' + GWEI_BN.toString(16)
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ describe('MetaMaskController', function () {
|
||||||
metamaskController.recentBlocksController = recentBlocksController1
|
metamaskController.recentBlocksController = recentBlocksController1
|
||||||
|
|
||||||
const gasPrice = await metamaskController.getGasPrice()
|
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
|
metamaskController.recentBlocksController = realRecentBlocksController
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue