Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 10% margin for gas price in case of RSK chains #419

Merged
merged 1 commit into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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