diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-18 04:31:28 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-18 05:44:40 +0800 |
commit | 32fa1bcc387e2eecae53db4b082e93f6fb09ae10 (patch) | |
tree | fd336b4ac4f8bc3565ff7066f857c751cb33dfbb /packages/instant/src/util | |
parent | 187bbc7fc14ccc0385981a38602334de65e2506c (diff) | |
download | dexon-0x-contracts-32fa1bcc387e2eecae53db4b082e93f6fb09ae10.tar dexon-0x-contracts-32fa1bcc387e2eecae53db4b082e93f6fb09ae10.tar.gz dexon-0x-contracts-32fa1bcc387e2eecae53db4b082e93f6fb09ae10.tar.bz2 dexon-0x-contracts-32fa1bcc387e2eecae53db4b082e93f6fb09ae10.tar.lz dexon-0x-contracts-32fa1bcc387e2eecae53db4b082e93f6fb09ae10.tar.xz dexon-0x-contracts-32fa1bcc387e2eecae53db4b082e93f6fb09ae10.tar.zst dexon-0x-contracts-32fa1bcc387e2eecae53db4b082e93f6fb09ae10.zip |
export assetDataUtil big obj
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r-- | packages/instant/src/util/asset_data.ts | 25 | ||||
-rw-r--r-- | packages/instant/src/util/error_description.ts | 4 |
2 files changed, 15 insertions, 14 deletions
diff --git a/packages/instant/src/util/asset_data.ts b/packages/instant/src/util/asset_data.ts index 958f500bb..4f3db8447 100644 --- a/packages/instant/src/util/asset_data.ts +++ b/packages/instant/src/util/asset_data.ts @@ -2,17 +2,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) { +export const assetDataUtil = { + 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; - } - const metaData = assetMetaData[assetData]; - if (metaData === undefined) { - return defaultString; - } - if (metaData.assetProxyId === AssetProxyId.ERC20) { - return metaData.symbol.toUpperCase(); - } - return defaultString; + }, }; diff --git a/packages/instant/src/util/error_description.ts b/packages/instant/src/util/error_description.ts index 78af9e9ff..9419a1e16 100644 --- a/packages/instant/src/util/error_description.ts +++ b/packages/instant/src/util/error_description.ts @@ -1,10 +1,10 @@ import { AssetBuyerError } from '@0xproject/asset-buyer'; -import { bestNameForAsset } from '../util/asset_data'; +import { assetDataUtil } from '../util/asset_data'; const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => { if (error.message === AssetBuyerError.InsufficientAssetLiquidity) { - const assetName = bestNameForAsset(assetData, 'of this asset'); + const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset'); return `Not enough ${assetName} available`; } |