aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-02 04:10:51 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-02 04:10:51 +0800
commitb55ba3a31823699fa2460fad6fd22b913c38c946 (patch)
treea3ce34b73187518f106894f9eeb35d6a56f065cf /packages/instant/src/containers
parent3f918622bcce21ba104e0f13e71247796345ab0f (diff)
downloaddexon-sol-tools-b55ba3a31823699fa2460fad6fd22b913c38c946.tar
dexon-sol-tools-b55ba3a31823699fa2460fad6fd22b913c38c946.tar.gz
dexon-sol-tools-b55ba3a31823699fa2460fad6fd22b913c38c946.tar.bz2
dexon-sol-tools-b55ba3a31823699fa2460fad6fd22b913c38c946.tar.lz
dexon-sol-tools-b55ba3a31823699fa2460fad6fd22b913c38c946.tar.xz
dexon-sol-tools-b55ba3a31823699fa2460fad6fd22b913c38c946.tar.zst
dexon-sol-tools-b55ba3a31823699fa2460fad6fd22b913c38c946.zip
feat: add states to the erc20 input for no assets or only 1 asset
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/available_erc20_token_selector.ts2
-rw-r--r--packages/instant/src/containers/selected_erc20_asset_amount_input.ts20
2 files changed, 11 insertions, 11 deletions
diff --git a/packages/instant/src/containers/available_erc20_token_selector.ts b/packages/instant/src/containers/available_erc20_token_selector.ts
index 6b5ecb6ac..e8bacdba0 100644
--- a/packages/instant/src/containers/available_erc20_token_selector.ts
+++ b/packages/instant/src/containers/available_erc20_token_selector.ts
@@ -20,7 +20,7 @@ interface ConnectedDispatch {
}
const mapStateToProps = (state: State, _ownProps: AvailableERC20TokenSelectorProps): ConnectedState => ({
- tokens: assetUtils.getERC20AssetsFromAssets(state.availableAssets),
+ tokens: assetUtils.getERC20AssetsFromAssets(state.availableAssets || []),
});
const mapDispatchToProps = (
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 217d603d2..64b6f4b3b 100644
--- a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
+++ b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
@@ -27,6 +27,7 @@ interface ConnectedState {
value?: BigNumberInput;
asset?: ERC20Asset;
isDisabled: boolean;
+ numberOfAssetsAvailable?: number;
}
interface ConnectedDispatch {
@@ -38,6 +39,7 @@ interface ConnectedProps {
asset?: ERC20Asset;
onChange: (value?: BigNumberInput, asset?: ERC20Asset) => void;
isDisabled: boolean;
+ numberOfAssetsAvailable?: number;
}
type FinalProps = ConnectedProps & SelectedERC20AssetAmountInputProps;
@@ -46,20 +48,17 @@ const mapStateToProps = (state: State, _ownProps: SelectedERC20AssetAmountInputP
const processState = state.buyOrderState.processState;
const isEnabled = processState === OrderProcessState.NONE || processState === OrderProcessState.FAILURE;
const isDisabled = !isEnabled;
-
- const selectedAsset = state.selectedAsset;
- if (_.isUndefined(selectedAsset) || selectedAsset.metaData.assetProxyId !== AssetProxyId.ERC20) {
- return {
- value: state.selectedAssetAmount,
- isDisabled,
- };
- }
-
+ const selectedAsset =
+ !_.isUndefined(state.selectedAsset) && state.selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20
+ ? (state.selectedAsset as ERC20Asset)
+ : undefined;
+ const numberOfAssetsAvailable = _.isUndefined(state.availableAssets) ? undefined : state.availableAssets.length;
return {
assetBuyer: state.assetBuyer,
value: state.selectedAssetAmount,
- asset: selectedAsset as ERC20Asset,
+ asset: selectedAsset,
isDisabled,
+ numberOfAssetsAvailable,
};
};
@@ -138,6 +137,7 @@ const mergeProps = (
connectedDispatch.updateBuyQuote(connectedState.assetBuyer, value, asset);
},
isDisabled: connectedState.isDisabled,
+ numberOfAssetsAvailable: connectedState.numberOfAssetsAvailable,
};
};