2021-03-25 12:24:49 +01:00
|
|
|
// @flow
|
|
|
|
import * as ACTIONS from 'constants/action_types';
|
|
|
|
import { selectPrefsReady } from 'redux/selectors/sync';
|
|
|
|
import { doAlertWaitingForSync } from 'redux/actions/app';
|
|
|
|
|
2021-04-04 09:10:55 +02:00
|
|
|
export const doAddCoinSwap = (coinSwap: CoinSwapInfo) => (dispatch: Dispatch, getState: GetState) => {
|
2021-03-25 12:24:49 +01:00
|
|
|
const state = getState();
|
|
|
|
const ready = selectPrefsReady(state);
|
|
|
|
|
|
|
|
if (!ready) {
|
|
|
|
return dispatch(doAlertWaitingForSync());
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
2021-04-04 09:10:55 +02:00
|
|
|
type: ACTIONS.ADD_COIN_SWAP,
|
2021-03-25 12:24:49 +01:00
|
|
|
data: {
|
2021-04-04 09:10:55 +02:00
|
|
|
coin: coinSwap.coin,
|
|
|
|
sendAddress: coinSwap.sendAddress,
|
|
|
|
sendAmount: coinSwap.sendAmount,
|
|
|
|
lbcAmount: coinSwap.lbcAmount,
|
2021-03-25 12:24:49 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-04-04 09:10:55 +02:00
|
|
|
export const doRemoveCoinSwap = (sendAddress: string) => (dispatch: Dispatch, getState: GetState) => {
|
2021-03-25 12:24:49 +01:00
|
|
|
const state = getState();
|
|
|
|
const ready = selectPrefsReady(state);
|
|
|
|
|
|
|
|
if (!ready) {
|
|
|
|
return dispatch(doAlertWaitingForSync());
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
2021-04-04 09:10:55 +02:00
|
|
|
type: ACTIONS.REMOVE_COIN_SWAP,
|
2021-03-25 12:24:49 +01:00
|
|
|
data: {
|
2021-04-04 09:10:55 +02:00
|
|
|
sendAddress,
|
2021-03-25 12:24:49 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|