return rates for all currencies supported by goingecko

pull/448/head
slowbackspace 5 years ago
parent 4616ebeadc
commit d269f31af9

@ -7,7 +7,7 @@ import type { FiatRateAction } from 'services/CoingeckoService';
export type Fiat = {
+network: string,
value: string,
rates: { [string]: number },
};
export const initialState: Array<Fiat> = [];
@ -15,12 +15,14 @@ export const initialState: Array<Fiat> = [];
const update = (state: Array<Fiat>, action: FiatRateAction): Array<Fiat> => {
const affected = state.find(f => f.network === action.network);
const otherRates = state.filter(d => d !== affected);
const { network, rate } = action;
const { network, rates } = action;
Object.keys(rates).map(k => rates[k].toFixed(2));
return otherRates.concat([
{
network,
value: rate.toFixed(2),
rates,
},
]);
};

@ -19,9 +19,15 @@ export const RATE_UPDATE: 'rate__update' = 'rate__update';
export type FiatRateAction = {
type: typeof RATE_UPDATE,
network: string,
rate: number,
rates: { [string]: number },
};
// const getSupportedCurrencies = async () => {
// const url = 'https://api.coingecko.com/api/v3/simple/supported_vs_currencies';
// const res = await httpRequest(url, 'json');
// return res;
// };
const loadRateAction = (): AsyncAction => async (
dispatch: Dispatch,
getState: GetState
@ -41,7 +47,7 @@ const loadRateAction = (): AsyncAction => async (
dispatch({
type: RATE_UPDATE,
network: response.symbol,
rate: response.market_data.current_price.usd,
rates: response.market_data.current_price,
});
}
});

Loading…
Cancel
Save