From b4fb6b5ff3106c9223508469a2bee583bcea8da0 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 18 Oct 2018 15:48:35 -0700 Subject: fix: add error message and move more logic to assetUtils --- packages/instant/src/util/asset.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'packages/instant/src/util/asset.ts') diff --git a/packages/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts index edeac0da3..e0d5ffcb7 100644 --- a/packages/instant/src/util/asset.ts +++ b/packages/instant/src/util/asset.ts @@ -19,14 +19,14 @@ export const assetUtils = { ): AssetMetaData => { let mainnetAssetData: string | undefined = assetData; if (network !== Network.Mainnet) { - mainnetAssetData = assetDataNetworkMapping.getAssociatedAssetDataIfExists(assetData, network); + mainnetAssetData = assetUtils.getAssociatedAssetDataIfExists(assetData, network); } if (_.isUndefined(mainnetAssetData)) { throw new Error(ZeroExInstantError.AssetMetaDataNotAvailable); } const metaData = metaDataMap[mainnetAssetData]; if (_.isUndefined(metaData)) { - throw new Error(); + throw new Error(ZeroExInstantError.AssetMetaDataNotAvailable); } return metaData; }, @@ -44,4 +44,11 @@ export const assetUtils = { return defaultName; } }, + getAssociatedAssetDataIfExists: (assetData: string, network: Network): string | undefined => { + const assetDataGroupIfExists = _.find(assetDataNetworkMapping, value => value[network] === assetData); + if (_.isUndefined(assetDataGroupIfExists)) { + return; + } + return assetDataGroupIfExists[Network.Mainnet]; + }, }; -- cgit