aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/asset_data.ts
blob: f7c5b78cd8b4e9f86f2636cdd25e9140ccd274eb (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 '@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;
    },
};