Merge pull request #1739 from lbryio/shapeshift-fix

Handle LBC unavailable error from ShapeShift without breaking the app
This commit is contained in:
Sean Yesmunt 2018-07-09 11:30:35 -04:00 committed by GitHub
commit 5cd70d5680
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 6 deletions

View file

@ -56,7 +56,7 @@ class ActiveShapeShift extends React.PureComponent<Props> {
} }
} }
continousFetch: ?number; continousFetch: ?IntervalID;
render() { render() {
const { const {
@ -135,8 +135,8 @@ class ActiveShapeShift extends React.PureComponent<Props> {
{shiftState === statuses.NO_DEPOSITS && {shiftState === statuses.NO_DEPOSITS &&
shiftReturnAddress && ( shiftReturnAddress && (
<div className="help"> <div className="help">
If the transaction doesn't go through, ShapeShift will return your {shiftCoinType}{' '} {__("If the transaction doesn't go through, ShapeShift will return your")}{' '}
back to {shiftReturnAddress} {shiftCoinType} {__('back to')} {shiftReturnAddress}
</div> </div>
)} )}
</div> </div>

View file

@ -1,3 +1,5 @@
export const NO_DEPOSITS = 'no_deposits'; export const NO_DEPOSITS = 'no_deposits';
export const RECEIVED = 'received'; export const RECEIVED = 'received';
export const COMPLETE = 'complete'; export const COMPLETE = 'complete';
export const AVAILABLE = 'available';
export const UNAVAILABLE = 'unavailable';

View file

@ -1,5 +1,6 @@
// @flow // @flow
import Promise from 'bluebird'; import Promise from 'bluebird';
import * as SHAPESHIFT_STATUSES from 'constants/shape_shift';
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
import { coinRegexPatterns } from 'util/shape_shift'; import { coinRegexPatterns } from 'util/shape_shift';
import type { import type {
@ -65,9 +66,15 @@ export const shapeShiftInit = () => (dispatch: Dispatch): ThunkAction => {
return shapeShift return shapeShift
.coinsAsync() .coinsAsync()
.then(coinData => { .then(coinData => {
if (coinData.LBC.status === SHAPESHIFT_STATUSES.UNAVAILABLE) {
return dispatch({
type: ACTIONS.GET_SUPPORTED_COINS_FAIL,
});
}
let supportedCoins = []; let supportedCoins = [];
Object.keys(coinData).forEach(symbol => { Object.keys(coinData).forEach(symbol => {
if (coinData[symbol].status === 'available') { if (coinData[symbol].status === SHAPESHIFT_STATUSES.UNAVAILABLE) {
supportedCoins.push(coinData[symbol]); supportedCoins.push(coinData[symbol]);
} }
}); });
@ -81,7 +88,7 @@ export const shapeShiftInit = () => (dispatch: Dispatch): ThunkAction => {
type: ACTIONS.GET_SUPPORTED_COINS_SUCCESS, type: ACTIONS.GET_SUPPORTED_COINS_SUCCESS,
data: supportedCoins, data: supportedCoins,
}); });
dispatch(getCoinStats(supportedCoins[0])); return dispatch(getCoinStats(supportedCoins[0]));
}) })
.catch(err => dispatch({ type: ACTIONS.GET_SUPPORTED_COINS_FAIL, data: err })); .catch(err => dispatch({ type: ACTIONS.GET_SUPPORTED_COINS_FAIL, data: err }));
}; };

View file

@ -117,7 +117,7 @@ export default handleActions(
[ACTIONS.GET_SUPPORTED_COINS_FAIL]: (state: ShapeShiftState): ShapeShiftState => ({ [ACTIONS.GET_SUPPORTED_COINS_FAIL]: (state: ShapeShiftState): ShapeShiftState => ({
...state, ...state,
loading: false, loading: false,
error: 'Error getting available coins', error: __('There was an error. Please try again later.'),
}), }),
[ACTIONS.GET_COIN_STATS_START]: ( [ACTIONS.GET_COIN_STATS_START]: (