aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/instant/src/components/asset_amount_input.tsx4
-rw-r--r--packages/instant/src/util/asset_data.ts25
-rw-r--r--packages/instant/src/util/error_description.ts4
3 files changed, 17 insertions, 16 deletions
diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx
index c9d9c52b3..db3dbe7f3 100644
--- a/packages/instant/src/components/asset_amount_input.tsx
+++ b/packages/instant/src/components/asset_amount_input.tsx
@@ -2,7 +2,7 @@ import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as React from 'react';
-import { bestNameForAsset } from '../util/asset_data';
+import { assetDataUtil } from '../util/asset_data';
import { ColorOption } from '../style/theme';
import { util } from '../util/util';
@@ -26,7 +26,7 @@ export class AssetAmountInput extends React.Component<AssetAmountInputProps> {
<AmountInput {...rest} onChange={this._handleChange} />
<Container display="inline-block" marginLeft="10px">
<Text fontSize={rest.fontSize} fontColor={ColorOption.white} textTransform="uppercase">
- {bestNameForAsset(this.props.assetData, '???')}
+ {assetDataUtil.bestNameForAsset(this.props.assetData, '???')}
</Text>
</Container>
</Container>
diff --git a/packages/instant/src/util/asset_data.ts b/packages/instant/src/util/asset_data.ts
index 958f500bb..4f3db8447 100644
--- a/packages/instant/src/util/asset_data.ts
+++ b/packages/instant/src/util/asset_data.ts
@@ -2,17 +2,18 @@ import { AssetProxyId } from '@0xproject/types';
import { assetMetaData } from '../data/asset_meta_data';
-// TODO: tests for this
-export const bestNameForAsset = (assetData: string | undefined, defaultString: string) => {
- if (assetData === undefined) {
+export const assetDataUtil = {
+ bestNameForAsset: (assetData: string | undefined, defaultString: string) => {
+ if (assetData === undefined) {
+ return defaultString;
+ }
+ const metaData = assetMetaData[assetData];
+ if (metaData === undefined) {
+ return defaultString;
+ }
+ if (metaData.assetProxyId === AssetProxyId.ERC20) {
+ return metaData.symbol.toUpperCase();
+ }
return defaultString;
- }
- const metaData = assetMetaData[assetData];
- if (metaData === undefined) {
- return defaultString;
- }
- if (metaData.assetProxyId === AssetProxyId.ERC20) {
- return metaData.symbol.toUpperCase();
- }
- return defaultString;
+ },
};
diff --git a/packages/instant/src/util/error_description.ts b/packages/instant/src/util/error_description.ts
index 78af9e9ff..9419a1e16 100644
--- a/packages/instant/src/util/error_description.ts
+++ b/packages/instant/src/util/error_description.ts
@@ -1,10 +1,10 @@
import { AssetBuyerError } from '@0xproject/asset-buyer';
-import { bestNameForAsset } from '../util/asset_data';
+import { assetDataUtil } from '../util/asset_data';
const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => {
if (error.message === AssetBuyerError.InsufficientAssetLiquidity) {
- const assetName = bestNameForAsset(assetData, 'of this asset');
+ const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset');
return `Not enough ${assetName} available`;
}