Skip to content

Commit

Permalink
Merge pull request #292 from poanetwork/fix-gas-price
Browse files Browse the repository at this point in the history
Fix gas price for RSK
  • Loading branch information
vbaranov committed Jun 12, 2019
2 parents 7576731 + 67664a3 commit 8a21664
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 12 additions & 3 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ const {
DAI_CODE,
POA_SOKOL_CODE,
CLASSIC_CODE,
MAINNET_CODE } = require('./controllers/network/enums')
MAINNET_CODE,
RSK_CODE,
RSK_TESTNET_CODE } = require('./controllers/network/enums')
const accountsPerPage = 5

module.exports = class MetamaskController extends EventEmitter {
Expand Down Expand Up @@ -1563,14 +1565,21 @@ module.exports = class MetamaskController extends EventEmitter {
if (!block.gasPrices || block.gasPrices.length < 1) {
return GWEI_BN
}
return block.gasPrices
const filteredGasPrices = block.gasPrices.filter((block) => block !== '0x00')
return filteredGasPrices
.map(hexPrefix => hexPrefix.substr(2))
.map(hex => new BN(hex, 16))
.sort((a, b) => {
return a.gt(b) ? 1 : -1
})[0]
})
.map(number => number.div(GWEI_BN).toNumber())
.map(number => number && number.div(GWEI_BN).toNumber()).filter(number => typeof number !== 'undefined' && number !== 0)

if (networkId === RSK_CODE || networkId === RSK_TESTNET_CODE) {
if (lowestPrices.length === 0) {
lowestPrices.push(1)
}
}

const percentileNum = percentile(65, lowestPrices)
const percentileNumBn = new BN(percentileNum)
Expand Down
4 changes: 1 addition & 3 deletions old-ui/app/components/transaction-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const { POA_CODE,
GOERLI_TESTNET_CODE,
CLASSIC_CODE,
RSK_CODE,
RSK_TESTNET_CODE,
} = require('../../../app/scripts/controllers/network/enums')

const mapDispatchToProps = dispatch => {
Expand Down Expand Up @@ -87,8 +86,7 @@ TransactionListItem.prototype.render = function () {
numericNet === DAI_CODE ||
numericNet === GOERLI_TESTNET_CODE ||
numericNet === CLASSIC_CODE ||
numericNet === RSK_CODE ||
numericNet === RSK_TESTNET_CODE
numericNet === RSK_CODE

var isMsg = ('msgParams' in transaction)
var isTx = ('txParams' in transaction)
Expand Down

0 comments on commit 8a21664

Please sign in to comment.