From 9a8670309d2791b212d04ee795f70040cc5f40fc Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 8 Jan 2018 13:19:18 -0800 Subject: bugfix - transactions controller - breakout logic and fix order of operations bug --- app/scripts/controllers/transactions.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index 469deb670..ded9739a8 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -180,8 +180,10 @@ module.exports = class TransactionController extends EventEmitter { // ensure value txMeta.gasPriceSpecified = Boolean(txParams.gasPrice) txMeta.nonceSpecified = Boolean(txParams.nonce) - const gasPrice = txParams.gasPrice || this.getGasPrice ? this.getGasPrice() - : await this.query.gasPrice() + let gasPrice = txParams.gasPrice + if (!gasPrice) { + gasPrice = this.getGasPrice ? this.getGasPrice() : await this.query.gasPrice() + } txParams.gasPrice = ethUtil.addHexPrefix(gasPrice.toString(16)) txParams.value = txParams.value || '0x0' // set gasLimit -- cgit From 0275231e13d49a9b71b85af389d2a9850229eacb Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 8 Jan 2018 15:08:05 -0800 Subject: Default gas estimate to 1 gwei for networks with no block activity --- app/scripts/metamask-controller.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 66738db51..9462af494 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -490,6 +490,12 @@ 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) -- cgit From d829fb91b889f35a3e1043dec56d8f0ff6faa09d Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 8 Jan 2018 15:41:57 -0800 Subject: Default to 1 gwei for empty blocks --- app/scripts/metamask-controller.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app') 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) -- cgit From 330ae020287f4178b493619ede17ee0b1b67b7af Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 9 Jan 2018 10:13:25 -0800 Subject: Version 3.13.4 --- app/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/manifest.json b/app/manifest.json index d6c57d681..df7b1f1aa 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "MetaMask", "short_name": "Metamask", - "version": "3.13.3", + "version": "3.13.4", "manifest_version": 2, "author": "https://metamask.io", "description": "Ethereum Browser Extension", -- cgit