mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Remove unused state from Redux gas
slice (#9975)
The `errors` and `total` state has been removed from the `gas` slice, along with related functions. It appears to have been unused for a long time, though I'm not exactly sure as of when.
This commit is contained in:
parent
703a063ad1
commit
cce690c3d8
@ -14,8 +14,6 @@ const {
|
||||
setBasicGasEstimateData,
|
||||
setCustomGasPrice,
|
||||
setCustomGasLimit,
|
||||
setCustomGasTotal,
|
||||
setCustomGasErrors,
|
||||
resetCustomGasState,
|
||||
fetchBasicGasEstimates,
|
||||
} = GasDuck
|
||||
@ -68,7 +66,6 @@ describe('Gas Duck', function () {
|
||||
safeLow: null,
|
||||
},
|
||||
basicEstimateIsLoading: true,
|
||||
errors: {},
|
||||
basicPriceEstimatesLastRetrieved: 0,
|
||||
}
|
||||
const BASIC_GAS_ESTIMATE_LOADING_FINISHED =
|
||||
@ -77,10 +74,8 @@ describe('Gas Duck', function () {
|
||||
'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_STARTED'
|
||||
const RESET_CUSTOM_GAS_STATE = 'metamask/gas/RESET_CUSTOM_GAS_STATE'
|
||||
const SET_BASIC_GAS_ESTIMATE_DATA = 'metamask/gas/SET_BASIC_GAS_ESTIMATE_DATA'
|
||||
const SET_CUSTOM_GAS_ERRORS = 'metamask/gas/SET_CUSTOM_GAS_ERRORS'
|
||||
const SET_CUSTOM_GAS_LIMIT = 'metamask/gas/SET_CUSTOM_GAS_LIMIT'
|
||||
const SET_CUSTOM_GAS_PRICE = 'metamask/gas/SET_CUSTOM_GAS_PRICE'
|
||||
const SET_CUSTOM_GAS_TOTAL = 'metamask/gas/SET_CUSTOM_GAS_TOTAL'
|
||||
const SET_BASIC_PRICE_ESTIMATES_LAST_RETRIEVED =
|
||||
'metamask/gas/SET_BASIC_PRICE_ESTIMATES_LAST_RETRIEVED'
|
||||
|
||||
@ -143,26 +138,6 @@ describe('Gas Duck', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it('should set customData.total when receiving a SET_CUSTOM_GAS_TOTAL action', function () {
|
||||
assert.deepStrictEqual(
|
||||
GasReducer(mockState, {
|
||||
type: SET_CUSTOM_GAS_TOTAL,
|
||||
value: 10000,
|
||||
}),
|
||||
{ customData: { total: 10000 }, ...mockState },
|
||||
)
|
||||
})
|
||||
|
||||
it('should set errors when receiving a SET_CUSTOM_GAS_ERRORS action', function () {
|
||||
assert.deepStrictEqual(
|
||||
GasReducer(mockState, {
|
||||
type: SET_CUSTOM_GAS_ERRORS,
|
||||
value: { someError: 'error_error' },
|
||||
}),
|
||||
{ errors: { someError: 'error_error' }, ...mockState },
|
||||
)
|
||||
})
|
||||
|
||||
it('should return the initial state in response to a RESET_CUSTOM_GAS_STATE action', function () {
|
||||
assert.deepStrictEqual(
|
||||
GasReducer(mockState, { type: RESET_CUSTOM_GAS_STATE }),
|
||||
@ -318,24 +293,6 @@ describe('Gas Duck', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('setCustomGasTotal', function () {
|
||||
it('should create the correct action', function () {
|
||||
assert.deepStrictEqual(setCustomGasTotal('mockCustomGasTotal'), {
|
||||
type: SET_CUSTOM_GAS_TOTAL,
|
||||
value: 'mockCustomGasTotal',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('setCustomGasErrors', function () {
|
||||
it('should create the correct action', function () {
|
||||
assert.deepStrictEqual(setCustomGasErrors('mockErrorObject'), {
|
||||
type: SET_CUSTOM_GAS_ERRORS,
|
||||
value: 'mockErrorObject',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('resetCustomGasState', function () {
|
||||
it('should create the correct action', function () {
|
||||
assert.deepStrictEqual(resetCustomGasState(), {
|
||||
|
@ -12,10 +12,8 @@ const BASIC_GAS_ESTIMATE_LOADING_STARTED =
|
||||
const RESET_CUSTOM_GAS_STATE = 'metamask/gas/RESET_CUSTOM_GAS_STATE'
|
||||
const RESET_CUSTOM_DATA = 'metamask/gas/RESET_CUSTOM_DATA'
|
||||
const SET_BASIC_GAS_ESTIMATE_DATA = 'metamask/gas/SET_BASIC_GAS_ESTIMATE_DATA'
|
||||
const SET_CUSTOM_GAS_ERRORS = 'metamask/gas/SET_CUSTOM_GAS_ERRORS'
|
||||
const SET_CUSTOM_GAS_LIMIT = 'metamask/gas/SET_CUSTOM_GAS_LIMIT'
|
||||
const SET_CUSTOM_GAS_PRICE = 'metamask/gas/SET_CUSTOM_GAS_PRICE'
|
||||
const SET_CUSTOM_GAS_TOTAL = 'metamask/gas/SET_CUSTOM_GAS_TOTAL'
|
||||
const SET_BASIC_PRICE_ESTIMATES_LAST_RETRIEVED =
|
||||
'metamask/gas/SET_BASIC_PRICE_ESTIMATES_LAST_RETRIEVED'
|
||||
|
||||
@ -31,7 +29,6 @@ const initState = {
|
||||
},
|
||||
basicEstimateIsLoading: true,
|
||||
basicPriceEstimatesLastRetrieved: 0,
|
||||
errors: {},
|
||||
}
|
||||
|
||||
// Reducer
|
||||
@ -68,22 +65,6 @@ export default function reducer(state = initState, action) {
|
||||
limit: action.value,
|
||||
},
|
||||
}
|
||||
case SET_CUSTOM_GAS_TOTAL:
|
||||
return {
|
||||
...state,
|
||||
customData: {
|
||||
...state.customData,
|
||||
total: action.value,
|
||||
},
|
||||
}
|
||||
case SET_CUSTOM_GAS_ERRORS:
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
...action.value,
|
||||
},
|
||||
}
|
||||
case SET_BASIC_PRICE_ESTIMATES_LAST_RETRIEVED:
|
||||
return {
|
||||
...state,
|
||||
@ -211,20 +192,6 @@ export function setCustomGasLimit(newLimit) {
|
||||
}
|
||||
}
|
||||
|
||||
export function setCustomGasTotal(newTotal) {
|
||||
return {
|
||||
type: SET_CUSTOM_GAS_TOTAL,
|
||||
value: newTotal,
|
||||
}
|
||||
}
|
||||
|
||||
export function setCustomGasErrors(newErrors) {
|
||||
return {
|
||||
type: SET_CUSTOM_GAS_ERRORS,
|
||||
value: newErrors,
|
||||
}
|
||||
}
|
||||
|
||||
export function setBasicPriceEstimatesLastRetrieved(retrievalTime) {
|
||||
return {
|
||||
type: SET_BASIC_PRICE_ESTIMATES_LAST_RETRIEVED,
|
||||
|
@ -13,10 +13,6 @@ import { getCurrentCurrency, getIsMainnet, getPreferences } from '.'
|
||||
|
||||
const NUMBER_OF_DECIMALS_SM_BTNS = 5
|
||||
|
||||
export function getCustomGasErrors(state) {
|
||||
return state.gas.errors
|
||||
}
|
||||
|
||||
export function getCustomGasLimit(state) {
|
||||
return state.gas.customData.limit
|
||||
}
|
||||
@ -25,10 +21,6 @@ export function getCustomGasPrice(state) {
|
||||
return state.gas.customData.price
|
||||
}
|
||||
|
||||
export function getCustomGasTotal(state) {
|
||||
return state.gas.customData.total
|
||||
}
|
||||
|
||||
export function getBasicGasEstimateLoadingStatus(state) {
|
||||
return state.gas.basicEstimateIsLoading
|
||||
}
|
||||
|
@ -2,10 +2,8 @@ import assert from 'assert'
|
||||
import proxyquire from 'proxyquire'
|
||||
|
||||
const {
|
||||
getCustomGasErrors,
|
||||
getCustomGasLimit,
|
||||
getCustomGasPrice,
|
||||
getCustomGasTotal,
|
||||
getRenderableBasicEstimateData,
|
||||
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
||||
} = proxyquire('../custom-gas', {})
|
||||
@ -25,20 +23,6 @@ describe('custom-gas selectors', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getCustomGasTotal()', function () {
|
||||
it('should return gas.customData.total', function () {
|
||||
const mockState = { gas: { customData: { total: 'mockTotal' } } }
|
||||
assert.strictEqual(getCustomGasTotal(mockState), 'mockTotal')
|
||||
})
|
||||
})
|
||||
|
||||
describe('getCustomGasErrors()', function () {
|
||||
it('should return gas.errors', function () {
|
||||
const mockState = { gas: { errors: 'mockErrors' } }
|
||||
assert.strictEqual(getCustomGasErrors(mockState), 'mockErrors')
|
||||
})
|
||||
})
|
||||
|
||||
describe('getRenderableBasicEstimateData()', function () {
|
||||
const tests = [
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user