chore(runway): cherry-pick fix: prevent uncaught error from missing crypto object on order data cp-7.72.0#28090
Merged
Conversation
…rypto object on order data cp-7.72.0 (#27884) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **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](consensys-vertical-apps/va-mmcx-onramp-api#894) 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](https://consensys.slack.com/archives/C03P2H287N2/p1771581292456779). ### 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** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** ```gherkin 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. <!-- CURSOR_SUMMARY --> --- > [!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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit bdd0b0f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Signed-off-by: Sébastien Van Eyck <sebastien.vaneyck@consensys.net>
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
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found All E2E tests pre-selected. |
|
Contributor
|
✅ E2E Fixture Validation — Schema is up to date |
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
Summary
This PR addresses the recurring
Cannot read property "network" of undefinederror 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
cryptoobject 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
Screenshots/Recordings
Before
After
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
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
SendTransactionplus tests; mainbehavior 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
SendTransactionscreen from crashing when anorder returns without
cryptoCurrency(or missingcryptoCurrency.network).transactionAnalyticsPayloadnow uses optional chaining forprovider/payment/currency fields, and
handleSendearly-returns ifchainIdis unavailable; the view also returnsnullwhencryptoCurrencyis missing.Adds/updates tests to cover missing/partial order data (including
analytics assertions and ensuring
addTransactionis not invoked) andrefreshes snapshots accordingly.
Written by Cursor
Bugbot for commit
bdd0b0f. This will update automatically
on new commits. Configure
here.
Signed-off-by: Sébastien Van Eyck sebastien.vaneyck@consensys.net 417a6fa