From 8e0422cdae4316208a32f2b1b9586cce8b554b4a Mon Sep 17 00:00:00 2001 From: William Swanson Date: Tue, 17 Oct 2023 14:37:43 -0700 Subject: [PATCH] fixup! Implement Co-authored-by: Jon-edge <90650827+Jon-edge@users.noreply.github.com> --- src/core/account/account-api.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/account/account-api.ts b/src/core/account/account-api.ts index 720184102..17c7c7989 100644 --- a/src/core/account/account-api.ts +++ b/src/core/account/account-api.ts @@ -626,6 +626,7 @@ export function makeAccountApi(ai: ApiInput, accountId: string): EdgeAccount { opts?: EdgeSwapRequestOptions ): Promise { const [quote, ...rest] = await fetchSwapQuotes( + const [bestQuote, ...otherQuotes] = await fetchSwapQuotes( ai, accountId, request, @@ -633,12 +634,12 @@ export function makeAccountApi(ai: ApiInput, accountId: string): EdgeAccount { ) // Close unused quotes: - for (const quote of rest) quote.close().catch(() => undefined) + for (const otherQuote of otherQuotes) + otherQuote.close().catch(() => undefined) // Return the front quote: - if (quote == null) throw new Error('No swap providers enabled') - return quote - }, + if (bestQuote == null) throw new Error('No swap providers enabled') + return bestQuote async fetchSwapQuotes( request: EdgeSwapRequest,