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

Open
#2,908 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript
Domain
frontend

Research direction

Start in extension/src/popup/components/manageAssets/ManageAssetRows/ChangeTrustInternal/index.tsx and trace the Add Token screen’s props, useNetworkFees, and useChangeTrustData flow. Confirm the current useGetAppData/redux data is referentially stable, then verify existing tests still pass. Done means the review uses the already-loaded recommendedFee and scan result without duplicate feeStats or scanAsset requests.

Written by the indexing model from the issue text.

Description

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

  • Source: local PR review of #2869 (feat/addtoken-sac-changetrust-review), head b314de9b.
  • Severity: low (latency / duplicate requests only; no correctness or security impact).
Dominant language
TypeScript
Stars
122
Forks
62
Avg merge
4d 19h
Merged PRs (30d)
41

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/freighter

All issues in stellar/freighter

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.