Bugfix/contract id search#2679
Conversation
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>
…earch
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>
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>
- 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>
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>
There was a problem hiding this comment.
Pull request overview
This PR updates the popup asset search flow to correctly handle Stellar Expert search results that return Soroban contract IDs (in addition to classic CODE-ISSUER assets), and ensures ownership detection works for contract-based token balances.
Changes:
- Extend
useAssetLookupto detect contract IDs from Stellar Expert results and resolve them via the existing token lookup flow. - Update
findAssetBalanceto match Soroban balances bycontractIdwhen the “issuer” is a contract ID. - Add unit tests for
findAssetBalanceand new Playwright E2E coverage for searching/adding contract-ID-returned tokens.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| extension/src/popup/helpers/balance.ts | Adds contract-id matching in findAssetBalance for Soroban token balances. |
| extension/src/popup/helpers/tests/balance.test.js | Adds unit tests covering classic vs contract-id balance matching. |
| extension/src/popup/components/manageAssets/SearchAsset/hooks/useAssetLookup.ts | Parses Stellar Expert results into classic rows vs contract IDs, then fetches token details for contract IDs. |
| extension/e2e-tests/addAssetContractSearch.test.ts | Adds E2E tests covering “already added”, “Add”, and add-confirm flows for contract-ID search results. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
extension/src/popup/components/manageAssets/SearchAsset/hooks/useAssetLookup.ts
Outdated
Show resolved
Hide resolved
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/stellar/freighter/sessions/01d13312-6e53-44c0-936a-8b25cf011859 Co-authored-by: piyalbasu <6789586+piyalbasu@users.noreply.github.com>
Applied both changes from the review in commit 45e00f0:
|
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>
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>
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>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #2677
This pull request adds comprehensive support and testing for assets identified by contract IDs (Soroban tokens) throughout the extension, especially in asset search, balance lookup, and swap error handling. It introduces new e2e and unit tests, improves the asset lookup logic to handle contract ID results from Stellar Expert, and ensures user-friendly error messages when attempting unsupported swaps with contract assets.
Contract ID (Soroban token) support in asset search and balances:
addAssetContractSearch.test.ts,helpers/stubs.ts) [1] [2]code,token_name,decimals, and TOML info. (useAssetLookup.ts) [1] [2] [3]findAssetBalancehelper to match balances by contract ID for Soroban tokens, with new unit tests verifying classic and contract asset handling. (balance.ts,balance.test.js) [1] [2] [3]Swap error handling improvements:
getSwapErrorMessage) that surfaces clear, user-friendly error messages when swaps involve contract ID assets, including a specific message for unsupported custom token swaps, and added thorough unit tests. (useSimulateSwapData.tsx,useSimulateSwapData.test.ts) [1] [2] [3]These changes ensure the extension can robustly handle Soroban contract tokens in asset management and provide clear feedback to users during swaps and asset searches.