Merge pull request #399 from poanetwork/vb-10gwei
Gas price adjustments
This commit is contained in:
commit
045fed4a30
|
@ -2,6 +2,8 @@
|
|||
|
||||
## Current Master
|
||||
|
||||
- [#399](https://github.com/poanetwork/nifty-wallet/pull/399) - (Chore) Set 10 Gwei gas price for POA and Sokol chains
|
||||
- [#399](https://github.com/poanetwork/nifty-wallet/pull/399) - (Fix) Fix 0 gas price when on POA, Sokol, xDai chains when confirmation popup is called from dApp
|
||||
- [#398](https://github.com/poanetwork/nifty-wallet/pull/398) - (Chore) New RSK testnet default tokens
|
||||
- [#398](https://github.com/poanetwork/nifty-wallet/pull/398) - (Fix) Etherscan link for Ethereum Mainnet
|
||||
- [#398](https://github.com/poanetwork/nifty-wallet/pull/398) - (Chrore) Update NPM deps to fix known vulnerabilities
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -16,6 +16,7 @@ const {
|
|||
ifRSK,
|
||||
ifRSKByProviderType,
|
||||
ifPOA,
|
||||
ifXDai,
|
||||
toChecksumAddress,
|
||||
isValidChecksumAddress,
|
||||
isInfuraProvider,
|
||||
|
@ -359,12 +360,19 @@ describe('normalizing values', function () {
|
|||
it('checks if this is POA chain', function () {
|
||||
assert(ifPOA(77))
|
||||
assert(ifPOA(99))
|
||||
assert(ifPOA(100))
|
||||
assert(!ifPOA(1))
|
||||
assert(!ifPOA())
|
||||
})
|
||||
})
|
||||
|
||||
describe('#ifXDai', function () {
|
||||
it('checks if this is xDai chain', function () {
|
||||
assert(ifXDai(100))
|
||||
assert(!ifXDai(1))
|
||||
assert(!ifXDai())
|
||||
})
|
||||
})
|
||||
|
||||
const addr = '0xB707b030A7887a21cc595Cd139746A8c2Ed91615'
|
||||
const addrRSKMainnet = '0xB707b030A7887a21Cc595cD139746A8c2ED91615'
|
||||
const addrRSKTestnet = '0xB707b030a7887a21Cc595CD139746a8C2ED91615'
|
||||
|
|
Loading…
Reference in New Issue