Skip to content

Commit

Permalink
fix: dedup bridges to approve properly (#1908)
Browse files Browse the repository at this point in the history
* fix: dedup bridges to approve properly

Signed-off-by: bennett <[email protected]>

---------

Signed-off-by: bennett <[email protected]>
  • Loading branch information
bmzig authored Nov 13, 2024
1 parent 28cffcd commit f644828
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/adapter/BaseChainAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ export class BaseChainAdapter {
),
]);
// Dedup the `gasTokensToApprove` array so that we don't approve the same bridge to send the same token multiple times.
const tokenBridgePairs = gasTokensToApprove.map(({ token, bridges }) => `${token.address}_${bridges.join("_")}`);
const tokensToApprove = gasTokensToApprove
.filter(({ token, bridges }, idx) => gasTokensToApprove.indexOf({ token, bridges }) === idx)
.filter(({ token, bridges }, idx) => {
const tokenBridgePair = `${token.address}_${bridges.join("_")}`;
return tokenBridgePairs.indexOf(tokenBridgePair) === idx;
})
.concat(bridgeTokensToApprove)
.filter(({ bridges }) => bridges.length > 0);
if (unavailableTokens.length > 0) {
Expand Down

0 comments on commit f644828

Please sign in to comment.