aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/asset.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-27 02:41:09 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-27 02:41:09 +0800
commita414dc9b83c14b277af90ce8397db3736a51a4d3 (patch)
treee9814de850892932b539c88e1798d44b00db563a /packages/instant/src/util/asset.ts
parent951a5271e15cebb010281de3b8cbfb3972ecec83 (diff)
parent0f6307169604f36b0316f236eb96d6001b788f50 (diff)
downloaddexon-sol-tools-a414dc9b83c14b277af90ce8397db3736a51a4d3.tar
dexon-sol-tools-a414dc9b83c14b277af90ce8397db3736a51a4d3.tar.gz
dexon-sol-tools-a414dc9b83c14b277af90ce8397db3736a51a4d3.tar.bz2
dexon-sol-tools-a414dc9b83c14b277af90ce8397db3736a51a4d3.tar.lz
dexon-sol-tools-a414dc9b83c14b277af90ce8397db3736a51a4d3.tar.xz
dexon-sol-tools-a414dc9b83c14b277af90ce8397db3736a51a4d3.tar.zst
dexon-sol-tools-a414dc9b83c14b277af90ce8397db3736a51a4d3.zip
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/fixed-orders-in-render-method
Diffstat (limited to 'packages/instant/src/util/asset.ts')
-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 d7e87eebb..630103c7b 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, ERC20Asset, Network, ZeroExInstantError } from '../types';
export const assetUtils = {
createAssetFromAssetData: (
@@ -46,6 +46,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)) {