aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/asset_data.ts
blob: fea2e2b19efabf14c1a5acaa852cf3aa57442013 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import * as _ from 'lodash';

import { AssetProxyId } from '@0x/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;
    },
};