Skip to content

Commit

Permalink
Portico: Add supportedSourceTokens and supportedDestTokens methods (#…
Browse files Browse the repository at this point in the history
…2143)

The base route implementation wasn't sufficient for the portico route.
  • Loading branch information
kev1n-peters authored May 29, 2024
1 parent cc8fabc commit 01fd047
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions wormhole-connect/src/routes/porticoBridge/porticoBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,40 @@ 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 01fd047

Please sign in to comment.