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

61 lines
1.1 KiB
JavaScript
Raw Normal View History

import { cloneDeep } from 'lodash';
import {
RESET_CUSTOM_DATA,
SET_CUSTOM_GAS_LIMIT,
SET_CUSTOM_GAS_PRICE,
} from './gas-action-constants';
const initState = {
customData: {
price: null,
limit: null,
},
};
// Reducer
2020-11-03 00:41:28 +01:00
export default function reducer(state = initState, action) {
switch (action.type) {
case SET_CUSTOM_GAS_PRICE:
return {
...state,
customData: {
...state.customData,
price: action.value,
},
};
case SET_CUSTOM_GAS_LIMIT:
return {
...state,
customData: {
...state.customData,
limit: action.value,
},
};
case RESET_CUSTOM_DATA:
return {
...state,
2020-07-08 22:17:53 +02:00
customData: cloneDeep(initState.customData),
};
default:
return state;
}
}
2020-11-03 00:41:28 +01:00
export function setCustomGasPrice(newPrice) {
return {
type: SET_CUSTOM_GAS_PRICE,
value: newPrice,
};
}
2020-11-03 00:41:28 +01:00
export function setCustomGasLimit(newLimit) {
return {
type: SET_CUSTOM_GAS_LIMIT,
value: newLimit,
};
}
2020-11-03 00:41:28 +01:00
export function resetCustomData() {
return { type: RESET_CUSTOM_DATA };
}