diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-11-03 07:26:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-03 07:26:16 +0800 |
commit | 66261102de57e3bc86714577c021aa5c7e17c150 (patch) | |
tree | 2a146790ba3d0a632a23c7335a3dcbd9d5a8c881 /packages/instant/src/containers/selected_erc20_asset_amount_input.ts | |
parent | d0f20a4fd5d1ab563d4b1c941b55018da129334e (diff) | |
parent | 6748c36b033798de4eb56e5d4e49d1c4b4e7be1e (diff) | |
download | dexon-sol-tools-66261102de57e3bc86714577c021aa5c7e17c150.tar dexon-sol-tools-66261102de57e3bc86714577c021aa5c7e17c150.tar.gz dexon-sol-tools-66261102de57e3bc86714577c021aa5c7e17c150.tar.bz2 dexon-sol-tools-66261102de57e3bc86714577c021aa5c7e17c150.tar.lz dexon-sol-tools-66261102de57e3bc86714577c021aa5c7e17c150.tar.xz dexon-sol-tools-66261102de57e3bc86714577c021aa5c7e17c150.tar.zst dexon-sol-tools-66261102de57e3bc86714577c021aa5c7e17c150.zip |
Merge pull request #1204 from 0xProject/feature/instant/maker-asset-datas-interface
[instant] Add `availableAssetDatas` to render method, fetch from asset-buyer if not specified, implement basic token selection
Diffstat (limited to 'packages/instant/src/containers/selected_erc20_asset_amount_input.ts')
-rw-r--r-- | packages/instant/src/containers/selected_erc20_asset_amount_input.ts | 20 |
1 files changed, 10 insertions, 10 deletions
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 12bc7040e..f7d56c564 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?: BigNumber; asset?: ERC20Asset; isDisabled: boolean; + numberOfAssetsAvailable?: number; affiliateInfo?: AffiliateInfo; } @@ -44,6 +45,7 @@ interface ConnectedProps { asset?: ERC20Asset; onChange: (value?: BigNumber, asset?: ERC20Asset) => void; isDisabled: boolean; + numberOfAssetsAvailable?: number; } type FinalProps = ConnectedProps & SelectedERC20AssetAmountInputProps; @@ -52,20 +54,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, affiliateInfo: state.affiliateInfo, }; }; @@ -151,6 +150,7 @@ const mergeProps = ( connectedDispatch.updateBuyQuote(connectedState.assetBuyer, value, asset, connectedState.affiliateInfo); }, isDisabled: connectedState.isDisabled, + numberOfAssetsAvailable: connectedState.numberOfAssetsAvailable, }; }; |