diff --git a/src/reducers/FiatRateReducer.js b/src/reducers/FiatRateReducer.js index fbccf087..dfd94760 100644 --- a/src/reducers/FiatRateReducer.js +++ b/src/reducers/FiatRateReducer.js @@ -7,7 +7,7 @@ import type { FiatRateAction } from 'services/CoingeckoService'; export type Fiat = { +network: string, - value: string, + rates: { [string]: number }, }; export const initialState: Array = []; @@ -15,12 +15,14 @@ export const initialState: Array = []; const update = (state: Array, action: FiatRateAction): Array => { 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, }, ]); }; diff --git a/src/services/CoingeckoService.js b/src/services/CoingeckoService.js index c5e6d216..f39bd0a7 100644 --- a/src/services/CoingeckoService.js +++ b/src/services/CoingeckoService.js @@ -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, }); } });