aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-24 08:08:34 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-24 08:08:34 +0800
commit8e501e5ec715da17e3319870dbde3cca87940416 (patch)
treed1a6ed1bf31042d2ac58456707cae767d0c6d925 /packages
parent7ccfa8a8afe103e1cc2920724b6f17644fe5629d (diff)
downloaddexon-sol-tools-8e501e5ec715da17e3319870dbde3cca87940416.tar
dexon-sol-tools-8e501e5ec715da17e3319870dbde3cca87940416.tar.gz
dexon-sol-tools-8e501e5ec715da17e3319870dbde3cca87940416.tar.bz2
dexon-sol-tools-8e501e5ec715da17e3319870dbde3cca87940416.tar.lz
dexon-sol-tools-8e501e5ec715da17e3319870dbde3cca87940416.tar.xz
dexon-sol-tools-8e501e5ec715da17e3319870dbde3cca87940416.tar.zst
dexon-sol-tools-8e501e5ec715da17e3319870dbde3cca87940416.zip
feat: add formatted symbol for asset uitl
Diffstat (limited to 'packages')
-rw-r--r--packages/instant/src/util/asset.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts
index 4e3b2b946..ebeba948e 100644
--- a/packages/instant/src/util/asset.ts
+++ b/packages/instant/src/util/asset.ts
@@ -2,7 +2,7 @@ import { AssetProxyId, ObjectMap } from '@0x/types';
import * as _ from 'lodash';
import { assetDataNetworkMapping } from '../data/asset_data_network_mapping';
-import { Asset, AssetMetaData, Network, ZeroExInstantError } from '../types';
+import { Asset, AssetMetaData, Network, ZeroExInstantError, ERC20Asset } from '../types';
export const assetUtils = {
createAssetFromAssetData: (
@@ -43,6 +43,16 @@ export const assetUtils = {
return defaultName;
}
},
+ formattedSymbolForAsset: (asset?: ERC20Asset, defaultName: string = '???'): string => {
+ if (_.isUndefined(asset)) {
+ return defaultName;
+ }
+ const symbol = asset.metaData.symbol;
+ if (symbol.length <= 5) {
+ return symbol;
+ }
+ return `${symbol.slice(0, 3)}...`;
+ },
getAssociatedAssetDataIfExists: (assetData: string, network: Network): string | undefined => {
const assetDataGroupIfExists = _.find(assetDataNetworkMapping, value => value[network] === assetData);
if (_.isUndefined(assetDataGroupIfExists)) {