From aec24ec81e4785ceea93375d562458f62be69266 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 5 Jan 2018 22:08:03 -0800 Subject: Fix feature to work --- app/scripts/controllers/transactions.js | 3 ++- app/scripts/metamask-controller.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index be7e7221f..469deb670 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -180,7 +180,8 @@ module.exports = class TransactionController extends EventEmitter { // ensure value txMeta.gasPriceSpecified = Boolean(txParams.gasPrice) txMeta.nonceSpecified = Boolean(txParams.nonce) - const gasPrice = txParams.gasPrice || this.getGasPrice() + const gasPrice = txParams.gasPrice || this.getGasPrice ? this.getGasPrice() + : await this.query.gasPrice() txParams.gasPrice = ethUtil.addHexPrefix(gasPrice.toString(16)) txParams.value = txParams.value || '0x0' // set gasLimit diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 79ad2ff05..1b13f6567 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -491,13 +491,20 @@ module.exports = class MetamaskController extends EventEmitter { const { recentBlocksController } = this const { recentBlocks } = recentBlocksController.store.getState() const lowestPrices = recentBlocks.map((block) => { - return block.transactions + if (!block.gasPrices) { + return new BN(0) + } + return block.gasPrices + .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()) - return percentile(50, lowestPrices) + const percentileNum = percentile(50, lowestPrices) + const percentileNumBn = new BN(percentileNum) + return '0x' + percentileNumBn.mul(GWEI_BN).toString(16) } // -- cgit