aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-26 09:57:30 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-26 09:57:30 +0800
commit30809e646be02025d6f9e9ed0ff214d9ace681c8 (patch)
tree2bd1446ac81a2319a672709ca8ef9cb2dd07c643 /packages/instant/src/containers
parentd5d99b9d2e3c793a95c68c1035246644b3ae80c6 (diff)
parent4a96dbe085004be49dbbaa435d4552a9c920d823 (diff)
downloaddexon-sol-tools-30809e646be02025d6f9e9ed0ff214d9ace681c8.tar
dexon-sol-tools-30809e646be02025d6f9e9ed0ff214d9ace681c8.tar.gz
dexon-sol-tools-30809e646be02025d6f9e9ed0ff214d9ace681c8.tar.bz2
dexon-sol-tools-30809e646be02025d6f9e9ed0ff214d9ace681c8.tar.lz
dexon-sol-tools-30809e646be02025d6f9e9ed0ff214d9ace681c8.tar.xz
dexon-sol-tools-30809e646be02025d6f9e9ed0ff214d9ace681c8.tar.zst
dexon-sol-tools-30809e646be02025d6f9e9ed0ff214d9ace681c8.zip
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/input-fees-rounding
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/selected_asset_buy_button.ts30
-rw-r--r--packages/instant/src/containers/selected_asset_buy_order_state_button.tsx4
-rw-r--r--packages/instant/src/containers/selected_asset_view_transaction_button.tsx10
-rw-r--r--packages/instant/src/containers/selected_erc20_asset_amount_input.ts4
4 files changed, 33 insertions, 15 deletions
diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts
index 71d2b8cf0..adcbd61bc 100644
--- a/packages/instant/src/containers/selected_asset_buy_button.ts
+++ b/packages/instant/src/containers/selected_asset_buy_button.ts
@@ -6,7 +6,7 @@ import { Dispatch } from 'redux';
import { Action, actions } from '../redux/actions';
import { State } from '../redux/reducer';
-import { AsyncProcessState } from '../types';
+import { OrderProcessState, OrderState } from '../types';
import { BuyButton } from '../components/buy_button';
@@ -18,9 +18,11 @@ interface ConnectedState {
}
interface ConnectedDispatch {
- onClick: (buyQuote: BuyQuote) => void;
- onBuySuccess: (buyQuote: BuyQuote, txnHash: string) => void;
- onBuyFailure: (buyQuote: BuyQuote) => void;
+ onAwaitingSignature: (buyQuote: BuyQuote) => void;
+ onSignatureDenied: (buyQuote: BuyQuote, error: Error) => void;
+ onBuyProcessing: (buyQuote: BuyQuote, txHash: string) => void;
+ onBuySuccess: (buyQuote: BuyQuote, txHash: string) => void;
+ onBuyFailure: (buyQuote: BuyQuote, txHash: string) => void;
}
const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps): ConnectedState => ({
@@ -29,10 +31,22 @@ const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps):
});
const mapDispatchToProps = (dispatch: Dispatch<Action>, ownProps: SelectedAssetBuyButtonProps): ConnectedDispatch => ({
- onClick: buyQuote => dispatch(actions.updateBuyOrderState({ processState: AsyncProcessState.PENDING })),
- onBuySuccess: (buyQuote: BuyQuote, txnHash: string) =>
- dispatch(actions.updateBuyOrderState({ processState: AsyncProcessState.SUCCESS, txnHash })),
- onBuyFailure: buyQuote => dispatch(actions.updateBuyOrderState({ processState: AsyncProcessState.FAILURE })),
+ onAwaitingSignature: (buyQuote: BuyQuote) => {
+ const newOrderState: OrderState = { processState: OrderProcessState.AWAITING_SIGNATURE };
+ dispatch(actions.updateBuyOrderState(newOrderState));
+ },
+ onBuyProcessing: (buyQuote: BuyQuote, txHash: string) => {
+ const newOrderState: OrderState = { processState: OrderProcessState.PROCESSING, txHash };
+ dispatch(actions.updateBuyOrderState(newOrderState));
+ },
+ onBuySuccess: (buyQuote: BuyQuote, txHash: string) =>
+ dispatch(actions.updateBuyOrderState({ processState: OrderProcessState.SUCCESS, txHash })),
+ onBuyFailure: (buyQuote: BuyQuote, txHash: string) =>
+ dispatch(actions.updateBuyOrderState({ processState: OrderProcessState.FAILURE, txHash })),
+ onSignatureDenied: (buyQuote, error) => {
+ dispatch(actions.resetAmount());
+ dispatch(actions.setError(error));
+ },
});
export const SelectedAssetBuyButton: React.ComponentClass<SelectedAssetBuyButtonProps> = connect(
diff --git a/packages/instant/src/containers/selected_asset_buy_order_state_button.tsx b/packages/instant/src/containers/selected_asset_buy_order_state_button.tsx
index f3efbb5d2..7faa79912 100644
--- a/packages/instant/src/containers/selected_asset_buy_order_state_button.tsx
+++ b/packages/instant/src/containers/selected_asset_buy_order_state_button.tsx
@@ -3,12 +3,12 @@ import * as React from 'react';
import { connect } from 'react-redux';
import { State } from '../redux/reducer';
-import { AsyncProcessState } from '../types';
+import { OrderProcessState } from '../types';
import { BuyOrderStateButton } from '../components/buy_order_state_button';
interface ConnectedState {
- buyOrderProcessingState: AsyncProcessState;
+ buyOrderProcessingState: OrderProcessState;
}
export interface SelectedAssetButtonProps {}
const mapStateToProps = (state: State, _ownProps: SelectedAssetButtonProps): ConnectedState => ({
diff --git a/packages/instant/src/containers/selected_asset_view_transaction_button.tsx b/packages/instant/src/containers/selected_asset_view_transaction_button.tsx
index 6f42b9f85..064b877be 100644
--- a/packages/instant/src/containers/selected_asset_view_transaction_button.tsx
+++ b/packages/instant/src/containers/selected_asset_view_transaction_button.tsx
@@ -5,7 +5,7 @@ import { connect } from 'react-redux';
import { State } from '../redux/reducer';
import { ViewTransactionButton } from '../components/view_transaction_button';
-import { AsyncProcessState } from '../types';
+import { OrderProcessState } from '../types';
import { etherscanUtil } from '../util/etherscan';
export interface SelectedAssetViewTransactionButtonProps {}
@@ -16,9 +16,13 @@ interface ConnectedState {
const mapStateToProps = (state: State, _ownProps: {}): ConnectedState => ({
onClick: () => {
- if (state.assetBuyer && state.buyOrderState.processState === AsyncProcessState.SUCCESS) {
+ if (
+ state.assetBuyer &&
+ (state.buyOrderState.processState === OrderProcessState.PROCESSING ||
+ state.buyOrderState.processState === OrderProcessState.SUCCESS)
+ ) {
const etherscanUrl = etherscanUtil.getEtherScanTxnAddressIfExists(
- state.buyOrderState.txnHash,
+ state.buyOrderState.txHash,
state.assetBuyer.networkId,
);
if (etherscanUrl) {
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 078f96cd4..ee76e9d66 100644
--- a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
+++ b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
@@ -10,7 +10,7 @@ import { Dispatch } from 'redux';
import { Action, actions } from '../redux/actions';
import { State } from '../redux/reducer';
import { ColorOption } from '../style/theme';
-import { AsyncProcessState, ERC20Asset } from '../types';
+import { ERC20Asset, OrderProcessState } from '../types';
import { BigNumberInput } from '../util/big_number_input';
import { errorUtil } from '../util/error';
@@ -91,7 +91,7 @@ const mapDispatchToProps = (
// invalidate the last buy quote.
dispatch(actions.updateLatestBuyQuote(undefined));
// reset our buy state
- dispatch(actions.updateBuyOrderState({ processState: AsyncProcessState.NONE }));
+ dispatch(actions.updateBuyOrderState({ processState: OrderProcessState.NONE }));
if (!_.isUndefined(value) && !_.isUndefined(asset) && !_.isUndefined(assetBuyer)) {
// even if it's debounced, give them the illusion it's loading