aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/asset.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-19 06:48:35 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-19 06:48:35 +0800
commitb4fb6b5ff3106c9223508469a2bee583bcea8da0 (patch)
treec34de19c59aa3c167dbb3daf0941b57079ac9311 /packages/instant/src/util/asset.ts
parentc87e68f833a2d8a87846d70a9d4a727b46323eea (diff)
downloaddexon-sol-tools-b4fb6b5ff3106c9223508469a2bee583bcea8da0.tar.gz
dexon-sol-tools-b4fb6b5ff3106c9223508469a2bee583bcea8da0.tar.zst
dexon-sol-tools-b4fb6b5ff3106c9223508469a2bee583bcea8da0.zip
fix: add error message and move more logic to assetUtils
Diffstat (limited to 'packages/instant/src/util/asset.ts')
-rw-r--r--packages/instant/src/util/asset.ts11
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];
+ },
};