From 854a4219aee5b2ce95b4c314e238718c0ba9daec Mon Sep 17 00:00:00 2001 From: Artur Sapek Date: Wed, 29 May 2024 14:10:58 -0400 Subject: [PATCH] Fix Route resolution issue (#2148) * fix baseRoute impl * remove trace --- .../src/routes/bridge/baseRoute.ts | 11 +++--- .../src/routes/porticoBridge/porticoBridge.ts | 34 ------------------- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/wormhole-connect/src/routes/bridge/baseRoute.ts b/wormhole-connect/src/routes/bridge/baseRoute.ts index 2883c4e7a..2550790d9 100644 --- a/wormhole-connect/src/routes/bridge/baseRoute.ts +++ b/wormhole-connect/src/routes/bridge/baseRoute.ts @@ -75,11 +75,11 @@ export abstract class BaseRoute extends RouteAbstract { tokens: TokenConfig[], destToken?: TokenConfig, sourceChain?: ChainName | ChainId, + destChain?: ChainName | ChainId, ): Promise { - if (!destToken) return tokens; const shouldAdd = await Promise.allSettled( tokens.map((token) => - this.isSupportedSourceToken(token, destToken, sourceChain), + this.isSupportedSourceToken(token, destToken, sourceChain, destChain), ), ); return tokens.filter((_token, i) => { @@ -91,10 +91,13 @@ export abstract class BaseRoute extends RouteAbstract { async supportedDestTokens( tokens: TokenConfig[], sourceToken?: TokenConfig, + sourceChain?: ChainName | ChainId, + destChain?: ChainName | ChainId, ): Promise { - if (!sourceToken) return tokens; const shouldAdd = await Promise.allSettled( - tokens.map((token) => this.isSupportedDestToken(token, sourceToken)), + tokens.map((token) => + this.isSupportedDestToken(token, sourceToken, sourceChain, destChain), + ), ); return tokens.filter((_token, i) => { const res = shouldAdd[i]; diff --git a/wormhole-connect/src/routes/porticoBridge/porticoBridge.ts b/wormhole-connect/src/routes/porticoBridge/porticoBridge.ts index 0a038387f..0256948b6 100644 --- a/wormhole-connect/src/routes/porticoBridge/porticoBridge.ts +++ b/wormhole-connect/src/routes/porticoBridge/porticoBridge.ts @@ -129,40 +129,6 @@ export abstract class PorticoBridge extends BaseRoute { ); } - async supportedSourceTokens( - tokens: TokenConfig[], - destToken?: TokenConfig, - sourceChain?: ChainName | ChainId, - destChain?: ChainName | ChainId, - ): Promise { - const shouldAdd = await Promise.allSettled( - tokens.map((token) => - this.isSupportedSourceToken(token, destToken, sourceChain, destChain), - ), - ); - return tokens.filter((_token, i) => { - const res = shouldAdd[i]; - return res.status === 'fulfilled' && res.value; - }); - } - - async supportedDestTokens( - tokens: TokenConfig[], - sourceToken?: TokenConfig, - sourceChain?: ChainName | ChainId, - destChain?: ChainName | ChainId, - ): Promise { - const shouldAdd = await Promise.allSettled( - tokens.map((token) => - this.isSupportedDestToken(token, sourceToken, sourceChain, destChain), - ), - ); - return tokens.filter((_token, i) => { - const res = shouldAdd[i]; - return res.status === 'fulfilled' && res.value; - }); - } - async isRouteSupported( sourceToken: string, destToken: string,