From f6a59fd91fe3bade8ae9bf2017ceaf318a3b4df3 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:03:37 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9Fix=20exact=20output=20quote=20usin?= =?UTF-8?q?g=20stellar=20classic=20assets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/generateRoute.ts | 68 +++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/functions/generateRoute.ts b/src/functions/generateRoute.ts index 3004cd49..b44f6479 100644 --- a/src/functions/generateRoute.ts +++ b/src/functions/generateRoute.ts @@ -118,42 +118,42 @@ export const useRouterSDK = () => { amount, tradeType, }; - - const horizonPath = (await getHorizonBestPath(horizonProps, sorobanContext)) as BuildTradeRoute; - + let horizonPath: BuildTradeRoute; + try { + horizonPath = (await getHorizonBestPath(horizonProps, sorobanContext)) as BuildTradeRoute; + } catch (error) { + console.error('Error getting horizon path'); + } let sorobanPath: BuildTradeRoute; - if (isAggregator) { - sorobanPath = (await router - .routeSplit(currencyAmount, quoteCurrency, tradeType) - .then((response) => { - if (!response) return undefined; - const result = { - ...response, - platform: PlatformType.AGGREGATOR, - }; - return result; - })) as BuildTradeRoute; - } else { - sorobanPath = (await router - .route(currencyAmount, quoteCurrency, tradeType, factory, sorobanContext as any) - .then((response) => { - if (!response) return undefined; - const result = { - ...response, - platform: PlatformType.ROUTER, - }; - return result; - })) as BuildTradeRoute; + try{ + if (isAggregator) { + sorobanPath = (await router + .routeSplit(currencyAmount, quoteCurrency, tradeType) + .then((response) => { + if (!response) return undefined; + const result = { + ...response, + platform: PlatformType.AGGREGATOR, + }; + return result; + })) as BuildTradeRoute; + } else { + sorobanPath = (await router + .route(currencyAmount, quoteCurrency, tradeType, factory, sorobanContext as any) + .then((response) => { + if (!response) return undefined; + const result = { + ...response, + platform: PlatformType.ROUTER, + }; + return result; + })) as BuildTradeRoute; + } + } catch (error) { + console.error('Error getting soroban path', error); } - const bestPath = getBestPath(horizonPath, sorobanPath, tradeType); - // .then((res) => { - // if (!res) return; - // const response = { - // ...res, - // platform: PlatformType.ROUTER, - // }; - // return response; - // }); + + const bestPath = getBestPath(horizonPath!, sorobanPath!, tradeType); return bestPath; };