2021-06-08 17:25:48 +02:00
|
|
|
import { GAS_LIMITS } from '../../shared/constants/gas';
|
2021-04-15 20:01:46 +02:00
|
|
|
import {
|
2018-08-16 14:28:27 +02:00
|
|
|
getCustomGasLimit,
|
|
|
|
getCustomGasPrice,
|
|
|
|
getRenderableBasicEstimateData,
|
2018-11-13 17:36:52 +01:00
|
|
|
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
2021-03-02 23:19:56 +01:00
|
|
|
isCustomPriceSafe,
|
2021-03-05 18:32:09 +01:00
|
|
|
isCustomPriceExcessive,
|
2021-04-15 20:01:46 +02:00
|
|
|
} from './custom-gas';
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('custom-gas selectors', () => {
|
|
|
|
describe('getCustomGasPrice()', () => {
|
|
|
|
it('should return gas.customData.price', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const mockState = { gas: { customData: { price: 'mockPrice' } } };
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(getCustomGasPrice(mockState)).toStrictEqual('mockPrice');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('isCustomGasPriceSafe()', () => {
|
|
|
|
it('should return true for gas.customData.price 0x77359400', () => {
|
2021-03-02 23:19:56 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x77359400' },
|
|
|
|
basicEstimates: { safeLow: 1 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceSafe(mockState)).toStrictEqual(true);
|
2021-03-02 23:19:56 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return true for gas.customData.price null', () => {
|
2021-03-02 23:19:56 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: null },
|
|
|
|
basicEstimates: { safeLow: 1 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceSafe(mockState)).toStrictEqual(true);
|
2021-03-02 23:19:56 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return true gas.customData.price undefined', () => {
|
2021-03-02 23:19:56 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: undefined },
|
|
|
|
basicEstimates: { safeLow: 1 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceSafe(mockState)).toStrictEqual(true);
|
2021-03-02 23:19:56 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return false gas.basicEstimates.safeLow undefined', () => {
|
2021-03-02 23:19:56 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x77359400' },
|
|
|
|
basicEstimates: { safeLow: undefined },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceSafe(mockState)).toStrictEqual(false);
|
2021-03-02 23:19:56 +01:00
|
|
|
});
|
|
|
|
});
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('isCustomPriceExcessive()', () => {
|
|
|
|
it('should return false for gas.customData.price null', () => {
|
2021-03-05 18:32:09 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: null },
|
|
|
|
basicEstimates: { fast: 150 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
2021-03-05 18:32:09 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return false gas.basicEstimates.fast undefined', () => {
|
2021-03-05 18:32:09 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x77359400' },
|
|
|
|
basicEstimates: { fast: undefined },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
2021-03-05 18:32:09 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return false gas.basicEstimates.price 0x205d0bae00 (139)', () => {
|
2021-03-05 18:32:09 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x205d0bae00' },
|
|
|
|
basicEstimates: { fast: 139 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
2021-03-05 18:32:09 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return false gas.basicEstimates.price 0x1bf08eb000 (120)', () => {
|
2021-03-05 18:32:09 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x1bf08eb000' },
|
|
|
|
basicEstimates: { fast: 139 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
2021-03-05 18:32:09 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return false gas.basicEstimates.price 0x28bed01600 (175)', () => {
|
2021-03-05 18:32:09 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x28bed01600' },
|
|
|
|
basicEstimates: { fast: 139 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(false);
|
2021-03-05 18:32:09 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return true gas.basicEstimates.price 0x30e4f9b400 (210)', () => {
|
2021-03-05 18:32:09 +01:00
|
|
|
const mockState = {
|
|
|
|
gas: {
|
|
|
|
customData: { price: '0x30e4f9b400' },
|
|
|
|
basicEstimates: { fast: 139 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceExcessive(mockState)).toStrictEqual(true);
|
2021-03-05 18:32:09 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return false gas.basicEstimates.price 0x28bed01600 (175) (checkSend=true)', () => {
|
2021-03-05 18:32:09 +01:00
|
|
|
const mockState = {
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasPrice: '0x28bed0160',
|
|
|
|
},
|
2021-03-05 18:32:09 +01:00
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
customData: { price: null },
|
|
|
|
basicEstimates: { fast: 139 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceExcessive(mockState, true)).toStrictEqual(false);
|
2021-03-05 18:32:09 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return true gas.basicEstimates.price 0x30e4f9b400 (210) (checkSend=true)', () => {
|
2021-03-05 18:32:09 +01:00
|
|
|
const mockState = {
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasPrice: '0x30e4f9b400',
|
|
|
|
},
|
2021-03-05 18:32:09 +01:00
|
|
|
},
|
|
|
|
gas: {
|
|
|
|
customData: { price: null },
|
|
|
|
basicEstimates: { fast: 139 },
|
|
|
|
},
|
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(isCustomPriceExcessive(mockState, true)).toStrictEqual(true);
|
2021-03-05 18:32:09 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('getCustomGasLimit()', () => {
|
|
|
|
it('should return gas.customData.limit', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const mockState = { gas: { customData: { limit: 'mockLimit' } } };
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(getCustomGasLimit(mockState)).toStrictEqual('mockLimit');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('getRenderableBasicEstimateData()', () => {
|
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',
|
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
|
|
|
},
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
},
|
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',
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: false,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'rinkeby',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x4',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
},
|
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',
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: true,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'rinkeby',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x4',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
},
|
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',
|
|
|
|
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
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02: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
|
|
|
];
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return renderable data about basic estimates', () => {
|
2020-02-15 21:34:12 +01:00
|
|
|
tests.forEach((test) => {
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
getRenderableBasicEstimateData(
|
|
|
|
test.mockState,
|
2021-06-08 17:25:48 +02:00
|
|
|
GAS_LIMITS.SIMPLE,
|
2020-11-03 00:41:28 +01:00
|
|
|
test.useFastestButtons,
|
|
|
|
),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(test.expectedResult);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-08-16 14:28:27 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('getRenderableEstimateDataForSmallButtonsFromGWEI()', () => {
|
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',
|
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
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02: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',
|
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
|
|
|
},
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
},
|
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',
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: false,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'rinkeby',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x4',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
},
|
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',
|
|
|
|
preferences: {
|
|
|
|
showFiatInTestnets: true,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'rinkeby',
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x4',
|
2019-02-26 19:30:41 +01:00
|
|
|
},
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
},
|
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',
|
|
|
|
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
|
|
|
},
|
2021-06-10 19:53:15 +02:00
|
|
|
send: {
|
2021-06-23 23:35:25 +02:00
|
|
|
gas: {
|
|
|
|
gasLimit: GAS_LIMITS.SIMPLE,
|
|
|
|
},
|
2021-06-10 19:53:15 +02: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
|
|
|
];
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should return renderable data about basic estimates appropriate for buttons with less info', () => {
|
2020-02-15 21:34:12 +01:00
|
|
|
tests.forEach((test) => {
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2018-11-13 17:36:52 +01:00
|
|
|
getRenderableEstimateDataForSmallButtonsFromGWEI(test.mockState),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(test.expectedResult);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|