Skip to content

Add Token SAC review re-fetches fee + scan data the Add Token screen already loaded #2908

Description

@piyalbasu

Summary

In the Add Token → SAC trustline review flow, ChangeTrustInternal re-fetches
data that the Add Token screen already loaded, adding avoidable latency and
duplicate backend requests. Not user-visible beyond the extra round-trips.
Follow-up from the PR #2869 review (finding #6, [efficiency]).

Details

extension/src/popup/components/manageAssets/ManageAssetRows/ChangeTrustInternal/index.tsx

  • Duplicate feeStats() round-trip. ChangeTrustInternal calls
    useNetworkFees() again even though the Add Token screen already fetched fees.
    Only initialFee is threaded down from the parent — not recommendedFee — so
    the child re-fetches to recover it.
  • Duplicate scanAsset. useChangeTrustData re-runs scanAsset for the
    same ${code}-${issuer} the Add Token screen already scanned; the prior scan
    result is not threaded down.

Proposed fix

Thread the already-fetched recommendedFee and the Add Token scan result down
into ChangeTrustInternal (via props) instead of re-fetching them in the child.

Related note to verify (not necessarily blocking)

fetchData is useCallback-memoized with networkDetails in its dep array and
the effect depends on [fetchData]. This is correct only while the
networkDetails prop is referentially stable
. If a parent ever passes a
freshly-constructed networkDetails each render, the memo breaks and fetchData
re-fires every render. Current tests pass, so the useGetAppData/redux source
appears stable — worth a quick confirmation while in this code.

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions