aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux/async_data.ts
blob: 3fde2d2e5b10520adfb338889d187009ebca1f31 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { BigNumber } from '@0xproject/utils';

import { ActionTypes } from '../types';
import { coinbaseApi } from '../util/coinbase_api';

import { store } from './store';

export const asyncData = {
    fetchAndDispatchToStore: async () => {
        let ethUsdPriceStr = '0';
        try {
            ethUsdPriceStr = await coinbaseApi.getEthUsdPrice();
        } catch (e) {
            // ignore
        } finally {
            store.dispatch({
                type: ActionTypes.UPDATE_ETH_USD_PRICE,
                data: new BigNumber(ethUsdPriceStr),
            });
        }
    },
};