aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2018-01-09 07:41:57 +0800
committerDan Finlay <dan@danfinlay.com>2018-01-09 07:41:57 +0800
commitd829fb91b889f35a3e1043dec56d8f0ff6faa09d (patch)
tree7678856de7f420591f0dc70ca087a8c8ebe47645
parent943befef91cd725579c4bf4e7024734f02ef98f5 (diff)
downloadtangerine-wallet-browser-d829fb91b889f35a3e1043dec56d8f0ff6faa09d.tar
tangerine-wallet-browser-d829fb91b889f35a3e1043dec56d8f0ff6faa09d.tar.gz
tangerine-wallet-browser-d829fb91b889f35a3e1043dec56d8f0ff6faa09d.tar.bz2
tangerine-wallet-browser-d829fb91b889f35a3e1043dec56d8f0ff6faa09d.tar.lz
tangerine-wallet-browser-d829fb91b889f35a3e1043dec56d8f0ff6faa09d.tar.xz
tangerine-wallet-browser-d829fb91b889f35a3e1043dec56d8f0ff6faa09d.tar.zst
tangerine-wallet-browser-d829fb91b889f35a3e1043dec56d8f0ff6faa09d.zip
Default to 1 gwei for empty blocks
-rw-r--r--app/scripts/metamask-controller.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 9462af494..f62b5e5cd 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -497,8 +497,8 @@ module.exports = class MetamaskController extends EventEmitter {
}
const lowestPrices = recentBlocks.map((block) => {
- if (!block.gasPrices) {
- return new BN(0)
+ if (!block.gasPrices || block.gasPrices.length < 1) {
+ return GWEI_BN
}
return block.gasPrices
.map(hexPrefix => hexPrefix.substr(2))
@@ -508,6 +508,7 @@ module.exports = class MetamaskController extends EventEmitter {
})[0]
})
.map(number => number.div(GWEI_BN).toNumber())
+
const percentileNum = percentile(50, lowestPrices)
const percentileNumBn = new BN(percentileNum)
return '0x' + percentileNumBn.mul(GWEI_BN).toString(16)