Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes duplicates
Browse files Browse the repository at this point in the history
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
@@ -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]
})
)
}

0 comments on commit 1b5398d

Please sign in to comment.