Skip to content

chore(runway): cherry-pick fix(perps): sync pending payment token and reset on asset change cp-7.72.0#28252

Merged
chloeYue merged 1 commit into
release/7.72.0from
runway-cherry-pick-7.72.0-1775040184
Apr 1, 2026
Merged

chore(runway): cherry-pick fix(perps): sync pending payment token and reset on asset change cp-7.72.0#28252
chloeYue merged 1 commit into
release/7.72.0from
runway-cherry-pick-7.72.0-1775040184

Conversation

@runway-github

@runway-github runway-github Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Description

When switching between perps assets (e.g. from BTC to ETH), the "Pay
with" token selection could get out of sync — the pending config from
the previous asset would either not be restored or would conflict with
the newly selected asset's payment token.

Changelog

CHANGELOG entry: Fixed payment token not restoring correctly when
switching between perps assets

Related issues

Fixes jira issue:
https://consensyssoftware.atlassian.net/browse/TAT-2785

Manual testing steps

Feature: Perps pay-with token persistence across asset switches

  Scenario: User switches perps asset and pending pay token is restored
    Given the user has a pending pay-with token config saved for ETH perps
    And the user is currently viewing BTC perps order view

    When the user switches to ETH perps
    Then the pay-with token row displays the previously saved payment token for ETH

  Scenario: User switches asset and controller state is reset
    Given the user is viewing BTC perps with a selected payment token

    When the user switches to ETH perps
    Then the controller's selectedPaymentToken is reset to null
    And the new asset's pending config (if any) is applied

  Scenario: User opens perps with no prior selectedPaymentToken in controller
    Given the user has a pending pay-with config but no selectedPaymentToken in the controller

    When the user opens the perps order view
    Then the pending config is applied and the correct pay token is displayed

Screenshots/Recordings

N/A — no UI changes, logic-only fix in payment token sync.

Before

N/A

After

N/A

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

Medium Risk
Touches perps payment-token synchronization logic and controller state
resets, which can affect what token a user trades with across asset
switches. Changes are localized and covered by new unit tests, but
regressions could impact user transaction configuration.

Overview
Fixes perps “Pay with” token desynchronization when switching
initialAsset by clearing PerpsController.setSelectedPaymentToken
on asset change
and ensuring pending token config is re-applied for
the new asset.

Adjusts pending-config sync so it can apply even when
selectedPaymentToken is null, and only re-syncs when either the
payToken or controller-selected token differs from the pending token
(avoiding unnecessary overwrites). Adds targeted tests covering
asset-change cleanup and the new sync edge cases.

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

[596bf1e](https://github.com/MetaMask/metamask-mobile/commit/596bf1ee866be45dfc92be06029cd3967ccdf7fc)

… reset on asset change cp-7.72.0 (#28086)

## **Description**

When switching between perps assets (e.g. from BTC to ETH), the "Pay
with" token selection could get out of sync — the pending config from
the previous asset would either not be restored or would conflict with
the newly selected asset's payment token.


## **Changelog**

CHANGELOG entry: Fixed payment token not restoring correctly when
switching between perps assets

## **Related issues**

Fixes jira issue:
https://consensyssoftware.atlassian.net/browse/TAT-2785

## **Manual testing steps**

```gherkin
Feature: Perps pay-with token persistence across asset switches

  Scenario: User switches perps asset and pending pay token is restored
    Given the user has a pending pay-with token config saved for ETH perps
    And the user is currently viewing BTC perps order view

    When the user switches to ETH perps
    Then the pay-with token row displays the previously saved payment token for ETH

  Scenario: User switches asset and controller state is reset
    Given the user is viewing BTC perps with a selected payment token

    When the user switches to ETH perps
    Then the controller's selectedPaymentToken is reset to null
    And the new asset's pending config (if any) is applied

  Scenario: User opens perps with no prior selectedPaymentToken in controller
    Given the user has a pending pay-with config but no selectedPaymentToken in the controller

    When the user opens the perps order view
    Then the pending config is applied and the correct pay token is displayed
```

## **Screenshots/Recordings**

N/A — no UI changes, logic-only fix in payment token sync.

### **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 synchronization logic and controller state
resets, which can affect what token a user trades with across asset
switches. Changes are localized and covered by new unit tests, but
regressions could impact user transaction configuration.
> 
> **Overview**
> Fixes perps “Pay with” token desynchronization when switching
`initialAsset` by **clearing `PerpsController.setSelectedPaymentToken`
on asset change** and ensuring pending token config is re-applied for
the new asset.
> 
> Adjusts pending-config sync so it can apply even when
`selectedPaymentToken` is `null`, and only re-syncs when either the
`payToken` *or* controller-selected token differs from the pending token
(avoiding unnecessary overwrites). Adds targeted tests covering
asset-change cleanup and the new sync edge cases.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ed6e439. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github Bot requested a review from a team as a code owner April 1, 2026 10:43
@github-actions

github-actions Bot commented Apr 1, 2026

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-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Apr 1, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk size-M and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 1, 2026

@chloeYue chloeYue 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.

LGTM

@chloeYue chloeYue added the skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run label Apr 1, 2026
@github-actions github-actions Bot added the risk-high Extensive testing required · High bug introduction risk label Apr 1, 2026
@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found

All E2E tests pre-selected.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented Apr 1, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Apr 1, 2026

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

@chloeYue chloeYue merged commit 871a63e into release/7.72.0 Apr 1, 2026
360 of 367 checks passed
@chloeYue chloeYue deleted the runway-cherry-pick-7.72.0-1775040184 branch April 1, 2026 16:34
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk-high Extensive testing required · High bug introduction risk size-M skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants