diff options
Diffstat (limited to 'packages/instant/src/util/asset_data.ts')
-rw-r--r-- | packages/instant/src/util/asset_data.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/instant/src/util/asset_data.ts b/packages/instant/src/util/asset_data.ts new file mode 100644 index 000000000..f7c5b78cd --- /dev/null +++ b/packages/instant/src/util/asset_data.ts @@ -0,0 +1,21 @@ +import * as _ from 'lodash'; + +import { AssetProxyId } from '@0xproject/types'; + +import { assetMetaData } from '../data/asset_meta_data'; + +export const assetDataUtil = { + bestNameForAsset: (assetData: string | undefined, defaultString: string) => { + if (_.isUndefined(assetData)) { + return defaultString; + } + const metaData = assetMetaData[assetData]; + if (_.isUndefined(metaData)) { + return defaultString; + } + if (metaData.assetProxyId === AssetProxyId.ERC20) { + return metaData.symbol.toUpperCase(); + } + return defaultString; + }, +}; |