Skip to content

chore(runway): cherry-pick fix(bridge): fix: cp-7.47.3 prevent crash when viewing Solana asset details#16776

Merged
tommasini merged 2 commits into
release/7.47.3from
runway-cherry-pick-7.47.3-1751073432
Jun 30, 2025
Merged

chore(runway): cherry-pick fix(bridge): fix: cp-7.47.3 prevent crash when viewing Solana asset details#16776
tommasini merged 2 commits into
release/7.47.3from
runway-cherry-pick-7.47.3-1751073432

Conversation

@runway-github

@runway-github runway-github Bot commented Jun 28, 2025

Copy link
Copy Markdown
Contributor

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

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

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

  • I've followed MetaMask Coding
    Standards
  • 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 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 86633c5

…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
@runway-github runway-github Bot requested a review from a team as a code owner June 28, 2025 01:17
@github-actions

Copy link
Copy Markdown
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.

@metamaskbot metamaskbot added the team-runway-bot-deprecated DEPRECATED: please use "team-bots" instead label Jun 28, 2025
@github-actions

github-actions Bot commented Jun 29, 2025

Copy link
Copy Markdown
Contributor

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 1cec747
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/56bccd22-b5b2-4b20-8cb8-f6257a0cc166

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@tommasini tommasini requested a review from a team June 29, 2025 17:03
@github-actions

github-actions Bot commented Jun 29, 2025

Copy link
Copy Markdown
Contributor

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: ebf835e
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/e10cdbcf-0bbd-46a1-bd8a-87cbfc89cb96

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@sonarqubecloud

Copy link
Copy Markdown

@tommasini tommasini merged commit 0f20b95 into release/7.47.3 Jun 30, 2025
39 of 41 checks passed
@tommasini tommasini deleted the runway-cherry-pick-7.47.3-1751073432 branch June 30, 2025 09:36
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

team-runway-bot-deprecated DEPRECATED: please use "team-bots" instead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants