port contract id search back to master#2684
Conversation
There was a problem hiding this comment.
Pull request overview
Ports contract-ID (Soroban token) support into master so the extension can handle Stellar Expert asset search results that return contract token IDs instead of only {code}-{issuer} identifiers.
Changes:
- Update balance lookup to match Soroban balances by contract ID.
- Enhance asset search mapping to construct
ManageAssetCurrencyrows from Stellar Expert contract-ID records. - Add unit + e2e test coverage for contract-ID asset search and swap error messaging.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| extension/src/popup/helpers/balance.ts | Adds contract-ID matching branch in findAssetBalance. |
| extension/src/popup/helpers/tests/balance.test.js | Adds unit tests for classic vs contract-ID balance matching. |
| extension/src/popup/components/swap/SwapAmount/hooks/useSimulateSwapData.tsx | Centralizes swap error display logic and adds contract-ID-specific messaging. |
| extension/src/popup/components/swap/SwapAmount/hooks/tests/useSimulateSwapData.test.ts | Adds unit tests for getSwapErrorMessage. |
| extension/src/popup/components/manageAssets/SearchAsset/hooks/useAssetLookup.ts | Maps Stellar Expert contract-ID search records into Manage Assets rows. |
| extension/e2e-tests/helpers/stubs.ts | Adds Stellar Expert asset-search stub returning a contract-ID record. |
| extension/e2e-tests/addAssetContractSearch.test.ts | Adds e2e coverage for contract-ID search results (“Already Added”, “Add”, and add-flow). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (isContractId(record.asset)) { | ||
| return { | ||
| code: record.code || record.tomlInfo?.code || "", | ||
| issuer: record.asset, | ||
| contract: record.asset, |
There was a problem hiding this comment.
The Stellar Expert search mapping now emits contract-ID assets (issuer/contract both set to the contract ID). Downstream in this hook, BlockAid bulk scanning builds asset_ids as ${code}-${issuer} for all returned rows when the search term is not a contract ID; that will end up scanning code-<contractId> for these results, which the existing logic/comments indicate is intended only for classic assets. Consider filtering contract-ID rows out of the BlockAid scan path (e.g., skip rows where isContractId(row.issuer) / row.contract is set) or updating the scan identifier format if BlockAid supports contract assets.
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Applied in commit 6441f61. Added !isContractId(record.issuer) guard in addBlockaidScanResults so contract-ID rows (where issuer is a Soroban contract ID) are skipped when building asset_ids for the BlockAid bulk scan — preventing malformed ${code}-${contractId} identifiers from being sent.
Agent-Logs-Url: https://github.com/stellar/freighter/sessions/37246841-df9c-403e-9682-316d0b343ee1 Co-authored-by: piyalbasu <6789586+piyalbasu@users.noreply.github.com>
Closes #2677
Porting the changes from #2679 to the master branch