aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-12-04 09:08:32 +0800
committerGitHub <noreply@github.com>2018-12-04 09:08:32 +0800
commit8c146ce231ab0c3b6948afa21effe2a9bf228432 (patch)
tree58cb1a0c0f9010f597d589f3cc29a0359310a8b9 /packages/instant
parent703cea6173f72ceb6969bc17bda0735b86477522 (diff)
parente592b27f771839fecd718c21fc1045c695a14f85 (diff)
downloaddexon-0x-contracts-8c146ce231ab0c3b6948afa21effe2a9bf228432.tar
dexon-0x-contracts-8c146ce231ab0c3b6948afa21effe2a9bf228432.tar.gz
dexon-0x-contracts-8c146ce231ab0c3b6948afa21effe2a9bf228432.tar.bz2
dexon-0x-contracts-8c146ce231ab0c3b6948afa21effe2a9bf228432.tar.lz
dexon-0x-contracts-8c146ce231ab0c3b6948afa21effe2a9bf228432.tar.xz
dexon-0x-contracts-8c146ce231ab0c3b6948afa21effe2a9bf228432.tar.zst
dexon-0x-contracts-8c146ce231ab0c3b6948afa21effe2a9bf228432.zip
Merge pull request #1372 from 0xProject/fix/instant/single-asset
[instant] render token selector when only one asset is available
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/src/components/erc20_asset_amount_input.tsx8
-rw-r--r--packages/instant/src/redux/async_data.ts3
2 files changed, 6 insertions, 5 deletions
diff --git a/packages/instant/src/components/erc20_asset_amount_input.tsx b/packages/instant/src/components/erc20_asset_amount_input.tsx
index ff900842a..4da82eb73 100644
--- a/packages/instant/src/components/erc20_asset_amount_input.tsx
+++ b/packages/instant/src/components/erc20_asset_amount_input.tsx
@@ -113,7 +113,7 @@ export class ERC20AssetAmountInput extends React.Component<ERC20AssetAmountInput
);
};
private readonly _renderChevronIcon = (): React.ReactNode => {
- if (!this._areMultipleAssetsAvailable()) {
+ if (!this._areAnyAssetsAvailable()) {
return null;
}
return (
@@ -134,14 +134,14 @@ export class ERC20AssetAmountInput extends React.Component<ERC20AssetAmountInput
// We don't want to allow opening the token selection panel if there are no assets.
// Since styles are inferred from the presence of a click handler, we want to return undefined
// instead of providing a noop.
- if (!this._areMultipleAssetsAvailable() || _.isUndefined(this.props.onSelectAssetClick)) {
+ if (!this._areAnyAssetsAvailable() || _.isUndefined(this.props.onSelectAssetClick)) {
return undefined;
}
return this._handleSelectAssetClick;
};
- private readonly _areMultipleAssetsAvailable = (): boolean => {
+ private readonly _areAnyAssetsAvailable = (): boolean => {
const { numberOfAssetsAvailable } = this.props;
- return !_.isUndefined(numberOfAssetsAvailable) && numberOfAssetsAvailable > 1;
+ return !_.isUndefined(numberOfAssetsAvailable) && numberOfAssetsAvailable > 0;
};
private readonly _handleSelectAssetClick = (): void => {
if (this.props.onSelectAssetClick) {
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts
index 18f671cd7..c67b222d1 100644
--- a/packages/instant/src/redux/async_data.ts
+++ b/packages/instant/src/redux/async_data.ts
@@ -32,7 +32,8 @@ export const asyncData = {
const assetBuyer = providerState.assetBuyer;
try {
const assetDatas = await assetBuyer.getAvailableAssetDatasAsync();
- const assets = assetUtils.createAssetsFromAssetDatas(assetDatas, assetMetaDataMap, network);
+ const deduplicatedAssetDatas = _.uniq(assetDatas);
+ const assets = assetUtils.createAssetsFromAssetDatas(deduplicatedAssetDatas, assetMetaDataMap, network);
dispatch(actions.setAvailableAssets(assets));
} catch (e) {
const errorMessage = 'Could not find any assets';