Skip to content

fix: remove O(n) API calls to ENS on the swaps flow#26126

Open
juanmigdr wants to merge 2 commits intomainfrom
fix/infinite-api-calls-to-ENS
Open

fix: remove O(n) API calls to ENS on the swaps flow#26126
juanmigdr wants to merge 2 commits intomainfrom
fix/infinite-api-calls-to-ENS

Conversation

@juanmigdr
Copy link
Member

@juanmigdr juanmigdr commented Feb 16, 2026

Description

When the bridge/swaps flow opens, useRecipientInitialization calls useDestinationAccounts, which calls useAccounts() with the default fetchENS: true. This triggers doENSReverseLookup() for every account in the wallet, each making an eth_call to the ENS Registry contract. The number of RPC calls scales linearly with the number of accounts, causing unnecessary network traffic and latency.

None of the ENS data is consumed anywhere in the bridge flow:

  • useRecipientInitialization only reads destinationAccounts, never ensByAccountAddress
  • RecipientSelectorModal builds its own account list from Redux selectors with no ENS involvement
  • useRecipientDisplayData uses internalAccount.metadata.name and account group metadata, not ENS
    The fix passes { fetchENS: false } to useAccounts() in useDestinationAccounts, eliminating the wasted ENS lookups with zero impact on functionality. The unused ensByAccountAddress return value is also removed from the hook.

Slack thread

Changelog

CHANGELOG entry: fixed excessive ENS API calls when opening the bridge/swaps flow that scaled with the number of accounts

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-2682

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

Screen.Recording.2026-02-16.at.15.26.35.mov

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Small, localized change that only affects account display data fetching and a hook return shape; low chance of impacting bridge logic beyond any remaining callers expecting ENS data.

Overview
Prevents per-account ENS network calls in Bridge destination account selection by calling useAccounts({ fetchENS: false }).

Simplifies useDestinationAccounts to only return destinationAccounts (drops ensByAccountAddress from the hook API).

Written by Cursor Bugbot for commit 55a204e. This will update automatically on new commits. Configure here.

@juanmigdr juanmigdr requested a review from a team as a code owner February 16, 2026 14:35
Copy link
Contributor

@bfullam bfullam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also remove both instances of ensByAccountAddress, since they're not used anywhere.

@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
The change modifies useDestinationAccounts.ts, a hook used in the bridge flow for selecting destination accounts. The modification is a performance optimization that:

  1. Passes { fetchENS: false } to the useAccounts() hook to skip unnecessary ENS name lookups
  2. Removes the unused ensByAccountAddress from the hook's return value

The change is traced through: useDestinationAccountsuseRecipientInitializationBridgeView. This is part of the bridge destination account selection logic.

Since this affects bridge functionality, SmokeTrade is the appropriate tag as it covers "cross-chain bridging between networks". Per the tag guidance, SmokeConfirmations should also be selected when SmokeTrade is selected for bridge flows, as transaction confirmations are part of the bridge flow.

The risk is low because:

  • This is a targeted optimization removing unused functionality
  • The ENS names were being fetched but never used in the bridge destination account flow
  • The useRecipientInitialization hook only uses destinationAccounts, not ensByAccountAddress
  • No functional behavior should change - only unnecessary network calls are avoided

Performance Test Selection:
While this change is itself a performance optimization (avoiding unnecessary ENS lookups), it doesn't require performance testing to validate. The change removes unnecessary work rather than modifying performance-critical rendering or data loading paths. The performance improvement is implicit in the code change itself - fewer network calls for ENS resolution. None of the available performance test tags (@PerformanceAccountList, @PerformanceSwaps, etc.) directly cover bridge destination account selection, and the change doesn't impact the areas those tests measure.

View GitHub Actions results

@juanmigdr juanmigdr enabled auto-merge February 16, 2026 15:40
@juanmigdr juanmigdr requested a review from bfullam February 16, 2026 15:41
@juanmigdr juanmigdr changed the title fix: remove API calls to ENS per account fix: remove O(n) API calls to ENS on the swaps flow Feb 16, 2026
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants