aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux/reducer.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-03 05:38:18 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-03 05:38:18 +0800
commitd5521ea5e09f5a42471335b856989751b90184dc (patch)
treec612141ef0b2101fdfe117d5944c143ae74e7c52 /packages/instant/src/redux/reducer.ts
parentcc4ccda6232af470b96950a37fa1d0f4b4ef7f3a (diff)
parent6a57a7b5be151114bb06c171560976b09a8c4aa1 (diff)
downloaddexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.tar
dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.tar.gz
dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.tar.bz2
dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.tar.lz
dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.tar.xz
dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.tar.zst
dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.zip
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/maker-asset-datas-interface
Diffstat (limited to 'packages/instant/src/redux/reducer.ts')
-rw-r--r--packages/instant/src/redux/reducer.ts58
1 files changed, 56 insertions, 2 deletions
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 20d927561..179c5902e 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -6,6 +6,7 @@ import * as _ from 'lodash';
import { assetMetaDataMap } from '../data/asset_meta_data_map';
import {
+ AffiliateInfo,
Asset,
AssetMetaData,
AsyncProcessState,
@@ -31,6 +32,7 @@ export interface State {
quoteRequestState: AsyncProcessState;
latestErrorMessage?: string;
latestErrorDisplayStatus: DisplayStatus;
+ affiliateInfo?: AffiliateInfo;
}
export const INITIAL_STATE: State = {
@@ -44,6 +46,7 @@ export const INITIAL_STATE: State = {
latestErrorMessage: undefined,
latestErrorDisplayStatus: DisplayStatus.Hidden,
quoteRequestState: AsyncProcessState.NONE,
+ affiliateInfo: undefined,
};
export const reducer = (state: State = INITIAL_STATE, action: Action): State => {
@@ -84,11 +87,62 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.FAILURE,
};
- case ActionTypes.UPDATE_BUY_ORDER_STATE:
+ case ActionTypes.SET_BUY_ORDER_STATE_NONE:
return {
...state,
- buyOrderState: action.data,
+ buyOrderState: { processState: OrderProcessState.NONE },
+ };
+ case ActionTypes.SET_BUY_ORDER_STATE_VALIDATING:
+ return {
+ ...state,
+ buyOrderState: { processState: OrderProcessState.VALIDATING },
};
+ case ActionTypes.SET_BUY_ORDER_STATE_PROCESSING:
+ const processingData = action.data;
+ const { startTimeUnix, expectedEndTimeUnix } = processingData;
+ return {
+ ...state,
+ buyOrderState: {
+ processState: OrderProcessState.PROCESSING,
+ txHash: processingData.txHash,
+ progress: {
+ startTimeUnix,
+ expectedEndTimeUnix,
+ },
+ },
+ };
+ case ActionTypes.SET_BUY_ORDER_STATE_FAILURE:
+ const failureTxHash = action.data;
+ if ('txHash' in state.buyOrderState) {
+ if (state.buyOrderState.txHash === failureTxHash) {
+ const { txHash, progress } = state.buyOrderState;
+ return {
+ ...state,
+ buyOrderState: {
+ processState: OrderProcessState.FAILURE,
+ txHash,
+ progress,
+ },
+ };
+ }
+ }
+ return state;
+ case ActionTypes.SET_BUY_ORDER_STATE_SUCCESS:
+ const successTxHash = action.data;
+ if ('txHash' in state.buyOrderState) {
+ if (state.buyOrderState.txHash === successTxHash) {
+ const { txHash, progress } = state.buyOrderState;
+ return {
+ ...state,
+ buyOrderState: {
+ processState: OrderProcessState.SUCCESS,
+ txHash,
+ progress,
+ },
+ };
+ }
+ }
+ return state;
case ActionTypes.SET_ERROR_MESSAGE:
return {
...state,