aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/asset_data.ts
blob: 958f500bbef90e49aeb2083906ce52a95c83ec4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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) {
        return defaultString;
    }
    const metaData = assetMetaData[assetData];
    if (metaData === undefined) {
        return defaultString;
    }
    if (metaData.assetProxyId === AssetProxyId.ERC20) {
        return metaData.symbol.toUpperCase();
    }
    return defaultString;
};