diff options
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r-- | packages/instant/src/util/asset.ts | 11 |
1 files changed, 9 insertions, 2 deletions
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]; + }, }; |