Closed
Conversation
* Handle contract ID results from Stellar Expert asset search
The Stellar Expert API now returns contract IDs (C...) alongside classic
{code}-{issuer} assets. Route contract-ID results through the token lookup
flow and fix findAssetBalance to match by contractId so already-added
tokens show the correct button state.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add e2e test for adding a token via contract ID from Stellar Expert search
Covers the full add-token flow when Stellar Expert returns a contract ID
instead of {code}-{issuer}: search -> click Add -> confirm on the
ToggleToken page.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix e2e test to check ellipsis button on the specific E2E token row
The previous assertion failed because it matched multiple rows. Use the
specific ManageAssetRowButton__ellipsis-E2E test ID to assert the owned
contract token shows the ellipsis menu instead of "Add".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address code review feedback for contract ID search changes
- Use discriminated union (StellarExpertResult) for fetchStellarExpertData
return type instead of placeholder ManageAssetCurrency objects (#6, #2)
- Fetch contract token data in parallel with Promise.allSettled (#1)
- Use top-level Page import instead of inline import() type (#7)
- Use precise ManageAssetCode selector for row filtering in e2e tests (#8)
- Add unit tests for findAssetBalance with contract ID matching (#9)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Hoist isContractId check out of balances.find() loop in findAssetBalance
The check is invariant to the loop iteration — hoisting it makes the
three lookup strategies (native, contract, classic) distinct top-level
branches.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address review feedback: move stubs to helpers and skip abort telemetry
Agent-Logs-Url: https://github.com/stellar/freighter/sessions/01d13312-6e53-44c0-936a-8b25cf011859
Co-authored-by: piyalbasu <6789586+piyalbasu@users.noreply.github.com>
* Use Stellar Expert metadata directly for contract ID results
Stellar Expert already returns code, token_name, decimals, domain, and
tomlInfo for contract ID records. Use this data to build ManageAssetCurrency
rows directly instead of making redundant RPC calls via fetchTokenData.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix issuer field for contract ID results to use token contract
tomlInfo.issuer can be a different address than the token's own contract
ID. Always use record.asset (the token contract) as issuer so
findAssetBalance correctly matches balance.contractId. Update stub to
use a divergent tomlInfo.issuer to prevent this class of bug from
passing tests silently.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Show custom token error when swapping SEP-41 tokens
Extract swap error logic into getSwapErrorMessage helper. Known errors
surface first regardless of asset type; unrecognized errors for
contract-ID assets show "Swapping custom tokens is not supported yet."
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: piyalbasu <6789586+piyalbasu@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the asset search + manage-assets flow to correctly handle Stellar Expert search results that return Soroban contract IDs (C…) alongside classic {code}-{issuer} assets, and improves related balance matching and swap error messaging.
Changes:
- Update
findAssetBalanceto match Soroban assets bybalance.contractIdwhen the searched asset issuer is a contract ID. - Extend Stellar Expert asset search mapping to build
ManageAssetCurrencyrows for contract-ID records using Stellar Expert-provided metadata. - Add unit + e2e coverage for contract-ID search behavior (manage assets button state + add-token flow) and add a swap error helper for custom-token swap messaging.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| extension/src/popup/helpers/balance.ts | Adds contract-ID branch to findAssetBalance so owned Soroban tokens are detected via contractId. |
| extension/src/popup/helpers/tests/balance.test.js | Adds unit tests covering classic and contract-ID matching behavior for findAssetBalance. |
| extension/src/popup/components/swap/SwapAmount/hooks/useSimulateSwapData.tsx | Extracts swap error selection into getSwapErrorMessage and adds a custom-token swap message for contract-ID assets. |
| extension/src/popup/components/swap/SwapAmount/hooks/tests/useSimulateSwapData.test.ts | Adds unit tests for getSwapErrorMessage behavior across classic/contract assets and error shapes. |
| extension/src/popup/components/manageAssets/SearchAsset/hooks/useAssetLookup.ts | Maps Stellar Expert contract-ID records into ManageAssetCurrency rows using metadata fields (code/name/decimals/domain/tomlInfo). |
| extension/e2e-tests/helpers/stubs.ts | Adds Stellar Expert search stub that returns a contract-ID record with realistic tomlInfo.issuer divergence. |
| extension/e2e-tests/addAssetContractSearch.test.ts | Adds e2e coverage for contract-ID search results: owned-token ellipsis state, not-owned “Add” state, and full add-token confirmation flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The Stellar Expert API now returns contract IDs (C...) alongside classic {code}-{issuer} assets. Route contract-ID results through the token lookup flow and fix findAssetBalance to match by contractId so already-added tokens show the correct button state.
Covers the full add-token flow when Stellar Expert returns a contract ID instead of {code}-{issuer}: search -> click Add -> confirm on the ToggleToken page.
The previous assertion failed because it matched multiple rows. Use the specific ManageAssetRowButton__ellipsis-E2E test ID to assert the owned contract token shows the ellipsis menu instead of "Add".
The check is invariant to the loop iteration — hoisting it makes the three lookup strategies (native, contract, classic) distinct top-level branches.
Agent-Logs-Url: https://github.com/stellar/freighter/sessions/01d13312-6e53-44c0-936a-8b25cf011859
Stellar Expert already returns code, token_name, decimals, domain, and tomlInfo for contract ID records. Use this data to build ManageAssetCurrency rows directly instead of making redundant RPC calls via fetchTokenData.
tomlInfo.issuer can be a different address than the token's own contract ID. Always use record.asset (the token contract) as issuer so findAssetBalance correctly matches balance.contractId. Update stub to use a divergent tomlInfo.issuer to prevent this class of bug from passing tests silently.
Extract swap error logic into getSwapErrorMessage helper. Known errors surface first regardless of asset type; unrecognized errors for contract-ID assets show "Swapping custom tokens is not supported yet."