Skip to content

fix: prevent uncaught error from missing crypto object on order data cp-7.72.0#27884

Merged
Akaryatrh merged 3 commits into
mainfrom
fix/TRAM-3393
Mar 30, 2026
Merged

fix: prevent uncaught error from missing crypto object on order data cp-7.72.0#27884
Akaryatrh merged 3 commits into
mainfrom
fix/TRAM-3393

Conversation

@Akaryatrh

@Akaryatrh Akaryatrh commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Description

Summary

This PR addresses the recurring Cannot read property "network" of undefined error encountered by some users during the offramp flow.

Context

The issue was identified via multiple user reports and there was already a previous fix for a similar issue. Users reported that after being redirected back from the provider's widget to the MetaMask app, the application crashed.
This issue is a blocker for users.

More info can be found on this Slack thread.

Changes

Added defensive checks to ensure the network object is properly initialized before access.

Next actions

Investigation is ongoing with providers to understand why crypto object could be missing in some occasion on order data.

Changelog

CHANGELOG entry: prevent app crash caused by missing crypto object from order data

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3393
Ongoing investigation: https://consensyssoftware.atlassian.net/browse/RAMP-451

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

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 all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Low risk defensive null-checking in SendTransaction plus tests; main behavior change is the screen and send action now no-op/return null when required crypto/network data is missing, which could hide the CTA for malformed orders but prevents crashes.

Overview
Prevents the offramp SendTransaction screen from crashing when an order returns without cryptoCurrency (or missing cryptoCurrency.network).

transactionAnalyticsPayload now uses optional chaining for provider/payment/currency fields, and handleSend early-returns if chainId is unavailable; the view also returns null when cryptoCurrency is missing.

Adds/updates tests to cover missing/partial order data (including analytics assertions and ensuring addTransaction is not invoked) and refreshes snapshots accordingly.

Written by Cursor Bugbot for commit bdd0b0f. This will update automatically on new commits. Configure here.

@Akaryatrh Akaryatrh requested a review from a team as a code owner March 24, 2026 17:41
@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-be-trade BE Trade team label Mar 24, 2026
@github-actions github-actions Bot added size-S risk-low Low testing needed · Low bug introduction risk labels Mar 24, 2026
@Akaryatrh Akaryatrh added the team-money-movement issues related to Money Movement features label Mar 24, 2026
…order data

Signed-off-by: Sébastien Van Eyck <sebastien.vaneyck@consensys.net>
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 25, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/Ramp/Aggregator/Views/SendTransaction/SendTransaction.test.tsx Outdated
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 25, 2026
georgeweiler
georgeweiler previously approved these changes Mar 25, 2026
@Akaryatrh Akaryatrh changed the title fix: prevent uncaught error from missing crypto object on order data fix: prevent uncaught error from missing crypto object on order data cp-7.71.0 Mar 25, 2026
@metamaskbot metamaskbot requested a review from a team as a code owner March 26, 2026 07:59
Comment thread android/app/build.gradle
Comment thread ios/MetaMask.xcodeproj/project.pbxproj
Comment thread bitrise.yml
@Akaryatrh Akaryatrh changed the title fix: prevent uncaught error from missing crypto object on order data cp-7.71.0 fix: prevent uncaught error from missing crypto object on order data Mar 26, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeRamps
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are isolated to the off-ramp SendTransaction view within the Ramp Aggregator. The fix adds optional chaining (?.) to safely access nested properties (cryptoCurrency?.network?.chainId, paymentMethod?.id, etc.) and adds an early return guard when chainId is missing, preventing crashes when order data is partially populated. The snapshot update is a minor artifact of test ordering. No shared components, controllers, Engine, or navigation are affected. SmokeRamps directly covers off-ramp (sell crypto) flows including the SendTransaction screen. No dependent tags are required per the tag descriptions.

Performance Test Selection:
This is a purely defensive null-check bug fix with no changes to rendering logic, data loading, state management, or UI structure. No performance impact is expected.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
18 value mismatches detected (expected — fixture represents an existing user).
View details

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.59%. Comparing base (62f6136) to head (bdd0b0f).
⚠️ Report is 45 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27884      +/-   ##
==========================================
+ Coverage   82.56%   82.59%   +0.03%     
==========================================
  Files        4825     4841      +16     
  Lines      123955   124527     +572     
  Branches    27617    27768     +151     
==========================================
+ Hits       102346   102858     +512     
- Misses      14560    14595      +35     
- Partials     7049     7074      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@Akaryatrh Akaryatrh changed the title fix: prevent uncaught error from missing crypto object on order data fix: prevent uncaught error from missing crypto object on order data cp-7.72.0 Mar 27, 2026
@Akaryatrh Akaryatrh enabled auto-merge March 27, 2026 12:32
@Akaryatrh Akaryatrh added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit 417a6fa Mar 30, 2026
192 checks passed
@Akaryatrh Akaryatrh deleted the fix/TRAM-3393 branch March 30, 2026 12:01
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 30, 2026
@metamaskbot metamaskbot added the release-7.73.0 Issue or pull request that will be included in release 7.73.0 label Mar 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-low Low testing needed · Low bug introduction risk size-S team-be-trade BE Trade team team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants