aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src')
-rw-r--r--packages/instant/src/data/asset_data_network_mapping.ts12
-rw-r--r--packages/instant/src/util/asset.ts11
2 files changed, 10 insertions, 13 deletions
diff --git a/packages/instant/src/data/asset_data_network_mapping.ts b/packages/instant/src/data/asset_data_network_mapping.ts
index 9e14462f8..e8ccbf011 100644
--- a/packages/instant/src/data/asset_data_network_mapping.ts
+++ b/packages/instant/src/data/asset_data_network_mapping.ts
@@ -7,19 +7,9 @@ interface AssetDataByNetwork {
[Network.Mainnet]?: string;
}
-const sameAssetDatas: AssetDataByNetwork[] = [
+export const assetDataNetworkMapping: AssetDataByNetwork[] = [
{
[Network.Mainnet]: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
[Network.Kovan]: '0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa',
},
];
-
-export const assetDataNetworkMapping = {
- getAssociatedAssetDataIfExists: (assetData: string, network: Network): string | undefined => {
- const assetDataGroupIfExists = _.find(sameAssetDatas, value => value[network] === assetData);
- if (_.isUndefined(assetDataGroupIfExists)) {
- return;
- }
- return assetDataGroupIfExists[Network.Mainnet];
- },
-};
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];
+ },
};