mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Change min gas price to 0.1 GWEI
This commit is contained in:
parent
0d8f21ad58
commit
220da24f9a
@ -2,6 +2,7 @@ const Component = require('react').Component
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
|
const ethUtil = require('ethereumjs-util')
|
||||||
const actions = require('../../actions')
|
const actions = require('../../actions')
|
||||||
const GasModalCard = require('./gas-modal-card')
|
const GasModalCard = require('./gas-modal-card')
|
||||||
|
|
||||||
@ -224,7 +225,7 @@ CustomizeGasModal.prototype.render = function () {
|
|||||||
value: convertedGasPrice,
|
value: convertedGasPrice,
|
||||||
min: MIN_GAS_PRICE_GWEI,
|
min: MIN_GAS_PRICE_GWEI,
|
||||||
// max: 1000,
|
// max: 1000,
|
||||||
step: 1,
|
step: MIN_GAS_PRICE_GWEI,
|
||||||
onChange: value => this.convertAndSetGasPrice(value),
|
onChange: value => this.convertAndSetGasPrice(value),
|
||||||
title: 'Gas Price (GWEI)',
|
title: 'Gas Price (GWEI)',
|
||||||
copy: 'We calculate the suggested gas prices based on network success rates.',
|
copy: 'We calculate the suggested gas prices based on network success rates.',
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
const Component = require('react').Component
|
const Component = require('react').Component
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const { addCurrencies } = require('../conversion-util')
|
const {
|
||||||
|
addCurrencies,
|
||||||
|
conversionGTE,
|
||||||
|
conversionLTE,
|
||||||
|
toNegative,
|
||||||
|
} = require('../conversion-util')
|
||||||
|
|
||||||
module.exports = InputNumber
|
module.exports = InputNumber
|
||||||
|
|
||||||
@ -17,8 +22,21 @@ InputNumber.prototype.setValue = function (newValue) {
|
|||||||
|
|
||||||
newValue = Number(fixed ? newValue.toFixed(4) : newValue)
|
newValue = Number(fixed ? newValue.toFixed(4) : newValue)
|
||||||
|
|
||||||
if (newValue >= min && newValue <= max) {
|
const newValueGreaterThanMin = conversionGTE(
|
||||||
|
{ value: newValue, fromNumericBase: 'dec' },
|
||||||
|
{ value: min, fromNumericBase: 'hex' },
|
||||||
|
)
|
||||||
|
|
||||||
|
const newValueLessThanMax = conversionLTE(
|
||||||
|
{ value: newValue, fromNumericBase: 'dec' },
|
||||||
|
{ value: max, fromNumericBase: 'hex' },
|
||||||
|
)
|
||||||
|
if (newValueGreaterThanMin && newValueLessThanMax) {
|
||||||
onChange(newValue)
|
onChange(newValue)
|
||||||
|
} else if (!newValueGreaterThanMin) {
|
||||||
|
onChange(min)
|
||||||
|
} else if (!newValueLessThanMax) {
|
||||||
|
onChange(max)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +47,7 @@ InputNumber.prototype.render = function () {
|
|||||||
h('input.customize-gas-input', {
|
h('input.customize-gas-input', {
|
||||||
placeholder,
|
placeholder,
|
||||||
type: 'number',
|
type: 'number',
|
||||||
value: value,
|
value,
|
||||||
onChange: (e) => this.setValue(e.target.value),
|
onChange: (e) => this.setValue(e.target.value),
|
||||||
}),
|
}),
|
||||||
h('span.gas-tooltip-input-detail', {}, [unitLabel]),
|
h('span.gas-tooltip-input-detail', {}, [unitLabel]),
|
||||||
@ -39,7 +57,7 @@ InputNumber.prototype.render = function () {
|
|||||||
}),
|
}),
|
||||||
h('i.fa.fa-angle-down', {
|
h('i.fa.fa-angle-down', {
|
||||||
style: { cursor: 'pointer' },
|
style: { cursor: 'pointer' },
|
||||||
onClick: () => this.setValue(addCurrencies(value, step * -1)),
|
onClick: () => this.setValue(addCurrencies(value, toNegative(step))),
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
@ -10,9 +10,7 @@ const BN = ethUtil.BN
|
|||||||
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
||||||
const { conversionUtil } = require('../../conversion-util')
|
const { conversionUtil } = require('../../conversion-util')
|
||||||
|
|
||||||
const MIN_GAS_PRICE_GWEI_BN = new BN(1)
|
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
||||||
const GWEI_FACTOR = new BN(1e9)
|
|
||||||
const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR)
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract)
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract)
|
||||||
@ -166,7 +164,7 @@ ConfirmDeployContract.prototype.getGasFee = function () {
|
|||||||
const gasBn = hexToBn(gas)
|
const gasBn = hexToBn(gas)
|
||||||
|
|
||||||
// Gas Price
|
// Gas Price
|
||||||
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16)
|
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_HEX
|
||||||
const gasPriceBn = hexToBn(gasPrice)
|
const gasPriceBn = hexToBn(gasPrice)
|
||||||
|
|
||||||
const txFeeBn = gasBn.mul(gasPriceBn)
|
const txFeeBn = gasBn.mul(gasPriceBn)
|
||||||
|
@ -10,9 +10,7 @@ const BN = ethUtil.BN
|
|||||||
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
|
||||||
const { conversionUtil, addCurrencies } = require('../../conversion-util')
|
const { conversionUtil, addCurrencies } = require('../../conversion-util')
|
||||||
|
|
||||||
const MIN_GAS_PRICE_GWEI_BN = new BN(1)
|
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
||||||
const GWEI_FACTOR = new BN(1e9)
|
|
||||||
const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR)
|
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmSendEther)
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmSendEther)
|
||||||
|
|
||||||
@ -93,7 +91,7 @@ ConfirmSendEther.prototype.getGasFee = function () {
|
|||||||
// const safeGasLimit = safeGasLimitBN.toString(10)
|
// const safeGasLimit = safeGasLimitBN.toString(10)
|
||||||
|
|
||||||
// Gas Price
|
// Gas Price
|
||||||
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16)
|
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_HEX
|
||||||
const gasPriceBn = hexToBn(gasPrice)
|
const gasPriceBn = hexToBn(gasPrice)
|
||||||
|
|
||||||
const txFeeBn = gasBn.mul(gasPriceBn)
|
const txFeeBn = gasBn.mul(gasPriceBn)
|
||||||
|
@ -17,9 +17,7 @@ const {
|
|||||||
addCurrencies,
|
addCurrencies,
|
||||||
} = require('../../conversion-util')
|
} = require('../../conversion-util')
|
||||||
|
|
||||||
const MIN_GAS_PRICE_GWEI_BN = new BN(1)
|
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
|
||||||
const GWEI_FACTOR = new BN(1e9)
|
|
||||||
const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR)
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getSelectedTokenExchangeRate,
|
getSelectedTokenExchangeRate,
|
||||||
@ -99,7 +97,7 @@ ConfirmSendToken.prototype.getGasFee = function () {
|
|||||||
const { decimals } = token
|
const { decimals } = token
|
||||||
|
|
||||||
const gas = txParams.gas
|
const gas = txParams.gas
|
||||||
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16)
|
const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_HEX
|
||||||
const gasTotal = multiplyCurrencies(gas, gasPrice, {
|
const gasTotal = multiplyCurrencies(gas, gasPrice, {
|
||||||
multiplicandBase: 16,
|
multiplicandBase: 16,
|
||||||
multiplierBase: 16,
|
multiplierBase: 16,
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
|
const ethUtil = require('ethereumjs-util')
|
||||||
const Identicon = require('../identicon')
|
const Identicon = require('../identicon')
|
||||||
const { multiplyCurrencies } = require('../../conversion-util')
|
const { conversionUtil, multiplyCurrencies } = require('../../conversion-util')
|
||||||
|
|
||||||
const MIN_GAS_PRICE_GWEI = '1'
|
const MIN_GAS_PRICE_HEX = (100000000).toString(16)
|
||||||
const GWEI_FACTOR = '1e9'
|
const MIN_GAS_PRICE_DEC = '100000000'
|
||||||
const MIN_GAS_PRICE_HEX = multiplyCurrencies(GWEI_FACTOR, MIN_GAS_PRICE_GWEI, {
|
|
||||||
multiplicandBase: 16,
|
|
||||||
multiplierBase: 16,
|
|
||||||
toNumericBase: 'hex',
|
|
||||||
})
|
|
||||||
const MIN_GAS_PRICE_DEC = multiplyCurrencies(GWEI_FACTOR, MIN_GAS_PRICE_GWEI, {
|
|
||||||
multiplicandBase: 16,
|
|
||||||
multiplierBase: 16,
|
|
||||||
toNumericBase: 'dec',
|
|
||||||
})
|
|
||||||
const MIN_GAS_LIMIT_HEX = (21000).toString(16)
|
const MIN_GAS_LIMIT_HEX = (21000).toString(16)
|
||||||
const MIN_GAS_LIMIT_DEC = 21000
|
const MIN_GAS_LIMIT_DEC = 21000
|
||||||
|
|
||||||
|
const MIN_GAS_PRICE_GWEI = ethUtil.addHexPrefix(conversionUtil(MIN_GAS_PRICE_HEX, {
|
||||||
|
fromDenomination: 'WEI',
|
||||||
|
toDenomination: 'GWEI',
|
||||||
|
fromNumericBase: 'hex',
|
||||||
|
toNumericBase: 'hex',
|
||||||
|
}))
|
||||||
|
|
||||||
const MIN_GAS_TOTAL = multiplyCurrencies(MIN_GAS_LIMIT_HEX, MIN_GAS_PRICE_HEX, {
|
const MIN_GAS_TOTAL = multiplyCurrencies(MIN_GAS_LIMIT_HEX, MIN_GAS_PRICE_HEX, {
|
||||||
toNumericBase: 'hex',
|
toNumericBase: 'hex',
|
||||||
multiplicandBase: 16,
|
multiplicandBase: 16,
|
||||||
|
@ -51,7 +51,7 @@ const toNormalizedDenomination = {
|
|||||||
}
|
}
|
||||||
const toSpecifiedDenomination = {
|
const toSpecifiedDenomination = {
|
||||||
WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).round(),
|
WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).round(),
|
||||||
GWEI: bigNumber => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).round(),
|
GWEI: bigNumber => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).round(1),
|
||||||
}
|
}
|
||||||
const baseChange = {
|
const baseChange = {
|
||||||
hex: n => n.toString(16),
|
hex: n => n.toString(16),
|
||||||
@ -169,9 +169,34 @@ const conversionGreaterThan = (
|
|||||||
return firstValue.gt(secondValue)
|
return firstValue.gt(secondValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const conversionGTE = (
|
||||||
|
{ ...firstProps },
|
||||||
|
{ ...secondProps },
|
||||||
|
) => {
|
||||||
|
const firstValue = converter({ ...firstProps })
|
||||||
|
const secondValue = converter({ ...secondProps })
|
||||||
|
return firstValue.greaterThanOrEqualTo(secondValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
const conversionLTE = (
|
||||||
|
{ ...firstProps },
|
||||||
|
{ ...secondProps },
|
||||||
|
) => {
|
||||||
|
const firstValue = converter({ ...firstProps })
|
||||||
|
const secondValue = converter({ ...secondProps })
|
||||||
|
return firstValue.lessThanOrEqualTo(secondValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
const toNegative = (n, options = {}) => {
|
||||||
|
return multiplyCurrencies(n, -1, options)
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
conversionUtil,
|
conversionUtil,
|
||||||
addCurrencies,
|
addCurrencies,
|
||||||
multiplyCurrencies,
|
multiplyCurrencies,
|
||||||
conversionGreaterThan,
|
conversionGreaterThan,
|
||||||
|
conversionGTE,
|
||||||
|
conversionLTE,
|
||||||
|
toNegative,
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user