Skip to content

Commit

Permalink
Make sure both chains are supported (#744)
Browse files Browse the repository at this point in the history
* make sure both chains are supported

(this is useful in case supportedDestinationTokens doesn't verify this)

* verify network too
  • Loading branch information
artursapek authored Nov 25, 2024
1 parent 0c57292 commit cff7ce2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions connect/src/routes/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ export class RouteResolver<N extends Network> {
const [, inputTokenId] = resolveWrappedToken(fromChain.network, fromChain.chain, inputToken);
const tokens = await Promise.all(
this.routeConstructors.map(async (rc) => {
const supportedNetworks = rc.supportedNetworks();
if (!supportedNetworks.includes(fromChain.network)) {
return [];
}

const supportedChains = rc.supportedChains(fromChain.network);
if (!supportedChains.includes(fromChain.chain) || !supportedChains.includes(toChain.chain)) {
return [];
}

try {
return await rc.supportedDestinationTokens(inputTokenId, fromChain, toChain);
} catch (e) {
Expand Down

0 comments on commit cff7ce2

Please sign in to comment.