2020-11-06 22:18:00 +01:00
|
|
|
import { addHexPrefix } from '../../../app/scripts/lib/util'
|
2018-08-16 14:28:27 +02:00
|
|
|
import {
|
|
|
|
conversionUtil,
|
2018-12-10 22:51:00 +01:00
|
|
|
conversionGreaterThan,
|
2019-03-22 00:03:30 +01:00
|
|
|
} from '../helpers/utils/conversion-util'
|
2020-11-03 00:41:28 +01:00
|
|
|
import { formatCurrency } from '../helpers/utils/confirm-tx.util'
|
|
|
|
import { decEthToConvertedCurrency as ethTotalToConvertedCurrency } from '../helpers/utils/conversions.util'
|
|
|
|
import { formatETHFee } from '../helpers/utils/formatters'
|
|
|
|
import { calcGasTotal } from '../pages/send/send.utils'
|
2018-08-16 14:28:27 +02:00
|
|
|
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
import { GAS_ESTIMATE_TYPES } from '../helpers/constants/common'
|
2020-11-03 00:41:28 +01:00
|
|
|
import { getCurrentCurrency, getIsMainnet, getPreferences } from '.'
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
|
2018-09-13 14:35:17 +02:00
|
|
|
const NUMBER_OF_DECIMALS_SM_BTNS = 5
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getCustomGasLimit(state) {
|
2018-08-16 14:28:27 +02:00
|
|
|
return state.gas.customData.limit
|
2018-08-02 18:02:22 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getCustomGasPrice(state) {
|
2018-08-16 14:28:27 +02:00
|
|
|
return state.gas.customData.price
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getBasicGasEstimateLoadingStatus(state) {
|
2018-08-16 14:28:27 +02:00
|
|
|
return state.gas.basicEstimateIsLoading
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getAveragePriceEstimateInHexWEI(state) {
|
2018-09-13 10:47:05 +02:00
|
|
|
const averagePriceEstimate = state.gas.basicEstimates.average
|
|
|
|
return getGasPriceInHexWei(averagePriceEstimate || '0x0')
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getFastPriceEstimateInHexWEI(state) {
|
2018-11-13 17:36:52 +01:00
|
|
|
const fastPriceEstimate = state.gas.basicEstimates.fast
|
2018-11-27 18:30:41 +01:00
|
|
|
return getGasPriceInHexWei(fastPriceEstimate || '0x0')
|
2018-11-13 17:36:52 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getDefaultActiveButtonIndex(
|
|
|
|
gasButtonInfo,
|
|
|
|
customGasPriceInHex,
|
|
|
|
gasPrice,
|
|
|
|
) {
|
2020-10-12 18:51:17 +02:00
|
|
|
return gasButtonInfo
|
|
|
|
.map(({ priceInHexWei }) => priceInHexWei)
|
|
|
|
.lastIndexOf(addHexPrefix(customGasPriceInHex || gasPrice))
|
2018-09-13 10:47:05 +02:00
|
|
|
}
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getSafeLowEstimate(state) {
|
2018-12-10 22:51:00 +01:00
|
|
|
const {
|
|
|
|
gas: {
|
2020-11-03 00:41:28 +01:00
|
|
|
basicEstimates: { safeLow },
|
2018-12-10 22:51:00 +01:00
|
|
|
},
|
|
|
|
} = state
|
|
|
|
|
|
|
|
return safeLow
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:14:08 +01:00
|
|
|
export function isCustomPriceSafe(state) {
|
2018-12-10 22:51:00 +01:00
|
|
|
const safeLow = getSafeLowEstimate(state)
|
2020-10-17 11:13:51 +02:00
|
|
|
|
2018-12-10 22:51:00 +01:00
|
|
|
const customGasPrice = getCustomGasPrice(state)
|
|
|
|
|
|
|
|
if (!customGasPrice) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:14:08 +01:00
|
|
|
if (safeLow === null) {
|
2020-10-17 11:13:51 +02:00
|
|
|
return false
|
2019-06-18 14:17:14 +02:00
|
|
|
}
|
|
|
|
|
2018-12-10 22:51:00 +01:00
|
|
|
const customPriceSafe = conversionGreaterThan(
|
|
|
|
{
|
|
|
|
value: customGasPrice,
|
|
|
|
fromNumericBase: 'hex',
|
|
|
|
fromDenomination: 'WEI',
|
|
|
|
toDenomination: 'GWEI',
|
|
|
|
},
|
2020-11-04 17:14:08 +01:00
|
|
|
{ value: safeLow, fromNumericBase: 'dec' },
|
2018-12-10 22:51:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
return customPriceSafe
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function basicPriceEstimateToETHTotal(
|
|
|
|
estimate,
|
|
|
|
gasLimit,
|
|
|
|
numberOfDecimals = 9,
|
|
|
|
) {
|
2018-08-16 14:28:27 +02:00
|
|
|
return conversionUtil(calcGasTotal(gasLimit, estimate), {
|
|
|
|
fromNumericBase: 'hex',
|
|
|
|
toNumericBase: 'dec',
|
|
|
|
fromDenomination: 'GWEI',
|
2018-09-13 14:35:17 +02:00
|
|
|
numberOfDecimals,
|
2018-08-16 14:28:27 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getRenderableEthFee(estimate, gasLimit, numberOfDecimals = 9) {
|
|
|
|
const value = conversionUtil(estimate, {
|
|
|
|
fromNumericBase: 'dec',
|
|
|
|
toNumericBase: 'hex',
|
|
|
|
})
|
2020-07-08 22:17:53 +02:00
|
|
|
const fee = basicPriceEstimateToETHTotal(value, gasLimit, numberOfDecimals)
|
|
|
|
return formatETHFee(fee)
|
2018-08-16 14:28:27 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getRenderableConvertedCurrencyFee(
|
|
|
|
estimate,
|
|
|
|
gasLimit,
|
|
|
|
convertedCurrency,
|
|
|
|
conversionRate,
|
|
|
|
) {
|
|
|
|
const value = conversionUtil(estimate, {
|
|
|
|
fromNumericBase: 'dec',
|
|
|
|
toNumericBase: 'hex',
|
|
|
|
})
|
2020-07-08 22:17:53 +02:00
|
|
|
const fee = basicPriceEstimateToETHTotal(value, gasLimit)
|
2020-11-03 00:41:28 +01:00
|
|
|
const feeInCurrency = ethTotalToConvertedCurrency(
|
|
|
|
fee,
|
|
|
|
convertedCurrency,
|
|
|
|
conversionRate,
|
|
|
|
)
|
2020-07-08 22:17:53 +02:00
|
|
|
return formatCurrency(feeInCurrency, convertedCurrency)
|
2018-08-16 14:28:27 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function priceEstimateToWei(priceEstimate) {
|
2018-08-16 14:28:27 +02:00
|
|
|
return conversionUtil(priceEstimate, {
|
|
|
|
fromNumericBase: 'hex',
|
|
|
|
toNumericBase: 'hex',
|
|
|
|
fromDenomination: 'GWEI',
|
|
|
|
toDenomination: 'WEI',
|
|
|
|
numberOfDecimals: 9,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getGasPriceInHexWei(price) {
|
|
|
|
const value = conversionUtil(price, {
|
|
|
|
fromNumericBase: 'dec',
|
|
|
|
toNumericBase: 'hex',
|
|
|
|
})
|
2020-07-08 22:17:53 +02:00
|
|
|
return addHexPrefix(priceEstimateToWei(value))
|
2018-08-16 14:28:27 +02:00
|
|
|
}
|
|
|
|
|
2020-11-04 17:14:08 +01:00
|
|
|
export function getRenderableGasButtonData(
|
|
|
|
estimates,
|
2020-11-03 00:41:28 +01:00
|
|
|
gasLimit,
|
2020-11-04 17:14:08 +01:00
|
|
|
showFiat,
|
|
|
|
conversionRate,
|
|
|
|
currentCurrency,
|
2020-11-03 00:41:28 +01:00
|
|
|
) {
|
2020-12-03 00:25:19 +01:00
|
|
|
const { safeLow, average, fast } = estimates
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2020-10-17 11:13:51 +02:00
|
|
|
const slowEstimateData = {
|
2020-10-12 18:51:17 +02:00
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.SLOW,
|
|
|
|
feeInPrimaryCurrency: getRenderableEthFee(safeLow, gasLimit),
|
|
|
|
feeInSecondaryCurrency: showFiat
|
2020-11-03 00:41:28 +01:00
|
|
|
? getRenderableConvertedCurrencyFee(
|
|
|
|
safeLow,
|
|
|
|
gasLimit,
|
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
)
|
2020-10-12 18:51:17 +02:00
|
|
|
: '',
|
|
|
|
priceInHexWei: getGasPriceInHexWei(safeLow),
|
|
|
|
}
|
|
|
|
const averageEstimateData = {
|
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
|
|
|
feeInPrimaryCurrency: getRenderableEthFee(average, gasLimit),
|
|
|
|
feeInSecondaryCurrency: showFiat
|
2020-11-03 00:41:28 +01:00
|
|
|
? getRenderableConvertedCurrencyFee(
|
|
|
|
average,
|
|
|
|
gasLimit,
|
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
)
|
2020-10-12 18:51:17 +02:00
|
|
|
: '',
|
|
|
|
priceInHexWei: getGasPriceInHexWei(average),
|
|
|
|
}
|
2020-10-17 11:13:51 +02:00
|
|
|
const fastEstimateData = {
|
2020-10-12 18:51:17 +02:00
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.FAST,
|
|
|
|
feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit),
|
|
|
|
feeInSecondaryCurrency: showFiat
|
2020-11-03 00:41:28 +01:00
|
|
|
? getRenderableConvertedCurrencyFee(
|
|
|
|
fast,
|
|
|
|
gasLimit,
|
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
)
|
2020-10-12 18:51:17 +02:00
|
|
|
: '',
|
|
|
|
priceInHexWei: getGasPriceInHexWei(fast),
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:14:08 +01:00
|
|
|
return {
|
|
|
|
slowEstimateData,
|
|
|
|
averageEstimateData,
|
|
|
|
fastEstimateData,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getRenderableBasicEstimateData(state, gasLimit) {
|
|
|
|
if (getBasicGasEstimateLoadingStatus(state)) {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
|
|
|
const { showFiatInTestnets } = getPreferences(state)
|
|
|
|
const isMainnet = getIsMainnet(state)
|
|
|
|
const showFiat = isMainnet || Boolean(showFiatInTestnets)
|
|
|
|
const { conversionRate } = state.metamask
|
|
|
|
const currentCurrency = getCurrentCurrency(state)
|
|
|
|
|
|
|
|
const {
|
|
|
|
slowEstimateData,
|
|
|
|
averageEstimateData,
|
|
|
|
fastEstimateData,
|
|
|
|
} = getRenderableGasButtonData(
|
|
|
|
state.gas.basicEstimates,
|
|
|
|
gasLimit,
|
|
|
|
showFiat,
|
|
|
|
conversionRate,
|
|
|
|
currentCurrency,
|
|
|
|
)
|
|
|
|
|
|
|
|
return [slowEstimateData, averageEstimateData, fastEstimateData]
|
2018-08-02 18:02:22 +02:00
|
|
|
}
|
2018-09-13 14:35:17 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function getRenderableEstimateDataForSmallButtonsFromGWEI(state) {
|
2018-09-13 14:35:17 +02:00
|
|
|
if (getBasicGasEstimateLoadingStatus(state)) {
|
|
|
|
return []
|
|
|
|
}
|
2019-02-26 19:30:41 +01:00
|
|
|
|
2020-05-26 08:11:58 +02:00
|
|
|
const { showFiatInTestnets } = getPreferences(state)
|
2019-02-26 19:30:41 +01:00
|
|
|
const isMainnet = getIsMainnet(state)
|
2020-11-03 00:41:28 +01:00
|
|
|
const showFiat = isMainnet || Boolean(showFiatInTestnets)
|
|
|
|
const gasLimit =
|
|
|
|
state.metamask.send.gasLimit || getCustomGasLimit(state) || '0x5208'
|
2020-08-18 22:06:58 +02:00
|
|
|
const { conversionRate } = state.metamask
|
2018-09-13 14:35:17 +02:00
|
|
|
const currentCurrency = getCurrentCurrency(state)
|
|
|
|
const {
|
|
|
|
gas: {
|
2020-11-03 00:41:28 +01:00
|
|
|
basicEstimates: { safeLow, average, fast },
|
2018-09-13 14:35:17 +02:00
|
|
|
},
|
|
|
|
} = state
|
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.SLOW,
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: showFiat
|
2020-11-03 00:41:28 +01:00
|
|
|
? getRenderableConvertedCurrencyFee(
|
|
|
|
safeLow,
|
|
|
|
gasLimit,
|
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
)
|
2019-02-26 19:30:41 +01:00
|
|
|
: '',
|
2020-11-03 00:41:28 +01:00
|
|
|
feeInPrimaryCurrency: getRenderableEthFee(
|
|
|
|
safeLow,
|
|
|
|
gasLimit,
|
|
|
|
NUMBER_OF_DECIMALS_SM_BTNS,
|
|
|
|
true,
|
|
|
|
),
|
2019-02-06 16:10:00 +01:00
|
|
|
priceInHexWei: getGasPriceInHexWei(safeLow, true),
|
2018-09-13 14:35:17 +02:00
|
|
|
},
|
|
|
|
{
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: showFiat
|
2020-11-03 00:41:28 +01:00
|
|
|
? getRenderableConvertedCurrencyFee(
|
|
|
|
average,
|
|
|
|
gasLimit,
|
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
)
|
2019-02-26 19:30:41 +01:00
|
|
|
: '',
|
2020-11-03 00:41:28 +01:00
|
|
|
feeInPrimaryCurrency: getRenderableEthFee(
|
|
|
|
average,
|
|
|
|
gasLimit,
|
|
|
|
NUMBER_OF_DECIMALS_SM_BTNS,
|
|
|
|
true,
|
|
|
|
),
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: getGasPriceInHexWei(average, true),
|
2018-09-13 14:35:17 +02:00
|
|
|
},
|
|
|
|
{
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.FAST,
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: showFiat
|
2020-11-03 00:41:28 +01:00
|
|
|
? getRenderableConvertedCurrencyFee(
|
|
|
|
fast,
|
|
|
|
gasLimit,
|
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
)
|
2019-02-26 19:30:41 +01:00
|
|
|
: '',
|
2020-11-03 00:41:28 +01:00
|
|
|
feeInPrimaryCurrency: getRenderableEthFee(
|
|
|
|
fast,
|
|
|
|
gasLimit,
|
|
|
|
NUMBER_OF_DECIMALS_SM_BTNS,
|
|
|
|
true,
|
|
|
|
),
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: getGasPriceInHexWei(fast, true),
|
2018-09-13 14:35:17 +02:00
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|