You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
I've clearly explained what problem this PR solves
I've linked the issue that this PR fixes
I've included manual testing steps
I've included screenshots/recordings if applicable
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:
// Detect if address is already in CAIP formatconstisCaipAssetType=asset.address.startsWith(`${asset.chainId}`);// Convert to CAIP format if neededconstnormalizedCaipAssetTypeAddress=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
amitabh94
changed the title
fix(bridge): prevent crash when viewing Solana asset details
fix(bridge): fix: cp-7.47.3 prevent crash when viewing Solana asset details
Jun 27, 2025
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
getTokenDetailsassuming 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
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
Pre-merge reviewer checklist
Solution Details
Root Cause
The
getTokenDetailsfunction was callingparseCaipAssetTypedirectly onasset.addressfor non-EVM assets, assuming it was already in CAIP format. However, the Bridge API sometimes returns raw Solana addresses instead of CAIP-formatted addresses, causingparseCaipAssetTypeto throw an error.Fix Applied
Implemented the same defensive approach used in
useTokenHistoricalPrices:Benefits
useTokenHistoricalPricesTesting