2021-02-04 19:15:23 +01:00
|
|
|
import assert from 'assert';
|
|
|
|
import proxyquire from 'proxyquire';
|
2018-08-16 14:28:27 +02:00
|
|
|
|
|
|
|
const {
|
|
|
|
getCustomGasLimit,
|
|
|
|
getCustomGasPrice,
|
|
|
|
getRenderableBasicEstimateData,
|
2018-11-13 17:36:52 +01:00
|
|
|
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
2021-03-02 23:19:56 +01:00
|
|
|
isCustomPriceSafe,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = proxyquire('../custom-gas', {});
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('custom-gas selectors', function () {
|
|
|
|
describe('getCustomGasPrice()', function () {
|
|
|
|
it('should return gas.customData.price', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const mockState = { gas: { customData: { price: 'mockPrice' } } };
|
|
|
|
assert.strictEqual(getCustomGasPrice(mockState), 'mockPrice');
|
|
|
|
});
|
|
|
|
});
|
2021-03-02 23:19:56 +01:00
|
|
|
describe('isCustomGasPriceSafe()', function () {
|
|
|
|
it('should return true for gas.customData.price 0x77359400', function () {
|
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x77359400' },
|
|
|
|
basicEstimates: { safeLow: 1 },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
assert.strictEqual(isCustomPriceSafe(mockState), true);
|
|
|
|
});
|
|
|
|
it('should return true for gas.customData.price null', function () {
|
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: null },
|
|
|
|
basicEstimates: { safeLow: 1 },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
assert.strictEqual(isCustomPriceSafe(mockState), true);
|
|
|
|
});
|
|
|
|
it('should return true gas.customData.price undefined', function () {
|
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: undefined },
|
|
|
|
basicEstimates: { safeLow: 1 },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
assert.strictEqual(isCustomPriceSafe(mockState), true);
|
|
|
|
});
|
|
|
|
it('should return false gas.basicEstimates.safeLow undefined', function () {
|
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x77359400' },
|
|
|
|
basicEstimates: { safeLow: undefined },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
assert.strictEqual(isCustomPriceSafe(mockState), false);
|
|
|
|
});
|
|
|
|
});
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getCustomGasLimit()', function () {
|
|
|
|
it('should return gas.customData.limit', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const mockState = { gas: { customData: { limit: 'mockLimit' } } };
|
|
|
|
assert.strictEqual(getCustomGasLimit(mockState), 'mockLimit');
|
|
|
|
});
|
|
|
|
});
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getRenderableBasicEstimateData()', function () {
|
2018-08-16 14:28:27 +02:00
|
|
|
const tests = [
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
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: 'SLOW',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '$0.01',
|
|
|
|
feeInPrimaryCurrency: '0.0000525 ETH',
|
2019-02-06 16:10:00 +01:00
|
|
|
priceInHexWei: '0x9502f900',
|
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
|
|
|
gasEstimateType: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInPrimaryCurrency: '0.000084 ETH',
|
|
|
|
feeInSecondaryCurrency: '$0.02',
|
|
|
|
priceInHexWei: '0xee6b2800',
|
|
|
|
},
|
|
|
|
{
|
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: 'FAST',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '$0.03',
|
|
|
|
feeInPrimaryCurrency: '0.000105 ETH',
|
2018-08-16 14:28:27 +02:00
|
|
|
priceInHexWei: '0x12a05f200',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 255.71,
|
|
|
|
currentCurrency: 'usd',
|
2019-02-26 19:30:41 +01:00
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: false,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'mainnet',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x1',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
2018-08-16 14:28:27 +02:00
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
blockTime: 14.16326530612245,
|
2018-11-27 18:30:41 +01:00
|
|
|
safeLow: 2.5,
|
2018-08-16 14:28:27 +02:00
|
|
|
safeLowWait: 6.6,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 4,
|
|
|
|
avgWait: 5.3,
|
2018-11-27 18:30:41 +01:00
|
|
|
fast: 5,
|
2018-11-13 17:36:52 +01:00
|
|
|
fastWait: 3.3,
|
2018-11-27 18:30:41 +01:00
|
|
|
fastest: 10,
|
2018-11-13 17:36:52 +01:00
|
|
|
fastestWait: 0.5,
|
2018-08-16 14:28:27 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
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: 'SLOW',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '$0.27',
|
|
|
|
feeInPrimaryCurrency: '0.000105 ETH',
|
2019-02-06 16:10:00 +01:00
|
|
|
priceInHexWei: '0x12a05f200',
|
2018-08-16 14:28:27 +02:00
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInPrimaryCurrency: '0.000147 ETH',
|
|
|
|
feeInSecondaryCurrency: '$0.38',
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x1a13b8600',
|
|
|
|
},
|
|
|
|
{
|
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: 'FAST',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '$0.54',
|
|
|
|
feeInPrimaryCurrency: '0.00021 ETH',
|
2018-08-16 14:28:27 +02:00
|
|
|
priceInHexWei: '0x2540be400',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 2557.1,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
2019-02-26 19:30:41 +01:00
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: false,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'mainnet',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x1',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
blockTime: 14.16326530612245,
|
|
|
|
safeLow: 5,
|
|
|
|
safeLowWait: 13.2,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 7,
|
|
|
|
avgWait: 10.1,
|
2019-02-26 19:30:41 +01:00
|
|
|
fast: 10,
|
|
|
|
fastWait: 6.6,
|
|
|
|
fastest: 20,
|
|
|
|
fastestWait: 1.0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
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: 'SLOW',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '',
|
|
|
|
feeInPrimaryCurrency: '0.000105 ETH',
|
|
|
|
priceInHexWei: '0x12a05f200',
|
|
|
|
},
|
|
|
|
{
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInPrimaryCurrency: '0.000147 ETH',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x1a13b8600',
|
2019-02-26 19:30:41 +01: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: 'FAST',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '',
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInPrimaryCurrency: '0.00021 ETH',
|
|
|
|
priceInHexWei: '0x2540be400',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 2557.1,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: false,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'rinkeby',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x4',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
blockTime: 14.16326530612245,
|
|
|
|
safeLow: 5,
|
|
|
|
safeLowWait: 13.2,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 7,
|
|
|
|
avgWait: 10.1,
|
2019-02-26 19:30:41 +01:00
|
|
|
fast: 10,
|
|
|
|
fastWait: 6.6,
|
|
|
|
fastest: 20,
|
|
|
|
fastestWait: 1.0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
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: 'SLOW',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '$0.27',
|
|
|
|
feeInPrimaryCurrency: '0.000105 ETH',
|
|
|
|
priceInHexWei: '0x12a05f200',
|
|
|
|
},
|
|
|
|
{
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInPrimaryCurrency: '0.000147 ETH',
|
|
|
|
feeInSecondaryCurrency: '$0.38',
|
|
|
|
priceInHexWei: '0x1a13b8600',
|
|
|
|
},
|
|
|
|
{
|
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: 'FAST',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '$0.54',
|
|
|
|
feeInPrimaryCurrency: '0.00021 ETH',
|
|
|
|
priceInHexWei: '0x2540be400',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 2557.1,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: true,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'rinkeby',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x4',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
safeLow: 5,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 7,
|
2019-02-26 19:30:41 +01:00
|
|
|
fast: 10,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
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: 'SLOW',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '$0.27',
|
|
|
|
feeInPrimaryCurrency: '0.000105 ETH',
|
|
|
|
priceInHexWei: '0x12a05f200',
|
|
|
|
},
|
|
|
|
{
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInPrimaryCurrency: '0.000147 ETH',
|
|
|
|
feeInSecondaryCurrency: '$0.38',
|
|
|
|
priceInHexWei: '0x1a13b8600',
|
|
|
|
},
|
|
|
|
{
|
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: 'FAST',
|
2019-02-26 19:30:41 +01:00
|
|
|
feeInSecondaryCurrency: '$0.54',
|
|
|
|
feeInPrimaryCurrency: '0.00021 ETH',
|
|
|
|
priceInHexWei: '0x2540be400',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 2557.1,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: true,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'mainnet',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x1',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
2018-08-16 14:28:27 +02:00
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
2018-11-27 18:30:41 +01:00
|
|
|
safeLow: 5,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 7,
|
2018-11-27 18:30:41 +01:00
|
|
|
fast: 10,
|
2018-08-16 14:28:27 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
];
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should return renderable data about basic estimates', function () {
|
2020-02-15 21:34:12 +01:00
|
|
|
tests.forEach((test) => {
|
2020-12-03 16:46:22 +01:00
|
|
|
assert.deepStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
getRenderableBasicEstimateData(
|
|
|
|
test.mockState,
|
|
|
|
'0x5208',
|
|
|
|
test.useFastestButtons,
|
|
|
|
),
|
2020-07-14 17:20:41 +02:00
|
|
|
test.expectedResult,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getRenderableEstimateDataForSmallButtonsFromGWEI()', function () {
|
2018-09-20 06:16:43 +02:00
|
|
|
const tests = [
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
2019-02-06 16:10:00 +01:00
|
|
|
feeInSecondaryCurrency: '$0.13',
|
|
|
|
feeInPrimaryCurrency: '0.00052 ETH',
|
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: 'SLOW',
|
2019-02-06 16:10:00 +01:00
|
|
|
priceInHexWei: '0x5d21dba00',
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInSecondaryCurrency: '$0.16',
|
|
|
|
feeInPrimaryCurrency: '0.00063 ETH',
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x6fc23ac00',
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInSecondaryCurrency: '$0.27',
|
|
|
|
feeInPrimaryCurrency: '0.00105 ETH',
|
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: 'FAST',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0xba43b7400',
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 255.71,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
2019-02-26 19:30:41 +01:00
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: false,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'mainnet',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x1',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
safeLow: 25,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 30,
|
2018-11-13 17:36:52 +01:00
|
|
|
fast: 50,
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
2019-02-06 16:10:00 +01:00
|
|
|
feeInSecondaryCurrency: '$2.68',
|
|
|
|
feeInPrimaryCurrency: '0.00105 ETH',
|
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: 'SLOW',
|
2019-02-06 16:10:00 +01:00
|
|
|
priceInHexWei: '0xba43b7400',
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInSecondaryCurrency: '$4.03',
|
|
|
|
feeInPrimaryCurrency: '0.00157 ETH',
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x1176592e00',
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInSecondaryCurrency: '$5.37',
|
|
|
|
feeInPrimaryCurrency: '0.0021 ETH',
|
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: 'FAST',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x174876e800',
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 2557.1,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
2019-02-26 19:30:41 +01:00
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: false,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'mainnet',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x1',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
blockTime: 14.16326530612245,
|
|
|
|
safeLow: 50,
|
|
|
|
safeLowWait: 13.2,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 75,
|
|
|
|
avgWait: 9.6,
|
2019-02-26 19:30:41 +01:00
|
|
|
fast: 100,
|
|
|
|
fastWait: 6.6,
|
|
|
|
fastest: 200,
|
|
|
|
fastestWait: 1.0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
|
|
|
feeInSecondaryCurrency: '',
|
|
|
|
feeInPrimaryCurrency: '0.00105 ETH',
|
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: 'SLOW',
|
2019-02-26 19:30:41 +01:00
|
|
|
priceInHexWei: '0xba43b7400',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
feeInSecondaryCurrency: '',
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInPrimaryCurrency: '0.00157 ETH',
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x1176592e00',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
feeInSecondaryCurrency: '',
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInPrimaryCurrency: '0.0021 ETH',
|
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: 'FAST',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x174876e800',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 2557.1,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: false,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'rinkeby',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x4',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
blockTime: 14.16326530612245,
|
|
|
|
safeLow: 50,
|
|
|
|
safeLowWait: 13.2,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 75,
|
|
|
|
avgWait: 9.6,
|
2019-02-26 19:30:41 +01:00
|
|
|
fast: 100,
|
|
|
|
fastWait: 6.6,
|
|
|
|
fastest: 200,
|
|
|
|
fastestWait: 1.0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
|
|
|
feeInSecondaryCurrency: '$2.68',
|
|
|
|
feeInPrimaryCurrency: '0.00105 ETH',
|
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: 'SLOW',
|
2019-02-26 19:30:41 +01:00
|
|
|
priceInHexWei: '0xba43b7400',
|
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInSecondaryCurrency: '$4.03',
|
|
|
|
feeInPrimaryCurrency: '0.00157 ETH',
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x1176592e00',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInSecondaryCurrency: '$5.37',
|
|
|
|
feeInPrimaryCurrency: '0.0021 ETH',
|
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: 'FAST',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x174876e800',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 2557.1,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: true,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'rinkeby',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x4',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
safeLow: 50,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 75,
|
2019-02-26 19:30:41 +01:00
|
|
|
fast: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expectedResult: [
|
|
|
|
{
|
|
|
|
feeInSecondaryCurrency: '$2.68',
|
|
|
|
feeInPrimaryCurrency: '0.00105 ETH',
|
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: 'SLOW',
|
2019-02-26 19:30:41 +01:00
|
|
|
priceInHexWei: '0xba43b7400',
|
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInSecondaryCurrency: '$4.03',
|
|
|
|
feeInPrimaryCurrency: '0.00157 ETH',
|
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: 'AVERAGE',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x1176592e00',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
{
|
2019-08-22 16:04:52 +02:00
|
|
|
feeInSecondaryCurrency: '$5.37',
|
|
|
|
feeInPrimaryCurrency: '0.0021 ETH',
|
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: 'FAST',
|
2019-08-22 16:04:52 +02:00
|
|
|
priceInHexWei: '0x174876e800',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
mockState: {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 2557.1,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
send: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
},
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: true,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'mainnet',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x1',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
basicEstimates: {
|
|
|
|
safeLow: 50,
|
2019-08-22 16:04:52 +02:00
|
|
|
average: 75,
|
2018-11-13 17:36:52 +01:00
|
|
|
fast: 100,
|
2018-09-20 06:16:43 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
];
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should return renderable data about basic estimates appropriate for buttons with less info', function () {
|
2020-02-15 21:34:12 +01:00
|
|
|
tests.forEach((test) => {
|
2020-12-03 16:46:22 +01:00
|
|
|
assert.deepStrictEqual(
|
2018-11-13 17:36:52 +01:00
|
|
|
getRenderableEstimateDataForSmallButtonsFromGWEI(test.mockState),
|
2020-07-14 17:20:41 +02:00
|
|
|
test.expectedResult,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|