Skip to content

refactor(ramp): dedupe hasMinimumRequiredVersion into shared util#31944

Open
asalsys wants to merge 1 commit into
mainfrom
refactor/MCWP-666-dedupe-ramp-hasMinimumRequiredVersion
Open

refactor(ramp): dedupe hasMinimumRequiredVersion into shared util#31944
asalsys wants to merge 1 commit into
mainfrom
refactor/MCWP-666-dedupe-ramp-hasMinimumRequiredVersion

Conversation

@asalsys

@asalsys asalsys commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

The Ramp module had a local hasMinimumRequiredVersion helper in app/components/UI/Ramp/utils/ that duplicated version-check logic already provided by app/util/remoteFeatureFlag. The helper was not imported anywhere in production code — useDepositEnabled maintained its own inline copy of the same logic.

This PR removes the unused Ramp utility and updates useDepositEnabled to use the shared hasMinimumRequiredVersion implementation.

Reason for change: Avoid maintaining duplicate version-check helpers that can drift over time.

Improvement: Deposit feature gating now uses the same version comparison helper as the rest of the app, with coverage retained in app/util/remoteFeatureFlag/index.test.ts and useDepositEnabled.test.ts.

Changelog

CHANGELOG entry: null

Related issues

Fixes: MCWP-666

Manual testing steps

N/A — internal refactor with no user-facing behavior change. Verified via unit tests:

  • yarn jest app/util/remoteFeatureFlag/index.test.ts
  • yarn jest app/components/UI/Ramp/Deposit/hooks/useDepositEnabled.test.ts

Screenshots/Recordings

N/A — no UI changes.

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Made with Cursor

Remove the unused Ramp-local version check helper and update
useDepositEnabled to use the canonical implementation from
app/util/remoteFeatureFlag.

Co-authored-by: Cursor <cursoragent@cursor.com>
@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.

@mm-token-exchange-service mm-token-exchange-service Bot added the team-mobile-platform Mobile Platform team label Jun 17, 2026
@mm-token-exchange-service

mm-token-exchange-service Bot commented Jun 17, 2026

Copy link
Copy Markdown

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Pre-merge author checklist has unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The PR makes three changes:

  1. useDepositEnabled.ts - Refactored to use the shared hasMinimumRequiredVersion from app/util/remoteFeatureFlag instead of a local inline implementation. The logic also slightly changed: the isFeatureEnabled parameter was removed from the shared utility, so the hook now explicitly checks depositActiveFlag && !!depositMinimumVersionFlag && hasMinimumRequiredVersion(depositMinimumVersionFlag).

  2. Ramp/utils/hasMinimumRequiredVersion.ts - Deleted (local implementation removed in favor of shared utility).

  3. Ramp/utils/hasMinimumRequiredVersion.test.ts - Deleted (tests for the deleted file).

This is a refactoring/consolidation PR that moves the hasMinimumRequiredVersion utility to a shared location (app/util/remoteFeatureFlag). The shared utility has a slightly different signature (no isFeatureEnabled parameter), so the calling code in useDepositEnabled.ts was updated to handle the feature flag check separately.

The useDepositEnabled hook controls whether the MetaMask Card deposit feature is accessible to users. This directly affects the SmokeMoney tag which covers MetaMask Card and fiat on/off-ramp flows including deposit. The change is low-risk (refactoring with equivalent logic), but should be validated to ensure the deposit feature gate still works correctly.

No other feature areas are impacted — this is isolated to the Ramp/Deposit feature gating logic.

Performance Test Selection:
The changes are a refactoring of a utility function used for feature flag version gating. This does not affect any performance-sensitive flows such as app launch, login, onboarding, swaps, asset loading, or other performance-measured scenarios. No performance tests are needed.

View GitHub Actions results

@asalsys asalsys self-assigned this Jun 17, 2026
@asalsys asalsys marked this pull request as ready for review June 17, 2026 21:18
@asalsys asalsys requested a review from a team as a code owner June 17, 2026 21:18
@github-actions github-actions Bot added the risk:low AI analysis: low risk label Jun 17, 2026
@asalsys asalsys enabled auto-merge June 17, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low AI analysis: low risk size-M team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant