chore(runway): cherry-pick fix(perps): extract payment token init into useInitPerpsPaymentToken hook and move it to the parent cp-7.73.0#28579
Merged
chloeYue merged 2 commits intorelease/7.73.0from Apr 9, 2026
Conversation
…o useInitPerpsPaymentToken hook and move it to the parent cp-7.73.0 (#28545) ## **Description** The `PerpsPayRow` component contained ~110 lines of payment token initialization logic (pending config syncing, default token selection, asset-change resets) mixed in with its rendering concerns. This made the component harder to follow and impossible to unit-test the initialization behavior in isolation. This PR extracts that logic into a dedicated `useInitPerpsPaymentToken` hook and calls it from `PerpsOrderViewContentBase` instead. The hook encapsulates: - Syncing the pay token from `pendingTradeConfiguration` when resuming an order - Falling back to the highest-balance allowlist token when the user has no perps balance - Resetting state when the traded asset changes - Cleaning up the controller's selected payment token on unmount A `key` prop keyed on `payToken.symbol` was also added to the `PerpsSlider` so it recomputes width when the payment token changes, keeping the slider range in sync, allowing the user to use the slider ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: #28539 ## **Manual testing steps** ```gherkin Feature: Perps payment token initialization Scenario: user opens a perps order with some perps balance and other tokens Given the user selects USDC on Arbitrum When user navigates changes the amount to a different amount Then the USDC on Arbitrum should be still selected And user should be able to use slider if they have enough balance to cover the trade ``` ## **Screenshots/Recordings** ### **Before** N/A ### **After** N/A ## **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 - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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] > **Medium Risk** > Touches Perps payment-token selection/init logic and its interaction with `PerpsController`/confirmation pay-token state, which could affect default token selection and persisted pending configs if incorrect. > > **Overview** > Moves Perps “pay with” token initialization/sync logic out of `PerpsPayRow` into a new `useInitPerpsPaymentToken` hook, and runs it from `PerpsOrderView` so pending trade config, default-token fallback, asset-change resets, and unmount cleanup are handled at the screen level. > > Simplifies `PerpsPayRow` to be a pure display/navigation row (dropping the `initialAsset` prop) and updates tests accordingly, while adding focused unit tests for `useInitPerpsPaymentToken`. > > Adds a `key` to `PerpsSlider` based on `payToken.symbol` to force a re-mount when the payment token changes, keeping the slider’s range/width in sync. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d3a7d10. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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 |
|
michalconsensys
approved these changes
Apr 9, 2026
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
The
PerpsPayRowcomponent contained ~110 lines of payment tokeninitialization logic (pending config syncing, default token selection,
asset-change resets) mixed in with its rendering concerns. This made the
component harder to follow and impossible to unit-test the
initialization behavior in isolation.
This PR extracts that logic into a dedicated
useInitPerpsPaymentTokenhook and calls it from
PerpsOrderViewContentBaseinstead. The hookencapsulates:
pendingTradeConfigurationwhen resumingan order
no perps balance
A
keyprop keyed onpayToken.symbolwas also added to thePerpsSliderso it recomputes width when the payment token changes,keeping the slider range in sync, allowing the user to use the slider
Changelog
CHANGELOG entry: null
Related issues
Fixes: #28539
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
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
Medium Risk
Touches Perps payment-token selection/init logic and its interaction
with
PerpsController/confirmation pay-token state, which could affectdefault token selection and persisted pending configs if incorrect.
Overview
Moves Perps “pay with” token initialization/sync logic out of
PerpsPayRowinto a newuseInitPerpsPaymentTokenhook, and runs itfrom
PerpsOrderViewso pending trade config, default-token fallback,asset-change resets, and unmount cleanup are handled at the screen
level.
Simplifies
PerpsPayRowto be a pure display/navigation row (droppingthe
initialAssetprop) and updates tests accordingly, while addingfocused unit tests for
useInitPerpsPaymentToken.Adds a
keytoPerpsSliderbased onpayToken.symbolto force are-mount when the payment token changes, keeping the slider’s
range/width in sync.
Reviewed by Cursor Bugbot for commit
d3a7d10. Bugbot is set up for automated
code reviews on this repo. Configure
here.