aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-01-12 03:40:56 +0800
committerGitHub <noreply@github.com>2018-01-12 03:40:56 +0800
commitcf60b23eec4fc5204e15ae5efbb501d372137a02 (patch)
tree5a690fe99904930e77f138af59469aa0d7ddd44f /app/scripts
parentcc49e637dd85f1946e606634a5fc8c126c7cc04d (diff)
parentf130772956ede6c989aba347e87ee60d4f452f87 (diff)
downloadtangerine-wallet-browser-cf60b23eec4fc5204e15ae5efbb501d372137a02.tar.gz
tangerine-wallet-browser-cf60b23eec4fc5204e15ae5efbb501d372137a02.tar.zst
tangerine-wallet-browser-cf60b23eec4fc5204e15ae5efbb501d372137a02.zip
Merge branch 'master' into infura-rest-api
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/metamask-controller.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 66738db51..f62b5e5cd 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -490,9 +490,15 @@ module.exports = class MetamaskController extends EventEmitter {
getGasPrice () {
const { recentBlocksController } = this
const { recentBlocks } = recentBlocksController.store.getState()
+
+ // Return 1 gwei if no blocks have been observed:
+ if (recentBlocks.length === 0) {
+ return '0x' + GWEI_BN.toString(16)
+ }
+
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))
@@ -502,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)