7cf5c1f6fe
- For the active swap, switch from polling to websocket. The returned data is now the Charge data from the commerce, so some parsing will be required. - Allow the user to send other coins that the commerce supports. - Only save the 'chargeCode' to the wallet. The other data can be repopulated from this. - Store the receipt currency. I'm not sure if the commerce supports sending bits from various coins. Take the coin that came with the 'COMPLETED' message for now. - Fix 'lbc' calculation to match IAPI side. - Allow users to see full detauls from "View Past Swaps". - String cleanup - GUI cleanup.
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
// @flow
|
|
import * as ACTIONS from 'constants/action_types';
|
|
import { selectPrefsReady } from 'redux/selectors/sync';
|
|
import { doAlertWaitingForSync } from 'redux/actions/app';
|
|
import { Lbryio } from 'lbryinc';
|
|
|
|
export const doAddCoinSwap = (coinSwapInfo: CoinSwapInfo) => (dispatch: Dispatch, getState: GetState) => {
|
|
const state = getState();
|
|
const ready = selectPrefsReady(state);
|
|
|
|
if (!ready) {
|
|
return dispatch(doAlertWaitingForSync());
|
|
}
|
|
|
|
dispatch({
|
|
type: ACTIONS.ADD_COIN_SWAP,
|
|
data: coinSwapInfo,
|
|
});
|
|
};
|
|
|
|
export const doRemoveCoinSwap = (chargeCode: string) => (dispatch: Dispatch, getState: GetState) => {
|
|
const state = getState();
|
|
const ready = selectPrefsReady(state);
|
|
|
|
if (!ready) {
|
|
return dispatch(doAlertWaitingForSync());
|
|
}
|
|
|
|
dispatch({
|
|
type: ACTIONS.REMOVE_COIN_SWAP,
|
|
data: {
|
|
chargeCode,
|
|
},
|
|
});
|
|
};
|
|
|
|
export const doQueryCoinSwapStatus = (chargeCode: string) => (dispatch: Dispatch, getState: GetState) => {
|
|
Lbryio.call('btc', 'status', { charge_code: chargeCode }).then((response) => {
|
|
dispatch({
|
|
type: ACTIONS.COIN_SWAP_STATUS_RECEIVED,
|
|
data: response,
|
|
});
|
|
});
|
|
};
|