Rename swap isNew → requiresTrustline (descriptor + telemetry)#915
Merged
Conversation
The DestinationTokenDescriptor.isNew flag was vague. requiresTrustline reads as it is used: when true, the swap bundles a changeTrust op. - Rename DestinationTokenDescriptor.isNew -> requiresTrustline and all reads / literals / comments across SwapScreen + transactionService. - Rename the shouldShowXlmReservePreflight param destinationIsNew -> destinationRequiresTrustline. - Telemetry: the SWAP_DESTINATION_SELECTED payload field isNew -> requiresTrustline (wire-format change; dashboards keyed on isNew must be updated). - Update docs/swap-to-new-token-design.md to match. Keeps freighter-mobile in sync with the extension design doc (stellar/freighter#2868). Swap unit suites green (272 tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR clarifies swap destination semantics by renaming DestinationTokenDescriptor.isNew to requiresTrustline, aligning the name with actual behavior (whether a changeTrust op is required) and updating related telemetry and documentation across the Swap feature.
Changes:
- Renamed swap destination descriptor flag
isNew→requiresTrustlineacross Swap screens/hooks/helpers andtransactionService. - Updated XLM reserve preflight wiring/parameter name (
destinationIsNew→destinationRequiresTrustline) and adjusted call sites. - Updated the swap design doc and Jest tests to reflect the rename, including the Amplitude payload field rename for
SWAP_DESTINATION_SELECTED.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/transactionService.ts | Updates swap builder docs to reference requiresTrustline. |
| src/components/screens/SwapScreen/screens/SwapToScreen.tsx | Renames Amplitude payload field to requiresTrustline for destination selection. |
| src/components/screens/SwapScreen/screens/SwapAmountScreen.tsx | Updates reserve/fee logic to key off requiresTrustline and threads renamed preflight param. |
| src/components/screens/SwapScreen/hooks/useTrendingTokenDetail.ts | Renames Amplitude payload field to requiresTrustline. |
| src/components/screens/SwapScreen/hooks/useSwapTransaction.ts | Renames trustline-derivation flag and related error message text. |
| src/components/screens/SwapScreen/hooks/useSwapForXlmReserve.ts | Updates descriptor literals to use requiresTrustline. |
| src/components/screens/SwapScreen/helpers/types.ts | Renames the descriptor field in the type definition. |
| src/components/screens/SwapScreen/helpers/swapPreflight.ts | Renames preflight param to destinationRequiresTrustline and updates the guard. |
| src/components/screens/SwapScreen/helpers/descriptors.ts | Renames descriptor projection field and updates derivation logic (!record.hasTrustline). |
| src/components/screens/SwapScreen/components/SwapReviewBottomSheet.tsx | Uses requiresTrustline to gate the trustline banner. |
| docs/swap-to-new-token-design.md | Updates design doc terminology and telemetry field name. |
| tests/ducks/swap.test.ts | Updates migration/test fixtures for renamed descriptor field. |
| tests/components/screens/SwapScreen/useSwapTransaction.test.ts | Updates includeTrustline wiring tests and expected error text. |
| tests/components/screens/SwapScreen/SwapToScreen.test.tsx | Updates swap destination fixture to use requiresTrustline. |
| tests/components/screens/SwapScreen/SwapReviewBottomSheet.test.tsx | Updates banner gating tests for renamed field. |
| tests/components/screens/SwapScreen/SwapAmountScreen.test.tsx | Updates mocked swap store types/fixtures and reserve preflight tests. |
| tests/components/screens/SwapScreen/hooks/useSwapSecurityAssessments.test.ts | Updates descriptor fixtures to use requiresTrustline. |
| tests/components/screens/SwapScreen/hooks/useSwapAmountError.test.ts | Updates descriptor fixtures to use requiresTrustline. |
| tests/components/screens/SwapScreen/helpers/swapPreflight.test.ts | Updates preflight arg name to destinationRequiresTrustline. |
| tests/components/screens/SwapScreen/helpers/descriptors.test.ts | Updates descriptor projection tests for renamed field. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
iOS Simulator preview build is ready: https://github.com/stellar/freighter-mobile/releases/tag/untagged-1f624d540455463892d3 (SDF collaborators only — install instructions in the release description) |
piyalbasu
approved these changes
Jun 24, 2026
leofelix077
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DestinationTokenDescriptor.isNewwas vague ("new" how?). Renames it torequiresTrustline, which reads as it is used: whentrue, the swap bundles achangeTrustop. All swap-relatedisNewwas introduced in #879, so the scope iscontained to the Swap feature.
DestinationTokenDescriptor.isNew→requiresTrustlineand everyread / literal / comment / error message across
SwapScreen/**andtransactionService.ts.shouldShowXlmReservePreflightparamdestinationIsNew→destinationRequiresTrustline.docs/swap-to-new-token-design.mdto match.Telemetry (wire-format change)
The
SWAP_DESTINATION_SELECTEDAmplitude payload field is renamedisNew→requiresTrustline. Any dashboards/queries keyed onisNewfor that event needupdating. (Intentional — done for cross-platform consistency.)
👆 this should be fine as Swap to New Token has not been released on mobile yet.
Why
Keeps freighter-mobile in sync with the browser-extension design doc, which makes
the same rename: stellar/freighter#2868 (comment)
Testing
🤖 Generated with Claude Code