Skip to content

Commit

Permalink
Merge pull request #419 from poanetwork/vb-rsk-gas-price-margin
Browse files Browse the repository at this point in the history
Add 10% margin for gas price in case of RSK chains
  • Loading branch information
vbaranov committed Oct 27, 2020
2 parents dec0b2f + 08f36f8 commit 7862f8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/app/controllers/metamask-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit 7862f8b

Please sign in to comment.