You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.7 KiB
80 lines
1.7 KiB
7 years ago
|
// Actions
|
||
4 years ago
|
const OPEN_TO_DROPDOWN = 'metamask/send/OPEN_TO_DROPDOWN';
|
||
|
const CLOSE_TO_DROPDOWN = 'metamask/send/CLOSE_TO_DROPDOWN';
|
||
|
const UPDATE_SEND_ERRORS = 'metamask/send/UPDATE_SEND_ERRORS';
|
||
|
const RESET_SEND_STATE = 'metamask/send/RESET_SEND_STATE';
|
||
|
const SHOW_GAS_BUTTON_GROUP = 'metamask/send/SHOW_GAS_BUTTON_GROUP';
|
||
|
const HIDE_GAS_BUTTON_GROUP = 'metamask/send/HIDE_GAS_BUTTON_GROUP';
|
||
7 years ago
|
|
||
|
const initState = {
|
||
|
toDropdownOpen: false,
|
||
6 years ago
|
gasButtonGroupShown: true,
|
||
7 years ago
|
errors: {},
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
|
// Reducer
|
||
4 years ago
|
export default function reducer(state = initState, action) {
|
||
7 years ago
|
switch (action.type) {
|
||
|
case OPEN_TO_DROPDOWN:
|
||
5 years ago
|
return {
|
||
5 years ago
|
...state,
|
||
7 years ago
|
toDropdownOpen: true,
|
||
4 years ago
|
};
|
||
7 years ago
|
case CLOSE_TO_DROPDOWN:
|
||
5 years ago
|
return {
|
||
5 years ago
|
...state,
|
||
7 years ago
|
toDropdownOpen: false,
|
||
4 years ago
|
};
|
||
7 years ago
|
case UPDATE_SEND_ERRORS:
|
||
5 years ago
|
return {
|
||
5 years ago
|
...state,
|
||
7 years ago
|
errors: {
|
||
5 years ago
|
...state.errors,
|
||
7 years ago
|
...action.value,
|
||
|
},
|
||
4 years ago
|
};
|
||
6 years ago
|
case SHOW_GAS_BUTTON_GROUP:
|
||
5 years ago
|
return {
|
||
5 years ago
|
...state,
|
||
6 years ago
|
gasButtonGroupShown: true,
|
||
4 years ago
|
};
|
||
6 years ago
|
case HIDE_GAS_BUTTON_GROUP:
|
||
5 years ago
|
return {
|
||
5 years ago
|
...state,
|
||
6 years ago
|
gasButtonGroupShown: false,
|
||
4 years ago
|
};
|
||
7 years ago
|
case RESET_SEND_STATE:
|
||
4 years ago
|
return { ...initState };
|
||
7 years ago
|
default:
|
||
4 years ago
|
return state;
|
||
7 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// Action Creators
|
||
4 years ago
|
export function openToDropdown() {
|
||
4 years ago
|
return { type: OPEN_TO_DROPDOWN };
|
||
7 years ago
|
}
|
||
|
|
||
4 years ago
|
export function closeToDropdown() {
|
||
4 years ago
|
return { type: CLOSE_TO_DROPDOWN };
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
4 years ago
|
export function showGasButtonGroup() {
|
||
4 years ago
|
return { type: SHOW_GAS_BUTTON_GROUP };
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
export function hideGasButtonGroup() {
|
||
4 years ago
|
return { type: HIDE_GAS_BUTTON_GROUP };
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
export function updateSendErrors(errorObject) {
|
||
7 years ago
|
return {
|
||
|
type: UPDATE_SEND_ERRORS,
|
||
|
value: errorObject,
|
||
4 years ago
|
};
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
4 years ago
|
export function resetSendState() {
|
||
4 years ago
|
return { type: RESET_SEND_STATE };
|
||
7 years ago
|
}
|