fix(perps): sync pending payment token and reset on asset change cp-7.72.0#28086
Conversation
Move appliedPendingTokenRef assignment before state updates to prevent stale ref reads. Add cleanup effect to reset selectedPaymentToken when initialAsset changes. Broaden sync guard to also reconcile selectedPaymentToken with pending config.
|
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. |
There was a problem hiding this comment.
Automation status: blocked for DSYS-616 migration-docs workflow.
This run is in MetaMask/metamask-mobile on branch cursor/mmds-component-migration-docs-8efb, but the requested task targets MetaMask/metamask-design-system.
Required docs targets are not present in this workspace:
packages/design-system-react/MIGRATION.mdpackages/design-system-react-native/MIGRATION.mdpackages/design-system-react/src/components/{ComponentName}/README.mdxpackages/design-system-react-native/src/components/{ComponentName}/README.md
Additionally, the required Atlassian/Jira MCP integration is unavailable in this run (atlassian MCP server not found), so the DSYS-616 story/component cannot be sourced from Jira.
Per the audit/quality gate, the run is stopped without code changes, lint, or PR updates.
Please re-run this automation in MetaMask/metamask-design-system with Atlassian MCP configured.
Sent by Cursor Automation: DSYS-616: MMDS - Create/Update migration docs
…le sync Move the ref assignment before the if-block so pending config is marked as handled even when payToken/selectedPaymentToken already match. This prevents the sync effect from re-firing and overwriting a user's manual token selection on subsequent re-renders.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|
✅ E2E Fixture Validation — Schema is up to date |
|






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
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
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
initialAssetby clearingPerpsController.setSelectedPaymentTokenon asset change and ensuring pending token config is re-applied for the new asset.Adjusts pending-config sync so it can apply even when
selectedPaymentTokenisnull, and only re-syncs when either thepayTokenor 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.