aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/src/redux/async_data.ts7
-rw-r--r--packages/instant/src/util/coinbase_api.ts6
2 files changed, 8 insertions, 5 deletions
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts
index 3fde2d2e5..b368491f0 100644
--- a/packages/instant/src/redux/async_data.ts
+++ b/packages/instant/src/redux/async_data.ts
@@ -1,5 +1,6 @@
import { BigNumber } from '@0xproject/utils';
+import { BIG_NUMBER_ZERO } from '../constants';
import { ActionTypes } from '../types';
import { coinbaseApi } from '../util/coinbase_api';
@@ -7,15 +8,15 @@ import { store } from './store';
export const asyncData = {
fetchAndDispatchToStore: async () => {
- let ethUsdPriceStr = '0';
+ let ethUsdPrice = BIG_NUMBER_ZERO;
try {
- ethUsdPriceStr = await coinbaseApi.getEthUsdPrice();
+ ethUsdPrice = await coinbaseApi.getEthUsdPrice();
} catch (e) {
// ignore
} finally {
store.dispatch({
type: ActionTypes.UPDATE_ETH_USD_PRICE,
- data: new BigNumber(ethUsdPriceStr),
+ data: ethUsdPrice,
});
}
},
diff --git a/packages/instant/src/util/coinbase_api.ts b/packages/instant/src/util/coinbase_api.ts
index 63c8077da..94a5d3c80 100644
--- a/packages/instant/src/util/coinbase_api.ts
+++ b/packages/instant/src/util/coinbase_api.ts
@@ -1,8 +1,10 @@
+import { BigNumber } from '@0xproject/utils';
+
const baseEndpoint = 'https://api.coinbase.com/v2';
export const coinbaseApi = {
- getEthUsdPrice: async (): Promise<string> => {
+ getEthUsdPrice: async (): Promise<BigNumber> => {
const res = await fetch(`${baseEndpoint}/prices/ETH-USD/buy`);
const resJson = await res.json();
- return resJson.data.amount;
+ return new BigNumber(resJson.data.amount);
},
};