Skip to content

Commit

Permalink
Fix Route resolution issue (wormhole-foundation#2148)
Browse files Browse the repository at this point in the history
* fix baseRoute impl

* remove trace
  • Loading branch information
artursapek committed May 29, 2024
1 parent 01fd047 commit 854a421
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 38 deletions.
11 changes: 7 additions & 4 deletions wormhole-connect/src/routes/bridge/baseRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ export abstract class BaseRoute extends RouteAbstract {
tokens: TokenConfig[],
destToken?: TokenConfig,
sourceChain?: ChainName | ChainId,
destChain?: ChainName | ChainId,
): Promise<TokenConfig[]> {
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) => {
Expand All @@ -91,10 +91,13 @@ export abstract class BaseRoute extends RouteAbstract {
async supportedDestTokens(
tokens: TokenConfig[],
sourceToken?: TokenConfig,
sourceChain?: ChainName | ChainId,
destChain?: ChainName | ChainId,
): Promise<TokenConfig[]> {
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];
Expand Down
34 changes: 0 additions & 34 deletions wormhole-connect/src/routes/porticoBridge/porticoBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,40 +129,6 @@ export abstract class PorticoBridge extends BaseRoute {
);
}

async supportedSourceTokens(
tokens: TokenConfig[],
destToken?: TokenConfig,
sourceChain?: ChainName | ChainId,
destChain?: ChainName | ChainId,
): Promise<TokenConfig[]> {
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<TokenConfig[]> {
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,
Expand Down

0 comments on commit 854a421

Please sign in to comment.