1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Change gas labels to Slow/Average/Fast (#6090)

* Change gas labels to Slow/Average/Fast

* Fix unit test
This commit is contained in:
Chi Kei Chan 2019-02-06 23:10:00 +08:00 committed by Whymarrh Whitby
parent 38b91f63a2
commit 83109c3dc7
2 changed files with 69 additions and 69 deletions

View File

@ -242,25 +242,25 @@ function getRenderableBasicEstimateData (state, gasLimit) {
return [ return [
{ {
labelKey: 'fastest', labelKey: 'slow',
feeInPrimaryCurrency: getRenderableConvertedCurrencyFee(fastest, gasLimit, currentCurrency, conversionRate), feeInPrimaryCurrency: getRenderableConvertedCurrencyFee(safeLow, gasLimit, currentCurrency, conversionRate),
feeInSecondaryCurrency: getRenderableEthFee(fastest, gasLimit), feeInSecondaryCurrency: getRenderableEthFee(safeLow, gasLimit),
timeEstimate: fastestWait && getRenderableTimeEstimate(fastestWait), timeEstimate: safeLowWait && getRenderableTimeEstimate(safeLowWait),
priceInHexWei: getGasPriceInHexWei(fastest), priceInHexWei: getGasPriceInHexWei(safeLow),
}, },
{ {
labelKey: 'fast', labelKey: 'average',
feeInPrimaryCurrency: getRenderableConvertedCurrencyFee(fast, gasLimit, currentCurrency, conversionRate), feeInPrimaryCurrency: getRenderableConvertedCurrencyFee(fast, gasLimit, currentCurrency, conversionRate),
feeInSecondaryCurrency: getRenderableEthFee(fast, gasLimit), feeInSecondaryCurrency: getRenderableEthFee(fast, gasLimit),
timeEstimate: fastWait && getRenderableTimeEstimate(fastWait), timeEstimate: fastWait && getRenderableTimeEstimate(fastWait),
priceInHexWei: getGasPriceInHexWei(fast), priceInHexWei: getGasPriceInHexWei(fast),
}, },
{ {
labelKey: 'slow', labelKey: 'fast',
feeInPrimaryCurrency: getRenderableConvertedCurrencyFee(safeLow, gasLimit, currentCurrency, conversionRate), feeInPrimaryCurrency: getRenderableConvertedCurrencyFee(fastest, gasLimit, currentCurrency, conversionRate),
feeInSecondaryCurrency: getRenderableEthFee(safeLow, gasLimit), feeInSecondaryCurrency: getRenderableEthFee(fastest, gasLimit),
timeEstimate: safeLowWait && getRenderableTimeEstimate(safeLowWait), timeEstimate: fastestWait && getRenderableTimeEstimate(fastestWait),
priceInHexWei: getGasPriceInHexWei(safeLow), priceInHexWei: getGasPriceInHexWei(fastest),
}, },
] ]
} }
@ -283,23 +283,23 @@ function getRenderableEstimateDataForSmallButtonsFromGWEI (state) {
} = state } = state
return [ return [
{
labelKey: 'fastest',
feeInSecondaryCurrency: getRenderableConvertedCurrencyFee(fastest, gasLimit, currentCurrency, conversionRate),
feeInPrimaryCurrency: getRenderableEthFee(fastest, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(fastest, true),
},
{
labelKey: 'fast',
feeInSecondaryCurrency: getRenderableConvertedCurrencyFee(fast, gasLimit, currentCurrency, conversionRate),
feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(fast, true),
},
{ {
labelKey: 'slow', labelKey: 'slow',
feeInSecondaryCurrency: getRenderableConvertedCurrencyFee(safeLow, gasLimit, currentCurrency, conversionRate), feeInSecondaryCurrency: getRenderableConvertedCurrencyFee(safeLow, gasLimit, currentCurrency, conversionRate),
feeInPrimaryCurrency: getRenderableEthFee(safeLow, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true), feeInPrimaryCurrency: getRenderableEthFee(safeLow, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(safeLow, true), priceInHexWei: getGasPriceInHexWei(safeLow, true),
}, },
{
labelKey: 'average',
feeInSecondaryCurrency: getRenderableConvertedCurrencyFee(fast, gasLimit, currentCurrency, conversionRate),
feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(fast, true),
},
{
labelKey: 'fast',
feeInSecondaryCurrency: getRenderableConvertedCurrencyFee(fastest, gasLimit, currentCurrency, conversionRate),
feeInPrimaryCurrency: getRenderableEthFee(fastest, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(fastest, true),
},
] ]
} }

View File

@ -77,25 +77,25 @@ describe('custom-gas selectors', () => {
{ {
expectedResult: [ expectedResult: [
{ {
labelKey: 'fastest', labelKey: 'slow',
feeInPrimaryCurrency: '$0.05', feeInPrimaryCurrency: '$0.01',
feeInSecondaryCurrency: '0.00021 ETH', feeInSecondaryCurrency: '0.0000525 ETH',
timeEstimate: '~30 sec', timeEstimate: '~6 min 36 sec',
priceInHexWei: '0x2540be400', priceInHexWei: '0x9502f900',
}, },
{ {
labelKey: 'fast', labelKey: 'average',
feeInPrimaryCurrency: '$0.03', feeInPrimaryCurrency: '$0.03',
feeInSecondaryCurrency: '0.000105 ETH', feeInSecondaryCurrency: '0.000105 ETH',
timeEstimate: '~3 min 18 sec', timeEstimate: '~3 min 18 sec',
priceInHexWei: '0x12a05f200', priceInHexWei: '0x12a05f200',
}, },
{ {
labelKey: 'slow', labelKey: 'fast',
feeInPrimaryCurrency: '$0.01', feeInPrimaryCurrency: '$0.05',
feeInSecondaryCurrency: '0.0000525 ETH', feeInSecondaryCurrency: '0.00021 ETH',
timeEstimate: '~6 min 36 sec', timeEstimate: '~30 sec',
priceInHexWei: '0x9502f900', priceInHexWei: '0x2540be400',
}, },
], ],
mockState: { mockState: {
@ -119,25 +119,25 @@ describe('custom-gas selectors', () => {
{ {
expectedResult: [ expectedResult: [
{ {
labelKey: 'fastest', labelKey: 'slow',
feeInPrimaryCurrency: '$1.07', feeInPrimaryCurrency: '$0.27',
feeInSecondaryCurrency: '0.00042 ETH', feeInSecondaryCurrency: '0.000105 ETH',
timeEstimate: '~1 min', timeEstimate: '~13 min 12 sec',
priceInHexWei: '0x4a817c800', priceInHexWei: '0x12a05f200',
}, },
{ {
labelKey: 'fast', labelKey: 'average',
feeInPrimaryCurrency: '$0.54', feeInPrimaryCurrency: '$0.54',
feeInSecondaryCurrency: '0.00021 ETH', feeInSecondaryCurrency: '0.00021 ETH',
timeEstimate: '~6 min 36 sec', timeEstimate: '~6 min 36 sec',
priceInHexWei: '0x2540be400', priceInHexWei: '0x2540be400',
}, },
{ {
labelKey: 'slow', labelKey: 'fast',
feeInPrimaryCurrency: '$0.27', feeInPrimaryCurrency: '$1.07',
feeInSecondaryCurrency: '0.000105 ETH', feeInSecondaryCurrency: '0.00042 ETH',
timeEstimate: '~13 min 12 sec', timeEstimate: '~1 min',
priceInHexWei: '0x12a05f200', priceInHexWei: '0x4a817c800',
}, },
], ],
mockState: { mockState: {
@ -177,24 +177,24 @@ describe('custom-gas selectors', () => {
const tests = [ const tests = [
{ {
expectedResult: [ expectedResult: [
{
feeInSecondaryCurrency: '$0.54',
feeInPrimaryCurrency: '0.0021 ETH',
labelKey: 'fastest',
priceInHexWei: '0x174876e800',
},
{
feeInSecondaryCurrency: '$0.27',
feeInPrimaryCurrency: '0.00105 ETH',
labelKey: 'fast',
priceInHexWei: '0xba43b7400',
},
{ {
feeInSecondaryCurrency: '$0.13', feeInSecondaryCurrency: '$0.13',
feeInPrimaryCurrency: '0.00052 ETH', feeInPrimaryCurrency: '0.00052 ETH',
labelKey: 'slow', labelKey: 'slow',
priceInHexWei: '0x5d21dba00', priceInHexWei: '0x5d21dba00',
}, },
{
feeInSecondaryCurrency: '$0.27',
feeInPrimaryCurrency: '0.00105 ETH',
labelKey: 'average',
priceInHexWei: '0xba43b7400',
},
{
feeInSecondaryCurrency: '$0.54',
feeInPrimaryCurrency: '0.0021 ETH',
labelKey: 'fast',
priceInHexWei: '0x174876e800',
},
], ],
mockState: { mockState: {
metamask: { metamask: {
@ -219,24 +219,24 @@ describe('custom-gas selectors', () => {
}, },
{ {
expectedResult: [ expectedResult: [
{
feeInSecondaryCurrency: '$10.74',
feeInPrimaryCurrency: '0.0042 ETH',
labelKey: 'fastest',
priceInHexWei: '0x2e90edd000',
},
{
feeInSecondaryCurrency: '$5.37',
feeInPrimaryCurrency: '0.0021 ETH',
labelKey: 'fast',
priceInHexWei: '0x174876e800',
},
{ {
feeInSecondaryCurrency: '$2.68', feeInSecondaryCurrency: '$2.68',
feeInPrimaryCurrency: '0.00105 ETH', feeInPrimaryCurrency: '0.00105 ETH',
labelKey: 'slow', labelKey: 'slow',
priceInHexWei: '0xba43b7400', priceInHexWei: '0xba43b7400',
}, },
{
feeInSecondaryCurrency: '$5.37',
feeInPrimaryCurrency: '0.0021 ETH',
labelKey: 'average',
priceInHexWei: '0x174876e800',
},
{
feeInSecondaryCurrency: '$10.74',
feeInPrimaryCurrency: '0.0042 ETH',
labelKey: 'fast',
priceInHexWei: '0x2e90edd000',
},
], ],
mockState: { mockState: {
metamask: { metamask: {