From b1f3e7fb73485f1cb5d461966ef2176655b56c38 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 10 Jul 2020 15:07:15 +0300 Subject: [PATCH] 10 gWei --- app/scripts/controllers/transactions/index.js | 2 +- app/scripts/metamask-controller.js | 13 ++++++++++--- old-ui/app/util.js | 9 ++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index c91e41ea0..313505102 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -212,7 +212,7 @@ class TransactionController extends EventEmitter { txParams.value = txParams.value ? ethUtil.addHexPrefix(txParams.value) : '0x0' txMeta.gasPriceSpecified = Boolean(txParams.gasPrice) let gasPrice = txParams.gasPrice - if (!gasPrice) { + if (!gasPrice || gasPrice === '0x0') { gasPrice = this.getGasPrice ? await this.getGasPrice() : await this.query.gasPrice() } txParams.gasPrice = ethUtil.addHexPrefix(gasPrice.toString(16)) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 9704b230f..225a92660 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -51,6 +51,7 @@ import selectChainId from './lib/select-chain-id' const version = require('../manifest.json').version import ethUtil, { BN } from 'ethereumjs-util' const GWEI_BN = new BN('1000000000') +const GWEI_10_BN = new BN('10000000000') import percentile from 'percentile' import seedPhraseVerifier from './lib/seed-phrase-verifier' import log from 'loglevel' @@ -60,7 +61,7 @@ import EthQuery from 'eth-query' import nanoid from 'nanoid' const { importTypes } = require('../../old-ui/app/accounts/import/enums') const { LEDGER, TREZOR } = require('../../old-ui/app/components/connect-hardware/enum') -const { ifPOA, ifRSK, getNetworkID, getDPath, setDPath } = require('../../old-ui/app/util') +const { ifPOA, ifXDai, ifRSK, getNetworkID, getDPath, setDPath } = require('../../old-ui/app/util') const { GasPriceOracle } = require('gas-price-oracle') import { @@ -1914,9 +1915,15 @@ module.exports = class MetamaskController extends EventEmitter { const { recentBlocksController } = this const { recentBlocks } = recentBlocksController.store.getState() const isPOA = ifPOA(networkId) + const isXDai = ifXDai(networkId) - // Return 1 gwei if using a POA network or if there are no blocks have been observed: - if (isPOA || recentBlocks.length === 0) { + // Return 10 gwei if using a POA, Sokol + if (isPOA) { + return '0x' + GWEI_10_BN.toString(16) + } + + // Return 1 gwei if xDai or there are no blocks have been observed: + if (isXDai || recentBlocks.length === 0) { return '0x' + GWEI_BN.toString(16) } diff --git a/old-ui/app/util.js b/old-ui/app/util.js index 9514262f5..e916e54bc 100644 --- a/old-ui/app/util.js +++ b/old-ui/app/util.js @@ -92,6 +92,7 @@ module.exports = { ifETC, ifRSKByProviderType, ifPOA, + ifXDai, toChecksumAddress, isValidChecksumAddress, isInfuraProvider, @@ -452,7 +453,13 @@ function ifRSKByProviderType (type) { function ifPOA (network) { if (!network) return false const numericNet = isNaN(network) ? network : parseInt(network) - return numericNet === POA_SOKOL_CODE || numericNet === POA_CODE || numericNet === DAI_CODE + return numericNet === POA_SOKOL_CODE || numericNet === POA_CODE +} + +function ifXDai (network) { + if (!network) return false + const numericNet = isNaN(network) ? network : parseInt(network) + return numericNet === DAI_CODE } function toChecksumAddressRSK (address, chainId = null) {