aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-26 05:48:37 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-26 05:48:37 +0800
commit0515a914e0215bb40f0da4147258544c38cf282d (patch)
tree9814fa764fdecd95f17614a045568c3b9a5991c9 /packages
parent23b165669202c1bdf4bd7d7e509b9bfe06e3ef8a (diff)
downloaddexon-sol-tools-0515a914e0215bb40f0da4147258544c38cf282d.tar
dexon-sol-tools-0515a914e0215bb40f0da4147258544c38cf282d.tar.gz
dexon-sol-tools-0515a914e0215bb40f0da4147258544c38cf282d.tar.bz2
dexon-sol-tools-0515a914e0215bb40f0da4147258544c38cf282d.tar.lz
dexon-sol-tools-0515a914e0215bb40f0da4147258544c38cf282d.tar.xz
dexon-sol-tools-0515a914e0215bb40f0da4147258544c38cf282d.tar.zst
dexon-sol-tools-0515a914e0215bb40f0da4147258544c38cf282d.zip
fix: dont fail for mainnet assetData and non-mainnet network
Diffstat (limited to 'packages')
-rw-r--r--packages/instant/public/index.html4
-rw-r--r--packages/instant/src/util/asset.ts5
2 files changed, 6 insertions, 3 deletions
diff --git a/packages/instant/public/index.html b/packages/instant/public/index.html
index 95216a929..0ee144a28 100644
--- a/packages/instant/public/index.html
+++ b/packages/instant/public/index.html
@@ -62,8 +62,8 @@
const renderOptionsOverrides = {
liquiditySource: liquiditySourceOverride === 'provided' ? [providedOrder] : liquiditySourceOverride,
assetData: queryParams.getQueryParamValue('assetData'),
- network: +queryParams.getQueryParamValue('network'),
- defaultAssetBuyAmount: +queryParams.getQueryParamValue('defaultAssetBuyAmount'),
+ network: +queryParams.getQueryParamValue('network') || undefined,
+ defaultAssetBuyAmount: +queryParams.getQueryParamValue('defaultAssetBuyAmount') || undefined,
}
const renderOptions = Object.assign({}, renderOptionsDefaults, removeUndefined(renderOptionsOverrides));
zeroExInstant.render(renderOptions);
diff --git a/packages/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts
index 4e3b2b946..d7e87eebb 100644
--- a/packages/instant/src/util/asset.ts
+++ b/packages/instant/src/util/asset.ts
@@ -18,7 +18,10 @@ export const assetUtils = {
getMetaDataOrThrow: (assetData: string, metaDataMap: ObjectMap<AssetMetaData>, network: Network): AssetMetaData => {
let mainnetAssetData: string | undefined = assetData;
if (network !== Network.Mainnet) {
- mainnetAssetData = assetUtils.getAssociatedAssetDataIfExists(assetData, network);
+ const mainnetAssetDataIfExists = assetUtils.getAssociatedAssetDataIfExists(assetData, network);
+ // Just so we don't fail in the case where we are on a non-mainnet network,
+ // but pass in a valid mainnet assetData.
+ mainnetAssetData = mainnetAssetDataIfExists || assetData;
}
if (_.isUndefined(mainnetAssetData)) {
throw new Error(ZeroExInstantError.AssetMetaDataNotAvailable);