fix: prefer selected evm account#30253
Conversation
|
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. |
90862bc to
054bf27
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 054bf27. Configure here.
eec46e9 to
d3e5f0c
Compare
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
This is a medium-risk refactoring that changes how the selected EVM account is resolved across all perps operations. While the logic is equivalent (with an improved primary path), any regression could break:
Tags selected:
Performance Test Selection: |
|




Description
This PR updates Perps account resolution so compliance gated Perps flows evaluate the same EVM account the user currently has selected.
As part of the compliance work, Perps needs to reliably identify the active wallet address before allowing account specific actions such as deposits, trades, signing, and account state operations. The previous logic derived the address from the selected account group, which could pick a different EVM account than the user facing selected account when multiple EVM accounts exist in the group.
The solution adds a selected-account-first lookup across the Perps controller and related services. Perps now reads
AccountsController:getSelectedAccountwhen it is an EVM account, and falls back to the existing selected account group behavior when needed. The PR also delegates that action through the Perps controller messenger so the selected account path works at runtime.This keeps Perps address resolution aligned with the active wallet while preserving compatibility with the existing account group fallback path.
This also wires Perps cache invalidation to selected-account changes, so switching between EVM accounts in the same account group clears stale user data and preloads data for the newly selected account.
Changelog
CHANGELOG entry: Prefer the selected EVM account when resolving Perps account state and compliance-gated actions.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Changes how Perps resolves the active wallet address and when it clears/preloads cached user data, which can impact deposits/signing and account-scoped state if the new selection logic misidentifies the active account.
Overview
Perps now resolves the active EVM address by preferring
AccountsController:getSelectedAccount(when it’s an EVM account) and falling back to the selected account group, via newgetSelectedEvmAccountFromMessengerhelpers.This selection logic is applied across
PerpsControllerand related services (deposit/withdrawal, wallet adapters, rewards, data lake reporting), and market/user-data preloading now also listens toAccountsController:selectedAccountChangeto clear disk+memory user cache and refresh data on account switches. Tests were added/updated to cover selected-account preference, cache invalidation, and messenger delegation.Reviewed by Cursor Bugbot for commit b6c41c9. Bugbot is set up for automated code reviews on this repo. Configure here.