Skip to content

Commit

Permalink
Removes duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha committed Sep 19, 2024
1 parent 4200b0f commit 1b5398d
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/rest-api/src/utils/bridgeRouteMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,27 @@ const transformPair = (string: string): any => {
}
}

const transformBridgeRouteValues = (routes: StringifiedBridgeRoutes) => {
const transformBridgeRouteValues = (
routes: StringifiedBridgeRoutes
): TransformedBridgeRoutes => {
return Object.fromEntries(
Object.entries(routes).map(([key, values]) => [
key,
values.map(transformPair).filter((pair) => pair !== undefined),
])
Object.entries(routes).map(([key, values]) => {
const uniquePairs: TokenData[] = []
values.forEach((pairStr) => {
const transformedPair = transformPair(pairStr)
if (
transformedPair &&
!uniquePairs.some(
(pair) =>
pair.symbol === transformedPair.symbol &&
pair.chainId === transformedPair.chainId
)
) {
uniquePairs.push(transformedPair)
}
})
return [key, uniquePairs]
})
)
}

Expand Down

0 comments on commit 1b5398d

Please sign in to comment.