aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-13 02:00:36 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-13 02:00:36 +0800
commitf3391e1250767eb9ef7a74f78eded38fa3c94586 (patch)
treee25eeb3652227ea68f5b77db82755765298cb22a /packages/instant/src/containers
parent09c5ae4e65f8fddd4504be041f27f9107d12df7d (diff)
downloaddexon-sol-tools-f3391e1250767eb9ef7a74f78eded38fa3c94586.tar
dexon-sol-tools-f3391e1250767eb9ef7a74f78eded38fa3c94586.tar.gz
dexon-sol-tools-f3391e1250767eb9ef7a74f78eded38fa3c94586.tar.bz2
dexon-sol-tools-f3391e1250767eb9ef7a74f78eded38fa3c94586.tar.lz
dexon-sol-tools-f3391e1250767eb9ef7a74f78eded38fa3c94586.tar.xz
dexon-sol-tools-f3391e1250767eb9ef7a74f78eded38fa3c94586.tar.zst
dexon-sol-tools-f3391e1250767eb9ef7a74f78eded38fa3c94586.zip
feat: make redux actions type-sage
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/selected_asset_amount_input.ts12
-rw-r--r--packages/instant/src/containers/selected_asset_buy_button.ts16
2 files changed, 13 insertions, 15 deletions
diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts
index fa675b385..9e3063ecc 100644
--- a/packages/instant/src/containers/selected_asset_amount_input.ts
+++ b/packages/instant/src/containers/selected_asset_amount_input.ts
@@ -6,9 +6,10 @@ import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import { zrxContractAddress, zrxDecimals } from '../constants';
+import { Action, actions } from '../redux/actions';
import { State } from '../redux/reducer';
import { ColorOption } from '../style/theme';
-import { Action, ActionTypes, AsyncProcessState } from '../types';
+import { AsyncProcessState } from '../types';
import { assetBuyer } from '../util/asset_buyer';
import { AmountInput } from '../components/amount_input';
@@ -38,7 +39,7 @@ const updateBuyQuote = async (dispatch: Dispatch<Action>, assetAmount?: BigNumbe
const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, zrxDecimals);
const newBuyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(zrxContractAddress, baseUnitValue);
// invalidate the last buy quote.
- dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: newBuyQuote });
+ dispatch(actions.updateLatestBuyQuote(newBuyQuote));
};
const debouncedUpdateBuyQuote = _.debounce(updateBuyQuote, 200, { trailing: true });
@@ -46,11 +47,12 @@ const debouncedUpdateBuyQuote = _.debounce(updateBuyQuote, 200, { trailing: true
const mapDispatchToProps = (dispatch: Dispatch<Action>): ConnectedDispatch => ({
onChange: async value => {
// Update the input
- dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, data: value });
+ dispatch(actions.updateSelectedAssetAmount(value));
// invalidate the last buy quote.
- dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: undefined });
+ dispatch(actions.updateLatestBuyQuote(undefined));
// reset our buy state
- dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.NONE });
+ dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.NONE));
+ // tslint:disable-next-line:no-floating-promises
debouncedUpdateBuyQuote(dispatch, value);
},
});
diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts
index 678c7e445..4cbaf5537 100644
--- a/packages/instant/src/containers/selected_asset_buy_button.ts
+++ b/packages/instant/src/containers/selected_asset_buy_button.ts
@@ -4,12 +4,11 @@ import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
+import { Action, actions } from '../redux/actions';
import { State } from '../redux/reducer';
-import { Action, ActionTypes, AsyncProcessState } from '../types';
-import { assetBuyer } from '../util/asset_buyer';
-import { web3Wrapper } from '../util/web3_wrapper';
+import { AsyncProcessState } from '../types';
-import { BuyButton, BuyButtonProps } from '../components/buy_button';
+import { BuyButton } from '../components/buy_button';
export interface SelectedAssetBuyButtonProps {}
@@ -45,12 +44,9 @@ const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps):
});
const mapDispatchToProps = (dispatch: Dispatch<Action>, ownProps: SelectedAssetBuyButtonProps): ConnectedDispatch => ({
- onClick: buyQuote =>
- dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.PENDING }),
- onBuySuccess: buyQuote =>
- dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.SUCCESS }),
- onBuyFailure: buyQuote =>
- dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.FAILURE }),
+ onClick: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.PENDING)),
+ onBuySuccess: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.SUCCESS)),
+ onBuyFailure: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.FAILURE)),
});
export const SelectedAssetBuyButton: React.ComponentClass<SelectedAssetBuyButtonProps> = connect(