aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-01 00:14:50 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-01 00:14:50 +0800
commitd6755472087af76982779728db7424b1171a1b47 (patch)
tree8b9d8b10f1e4dd6ce6aacc02e27a2845414c5cdc /packages/instant/src/containers
parentd938ba46061fc8d0682f356ea9aba16535466455 (diff)
downloaddexon-sol-tools-d6755472087af76982779728db7424b1171a1b47.tar
dexon-sol-tools-d6755472087af76982779728db7424b1171a1b47.tar.gz
dexon-sol-tools-d6755472087af76982779728db7424b1171a1b47.tar.bz2
dexon-sol-tools-d6755472087af76982779728db7424b1171a1b47.tar.lz
dexon-sol-tools-d6755472087af76982779728db7424b1171a1b47.tar.xz
dexon-sol-tools-d6755472087af76982779728db7424b1171a1b47.tar.zst
dexon-sol-tools-d6755472087af76982779728db7424b1171a1b47.zip
Explicit actions for setting different order states
This allows us to dispatch updates with less syntax, and allows us to not have to send in progress info when setting failure and success
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts46
-rw-r--r--packages/instant/src/containers/selected_erc20_asset_amount_input.ts2
2 files changed, 8 insertions, 40 deletions
diff --git a/packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts b/packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts
index 247d57938..a94538ffc 100644
--- a/packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts
+++ b/packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts
@@ -22,8 +22,8 @@ interface ConnectedDispatch {
onValidationPending: (buyQuote: BuyQuote) => void;
onSignatureDenied: (buyQuote: BuyQuote) => void;
onBuyProcessing: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) => void;
- onBuySuccess: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) => void;
- onBuyFailure: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) => void;
+ onBuySuccess: (buyQuote: BuyQuote, txHash: string) => void;
+ onBuyFailure: (buyQuote: BuyQuote, txHash: string) => void;
onRetry: () => void;
onValidationFail: (buyQuote: BuyQuote, errorMessage: AssetBuyerError | ZeroExInstantError) => void;
}
@@ -56,52 +56,20 @@ const mapDispatchToProps = (
ownProps: SelectedAssetBuyOrderStateButtons,
): ConnectedDispatch => ({
onValidationPending: (buyQuote: BuyQuote) => {
- const newOrderState: OrderState = { processState: OrderProcessState.VALIDATING };
- dispatch(actions.updateBuyOrderState(newOrderState));
+ dispatch(actions.setBuyOrderStateValidating());
},
onBuyProcessing: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) => {
- const newOrderState: OrderState = {
- processState: OrderProcessState.PROCESSING,
- txHash,
- progress: {
- startTimeUnix,
- expectedEndTimeUnix,
- ended: false,
- },
- };
- dispatch(actions.updateBuyOrderState(newOrderState));
+ dispatch(actions.setBuyOrderStateProcessing(txHash, startTimeUnix, expectedEndTimeUnix));
},
- onBuySuccess: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- dispatch(
- actions.updateBuyOrderState({
- processState: OrderProcessState.SUCCESS,
- txHash,
- progress: {
- startTimeUnix,
- expectedEndTimeUnix,
- ended: true,
- },
- }),
- ),
- onBuyFailure: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- dispatch(
- actions.updateBuyOrderState({
- processState: OrderProcessState.FAILURE,
- txHash,
- progress: {
- startTimeUnix,
- expectedEndTimeUnix,
- ended: true,
- },
- }),
- ),
+ onBuySuccess: (buyQuote: BuyQuote, txHash: string) => dispatch(actions.setBuyOrderStateSuccess(txHash)),
+ onBuyFailure: (buyQuote: BuyQuote, txHash: string) => dispatch(actions.setBuyOrderStateFailure(txHash)),
onSignatureDenied: () => {
dispatch(actions.resetAmount());
const errorMessage = 'You denied this transaction';
errorFlasher.flashNewErrorMessage(dispatch, errorMessage);
},
onValidationFail: (buyQuote, error) => {
- dispatch(actions.updateBuyOrderState({ processState: OrderProcessState.NONE }));
+ dispatch(actions.setBuyOrderStateNone());
if (error === ZeroExInstantError.InsufficientETH) {
const errorMessage = "You don't have enough ETH";
errorFlasher.flashNewErrorMessage(dispatch, errorMessage);
diff --git a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
index 4767b15d4..c0245f721 100644
--- a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
+++ b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
@@ -113,7 +113,7 @@ const mapDispatchToProps = (
// invalidate the last buy quote.
dispatch(actions.updateLatestBuyQuote(undefined));
// reset our buy state
- dispatch(actions.updateBuyOrderState({ processState: OrderProcessState.NONE }));
+ dispatch(actions.setBuyOrderStateNone());
if (!_.isUndefined(value) && !_.isUndefined(asset) && !_.isUndefined(assetBuyer)) {
// even if it's debounced, give them the illusion it's loading