chore(runway): cherry-pick fix(bridge): fix: cp-7.47.3 prevent crash when viewing Solana asset details#16776
Merged
Conversation
…when viewing Solana asset details (#16770) ## **Description** Fixes a crash that occurs when viewing asset details for Solana tokens in the Bridge flow. The issue was caused by `getTokenDetails` assuming all non-EVM asset addresses are already in CAIP format, when the Bridge API sometimes returns raw Solana addresses. ## **Related issues** Fixes #16734 Fixes [SWAPS-2525](https://consensyssoftware.atlassian.net/browse/SWAPS-2525) ## **Manual testing steps** 1. Navigate to Bridge feature 2. Select Solana as source or destination chain 3. Select any Solana token from the token list 4. Tap on the asset detail info button 5. Verify the asset details screen loads without crashing 6. Verify contract address and other details display correctly ## **Screenshots/Recordings** <!-- Add screenshots or recordings demonstrating the fix --> **Before:** https://github.com/user-attachments/assets/cf41e9fa-ae3d-4336-aefe-40017e831364 **After:** https://github.com/user-attachments/assets/ccacf57e-1971-42c4-a3d7-a3978e7c954b ## **Pre-merge author checklist** - [x] I've followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md) - [x] I've clearly explained what problem this PR solves - [x] I've linked the issue that this PR fixes - [x] I've included manual testing steps - [x] I've included screenshots/recordings if applicable - [x] I've added unit tests if applicable ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed) - [ ] I confirm that this PR addresses the issue linked above - [ ] I've checked that all unit tests pass ## **Solution Details** ### **Root Cause** The `getTokenDetails` function was calling `parseCaipAssetType` directly on `asset.address` for non-EVM assets, assuming it was already in CAIP format. However, the Bridge API sometimes returns raw Solana addresses instead of CAIP-formatted addresses, causing `parseCaipAssetType` to throw an error. ### **Fix Applied** Implemented the same defensive approach used in `useTokenHistoricalPrices`: ```typescript // Detect if address is already in CAIP format const isCaipAssetType = asset.address.startsWith(`${asset.chainId}`); // Convert to CAIP format if needed const normalizedCaipAssetTypeAddress = isCaipAssetType ? asset.address : `${asset.chainId}/token:${asset.address}`; ``` ### **Benefits** - ✅ **Fixes crash**: Solana asset details now load without errors - ✅ **Backward compatible**: Handles both raw and CAIP format addresses - ✅ **Consistent pattern**: Uses same approach as `useTokenHistoricalPrices` - ✅ **Zero breaking changes**: All existing functionality preserved - ✅ **Future-proof**: Works with any non-EVM chain automatically ### **Testing** - Added comprehensive unit tests covering both scenarios - All 12 tests pass including new test cases - Verified with existing Bridge test suite - Manual testing confirms crash is resolved [SWAPS-2525]: https://consensyssoftware.atlassian.net/browse/SWAPS-2525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Contributor
|
Contributor
|
|
tommasini
approved these changes
Jun 30, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.



Description
Fixes a crash that occurs when viewing asset details for Solana tokens
in the Bridge flow. The issue was caused by
getTokenDetailsassumingall non-EVM asset addresses are already in CAIP format, when the Bridge
API sometimes returns raw Solana addresses.
Related issues
Fixes #16734
Fixes
SWAPS-2525
Manual testing steps
Screenshots/Recordings
Before:
ScreenRecording_06-25-2025.17-44-43_1.MOV
After:
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-06-27.at.14.16.00.mp4
Pre-merge author checklist
Standards
Pre-merge reviewer checklist
app, test code being changed)
Solution Details
Root Cause
The
getTokenDetailsfunction was callingparseCaipAssetTypedirectlyon
asset.addressfor non-EVM assets, assuming it was already in CAIPformat. However, the Bridge API sometimes returns raw Solana addresses
instead of CAIP-formatted addresses, causing
parseCaipAssetTypetothrow an error.
Fix Applied
Implemented the same defensive approach used in
useTokenHistoricalPrices:Benefits
useTokenHistoricalPricesTesting
SWAPS-2525:
https://consensyssoftware.atlassian.net/browse/SWAPS-2525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ 86633c5