aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux/reducer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src/redux/reducer.ts')
-rw-r--r--packages/instant/src/redux/reducer.ts31
1 files changed, 25 insertions, 6 deletions
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 2d50dd4b9..1538621a5 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -1,14 +1,19 @@
-import { BuyQuote } from '@0x/asset-buyer';
+import { AssetBuyer, BuyQuote } from '@0x/asset-buyer';
+import { ObjectMap } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
-import { zrxAssetData } from '../constants';
-import { AsyncProcessState, DisplayStatus } from '../types';
+import { assetMetaDataMap } from '../data/asset_meta_data_map';
+import { Asset, AssetMetaData, AsyncProcessState, DisplayStatus, Network } from '../types';
+import { assetUtils } from '../util/asset';
import { Action, ActionTypes } from './actions';
export interface State {
- selectedAssetData?: string;
+ network: Network;
+ assetBuyer?: AssetBuyer;
+ assetMetaDataMap: ObjectMap<AssetMetaData>;
+ selectedAsset?: Asset;
selectedAssetAmount?: BigNumber;
buyOrderState: AsyncProcessState;
ethUsdPrice?: BigNumber;
@@ -19,9 +24,9 @@ export interface State {
}
export const INITIAL_STATE: State = {
- // TODO: Remove hardcoded zrxAssetData
- selectedAssetData: zrxAssetData,
+ network: Network.Mainnet,
selectedAssetAmount: undefined,
+ assetMetaDataMap,
buyOrderState: AsyncProcessState.NONE,
ethUsdPrice: undefined,
latestBuyQuote: undefined,
@@ -82,6 +87,20 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
latestError: undefined,
latestErrorDisplay: DisplayStatus.Hidden,
};
+ case ActionTypes.UPDATE_SELECTED_ASSET:
+ const newSelectedAssetData = action.data;
+ let newSelectedAsset: Asset | undefined;
+ if (!_.isUndefined(newSelectedAssetData)) {
+ newSelectedAsset = assetUtils.createAssetFromAssetData(
+ newSelectedAssetData,
+ state.assetMetaDataMap,
+ state.network,
+ );
+ }
+ return {
+ ...state,
+ selectedAsset: newSelectedAsset,
+ };
default:
return state;
}